Repository: acoto87/war1 Branch: master Commit: 5a6070277e64 Files: 230 Total size: 60.9 MB Directory structure: gitextract__n2furko/ ├── .clangformat ├── .github/ │ └── workflows/ │ └── build.yml ├── .gitignore ├── ANALYSIS.md ├── LICENSE ├── README.md ├── assets/ │ └── GMGeneric.SF2 ├── cinematics.txt ├── deps/ │ ├── include/ │ │ ├── SDL3/ │ │ │ ├── SDL.h │ │ │ ├── SDL_assert.h │ │ │ ├── SDL_asyncio.h │ │ │ ├── SDL_atomic.h │ │ │ ├── SDL_audio.h │ │ │ ├── SDL_begin_code.h │ │ │ ├── SDL_bits.h │ │ │ ├── SDL_blendmode.h │ │ │ ├── SDL_camera.h │ │ │ ├── SDL_clipboard.h │ │ │ ├── SDL_close_code.h │ │ │ ├── SDL_copying.h │ │ │ ├── SDL_cpuinfo.h │ │ │ ├── SDL_dialog.h │ │ │ ├── SDL_dlopennote.h │ │ │ ├── SDL_egl.h │ │ │ ├── SDL_endian.h │ │ │ ├── SDL_error.h │ │ │ ├── SDL_events.h │ │ │ ├── SDL_filesystem.h │ │ │ ├── SDL_gamepad.h │ │ │ ├── SDL_gpu.h │ │ │ ├── SDL_guid.h │ │ │ ├── SDL_haptic.h │ │ │ ├── SDL_hidapi.h │ │ │ ├── SDL_hints.h │ │ │ ├── SDL_init.h │ │ │ ├── SDL_intrin.h │ │ │ ├── SDL_iostream.h │ │ │ ├── SDL_joystick.h │ │ │ ├── SDL_keyboard.h │ │ │ ├── SDL_keycode.h │ │ │ ├── SDL_loadso.h │ │ │ ├── SDL_locale.h │ │ │ ├── SDL_log.h │ │ │ ├── SDL_main.h │ │ │ ├── SDL_main_impl.h │ │ │ ├── SDL_messagebox.h │ │ │ ├── SDL_metal.h │ │ │ ├── SDL_misc.h │ │ │ ├── SDL_mouse.h │ │ │ ├── SDL_mutex.h │ │ │ ├── SDL_oldnames.h │ │ │ ├── SDL_opengl.h │ │ │ ├── SDL_opengl_glext.h │ │ │ ├── SDL_opengles.h │ │ │ ├── SDL_opengles2.h │ │ │ ├── SDL_opengles2_gl2.h │ │ │ ├── SDL_opengles2_gl2ext.h │ │ │ ├── SDL_opengles2_gl2platform.h │ │ │ ├── SDL_opengles2_khrplatform.h │ │ │ ├── SDL_pen.h │ │ │ ├── SDL_pixels.h │ │ │ ├── SDL_platform.h │ │ │ ├── SDL_platform_defines.h │ │ │ ├── SDL_power.h │ │ │ ├── SDL_process.h │ │ │ ├── SDL_properties.h │ │ │ ├── SDL_rect.h │ │ │ ├── SDL_render.h │ │ │ ├── SDL_revision.h │ │ │ ├── SDL_scancode.h │ │ │ ├── SDL_sensor.h │ │ │ ├── SDL_stdinc.h │ │ │ ├── SDL_storage.h │ │ │ ├── SDL_surface.h │ │ │ ├── SDL_system.h │ │ │ ├── SDL_test.h │ │ │ ├── SDL_test_assert.h │ │ │ ├── SDL_test_common.h │ │ │ ├── SDL_test_compare.h │ │ │ ├── SDL_test_crc32.h │ │ │ ├── SDL_test_font.h │ │ │ ├── SDL_test_fuzzer.h │ │ │ ├── SDL_test_harness.h │ │ │ ├── SDL_test_log.h │ │ │ ├── SDL_test_md5.h │ │ │ ├── SDL_test_memory.h │ │ │ ├── SDL_thread.h │ │ │ ├── SDL_time.h │ │ │ ├── SDL_timer.h │ │ │ ├── SDL_touch.h │ │ │ ├── SDL_tray.h │ │ │ ├── SDL_version.h │ │ │ ├── SDL_video.h │ │ │ └── SDL_vulkan.h │ │ ├── TinySoundFont/ │ │ │ ├── tml.h │ │ │ └── tsf.h │ │ ├── TracyC.h │ │ ├── shl/ │ │ │ ├── array.h │ │ │ ├── binary_heap.h │ │ │ ├── flic.h │ │ │ ├── list.h │ │ │ ├── map.h │ │ │ ├── memory_buffer.h │ │ │ ├── memzone.h │ │ │ ├── memzone_audit.h │ │ │ ├── queue.h │ │ │ ├── set.h │ │ │ ├── shl_internal.h │ │ │ ├── stack.h │ │ │ ├── wav.h │ │ │ └── wstr.h │ │ └── stb/ │ │ ├── stb_image.h │ │ ├── stb_image_resize.h │ │ └── stb_image_write.h │ └── lib/ │ ├── arm64/ │ │ ├── libSDL3.so.0 │ │ └── libSDL3.so.0.5.0 │ ├── linux64/ │ │ ├── libSDL3.so.0 │ │ └── libSDL3.so.0.5.0 │ ├── win32/ │ │ ├── SDL3.lib │ │ ├── Tracy.lib │ │ └── libSDL3.dll.a │ └── win64/ │ ├── SDL3.lib │ ├── Tracy.lib │ └── libSDL3.dll.a ├── docs/ │ ├── ACTION_SYSTEM.md │ ├── ANIMATION_SYSTEM.md │ ├── COMMANDS_SYSTEM.md │ ├── ENTITIES_SYSTEM.md │ ├── INPUT_SYSTEM.md │ ├── SCENES_SYSTEM.md │ ├── STATE_MACHINE_SYSTEM.md │ └── UI_SYSTEM.md ├── nob.c ├── nob.h ├── src/ │ ├── common.h │ ├── war.h │ ├── war1.c │ ├── war_actions.c │ ├── war_actions.h │ ├── war_ai.c │ ├── war_ai.h │ ├── war_alloc.c │ ├── war_alloc.h │ ├── war_animations.c │ ├── war_animations.h │ ├── war_audio.c │ ├── war_audio.h │ ├── war_campaigns.c │ ├── war_campaigns.h │ ├── war_cheats.c │ ├── war_cheats.h │ ├── war_cheats_panel.c │ ├── war_color.h │ ├── war_commands.c │ ├── war_commands.h │ ├── war_database.h │ ├── war_entities.c │ ├── war_entities.h │ ├── war_enums.h │ ├── war_file.c │ ├── war_file.h │ ├── war_font.c │ ├── war_font.h │ ├── war_fwd.h │ ├── war_game.c │ ├── war_game.h │ ├── war_imui.c │ ├── war_imui.h │ ├── war_log.c │ ├── war_log.h │ ├── war_map.c │ ├── war_map.h │ ├── war_map_menu.c │ ├── war_map_menu.h │ ├── war_map_ui.c │ ├── war_map_ui.h │ ├── war_math.c │ ├── war_math.h │ ├── war_net.c │ ├── war_net.h │ ├── war_pathfinder.c │ ├── war_pathfinder.h │ ├── war_projectiles.c │ ├── war_projectiles.h │ ├── war_render.c │ ├── war_render.h │ ├── war_resources.c │ ├── war_resources.h │ ├── war_roads.c │ ├── war_ruins.c │ ├── war_scene_blizzard.c │ ├── war_scene_blizzard.h │ ├── war_scene_briefing.c │ ├── war_scene_briefing.h │ ├── war_scene_download.c │ ├── war_scene_download.h │ ├── war_scene_menu.c │ ├── war_scene_menu.h │ ├── war_scenes.c │ ├── war_scenes.h │ ├── war_sprites.c │ ├── war_sprites.h │ ├── war_state_machine.c │ ├── war_state_machine.h │ ├── war_state_machine_attack.c │ ├── war_state_machine_build.c │ ├── war_state_machine_cast.c │ ├── war_state_machine_chopping.c │ ├── war_state_machine_collapse.c │ ├── war_state_machine_death.c │ ├── war_state_machine_deliver.c │ ├── war_state_machine_follow.c │ ├── war_state_machine_gather_gold.c │ ├── war_state_machine_gather_wood.c │ ├── war_state_machine_idle.c │ ├── war_state_machine_mining.c │ ├── war_state_machine_move.c │ ├── war_state_machine_patrol.c │ ├── war_state_machine_repair.c │ ├── war_state_machine_repairing.c │ ├── war_state_machine_train.c │ ├── war_state_machine_upgrade.c │ ├── war_state_machine_wait.c │ ├── war_trees.c │ ├── war_ui.c │ ├── war_ui.h │ ├── war_units.c │ ├── war_units.h │ └── war_walls.c └── todo.md ================================================ FILE CONTENTS ================================================ ================================================ FILE: .clangformat ================================================ # ClangFormat configuration for war1-c # Style: Allman braces, 4-space indent, no tabs, C99/C11 Language: Cpp BasedOnStyle: LLVM # ── Indentation ──────────────────────────────────────────────── IndentWidth: 4 TabWidth: 4 UseTab: Never ContinuationIndentWidth: 4 # ── Brace placement — Allman style ───────────────────────────── BreakBeforeBraces: Allman # ── Braces / short forms — keep nothing on one line ──────────── AllowShortBlocksOnASingleLine: Never AllowShortCaseLabelsOnASingleLine: false AllowShortFunctionsOnASingleLine: None AllowShortIfStatementsOnASingleLine: Never AllowShortLoopsOnASingleLine: false # ── Line length ───────────────────────────────────────────────── ColumnLimit: 120 # ── Pointer / reference alignment ────────────────────────────── # WarContext* context (pointer attached to type) PointerAlignment: Right # ── Includes ──────────────────────────────────────────────────── SortIncludes: false IncludeBlocks: Preserve # ── Spaces ────────────────────────────────────────────────────── SpaceBeforeParens: ControlStatements SpaceInEmptyParentheses: false SpacesInParentheses: false SpacesInSquareBrackets: false SpaceAfterCStyleCast: false SpaceBeforeAssignmentOperators: true SpaceBeforeSquareBrackets: false # ── Operators ─────────────────────────────────────────────────── BreakBeforeBinaryOperators: None BreakBeforeTernaryOperators: true # ── Function call / declaration alignment ────────────────────── AlignAfterOpenBracket: Align BinPackArguments: false BinPackParameters: false AllowAllArgumentsOnNextLine: false AllowAllParametersOfDeclarationOnNextLine: false # ── Trailing commas ───────────────────────────────────────────── InsertTrailingCommas: None # ── Blank lines ───────────────────────────────────────────────── MaxEmptyLinesToKeep: 2 KeepEmptyLinesAtTheStartOfBlocks: false # ── Comments ──────────────────────────────────────────────────── ReflowComments: false SpacesBeforeTrailingComments: 1 # ── Switch/case ───────────────────────────────────────────────── IndentCaseLabels: true IndentCaseBlocks: false # ── Misc ──────────────────────────────────────────────────────── DeriveLineEnding: false UseCRLF: false InsertNewlineAtEOF: true ================================================ FILE: .github/workflows/build.yml ================================================ name: build on: push: branches: - master pull_request: permissions: contents: read jobs: linux: runs-on: ubuntu-latest strategy: fail-fast: false matrix: compiler: - gcc - clang steps: - name: Checkout uses: actions/checkout@v4 - name: Install clang if: matrix.compiler == 'clang' run: sudo apt-get update && sudo apt-get install -y clang - name: Compile nob bootstrap run: ${{ matrix.compiler }} -std=c99 -Wall -Wextra -D_DEFAULT_SOURCE -D_POSIX_C_SOURCE=200809L -o nob nob.c - name: Build project run: ./nob build --cc ${{ matrix.compiler }} --target linux64 rpi: runs-on: ubuntu-24.04-arm strategy: fail-fast: false matrix: compiler: - gcc - clang steps: - name: Checkout uses: actions/checkout@v4 - name: Install clang if: matrix.compiler == 'clang' run: sudo apt-get update && sudo apt-get install -y clang - name: Compile nob bootstrap run: ${{ matrix.compiler }} -std=c99 -Wall -Wextra -D_DEFAULT_SOURCE -D_POSIX_C_SOURCE=200809L -o nob nob.c - name: Build project (Raspberry Pi 4/5 - ARM64) run: ./nob build --cc ${{ matrix.compiler }} --target arm64 --check windows-msvc: runs-on: windows-latest steps: - name: Checkout uses: actions/checkout@v4 - name: Set up MSVC developer command prompt uses: ilammy/msvc-dev-cmd@v1.13.0 - name: Compile nob bootstrap shell: cmd run: cl /nologo /std:c11 /W4 /D_CRT_SECURE_NO_WARNINGS /Fenob.exe nob.c - name: Compile-check project with MSVC shell: cmd run: nob.exe build --cc msvc --target win64 --check ================================================ FILE: .gitignore ================================================ /build/ /.vscode/ build_timings.ctm ctime.exe nob.exe nob.exe.old nob.obj nob flic-file-format output_189.png output_192.png output_195.png tags callgrind* assets/*.WAR .vscode-ctags .markdownlint.json *.pdb ================================================ FILE: ANALYSIS.md ================================================ # War1-C: Comprehensive Project Analysis **Author:** Alejandro Coto Gutierrez **Repository:** https://github.com/acoto87/war1 **License:** zlib **Date:** April 2026 (updated from March 2026) --- ## 1. What Is This Project? **War1-C** is a ground-up reimplementation of *Warcraft: Orcs & Humans* (1994) written in C99/C11. It reads the original game's `DATA.WAR` asset file (from the DOS version) and recreates the full gameplay experience using modern cross-platform libraries. | Layer | Technology | |-------|-------------| | Windowing/Input/Events | SDL3 | | 2D Rendering | SDL3 Renderer (hardware-accelerated) | | Audio | SDL3 Audio + TinySoundFont (MIDI synthesis) | | Data Structures | shl (author's own single-header libraries) | | Build System | `nob.c` (C-based build script) | | Profiling | Tracy C (opt-in via `TRACY_ENABLE`) | | Memory | Custom arena allocators (`memzone_t`) | > **Breaking change since March 2026:** GLFW, NanoVG (OpenGL ES 2.0), and Miniaudio have all been replaced with SDL3 (PR #9). This is the single largest architectural change in the project's history — approximately 100,000 lines of dependency code removed and replaced. **Targets:** Windows 64-bit (MSVC), Linux x86_64, Raspberry Pi ARM64. *(Windows 32-bit dropped; Raspberry Pi 32-bit replaced with ARM64.)* **Codebase:** ~35,000+ lines of C across ~56 source files (after the war_types.h breakup and war_units.c expansion), compiled as a **unity build** (single translation unit — all `.c` files `#include`d into `war1.c`). --- ## 2. Implemented Features ### Core Engine - **Game loop:** Classic `input → update → render → present` at 60 FPS using `SDL_PollEvent` / `SDL_RenderPresent` - **Scene system:** Download → Blizzard Splash → Main Menu → Custom Game Menu → Briefing → Map (gameplay) - **Asset pipeline:** Full `DATA.WAR` archive parser with 583 indexed entries (supports both retail and demo versions) - **Custom bitmap font system** recreated pixel-by-pixel from the original game - **Build system:** `nob.c` C-based build script with `--cc` and `--target` flags, replacing per-platform shell scripts - **CI/CD:** GitHub Actions pipeline building on linux64 (gcc + clang), arm64, and win64 (MSVC) on every push and PR - **Memory management:** Custom arena allocator with `permanentZone` (512 MB) and `frameZone` (4 MB); all subsystems route allocations through `wm_alloc()`/`wm_free()` - **Profiling:** Tracy C profiler integrated with 41 zones across game loop, AI, pathfinder, entity system, and animations - **Logging:** Thread-safe logging via SDL3's `SDL_LogMessage`, routing all `logInfo`/`logError`/`logWarning` calls through a single `wlog_log()` function ### Gameplay — Fully Functional - **All 30+ unit types** from the original game (both Human and Orc rosters) - **All buildings** (Farm, Barracks, Town Hall, Church/Temple, Tower, Lumber Mill, Stable/Kennel, Blacksmith, Keep/Spire, Gold Mine) - **Full unit state machine** with 19 states: Idle, Move, Patrol, Follow, Attack, Gold Gathering, Mining, Wood Gathering, Chopping, Deliver, Death, Collapse, Train, Upgrade, Build, Repair, Repairing, Cast, Wait - **Resource management:** Gold mining (workers enter mine, extract, deliver) and wood chopping (chop trees, carry lumber, deliver) - **Building construction** with placement validation, build progress, and completion - **Unit training** from buildings with resource cost enforcement - **Upgrades** (weapons, armor, spells) from appropriate buildings - **Combat:** Melee and ranged attacks with proper damage calculation - **Projectile system:** Arrows, fireballs, catapult rocks with splash damage - **All 10 spells:** Healing, Far Sight/Dark Vision, Invisibility, Unholy Armor, Rain of Fire, Poison Cloud, Raise Dead, Summon (Spider, Scorpion, Daemon, Water Elemental) - **A\* pathfinding** with static and dynamic entity avoidance - **Fog of war** with three states (unknown, fog, visible), timed decay, and sight radius - **Full audio:** All 45 MIDI tracks, all sound effects, spatial audio attenuation, separate volume controls - **Complete HUD:** Minimap, unit portraits, contextual command buttons, resource counters, status bar - **Campaign:** All 24 maps defined (12 Human, 12 Orc) with briefing text and voiceovers - **Custom games:** Custom game menu scene, map selection, 21+ maps across Forest, Swamp, and Dungeon tilesets - **Cheat system:** All original cheats + custom development cheats (god mode, unit spawning, map editing, music/volume control, speed/scale adjustment, add unit) --- ## 3. What Is Left to Implement ### Critical Missing Features | Feature | Status | Notes | |---------|--------|-------| | **AI System** | ~20–25% done | Request/Wait/Sleep commands execute. Attack/Defend commands are defined but fall through to `logWarning`. Building creation code is a stub returning `true` without doing anything. Still hardcoded to `players[1]` only. | | **Campaign Win/Loss Conditions** | ~8% done | Only maps 01 (Human) and 02 (Orc) check objectives. Remaining 22 maps never detect victory or defeat. | | **Save/Load** | 0% | `wmm_handleGameOverSave` calls `NOT_IMPLEMENTED()`. No serialization code exists. | | **Cinematics** | 0% | All 40 FLIC animation files catalogued. `shl/flic.h` reader exists in `deps/`. No playback scene. | | **Multiplayer** | 0% | Main menu "Multi Player" button is a dead end. `war_net.c` only handles HTTP asset download. | | **Dialogues** | 0% | No dialogue system. | ### Gameplay Polish (from `todo.md`) - Palette variation for unit portraits per tileset - NPC explosion animation on repeated clicking - Ctrl+click to select all units of same type on screen - Rally points for trained units - Animated water/blue-water tiles - Zoom feature - State machine return values (so Follow can tell Attack that target is unreachable) - Better diagonal movement cost in pathfinding - Actions system description (documentation) - Idle units do not retaliate when attacked - Worker collision near town hall during resource delivery ### Technical Debt - Component dictionary instead of each entity having all components - Remove BFS pathfinding implementation (superseded by A\*) - Multi-sprite support for entities - Separate animation rendering pass (render animations above everything else) - Better minimap layering - Dialogue system - Cutscene system (FLIC playback) - `rewriteAppendCheatTextInput` and `downloadFileFromUrl` to use `wstr`/`StringView`-friendly implementations --- ## 4. Confirmed Bugs ### Fixed Since March 2026 The following bugs from the previous analysis have been resolved: 1. ~~**Copy-paste bug in palette colors**~~ — Fixed in `wres_getPalette()`. Green and blue channels are now correctly indexed from `palette2`. 2. ~~**Wrong unit type for Orc Blacksmith**~~ — Fixed: `wcmd_buildBlacksmithOrcs` now passes `WAR_UNIT_BLACKSMITH_ORCS`. 3. ~~**Wrong unit type for Raider training**~~ — Fixed: `wcmd_trainRaider` now passes `WAR_UNIT_RAIDER`. 4. ~~**Logic bug in projectile type check**~~ — Fixed: condition is now `&&` (`type != FIREBALL && type != RAIN_OF_FIRE`). 5. ~~**Integer division kills audio interpolation**~~ — Fixed: `wa_changeSampleRate` now uses `1.0f / (f32)factor` with proper linear interpolation between samples. 6. ~~**Wrong loop variable in UI button reset**~~ — Fixed: inner loop now correctly uses `buttons->items[j]`. 7. ~~**`sizeof` instead of `arrayLength`**~~ — Fixed: `war_render.c` now uses `arrayLength(colors)`. 8. ~~**~84 instances of unbounded `sprintf`/`strcpy`/`vsprintf`**~~ — Dramatically reduced; only 2 remaining (see below). ### Active Bugs #### 1. Duplicate macro definition in `war_units.c` - **File:** `src/war_units.c:6,14` - **Issue:** `#define WSV_INIT(s) { s, sizeof(s) - 1 }` is defined twice at lines 6 and 14. Under `-Wpedantic` this is a benign redefinition, but it is dead code that will confuse editors and should be removed. #### 2. Two remaining `strcpy` calls - **File:** `src/war_net.c` — `strcpy(cut, urlStr + shift)` — buffer overflow risk if `urlStr` is malformed. - **File:** `src/war_resources.c` — `strcpy(resource->levelInfo.objectives, ...)` — relies on the destination buffer being large enough for the raw level data. - **Recommendation:** Replace both with `strncpy` or a length-checked copy. #### 3. AI building creation is a silent no-op - **File:** `src/war_ai.c:176–187` - **Issue:** `wai_tryCreateUnit()` for building types immediately `return true` with a TODO comment. A `WAR_AI_COMMAND_REQUEST` for any building type will mark itself complete without spawning anything. The AI scripting will silently succeed without creating any buildings. #### 4. AI hardcoded to a single player index - **File:** `src/war_ai.c:127,360` - **Issue:** Both `wai_initAIPlayers` and `wai_updateAIPlayers` hardcode `players[1]`. On any map with more than one AI opponent this is wrong. The multi-player AI will not run. #### 5. AI Attack/Defend commands unimplemented - **File:** `src/war_ai.c:264–269` - **Issue:** `WAR_AI_COMMAND_ATTACK` and `WAR_AI_COMMAND_DEFEND` hit the `default` case which logs a warning and returns `true`. Any AI script that issues attack or defend commands will silently do nothing. #### 6. Memory leak on unknown file type - **File:** `src/war_file.c:40-42` - **Issue:** Returns `NULL` without freeing the allocated `warFile` struct or closing the file handle on unrecognised file types. ### Pre-Existing High-Risk Issues (still unresolved) 7. **Potential crash from NULL entity manager** (`src/war_entities.c`): `getEntityManager()` can return `NULL`; callers dereference without checking. 8. **Possible crash with 0 selected entities** (`src/war_commands.c`): `selectedEntities.items[0]` accessed in code paths where `selectedEntities.count` could be 0. 9. **VLA buffer overflow in HTTP request** (`src/war_net.c`): Buffer may be too small for multi-line HTTP headers. 10. **AI commands never freed** (`src/war_ai.c:316–331`): `WarAICommandListRemoveAt` removes from list but the `WarAICommand*` pointer is never `wm_free()`d. Permanent zone leak per completed command. 11. **Entities never fully freed** (`src/war_entities.c`): Components cleaned up but the `WarEntity` struct itself is never returned to the allocator. ### Bugs from `todo.md` (Unresolved) 12. **Cursor escapes window** — OS cursor appears outside game window. 13. **Pathfinding edge case** — Last path position occupied by another entity; behavior undefined. 14. **Memory leaks in animation removal**. 15. **Linux rendering** — Global scale renders incorrectly on Linux after a scale change. 16. **UI drag bug** — Dragging from a button to the map panel starts a selection rectangle. 17. **Idle units don't retaliate** when attacked. 18. **Worker collision near town hall** during resource delivery. 19. **Invisible worker bug** — Worker enters mine but doesn't mine; remains commandable. 20. **Audio saturation** from rapid order commands. 21. **Sprite antialiasing lines** visible between sprites on Windows. --- ## 5. Architecture Analysis ### Current Architecture ``` war1.c (entry point + unity build root) ├── war_game.c (game loop: input → update → render → present) │ ├── war_scenes.c (scene stack management) │ │ ├── war_scene_blizzard.c │ │ ├── war_scene_download.c │ │ ├── war_scene_menu.c (main menu + custom game menu) │ │ └── war_scene_briefing.c │ └── war_map.c (main gameplay scene) │ ├── war_entities.c (ECS-like entity/component system) │ ├── war_commands.c (command dispatch) │ ├── war_state_machine*.c (19 behavior states) │ ├── war_pathfinder.c (A*) │ ├── war_ai.c (enemy AI — partial) │ ├── war_projectiles.c │ └── war_map_ui.c / war_map_menu.c ├── war_resources.c + war_file.c (DATA.WAR asset loading) ├── war_render.c + war_font.c (SDL3 renderer) ├── war_audio.c (SDL3 Audio + TinySoundFont, separate thread) ├── war_alloc.c (arena allocator — permanentZone + frameZone) └── war_log.c (thread-safe SDL3-backed logging) ``` **Key design patterns:** - **Entity-Component System** (ECS-like): `WarEntity` has components (sprite, unit, button, animation, etc.) - **Hierarchical State Machine**: Units driven by enter/update/leave callbacks per state - **Scene Stack**: Scenes managed as a stack with push/pop semantics - **Unity Build**: Entire codebase compiled as one translation unit via `war1.c` - **Arena Allocation**: All game memory allocated from two `memzone_t` arenas; no scattered `malloc`/`free` in game code - **Forward Declaration Header**: `war_fwd.h` centralises all forward declarations for the now-decomposed type system ### Architectural Strengths 1. **Clean state machine decomposition** — Each of the 19 unit states is in its own file with clear enter/update/leave contracts. Well-organised and easy to extend. 2. **Unified arena memory model** — The `wm_alloc`/`wm_free`/`wm_realloc` API backed by `memzone_t` is now threaded throughout the entire codebase including third-party libraries (TinySoundFont, stb_image, shl). This eliminates fragmentation, enables debug auditing with `memzone_audit.h`, and makes leak tracking possible. 3. **SDL3 unification** — Replacing three separate dependencies (GLFW, NanoVG, Miniaudio) with a single SDL3 layer dramatically reduces the dependency surface. SDL3 handles windowing, input, 2D rendering, audio, threading, and timing under one API with better long-term maintenance guarantees. 4. **Self-contained build system** — `nob.c` is a single C file that bootstraps with one compiler command and drives the full build. Combined with GitHub Actions CI (linux64 GCC+Clang, arm64, win64 MSVC), every commit is compile-verified across all supported targets. 5. **Accurate original game data integration** — The 583-entry `war_database.h` maps every asset in `DATA.WAR` by index. Faithfully reads original game assets including custom map loading. 6. **Tracy profiler integration** — 41 instrumented zones across the game loop, AI, pathfinding, entity system, and animations allow real profiling sessions without code modification. Zero overhead when `TRACY_ENABLE` is not defined. 7. **Thread-safe logging** — The previous global `__log__` state and mutex is gone; `wlog_log()` delegates to `SDL_LogMessage` which is thread-safe by design, fixing the audio thread vs main thread stdout corruption. ### Architectural Weaknesses & Improvement Ideas #### 1. Monolithic Entity Structure (unchanged) **Problem:** `WarEntity` contains ALL component types as direct struct members. Every entity carries the full weight of every possible component regardless of its type. **Recommendation:** Move to a proper ECS with components stored in separate arrays/pools indexed by entity ID. Already in `todo.md`. Would reduce memory footprint and improve cache coherence significantly. The arena allocator makes this refactor safer — a per-component-type pool can be carved from the permanent zone. #### 2. Unity Build Limits Development Velocity **Problem:** `war1.c` compiles everything as a single translation unit. Any change recompiles all 35 000+ lines. `nob.c` uses `--check` mode for compile verification but cannot do incremental builds. This is manageable for a solo project, but will become a bottleneck for contributors. **Note:** The `nob.c` build system does compile the project; the unity build is a deliberate design choice. The issue is that there is no way to compile only the changed files. A CMakeLists.txt companion (compile-only mode) could enable IDE integration and faster iteration without abandoning the unity build for release. #### 3. AI Architecture Needs a Rethink **Problem:** The current AI is a linear command script (`WarAICustomData::commands` array walked by index). This works for simple build-order sequences but cannot represent reactive behaviour (defend when attacked, retreat when losing). Attack/Defend commands exist in the enum but are unimplemented. Building creation is a stub. The system is hard-coded to `players[1]`. **Recommendation:** The scripted command queue is a solid foundation. The next step is: 1. Fix the multi-player loop (iterate all players with `player->ai != NULL`). 2. Implement building creation (find a free worker, find a buildable tile, issue a repair state). 3. Implement attack: select military units and issue a move-to-attack order towards the enemy base. 4. Add a reactive layer: a periodic `wai_scanThreats()` function that inserts defend commands when friendly units take damage. #### 4. `war_units.c` Centralisation Risk **Problem:** `war_units.c` has grown to ~2 771 lines and is the single source of truth for all unit stats, upgrade data, upgrade names, feature names, and build time constants. While well-structured, any mistake here silently corrupts game balance data for all unit types. **Recommendation:** Add compile-time `static_assert` guards verifying array lengths against the corresponding enum `_COUNT` values. This catches off-by-one errors in stat tables at compile time. #### 5. Unsafe String Handling (nearly resolved, 2 remaining) **Problem:** The original ~84 instances of `sprintf`/`strcpy`/`vsprintf` have been resolved almost entirely. Two `strcpy` calls remain: - `src/war_net.c`: URL parsing without bounds check. - `src/war_resources.c`: Level objectives text copy. **Recommendation:** Replace both with `strncpy` + explicit null-termination, or a safer helper. #### 6. No Tests (unchanged) **Problem:** Zero test files. No test framework. Critical systems like pathfinding, state machines, combat damage, resource management, and DATA.WAR parsing have no automated verification. The CI only checks that the code *compiles* — it does not verify correctness. **Recommendation:** Add unit tests for: - Pathfinding (A\* correctness with known obstacle maps) - Damage calculation - Resource cost enforcement - State machine transitions - DATA.WAR file parsing --- ## 6. Recent Change Log Analysis (Last ~25 Commits) ### What Changed and Why It Matters | PR / Commit | Change | Impact | |---|---|---| | PR #9 | **SDL3 migration** — removed GLFW, NanoVG (OpenGL ES), Miniaudio | Eliminates ~100 kloc of deps; single unified API; better portability | | PR #8 + String 1 | **`nob.c` + GitHub Actions CI** | Every commit now compile-verified on 3 platforms/4 compilers | | PR #10 | **Unity build cleanup** — each `.c` file got proper guards and headers | Fixes include ordering; eliminates order-dependent compile errors | | PR #11 | **Prefix refactor** — `io.c`/`log.c` absorbed into `war_log.c`; `__log__` global removed | Thread-safety; cleaner API surface | | PR #12 | **`wstr.h` / `memzone.h`** added to shl; Linux SDL3 lib added | Foundation for string refactor and arena allocator | | PR #13 | **StringView + cheat refactor** — `str.c`/`str.h` removed; `shl/wstr.h` and `shl/wav.h` adopted | Safer, non-owning string passing throughout cheat and UI text paths | | PR #14 | **Memory + audio refactor** — `war_alloc.c` introduced; Tracy added; all allocs routed through `wm_*` | Arena model; debug auditing; profiling infrastructure | | PR #15 | **Full function prefix rename** across all 85 source files | Naming conventions now consistently applied; greatly aids code search | | PR #16 | **`war_types.h` decomposed** — types moved into module headers; `war_fwd.h` for forward decls; `war_units.c` fully populated | Reduced header coupling; `war_units.c` now ~2771 lines of authoritative unit data | | AI commits | **AI command system** — request/wait/sleep execute; attack/defend stubbed | Foundation for AI is solid; execution layer is partially complete | | Custom game commits | **Custom game menu + map loading** | Enables AI development and testing without playing campaign maps | --- ## 7. Potential New Development Directions ### High-Value, Feasible 1. **Complete the AI system** — The command infrastructure exists. The highest-leverage work is: (a) multi-player loop, (b) building-construction execution, (c) basic army attack logic. These three items would make AI opponents functional in custom games and set up campaign AI. 2. **Implement all campaign win/loss conditions** — Only 2 of 24 maps have objectives. The original game's objectives are well-documented and the framework already handles the two working cases. Filling in the remaining 22 is largely mechanical. 3. **Integrate FLIC cinematics** — `shl/flic.h` reader already exists. Needs: a playback scene, frame rendering via SDL3 textures, and campaign sequence integration. 4. **Save/Load system** — `wmm_handleGameOverSave` exists as a stub. With the arena allocator, a binary snapshot of the permanent zone is technically feasible, though a structured approach (serialising `WarMap` + entity list + player state) would be more robust and portable. ### Medium-Term 5. **State machine return values** — The most impactful open state machine issue: Follow cannot currently tell Attack that a target is unreachable, causing an infinite Follow↔Attack loop. Fixing this would resolve one of the most noticeable AI/gameplay bugs. 6. **Component dictionary (ECS refactor)** — Already in `todo.md`. Now that the arena allocator is in place, a per-component-type pool approach is feasible without changing the existing allocation API. 7. **Map editor** — Cheat system already has tree/wall/road/ruins editing. Expanding this into a proper editor with save-to-file would be high value for the modding community. 8. **WebAssembly port** — SDL3 has Emscripten support. The arena allocator (one large static buffer) maps naturally to WASM. A browser-playable version would greatly increase accessibility. ### Ambitious / Long-Term 9. **Multiplayer (LAN/Online)** — The command system is centralised and the game loop is deterministic, which is the correct foundation for lockstep networking. The `war_net.c` HTTP stack would need to be repurposed or a separate networking layer added. 10. **Higher resolution rendering** — The game renders at 320×200 scaled up via SDL3's logical presentation. Mode using upscaling filters (xBRZ, HQ2x) could modernise visuals without touching the game logic. 11. **Steam Deck / Console ports** — SDL3 is portable to all major platforms including consoles. The main work would be controller input mapping and resolution adaptation. --- ## 8. Summary of Priorities | Priority | Task | Impact | |----------|------|--------| | **P0** | Fix AI building-creation stub (currently returns `true` silently) | AI correctness | | **P0** | Fix AI hardcoded to `players[1]` | Multi-AI maps | | **P0** | Fix 2 remaining `strcpy` calls | Security/stability | | **P0** | Fix duplicate `WSV_INIT` macro in `war_units.c` | Code hygiene | | **P1** | Implement AI Attack/Defend command execution | Makes AI fight back | | **P1** | Complete campaign win/loss conditions (22 remaining maps) | Campaign completable | | **P2** | Fix state machine return values (Follow → Attack unreachable loop) | Gameplay polish | | **P2** | Integrate FLIC cinematics playback | Campaign polish | | **P2** | Implement Save/Load | Player quality of life | | **P3** | ECS refactor (component dictionary) | Memory and cache efficiency | | **P3** | Fix memory leaks (AI commands never freed, entities never freed) | Stability for long sessions | | **P3** | Add compile-time `static_assert` guards in `war_units.c` | Data correctness | | **P4** | Add unit tests | Long-term maintainability | | **P4** | WebAssembly port | Accessibility | | **P5** | Multiplayer | Feature expansion | --- ## Conclusion This project has made substantial architectural improvements since the March 2026 snapshot. The SDL3 migration eliminated three large dependency stacks in favour of a single well-maintained library. The `nob.c` build system and GitHub Actions CI — previously absent entirely — now provide multi-platform compile verification on every commit. The arena-based memory model and Tracy profiler integration put the project on a professional footing for performance work. The naming conventions and `war_types.h` decomposition have significantly improved code navigability. The core gameplay loop remains fully functional. The highest-leverage remaining work is completing the AI system to make single-player against an opponent actually playable, then filling in the 22 missing campaign objective checks to make the full campaign completable. With those two items done, this would be a faithfully playable recreation of the original game. The foundational architecture is sound. The main gaps are feature completeness (AI, campaign, cinematics, save/load) rather than structural problems. ================================================ FILE: LICENSE ================================================ zlib License (C) 2019 Alejandro Coto Gutiérrez This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. ================================================ FILE: README.md ================================================ # War1 A remake of Warcraft: Orcs & Humans written in C. This is a remake of the Warcraft: Orcs & Humans game created and published by Blizzard Entertainment in 1994. It pretends to be a complete implementation of the game using only the assets (*.WAR files) from the original game. War1 is not an official Blizzard Entertainment product. It intent to be an enhancement of the original product with modern RTS features. You will need a copy of the original Warcraft: Orcs & Humans MS-DOS (or shareware) version be able to play War1. You can get it here Warcraft: Orcs and Humans. Warcraft and all graphics you see in the game are a registered trademark of Blizzard Entertainment. Current features (this list is not complete): * Path finding and collisions detection * Unit movement with animations * Unit training * Building construction * Resources gathering by peasants and peons * Features specification for maps (this is specify if the player can train, build or research certain units, buildings or spells) * Win/lose condition checking * Fog of war * Basic behavior for enemies (it will attack your units if you get near enough, it will chase your units) * Spells * Typing commands for cheats and other stuff that could be activated by it in the engine Still to develop (this list is not complete): * AI (I'm planning to do a basic one first and build from that more complex ones) * Cinematics (I've the code for reading FLIC files just need to integrate it into the engine) * Save/Load You can check videos of gameplay and features as they are built [here](https://www.youtube.com/playlist?list=PLgN8fwyHpZaY42SjuwAQ4MPJ1rD9w1Kym). ## How to build 1. Clone the repository `git clone https://github.com/acoto87/war1` 2. Get the `DATA.WAR` file and place it in the `assets` folder. 3. Bootstrap the `nob` build entry point with your C compiler of choice: ### Bootstrap with GCC ```sh gcc -std=c99 -Wall -Wextra -D_DEFAULT_SOURCE -D_POSIX_C_SOURCE=200809L -o nob nob.c ``` ### Bootstrap with Clang ```sh clang -std=c99 -Wall -Wextra -D_DEFAULT_SOURCE -D_POSIX_C_SOURCE=200809L -o nob nob.c ``` ### Bootstrap with MSVC ```bat cl /nologo /std:c11 /W4 /D_CRT_SECURE_NO_WARNINGS /Fenob.exe nob.c ``` 4. Build the project with `nob`: ### Linux 64-bit ```sh ./nob build --cc gcc --target linux64 ./nob build --cc clang --target linux64 ``` ### Windows ```bat nob.exe build --cc gcc --target win32 nob.exe build --cc gcc --target win64 ``` MSVC currently supports compile validation with `--check`: ```bat nob.exe build --cc msvc --target win64 --check ``` ### Raspberry Pi ```sh ./nob build --cc gcc --target arm32 ``` The legacy `build-gcc-*.sh` and `build-gcc-*.bat` scripts are still available, but `nob.c` is now the main build entry point. ## How to run Since I'm not able to distribute the DATA.WAR file, which contains the original assets, there is a little process to get the game working properly (this applies if you don't own a copy of the game that you can purchase here [Warcraft: Orcs and Humans](https://www.gog.com/game/warcraft_orcs_and_humans)). If you own an original copy of the game, or just bought the game on GOG, find the file DATA.WAR and just copy and paste it into the War 1 folder, and execute war1.exe. Or just start the game and there is an option within the game to download the file. If you don't own the original game and want to try it with the demo version, just download the demo version of [DATA.WAR](https://archive.org/download/WarcraftOrcsHumansDemo/WCRFT.ZIP/DEMODATA%2FDATA.WAR). Or just start the game and there is an option within the game to download the file. If you want to check were that file comes from, it's from here: https://archive.org/details/WarcraftOrcsHumansDemo. If you click SEE ALL in the DOWNLOADS section you will see a WCRFT.ZIP (View Contents) entry, just click on View Contents and there is a line with the DATA.WAR file of the demo version. ## Libraries used * [SDL3](https://libsdl.org/): A cross-platform development library designed to provide low-level access to audio, keyboard, mouse, joystick, and graphics hardware. * [TinySoundFont](https://github.com/schellingb/TinySoundFont) SoundFont2 synthesizer. * [shl](https://github.com/acoto87/shl): Single header libraries with commonly used data structures. * [stb](https://github.com/nothings/stb) Single-file public domain libraries for C/C++ Here is my [TODO](https://github.com/acoto87/war1/blob/master/todo.md) list. ## Other Warcraft 1 re-implementations: * [War1gus](https://wargus.github.io/war1gus.html): War1gus is a re-implementation of "Warcraft: Orcs & Humans" that allows you to play Warcraft with the Stratagus engine. * [OpenWar](https://phix.itch.io/openwar): OpenWar is an alternative Warcraft: Orcs & Humans game engine. * [Warcraft Remake](http://www.b3dgs.com/v7/page.php?lang=en§ion=warcraft_remake): Warcraft Remake is a remake of the classic Blizzard game. * [WinWar](https://github.com/CAMongrel/WinWar): WinWar is a multiplatform (Windows, WindowsStore, OSX, Linux, iOS) port of the original DOS WarCraft: Orcs & Humans PC Game. ## Screenshots Gifs | Images ------------------------- | ------------------------- ![](https://github.com/acoto87/war1/blob/master/pics/gif1.gif) | ![](https://github.com/acoto87/war1/blob/master/pics/pic1.png) ![](https://github.com/acoto87/war1/blob/master/pics/gif2.gif) | ![](https://github.com/acoto87/war1/blob/master/pics/pic2.png) ![](https://github.com/acoto87/war1/blob/master/pics/gif3.gif) | ![](https://github.com/acoto87/war1/blob/master/pics/pic3.png) ================================================ FILE: cinematics.txt ================================================ File name Scene Length CAVE1 Approaching cave 7.7 secs CAVE2 Loop before cave door 1.7 secs CAVE3 Door opens, view point passes through 2.4 secs HFINALE Fireworks over Stormwind Keep 8.6 secs HINTRO1 Approaching Stormwind Keep 7.2 secs HINTRO2 Loop of flags flying at Stormwind Keep 1.8 secs HMAP01 Intro to human map 3.2 secs HMAP02 Intro to human map 3.3 secs HMAP03 Intro to human map 3.3 secs HMAP04 Intro to human map 3.3 secs HMAP05 Intro to human map 3.3 secs HMAP06 Intro to human map 3.3 secs HMAP07 Intro to human map 3.3 secs HMAP08 Intro to human map 3.3 secs HMAP09 Intro to human map 3.3 secs HMAP10 Intro to human map 3.3 secs HMAP11 Intro to human map 3.3 secs HMAP12 Intro to human map 3.3 secs LOSE1 Approach skeleton on battle field 6.0 secs LOSE2 Loop of burning fires 0.9 secs OFINALE Loop of Orcs w/ spears at a fire 2.1 secs OINTRO1 Approaching Black Rock Spire gate 9.8 secs OINTRO2 Looping fires at Black Rock Spire gate 0.8 secs OINTRO3 Pass through Black Rock Spire gate 3.6 secs OMAP01 Intro to orc map 3.2 secs OMAP02 Intro to orc map 3.3 secs OMAP03 Intro to orc map 3.3 secs OMAP04 Intro to orc map 3.3 secs OMAP05 Intro to orc map 3.3 secs OMAP06 Intro to orc map 3.3 secs OMAP07 Intro to orc map 3.3 secs OMAP08 Intro to orc map 3.3 secs OMAP09 Intro to orc map 3.3 secs OMAP10 Intro to orc map 3.3 secs OMAP11 Intro to orc map 3.3 secs OMAP12 Intro to orc map 3.3 secs TITLE Zoom in on "Warcraft" title 3.0 secs WIN1 Fly into throne room 5.0 secs WIN2 Looping torches in throne room 0.8 secs ================================================ FILE: deps/include/SDL3/SDL.h ================================================ /* Simple DirectMedia Layer Copyright (C) 1997-2026 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ /** * Main include header for the SDL library, version 3.4.4 * * It is almost always best to include just this one header instead of * picking out individual headers included here. There are exceptions to * this rule--SDL_main.h is special and not included here--but usually * letting SDL.h include the kitchen sink for you is the correct approach. */ #ifndef SDL_h_ #define SDL_h_ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #endif /* SDL_h_ */ ================================================ FILE: deps/include/SDL3/SDL_assert.h ================================================ /* Simple DirectMedia Layer Copyright (C) 1997-2026 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ /** * # CategoryAssert * * A helpful assertion macro! * * SDL assertions operate like your usual `assert` macro, but with some added * features: * * - It uses a trick with the `sizeof` operator, so disabled assertions * vaporize out of the compiled code, but variables only referenced in the * assertion won't trigger compiler warnings about being unused. * - It is safe to use with a dangling-else: `if (x) SDL_assert(y); else * do_something();` * - It works the same everywhere, instead of counting on various platforms' * compiler and C runtime to behave. * - It provides multiple levels of assertion (SDL_assert, SDL_assert_release, * SDL_assert_paranoid) instead of a single all-or-nothing option. * - It offers a variety of responses when an assertion fails (retry, trigger * the debugger, abort the program, ignore the failure once, ignore it for * the rest of the program's run). * - It tries to show the user a dialog by default, if possible, but the app * can provide a callback to handle assertion failures however they like. * - It lets failed assertions be retried. Perhaps you had a network failure * and just want to retry the test after plugging your network cable back * in? You can. * - It lets the user ignore an assertion failure, if there's a harmless * problem that one can continue past. * - It lets the user mark an assertion as ignored for the rest of the * program's run; if there's a harmless problem that keeps popping up. * - It provides statistics and data on all failed assertions to the app. * - It allows the default assertion handler to be controlled with environment * variables, in case an automated script needs to control it. * - It can be used as an aid to Clang's static analysis; it will treat SDL * assertions as universally true (under the assumption that you are serious * about the asserted claims and that your debug builds will detect when * these claims were wrong). This can help the analyzer avoid false * positives. * * To use it: compile a debug build and just sprinkle around tests to check * your code! */ #ifndef SDL_assert_h_ #define SDL_assert_h_ #include #include /* Set up for C function definitions, even when using C++ */ #ifdef __cplusplus extern "C" { #endif #ifdef SDL_WIKI_DOCUMENTATION_SECTION /** * The level of assertion aggressiveness. * * This value changes depending on compiler options and other preprocessor * defines. * * It is currently one of the following values, but future SDL releases might * add more: * * - 0: All SDL assertion macros are disabled. * - 1: Release settings: SDL_assert disabled, SDL_assert_release enabled. * - 2: Debug settings: SDL_assert and SDL_assert_release enabled. * - 3: Paranoid settings: All SDL assertion macros enabled, including * SDL_assert_paranoid. * * \since This macro is available since SDL 3.2.0. */ #define SDL_ASSERT_LEVEL SomeNumberBasedOnVariousFactors #elif !defined(SDL_ASSERT_LEVEL) #ifdef SDL_DEFAULT_ASSERT_LEVEL #define SDL_ASSERT_LEVEL SDL_DEFAULT_ASSERT_LEVEL #elif defined(_DEBUG) || defined(DEBUG) || \ (defined(__GNUC__) && !defined(__OPTIMIZE__)) #define SDL_ASSERT_LEVEL 2 #else #define SDL_ASSERT_LEVEL 1 #endif #endif #ifdef SDL_WIKI_DOCUMENTATION_SECTION /** * Attempt to tell an attached debugger to pause. * * This allows an app to programmatically halt ("break") the debugger as if it * had hit a breakpoint, allowing the developer to examine program state, etc. * * This is a macro--not a function--so that the debugger breaks on the source * code line that used SDL_TriggerBreakpoint and not in some random guts of * SDL. SDL_assert uses this macro for the same reason. * * If the program is not running under a debugger, SDL_TriggerBreakpoint will * likely terminate the app, possibly without warning. If the current platform * isn't supported, this macro is left undefined. * * \threadsafety It is safe to call this macro from any thread. * * \since This macro is available since SDL 3.2.0. */ #define SDL_TriggerBreakpoint() TriggerABreakpointInAPlatformSpecificManner #elif defined(__MINGW32__) || (defined(_MSC_VER) && _MSC_VER >= 1310) /* Don't include intrin.h here because it contains C++ code */ extern void __cdecl __debugbreak(void); #define SDL_TriggerBreakpoint() __debugbreak() #elif defined(_MSC_VER) && defined(_M_IX86) #define SDL_TriggerBreakpoint() { _asm { int 0x03 } } #elif SDL_HAS_BUILTIN(__builtin_debugtrap) #define SDL_TriggerBreakpoint() __builtin_debugtrap() #elif SDL_HAS_BUILTIN(__builtin_trap) #define SDL_TriggerBreakpoint() __builtin_trap() #elif (defined(__GNUC__) || defined(__clang__) || defined(__TINYC__) || defined(__slimcc__)) && (defined(__i386__) || defined(__x86_64__)) #define SDL_TriggerBreakpoint() __asm__ __volatile__ ( "int $3\n\t" ) #elif (defined(__GNUC__) || defined(__clang__)) && defined(__riscv) #define SDL_TriggerBreakpoint() __asm__ __volatile__ ( "ebreak\n\t" ) #elif ( defined(SDL_PLATFORM_APPLE) && (defined(__arm64__) || defined(__aarch64__)) ) /* this might work on other ARM targets, but this is a known quantity... */ #define SDL_TriggerBreakpoint() __asm__ __volatile__ ( "brk #22\n\t" ) #elif defined(SDL_PLATFORM_APPLE) && defined(__arm__) #define SDL_TriggerBreakpoint() __asm__ __volatile__ ( "bkpt #22\n\t" ) #elif defined(_WIN32) && ((defined(__GNUC__) || defined(__clang__)) && (defined(__arm64__) || defined(__aarch64__)) ) #define SDL_TriggerBreakpoint() __asm__ __volatile__ ( "brk #0xF000\n\t" ) #elif defined(__GNUC__) || defined(__clang__) #define SDL_TriggerBreakpoint() __builtin_trap() /* older gcc may not support SDL_HAS_BUILTIN(__builtin_trap) above */ #elif defined(__386__) && defined(__WATCOMC__) #define SDL_TriggerBreakpoint() { _asm { int 0x03 } } #elif defined(HAVE_SIGNAL_H) && !defined(__WATCOMC__) #include #define SDL_TriggerBreakpoint() raise(SIGTRAP) #else /* SDL_TriggerBreakpoint is intentionally left undefined on unknown platforms. */ #endif #ifdef SDL_WIKI_DOCUMENTATION_SECTION /** * A constant that contains the current function being compiled. * * If SDL can't figure how the compiler reports this, it will use "???". * * \since This macro is available since SDL 3.2.0. */ #define SDL_FUNCTION __FUNCTION__ #elif !defined(SDL_FUNCTION) #if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) /* C99 supports __func__ as a standard. */ # define SDL_FUNCTION __func__ #elif ((defined(__GNUC__) && (__GNUC__ >= 2)) || defined(_MSC_VER) || defined (__WATCOMC__)) # define SDL_FUNCTION __FUNCTION__ #else # define SDL_FUNCTION "???" #endif #endif #ifdef SDL_WIKI_DOCUMENTATION_SECTION /** * A macro that reports the current file being compiled. * * This macro is only defined if it isn't already defined, so to override it * (perhaps with something that doesn't provide path information at all, so * build machine information doesn't leak into public binaries), apps can * define this macro before including SDL.h or SDL_assert.h. * * \since This macro is available since SDL 3.2.0. */ #define SDL_FILE __FILE_NAME__ #elif !defined(SDL_FILE) #ifdef __FILE_NAME__ #define SDL_FILE __FILE_NAME__ #else #define SDL_FILE __FILE__ #endif #endif #ifdef SDL_WIKI_DOCUMENTATION_SECTION /** * A macro that reports the current file being compiled, for use in * assertions. * * This macro is only defined if it isn't already defined, so to override it * (perhaps with something that doesn't provide path information at all, so * build machine information doesn't leak into public binaries), apps can * define this macro before including SDL_assert.h. For example, defining this * to `""` will make sure no source path information is included in asserts. * * \since This macro is available since SDL 3.4.0. */ #define SDL_ASSERT_FILE SDL_FILE #elif !defined(SDL_ASSERT_FILE) #define SDL_ASSERT_FILE SDL_FILE #endif /** * A macro that reports the current line number of the file being compiled. * * \since This macro is available since SDL 3.2.0. */ #define SDL_LINE __LINE__ /* sizeof (x) makes the compiler still parse the expression even without assertions enabled, so the code is always checked at compile time, but doesn't actually generate code for it, so there are no side effects or expensive checks at run time, just the constant size of what x WOULD be, which presumably gets optimized out as unused. This also solves the problem of... int somevalue = blah(); SDL_assert(somevalue == 1); ...which would cause compiles to complain that somevalue is unused if we disable assertions. */ #ifdef SDL_WIKI_DOCUMENTATION_SECTION /** * A macro for wrapping code in `do {} while (0);` without compiler warnings. * * Visual Studio with really aggressive warnings enabled needs this to avoid * compiler complaints. * * the `do {} while (0);` trick is useful for wrapping code in a macro that * may or may not be a single statement, to avoid various C language * accidents. * * To use: * * ```c * do { SomethingOnce(); } while (SDL_NULL_WHILE_LOOP_CONDITION (0)); * ``` * * \since This macro is available since SDL 3.2.0. */ #define SDL_NULL_WHILE_LOOP_CONDITION (0) #elif defined(_MSC_VER) /* Avoid /W4 warnings. */ /* "while (0,0)" fools Microsoft's compiler's /W4 warning level into thinking this condition isn't constant. And looks like an owl's face! */ #define SDL_NULL_WHILE_LOOP_CONDITION (0,0) #else #define SDL_NULL_WHILE_LOOP_CONDITION (0) #endif /** * The macro used when an assertion is disabled. * * This isn't for direct use by apps, but this is the code that is inserted * when an SDL_assert is disabled (perhaps in a release build). * * The code does nothing, but wraps `condition` in a sizeof operator, which * generates no code and has no side effects, but avoid compiler warnings * about unused variables. * * \param condition the condition to assert (but not actually run here). * * \since This macro is available since SDL 3.2.0. */ #define SDL_disabled_assert(condition) \ do { (void) sizeof ((condition)); } while (SDL_NULL_WHILE_LOOP_CONDITION) /** * Possible outcomes from a triggered assertion. * * When an enabled assertion triggers, it may call the assertion handler * (possibly one provided by the app via SDL_SetAssertionHandler), which will * return one of these values, possibly after asking the user. * * Then SDL will respond based on this outcome (loop around to retry the * condition, try to break in a debugger, kill the program, or ignore the * problem). * * \since This enum is available since SDL 3.2.0. */ typedef enum SDL_AssertState { SDL_ASSERTION_RETRY, /**< Retry the assert immediately. */ SDL_ASSERTION_BREAK, /**< Make the debugger trigger a breakpoint. */ SDL_ASSERTION_ABORT, /**< Terminate the program. */ SDL_ASSERTION_IGNORE, /**< Ignore the assert. */ SDL_ASSERTION_ALWAYS_IGNORE /**< Ignore the assert from now on. */ } SDL_AssertState; /** * Information about an assertion failure. * * This structure is filled in with information about a triggered assertion, * used by the assertion handler, then added to the assertion report. This is * returned as a linked list from SDL_GetAssertionReport(). * * \since This struct is available since SDL 3.2.0. */ typedef struct SDL_AssertData { bool always_ignore; /**< true if app should always continue when assertion is triggered. */ unsigned int trigger_count; /**< Number of times this assertion has been triggered. */ const char *condition; /**< A string of this assert's test code. */ const char *filename; /**< The source file where this assert lives. */ int linenum; /**< The line in `filename` where this assert lives. */ const char *function; /**< The name of the function where this assert lives. */ const struct SDL_AssertData *next; /**< next item in the linked list. */ } SDL_AssertData; /** * Never call this directly. * * Use the SDL_assert macros instead. * * \param data assert data structure. * \param func function name. * \param file file name. * \param line line number. * \returns assert state. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC SDL_AssertState SDLCALL SDL_ReportAssertion(SDL_AssertData *data, const char *func, const char *file, int line) SDL_ANALYZER_NORETURN; #ifdef SDL_WIKI_DOCUMENTATION_SECTION /** * The macro used when an assertion triggers a breakpoint. * * This isn't for direct use by apps; use SDL_assert or SDL_TriggerBreakpoint * instead. * * \since This macro is available since SDL 3.2.0. */ #define SDL_AssertBreakpoint() SDL_TriggerBreakpoint() #elif !defined(SDL_AssertBreakpoint) # if defined(ANDROID) && defined(assert) /* Define this as empty in case assert() is defined as SDL_assert */ # define SDL_AssertBreakpoint() # else # define SDL_AssertBreakpoint() SDL_TriggerBreakpoint() # endif #endif /* !SDL_AssertBreakpoint */ /** * The macro used when an assertion is enabled. * * This isn't for direct use by apps, but this is the code that is inserted * when an SDL_assert is enabled. * * The `do {} while(0)` avoids dangling else problems: * * ```c * if (x) SDL_assert(y); else blah(); * ``` * * ... without the do/while, the "else" could attach to this macro's "if". We * try to handle just the minimum we need here in a macro...the loop, the * static vars, and break points. The heavy lifting is handled in * SDL_ReportAssertion(). * * \param condition the condition to assert. * * \since This macro is available since SDL 3.2.0. */ #define SDL_enabled_assert(condition) \ do { \ while ( !(condition) ) { \ static struct SDL_AssertData sdl_assert_data = { false, 0, #condition, NULL, 0, NULL, NULL }; \ const SDL_AssertState sdl_assert_state = SDL_ReportAssertion(&sdl_assert_data, SDL_FUNCTION, SDL_ASSERT_FILE, SDL_LINE); \ if (sdl_assert_state == SDL_ASSERTION_RETRY) { \ continue; /* go again. */ \ } else if (sdl_assert_state == SDL_ASSERTION_BREAK) { \ SDL_AssertBreakpoint(); \ } \ break; /* not retrying. */ \ } \ } while (SDL_NULL_WHILE_LOOP_CONDITION) #ifdef SDL_WIKI_DOCUMENTATION_SECTION /** * An assertion test that is normally performed only in debug builds. * * This macro is enabled when the SDL_ASSERT_LEVEL is >= 2, otherwise it is * disabled. This is meant to only do these tests in debug builds, so they can * tend to be more expensive, and they are meant to bring everything to a halt * when they fail, with the programmer there to assess the problem. * * In short: you can sprinkle these around liberally and assume they will * evaporate out of the build when building for end-users. * * When assertions are disabled, this wraps `condition` in a `sizeof` * operator, which means any function calls and side effects will not run, but * the compiler will not complain about any otherwise-unused variables that * are only referenced in the assertion. * * One can set the environment variable "SDL_ASSERT" to one of several strings * ("abort", "break", "retry", "ignore", "always_ignore") to force a default * behavior, which may be desirable for automation purposes. If your platform * requires GUI interfaces to happen on the main thread but you're debugging * an assertion in a background thread, it might be desirable to set this to * "break" so that your debugger takes control as soon as assert is triggered, * instead of risking a bad UI interaction (deadlock, etc) in the application. * * \param condition boolean value to test. * * \threadsafety It is safe to call this macro from any thread. * * \since This macro is available since SDL 3.2.0. */ #define SDL_assert(condition) if (assertion_enabled && (condition)) { trigger_assertion; } /** * An assertion test that is performed even in release builds. * * This macro is enabled when the SDL_ASSERT_LEVEL is >= 1, otherwise it is * disabled. This is meant to be for tests that are cheap to make and * extremely unlikely to fail; generally it is frowned upon to have an * assertion failure in a release build, so these assertions generally need to * be of more than life-and-death importance if there's a chance they might * trigger. You should almost always consider handling these cases more * gracefully than an assert allows. * * When assertions are disabled, this wraps `condition` in a `sizeof` * operator, which means any function calls and side effects will not run, but * the compiler will not complain about any otherwise-unused variables that * are only referenced in the assertion. * * One can set the environment variable "SDL_ASSERT" to one of several strings * ("abort", "break", "retry", "ignore", "always_ignore") to force a default * behavior, which may be desirable for automation purposes. If your platform * requires GUI interfaces to happen on the main thread but you're debugging * an assertion in a background thread, it might be desirable to set this to * "break" so that your debugger takes control as soon as assert is triggered, * instead of risking a bad UI interaction (deadlock, etc) in the application. * * * * \param condition boolean value to test. * * \threadsafety It is safe to call this macro from any thread. * * \since This macro is available since SDL 3.2.0. */ #define SDL_assert_release(condition) SDL_disabled_assert(condition) /** * An assertion test that is performed only when built with paranoid settings. * * This macro is enabled when the SDL_ASSERT_LEVEL is >= 3, otherwise it is * disabled. This is a higher level than both release and debug, so these * tests are meant to be expensive and only run when specifically looking for * extremely unexpected failure cases in a special build. * * When assertions are disabled, this wraps `condition` in a `sizeof` * operator, which means any function calls and side effects will not run, but * the compiler will not complain about any otherwise-unused variables that * are only referenced in the assertion. * * One can set the environment variable "SDL_ASSERT" to one of several strings * ("abort", "break", "retry", "ignore", "always_ignore") to force a default * behavior, which may be desirable for automation purposes. If your platform * requires GUI interfaces to happen on the main thread but you're debugging * an assertion in a background thread, it might be desirable to set this to * "break" so that your debugger takes control as soon as assert is triggered, * instead of risking a bad UI interaction (deadlock, etc) in the application. * * \param condition boolean value to test. * * \threadsafety It is safe to call this macro from any thread. * * \since This macro is available since SDL 3.2.0. */ #define SDL_assert_paranoid(condition) SDL_disabled_assert(condition) /* Enable various levels of assertions. */ #elif SDL_ASSERT_LEVEL == 0 /* assertions disabled */ # define SDL_assert(condition) SDL_disabled_assert(condition) # define SDL_assert_release(condition) SDL_disabled_assert(condition) # define SDL_assert_paranoid(condition) SDL_disabled_assert(condition) #elif SDL_ASSERT_LEVEL == 1 /* release settings. */ # define SDL_assert(condition) SDL_disabled_assert(condition) # define SDL_assert_release(condition) SDL_enabled_assert(condition) # define SDL_assert_paranoid(condition) SDL_disabled_assert(condition) #elif SDL_ASSERT_LEVEL == 2 /* debug settings. */ # define SDL_assert(condition) SDL_enabled_assert(condition) # define SDL_assert_release(condition) SDL_enabled_assert(condition) # define SDL_assert_paranoid(condition) SDL_disabled_assert(condition) #elif SDL_ASSERT_LEVEL == 3 /* paranoid settings. */ # define SDL_assert(condition) SDL_enabled_assert(condition) # define SDL_assert_release(condition) SDL_enabled_assert(condition) # define SDL_assert_paranoid(condition) SDL_enabled_assert(condition) #else # error Unknown assertion level. #endif /** * An assertion test that is always performed. * * This macro is always enabled no matter what SDL_ASSERT_LEVEL is set to. You * almost never want to use this, as it could trigger on an end-user's system, * crashing your program. * * One can set the environment variable "SDL_ASSERT" to one of several strings * ("abort", "break", "retry", "ignore", "always_ignore") to force a default * behavior, which may be desirable for automation purposes. If your platform * requires GUI interfaces to happen on the main thread but you're debugging * an assertion in a background thread, it might be desirable to set this to * "break" so that your debugger takes control as soon as assert is triggered, * instead of risking a bad UI interaction (deadlock, etc) in the application. * * \param condition boolean value to test. * * \threadsafety It is safe to call this macro from any thread. * * \since This macro is available since SDL 3.2.0. */ #define SDL_assert_always(condition) SDL_enabled_assert(condition) /** * A callback that fires when an SDL assertion fails. * * \param data a pointer to the SDL_AssertData structure corresponding to the * current assertion. * \param userdata what was passed as `userdata` to SDL_SetAssertionHandler(). * \returns an SDL_AssertState value indicating how to handle the failure. * * \threadsafety This callback may be called from any thread that triggers an * assert at any time. * * \since This datatype is available since SDL 3.2.0. */ typedef SDL_AssertState (SDLCALL *SDL_AssertionHandler)( const SDL_AssertData *data, void *userdata); /** * Set an application-defined assertion handler. * * This function allows an application to show its own assertion UI and/or * force the response to an assertion failure. If the application doesn't * provide this, SDL will try to do the right thing, popping up a * system-specific GUI dialog, and probably minimizing any fullscreen windows. * * This callback may fire from any thread, but it runs wrapped in a mutex, so * it will only fire from one thread at a time. * * This callback is NOT reset to SDL's internal handler upon SDL_Quit()! * * \param handler the SDL_AssertionHandler function to call when an assertion * fails or NULL for the default handler. * \param userdata a pointer that is passed to `handler`. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetAssertionHandler */ extern SDL_DECLSPEC void SDLCALL SDL_SetAssertionHandler( SDL_AssertionHandler handler, void *userdata); /** * Get the default assertion handler. * * This returns the function pointer that is called by default when an * assertion is triggered. This is an internal function provided by SDL, that * is used for assertions when SDL_SetAssertionHandler() hasn't been used to * provide a different function. * * \returns the default SDL_AssertionHandler that is called when an assert * triggers. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetAssertionHandler */ extern SDL_DECLSPEC SDL_AssertionHandler SDLCALL SDL_GetDefaultAssertionHandler(void); /** * Get the current assertion handler. * * This returns the function pointer that is called when an assertion is * triggered. This is either the value last passed to * SDL_SetAssertionHandler(), or if no application-specified function is set, * is equivalent to calling SDL_GetDefaultAssertionHandler(). * * The parameter `puserdata` is a pointer to a void*, which will store the * "userdata" pointer that was passed to SDL_SetAssertionHandler(). This value * will always be NULL for the default handler. If you don't care about this * data, it is safe to pass a NULL pointer to this function to ignore it. * * \param puserdata pointer which is filled with the "userdata" pointer that * was passed to SDL_SetAssertionHandler(). * \returns the SDL_AssertionHandler that is called when an assert triggers. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_SetAssertionHandler */ extern SDL_DECLSPEC SDL_AssertionHandler SDLCALL SDL_GetAssertionHandler(void **puserdata); /** * Get a list of all assertion failures. * * This function gets all assertions triggered since the last call to * SDL_ResetAssertionReport(), or the start of the program. * * The proper way to examine this data looks something like this: * * ```c * const SDL_AssertData *item = SDL_GetAssertionReport(); * while (item) { * printf("'%s', %s (%s:%d), triggered %u times, always ignore: %s.\\n", * item->condition, item->function, item->filename, * item->linenum, item->trigger_count, * item->always_ignore ? "yes" : "no"); * item = item->next; * } * ``` * * \returns a list of all failed assertions or NULL if the list is empty. This * memory should not be modified or freed by the application. This * pointer remains valid until the next call to SDL_Quit() or * SDL_ResetAssertionReport(). * * \threadsafety This function is not thread safe. Other threads calling * SDL_ResetAssertionReport() simultaneously, may render the * returned pointer invalid. * * \since This function is available since SDL 3.2.0. * * \sa SDL_ResetAssertionReport */ extern SDL_DECLSPEC const SDL_AssertData * SDLCALL SDL_GetAssertionReport(void); /** * Clear the list of all assertion failures. * * This function will clear the list of all assertions triggered up to that * point. Immediately following this call, SDL_GetAssertionReport will return * no items. In addition, any previously-triggered assertions will be reset to * a trigger_count of zero, and their always_ignore state will be false. * * \threadsafety This function is not thread safe. Other threads triggering an * assertion, or simultaneously calling this function may cause * memory leaks or crashes. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetAssertionReport */ extern SDL_DECLSPEC void SDLCALL SDL_ResetAssertionReport(void); /* Ends C function definitions when using C++ */ #ifdef __cplusplus } #endif #include #endif /* SDL_assert_h_ */ ================================================ FILE: deps/include/SDL3/SDL_asyncio.h ================================================ /* Simple DirectMedia Layer Copyright (C) 1997-2026 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ /* WIKI CATEGORY: AsyncIO */ /** * # CategoryAsyncIO * * SDL offers a way to perform I/O asynchronously. This allows an app to read * or write files without waiting for data to actually transfer; the functions * that request I/O never block while the request is fulfilled. * * Instead, the data moves in the background and the app can check for results * at their leisure. * * This is more complicated than just reading and writing files in a * synchronous way, but it can allow for more efficiency, and never having * framerate drops as the hard drive catches up, etc. * * The general usage pattern for async I/O is: * * - Create one or more SDL_AsyncIOQueue objects. * - Open files with SDL_AsyncIOFromFile. * - Start I/O tasks to the files with SDL_ReadAsyncIO or SDL_WriteAsyncIO, * putting those tasks into one of the queues. * - Later on, use SDL_GetAsyncIOResult on a queue to see if any task is * finished without blocking. Tasks might finish in any order with success * or failure. * - When all your tasks are done, close the file with SDL_CloseAsyncIO. This * also generates a task, since it might flush data to disk! * * This all works, without blocking, in a single thread, but one can also wait * on a queue in a background thread, sleeping until new results have arrived: * * - Call SDL_WaitAsyncIOResult from one or more threads to efficiently block * until new tasks complete. * - When shutting down, call SDL_SignalAsyncIOQueue to unblock any sleeping * threads despite there being no new tasks completed. * * And, of course, to match the synchronous SDL_LoadFile, we offer * SDL_LoadFileAsync as a convenience function. This will handle allocating a * buffer, slurping in the file data, and null-terminating it; you still check * for results later. * * Behind the scenes, SDL will use newer, efficient APIs on platforms that * support them: Linux's io_uring and Windows 11's IoRing, for example. If * those technologies aren't available, SDL will offload the work to a thread * pool that will manage otherwise-synchronous loads without blocking the app. * * ## Best Practices * * Simple non-blocking I/O--for an app that just wants to pick up data * whenever it's ready without losing framerate waiting on disks to spin--can * use whatever pattern works well for the program. In this case, simply call * SDL_ReadAsyncIO, or maybe SDL_LoadFileAsync, as needed. Once a frame, call * SDL_GetAsyncIOResult to check for any completed tasks and deal with the * data as it arrives. * * If two separate pieces of the same program need their own I/O, it is legal * for each to create their own queue. This will prevent either piece from * accidentally consuming the other's completed tasks. Each queue does require * some amount of resources, but it is not an overwhelming cost. Do not make a * queue for each task, however. It is better to put many tasks into a single * queue. They will be reported in order of completion, not in the order they * were submitted, so it doesn't generally matter what order tasks are * started. * * One async I/O queue can be shared by multiple threads, or one thread can * have more than one queue, but the most efficient way--if ruthless * efficiency is the goal--is to have one queue per thread, with multiple * threads working in parallel, and attempt to keep each queue loaded with * tasks that are both started by and consumed by the same thread. On modern * platforms that can use newer interfaces, this can keep data flowing as * efficiently as possible all the way from storage hardware to the app, with * no contention between threads for access to the same queue. * * Written data is not guaranteed to make it to physical media by the time a * closing task is completed, unless SDL_CloseAsyncIO is called with its * `flush` parameter set to true, which is to say that a successful result * here can still result in lost data during an unfortunately-timed power * outage if not flushed. However, flushing will take longer and may be * unnecessary, depending on the app's needs. */ #ifndef SDL_asyncio_h_ #define SDL_asyncio_h_ #include #include /* Set up for C function definitions, even when using C++ */ #ifdef __cplusplus extern "C" { #endif /** * The asynchronous I/O operation structure. * * This operates as an opaque handle. One can then request read or write * operations on it. * * \since This struct is available since SDL 3.2.0. * * \sa SDL_AsyncIOFromFile */ typedef struct SDL_AsyncIO SDL_AsyncIO; /** * Types of asynchronous I/O tasks. * * \since This enum is available since SDL 3.2.0. */ typedef enum SDL_AsyncIOTaskType { SDL_ASYNCIO_TASK_READ, /**< A read operation. */ SDL_ASYNCIO_TASK_WRITE, /**< A write operation. */ SDL_ASYNCIO_TASK_CLOSE /**< A close operation. */ } SDL_AsyncIOTaskType; /** * Possible outcomes of an asynchronous I/O task. * * \since This enum is available since SDL 3.2.0. */ typedef enum SDL_AsyncIOResult { SDL_ASYNCIO_COMPLETE, /**< request was completed without error */ SDL_ASYNCIO_FAILURE, /**< request failed for some reason; check SDL_GetError()! */ SDL_ASYNCIO_CANCELED /**< request was canceled before completing. */ } SDL_AsyncIOResult; /** * Information about a completed asynchronous I/O request. * * \since This struct is available since SDL 3.2.0. */ typedef struct SDL_AsyncIOOutcome { SDL_AsyncIO *asyncio; /**< what generated this task. This pointer will be invalid if it was closed! */ SDL_AsyncIOTaskType type; /**< What sort of task was this? Read, write, etc? */ SDL_AsyncIOResult result; /**< the result of the work (success, failure, cancellation). */ void *buffer; /**< buffer where data was read/written. */ Uint64 offset; /**< offset in the SDL_AsyncIO where data was read/written. */ Uint64 bytes_requested; /**< number of bytes the task was to read/write. */ Uint64 bytes_transferred; /**< actual number of bytes that were read/written. */ void *userdata; /**< pointer provided by the app when starting the task */ } SDL_AsyncIOOutcome; /** * A queue of completed asynchronous I/O tasks. * * When starting an asynchronous operation, you specify a queue for the new * task. A queue can be asked later if any tasks in it have completed, * allowing an app to manage multiple pending tasks in one place, in whatever * order they complete. * * \since This struct is available since SDL 3.2.0. * * \sa SDL_CreateAsyncIOQueue * \sa SDL_ReadAsyncIO * \sa SDL_WriteAsyncIO * \sa SDL_GetAsyncIOResult * \sa SDL_WaitAsyncIOResult */ typedef struct SDL_AsyncIOQueue SDL_AsyncIOQueue; /** * Use this function to create a new SDL_AsyncIO object for reading from * and/or writing to a named file. * * The `mode` string understands the following values: * * - "r": Open a file for reading only. It must exist. * - "w": Open a file for writing only. It will create missing files or * truncate existing ones. * - "r+": Open a file for update both reading and writing. The file must * exist. * - "w+": Create an empty file for both reading and writing. If a file with * the same name already exists its content is erased and the file is * treated as a new empty file. * * There is no "b" mode, as there is only "binary" style I/O, and no "a" mode * for appending, since you specify the position when starting a task. * * This function supports Unicode filenames, but they must be encoded in UTF-8 * format, regardless of the underlying operating system. * * This call is _not_ asynchronous; it will open the file before returning, * under the assumption that doing so is generally a fast operation. Future * reads and writes to the opened file will be async, however. * * \param file a UTF-8 string representing the filename to open. * \param mode an ASCII string representing the mode to be used for opening * the file. * \returns a pointer to the SDL_AsyncIO structure that is created or NULL on * failure; call SDL_GetError() for more information. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_CloseAsyncIO * \sa SDL_ReadAsyncIO * \sa SDL_WriteAsyncIO */ extern SDL_DECLSPEC SDL_AsyncIO * SDLCALL SDL_AsyncIOFromFile(const char *file, const char *mode); /** * Use this function to get the size of the data stream in an SDL_AsyncIO. * * This call is _not_ asynchronous; it assumes that obtaining this info is a * non-blocking operation in most reasonable cases. * * \param asyncio the SDL_AsyncIO to get the size of the data stream from. * \returns the size of the data stream in the SDL_IOStream on success or a * negative error code on failure; call SDL_GetError() for more * information. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC Sint64 SDLCALL SDL_GetAsyncIOSize(SDL_AsyncIO *asyncio); /** * Start an async read. * * This function reads up to `size` bytes from `offset` position in the data * source to the area pointed at by `ptr`. This function may read less bytes * than requested. * * This function returns as quickly as possible; it does not wait for the read * to complete. On a successful return, this work will continue in the * background. If the work begins, even failure is asynchronous: a failing * return value from this function only means the work couldn't start at all. * * `ptr` must remain available until the work is done, and may be accessed by * the system at any time until then. Do not allocate it on the stack, as this * might take longer than the life of the calling function to complete! * * An SDL_AsyncIOQueue must be specified. The newly-created task will be added * to it when it completes its work. * * \param asyncio a pointer to an SDL_AsyncIO structure. * \param ptr a pointer to a buffer to read data into. * \param offset the position to start reading in the data source. * \param size the number of bytes to read from the data source. * \param queue a queue to add the new SDL_AsyncIO to. * \param userdata an app-defined pointer that will be provided with the task * results. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_WriteAsyncIO * \sa SDL_CreateAsyncIOQueue */ extern SDL_DECLSPEC bool SDLCALL SDL_ReadAsyncIO(SDL_AsyncIO *asyncio, void *ptr, Uint64 offset, Uint64 size, SDL_AsyncIOQueue *queue, void *userdata); /** * Start an async write. * * This function writes `size` bytes from `offset` position in the data source * to the area pointed at by `ptr`. * * This function returns as quickly as possible; it does not wait for the * write to complete. On a successful return, this work will continue in the * background. If the work begins, even failure is asynchronous: a failing * return value from this function only means the work couldn't start at all. * * `ptr` must remain available until the work is done, and may be accessed by * the system at any time until then. Do not allocate it on the stack, as this * might take longer than the life of the calling function to complete! * * An SDL_AsyncIOQueue must be specified. The newly-created task will be added * to it when it completes its work. * * \param asyncio a pointer to an SDL_AsyncIO structure. * \param ptr a pointer to a buffer to write data from. * \param offset the position to start writing to the data source. * \param size the number of bytes to write to the data source. * \param queue a queue to add the new SDL_AsyncIO to. * \param userdata an app-defined pointer that will be provided with the task * results. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_ReadAsyncIO * \sa SDL_CreateAsyncIOQueue */ extern SDL_DECLSPEC bool SDLCALL SDL_WriteAsyncIO(SDL_AsyncIO *asyncio, void *ptr, Uint64 offset, Uint64 size, SDL_AsyncIOQueue *queue, void *userdata); /** * Close and free any allocated resources for an async I/O object. * * Closing a file is _also_ an asynchronous task! If a write failure were to * happen during the closing process, for example, the task results will * report it as usual. * * Closing a file that has been written to does not guarantee the data has * made it to physical media; it may remain in the operating system's file * cache, for later writing to disk. This means that a successfully-closed * file can be lost if the system crashes or loses power in this small window. * To prevent this, call this function with the `flush` parameter set to true. * This will make the operation take longer, and perhaps increase system load * in general, but a successful result guarantees that the data has made it to * physical storage. Don't use this for temporary files, caches, and * unimportant data, and definitely use it for crucial irreplaceable files, * like game saves. * * This function guarantees that the close will happen after any other pending * tasks to `asyncio`, so it's safe to open a file, start several operations, * close the file immediately, then check for all results later. This function * will not block until the tasks have completed. * * Once this function returns true, `asyncio` is no longer valid, regardless * of any future outcomes. Any completed tasks might still contain this * pointer in their SDL_AsyncIOOutcome data, in case the app was using this * value to track information, but it should not be used again. * * If this function returns false, the close wasn't started at all, and it's * safe to attempt to close again later. * * An SDL_AsyncIOQueue must be specified. The newly-created task will be added * to it when it completes its work. * * \param asyncio a pointer to an SDL_AsyncIO structure to close. * \param flush true if data should sync to disk before the task completes. * \param queue a queue to add the new SDL_AsyncIO to. * \param userdata an app-defined pointer that will be provided with the task * results. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety It is safe to call this function from any thread, but two * threads should not attempt to close the same object. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC bool SDLCALL SDL_CloseAsyncIO(SDL_AsyncIO *asyncio, bool flush, SDL_AsyncIOQueue *queue, void *userdata); /** * Create a task queue for tracking multiple I/O operations. * * Async I/O operations are assigned to a queue when started. The queue can be * checked for completed tasks thereafter. * * \returns a new task queue object or NULL if there was an error; call * SDL_GetError() for more information. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_DestroyAsyncIOQueue * \sa SDL_GetAsyncIOResult * \sa SDL_WaitAsyncIOResult */ extern SDL_DECLSPEC SDL_AsyncIOQueue * SDLCALL SDL_CreateAsyncIOQueue(void); /** * Destroy a previously-created async I/O task queue. * * If there are still tasks pending for this queue, this call will block until * those tasks are finished. All those tasks will be deallocated. Their * results will be lost to the app. * * Any pending reads from SDL_LoadFileAsync() that are still in this queue * will have their buffers deallocated by this function, to prevent a memory * leak. * * Once this function is called, the queue is no longer valid and should not * be used, including by other threads that might access it while destruction * is blocking on pending tasks. * * Do not destroy a queue that still has threads waiting on it through * SDL_WaitAsyncIOResult(). You can call SDL_SignalAsyncIOQueue() first to * unblock those threads, and take measures (such as SDL_WaitThread()) to make * sure they have finished their wait and won't wait on the queue again. * * \param queue the task queue to destroy. * * \threadsafety It is safe to call this function from any thread, so long as * no other thread is waiting on the queue with * SDL_WaitAsyncIOResult. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC void SDLCALL SDL_DestroyAsyncIOQueue(SDL_AsyncIOQueue *queue); /** * Query an async I/O task queue for completed tasks. * * If a task assigned to this queue has finished, this will return true and * fill in `outcome` with the details of the task. If no task in the queue has * finished, this function will return false. This function does not block. * * If a task has completed, this function will free its resources and the task * pointer will no longer be valid. The task will be removed from the queue. * * It is safe for multiple threads to call this function on the same queue at * once; a completed task will only go to one of the threads. * * \param queue the async I/O task queue to query. * \param outcome details of a finished task will be written here. May not be * NULL. * \returns true if a task has completed, false otherwise. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_WaitAsyncIOResult */ extern SDL_DECLSPEC bool SDLCALL SDL_GetAsyncIOResult(SDL_AsyncIOQueue *queue, SDL_AsyncIOOutcome *outcome); /** * Block until an async I/O task queue has a completed task. * * This function puts the calling thread to sleep until there a task assigned * to the queue that has finished. * * If a task assigned to the queue has finished, this will return true and * fill in `outcome` with the details of the task. If no task in the queue has * finished, this function will return false. * * If a task has completed, this function will free its resources and the task * pointer will no longer be valid. The task will be removed from the queue. * * It is safe for multiple threads to call this function on the same queue at * once; a completed task will only go to one of the threads. * * Note that by the nature of various platforms, more than one waiting thread * may wake to handle a single task, but only one will obtain it, so * `timeoutMS` is a _maximum_ wait time, and this function may return false * sooner. * * This function may return false if there was a system error, the OS * inadvertently awoke multiple threads, or if SDL_SignalAsyncIOQueue() was * called to wake up all waiting threads without a finished task. * * A timeout can be used to specify a maximum wait time, but rather than * polling, it is possible to have a timeout of -1 to wait forever, and use * SDL_SignalAsyncIOQueue() to wake up the waiting threads later. * * \param queue the async I/O task queue to wait on. * \param outcome details of a finished task will be written here. May not be * NULL. * \param timeoutMS the maximum time to wait, in milliseconds, or -1 to wait * indefinitely. * \returns true if task has completed, false otherwise. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_SignalAsyncIOQueue */ extern SDL_DECLSPEC bool SDLCALL SDL_WaitAsyncIOResult(SDL_AsyncIOQueue *queue, SDL_AsyncIOOutcome *outcome, Sint32 timeoutMS); /** * Wake up any threads that are blocking in SDL_WaitAsyncIOResult(). * * This will unblock any threads that are sleeping in a call to * SDL_WaitAsyncIOResult for the specified queue, and cause them to return * from that function. * * This can be useful when destroying a queue to make sure nothing is touching * it indefinitely. In this case, once this call completes, the caller should * take measures to make sure any previously-blocked threads have returned * from their wait and will not touch the queue again (perhaps by setting a * flag to tell the threads to terminate and then using SDL_WaitThread() to * make sure they've done so). * * \param queue the async I/O task queue to signal. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_WaitAsyncIOResult */ extern SDL_DECLSPEC void SDLCALL SDL_SignalAsyncIOQueue(SDL_AsyncIOQueue *queue); /** * Load all the data from a file path, asynchronously. * * This function returns as quickly as possible; it does not wait for the read * to complete. On a successful return, this work will continue in the * background. If the work begins, even failure is asynchronous: a failing * return value from this function only means the work couldn't start at all. * * The data is allocated with a zero byte at the end (null terminated) for * convenience. This extra byte is not included in SDL_AsyncIOOutcome's * bytes_transferred value. * * This function will allocate the buffer to contain the file. It must be * deallocated by calling SDL_free() on SDL_AsyncIOOutcome's buffer field * after completion. * * An SDL_AsyncIOQueue must be specified. The newly-created task will be added * to it when it completes its work. * * \param file the path to read all available data from. * \param queue a queue to add the new SDL_AsyncIO to. * \param userdata an app-defined pointer that will be provided with the task * results. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_LoadFile_IO */ extern SDL_DECLSPEC bool SDLCALL SDL_LoadFileAsync(const char *file, SDL_AsyncIOQueue *queue, void *userdata); /* Ends C function definitions when using C++ */ #ifdef __cplusplus } #endif #include #endif /* SDL_asyncio_h_ */ ================================================ FILE: deps/include/SDL3/SDL_atomic.h ================================================ /* Simple DirectMedia Layer Copyright (C) 1997-2026 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ /** * # CategoryAtomic * * Atomic operations. * * IMPORTANT: If you are not an expert in concurrent lockless programming, you * should not be using any functions in this file. You should be protecting * your data structures with full mutexes instead. * * ***Seriously, here be dragons!*** * * You can find out a little more about lockless programming and the subtle * issues that can arise here: * https://learn.microsoft.com/en-us/windows/win32/dxtecharts/lockless-programming * * There's also lots of good information here: * * - https://www.1024cores.net/home/lock-free-algorithms * - https://preshing.com/ * * These operations may or may not actually be implemented using processor * specific atomic operations. When possible they are implemented as true * processor specific atomic operations. When that is not possible the are * implemented using locks that *do* use the available atomic operations. * * All of the atomic operations that modify memory are full memory barriers. */ #ifndef SDL_atomic_h_ #define SDL_atomic_h_ #include #include #include /* Set up for C function definitions, even when using C++ */ #ifdef __cplusplus extern "C" { #endif /** * An atomic spinlock. * * The atomic locks are efficient spinlocks using CPU instructions, but are * vulnerable to starvation and can spin forever if a thread holding a lock * has been terminated. For this reason you should minimize the code executed * inside an atomic lock and never do expensive things like API or system * calls while holding them. * * They are also vulnerable to starvation if the thread holding the lock is * lower priority than other threads and doesn't get scheduled. In general you * should use mutexes instead, since they have better performance and * contention behavior. * * The atomic locks are not safe to lock recursively. * * Porting Note: The spin lock functions and type are required and can not be * emulated because they are used in the atomic emulation code. */ typedef int SDL_SpinLock; /** * Try to lock a spin lock by setting it to a non-zero value. * * ***Please note that spinlocks are dangerous if you don't know what you're * doing. Please be careful using any sort of spinlock!*** * * \param lock a pointer to a lock variable. * \returns true if the lock succeeded, false if the lock is already held. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_LockSpinlock * \sa SDL_UnlockSpinlock */ extern SDL_DECLSPEC bool SDLCALL SDL_TryLockSpinlock(SDL_SpinLock *lock); /** * Lock a spin lock by setting it to a non-zero value. * * ***Please note that spinlocks are dangerous if you don't know what you're * doing. Please be careful using any sort of spinlock!*** * * \param lock a pointer to a lock variable. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_TryLockSpinlock * \sa SDL_UnlockSpinlock */ extern SDL_DECLSPEC void SDLCALL SDL_LockSpinlock(SDL_SpinLock *lock); /** * Unlock a spin lock by setting it to 0. * * Always returns immediately. * * ***Please note that spinlocks are dangerous if you don't know what you're * doing. Please be careful using any sort of spinlock!*** * * \param lock a pointer to a lock variable. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_LockSpinlock * \sa SDL_TryLockSpinlock */ extern SDL_DECLSPEC void SDLCALL SDL_UnlockSpinlock(SDL_SpinLock *lock); #ifdef SDL_WIKI_DOCUMENTATION_SECTION /** * Mark a compiler barrier. * * A compiler barrier prevents the compiler from reordering reads and writes * to globally visible variables across the call. * * This macro only prevents the compiler from reordering reads and writes, it * does not prevent the CPU from reordering reads and writes. However, all of * the atomic operations that modify memory are full memory barriers. * * \threadsafety Obviously this macro is safe to use from any thread at any * time, but if you find yourself needing this, you are probably * dealing with some very sensitive code; be careful! * * \since This macro is available since SDL 3.2.0. */ #define SDL_CompilerBarrier() DoCompilerSpecificReadWriteBarrier() #elif defined(_MSC_VER) && (_MSC_VER > 1200) && !defined(__clang__) void _ReadWriteBarrier(void); #pragma intrinsic(_ReadWriteBarrier) #define SDL_CompilerBarrier() _ReadWriteBarrier() #elif (defined(__GNUC__) && !defined(SDL_PLATFORM_EMSCRIPTEN)) || (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x5120)) /* This is correct for all CPUs when using GCC or Solaris Studio 12.1+. */ #define SDL_CompilerBarrier() __asm__ __volatile__ ("" : : : "memory") #elif defined(__WATCOMC__) extern __inline void SDL_CompilerBarrier(void); #pragma aux SDL_CompilerBarrier = "" parm [] modify exact []; #else #define SDL_CompilerBarrier() \ { SDL_SpinLock _tmp = 0; SDL_LockSpinlock(&_tmp); SDL_UnlockSpinlock(&_tmp); } #endif /** * Insert a memory release barrier (function version). * * Please refer to SDL_MemoryBarrierRelease for details. This is a function * version, which might be useful if you need to use this functionality from a * scripting language, etc. Also, some of the macro versions call this * function behind the scenes, where more heavy lifting can happen inside of * SDL. Generally, though, an app written in C/C++/etc should use the macro * version, as it will be more efficient. * * \threadsafety Obviously this function is safe to use from any thread at any * time, but if you find yourself needing this, you are probably * dealing with some very sensitive code; be careful! * * \since This function is available since SDL 3.2.0. * * \sa SDL_MemoryBarrierRelease */ extern SDL_DECLSPEC void SDLCALL SDL_MemoryBarrierReleaseFunction(void); /** * Insert a memory acquire barrier (function version). * * Please refer to SDL_MemoryBarrierRelease for details. This is a function * version, which might be useful if you need to use this functionality from a * scripting language, etc. Also, some of the macro versions call this * function behind the scenes, where more heavy lifting can happen inside of * SDL. Generally, though, an app written in C/C++/etc should use the macro * version, as it will be more efficient. * * \threadsafety Obviously this function is safe to use from any thread at any * time, but if you find yourself needing this, you are probably * dealing with some very sensitive code; be careful! * * \since This function is available since SDL 3.2.0. * * \sa SDL_MemoryBarrierAcquire */ extern SDL_DECLSPEC void SDLCALL SDL_MemoryBarrierAcquireFunction(void); #ifdef SDL_WIKI_DOCUMENTATION_SECTION /** * Insert a memory release barrier (macro version). * * Memory barriers are designed to prevent reads and writes from being * reordered by the compiler and being seen out of order on multi-core CPUs. * * A typical pattern would be for thread A to write some data and a flag, and * for thread B to read the flag and get the data. In this case you would * insert a release barrier between writing the data and the flag, * guaranteeing that the data write completes no later than the flag is * written, and you would insert an acquire barrier between reading the flag * and reading the data, to ensure that all the reads associated with the flag * have completed. * * In this pattern you should always see a release barrier paired with an * acquire barrier and you should gate the data reads/writes with a single * flag variable. * * For more information on these semantics, take a look at the blog post: * http://preshing.com/20120913/acquire-and-release-semantics * * This is the macro version of this functionality; if possible, SDL will use * compiler intrinsics or inline assembly, but some platforms might need to * call the function version of this, SDL_MemoryBarrierReleaseFunction to do * the heavy lifting. Apps that can use the macro should favor it over the * function. * * \threadsafety Obviously this macro is safe to use from any thread at any * time, but if you find yourself needing this, you are probably * dealing with some very sensitive code; be careful! * * \since This macro is available since SDL 3.2.0. * * \sa SDL_MemoryBarrierAcquire * \sa SDL_MemoryBarrierReleaseFunction */ #define SDL_MemoryBarrierRelease() SDL_MemoryBarrierReleaseFunction() /** * Insert a memory acquire barrier (macro version). * * Please see SDL_MemoryBarrierRelease for the details on what memory barriers * are and when to use them. * * This is the macro version of this functionality; if possible, SDL will use * compiler intrinsics or inline assembly, but some platforms might need to * call the function version of this, SDL_MemoryBarrierAcquireFunction, to do * the heavy lifting. Apps that can use the macro should favor it over the * function. * * \threadsafety Obviously this macro is safe to use from any thread at any * time, but if you find yourself needing this, you are probably * dealing with some very sensitive code; be careful! * * \since This macro is available since SDL 3.2.0. * * \sa SDL_MemoryBarrierRelease * \sa SDL_MemoryBarrierAcquireFunction */ #define SDL_MemoryBarrierAcquire() SDL_MemoryBarrierAcquireFunction() #elif defined(__GNUC__) && (defined(__powerpc__) || defined(__ppc__)) #define SDL_MemoryBarrierRelease() __asm__ __volatile__ ("lwsync" : : : "memory") #define SDL_MemoryBarrierAcquire() __asm__ __volatile__ ("lwsync" : : : "memory") #elif defined(__GNUC__) && defined(__aarch64__) #define SDL_MemoryBarrierRelease() __asm__ __volatile__ ("dmb ish" : : : "memory") #define SDL_MemoryBarrierAcquire() __asm__ __volatile__ ("dmb ish" : : : "memory") #elif defined(__GNUC__) && defined(__arm__) #if 0 /* defined(SDL_PLATFORM_LINUX) || defined(SDL_PLATFORM_ANDROID) */ /* Information from: https://chromium.googlesource.com/chromium/chromium/+/trunk/base/atomicops_internals_arm_gcc.h#19 The Linux kernel provides a helper function which provides the right code for a memory barrier, hard-coded at address 0xffff0fa0 */ typedef void (*SDL_KernelMemoryBarrierFunc)(); #define SDL_MemoryBarrierRelease() ((SDL_KernelMemoryBarrierFunc)0xffff0fa0)() #define SDL_MemoryBarrierAcquire() ((SDL_KernelMemoryBarrierFunc)0xffff0fa0)() #else #if defined(__ARM_ARCH_7__) || defined(__ARM_ARCH_7A__) || defined(__ARM_ARCH_7EM__) || defined(__ARM_ARCH_7R__) || defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7S__) || defined(__ARM_ARCH_8A__) #define SDL_MemoryBarrierRelease() __asm__ __volatile__ ("dmb ish" : : : "memory") #define SDL_MemoryBarrierAcquire() __asm__ __volatile__ ("dmb ish" : : : "memory") #elif defined(__ARM_ARCH_6__) || defined(__ARM_ARCH_6J__) || defined(__ARM_ARCH_6K__) || defined(__ARM_ARCH_6T2__) || defined(__ARM_ARCH_6Z__) || defined(__ARM_ARCH_6ZK__) #ifdef __thumb__ /* The mcr instruction isn't available in thumb mode, use real functions */ #define SDL_MEMORY_BARRIER_USES_FUNCTION #define SDL_MemoryBarrierRelease() SDL_MemoryBarrierReleaseFunction() #define SDL_MemoryBarrierAcquire() SDL_MemoryBarrierAcquireFunction() #else #define SDL_MemoryBarrierRelease() __asm__ __volatile__ ("mcr p15, 0, %0, c7, c10, 5" : : "r"(0) : "memory") #define SDL_MemoryBarrierAcquire() __asm__ __volatile__ ("mcr p15, 0, %0, c7, c10, 5" : : "r"(0) : "memory") #endif /* __thumb__ */ #else #define SDL_MemoryBarrierRelease() __asm__ __volatile__ ("" : : : "memory") #define SDL_MemoryBarrierAcquire() __asm__ __volatile__ ("" : : : "memory") #endif /* SDL_PLATFORM_LINUX || SDL_PLATFORM_ANDROID */ #endif /* __GNUC__ && __arm__ */ #else #if (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x5120)) /* This is correct for all CPUs on Solaris when using Solaris Studio 12.1+. */ #include #define SDL_MemoryBarrierRelease() __machine_rel_barrier() #define SDL_MemoryBarrierAcquire() __machine_acq_barrier() #else /* This is correct for the x86 and x64 CPUs, and we'll expand this over time. */ #define SDL_MemoryBarrierRelease() SDL_CompilerBarrier() #define SDL_MemoryBarrierAcquire() SDL_CompilerBarrier() #endif #endif /* "REP NOP" is PAUSE, coded for tools that don't know it by that name. */ #ifdef SDL_WIKI_DOCUMENTATION_SECTION /** * A macro to insert a CPU-specific "pause" instruction into the program. * * This can be useful in busy-wait loops, as it serves as a hint to the CPU as * to the program's intent; some CPUs can use this to do more efficient * processing. On some platforms, this doesn't do anything, so using this * macro might just be a harmless no-op. * * Note that if you are busy-waiting, there are often more-efficient * approaches with other synchronization primitives: mutexes, semaphores, * condition variables, etc. * * \threadsafety This macro is safe to use from any thread. * * \since This macro is available since SDL 3.2.0. */ #define SDL_CPUPauseInstruction() DoACPUPauseInACompilerAndArchitectureSpecificWay #elif (defined(__GNUC__) || defined(__clang__)) && (defined(__i386__) || defined(__x86_64__)) #define SDL_CPUPauseInstruction() __asm__ __volatile__("pause\n") /* Some assemblers can't do REP NOP, so go with PAUSE. */ #elif (defined(__arm__) && defined(__ARM_ARCH) && __ARM_ARCH >= 7) || defined(__aarch64__) #define SDL_CPUPauseInstruction() __asm__ __volatile__("yield" ::: "memory") #elif (defined(__powerpc__) || defined(__powerpc64__)) #define SDL_CPUPauseInstruction() __asm__ __volatile__("or 27,27,27"); #elif (defined(__riscv) && __riscv_xlen == 64) #define SDL_CPUPauseInstruction() __asm__ __volatile__(".insn i 0x0F, 0, x0, x0, 0x010"); #elif defined(_MSC_VER) && (defined(_M_IX86) || defined(_M_X64)) #define SDL_CPUPauseInstruction() _mm_pause() /* this is actually "rep nop" and not a SIMD instruction. No inline asm in MSVC x86-64! */ #elif defined(_MSC_VER) && (defined(_M_ARM) || defined(_M_ARM64)) #define SDL_CPUPauseInstruction() __yield() #elif defined(__WATCOMC__) && defined(__386__) extern __inline void SDL_CPUPauseInstruction(void); #pragma aux SDL_CPUPauseInstruction = ".686p" ".xmm2" "pause" #else #define SDL_CPUPauseInstruction() #endif /** * A type representing an atomic integer value. * * This can be used to manage a value that is synchronized across multiple * CPUs without a race condition; when an app sets a value with * SDL_SetAtomicInt all other threads, regardless of the CPU it is running on, * will see that value when retrieved with SDL_GetAtomicInt, regardless of CPU * caches, etc. * * This is also useful for atomic compare-and-swap operations: a thread can * change the value as long as its current value matches expectations. When * done in a loop, one can guarantee data consistency across threads without a * lock (but the usual warnings apply: if you don't know what you're doing, or * you don't do it carefully, you can confidently cause any number of * disasters with this, so in most cases, you _should_ use a mutex instead of * this!). * * This is a struct so people don't accidentally use numeric operations on it * directly. You have to use SDL atomic functions. * * \since This struct is available since SDL 3.2.0. * * \sa SDL_CompareAndSwapAtomicInt * \sa SDL_GetAtomicInt * \sa SDL_SetAtomicInt * \sa SDL_AddAtomicInt */ typedef struct SDL_AtomicInt { int value; } SDL_AtomicInt; /** * Set an atomic variable to a new value if it is currently an old value. * * ***Note: If you don't know what this function is for, you shouldn't use * it!*** * * \param a a pointer to an SDL_AtomicInt variable to be modified. * \param oldval the old value. * \param newval the new value. * \returns true if the atomic variable was set, false otherwise. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetAtomicInt * \sa SDL_SetAtomicInt */ extern SDL_DECLSPEC bool SDLCALL SDL_CompareAndSwapAtomicInt(SDL_AtomicInt *a, int oldval, int newval); /** * Set an atomic variable to a value. * * This function also acts as a full memory barrier. * * ***Note: If you don't know what this function is for, you shouldn't use * it!*** * * \param a a pointer to an SDL_AtomicInt variable to be modified. * \param v the desired value. * \returns the previous value of the atomic variable. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetAtomicInt */ extern SDL_DECLSPEC int SDLCALL SDL_SetAtomicInt(SDL_AtomicInt *a, int v); /** * Get the value of an atomic variable. * * ***Note: If you don't know what this function is for, you shouldn't use * it!*** * * \param a a pointer to an SDL_AtomicInt variable. * \returns the current value of an atomic variable. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_SetAtomicInt */ extern SDL_DECLSPEC int SDLCALL SDL_GetAtomicInt(SDL_AtomicInt *a); /** * Add to an atomic variable. * * This function also acts as a full memory barrier. * * ***Note: If you don't know what this function is for, you shouldn't use * it!*** * * \param a a pointer to an SDL_AtomicInt variable to be modified. * \param v the desired value to add. * \returns the previous value of the atomic variable. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_AtomicDecRef * \sa SDL_AtomicIncRef */ extern SDL_DECLSPEC int SDLCALL SDL_AddAtomicInt(SDL_AtomicInt *a, int v); #ifndef SDL_AtomicIncRef /** * Increment an atomic variable used as a reference count. * * ***Note: If you don't know what this macro is for, you shouldn't use it!*** * * \param a a pointer to an SDL_AtomicInt to increment. * \returns the previous value of the atomic variable. * * \threadsafety It is safe to call this macro from any thread. * * \since This macro is available since SDL 3.2.0. * * \sa SDL_AtomicDecRef */ #define SDL_AtomicIncRef(a) SDL_AddAtomicInt(a, 1) #endif #ifndef SDL_AtomicDecRef /** * Decrement an atomic variable used as a reference count. * * ***Note: If you don't know what this macro is for, you shouldn't use it!*** * * \param a a pointer to an SDL_AtomicInt to decrement. * \returns true if the variable reached zero after decrementing, false * otherwise. * * \threadsafety It is safe to call this macro from any thread. * * \since This macro is available since SDL 3.2.0. * * \sa SDL_AtomicIncRef */ #define SDL_AtomicDecRef(a) (SDL_AddAtomicInt(a, -1) == 1) #endif /** * A type representing an atomic unsigned 32-bit value. * * This can be used to manage a value that is synchronized across multiple * CPUs without a race condition; when an app sets a value with * SDL_SetAtomicU32 all other threads, regardless of the CPU it is running on, * will see that value when retrieved with SDL_GetAtomicU32, regardless of CPU * caches, etc. * * This is also useful for atomic compare-and-swap operations: a thread can * change the value as long as its current value matches expectations. When * done in a loop, one can guarantee data consistency across threads without a * lock (but the usual warnings apply: if you don't know what you're doing, or * you don't do it carefully, you can confidently cause any number of * disasters with this, so in most cases, you _should_ use a mutex instead of * this!). * * This is a struct so people don't accidentally use numeric operations on it * directly. You have to use SDL atomic functions. * * \since This struct is available since SDL 3.2.0. * * \sa SDL_CompareAndSwapAtomicU32 * \sa SDL_GetAtomicU32 * \sa SDL_SetAtomicU32 */ typedef struct SDL_AtomicU32 { Uint32 value; } SDL_AtomicU32; /** * Set an atomic variable to a new value if it is currently an old value. * * ***Note: If you don't know what this function is for, you shouldn't use * it!*** * * \param a a pointer to an SDL_AtomicU32 variable to be modified. * \param oldval the old value. * \param newval the new value. * \returns true if the atomic variable was set, false otherwise. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetAtomicU32 * \sa SDL_SetAtomicU32 */ extern SDL_DECLSPEC bool SDLCALL SDL_CompareAndSwapAtomicU32(SDL_AtomicU32 *a, Uint32 oldval, Uint32 newval); /** * Set an atomic variable to a value. * * This function also acts as a full memory barrier. * * ***Note: If you don't know what this function is for, you shouldn't use * it!*** * * \param a a pointer to an SDL_AtomicU32 variable to be modified. * \param v the desired value. * \returns the previous value of the atomic variable. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetAtomicU32 */ extern SDL_DECLSPEC Uint32 SDLCALL SDL_SetAtomicU32(SDL_AtomicU32 *a, Uint32 v); /** * Get the value of an atomic variable. * * ***Note: If you don't know what this function is for, you shouldn't use * it!*** * * \param a a pointer to an SDL_AtomicU32 variable. * \returns the current value of an atomic variable. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_SetAtomicU32 */ extern SDL_DECLSPEC Uint32 SDLCALL SDL_GetAtomicU32(SDL_AtomicU32 *a); /** * Add to an atomic variable. * * This function also acts as a full memory barrier. * * ***Note: If you don't know what this function is for, you shouldn't use * it!*** * * \param a a pointer to an SDL_AtomicU32 variable to be modified. * \param v the desired value to add or subtract. * \returns the previous value of the atomic variable. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.4.0. */ extern SDL_DECLSPEC Uint32 SDLCALL SDL_AddAtomicU32(SDL_AtomicU32 *a, int v); /** * Set a pointer to a new value if it is currently an old value. * * ***Note: If you don't know what this function is for, you shouldn't use * it!*** * * \param a a pointer to a pointer. * \param oldval the old pointer value. * \param newval the new pointer value. * \returns true if the pointer was set, false otherwise. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_CompareAndSwapAtomicInt * \sa SDL_GetAtomicPointer * \sa SDL_SetAtomicPointer */ extern SDL_DECLSPEC bool SDLCALL SDL_CompareAndSwapAtomicPointer(void **a, void *oldval, void *newval); /** * Set a pointer to a value atomically. * * ***Note: If you don't know what this function is for, you shouldn't use * it!*** * * \param a a pointer to a pointer. * \param v the desired pointer value. * \returns the previous value of the pointer. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_CompareAndSwapAtomicPointer * \sa SDL_GetAtomicPointer */ extern SDL_DECLSPEC void * SDLCALL SDL_SetAtomicPointer(void **a, void *v); /** * Get the value of a pointer atomically. * * ***Note: If you don't know what this function is for, you shouldn't use * it!*** * * \param a a pointer to a pointer. * \returns the current value of a pointer. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_CompareAndSwapAtomicPointer * \sa SDL_SetAtomicPointer */ extern SDL_DECLSPEC void * SDLCALL SDL_GetAtomicPointer(void **a); /* Ends C function definitions when using C++ */ #ifdef __cplusplus } #endif #include #endif /* SDL_atomic_h_ */ ================================================ FILE: deps/include/SDL3/SDL_audio.h ================================================ /* Simple DirectMedia Layer Copyright (C) 1997-2026 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ /** * # CategoryAudio * * Audio functionality for the SDL library. * * All audio in SDL3 revolves around SDL_AudioStream. Whether you want to play * or record audio, convert it, stream it, buffer it, or mix it, you're going * to be passing it through an audio stream. * * Audio streams are quite flexible; they can accept any amount of data at a * time, in any supported format, and output it as needed in any other format, * even if the data format changes on either side halfway through. * * An app opens an audio device and binds any number of audio streams to it, * feeding more data to the streams as available. When the device needs more * data, it will pull it from all bound streams and mix them together for * playback. * * Audio streams can also use an app-provided callback to supply data * on-demand, which maps pretty closely to the SDL2 audio model. * * SDL also provides a simple .WAV loader in SDL_LoadWAV (and SDL_LoadWAV_IO * if you aren't reading from a file) as a basic means to load sound data into * your program. * * ## Logical audio devices * * In SDL3, opening a physical device (like a SoundBlaster 16 Pro) gives you a * logical device ID that you can bind audio streams to. In almost all cases, * logical devices can be used anywhere in the API that a physical device is * normally used. However, since each device opening generates a new logical * device, different parts of the program (say, a VoIP library, or * text-to-speech framework, or maybe some other sort of mixer on top of SDL) * can have their own device opens that do not interfere with each other; each * logical device will mix its separate audio down to a single buffer, fed to * the physical device, behind the scenes. As many logical devices as you like * can come and go; SDL will only have to open the physical device at the OS * level once, and will manage all the logical devices on top of it * internally. * * One other benefit of logical devices: if you don't open a specific physical * device, instead opting for the default, SDL can automatically migrate those * logical devices to different hardware as circumstances change: a user * plugged in headphones? The system default changed? SDL can transparently * migrate the logical devices to the correct physical device seamlessly and * keep playing; the app doesn't even have to know it happened if it doesn't * want to. * * ## Simplified audio * * As a simplified model for when a single source of audio is all that's * needed, an app can use SDL_OpenAudioDeviceStream, which is a single * function to open an audio device, create an audio stream, bind that stream * to the newly-opened device, and (optionally) provide a callback for * obtaining audio data. When using this function, the primary interface is * the SDL_AudioStream and the device handle is mostly hidden away; destroying * a stream created through this function will also close the device, stream * bindings cannot be changed, etc. One other quirk of this is that the device * is started in a _paused_ state and must be explicitly resumed; this is * partially to offer a clean migration for SDL2 apps and partially because * the app might have to do more setup before playback begins; in the * non-simplified form, nothing will play until a stream is bound to a device, * so they start _unpaused_. * * ## Channel layouts * * Audio data passing through SDL is uncompressed PCM data, interleaved. One * can provide their own decompression through an MP3, etc, decoder, but SDL * does not provide this directly. Each interleaved channel of data is meant * to be in a specific order. * * Abbreviations: * * - FRONT = single mono speaker * - FL = front left speaker * - FR = front right speaker * - FC = front center speaker * - BL = back left speaker * - BR = back right speaker * - SR = surround right speaker * - SL = surround left speaker * - BC = back center speaker * - LFE = low-frequency speaker * * These are listed in the order they are laid out in memory, so "FL, FR" * means "the front left speaker is laid out in memory first, then the front * right, then it repeats for the next audio frame". * * - 1 channel (mono) layout: FRONT * - 2 channels (stereo) layout: FL, FR * - 3 channels (2.1) layout: FL, FR, LFE * - 4 channels (quad) layout: FL, FR, BL, BR * - 5 channels (4.1) layout: FL, FR, LFE, BL, BR * - 6 channels (5.1) layout: FL, FR, FC, LFE, BL, BR (last two can also be * SL, SR) * - 7 channels (6.1) layout: FL, FR, FC, LFE, BC, SL, SR * - 8 channels (7.1) layout: FL, FR, FC, LFE, BL, BR, SL, SR * * This is the same order as DirectSound expects, but applied to all * platforms; SDL will swizzle the channels as necessary if a platform expects * something different. * * SDL_AudioStream can also be provided channel maps to change this ordering * to whatever is necessary, in other audio processing scenarios. */ #ifndef SDL_audio_h_ #define SDL_audio_h_ #include #include #include #include #include #include #include /* Set up for C function definitions, even when using C++ */ #ifdef __cplusplus extern "C" { #endif /** * Mask of bits in an SDL_AudioFormat that contains the format bit size. * * Generally one should use SDL_AUDIO_BITSIZE instead of this macro directly. * * \since This macro is available since SDL 3.2.0. */ #define SDL_AUDIO_MASK_BITSIZE (0xFFu) /** * Mask of bits in an SDL_AudioFormat that contain the floating point flag. * * Generally one should use SDL_AUDIO_ISFLOAT instead of this macro directly. * * \since This macro is available since SDL 3.2.0. */ #define SDL_AUDIO_MASK_FLOAT (1u<<8) /** * Mask of bits in an SDL_AudioFormat that contain the bigendian flag. * * Generally one should use SDL_AUDIO_ISBIGENDIAN or SDL_AUDIO_ISLITTLEENDIAN * instead of this macro directly. * * \since This macro is available since SDL 3.2.0. */ #define SDL_AUDIO_MASK_BIG_ENDIAN (1u<<12) /** * Mask of bits in an SDL_AudioFormat that contain the signed data flag. * * Generally one should use SDL_AUDIO_ISSIGNED instead of this macro directly. * * \since This macro is available since SDL 3.2.0. */ #define SDL_AUDIO_MASK_SIGNED (1u<<15) /** * Define an SDL_AudioFormat value. * * SDL does not support custom audio formats, so this macro is not of much use * externally, but it can be illustrative as to what the various bits of an * SDL_AudioFormat mean. * * For example, SDL_AUDIO_S32LE looks like this: * * ```c * SDL_DEFINE_AUDIO_FORMAT(1, 0, 0, 32) * ``` * * \param signed 1 for signed data, 0 for unsigned data. * \param bigendian 1 for bigendian data, 0 for littleendian data. * \param flt 1 for floating point data, 0 for integer data. * \param size number of bits per sample. * \returns a format value in the style of SDL_AudioFormat. * * \threadsafety It is safe to call this macro from any thread. * * \since This macro is available since SDL 3.2.0. */ #define SDL_DEFINE_AUDIO_FORMAT(signed, bigendian, flt, size) \ (((Uint16)(signed) << 15) | ((Uint16)(bigendian) << 12) | ((Uint16)(flt) << 8) | ((size) & SDL_AUDIO_MASK_BITSIZE)) /** * Audio format. * * \since This enum is available since SDL 3.2.0. * * \sa SDL_AUDIO_BITSIZE * \sa SDL_AUDIO_BYTESIZE * \sa SDL_AUDIO_ISINT * \sa SDL_AUDIO_ISFLOAT * \sa SDL_AUDIO_ISBIGENDIAN * \sa SDL_AUDIO_ISLITTLEENDIAN * \sa SDL_AUDIO_ISSIGNED * \sa SDL_AUDIO_ISUNSIGNED */ typedef enum SDL_AudioFormat { SDL_AUDIO_UNKNOWN = 0x0000u, /**< Unspecified audio format */ SDL_AUDIO_U8 = 0x0008u, /**< Unsigned 8-bit samples */ /* SDL_DEFINE_AUDIO_FORMAT(0, 0, 0, 8), */ SDL_AUDIO_S8 = 0x8008u, /**< Signed 8-bit samples */ /* SDL_DEFINE_AUDIO_FORMAT(1, 0, 0, 8), */ SDL_AUDIO_S16LE = 0x8010u, /**< Signed 16-bit samples */ /* SDL_DEFINE_AUDIO_FORMAT(1, 0, 0, 16), */ SDL_AUDIO_S16BE = 0x9010u, /**< As above, but big-endian byte order */ /* SDL_DEFINE_AUDIO_FORMAT(1, 1, 0, 16), */ SDL_AUDIO_S32LE = 0x8020u, /**< 32-bit integer samples */ /* SDL_DEFINE_AUDIO_FORMAT(1, 0, 0, 32), */ SDL_AUDIO_S32BE = 0x9020u, /**< As above, but big-endian byte order */ /* SDL_DEFINE_AUDIO_FORMAT(1, 1, 0, 32), */ SDL_AUDIO_F32LE = 0x8120u, /**< 32-bit floating point samples */ /* SDL_DEFINE_AUDIO_FORMAT(1, 0, 1, 32), */ SDL_AUDIO_F32BE = 0x9120u, /**< As above, but big-endian byte order */ /* SDL_DEFINE_AUDIO_FORMAT(1, 1, 1, 32), */ /* These represent the current system's byteorder. */ #if SDL_BYTEORDER == SDL_LIL_ENDIAN SDL_AUDIO_S16 = SDL_AUDIO_S16LE, SDL_AUDIO_S32 = SDL_AUDIO_S32LE, SDL_AUDIO_F32 = SDL_AUDIO_F32LE #else SDL_AUDIO_S16 = SDL_AUDIO_S16BE, SDL_AUDIO_S32 = SDL_AUDIO_S32BE, SDL_AUDIO_F32 = SDL_AUDIO_F32BE #endif } SDL_AudioFormat; /** * Retrieve the size, in bits, from an SDL_AudioFormat. * * For example, `SDL_AUDIO_BITSIZE(SDL_AUDIO_S16)` returns 16. * * \param x an SDL_AudioFormat value. * \returns data size in bits. * * \threadsafety It is safe to call this macro from any thread. * * \since This macro is available since SDL 3.2.0. */ #define SDL_AUDIO_BITSIZE(x) ((x) & SDL_AUDIO_MASK_BITSIZE) /** * Retrieve the size, in bytes, from an SDL_AudioFormat. * * For example, `SDL_AUDIO_BYTESIZE(SDL_AUDIO_S16)` returns 2. * * \param x an SDL_AudioFormat value. * \returns data size in bytes. * * \threadsafety It is safe to call this macro from any thread. * * \since This macro is available since SDL 3.2.0. */ #define SDL_AUDIO_BYTESIZE(x) (SDL_AUDIO_BITSIZE(x) / 8) /** * Determine if an SDL_AudioFormat represents floating point data. * * For example, `SDL_AUDIO_ISFLOAT(SDL_AUDIO_S16)` returns 0. * * \param x an SDL_AudioFormat value. * \returns non-zero if format is floating point, zero otherwise. * * \threadsafety It is safe to call this macro from any thread. * * \since This macro is available since SDL 3.2.0. */ #define SDL_AUDIO_ISFLOAT(x) ((x) & SDL_AUDIO_MASK_FLOAT) /** * Determine if an SDL_AudioFormat represents bigendian data. * * For example, `SDL_AUDIO_ISBIGENDIAN(SDL_AUDIO_S16LE)` returns 0. * * \param x an SDL_AudioFormat value. * \returns non-zero if format is bigendian, zero otherwise. * * \threadsafety It is safe to call this macro from any thread. * * \since This macro is available since SDL 3.2.0. */ #define SDL_AUDIO_ISBIGENDIAN(x) ((x) & SDL_AUDIO_MASK_BIG_ENDIAN) /** * Determine if an SDL_AudioFormat represents littleendian data. * * For example, `SDL_AUDIO_ISLITTLEENDIAN(SDL_AUDIO_S16BE)` returns 0. * * \param x an SDL_AudioFormat value. * \returns non-zero if format is littleendian, zero otherwise. * * \threadsafety It is safe to call this macro from any thread. * * \since This macro is available since SDL 3.2.0. */ #define SDL_AUDIO_ISLITTLEENDIAN(x) (!SDL_AUDIO_ISBIGENDIAN(x)) /** * Determine if an SDL_AudioFormat represents signed data. * * For example, `SDL_AUDIO_ISSIGNED(SDL_AUDIO_U8)` returns 0. * * \param x an SDL_AudioFormat value. * \returns non-zero if format is signed, zero otherwise. * * \threadsafety It is safe to call this macro from any thread. * * \since This macro is available since SDL 3.2.0. */ #define SDL_AUDIO_ISSIGNED(x) ((x) & SDL_AUDIO_MASK_SIGNED) /** * Determine if an SDL_AudioFormat represents integer data. * * For example, `SDL_AUDIO_ISINT(SDL_AUDIO_F32)` returns 0. * * \param x an SDL_AudioFormat value. * \returns non-zero if format is integer, zero otherwise. * * \threadsafety It is safe to call this macro from any thread. * * \since This macro is available since SDL 3.2.0. */ #define SDL_AUDIO_ISINT(x) (!SDL_AUDIO_ISFLOAT(x)) /** * Determine if an SDL_AudioFormat represents unsigned data. * * For example, `SDL_AUDIO_ISUNSIGNED(SDL_AUDIO_S16)` returns 0. * * \param x an SDL_AudioFormat value. * \returns non-zero if format is unsigned, zero otherwise. * * \threadsafety It is safe to call this macro from any thread. * * \since This macro is available since SDL 3.2.0. */ #define SDL_AUDIO_ISUNSIGNED(x) (!SDL_AUDIO_ISSIGNED(x)) /** * SDL Audio Device instance IDs. * * Zero is used to signify an invalid/null device. * * \since This datatype is available since SDL 3.2.0. */ typedef Uint32 SDL_AudioDeviceID; /** * A value used to request a default playback audio device. * * Several functions that require an SDL_AudioDeviceID will accept this value * to signify the app just wants the system to choose a default device instead * of the app providing a specific one. * * \since This macro is available since SDL 3.2.0. */ #define SDL_AUDIO_DEVICE_DEFAULT_PLAYBACK ((SDL_AudioDeviceID) 0xFFFFFFFFu) /** * A value used to request a default recording audio device. * * Several functions that require an SDL_AudioDeviceID will accept this value * to signify the app just wants the system to choose a default device instead * of the app providing a specific one. * * \since This macro is available since SDL 3.2.0. */ #define SDL_AUDIO_DEVICE_DEFAULT_RECORDING ((SDL_AudioDeviceID) 0xFFFFFFFEu) /** * Format specifier for audio data. * * \since This struct is available since SDL 3.2.0. * * \sa SDL_AudioFormat */ typedef struct SDL_AudioSpec { SDL_AudioFormat format; /**< Audio data format */ int channels; /**< Number of channels: 1 mono, 2 stereo, etc */ int freq; /**< sample rate: sample frames per second */ } SDL_AudioSpec; /** * Calculate the size of each audio frame (in bytes) from an SDL_AudioSpec. * * This reports on the size of an audio sample frame: stereo Sint16 data (2 * channels of 2 bytes each) would be 4 bytes per frame, for example. * * \param x an SDL_AudioSpec to query. * \returns the number of bytes used per sample frame. * * \threadsafety It is safe to call this macro from any thread. * * \since This macro is available since SDL 3.2.0. */ #define SDL_AUDIO_FRAMESIZE(x) (SDL_AUDIO_BYTESIZE((x).format) * (x).channels) /** * The opaque handle that represents an audio stream. * * SDL_AudioStream is an audio conversion interface. * * - It can handle resampling data in chunks without generating artifacts, * when it doesn't have the complete buffer available. * - It can handle incoming data in any variable size. * - It can handle input/output format changes on the fly. * - It can remap audio channels between inputs and outputs. * - You push data as you have it, and pull it when you need it * - It can also function as a basic audio data queue even if you just have * sound that needs to pass from one place to another. * - You can hook callbacks up to them when more data is added or requested, * to manage data on-the-fly. * * Audio streams are the core of the SDL3 audio interface. You create one or * more of them, bind them to an opened audio device, and feed data to them * (or for recording, consume data from them). * * \since This struct is available since SDL 3.2.0. * * \sa SDL_CreateAudioStream */ typedef struct SDL_AudioStream SDL_AudioStream; /* Function prototypes */ /** * Use this function to get the number of built-in audio drivers. * * This function returns a hardcoded number. This never returns a negative * value; if there are no drivers compiled into this build of SDL, this * function returns zero. The presence of a driver in this list does not mean * it will function, it just means SDL is capable of interacting with that * interface. For example, a build of SDL might have esound support, but if * there's no esound server available, SDL's esound driver would fail if used. * * By default, SDL tries all drivers, in its preferred order, until one is * found to be usable. * * \returns the number of built-in audio drivers. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetAudioDriver */ extern SDL_DECLSPEC int SDLCALL SDL_GetNumAudioDrivers(void); /** * Use this function to get the name of a built in audio driver. * * The list of audio drivers is given in the order that they are normally * initialized by default; the drivers that seem more reasonable to choose * first (as far as the SDL developers believe) are earlier in the list. * * The names of drivers are all simple, low-ASCII identifiers, like "alsa", * "coreaudio" or "wasapi". These never have Unicode characters, and are not * meant to be proper names. * * \param index the index of the audio driver; the value ranges from 0 to * SDL_GetNumAudioDrivers() - 1. * \returns the name of the audio driver at the requested index, or NULL if an * invalid index was specified. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetNumAudioDrivers */ extern SDL_DECLSPEC const char * SDLCALL SDL_GetAudioDriver(int index); /** * Get the name of the current audio driver. * * The names of drivers are all simple, low-ASCII identifiers, like "alsa", * "coreaudio" or "wasapi". These never have Unicode characters, and are not * meant to be proper names. * * \returns the name of the current audio driver or NULL if no driver has been * initialized. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC const char * SDLCALL SDL_GetCurrentAudioDriver(void); /** * Get a list of currently-connected audio playback devices. * * This returns of list of available devices that play sound, perhaps to * speakers or headphones ("playback" devices). If you want devices that * record audio, like a microphone ("recording" devices), use * SDL_GetAudioRecordingDevices() instead. * * This only returns a list of physical devices; it will not have any device * IDs returned by SDL_OpenAudioDevice(). * * If this function returns NULL, to signify an error, `*count` will be set to * zero. * * \param count a pointer filled in with the number of devices returned, may * be NULL. * \returns a 0 terminated array of device instance IDs or NULL on error; call * SDL_GetError() for more information. This should be freed with * SDL_free() when it is no longer needed. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_OpenAudioDevice * \sa SDL_GetAudioRecordingDevices */ extern SDL_DECLSPEC SDL_AudioDeviceID * SDLCALL SDL_GetAudioPlaybackDevices(int *count); /** * Get a list of currently-connected audio recording devices. * * This returns of list of available devices that record audio, like a * microphone ("recording" devices). If you want devices that play sound, * perhaps to speakers or headphones ("playback" devices), use * SDL_GetAudioPlaybackDevices() instead. * * This only returns a list of physical devices; it will not have any device * IDs returned by SDL_OpenAudioDevice(). * * If this function returns NULL, to signify an error, `*count` will be set to * zero. * * \param count a pointer filled in with the number of devices returned, may * be NULL. * \returns a 0 terminated array of device instance IDs, or NULL on failure; * call SDL_GetError() for more information. This should be freed * with SDL_free() when it is no longer needed. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_OpenAudioDevice * \sa SDL_GetAudioPlaybackDevices */ extern SDL_DECLSPEC SDL_AudioDeviceID * SDLCALL SDL_GetAudioRecordingDevices(int *count); /** * Get the human-readable name of a specific audio device. * * **WARNING**: this function will work with SDL_AUDIO_DEVICE_DEFAULT_PLAYBACK * and SDL_AUDIO_DEVICE_DEFAULT_RECORDING, returning the current default * physical devices' names. However, as the default device may change at any * time, it is likely better to show a generic name to the user, like "System * default audio device" or perhaps "default [currently %s]". Do not store * this name to disk to reidentify the device in a later run of the program, * as the default might change in general, and the string will be the name of * a specific device and not the abstract system default. * * \param devid the instance ID of the device to query. * \returns the name of the audio device, or NULL on failure; call * SDL_GetError() for more information. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetAudioPlaybackDevices * \sa SDL_GetAudioRecordingDevices */ extern SDL_DECLSPEC const char * SDLCALL SDL_GetAudioDeviceName(SDL_AudioDeviceID devid); /** * Get the current audio format of a specific audio device. * * For an opened device, this will report the format the device is currently * using. If the device isn't yet opened, this will report the device's * preferred format (or a reasonable default if this can't be determined). * * You may also specify SDL_AUDIO_DEVICE_DEFAULT_PLAYBACK or * SDL_AUDIO_DEVICE_DEFAULT_RECORDING here, which is useful for getting a * reasonable recommendation before opening the system-recommended default * device. * * You can also use this to request the current device buffer size. This is * specified in sample frames and represents the amount of data SDL will feed * to the physical hardware in each chunk. This can be converted to * milliseconds of audio with the following equation: * * `ms = (int) ((((Sint64) frames) * 1000) / spec.freq);` * * Buffer size is only important if you need low-level control over the audio * playback timing. Most apps do not need this. * * \param devid the instance ID of the device to query. * \param spec on return, will be filled with device details. * \param sample_frames pointer to store device buffer size, in sample frames. * Can be NULL. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC bool SDLCALL SDL_GetAudioDeviceFormat(SDL_AudioDeviceID devid, SDL_AudioSpec *spec, int *sample_frames); /** * Get the current channel map of an audio device. * * Channel maps are optional; most things do not need them, instead passing * data in the [order that SDL expects](CategoryAudio#channel-layouts). * * Audio devices usually have no remapping applied. This is represented by * returning NULL, and does not signify an error. * * \param devid the instance ID of the device to query. * \param count On output, set to number of channels in the map. Can be NULL. * \returns an array of the current channel mapping, with as many elements as * the current output spec's channels, or NULL if default. This * should be freed with SDL_free() when it is no longer needed. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_SetAudioStreamInputChannelMap */ extern SDL_DECLSPEC int * SDLCALL SDL_GetAudioDeviceChannelMap(SDL_AudioDeviceID devid, int *count); /** * Open a specific audio device. * * You can open both playback and recording devices through this function. * Playback devices will take data from bound audio streams, mix it, and send * it to the hardware. Recording devices will feed any bound audio streams * with a copy of any incoming data. * * An opened audio device starts out with no audio streams bound. To start * audio playing, bind a stream and supply audio data to it. Unlike SDL2, * there is no audio callback; you only bind audio streams and make sure they * have data flowing into them (however, you can simulate SDL2's semantics * fairly closely by using SDL_OpenAudioDeviceStream instead of this * function). * * If you don't care about opening a specific device, pass a `devid` of either * `SDL_AUDIO_DEVICE_DEFAULT_PLAYBACK` or * `SDL_AUDIO_DEVICE_DEFAULT_RECORDING`. In this case, SDL will try to pick * the most reasonable default, and may also switch between physical devices * seamlessly later, if the most reasonable default changes during the * lifetime of this opened device (user changed the default in the OS's system * preferences, the default got unplugged so the system jumped to a new * default, the user plugged in headphones on a mobile device, etc). Unless * you have a good reason to choose a specific device, this is probably what * you want. * * You may request a specific format for the audio device, but there is no * promise the device will honor that request for several reasons. As such, * it's only meant to be a hint as to what data your app will provide. Audio * streams will accept data in whatever format you specify and manage * conversion for you as appropriate. SDL_GetAudioDeviceFormat can tell you * the preferred format for the device before opening and the actual format * the device is using after opening. * * It's legal to open the same device ID more than once; each successful open * will generate a new logical SDL_AudioDeviceID that is managed separately * from others on the same physical device. This allows libraries to open a * device separately from the main app and bind its own streams without * conflicting. * * It is also legal to open a device ID returned by a previous call to this * function; doing so just creates another logical device on the same physical * device. This may be useful for making logical groupings of audio streams. * * This function returns the opened device ID on success. This is a new, * unique SDL_AudioDeviceID that represents a logical device. * * Some backends might offer arbitrary devices (for example, a networked audio * protocol that can connect to an arbitrary server). For these, as a change * from SDL2, you should open a default device ID and use an SDL hint to * specify the target if you care, or otherwise let the backend figure out a * reasonable default. Most backends don't offer anything like this, and often * this would be an end user setting an environment variable for their custom * need, and not something an application should specifically manage. * * When done with an audio device, possibly at the end of the app's life, one * should call SDL_CloseAudioDevice() on the returned device id. * * \param devid the device instance id to open, or * SDL_AUDIO_DEVICE_DEFAULT_PLAYBACK or * SDL_AUDIO_DEVICE_DEFAULT_RECORDING for the most reasonable * default device. * \param spec the requested device configuration. Can be NULL to use * reasonable defaults. * \returns the device ID on success or 0 on failure; call SDL_GetError() for * more information. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_CloseAudioDevice * \sa SDL_GetAudioDeviceFormat */ extern SDL_DECLSPEC SDL_AudioDeviceID SDLCALL SDL_OpenAudioDevice(SDL_AudioDeviceID devid, const SDL_AudioSpec *spec); /** * Determine if an audio device is physical (instead of logical). * * An SDL_AudioDeviceID that represents physical hardware is a physical * device; there is one for each piece of hardware that SDL can see. Logical * devices are created by calling SDL_OpenAudioDevice or * SDL_OpenAudioDeviceStream, and while each is associated with a physical * device, there can be any number of logical devices on one physical device. * * For the most part, logical and physical IDs are interchangeable--if you try * to open a logical device, SDL understands to assign that effort to the * underlying physical device, etc. However, it might be useful to know if an * arbitrary device ID is physical or logical. This function reports which. * * This function may return either true or false for invalid device IDs. * * \param devid the device ID to query. * \returns true if devid is a physical device, false if it is logical. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC bool SDLCALL SDL_IsAudioDevicePhysical(SDL_AudioDeviceID devid); /** * Determine if an audio device is a playback device (instead of recording). * * This function may return either true or false for invalid device IDs. * * \param devid the device ID to query. * \returns true if devid is a playback device, false if it is recording. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC bool SDLCALL SDL_IsAudioDevicePlayback(SDL_AudioDeviceID devid); /** * Use this function to pause audio playback on a specified device. * * This function pauses audio processing for a given device. Any bound audio * streams will not progress, and no audio will be generated. Pausing one * device does not prevent other unpaused devices from running. * * Unlike in SDL2, audio devices start in an _unpaused_ state, since an app * has to bind a stream before any audio will flow. Pausing a paused device is * a legal no-op. * * Pausing a device can be useful to halt all audio without unbinding all the * audio streams. This might be useful while a game is paused, or a level is * loading, etc. * * Physical devices can not be paused or unpaused, only logical devices * created through SDL_OpenAudioDevice() can be. * * \param devid a device opened by SDL_OpenAudioDevice(). * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_ResumeAudioDevice * \sa SDL_AudioDevicePaused */ extern SDL_DECLSPEC bool SDLCALL SDL_PauseAudioDevice(SDL_AudioDeviceID devid); /** * Use this function to unpause audio playback on a specified device. * * This function unpauses audio processing for a given device that has * previously been paused with SDL_PauseAudioDevice(). Once unpaused, any * bound audio streams will begin to progress again, and audio can be * generated. * * Unlike in SDL2, audio devices start in an _unpaused_ state, since an app * has to bind a stream before any audio will flow. Unpausing an unpaused * device is a legal no-op. * * Physical devices can not be paused or unpaused, only logical devices * created through SDL_OpenAudioDevice() can be. * * \param devid a device opened by SDL_OpenAudioDevice(). * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_AudioDevicePaused * \sa SDL_PauseAudioDevice */ extern SDL_DECLSPEC bool SDLCALL SDL_ResumeAudioDevice(SDL_AudioDeviceID devid); /** * Use this function to query if an audio device is paused. * * Unlike in SDL2, audio devices start in an _unpaused_ state, since an app * has to bind a stream before any audio will flow. * * Physical devices can not be paused or unpaused, only logical devices * created through SDL_OpenAudioDevice() can be. Physical and invalid device * IDs will report themselves as unpaused here. * * \param devid a device opened by SDL_OpenAudioDevice(). * \returns true if device is valid and paused, false otherwise. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_PauseAudioDevice * \sa SDL_ResumeAudioDevice */ extern SDL_DECLSPEC bool SDLCALL SDL_AudioDevicePaused(SDL_AudioDeviceID devid); /** * Get the gain of an audio device. * * The gain of a device is its volume; a larger gain means a louder output, * with a gain of zero being silence. * * Audio devices default to a gain of 1.0f (no change in output). * * Physical devices may not have their gain changed, only logical devices, and * this function will always return -1.0f when used on physical devices. * * \param devid the audio device to query. * \returns the gain of the device or -1.0f on failure; call SDL_GetError() * for more information. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_SetAudioDeviceGain */ extern SDL_DECLSPEC float SDLCALL SDL_GetAudioDeviceGain(SDL_AudioDeviceID devid); /** * Change the gain of an audio device. * * The gain of a device is its volume; a larger gain means a louder output, * with a gain of zero being silence. * * Audio devices default to a gain of 1.0f (no change in output). * * Physical devices may not have their gain changed, only logical devices, and * this function will always return false when used on physical devices. While * it might seem attractive to adjust several logical devices at once in this * way, it would allow an app or library to interfere with another portion of * the program's otherwise-isolated devices. * * This is applied, along with any per-audiostream gain, during playback to * the hardware, and can be continuously changed to create various effects. On * recording devices, this will adjust the gain before passing the data into * an audiostream; that recording audiostream can then adjust its gain further * when outputting the data elsewhere, if it likes, but that second gain is * not applied until the data leaves the audiostream again. * * \param devid the audio device on which to change gain. * \param gain the gain. 1.0f is no change, 0.0f is silence. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety It is safe to call this function from any thread, as it holds * a stream-specific mutex while running. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetAudioDeviceGain */ extern SDL_DECLSPEC bool SDLCALL SDL_SetAudioDeviceGain(SDL_AudioDeviceID devid, float gain); /** * Close a previously-opened audio device. * * The application should close open audio devices once they are no longer * needed. * * This function may block briefly while pending audio data is played by the * hardware, so that applications don't drop the last buffer of data they * supplied if terminating immediately afterwards. * * \param devid an audio device id previously returned by * SDL_OpenAudioDevice(). * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_OpenAudioDevice */ extern SDL_DECLSPEC void SDLCALL SDL_CloseAudioDevice(SDL_AudioDeviceID devid); /** * Bind a list of audio streams to an audio device. * * Audio data will flow through any bound streams. For a playback device, data * for all bound streams will be mixed together and fed to the device. For a * recording device, a copy of recorded data will be provided to each bound * stream. * * Audio streams can only be bound to an open device. This operation is * atomic--all streams bound in the same call will start processing at the * same time, so they can stay in sync. Also: either all streams will be bound * or none of them will be. * * It is an error to bind an already-bound stream; it must be explicitly * unbound first. * * Binding a stream to a device will set its output format for playback * devices, and its input format for recording devices, so they match the * device's settings. The caller is welcome to change the other end of the * stream's format at any time with SDL_SetAudioStreamFormat(). If the other * end of the stream's format has never been set (the audio stream was created * with a NULL audio spec), this function will set it to match the device * end's format. * * \param devid an audio device to bind a stream to. * \param streams an array of audio streams to bind. * \param num_streams number streams listed in the `streams` array. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_BindAudioStreams * \sa SDL_UnbindAudioStream * \sa SDL_GetAudioStreamDevice */ extern SDL_DECLSPEC bool SDLCALL SDL_BindAudioStreams(SDL_AudioDeviceID devid, SDL_AudioStream * const *streams, int num_streams); /** * Bind a single audio stream to an audio device. * * This is a convenience function, equivalent to calling * `SDL_BindAudioStreams(devid, &stream, 1)`. * * \param devid an audio device to bind a stream to. * \param stream an audio stream to bind to a device. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_BindAudioStreams * \sa SDL_UnbindAudioStream * \sa SDL_GetAudioStreamDevice */ extern SDL_DECLSPEC bool SDLCALL SDL_BindAudioStream(SDL_AudioDeviceID devid, SDL_AudioStream *stream); /** * Unbind a list of audio streams from their audio devices. * * The streams being unbound do not all have to be on the same device. All * streams on the same device will be unbound atomically (data will stop * flowing through all unbound streams on the same device at the same time). * * Unbinding a stream that isn't bound to a device is a legal no-op. * * \param streams an array of audio streams to unbind. Can be NULL or contain * NULL. * \param num_streams number streams listed in the `streams` array. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_BindAudioStreams */ extern SDL_DECLSPEC void SDLCALL SDL_UnbindAudioStreams(SDL_AudioStream * const *streams, int num_streams); /** * Unbind a single audio stream from its audio device. * * This is a convenience function, equivalent to calling * `SDL_UnbindAudioStreams(&stream, 1)`. * * \param stream an audio stream to unbind from a device. Can be NULL. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_BindAudioStream */ extern SDL_DECLSPEC void SDLCALL SDL_UnbindAudioStream(SDL_AudioStream *stream); /** * Query an audio stream for its currently-bound device. * * This reports the logical audio device that an audio stream is currently * bound to. * * If not bound, or invalid, this returns zero, which is not a valid device * ID. * * \param stream the audio stream to query. * \returns the bound audio device, or 0 if not bound or invalid. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_BindAudioStream * \sa SDL_BindAudioStreams */ extern SDL_DECLSPEC SDL_AudioDeviceID SDLCALL SDL_GetAudioStreamDevice(SDL_AudioStream *stream); /** * Create a new audio stream. * * \param src_spec the format details of the input audio. * \param dst_spec the format details of the output audio. * \returns a new audio stream on success or NULL on failure; call * SDL_GetError() for more information. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_PutAudioStreamData * \sa SDL_GetAudioStreamData * \sa SDL_GetAudioStreamAvailable * \sa SDL_FlushAudioStream * \sa SDL_ClearAudioStream * \sa SDL_SetAudioStreamFormat * \sa SDL_DestroyAudioStream */ extern SDL_DECLSPEC SDL_AudioStream * SDLCALL SDL_CreateAudioStream(const SDL_AudioSpec *src_spec, const SDL_AudioSpec *dst_spec); /** * Get the properties associated with an audio stream. * * The application can hang any data it wants here, but the following * properties are understood by SDL: * * - `SDL_PROP_AUDIOSTREAM_AUTO_CLEANUP_BOOLEAN`: if true (the default), the * stream be automatically cleaned up when the audio subsystem quits. If set * to false, the streams will persist beyond that. This property is ignored * for streams created through SDL_OpenAudioDeviceStream(), and will always * be cleaned up. Streams that are not cleaned up will still be unbound from * devices when the audio subsystem quits. This property was added in SDL * 3.4.0. * * \param stream the SDL_AudioStream to query. * \returns a valid property ID on success or 0 on failure; call * SDL_GetError() for more information. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC SDL_PropertiesID SDLCALL SDL_GetAudioStreamProperties(SDL_AudioStream *stream); #define SDL_PROP_AUDIOSTREAM_AUTO_CLEANUP_BOOLEAN "SDL.audiostream.auto_cleanup" /** * Query the current format of an audio stream. * * \param stream the SDL_AudioStream to query. * \param src_spec where to store the input audio format; ignored if NULL. * \param dst_spec where to store the output audio format; ignored if NULL. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety It is safe to call this function from any thread, as it holds * a stream-specific mutex while running. * * \since This function is available since SDL 3.2.0. * * \sa SDL_SetAudioStreamFormat */ extern SDL_DECLSPEC bool SDLCALL SDL_GetAudioStreamFormat(SDL_AudioStream *stream, SDL_AudioSpec *src_spec, SDL_AudioSpec *dst_spec); /** * Change the input and output formats of an audio stream. * * Future calls to and SDL_GetAudioStreamAvailable and SDL_GetAudioStreamData * will reflect the new format, and future calls to SDL_PutAudioStreamData * must provide data in the new input formats. * * Data that was previously queued in the stream will still be operated on in * the format that was current when it was added, which is to say you can put * the end of a sound file in one format to a stream, change formats for the * next sound file, and start putting that new data while the previous sound * file is still queued, and everything will still play back correctly. * * If a stream is bound to a device, then the format of the side of the stream * bound to a device cannot be changed (src_spec for recording devices, * dst_spec for playback devices). Attempts to make a change to this side will * be ignored, but this will not report an error. The other side's format can * be changed. * * \param stream the stream the format is being changed. * \param src_spec the new format of the audio input; if NULL, it is not * changed. * \param dst_spec the new format of the audio output; if NULL, it is not * changed. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety It is safe to call this function from any thread, as it holds * a stream-specific mutex while running. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetAudioStreamFormat * \sa SDL_SetAudioStreamFrequencyRatio */ extern SDL_DECLSPEC bool SDLCALL SDL_SetAudioStreamFormat(SDL_AudioStream *stream, const SDL_AudioSpec *src_spec, const SDL_AudioSpec *dst_spec); /** * Get the frequency ratio of an audio stream. * * \param stream the SDL_AudioStream to query. * \returns the frequency ratio of the stream or 0.0 on failure; call * SDL_GetError() for more information. * * \threadsafety It is safe to call this function from any thread, as it holds * a stream-specific mutex while running. * * \since This function is available since SDL 3.2.0. * * \sa SDL_SetAudioStreamFrequencyRatio */ extern SDL_DECLSPEC float SDLCALL SDL_GetAudioStreamFrequencyRatio(SDL_AudioStream *stream); /** * Change the frequency ratio of an audio stream. * * The frequency ratio is used to adjust the rate at which input data is * consumed. Changing this effectively modifies the speed and pitch of the * audio. A value greater than 1.0f will play the audio faster, and at a * higher pitch. A value less than 1.0f will play the audio slower, and at a * lower pitch. 1.0f means play at normal speed. * * This is applied during SDL_GetAudioStreamData, and can be continuously * changed to create various effects. * * \param stream the stream on which the frequency ratio is being changed. * \param ratio the frequency ratio. 1.0 is normal speed. Must be between 0.01 * and 100. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety It is safe to call this function from any thread, as it holds * a stream-specific mutex while running. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetAudioStreamFrequencyRatio * \sa SDL_SetAudioStreamFormat */ extern SDL_DECLSPEC bool SDLCALL SDL_SetAudioStreamFrequencyRatio(SDL_AudioStream *stream, float ratio); /** * Get the gain of an audio stream. * * The gain of a stream is its volume; a larger gain means a louder output, * with a gain of zero being silence. * * Audio streams default to a gain of 1.0f (no change in output). * * \param stream the SDL_AudioStream to query. * \returns the gain of the stream or -1.0f on failure; call SDL_GetError() * for more information. * * \threadsafety It is safe to call this function from any thread, as it holds * a stream-specific mutex while running. * * \since This function is available since SDL 3.2.0. * * \sa SDL_SetAudioStreamGain */ extern SDL_DECLSPEC float SDLCALL SDL_GetAudioStreamGain(SDL_AudioStream *stream); /** * Change the gain of an audio stream. * * The gain of a stream is its volume; a larger gain means a louder output, * with a gain of zero being silence. * * Audio streams default to a gain of 1.0f (no change in output). * * This is applied during SDL_GetAudioStreamData, and can be continuously * changed to create various effects. * * \param stream the stream on which the gain is being changed. * \param gain the gain. 1.0f is no change, 0.0f is silence. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety It is safe to call this function from any thread, as it holds * a stream-specific mutex while running. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetAudioStreamGain */ extern SDL_DECLSPEC bool SDLCALL SDL_SetAudioStreamGain(SDL_AudioStream *stream, float gain); /** * Get the current input channel map of an audio stream. * * Channel maps are optional; most things do not need them, instead passing * data in the [order that SDL expects](CategoryAudio#channel-layouts). * * Audio streams default to no remapping applied. This is represented by * returning NULL, and does not signify an error. * * \param stream the SDL_AudioStream to query. * \param count On output, set to number of channels in the map. Can be NULL. * \returns an array of the current channel mapping, with as many elements as * the current output spec's channels, or NULL if default. This * should be freed with SDL_free() when it is no longer needed. * * \threadsafety It is safe to call this function from any thread, as it holds * a stream-specific mutex while running. * * \since This function is available since SDL 3.2.0. * * \sa SDL_SetAudioStreamInputChannelMap */ extern SDL_DECLSPEC int * SDLCALL SDL_GetAudioStreamInputChannelMap(SDL_AudioStream *stream, int *count); /** * Get the current output channel map of an audio stream. * * Channel maps are optional; most things do not need them, instead passing * data in the [order that SDL expects](CategoryAudio#channel-layouts). * * Audio streams default to no remapping applied. This is represented by * returning NULL, and does not signify an error. * * \param stream the SDL_AudioStream to query. * \param count On output, set to number of channels in the map. Can be NULL. * \returns an array of the current channel mapping, with as many elements as * the current output spec's channels, or NULL if default. This * should be freed with SDL_free() when it is no longer needed. * * \threadsafety It is safe to call this function from any thread, as it holds * a stream-specific mutex while running. * * \since This function is available since SDL 3.2.0. * * \sa SDL_SetAudioStreamInputChannelMap */ extern SDL_DECLSPEC int * SDLCALL SDL_GetAudioStreamOutputChannelMap(SDL_AudioStream *stream, int *count); /** * Set the current input channel map of an audio stream. * * Channel maps are optional; most things do not need them, instead passing * data in the [order that SDL expects](CategoryAudio#channel-layouts). * * The input channel map reorders data that is added to a stream via * SDL_PutAudioStreamData. Future calls to SDL_PutAudioStreamData must provide * data in the new channel order. * * Each item in the array represents an input channel, and its value is the * channel that it should be remapped to. To reverse a stereo signal's left * and right values, you'd have an array of `{ 1, 0 }`. It is legal to remap * multiple channels to the same thing, so `{ 1, 1 }` would duplicate the * right channel to both channels of a stereo signal. An element in the * channel map set to -1 instead of a valid channel will mute that channel, * setting it to a silence value. * * You cannot change the number of channels through a channel map, just * reorder/mute them. * * Data that was previously queued in the stream will still be operated on in * the order that was current when it was added, which is to say you can put * the end of a sound file in one order to a stream, change orders for the * next sound file, and start putting that new data while the previous sound * file is still queued, and everything will still play back correctly. * * Audio streams default to no remapping applied. Passing a NULL channel map * is legal, and turns off remapping. * * SDL will copy the channel map; the caller does not have to save this array * after this call. * * If `count` is not equal to the current number of channels in the audio * stream's format, this will fail. This is a safety measure to make sure a * race condition hasn't changed the format while this call is setting the * channel map. * * Unlike attempting to change the stream's format, the input channel map on a * stream bound to a recording device is permitted to change at any time; any * data added to the stream from the device after this call will have the new * mapping, but previously-added data will still have the prior mapping. * * \param stream the SDL_AudioStream to change. * \param chmap the new channel map, NULL to reset to default. * \param count The number of channels in the map. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety It is safe to call this function from any thread, as it holds * a stream-specific mutex while running. Don't change the * stream's format to have a different number of channels from a * different thread at the same time, though! * * \since This function is available since SDL 3.2.0. * * \sa SDL_SetAudioStreamOutputChannelMap */ extern SDL_DECLSPEC bool SDLCALL SDL_SetAudioStreamInputChannelMap(SDL_AudioStream *stream, const int *chmap, int count); /** * Set the current output channel map of an audio stream. * * Channel maps are optional; most things do not need them, instead passing * data in the [order that SDL expects](CategoryAudio#channel-layouts). * * The output channel map reorders data that is leaving a stream via * SDL_GetAudioStreamData. * * Each item in the array represents an input channel, and its value is the * channel that it should be remapped to. To reverse a stereo signal's left * and right values, you'd have an array of `{ 1, 0 }`. It is legal to remap * multiple channels to the same thing, so `{ 1, 1 }` would duplicate the * right channel to both channels of a stereo signal. An element in the * channel map set to -1 instead of a valid channel will mute that channel, * setting it to a silence value. * * You cannot change the number of channels through a channel map, just * reorder/mute them. * * The output channel map can be changed at any time, as output remapping is * applied during SDL_GetAudioStreamData. * * Audio streams default to no remapping applied. Passing a NULL channel map * is legal, and turns off remapping. * * SDL will copy the channel map; the caller does not have to save this array * after this call. * * If `count` is not equal to the current number of channels in the audio * stream's format, this will fail. This is a safety measure to make sure a * race condition hasn't changed the format while this call is setting the * channel map. * * Unlike attempting to change the stream's format, the output channel map on * a stream bound to a recording device is permitted to change at any time; * any data added to the stream after this call will have the new mapping, but * previously-added data will still have the prior mapping. When the channel * map doesn't match the hardware's channel layout, SDL will convert the data * before feeding it to the device for playback. * * \param stream the SDL_AudioStream to change. * \param chmap the new channel map, NULL to reset to default. * \param count The number of channels in the map. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety It is safe to call this function from any thread, as it holds * a stream-specific mutex while running. Don't change the * stream's format to have a different number of channels from a * a different thread at the same time, though! * * \since This function is available since SDL 3.2.0. * * \sa SDL_SetAudioStreamInputChannelMap */ extern SDL_DECLSPEC bool SDLCALL SDL_SetAudioStreamOutputChannelMap(SDL_AudioStream *stream, const int *chmap, int count); /** * Add data to the stream. * * This data must match the format/channels/samplerate specified in the latest * call to SDL_SetAudioStreamFormat, or the format specified when creating the * stream if it hasn't been changed. * * Note that this call simply copies the unconverted data for later. This is * different than SDL2, where data was converted during the Put call and the * Get call would just dequeue the previously-converted data. * * \param stream the stream the audio data is being added to. * \param buf a pointer to the audio data to add. * \param len the number of bytes to write to the stream. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety It is safe to call this function from any thread, but if the * stream has a callback set, the caller might need to manage * extra locking. * * \since This function is available since SDL 3.2.0. * * \sa SDL_ClearAudioStream * \sa SDL_FlushAudioStream * \sa SDL_GetAudioStreamData * \sa SDL_GetAudioStreamQueued */ extern SDL_DECLSPEC bool SDLCALL SDL_PutAudioStreamData(SDL_AudioStream *stream, const void *buf, int len); /** * A callback that fires for completed SDL_PutAudioStreamDataNoCopy() data. * * When using SDL_PutAudioStreamDataNoCopy() to provide data to an * SDL_AudioStream, it's not safe to dispose of the data until the stream has * completely consumed it. Often times it's difficult to know exactly when * this has happened. * * This callback fires once when the stream no longer needs the buffer, * allowing the app to easily free or reuse it. * * \param userdata an opaque pointer provided by the app for their personal * use. * \param buf the pointer provided to SDL_PutAudioStreamDataNoCopy(). * \param buflen the size of buffer, in bytes, provided to * SDL_PutAudioStreamDataNoCopy(). * * \threadsafety This callbacks may run from any thread, so if you need to * protect shared data, you should use SDL_LockAudioStream to * serialize access; this lock will be held before your callback * is called, so your callback does not need to manage the lock * explicitly. * * \since This datatype is available since SDL 3.4.0. * * \sa SDL_SetAudioStreamGetCallback * \sa SDL_SetAudioStreamPutCallback */ typedef void (SDLCALL *SDL_AudioStreamDataCompleteCallback)(void *userdata, const void *buf, int buflen); /** * Add external data to an audio stream without copying it. * * Unlike SDL_PutAudioStreamData(), this function does not make a copy of the * provided data, instead storing the provided pointer. This means that the * put operation does not need to allocate and copy the data, but the original * data must remain available until the stream is done with it, either by * being read from the stream in its entirety, or a call to * SDL_ClearAudioStream() or SDL_DestroyAudioStream(). * * The data must match the format/channels/samplerate specified in the latest * call to SDL_SetAudioStreamFormat, or the format specified when creating the * stream if it hasn't been changed. * * An optional callback may be provided, which is called when the stream no * longer needs the data. Once this callback fires, the stream will not access * the data again. This callback will fire for any reason the data is no * longer needed, including clearing or destroying the stream. * * Note that there is still an allocation to store tracking information, so * this function is more efficient for larger blocks of data. If you're * planning to put a few samples at a time, it will be more efficient to use * SDL_PutAudioStreamData(), which allocates and buffers in blocks. * * \param stream the stream the audio data is being added to. * \param buf a pointer to the audio data to add. * \param len the number of bytes to add to the stream. * \param callback the callback function to call when the data is no longer * needed by the stream. May be NULL. * \param userdata an opaque pointer provided to the callback for its own * personal use. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety It is safe to call this function from any thread, but if the * stream has a callback set, the caller might need to manage * extra locking. * * \since This function is available since SDL 3.4.0. * * \sa SDL_ClearAudioStream * \sa SDL_FlushAudioStream * \sa SDL_GetAudioStreamData * \sa SDL_GetAudioStreamQueued */ extern SDL_DECLSPEC bool SDLCALL SDL_PutAudioStreamDataNoCopy(SDL_AudioStream *stream, const void *buf, int len, SDL_AudioStreamDataCompleteCallback callback, void *userdata); /** * Add data to the stream with each channel in a separate array. * * This data must match the format/channels/samplerate specified in the latest * call to SDL_SetAudioStreamFormat, or the format specified when creating the * stream if it hasn't been changed. * * The data will be interleaved and queued. Note that SDL_AudioStream only * operates on interleaved data, so this is simply a convenience function for * easily queueing data from sources that provide separate arrays. There is no * equivalent function to retrieve planar data. * * The arrays in `channel_buffers` are ordered as they are to be interleaved; * the first array will be the first sample in the interleaved data. Any * individual array may be NULL; in this case, silence will be interleaved for * that channel. * * `num_channels` specifies how many arrays are in `channel_buffers`. This can * be used as a safety to prevent overflow, in case the stream format has * changed elsewhere. If more channels are specified than the current input * spec, they are ignored. If less channels are specified, the missing arrays * are treated as if they are NULL (silence is written to those channels). If * the count is -1, SDL will assume the array count matches the current input * spec. * * Note that `num_samples` is the number of _samples per array_. This can also * be thought of as the number of _sample frames_ to be queued. A value of 1 * with stereo arrays will queue two samples to the stream. This is different * than SDL_PutAudioStreamData, which wants the size of a single array in * bytes. * * \param stream the stream the audio data is being added to. * \param channel_buffers a pointer to an array of arrays, one array per * channel. * \param num_channels the number of arrays in `channel_buffers` or -1. * \param num_samples the number of _samples_ per array to write to the * stream. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety It is safe to call this function from any thread, but if the * stream has a callback set, the caller might need to manage * extra locking. * * \since This function is available since SDL 3.4.0. * * \sa SDL_ClearAudioStream * \sa SDL_FlushAudioStream * \sa SDL_GetAudioStreamData * \sa SDL_GetAudioStreamQueued */ extern SDL_DECLSPEC bool SDLCALL SDL_PutAudioStreamPlanarData(SDL_AudioStream *stream, const void * const *channel_buffers, int num_channels, int num_samples); /** * Get converted/resampled data from the stream. * * The input/output data format/channels/samplerate is specified when creating * the stream, and can be changed after creation by calling * SDL_SetAudioStreamFormat. * * Note that any conversion and resampling necessary is done during this call, * and SDL_PutAudioStreamData simply queues unconverted data for later. This * is different than SDL2, where that work was done while inputting new data * to the stream and requesting the output just copied the converted data. * * \param stream the stream the audio is being requested from. * \param buf a buffer to fill with audio data. * \param len the maximum number of bytes to fill. * \returns the number of bytes read from the stream or -1 on failure; call * SDL_GetError() for more information. * * \threadsafety It is safe to call this function from any thread, but if the * stream has a callback set, the caller might need to manage * extra locking. * * \since This function is available since SDL 3.2.0. * * \sa SDL_ClearAudioStream * \sa SDL_GetAudioStreamAvailable * \sa SDL_PutAudioStreamData */ extern SDL_DECLSPEC int SDLCALL SDL_GetAudioStreamData(SDL_AudioStream *stream, void *buf, int len); /** * Get the number of converted/resampled bytes available. * * The stream may be buffering data behind the scenes until it has enough to * resample correctly, so this number might be lower than what you expect, or * even be zero. Add more data or flush the stream if you need the data now. * * If the stream has so much data that it would overflow an int, the return * value is clamped to a maximum value, but no queued data is lost; if there * are gigabytes of data queued, the app might need to read some of it with * SDL_GetAudioStreamData before this function's return value is no longer * clamped. * * \param stream the audio stream to query. * \returns the number of converted/resampled bytes available or -1 on * failure; call SDL_GetError() for more information. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetAudioStreamData * \sa SDL_PutAudioStreamData */ extern SDL_DECLSPEC int SDLCALL SDL_GetAudioStreamAvailable(SDL_AudioStream *stream); /** * Get the number of bytes currently queued. * * This is the number of bytes put into a stream as input, not the number that * can be retrieved as output. Because of several details, it's not possible * to calculate one number directly from the other. If you need to know how * much usable data can be retrieved right now, you should use * SDL_GetAudioStreamAvailable() and not this function. * * Note that audio streams can change their input format at any time, even if * there is still data queued in a different format, so the returned byte * count will not necessarily match the number of _sample frames_ available. * Users of this API should be aware of format changes they make when feeding * a stream and plan accordingly. * * Queued data is not converted until it is consumed by * SDL_GetAudioStreamData, so this value should be representative of the exact * data that was put into the stream. * * If the stream has so much data that it would overflow an int, the return * value is clamped to a maximum value, but no queued data is lost; if there * are gigabytes of data queued, the app might need to read some of it with * SDL_GetAudioStreamData before this function's return value is no longer * clamped. * * \param stream the audio stream to query. * \returns the number of bytes queued or -1 on failure; call SDL_GetError() * for more information. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_PutAudioStreamData * \sa SDL_ClearAudioStream */ extern SDL_DECLSPEC int SDLCALL SDL_GetAudioStreamQueued(SDL_AudioStream *stream); /** * Tell the stream that you're done sending data, and anything being buffered * should be converted/resampled and made available immediately. * * It is legal to add more data to a stream after flushing, but there may be * audio gaps in the output. Generally this is intended to signal the end of * input, so the complete output becomes available. * * \param stream the audio stream to flush. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_PutAudioStreamData */ extern SDL_DECLSPEC bool SDLCALL SDL_FlushAudioStream(SDL_AudioStream *stream); /** * Clear any pending data in the stream. * * This drops any queued data, so there will be nothing to read from the * stream until more is added. * * \param stream the audio stream to clear. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetAudioStreamAvailable * \sa SDL_GetAudioStreamData * \sa SDL_GetAudioStreamQueued * \sa SDL_PutAudioStreamData */ extern SDL_DECLSPEC bool SDLCALL SDL_ClearAudioStream(SDL_AudioStream *stream); /** * Use this function to pause audio playback on the audio device associated * with an audio stream. * * This function pauses audio processing for a given device. Any bound audio * streams will not progress, and no audio will be generated. Pausing one * device does not prevent other unpaused devices from running. * * Pausing a device can be useful to halt all audio without unbinding all the * audio streams. This might be useful while a game is paused, or a level is * loading, etc. * * \param stream the audio stream associated with the audio device to pause. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_ResumeAudioStreamDevice */ extern SDL_DECLSPEC bool SDLCALL SDL_PauseAudioStreamDevice(SDL_AudioStream *stream); /** * Use this function to unpause audio playback on the audio device associated * with an audio stream. * * This function unpauses audio processing for a given device that has * previously been paused. Once unpaused, any bound audio streams will begin * to progress again, and audio can be generated. * * SDL_OpenAudioDeviceStream opens audio devices in a paused state, so this * function call is required for audio playback to begin on such devices. * * \param stream the audio stream associated with the audio device to resume. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_PauseAudioStreamDevice */ extern SDL_DECLSPEC bool SDLCALL SDL_ResumeAudioStreamDevice(SDL_AudioStream *stream); /** * Use this function to query if an audio device associated with a stream is * paused. * * Unlike in SDL2, audio devices start in an _unpaused_ state, since an app * has to bind a stream before any audio will flow. * * \param stream the audio stream associated with the audio device to query. * \returns true if device is valid and paused, false otherwise. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_PauseAudioStreamDevice * \sa SDL_ResumeAudioStreamDevice */ extern SDL_DECLSPEC bool SDLCALL SDL_AudioStreamDevicePaused(SDL_AudioStream *stream); /** * Lock an audio stream for serialized access. * * Each SDL_AudioStream has an internal mutex it uses to protect its data * structures from threading conflicts. This function allows an app to lock * that mutex, which could be useful if registering callbacks on this stream. * * One does not need to lock a stream to use in it most cases, as the stream * manages this lock internally. However, this lock is held during callbacks, * which may run from arbitrary threads at any time, so if an app needs to * protect shared data during those callbacks, locking the stream guarantees * that the callback is not running while the lock is held. * * As this is just a wrapper over SDL_LockMutex for an internal lock; it has * all the same attributes (recursive locks are allowed, etc). * * \param stream the audio stream to lock. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_UnlockAudioStream */ extern SDL_DECLSPEC bool SDLCALL SDL_LockAudioStream(SDL_AudioStream *stream); /** * Unlock an audio stream for serialized access. * * This unlocks an audio stream after a call to SDL_LockAudioStream. * * \param stream the audio stream to unlock. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety You should only call this from the same thread that * previously called SDL_LockAudioStream. * * \since This function is available since SDL 3.2.0. * * \sa SDL_LockAudioStream */ extern SDL_DECLSPEC bool SDLCALL SDL_UnlockAudioStream(SDL_AudioStream *stream); /** * A callback that fires when data passes through an SDL_AudioStream. * * Apps can (optionally) register a callback with an audio stream that is * called when data is added with SDL_PutAudioStreamData, or requested with * SDL_GetAudioStreamData. * * Two values are offered here: one is the amount of additional data needed to * satisfy the immediate request (which might be zero if the stream already * has enough data queued) and the other is the total amount being requested. * In a Get call triggering a Put callback, these values can be different. In * a Put call triggering a Get callback, these values are always the same. * * Byte counts might be slightly overestimated due to buffering or resampling, * and may change from call to call. * * This callback is not required to do anything. Generally this is useful for * adding/reading data on demand, and the app will often put/get data as * appropriate, but the system goes on with the data currently available to it * if this callback does nothing. * * \param stream the SDL audio stream associated with this callback. * \param additional_amount the amount of data, in bytes, that is needed right * now. * \param total_amount the total amount of data requested, in bytes, that is * requested or available. * \param userdata an opaque pointer provided by the app for their personal * use. * * \threadsafety This callbacks may run from any thread, so if you need to * protect shared data, you should use SDL_LockAudioStream to * serialize access; this lock will be held before your callback * is called, so your callback does not need to manage the lock * explicitly. * * \since This datatype is available since SDL 3.2.0. * * \sa SDL_SetAudioStreamGetCallback * \sa SDL_SetAudioStreamPutCallback */ typedef void (SDLCALL *SDL_AudioStreamCallback)(void *userdata, SDL_AudioStream *stream, int additional_amount, int total_amount); /** * Set a callback that runs when data is requested from an audio stream. * * This callback is called _before_ data is obtained from the stream, giving * the callback the chance to add more on-demand. * * The callback can (optionally) call SDL_PutAudioStreamData() to add more * audio to the stream during this call; if needed, the request that triggered * this callback will obtain the new data immediately. * * The callback's `additional_amount` argument is roughly how many bytes of * _unconverted_ data (in the stream's input format) is needed by the caller, * although this may overestimate a little for safety. This takes into account * how much is already in the stream and only asks for any extra necessary to * resolve the request, which means the callback may be asked for zero bytes, * and a different amount on each call. * * The callback is not required to supply exact amounts; it is allowed to * supply too much or too little or none at all. The caller will get what's * available, up to the amount they requested, regardless of this callback's * outcome. * * Clearing or flushing an audio stream does not call this callback. * * This function obtains the stream's lock, which means any existing callback * (get or put) in progress will finish running before setting the new * callback. * * Setting a NULL function turns off the callback. * * \param stream the audio stream to set the new callback on. * \param callback the new callback function to call when data is requested * from the stream. * \param userdata an opaque pointer provided to the callback for its own * personal use. * \returns true on success or false on failure; call SDL_GetError() for more * information. This only fails if `stream` is NULL. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_SetAudioStreamPutCallback */ extern SDL_DECLSPEC bool SDLCALL SDL_SetAudioStreamGetCallback(SDL_AudioStream *stream, SDL_AudioStreamCallback callback, void *userdata); /** * Set a callback that runs when data is added to an audio stream. * * This callback is called _after_ the data is added to the stream, giving the * callback the chance to obtain it immediately. * * The callback can (optionally) call SDL_GetAudioStreamData() to obtain audio * from the stream during this call. * * The callback's `additional_amount` argument is how many bytes of * _converted_ data (in the stream's output format) was provided by the * caller, although this may underestimate a little for safety. This value * might be less than what is currently available in the stream, if data was * already there, and might be less than the caller provided if the stream * needs to keep a buffer to aid in resampling. Which means the callback may * be provided with zero bytes, and a different amount on each call. * * The callback may call SDL_GetAudioStreamAvailable to see the total amount * currently available to read from the stream, instead of the total provided * by the current call. * * The callback is not required to obtain all data. It is allowed to read less * or none at all. Anything not read now simply remains in the stream for * later access. * * Clearing or flushing an audio stream does not call this callback. * * This function obtains the stream's lock, which means any existing callback * (get or put) in progress will finish running before setting the new * callback. * * Setting a NULL function turns off the callback. * * \param stream the audio stream to set the new callback on. * \param callback the new callback function to call when data is added to the * stream. * \param userdata an opaque pointer provided to the callback for its own * personal use. * \returns true on success or false on failure; call SDL_GetError() for more * information. This only fails if `stream` is NULL. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_SetAudioStreamGetCallback */ extern SDL_DECLSPEC bool SDLCALL SDL_SetAudioStreamPutCallback(SDL_AudioStream *stream, SDL_AudioStreamCallback callback, void *userdata); /** * Free an audio stream. * * This will release all allocated data, including any audio that is still * queued. You do not need to manually clear the stream first. * * If this stream was bound to an audio device, it is unbound during this * call. If this stream was created with SDL_OpenAudioDeviceStream, the audio * device that was opened alongside this stream's creation will be closed, * too. * * \param stream the audio stream to destroy. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_CreateAudioStream */ extern SDL_DECLSPEC void SDLCALL SDL_DestroyAudioStream(SDL_AudioStream *stream); /** * Convenience function for straightforward audio init for the common case. * * If all your app intends to do is provide a single source of PCM audio, this * function allows you to do all your audio setup in a single call. * * This is also intended to be a clean means to migrate apps from SDL2. * * This function will open an audio device, create a stream and bind it. * Unlike other methods of setup, the audio device will be closed when this * stream is destroyed, so the app can treat the returned SDL_AudioStream as * the only object needed to manage audio playback. * * Also unlike other functions, the audio device begins paused. This is to map * more closely to SDL2-style behavior, since there is no extra step here to * bind a stream to begin audio flowing. The audio device should be resumed * with SDL_ResumeAudioStreamDevice(). * * This function works with both playback and recording devices. * * The `spec` parameter represents the app's side of the audio stream. That * is, for recording audio, this will be the output format, and for playing * audio, this will be the input format. If spec is NULL, the system will * choose the format, and the app can use SDL_GetAudioStreamFormat() to obtain * this information later. * * If you don't care about opening a specific audio device, you can (and * probably _should_), use SDL_AUDIO_DEVICE_DEFAULT_PLAYBACK for playback and * SDL_AUDIO_DEVICE_DEFAULT_RECORDING for recording. * * One can optionally provide a callback function; if NULL, the app is * expected to queue audio data for playback (or unqueue audio data if * capturing). Otherwise, the callback will begin to fire once the device is * unpaused. * * Destroying the returned stream with SDL_DestroyAudioStream will also close * the audio device associated with this stream. * * \param devid an audio device to open, or SDL_AUDIO_DEVICE_DEFAULT_PLAYBACK * or SDL_AUDIO_DEVICE_DEFAULT_RECORDING. * \param spec the audio stream's data format. Can be NULL. * \param callback a callback where the app will provide new data for * playback, or receive new data for recording. Can be NULL, * in which case the app will need to call * SDL_PutAudioStreamData or SDL_GetAudioStreamData as * necessary. * \param userdata app-controlled pointer passed to callback. Can be NULL. * Ignored if callback is NULL. * \returns an audio stream on success, ready to use, or NULL on failure; call * SDL_GetError() for more information. When done with this stream, * call SDL_DestroyAudioStream to free resources and close the * device. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetAudioStreamDevice * \sa SDL_ResumeAudioStreamDevice */ extern SDL_DECLSPEC SDL_AudioStream * SDLCALL SDL_OpenAudioDeviceStream(SDL_AudioDeviceID devid, const SDL_AudioSpec *spec, SDL_AudioStreamCallback callback, void *userdata); /** * A callback that fires when data is about to be fed to an audio device. * * This is useful for accessing the final mix, perhaps for writing a * visualizer or applying a final effect to the audio data before playback. * * This callback should run as quickly as possible and not block for any * significant time, as this callback delays submission of data to the audio * device, which can cause audio playback problems. * * The postmix callback _must_ be able to handle any audio data format * specified in `spec`, which can change between callbacks if the audio device * changed. However, this only covers frequency and channel count; data is * always provided here in SDL_AUDIO_F32 format. * * The postmix callback runs _after_ logical device gain and audiostream gain * have been applied, which is to say you can make the output data louder at * this point than the gain settings would suggest. * * \param userdata a pointer provided by the app through * SDL_SetAudioPostmixCallback, for its own use. * \param spec the current format of audio that is to be submitted to the * audio device. * \param buffer the buffer of audio samples to be submitted. The callback can * inspect and/or modify this data. * \param buflen the size of `buffer` in bytes. * * \threadsafety This will run from a background thread owned by SDL. The * application is responsible for locking resources the callback * touches that need to be protected. * * \since This datatype is available since SDL 3.2.0. * * \sa SDL_SetAudioPostmixCallback */ typedef void (SDLCALL *SDL_AudioPostmixCallback)(void *userdata, const SDL_AudioSpec *spec, float *buffer, int buflen); /** * Set a callback that fires when data is about to be fed to an audio device. * * This is useful for accessing the final mix, perhaps for writing a * visualizer or applying a final effect to the audio data before playback. * * The buffer is the final mix of all bound audio streams on an opened device; * this callback will fire regularly for any device that is both opened and * unpaused. If there is no new data to mix, either because no streams are * bound to the device or all the streams are empty, this callback will still * fire with the entire buffer set to silence. * * This callback is allowed to make changes to the data; the contents of the * buffer after this call is what is ultimately passed along to the hardware. * * The callback is always provided the data in float format (values from -1.0f * to 1.0f), but the number of channels or sample rate may be different than * the format the app requested when opening the device; SDL might have had to * manage a conversion behind the scenes, or the playback might have jumped to * new physical hardware when a system default changed, etc. These details may * change between calls. Accordingly, the size of the buffer might change * between calls as well. * * This callback can run at any time, and from any thread; if you need to * serialize access to your app's data, you should provide and use a mutex or * other synchronization device. * * All of this to say: there are specific needs this callback can fulfill, but * it is not the simplest interface. Apps should generally provide audio in * their preferred format through an SDL_AudioStream and let SDL handle the * difference. * * This function is extremely time-sensitive; the callback should do the least * amount of work possible and return as quickly as it can. The longer the * callback runs, the higher the risk of audio dropouts or other problems. * * This function will block until the audio device is in between iterations, * so any existing callback that might be running will finish before this * function sets the new callback and returns. * * Setting a NULL callback function disables any previously-set callback. * * \param devid the ID of an opened audio device. * \param callback a callback function to be called. Can be NULL. * \param userdata app-controlled pointer passed to callback. Can be NULL. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC bool SDLCALL SDL_SetAudioPostmixCallback(SDL_AudioDeviceID devid, SDL_AudioPostmixCallback callback, void *userdata); /** * Load the audio data of a WAVE file into memory. * * Loading a WAVE file requires `src`, `spec`, `audio_buf` and `audio_len` to * be valid pointers. The entire data portion of the file is then loaded into * memory and decoded if necessary. * * Supported formats are RIFF WAVE files with the formats PCM (8, 16, 24, and * 32 bits), IEEE Float (32 bits), Microsoft ADPCM and IMA ADPCM (4 bits), and * A-law and mu-law (8 bits). Other formats are currently unsupported and * cause an error. * * If this function succeeds, the return value is zero and the pointer to the * audio data allocated by the function is written to `audio_buf` and its * length in bytes to `audio_len`. The SDL_AudioSpec members `freq`, * `channels`, and `format` are set to the values of the audio data in the * buffer. * * It's necessary to use SDL_free() to free the audio data returned in * `audio_buf` when it is no longer used. * * Because of the underspecification of the .WAV format, there are many * problematic files in the wild that cause issues with strict decoders. To * provide compatibility with these files, this decoder is lenient in regards * to the truncation of the file, the fact chunk, and the size of the RIFF * chunk. The hints `SDL_HINT_WAVE_RIFF_CHUNK_SIZE`, * `SDL_HINT_WAVE_TRUNCATION`, and `SDL_HINT_WAVE_FACT_CHUNK` can be used to * tune the behavior of the loading process. * * Any file that is invalid (due to truncation, corruption, or wrong values in * the headers), too big, or unsupported causes an error. Additionally, any * critical I/O error from the data source will terminate the loading process * with an error. The function returns NULL on error and in all cases (with * the exception of `src` being NULL), an appropriate error message will be * set. * * It is required that the data source supports seeking. * * Example: * * ```c * SDL_LoadWAV_IO(SDL_IOFromFile("sample.wav", "rb"), true, &spec, &buf, &len); * ``` * * Note that the SDL_LoadWAV function does this same thing for you, but in a * less messy way: * * ```c * SDL_LoadWAV("sample.wav", &spec, &buf, &len); * ``` * * \param src the data source for the WAVE data. * \param closeio if true, calls SDL_CloseIO() on `src` before returning, even * in the case of an error. * \param spec a pointer to an SDL_AudioSpec that will be set to the WAVE * data's format details on successful return. * \param audio_buf a pointer filled with the audio data, allocated by the * function. * \param audio_len a pointer filled with the length of the audio data buffer * in bytes. * \returns true on success. `audio_buf` will be filled with a pointer to an * allocated buffer containing the audio data, and `audio_len` is * filled with the length of that audio buffer in bytes. * * This function returns false if the .WAV file cannot be opened, * uses an unknown data format, or is corrupt; call SDL_GetError() * for more information. * * When the application is done with the data returned in * `audio_buf`, it should call SDL_free() to dispose of it. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_free * \sa SDL_LoadWAV */ extern SDL_DECLSPEC bool SDLCALL SDL_LoadWAV_IO(SDL_IOStream *src, bool closeio, SDL_AudioSpec *spec, Uint8 **audio_buf, Uint32 *audio_len); /** * Loads a WAV from a file path. * * This is a convenience function that is effectively the same as: * * ```c * SDL_LoadWAV_IO(SDL_IOFromFile(path, "rb"), true, spec, audio_buf, audio_len); * ``` * * \param path the file path of the WAV file to open. * \param spec a pointer to an SDL_AudioSpec that will be set to the WAVE * data's format details on successful return. * \param audio_buf a pointer filled with the audio data, allocated by the * function. * \param audio_len a pointer filled with the length of the audio data buffer * in bytes. * \returns true on success. `audio_buf` will be filled with a pointer to an * allocated buffer containing the audio data, and `audio_len` is * filled with the length of that audio buffer in bytes. * * This function returns false if the .WAV file cannot be opened, * uses an unknown data format, or is corrupt; call SDL_GetError() * for more information. * * When the application is done with the data returned in * `audio_buf`, it should call SDL_free() to dispose of it. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_free * \sa SDL_LoadWAV_IO */ extern SDL_DECLSPEC bool SDLCALL SDL_LoadWAV(const char *path, SDL_AudioSpec *spec, Uint8 **audio_buf, Uint32 *audio_len); /** * Mix audio data in a specified format. * * This takes an audio buffer `src` of `len` bytes of `format` data and mixes * it into `dst`, performing addition, volume adjustment, and overflow * clipping. The buffer pointed to by `dst` must also be `len` bytes of * `format` data. * * This is provided for convenience -- you can mix your own audio data. * * Do not use this function for mixing together more than two streams of * sample data. The output from repeated application of this function may be * distorted by clipping, because there is no accumulator with greater range * than the input (not to mention this being an inefficient way of doing it). * * It is a common misconception that this function is required to write audio * data to an output stream in an audio callback. While you can do that, * SDL_MixAudio() is really only needed when you're mixing a single audio * stream with a volume adjustment. * * \param dst the destination for the mixed audio. * \param src the source audio buffer to be mixed. * \param format the SDL_AudioFormat structure representing the desired audio * format. * \param len the length of the audio buffer in bytes. * \param volume ranges from 0.0 - 1.0, and should be set to 1.0 for full * audio volume. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC bool SDLCALL SDL_MixAudio(Uint8 *dst, const Uint8 *src, SDL_AudioFormat format, Uint32 len, float volume); /** * Convert some audio data of one format to another format. * * Please note that this function is for convenience, but should not be used * to resample audio in blocks, as it will introduce audio artifacts on the * boundaries. You should only use this function if you are converting audio * data in its entirety in one call. If you want to convert audio in smaller * chunks, use an SDL_AudioStream, which is designed for this situation. * * Internally, this function creates and destroys an SDL_AudioStream on each * use, so it's also less efficient than using one directly, if you need to * convert multiple times. * * \param src_spec the format details of the input audio. * \param src_data the audio data to be converted. * \param src_len the len of src_data. * \param dst_spec the format details of the output audio. * \param dst_data will be filled with a pointer to converted audio data, * which should be freed with SDL_free(). On error, it will be * NULL. * \param dst_len will be filled with the len of dst_data. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC bool SDLCALL SDL_ConvertAudioSamples(const SDL_AudioSpec *src_spec, const Uint8 *src_data, int src_len, const SDL_AudioSpec *dst_spec, Uint8 **dst_data, int *dst_len); /** * Get the human readable name of an audio format. * * \param format the audio format to query. * \returns the human readable name of the specified audio format or * "SDL_AUDIO_UNKNOWN" if the format isn't recognized. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC const char * SDLCALL SDL_GetAudioFormatName(SDL_AudioFormat format); /** * Get the appropriate memset value for silencing an audio format. * * The value returned by this function can be used as the second argument to * memset (or SDL_memset) to set an audio buffer in a specific format to * silence. * * \param format the audio data format to query. * \returns a byte value that can be passed to memset. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC int SDLCALL SDL_GetSilenceValueForFormat(SDL_AudioFormat format); /* Ends C function definitions when using C++ */ #ifdef __cplusplus } #endif #include #endif /* SDL_audio_h_ */ ================================================ FILE: deps/include/SDL3/SDL_begin_code.h ================================================ /* Simple DirectMedia Layer Copyright (C) 1997-2026 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ /* WIKI CATEGORY: BeginCode */ /** * # CategoryBeginCode * * `SDL_begin_code.h` sets things up for C dynamic library function * definitions, static inlined functions, and structures aligned at 4-byte * alignment. If you don't like ugly C preprocessor code, don't look at this * file. :) * * SDL's headers use this; applications generally should not include this * header directly. */ /* This shouldn't be nested -- included it around code only. */ #ifdef SDL_begin_code_h #error Nested inclusion of SDL_begin_code.h #endif #define SDL_begin_code_h #ifdef SDL_WIKI_DOCUMENTATION_SECTION /** * A macro to tag a symbol as deprecated. * * A function is marked deprecated by adding this macro to its declaration: * * ```c * extern SDL_DEPRECATED int ThisFunctionWasABadIdea(void); * ``` * * Compilers with deprecation support can give a warning when a deprecated * function is used. This symbol may be used in SDL's headers, but apps are * welcome to use it for their own interfaces as well. * * SDL, on occasion, might deprecate a function for various reasons. However, * SDL never removes symbols before major versions, so deprecated interfaces * in SDL3 will remain available until SDL4, where it would be expected an app * would have to take steps to migrate anyhow. * * On compilers without a deprecation mechanism, this is defined to nothing, * and using a deprecated function will not generate a warning. * * \since This macro is available since SDL 3.2.0. */ #define SDL_DEPRECATED __attribute__((deprecated)) /** * A macro to tag a symbol as a public API. * * SDL uses this macro for all its public functions. On some targets, it is * used to signal to the compiler that this function needs to be exported from * a shared library, but it might have other side effects. * * This symbol is used in SDL's headers, but apps and other libraries are * welcome to use it for their own interfaces as well. * * \since This macro is available since SDL 3.2.0. */ #define SDL_DECLSPEC __attribute__ ((visibility("default"))) /** * A macro to set a function's calling conventions. * * SDL uses this macro for all its public functions, and any callbacks it * defines. This macro guarantees that calling conventions match between SDL * and the app, even if the two were built with different compilers or * optimization settings. * * When writing a callback function, it is very important for it to be * correctly tagged with SDLCALL, as mismatched calling conventions can cause * strange behaviors and can be difficult to diagnose. Plus, on many * platforms, SDLCALL is defined to nothing, so compilers won't be able to * warn that the tag is missing. * * This symbol is used in SDL's headers, but apps and other libraries are * welcome to use it for their own interfaces as well. * * \since This macro is available since SDL 3.2.0. */ #define SDLCALL __cdecl /** * A macro to request a function be inlined. * * This is a hint to the compiler to inline a function. The compiler is free * to ignore this request. On compilers without inline support, this is * defined to nothing. * * \since This macro is available since SDL 3.2.0. */ #define SDL_INLINE __inline /** * A macro to demand a function be inlined. * * This is a command to the compiler to inline a function. SDL uses this macro * in its public headers for a handful of simple functions. On compilers * without forceinline support, this is defined to `static SDL_INLINE`, which * is often good enough. * * This symbol is used in SDL's headers, but apps and other libraries are * welcome to use it for their own interfaces as well. * * \since This macro is available since SDL 3.2.0. */ #define SDL_FORCE_INLINE __forceinline /** * A macro to tag a function as never-returning. * * This is a hint to the compiler that a function does not return. An example * of a function like this is the C runtime's exit() function. * * This hint can lead to code optimizations, and help analyzers understand * code flow better. On compilers without noreturn support, this is defined to * nothing. * * This symbol is used in SDL's headers, but apps and other libraries are * welcome to use it for their own interfaces as well. * * \since This macro is available since SDL 3.2.0. */ #define SDL_NORETURN __attribute__((noreturn)) /** * A macro to tag a function as never-returning (for analysis purposes). * * This is almost identical to SDL_NORETURN, except functions marked with this * _can_ actually return. The difference is that this isn't used for code * generation, but rather static analyzers use this information to assume * truths about program state and available code paths. Specifically, this tag * is useful for writing an assertion mechanism. Indeed, SDL_assert uses this * tag behind the scenes. Generally, apps that don't understand the specific * use-case for this tag should avoid using it directly. * * On compilers without analyzer_noreturn support, this is defined to nothing. * * This symbol is used in SDL's headers, but apps and other libraries are * welcome to use it for their own interfaces as well. * * \since This macro is available since SDL 3.2.0. */ #define SDL_ANALYZER_NORETURN __attribute__((analyzer_noreturn)) /** * A macro to signal that a case statement without a `break` is intentional. * * C compilers have gotten more aggressive about warning when a switch's * `case` block does not end with a `break` or other flow control statement, * flowing into the next case's code, as this is a common accident that leads * to strange bugs. But sometimes falling through to the next case is the * correct and desired behavior. This symbol lets an app communicate this * intention to the compiler, so it doesn't generate a warning. * * It is used like this: * * ```c * switch (x) { * case 1: * DoSomethingOnlyForOne(); * SDL_FALLTHROUGH; // tell the compiler this was intentional. * case 2: * DoSomethingForOneAndTwo(); * break; * } * ``` * * \since This macro is available since SDL 3.2.0. */ #define SDL_FALLTHROUGH [[fallthrough]] /** * A macro to tag a function's return value as critical. * * This is a hint to the compiler that a function's return value should not be * ignored. * * If an NODISCARD function's return value is thrown away (the function is * called as if it returns `void`), the compiler will issue a warning. * * While it's generally good practice to check return values for errors, often * times legitimate programs do not for good reasons. Be careful about what * functions are tagged as NODISCARD. It operates best when used on a function * that's failure is surprising and catastrophic; a good example would be a * program that checks the return values of all its file write function calls * but not the call to close the file, which it assumes incorrectly never * fails. * * Function callers that want to throw away a NODISCARD return value can call * the function with a `(void)` cast, which informs the compiler the act is * intentional. * * On compilers without nodiscard support, this is defined to nothing. * * \since This macro is available since SDL 3.2.0. */ #define SDL_NODISCARD [[nodiscard]] /** * A macro to tag a function as an allocator. * * This is a hint to the compiler that a function is an allocator, like * malloc(), with certain rules. A description of how GCC treats this hint is * here: * * https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-malloc-function-attribute * * On compilers without allocator tag support, this is defined to nothing. * * Most apps don't need to, and should not, use this directly. * * \since This macro is available since SDL 3.2.0. */ #define SDL_MALLOC __declspec(allocator) __desclspec(restrict) /** * A macro to tag a function as returning a certain allocation. * * This is a hint to the compiler that a function allocates and returns a * specific amount of memory based on one of its arguments. For example, the C * runtime's malloc() function could use this macro with an argument of 1 * (first argument to malloc is the size of the allocation). * * On compilers without alloc_size support, this is defined to nothing. * * Most apps don't need to, and should not, use this directly. * * \since This macro is available since SDL 3.2.0. */ #define SDL_ALLOC_SIZE(p) __attribute__((alloc_size(p))) /** * A macro to tag a pointer variable, to help with pointer aliasing. * * A good explanation of the restrict keyword is here: * * https://en.wikipedia.org/wiki/Restrict * * On compilers without restrict support, this is defined to nothing. * * \since This macro is available since SDL 3.4.0. */ #define SDL_RESTRICT __restrict /** * Check if the compiler supports a given builtin functionality. * * This allows preprocessor checks for things that otherwise might fail to * compile. * * Supported by virtually all clang versions and more-recent GCCs. Use this * instead of checking the clang version if possible. * * On compilers without has_builtin support, this is defined to 0 (always * false). * * \since This macro is available since SDL 3.2.0. */ #define SDL_HAS_BUILTIN(x) __has_builtin(x) /** * A macro to specify data alignment. * * This informs the compiler that a given datatype or variable must be aligned * to a specific byte count. * * For example: * * ```c * // make sure this is struct is aligned to 16 bytes for SIMD access. * typedef struct { * float x, y, z, w; * } SDL_ALIGNED(16) MySIMDAlignedData; * * // make sure this one field in a struct is aligned to 16 bytes for SIMD access. * typedef struct { * SomeStuff stuff; * float SDL_ALIGNED(16) position[4]; * SomeOtherStuff other_stuff; * } MyStruct; * * // make sure this variable is aligned to 32 bytes. * int SDL_ALIGNED(32) myval = 0; * ``` * * Alignment is only guaranteed for things the compiler places: local * variables on the stack and global/static variables. To dynamically allocate * something that respects this alignment, use SDL_aligned_alloc() or some * other mechanism. * * On compilers without alignment support, this macro is defined to an invalid * symbol, to make it clear that the current compiler is likely to generate * incorrect code when it sees this macro. * * \param x the byte count to align to, so the data's address will be a * multiple of this value. * * \since This macro is available since SDL 3.4.0. */ #define SDL_ALIGNED(x) __attribute__((aligned(x))) /* end of wiki documentation section. */ #endif /* `restrict` is from C99, but __restrict works with both Visual Studio and GCC. */ #ifndef SDL_RESTRICT # if defined(restrict) || ((defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L))) # define SDL_RESTRICT restrict # elif defined(_MSC_VER) || defined(__GNUC__) || defined(__clang__) # define SDL_RESTRICT __restrict # else # define SDL_RESTRICT # endif #endif #ifndef SDL_HAS_BUILTIN #ifdef __has_builtin #define SDL_HAS_BUILTIN(x) __has_builtin(x) #else #define SDL_HAS_BUILTIN(x) 0 #endif #endif #ifndef SDL_DEPRECATED # if defined(__GNUC__) && (__GNUC__ >= 4) /* technically, this arrived in gcc 3.1, but oh well. */ # define SDL_DEPRECATED __attribute__((deprecated)) # elif defined(_MSC_VER) # define SDL_DEPRECATED __declspec(deprecated) # else # define SDL_DEPRECATED # endif #endif #ifndef SDL_UNUSED # ifdef __GNUC__ # define SDL_UNUSED __attribute__((unused)) # else # define SDL_UNUSED # endif #endif /* Some compilers use a special export keyword */ #ifndef SDL_DECLSPEC # if defined(SDL_PLATFORM_WINDOWS) # ifdef DLL_EXPORT # define SDL_DECLSPEC __declspec(dllexport) # else # define SDL_DECLSPEC # endif # else # if defined(__GNUC__) && __GNUC__ >= 4 # define SDL_DECLSPEC __attribute__ ((visibility("default"))) # else # define SDL_DECLSPEC # endif # endif #endif /* By default SDL uses the C calling convention */ #ifndef SDLCALL #if defined(SDL_PLATFORM_WINDOWS) && !defined(__GNUC__) #define SDLCALL __cdecl #else #define SDLCALL #endif #endif /* SDLCALL */ /* Force structure packing at 4 byte alignment. This is necessary if the header is included in code which has structure packing set to an alternate value, say for loading structures from disk. The packing is reset to the previous value in SDL_close_code.h */ #if defined(_MSC_VER) || defined(__MWERKS__) || defined(__BORLANDC__) #ifdef _MSC_VER #pragma warning(disable: 4103) #endif #ifdef __clang__ #pragma clang diagnostic ignored "-Wpragma-pack" #endif #ifdef __BORLANDC__ #pragma nopackwarning #endif #ifdef _WIN64 /* Use 8-byte alignment on 64-bit architectures, so pointers are aligned */ #pragma pack(push,8) #else #pragma pack(push,4) #endif #endif /* Compiler needs structure packing set */ #ifndef SDL_INLINE #ifdef __GNUC__ #define SDL_INLINE __inline__ #elif defined(_MSC_VER) || defined(__BORLANDC__) || \ defined(__DMC__) || defined(__SC__) || \ defined(__WATCOMC__) || defined(__LCC__) || \ defined(__DECC) || defined(__CC_ARM) #define SDL_INLINE __inline #ifndef __inline__ #define __inline__ __inline #endif #else #define SDL_INLINE inline #ifndef __inline__ #define __inline__ inline #endif #endif #endif /* SDL_INLINE not defined */ #ifndef SDL_FORCE_INLINE #if defined(_MSC_VER) && (_MSC_VER >= 1200) #define SDL_FORCE_INLINE __forceinline #elif ( (defined(__GNUC__) && (__GNUC__ >= 4)) || defined(__clang__) ) #define SDL_FORCE_INLINE __attribute__((always_inline)) static __inline__ #else #define SDL_FORCE_INLINE static SDL_INLINE #endif #endif /* SDL_FORCE_INLINE not defined */ #ifndef SDL_NORETURN #if defined(__GNUC__) #define SDL_NORETURN __attribute__((noreturn)) #elif defined(_MSC_VER) #define SDL_NORETURN __declspec(noreturn) #else #define SDL_NORETURN #endif #endif /* SDL_NORETURN not defined */ #ifdef __clang__ #if __has_feature(attribute_analyzer_noreturn) #define SDL_ANALYZER_NORETURN __attribute__((analyzer_noreturn)) #endif #endif #ifndef SDL_ANALYZER_NORETURN #define SDL_ANALYZER_NORETURN #endif /* Apparently this is needed by several Windows compilers */ #ifndef __MACH__ #ifndef NULL #ifdef __cplusplus #define NULL 0 #else #define NULL ((void *)0) #endif #endif /* NULL */ #endif /* __MACH__ */ #ifndef SDL_FALLTHROUGH #if (defined(__cplusplus) && __cplusplus >= 201703L) || \ (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202000L) #define SDL_FALLTHROUGH [[fallthrough]] #else #if defined(__has_attribute) && !defined(__SUNPRO_C) && !defined(__SUNPRO_CC) #define SDL_HAS_FALLTHROUGH __has_attribute(__fallthrough__) #else #define SDL_HAS_FALLTHROUGH 0 #endif /* __has_attribute */ #if SDL_HAS_FALLTHROUGH && \ ((defined(__GNUC__) && __GNUC__ >= 7) || \ (defined(__clang_major__) && __clang_major__ >= 10)) #define SDL_FALLTHROUGH __attribute__((__fallthrough__)) #else #define SDL_FALLTHROUGH do {} while (0) /* fallthrough */ #endif /* SDL_HAS_FALLTHROUGH */ #undef SDL_HAS_FALLTHROUGH #endif /* C++17 or C2x */ #endif /* SDL_FALLTHROUGH not defined */ #ifndef SDL_NODISCARD #if (defined(__cplusplus) && __cplusplus >= 201703L) || \ (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L) #define SDL_NODISCARD [[nodiscard]] #elif ( (defined(__GNUC__) && (__GNUC__ >= 4)) || defined(__clang__) ) #define SDL_NODISCARD __attribute__((warn_unused_result)) #elif defined(_MSC_VER) && (_MSC_VER >= 1700) #define SDL_NODISCARD _Check_return_ #else #define SDL_NODISCARD #endif /* C++17 or C23 */ #endif /* SDL_NODISCARD not defined */ #ifndef SDL_MALLOC #if defined(__GNUC__) && (__GNUC__ >= 3) #define SDL_MALLOC __attribute__((malloc)) /** FIXME #elif defined(_MSC_VER) #define SDL_MALLOC __declspec(allocator) __desclspec(restrict) **/ #else #define SDL_MALLOC #endif #endif /* SDL_MALLOC not defined */ #ifndef SDL_ALLOC_SIZE #if (defined(__clang__) && __clang_major__ >= 4) || (defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))) #define SDL_ALLOC_SIZE(p) __attribute__((alloc_size(p))) #elif defined(_MSC_VER) #define SDL_ALLOC_SIZE(p) #else #define SDL_ALLOC_SIZE(p) #endif #endif /* SDL_ALLOC_SIZE not defined */ #ifndef SDL_ALLOC_SIZE2 #if (defined(__clang__) && __clang_major__ >= 4) || (defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))) #define SDL_ALLOC_SIZE2(p1, p2) __attribute__((alloc_size(p1, p2))) #elif defined(_MSC_VER) #define SDL_ALLOC_SIZE2(p1, p2) #else #define SDL_ALLOC_SIZE2(p1, p2) #endif #endif /* SDL_ALLOC_SIZE2 not defined */ #ifndef SDL_ALIGNED #if defined(__clang__) || defined(__GNUC__) #define SDL_ALIGNED(x) __attribute__((aligned(x))) #elif defined(_MSC_VER) #define SDL_ALIGNED(x) __declspec(align(x)) #elif defined(__cplusplus) && (__cplusplus >= 201103L) #define SDL_ALIGNED(x) alignas(x) #elif defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L) #define SDL_ALIGNED(x) _Alignas(x) #else #define SDL_ALIGNED(x) PLEASE_DEFINE_SDL_ALIGNED #endif #endif /* SDL_ALIGNED not defined */ ================================================ FILE: deps/include/SDL3/SDL_bits.h ================================================ /* Simple DirectMedia Layer Copyright (C) 1997-2026 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ /** * # CategoryBits * * Functions for fiddling with bits and bitmasks. */ #ifndef SDL_bits_h_ #define SDL_bits_h_ #include #include /* Set up for C function definitions, even when using C++ */ #ifdef __cplusplus extern "C" { #endif #if defined(__WATCOMC__) && defined(__386__) extern __inline int _SDL_bsr_watcom(Uint32); #pragma aux _SDL_bsr_watcom = \ "bsr eax, eax" \ parm [eax] nomemory \ value [eax] \ modify exact [eax] nomemory; #endif /** * Get the index of the most significant (set) bit in a 32-bit number. * * This operation can also be stated as "count leading zeroes" and "log base 2". * * Note that this is a forced-inline function in a header, and not a public * API function available in the SDL library (which is to say, the code is * embedded in the calling program and the linker and dynamic loader will not * be able to find this function inside SDL itself). * * \param x the 32-bit value to examine. * \returns the index of the most significant bit, or -1 if the value is 0. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. */ SDL_FORCE_INLINE int SDL_MostSignificantBitIndex32(Uint32 x) { #if defined(__GNUC__) && (__GNUC__ >= 4 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) /* Count Leading Zeroes builtin in GCC. * http://gcc.gnu.org/onlinedocs/gcc-4.3.4/gcc/Other-Builtins.html */ if (x == 0) { return -1; } return 31 - __builtin_clz(x); #elif defined(__WATCOMC__) && defined(__386__) if (x == 0) { return -1; } return _SDL_bsr_watcom(x); #elif defined(_MSC_VER) && _MSC_VER >= 1400 unsigned long index; if (_BitScanReverse(&index, x)) { return (int)index; } return -1; #else /* Based off of Bit Twiddling Hacks by Sean Eron Anderson * , released in the public domain. * http://graphics.stanford.edu/~seander/bithacks.html#IntegerLog */ const Uint32 b[] = {0x2, 0xC, 0xF0, 0xFF00, 0xFFFF0000}; const int S[] = {1, 2, 4, 8, 16}; int msbIndex = 0; int i; if (x == 0) { return -1; } for (i = 4; i >= 0; i--) { if (x & b[i]) { x >>= S[i]; msbIndex |= S[i]; } } return msbIndex; #endif } /** * Determine if a unsigned 32-bit value has exactly one bit set. * * If there are no bits set (`x` is zero), or more than one bit set, this * returns false. If any one bit is exclusively set, this returns true. * * Note that this is a forced-inline function in a header, and not a public * API function available in the SDL library (which is to say, the code is * embedded in the calling program and the linker and dynamic loader will not * be able to find this function inside SDL itself). * * \param x the 32-bit value to examine. * \returns true if exactly one bit is set in `x`, false otherwise. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. */ SDL_FORCE_INLINE bool SDL_HasExactlyOneBitSet32(Uint32 x) { if (x && !(x & (x - 1))) { return true; } return false; } /* Ends C function definitions when using C++ */ #ifdef __cplusplus } #endif #include #endif /* SDL_bits_h_ */ ================================================ FILE: deps/include/SDL3/SDL_blendmode.h ================================================ /* Simple DirectMedia Layer Copyright (C) 1997-2026 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ /** * # CategoryBlendmode * * Blend modes decide how two colors will mix together. There are both * standard modes for basic needs and a means to create custom modes, * dictating what sort of math to do on what color components. */ #ifndef SDL_blendmode_h_ #define SDL_blendmode_h_ #include #include /* Set up for C function definitions, even when using C++ */ #ifdef __cplusplus extern "C" { #endif /** * A set of blend modes used in drawing operations. * * These predefined blend modes are supported everywhere. * * Additional values may be obtained from SDL_ComposeCustomBlendMode. * * \since This datatype is available since SDL 3.2.0. * * \sa SDL_ComposeCustomBlendMode */ typedef Uint32 SDL_BlendMode; #define SDL_BLENDMODE_NONE 0x00000000u /**< no blending: dstRGBA = srcRGBA */ #define SDL_BLENDMODE_BLEND 0x00000001u /**< alpha blending: dstRGB = (srcRGB * srcA) + (dstRGB * (1-srcA)), dstA = srcA + (dstA * (1-srcA)) */ #define SDL_BLENDMODE_BLEND_PREMULTIPLIED 0x00000010u /**< pre-multiplied alpha blending: dstRGBA = srcRGBA + (dstRGBA * (1-srcA)) */ #define SDL_BLENDMODE_ADD 0x00000002u /**< additive blending: dstRGB = (srcRGB * srcA) + dstRGB, dstA = dstA */ #define SDL_BLENDMODE_ADD_PREMULTIPLIED 0x00000020u /**< pre-multiplied additive blending: dstRGB = srcRGB + dstRGB, dstA = dstA */ #define SDL_BLENDMODE_MOD 0x00000004u /**< color modulate: dstRGB = srcRGB * dstRGB, dstA = dstA */ #define SDL_BLENDMODE_MUL 0x00000008u /**< color multiply: dstRGB = (srcRGB * dstRGB) + (dstRGB * (1-srcA)), dstA = dstA */ #define SDL_BLENDMODE_INVALID 0x7FFFFFFFu /** * The blend operation used when combining source and destination pixel * components. * * \since This enum is available since SDL 3.2.0. */ typedef enum SDL_BlendOperation { SDL_BLENDOPERATION_ADD = 0x1, /**< dst + src: supported by all renderers */ SDL_BLENDOPERATION_SUBTRACT = 0x2, /**< src - dst : supported by D3D, OpenGL, OpenGLES, and Vulkan */ SDL_BLENDOPERATION_REV_SUBTRACT = 0x3, /**< dst - src : supported by D3D, OpenGL, OpenGLES, and Vulkan */ SDL_BLENDOPERATION_MINIMUM = 0x4, /**< min(dst, src) : supported by D3D, OpenGL, OpenGLES, and Vulkan */ SDL_BLENDOPERATION_MAXIMUM = 0x5 /**< max(dst, src) : supported by D3D, OpenGL, OpenGLES, and Vulkan */ } SDL_BlendOperation; /** * The normalized factor used to multiply pixel components. * * The blend factors are multiplied with the pixels from a drawing operation * (src) and the pixels from the render target (dst) before the blend * operation. The comma-separated factors listed above are always applied in * the component order red, green, blue, and alpha. * * \since This enum is available since SDL 3.2.0. */ typedef enum SDL_BlendFactor { SDL_BLENDFACTOR_ZERO = 0x1, /**< 0, 0, 0, 0 */ SDL_BLENDFACTOR_ONE = 0x2, /**< 1, 1, 1, 1 */ SDL_BLENDFACTOR_SRC_COLOR = 0x3, /**< srcR, srcG, srcB, srcA */ SDL_BLENDFACTOR_ONE_MINUS_SRC_COLOR = 0x4, /**< 1-srcR, 1-srcG, 1-srcB, 1-srcA */ SDL_BLENDFACTOR_SRC_ALPHA = 0x5, /**< srcA, srcA, srcA, srcA */ SDL_BLENDFACTOR_ONE_MINUS_SRC_ALPHA = 0x6, /**< 1-srcA, 1-srcA, 1-srcA, 1-srcA */ SDL_BLENDFACTOR_DST_COLOR = 0x7, /**< dstR, dstG, dstB, dstA */ SDL_BLENDFACTOR_ONE_MINUS_DST_COLOR = 0x8, /**< 1-dstR, 1-dstG, 1-dstB, 1-dstA */ SDL_BLENDFACTOR_DST_ALPHA = 0x9, /**< dstA, dstA, dstA, dstA */ SDL_BLENDFACTOR_ONE_MINUS_DST_ALPHA = 0xA /**< 1-dstA, 1-dstA, 1-dstA, 1-dstA */ } SDL_BlendFactor; /** * Compose a custom blend mode for renderers. * * The functions SDL_SetRenderDrawBlendMode and SDL_SetTextureBlendMode accept * the SDL_BlendMode returned by this function if the renderer supports it. * * A blend mode controls how the pixels from a drawing operation (source) get * combined with the pixels from the render target (destination). First, the * components of the source and destination pixels get multiplied with their * blend factors. Then, the blend operation takes the two products and * calculates the result that will get stored in the render target. * * Expressed in pseudocode, it would look like this: * * ```c * dstRGB = colorOperation(srcRGB * srcColorFactor, dstRGB * dstColorFactor); * dstA = alphaOperation(srcA * srcAlphaFactor, dstA * dstAlphaFactor); * ``` * * Where the functions `colorOperation(src, dst)` and `alphaOperation(src, * dst)` can return one of the following: * * - `src + dst` * - `src - dst` * - `dst - src` * - `min(src, dst)` * - `max(src, dst)` * * The red, green, and blue components are always multiplied with the first, * second, and third components of the SDL_BlendFactor, respectively. The * fourth component is not used. * * The alpha component is always multiplied with the fourth component of the * SDL_BlendFactor. The other components are not used in the alpha * calculation. * * Support for these blend modes varies for each renderer. To check if a * specific SDL_BlendMode is supported, create a renderer and pass it to * either SDL_SetRenderDrawBlendMode or SDL_SetTextureBlendMode. They will * return with an error if the blend mode is not supported. * * This list describes the support of custom blend modes for each renderer. * All renderers support the four blend modes listed in the SDL_BlendMode * enumeration. * * - **direct3d**: Supports all operations with all factors. However, some * factors produce unexpected results with `SDL_BLENDOPERATION_MINIMUM` and * `SDL_BLENDOPERATION_MAXIMUM`. * - **direct3d11**: Same as Direct3D 9. * - **opengl**: Supports the `SDL_BLENDOPERATION_ADD` operation with all * factors. OpenGL versions 1.1, 1.2, and 1.3 do not work correctly here. * - **opengles2**: Supports the `SDL_BLENDOPERATION_ADD`, * `SDL_BLENDOPERATION_SUBTRACT`, `SDL_BLENDOPERATION_REV_SUBTRACT` * operations with all factors. * - **psp**: No custom blend mode support. * - **software**: No custom blend mode support. * * Some renderers do not provide an alpha component for the default render * target. The `SDL_BLENDFACTOR_DST_ALPHA` and * `SDL_BLENDFACTOR_ONE_MINUS_DST_ALPHA` factors do not have an effect in this * case. * * \param srcColorFactor the SDL_BlendFactor applied to the red, green, and * blue components of the source pixels. * \param dstColorFactor the SDL_BlendFactor applied to the red, green, and * blue components of the destination pixels. * \param colorOperation the SDL_BlendOperation used to combine the red, * green, and blue components of the source and * destination pixels. * \param srcAlphaFactor the SDL_BlendFactor applied to the alpha component of * the source pixels. * \param dstAlphaFactor the SDL_BlendFactor applied to the alpha component of * the destination pixels. * \param alphaOperation the SDL_BlendOperation used to combine the alpha * component of the source and destination pixels. * \returns an SDL_BlendMode that represents the chosen factors and * operations. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_SetRenderDrawBlendMode * \sa SDL_GetRenderDrawBlendMode * \sa SDL_SetTextureBlendMode * \sa SDL_GetTextureBlendMode */ extern SDL_DECLSPEC SDL_BlendMode SDLCALL SDL_ComposeCustomBlendMode(SDL_BlendFactor srcColorFactor, SDL_BlendFactor dstColorFactor, SDL_BlendOperation colorOperation, SDL_BlendFactor srcAlphaFactor, SDL_BlendFactor dstAlphaFactor, SDL_BlendOperation alphaOperation); /* Ends C function definitions when using C++ */ #ifdef __cplusplus } #endif #include #endif /* SDL_blendmode_h_ */ ================================================ FILE: deps/include/SDL3/SDL_camera.h ================================================ /* Simple DirectMedia Layer Copyright (C) 1997-2026 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ /** * # CategoryCamera * * Video capture for the SDL library. * * This API lets apps read input from video sources, like webcams. Camera * devices can be enumerated, queried, and opened. Once opened, it will * provide SDL_Surface objects as new frames of video come in. These surfaces * can be uploaded to an SDL_Texture or processed as pixels in memory. * * Several platforms will alert the user if an app tries to access a camera, * and some will present a UI asking the user if your application should be * allowed to obtain images at all, which they can deny. A successfully opened * camera will not provide images until permission is granted. Applications, * after opening a camera device, can see if they were granted access by * either polling with the SDL_GetCameraPermissionState() function, or waiting * for an SDL_EVENT_CAMERA_DEVICE_APPROVED or SDL_EVENT_CAMERA_DEVICE_DENIED * event. Platforms that don't have any user approval process will report * approval immediately. * * Note that SDL cameras only provide video as individual frames; they will * not provide full-motion video encoded in a movie file format, although an * app is free to encode the acquired frames into any format it likes. It also * does not provide audio from the camera hardware through this API; not only * do many webcams not have microphones at all, many people--from streamers to * people on Zoom calls--will want to use a separate microphone regardless of * the camera. In any case, recorded audio will be available through SDL's * audio API no matter what hardware provides the microphone. * * ## Camera gotchas * * Consumer-level camera hardware tends to take a little while to warm up, * once the device has been opened. Generally most camera apps have some sort * of UI to take a picture (a button to snap a pic while a preview is showing, * some sort of multi-second countdown for the user to pose, like a photo * booth), which puts control in the users' hands, or they are intended to * stay on for long times (Pokemon Go, etc). * * It's not uncommon that a newly-opened camera will provide a couple of * completely black frames, maybe followed by some under-exposed images. If * taking a single frame automatically, or recording video from a camera's * input without the user initiating it from a preview, it could be wise to * drop the first several frames (if not the first several _seconds_ worth of * frames!) before using images from a camera. */ #ifndef SDL_camera_h_ #define SDL_camera_h_ #include #include #include #include #include #include /* Set up for C function definitions, even when using C++ */ #ifdef __cplusplus extern "C" { #endif /** * This is a unique ID for a camera device for the time it is connected to the * system, and is never reused for the lifetime of the application. * * If the device is disconnected and reconnected, it will get a new ID. * * The value 0 is an invalid ID. * * \since This datatype is available since SDL 3.2.0. * * \sa SDL_GetCameras */ typedef Uint32 SDL_CameraID; /** * The opaque structure used to identify an opened SDL camera. * * \since This struct is available since SDL 3.2.0. */ typedef struct SDL_Camera SDL_Camera; /** * The details of an output format for a camera device. * * Cameras often support multiple formats; each one will be encapsulated in * this struct. * * \since This struct is available since SDL 3.2.0. * * \sa SDL_GetCameraSupportedFormats * \sa SDL_GetCameraFormat */ typedef struct SDL_CameraSpec { SDL_PixelFormat format; /**< Frame format */ SDL_Colorspace colorspace; /**< Frame colorspace */ int width; /**< Frame width */ int height; /**< Frame height */ int framerate_numerator; /**< Frame rate numerator ((num / denom) == FPS, (denom / num) == duration in seconds) */ int framerate_denominator; /**< Frame rate denominator ((num / denom) == FPS, (denom / num) == duration in seconds) */ } SDL_CameraSpec; /** * The position of camera in relation to system device. * * \since This enum is available since SDL 3.2.0. * * \sa SDL_GetCameraPosition */ typedef enum SDL_CameraPosition { SDL_CAMERA_POSITION_UNKNOWN, SDL_CAMERA_POSITION_FRONT_FACING, SDL_CAMERA_POSITION_BACK_FACING } SDL_CameraPosition; /** * The current state of a request for camera access. * * \since This enum is available since SDL 3.4.0. * * \sa SDL_GetCameraPermissionState */ typedef enum SDL_CameraPermissionState { SDL_CAMERA_PERMISSION_STATE_DENIED = -1, SDL_CAMERA_PERMISSION_STATE_PENDING, SDL_CAMERA_PERMISSION_STATE_APPROVED, } SDL_CameraPermissionState; /** * Use this function to get the number of built-in camera drivers. * * This function returns a hardcoded number. This never returns a negative * value; if there are no drivers compiled into this build of SDL, this * function returns zero. The presence of a driver in this list does not mean * it will function, it just means SDL is capable of interacting with that * interface. For example, a build of SDL might have v4l2 support, but if * there's no kernel support available, SDL's v4l2 driver would fail if used. * * By default, SDL tries all drivers, in its preferred order, until one is * found to be usable. * * \returns the number of built-in camera drivers. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetCameraDriver */ extern SDL_DECLSPEC int SDLCALL SDL_GetNumCameraDrivers(void); /** * Use this function to get the name of a built in camera driver. * * The list of camera drivers is given in the order that they are normally * initialized by default; the drivers that seem more reasonable to choose * first (as far as the SDL developers believe) are earlier in the list. * * The names of drivers are all simple, low-ASCII identifiers, like "v4l2", * "coremedia" or "android". These never have Unicode characters, and are not * meant to be proper names. * * \param index the index of the camera driver; the value ranges from 0 to * SDL_GetNumCameraDrivers() - 1. * \returns the name of the camera driver at the requested index, or NULL if * an invalid index was specified. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetNumCameraDrivers */ extern SDL_DECLSPEC const char * SDLCALL SDL_GetCameraDriver(int index); /** * Get the name of the current camera driver. * * The names of drivers are all simple, low-ASCII identifiers, like "v4l2", * "coremedia" or "android". These never have Unicode characters, and are not * meant to be proper names. * * \returns the name of the current camera driver or NULL if no driver has * been initialized. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC const char * SDLCALL SDL_GetCurrentCameraDriver(void); /** * Get a list of currently connected camera devices. * * \param count a pointer filled in with the number of cameras returned, may * be NULL. * \returns a 0 terminated array of camera instance IDs or NULL on failure; * call SDL_GetError() for more information. This should be freed * with SDL_free() when it is no longer needed. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_OpenCamera */ extern SDL_DECLSPEC SDL_CameraID * SDLCALL SDL_GetCameras(int *count); /** * Get the list of native formats/sizes a camera supports. * * This returns a list of all formats and frame sizes that a specific camera * can offer. This is useful if your app can accept a variety of image formats * and sizes and so want to find the optimal spec that doesn't require * conversion. * * This function isn't strictly required; if you call SDL_OpenCamera with a * NULL spec, SDL will choose a native format for you, and if you instead * specify a desired format, it will transparently convert to the requested * format on your behalf. * * If `count` is not NULL, it will be filled with the number of elements in * the returned array. * * Note that it's legal for a camera to supply an empty list. This is what * will happen on Emscripten builds, since that platform won't tell _anything_ * about available cameras until you've opened one, and won't even tell if * there _is_ a camera until the user has given you permission to check * through a scary warning popup. * * \param instance_id the camera device instance ID. * \param count a pointer filled in with the number of elements in the list, * may be NULL. * \returns a NULL terminated array of pointers to SDL_CameraSpec or NULL on * failure; call SDL_GetError() for more information. This is a * single allocation that should be freed with SDL_free() when it is * no longer needed. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetCameras * \sa SDL_OpenCamera */ extern SDL_DECLSPEC SDL_CameraSpec ** SDLCALL SDL_GetCameraSupportedFormats(SDL_CameraID instance_id, int *count); /** * Get the human-readable device name for a camera. * * \param instance_id the camera device instance ID. * \returns a human-readable device name or NULL on failure; call * SDL_GetError() for more information. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetCameras */ extern SDL_DECLSPEC const char * SDLCALL SDL_GetCameraName(SDL_CameraID instance_id); /** * Get the position of the camera in relation to the system. * * Most platforms will report UNKNOWN, but mobile devices, like phones, can * often make a distinction between cameras on the front of the device (that * points towards the user, for taking "selfies") and cameras on the back (for * filming in the direction the user is facing). * * \param instance_id the camera device instance ID. * \returns the position of the camera on the system hardware. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetCameras */ extern SDL_DECLSPEC SDL_CameraPosition SDLCALL SDL_GetCameraPosition(SDL_CameraID instance_id); /** * Open a video recording device (a "camera"). * * You can open the device with any reasonable spec, and if the hardware can't * directly support it, it will convert data seamlessly to the requested * format. This might incur overhead, including scaling of image data. * * If you would rather accept whatever format the device offers, you can pass * a NULL spec here and it will choose one for you (and you can use * SDL_Surface's conversion/scaling functions directly if necessary). * * You can call SDL_GetCameraFormat() to get the actual data format if passing * a NULL spec here. You can see the exact specs a device can support without * conversion with SDL_GetCameraSupportedFormats(). * * SDL will not attempt to emulate framerate; it will try to set the hardware * to the rate closest to the requested speed, but it won't attempt to limit * or duplicate frames artificially; call SDL_GetCameraFormat() to see the * actual framerate of the opened the device, and check your timestamps if * this is crucial to your app! * * Note that the camera is not usable until the user approves its use! On some * platforms, the operating system will prompt the user to permit access to * the camera, and they can choose Yes or No at that point. Until they do, the * camera will not be usable. The app should either wait for an * SDL_EVENT_CAMERA_DEVICE_APPROVED (or SDL_EVENT_CAMERA_DEVICE_DENIED) event, * or poll SDL_GetCameraPermissionState() occasionally until it returns * non-zero. On platforms that don't require explicit user approval (and * perhaps in places where the user previously permitted access), the approval * event might come immediately, but it might come seconds, minutes, or hours * later! * * \param instance_id the camera device instance ID. * \param spec the desired format for data the device will provide. Can be * NULL. * \returns an SDL_Camera object or NULL on failure; call SDL_GetError() for * more information. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetCameras * \sa SDL_GetCameraFormat */ extern SDL_DECLSPEC SDL_Camera * SDLCALL SDL_OpenCamera(SDL_CameraID instance_id, const SDL_CameraSpec *spec); /** * Query if camera access has been approved by the user. * * Cameras will not function between when the device is opened by the app and * when the user permits access to the hardware. On some platforms, this * presents as a popup dialog where the user has to explicitly approve access; * on others the approval might be implicit and not alert the user at all. * * This function can be used to check the status of that approval. It will * return SDL_CAMERA_PERMISSION_STATE_PENDING if waiting for user response, * SDL_CAMERA_PERMISSION_STATE_APPROVED if the camera is approved for use, and * SDL_CAMERA_PERMISSION_STATE_DENIED if the user denied access. * * Instead of polling with this function, you can wait for a * SDL_EVENT_CAMERA_DEVICE_APPROVED (or SDL_EVENT_CAMERA_DEVICE_DENIED) event * in the standard SDL event loop, which is guaranteed to be sent once when * permission to use the camera is decided. * * If a camera is declined, there's nothing to be done but call * SDL_CloseCamera() to dispose of it. * * \param camera the opened camera device to query. * \returns an SDL_CameraPermissionState value indicating if access is * granted, or `SDL_CAMERA_PERMISSION_STATE_PENDING` if the decision * is still pending. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_OpenCamera * \sa SDL_CloseCamera */ extern SDL_DECLSPEC SDL_CameraPermissionState SDLCALL SDL_GetCameraPermissionState(SDL_Camera *camera); /** * Get the instance ID of an opened camera. * * \param camera an SDL_Camera to query. * \returns the instance ID of the specified camera on success or 0 on * failure; call SDL_GetError() for more information. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_OpenCamera */ extern SDL_DECLSPEC SDL_CameraID SDLCALL SDL_GetCameraID(SDL_Camera *camera); /** * Get the properties associated with an opened camera. * * \param camera the SDL_Camera obtained from SDL_OpenCamera(). * \returns a valid property ID on success or 0 on failure; call * SDL_GetError() for more information. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC SDL_PropertiesID SDLCALL SDL_GetCameraProperties(SDL_Camera *camera); /** * Get the spec that a camera is using when generating images. * * Note that this might not be the native format of the hardware, as SDL might * be converting to this format behind the scenes. * * If the system is waiting for the user to approve access to the camera, as * some platforms require, this will return false, but this isn't necessarily * a fatal error; you should either wait for an * SDL_EVENT_CAMERA_DEVICE_APPROVED (or SDL_EVENT_CAMERA_DEVICE_DENIED) event, * or poll SDL_GetCameraPermissionState() occasionally until it returns * non-zero. * * \param camera opened camera device. * \param spec the SDL_CameraSpec to be initialized by this function. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_OpenCamera */ extern SDL_DECLSPEC bool SDLCALL SDL_GetCameraFormat(SDL_Camera *camera, SDL_CameraSpec *spec); /** * Acquire a frame. * * The frame is a memory pointer to the image data, whose size and format are * given by the spec requested when opening the device. * * This is a non blocking API. If there is a frame available, a non-NULL * surface is returned, and timestampNS will be filled with a non-zero value. * * Note that an error case can also return NULL, but a NULL by itself is * normal and just signifies that a new frame is not yet available. Note that * even if a camera device fails outright (a USB camera is unplugged while in * use, etc), SDL will send an event separately to notify the app, but * continue to provide blank frames at ongoing intervals until * SDL_CloseCamera() is called, so real failure here is almost always an out * of memory condition. * * After use, the frame should be released with SDL_ReleaseCameraFrame(). If * you don't do this, the system may stop providing more video! * * Do not call SDL_DestroySurface() on the returned surface! It must be given * back to the camera subsystem with SDL_ReleaseCameraFrame! * * If the system is waiting for the user to approve access to the camera, as * some platforms require, this will return NULL (no frames available); you * should either wait for an SDL_EVENT_CAMERA_DEVICE_APPROVED (or * SDL_EVENT_CAMERA_DEVICE_DENIED) event, or poll * SDL_GetCameraPermissionState() occasionally until it returns non-zero. * * \param camera opened camera device. * \param timestampNS a pointer filled in with the frame's timestamp, or 0 on * error. Can be NULL. * \returns a new frame of video on success, NULL if none is currently * available. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_ReleaseCameraFrame */ extern SDL_DECLSPEC SDL_Surface * SDLCALL SDL_AcquireCameraFrame(SDL_Camera *camera, Uint64 *timestampNS); /** * Release a frame of video acquired from a camera. * * Let the back-end re-use the internal buffer for camera. * * This function _must_ be called only on surface objects returned by * SDL_AcquireCameraFrame(). This function should be called as quickly as * possible after acquisition, as SDL keeps a small FIFO queue of surfaces for * video frames; if surfaces aren't released in a timely manner, SDL may drop * upcoming video frames from the camera. * * If the app needs to keep the surface for a significant time, they should * make a copy of it and release the original. * * The app should not use the surface again after calling this function; * assume the surface is freed and the pointer is invalid. * * \param camera opened camera device. * \param frame the video frame surface to release. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_AcquireCameraFrame */ extern SDL_DECLSPEC void SDLCALL SDL_ReleaseCameraFrame(SDL_Camera *camera, SDL_Surface *frame); /** * Use this function to shut down camera processing and close the camera * device. * * \param camera opened camera device. * * \threadsafety It is safe to call this function from any thread, but no * thread may reference `device` once this function is called. * * \since This function is available since SDL 3.2.0. * * \sa SDL_OpenCamera */ extern SDL_DECLSPEC void SDLCALL SDL_CloseCamera(SDL_Camera *camera); /* Ends C function definitions when using C++ */ #ifdef __cplusplus } #endif #include #endif /* SDL_camera_h_ */ ================================================ FILE: deps/include/SDL3/SDL_clipboard.h ================================================ /* Simple DirectMedia Layer Copyright (C) 1997-2026 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ /** * # CategoryClipboard * * SDL provides access to the system clipboard, both for reading information * from other processes and publishing information of its own. * * This is not just text! SDL apps can access and publish data by mimetype. * * ## Basic use (text) * * Obtaining and publishing simple text to the system clipboard is as easy as * calling SDL_GetClipboardText() and SDL_SetClipboardText(), respectively. * These deal with C strings in UTF-8 encoding. Data transmission and encoding * conversion is completely managed by SDL. * * ## Clipboard callbacks (data other than text) * * Things get more complicated when the clipboard contains something other * than text. Not only can the system clipboard contain data of any type, in * some cases it can contain the same data in different formats! For example, * an image painting app might let the user copy a graphic to the clipboard, * and offers it in .BMP, .JPG, or .PNG format for other apps to consume. * * Obtaining clipboard data ("pasting") like this is a matter of calling * SDL_GetClipboardData() and telling it the mimetype of the data you want. * But how does one know if that format is available? SDL_HasClipboardData() * can report if a specific mimetype is offered, and * SDL_GetClipboardMimeTypes() can provide the entire list of mimetypes * available, so the app can decide what to do with the data and what formats * it can support. * * Setting the clipboard ("copying") to arbitrary data is done with * SDL_SetClipboardData. The app does not provide the data in this call, but * rather the mimetypes it is willing to provide and a callback function. * During the callback, the app will generate the data. This allows massive * data sets to be provided to the clipboard, without any data being copied * before it is explicitly requested. More specifically, it allows an app to * offer data in multiple formats without providing a copy of all of them * upfront. If the app has an image that it could provide in PNG or JPG * format, it doesn't have to encode it to either of those unless and until * something tries to paste it. * * ## Primary Selection * * The X11 and Wayland video targets have a concept of the "primary selection" * in addition to the usual clipboard. This is generally highlighted (but not * explicitly copied) text from various apps. SDL offers APIs for this through * SDL_GetPrimarySelectionText() and SDL_SetPrimarySelectionText(). SDL offers * these APIs on platforms without this concept, too, but only so far that it * will keep a copy of a string that the app sets for later retrieval; the * operating system will not ever attempt to change the string externally if * it doesn't support a primary selection. */ #ifndef SDL_clipboard_h_ #define SDL_clipboard_h_ #include #include #include /* Set up for C function definitions, even when using C++ */ #ifdef __cplusplus extern "C" { #endif /* Function prototypes */ /** * Put UTF-8 text into the clipboard. * * \param text the text to store in the clipboard. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetClipboardText * \sa SDL_HasClipboardText */ extern SDL_DECLSPEC bool SDLCALL SDL_SetClipboardText(const char *text); /** * Get UTF-8 text from the clipboard. * * This function returns an empty string if there is not enough memory left * for a copy of the clipboard's content. * * \returns the clipboard text on success or an empty string on failure; call * SDL_GetError() for more information. This should be freed with * SDL_free() when it is no longer needed. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_HasClipboardText * \sa SDL_SetClipboardText */ extern SDL_DECLSPEC char * SDLCALL SDL_GetClipboardText(void); /** * Query whether the clipboard exists and contains a non-empty text string. * * \returns true if the clipboard has text, or false if it does not. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetClipboardText * \sa SDL_SetClipboardText */ extern SDL_DECLSPEC bool SDLCALL SDL_HasClipboardText(void); /** * Put UTF-8 text into the primary selection. * * \param text the text to store in the primary selection. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetPrimarySelectionText * \sa SDL_HasPrimarySelectionText */ extern SDL_DECLSPEC bool SDLCALL SDL_SetPrimarySelectionText(const char *text); /** * Get UTF-8 text from the primary selection. * * This function returns an empty string if there is not enough memory left * for a copy of the primary selection's content. * * \returns the primary selection text on success or an empty string on * failure; call SDL_GetError() for more information. This should be * freed with SDL_free() when it is no longer needed. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_HasPrimarySelectionText * \sa SDL_SetPrimarySelectionText */ extern SDL_DECLSPEC char * SDLCALL SDL_GetPrimarySelectionText(void); /** * Query whether the primary selection exists and contains a non-empty text * string. * * \returns true if the primary selection has text, or false if it does not. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetPrimarySelectionText * \sa SDL_SetPrimarySelectionText */ extern SDL_DECLSPEC bool SDLCALL SDL_HasPrimarySelectionText(void); /** * Callback function that will be called when data for the specified mime-type * is requested by the OS. * * The callback function is called with NULL as the mime_type when the * clipboard is cleared or new data is set. The clipboard is automatically * cleared in SDL_Quit(). * * \param userdata a pointer to the provided user data. * \param mime_type the requested mime-type. * \param size a pointer filled in with the length of the returned data. * \returns a pointer to the data for the provided mime-type. Returning NULL * or setting the length to 0 will cause zero length data to be sent * to the "receiver", which should be able to handle this. The * returned data will not be freed, so it needs to be retained and * dealt with internally. * * \since This function is available since SDL 3.2.0. * * \sa SDL_SetClipboardData */ typedef const void *(SDLCALL *SDL_ClipboardDataCallback)(void *userdata, const char *mime_type, size_t *size); /** * Callback function that will be called when the clipboard is cleared, or * when new data is set. * * \param userdata a pointer to the provided user data. * * \since This function is available since SDL 3.2.0. * * \sa SDL_SetClipboardData */ typedef void (SDLCALL *SDL_ClipboardCleanupCallback)(void *userdata); /** * Offer clipboard data to the OS. * * Tell the operating system that the application is offering clipboard data * for each of the provided mime-types. Once another application requests the * data the callback function will be called, allowing it to generate and * respond with the data for the requested mime-type. * * The size of text data does not include any terminator, and the text does * not need to be null-terminated (e.g., you can directly copy a portion of a * document). * * \param callback a function pointer to the function that provides the * clipboard data. * \param cleanup a function pointer to the function that cleans up the * clipboard data. * \param userdata an opaque pointer that will be forwarded to the callbacks. * \param mime_types a list of mime-types that are being offered. SDL copies * the given list. * \param num_mime_types the number of mime-types in the mime_types list. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_ClearClipboardData * \sa SDL_GetClipboardData * \sa SDL_HasClipboardData */ extern SDL_DECLSPEC bool SDLCALL SDL_SetClipboardData(SDL_ClipboardDataCallback callback, SDL_ClipboardCleanupCallback cleanup, void *userdata, const char **mime_types, size_t num_mime_types); /** * Clear the clipboard data. * * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_SetClipboardData */ extern SDL_DECLSPEC bool SDLCALL SDL_ClearClipboardData(void); /** * Get the data from the clipboard for a given mime type. * * The size of text data does not include the terminator, but the text is * guaranteed to be null-terminated. * * \param mime_type the mime type to read from the clipboard. * \param size a pointer filled in with the length of the returned data. * \returns the retrieved data buffer or NULL on failure; call SDL_GetError() * for more information. This should be freed with SDL_free() when it * is no longer needed. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_HasClipboardData * \sa SDL_SetClipboardData */ extern SDL_DECLSPEC void * SDLCALL SDL_GetClipboardData(const char *mime_type, size_t *size); /** * Query whether there is data in the clipboard for the provided mime type. * * \param mime_type the mime type to check for data. * \returns true if data exists in the clipboard for the provided mime type, * false if it does not. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_SetClipboardData * \sa SDL_GetClipboardData */ extern SDL_DECLSPEC bool SDLCALL SDL_HasClipboardData(const char *mime_type); /** * Retrieve the list of mime types available in the clipboard. * * \param num_mime_types a pointer filled with the number of mime types, may * be NULL. * \returns a null-terminated array of strings with mime types, or NULL on * failure; call SDL_GetError() for more information. This should be * freed with SDL_free() when it is no longer needed. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_SetClipboardData */ extern SDL_DECLSPEC char ** SDLCALL SDL_GetClipboardMimeTypes(size_t *num_mime_types); /* Ends C function definitions when using C++ */ #ifdef __cplusplus } #endif #include #endif /* SDL_clipboard_h_ */ ================================================ FILE: deps/include/SDL3/SDL_close_code.h ================================================ /* Simple DirectMedia Layer Copyright (C) 1997-2026 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ /* * This file reverses the effects of SDL_begin_code.h and should be included * after you finish any function and structure declarations in your headers. * * SDL's headers use this; applications generally should not include this * header directly. */ #ifndef SDL_begin_code_h #error SDL_close_code.h included without matching SDL_begin_code.h #endif #undef SDL_begin_code_h /* Reset structure packing at previous byte alignment */ #if defined(_MSC_VER) || defined(__MWERKS__) || defined(__BORLANDC__) #ifdef __BORLANDC__ #pragma nopackwarning #endif #pragma pack(pop) #endif /* Compiler needs structure packing set */ ================================================ FILE: deps/include/SDL3/SDL_copying.h ================================================ /* Simple DirectMedia Layer Copyright (C) 1997-2026 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ /* Header file containing SDL's license. */ ================================================ FILE: deps/include/SDL3/SDL_cpuinfo.h ================================================ /* Simple DirectMedia Layer Copyright (C) 1997-2026 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ /* WIKI CATEGORY: CPUInfo */ /** * # CategoryCPUInfo * * CPU feature detection for SDL. * * These functions are largely concerned with reporting if the system has * access to various SIMD instruction sets, but also has other important info * to share, such as system RAM size and number of logical CPU cores. * * CPU instruction set checks, like SDL_HasSSE() and SDL_HasNEON(), are * available on all platforms, even if they don't make sense (an ARM processor * will never have SSE and an x86 processor will never have NEON, for example, * but these functions still exist and will simply return false in these * cases). */ #ifndef SDL_cpuinfo_h_ #define SDL_cpuinfo_h_ #include #include /* Set up for C function definitions, even when using C++ */ #ifdef __cplusplus extern "C" { #endif /** * A guess for the cacheline size used for padding. * * Most x86 processors have a 64 byte cache line. The 64-bit PowerPC * processors have a 128 byte cache line. We use the larger value to be * generally safe. * * \since This macro is available since SDL 3.2.0. */ #define SDL_CACHELINE_SIZE 128 /** * Get the number of logical CPU cores available. * * \returns the total number of logical CPU cores. On CPUs that include * technologies such as hyperthreading, the number of logical cores * may be more than the number of physical cores. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC int SDLCALL SDL_GetNumLogicalCPUCores(void); /** * Determine the L1 cache line size of the CPU. * * This is useful for determining multi-threaded structure padding or SIMD * prefetch sizes. * * \returns the L1 cache line size of the CPU, in bytes. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC int SDLCALL SDL_GetCPUCacheLineSize(void); /** * Determine whether the CPU has AltiVec features. * * This always returns false on CPUs that aren't using PowerPC instruction * sets. * * \returns true if the CPU has AltiVec features or false if not. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC bool SDLCALL SDL_HasAltiVec(void); /** * Determine whether the CPU has MMX features. * * This always returns false on CPUs that aren't using Intel instruction sets. * * \returns true if the CPU has MMX features or false if not. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC bool SDLCALL SDL_HasMMX(void); /** * Determine whether the CPU has SSE features. * * This always returns false on CPUs that aren't using Intel instruction sets. * * \returns true if the CPU has SSE features or false if not. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_HasSSE2 * \sa SDL_HasSSE3 * \sa SDL_HasSSE41 * \sa SDL_HasSSE42 */ extern SDL_DECLSPEC bool SDLCALL SDL_HasSSE(void); /** * Determine whether the CPU has SSE2 features. * * This always returns false on CPUs that aren't using Intel instruction sets. * * \returns true if the CPU has SSE2 features or false if not. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_HasSSE * \sa SDL_HasSSE3 * \sa SDL_HasSSE41 * \sa SDL_HasSSE42 */ extern SDL_DECLSPEC bool SDLCALL SDL_HasSSE2(void); /** * Determine whether the CPU has SSE3 features. * * This always returns false on CPUs that aren't using Intel instruction sets. * * \returns true if the CPU has SSE3 features or false if not. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_HasSSE * \sa SDL_HasSSE2 * \sa SDL_HasSSE41 * \sa SDL_HasSSE42 */ extern SDL_DECLSPEC bool SDLCALL SDL_HasSSE3(void); /** * Determine whether the CPU has SSE4.1 features. * * This always returns false on CPUs that aren't using Intel instruction sets. * * \returns true if the CPU has SSE4.1 features or false if not. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_HasSSE * \sa SDL_HasSSE2 * \sa SDL_HasSSE3 * \sa SDL_HasSSE42 */ extern SDL_DECLSPEC bool SDLCALL SDL_HasSSE41(void); /** * Determine whether the CPU has SSE4.2 features. * * This always returns false on CPUs that aren't using Intel instruction sets. * * \returns true if the CPU has SSE4.2 features or false if not. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_HasSSE * \sa SDL_HasSSE2 * \sa SDL_HasSSE3 * \sa SDL_HasSSE41 */ extern SDL_DECLSPEC bool SDLCALL SDL_HasSSE42(void); /** * Determine whether the CPU has AVX features. * * This always returns false on CPUs that aren't using Intel instruction sets. * * \returns true if the CPU has AVX features or false if not. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_HasAVX2 * \sa SDL_HasAVX512F */ extern SDL_DECLSPEC bool SDLCALL SDL_HasAVX(void); /** * Determine whether the CPU has AVX2 features. * * This always returns false on CPUs that aren't using Intel instruction sets. * * \returns true if the CPU has AVX2 features or false if not. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_HasAVX * \sa SDL_HasAVX512F */ extern SDL_DECLSPEC bool SDLCALL SDL_HasAVX2(void); /** * Determine whether the CPU has AVX-512F (foundation) features. * * This always returns false on CPUs that aren't using Intel instruction sets. * * \returns true if the CPU has AVX-512F features or false if not. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_HasAVX * \sa SDL_HasAVX2 */ extern SDL_DECLSPEC bool SDLCALL SDL_HasAVX512F(void); /** * Determine whether the CPU has ARM SIMD (ARMv6) features. * * This is different from ARM NEON, which is a different instruction set. * * This always returns false on CPUs that aren't using ARM instruction sets. * * \returns true if the CPU has ARM SIMD features or false if not. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_HasNEON */ extern SDL_DECLSPEC bool SDLCALL SDL_HasARMSIMD(void); /** * Determine whether the CPU has NEON (ARM SIMD) features. * * This always returns false on CPUs that aren't using ARM instruction sets. * * \returns true if the CPU has ARM NEON features or false if not. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC bool SDLCALL SDL_HasNEON(void); /** * Determine whether the CPU has LSX (LOONGARCH SIMD) features. * * This always returns false on CPUs that aren't using LOONGARCH instruction * sets. * * \returns true if the CPU has LOONGARCH LSX features or false if not. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC bool SDLCALL SDL_HasLSX(void); /** * Determine whether the CPU has LASX (LOONGARCH SIMD) features. * * This always returns false on CPUs that aren't using LOONGARCH instruction * sets. * * \returns true if the CPU has LOONGARCH LASX features or false if not. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC bool SDLCALL SDL_HasLASX(void); /** * Get the amount of RAM configured in the system. * * \returns the amount of RAM configured in the system in MiB. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC int SDLCALL SDL_GetSystemRAM(void); /** * Report the alignment this system needs for SIMD allocations. * * This will return the minimum number of bytes to which a pointer must be * aligned to be compatible with SIMD instructions on the current machine. For * example, if the machine supports SSE only, it will return 16, but if it * supports AVX-512F, it'll return 64 (etc). This only reports values for * instruction sets SDL knows about, so if your SDL build doesn't have * SDL_HasAVX512F(), then it might return 16 for the SSE support it sees and * not 64 for the AVX-512 instructions that exist but SDL doesn't know about. * Plan accordingly. * * \returns the alignment in bytes needed for available, known SIMD * instructions. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_aligned_alloc * \sa SDL_aligned_free */ extern SDL_DECLSPEC size_t SDLCALL SDL_GetSIMDAlignment(void); /** * Report the size of a page of memory. * * Different platforms might have different memory page sizes. In current * times, 4 kilobytes is not unusual, but newer systems are moving to larger * page sizes, and esoteric platforms might have any unexpected size. * * Note that this function can return 0, which means SDL can't determine the * page size on this platform. It will _not_ set an error string to be * retrieved with SDL_GetError() in this case! In this case, defaulting to * 4096 is often a reasonable option. * * \returns the size of a single page of memory, in bytes, or 0 if SDL can't * determine this information. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.4.0. */ extern SDL_DECLSPEC int SDLCALL SDL_GetSystemPageSize(void); /* Ends C function definitions when using C++ */ #ifdef __cplusplus } #endif #include #endif /* SDL_cpuinfo_h_ */ ================================================ FILE: deps/include/SDL3/SDL_dialog.h ================================================ /* Simple DirectMedia Layer Copyright (C) 1997-2026 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ /** * # CategoryDialog * * File dialog support. * * SDL offers file dialogs, to let users select files with native GUI * interfaces. There are "open" dialogs, "save" dialogs, and folder selection * dialogs. The app can control some details, such as filtering to specific * files, or whether multiple files can be selected by the user. * * Note that launching a file dialog is a non-blocking operation; control * returns to the app immediately, and a callback is called later (possibly in * another thread) when the user makes a choice. */ #ifndef SDL_dialog_h_ #define SDL_dialog_h_ #include #include #include #include #include /* Set up for C function definitions, even when using C++ */ #ifdef __cplusplus extern "C" { #endif /** * An entry for filters for file dialogs. * * `name` is a user-readable label for the filter (for example, "Office * document"). * * `pattern` is a semicolon-separated list of file extensions (for example, * "doc;docx"). File extensions may only contain alphanumeric characters, * hyphens, underscores and periods. Alternatively, the whole string can be a * single asterisk ("*"), which serves as an "All files" filter. * * \since This struct is available since SDL 3.2.0. * * \sa SDL_DialogFileCallback * \sa SDL_ShowOpenFileDialog * \sa SDL_ShowSaveFileDialog * \sa SDL_ShowOpenFolderDialog * \sa SDL_ShowFileDialogWithProperties */ typedef struct SDL_DialogFileFilter { const char *name; const char *pattern; } SDL_DialogFileFilter; /** * Callback used by file dialog functions. * * The specific usage is described in each function. * * If `filelist` is: * * - NULL, an error occurred. Details can be obtained with SDL_GetError(). * - A pointer to NULL, the user either didn't choose any file or canceled the * dialog. * - A pointer to non-`NULL`, the user chose one or more files. The argument * is a null-terminated array of pointers to UTF-8 encoded strings, each * containing a path. * * The filelist argument should not be freed; it will automatically be freed * when the callback returns. * * The filter argument is the index of the filter that was selected, or -1 if * no filter was selected or if the platform or method doesn't support * fetching the selected filter. * * In Android, the `filelist` are `content://` URIs. They should be opened * using SDL_IOFromFile() with appropriate modes. This applies both to open * and save file dialog. * * \param userdata an app-provided pointer, for the callback's use. * \param filelist the file(s) chosen by the user. * \param filter index of the selected filter. * * \since This datatype is available since SDL 3.2.0. * * \sa SDL_DialogFileFilter * \sa SDL_ShowOpenFileDialog * \sa SDL_ShowSaveFileDialog * \sa SDL_ShowOpenFolderDialog * \sa SDL_ShowFileDialogWithProperties */ typedef void (SDLCALL *SDL_DialogFileCallback)(void *userdata, const char * const *filelist, int filter); /** * Displays a dialog that lets the user select a file on their filesystem. * * This is an asynchronous function; it will return immediately, and the * result will be passed to the callback. * * The callback will be invoked with a null-terminated list of files the user * chose. The list will be empty if the user canceled the dialog, and it will * be NULL if an error occurred. * * Note that the callback may be called from a different thread than the one * the function was invoked on. * * Depending on the platform, the user may be allowed to input paths that * don't yet exist. * * On Linux, dialogs may require XDG Portals, which requires DBus, which * requires an event-handling loop. Apps that do not use SDL to handle events * should add a call to SDL_PumpEvents in their main loop. * * \param callback a function pointer to be invoked when the user selects a * file and accepts, or cancels the dialog, or an error * occurs. * \param userdata an optional pointer to pass extra data to the callback when * it will be invoked. * \param window the window that the dialog should be modal for, may be NULL. * Not all platforms support this option. * \param filters a list of filters, may be NULL. See the * [`SDL_DialogFileFilter`](SDL_DialogFileFilter#code-examples) * documentation for examples]. Not all platforms support this * option, and platforms that do support it may allow the user * to ignore the filters. If non-NULL, it must remain valid at * least until the callback is invoked. * \param nfilters the number of filters. Ignored if filters is NULL. * \param default_location the default folder or file to start the dialog at, * may be NULL. Not all platforms support this option. * \param allow_many if non-zero, the user will be allowed to select multiple * entries. Not all platforms support this option. * * \threadsafety This function should be called only from the main thread. The * callback may be invoked from the same thread or from a * different one, depending on the OS's constraints. * * \since This function is available since SDL 3.2.0. * * \sa SDL_DialogFileCallback * \sa SDL_DialogFileFilter * \sa SDL_ShowSaveFileDialog * \sa SDL_ShowOpenFolderDialog * \sa SDL_ShowFileDialogWithProperties */ extern SDL_DECLSPEC void SDLCALL SDL_ShowOpenFileDialog(SDL_DialogFileCallback callback, void *userdata, SDL_Window *window, const SDL_DialogFileFilter *filters, int nfilters, const char *default_location, bool allow_many); /** * Displays a dialog that lets the user choose a new or existing file on their * filesystem. * * This is an asynchronous function; it will return immediately, and the * result will be passed to the callback. * * The callback will be invoked with a null-terminated list of files the user * chose. The list will be empty if the user canceled the dialog, and it will * be NULL if an error occurred. * * Note that the callback may be called from a different thread than the one * the function was invoked on. * * The chosen file may or may not already exist. * * On Linux, dialogs may require XDG Portals, which requires DBus, which * requires an event-handling loop. Apps that do not use SDL to handle events * should add a call to SDL_PumpEvents in their main loop. * * \param callback a function pointer to be invoked when the user selects a * file and accepts, or cancels the dialog, or an error * occurs. * \param userdata an optional pointer to pass extra data to the callback when * it will be invoked. * \param window the window that the dialog should be modal for, may be NULL. * Not all platforms support this option. * \param filters a list of filters, may be NULL. Not all platforms support * this option, and platforms that do support it may allow the * user to ignore the filters. If non-NULL, it must remain * valid at least until the callback is invoked. * \param nfilters the number of filters. Ignored if filters is NULL. * \param default_location the default folder or file to start the dialog at, * may be NULL. Not all platforms support this option. * * \threadsafety This function should be called only from the main thread. The * callback may be invoked from the same thread or from a * different one, depending on the OS's constraints. * * \since This function is available since SDL 3.2.0. * * \sa SDL_DialogFileCallback * \sa SDL_DialogFileFilter * \sa SDL_ShowOpenFileDialog * \sa SDL_ShowOpenFolderDialog * \sa SDL_ShowFileDialogWithProperties */ extern SDL_DECLSPEC void SDLCALL SDL_ShowSaveFileDialog(SDL_DialogFileCallback callback, void *userdata, SDL_Window *window, const SDL_DialogFileFilter *filters, int nfilters, const char *default_location); /** * Displays a dialog that lets the user select a folder on their filesystem. * * This is an asynchronous function; it will return immediately, and the * result will be passed to the callback. * * The callback will be invoked with a null-terminated list of files the user * chose. The list will be empty if the user canceled the dialog, and it will * be NULL if an error occurred. * * Note that the callback may be called from a different thread than the one * the function was invoked on. * * Depending on the platform, the user may be allowed to input paths that * don't yet exist. * * On Linux, dialogs may require XDG Portals, which requires DBus, which * requires an event-handling loop. Apps that do not use SDL to handle events * should add a call to SDL_PumpEvents in their main loop. * * \param callback a function pointer to be invoked when the user selects a * file and accepts, or cancels the dialog, or an error * occurs. * \param userdata an optional pointer to pass extra data to the callback when * it will be invoked. * \param window the window that the dialog should be modal for, may be NULL. * Not all platforms support this option. * \param default_location the default folder or file to start the dialog at, * may be NULL. Not all platforms support this option. * \param allow_many if non-zero, the user will be allowed to select multiple * entries. Not all platforms support this option. * * \threadsafety This function should be called only from the main thread. The * callback may be invoked from the same thread or from a * different one, depending on the OS's constraints. * * \since This function is available since SDL 3.2.0. * * \sa SDL_DialogFileCallback * \sa SDL_ShowOpenFileDialog * \sa SDL_ShowSaveFileDialog * \sa SDL_ShowFileDialogWithProperties */ extern SDL_DECLSPEC void SDLCALL SDL_ShowOpenFolderDialog(SDL_DialogFileCallback callback, void *userdata, SDL_Window *window, const char *default_location, bool allow_many); /** * Various types of file dialogs. * * This is used by SDL_ShowFileDialogWithProperties() to decide what kind of * dialog to present to the user. * * \since This enum is available since SDL 3.2.0. * * \sa SDL_ShowFileDialogWithProperties */ typedef enum SDL_FileDialogType { SDL_FILEDIALOG_OPENFILE, SDL_FILEDIALOG_SAVEFILE, SDL_FILEDIALOG_OPENFOLDER } SDL_FileDialogType; /** * Create and launch a file dialog with the specified properties. * * These are the supported properties: * * - `SDL_PROP_FILE_DIALOG_FILTERS_POINTER`: a pointer to a list of * SDL_DialogFileFilter structs, which will be used as filters for * file-based selections. Ignored if the dialog is an "Open Folder" dialog. * If non-NULL, the array of filters must remain valid at least until the * callback is invoked. * - `SDL_PROP_FILE_DIALOG_NFILTERS_NUMBER`: the number of filters in the * array of filters, if it exists. * - `SDL_PROP_FILE_DIALOG_WINDOW_POINTER`: the window that the dialog should * be modal for. * - `SDL_PROP_FILE_DIALOG_LOCATION_STRING`: the default folder or file to * start the dialog at. * - `SDL_PROP_FILE_DIALOG_MANY_BOOLEAN`: true to allow the user to select * more than one entry. * - `SDL_PROP_FILE_DIALOG_TITLE_STRING`: the title for the dialog. * - `SDL_PROP_FILE_DIALOG_ACCEPT_STRING`: the label that the accept button * should have. * - `SDL_PROP_FILE_DIALOG_CANCEL_STRING`: the label that the cancel button * should have. * * Note that each platform may or may not support any of the properties. * * \param type the type of file dialog. * \param callback a function pointer to be invoked when the user selects a * file and accepts, or cancels the dialog, or an error * occurs. * \param userdata an optional pointer to pass extra data to the callback when * it will be invoked. * \param props the properties to use. * * \threadsafety This function should be called only from the main thread. The * callback may be invoked from the same thread or from a * different one, depending on the OS's constraints. * * \since This function is available since SDL 3.2.0. * * \sa SDL_FileDialogType * \sa SDL_DialogFileCallback * \sa SDL_DialogFileFilter * \sa SDL_ShowOpenFileDialog * \sa SDL_ShowSaveFileDialog * \sa SDL_ShowOpenFolderDialog */ extern SDL_DECLSPEC void SDLCALL SDL_ShowFileDialogWithProperties(SDL_FileDialogType type, SDL_DialogFileCallback callback, void *userdata, SDL_PropertiesID props); #define SDL_PROP_FILE_DIALOG_FILTERS_POINTER "SDL.filedialog.filters" #define SDL_PROP_FILE_DIALOG_NFILTERS_NUMBER "SDL.filedialog.nfilters" #define SDL_PROP_FILE_DIALOG_WINDOW_POINTER "SDL.filedialog.window" #define SDL_PROP_FILE_DIALOG_LOCATION_STRING "SDL.filedialog.location" #define SDL_PROP_FILE_DIALOG_MANY_BOOLEAN "SDL.filedialog.many" #define SDL_PROP_FILE_DIALOG_TITLE_STRING "SDL.filedialog.title" #define SDL_PROP_FILE_DIALOG_ACCEPT_STRING "SDL.filedialog.accept" #define SDL_PROP_FILE_DIALOG_CANCEL_STRING "SDL.filedialog.cancel" /* Ends C function definitions when using C++ */ #ifdef __cplusplus } #endif #include #endif /* SDL_dialog_h_ */ ================================================ FILE: deps/include/SDL3/SDL_dlopennote.h ================================================ /* Simple DirectMedia Layer Copyright (C) 1997-2026 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ /* WIKI CATEGORY: DlopenNotes */ /** * # CategoryDlopenNotes * * This header allows you to annotate your code so external tools know about * dynamic shared library dependencies. * * If you determine that your toolchain doesn't support dlopen notes, you can * disable this feature by defining `SDL_DISABLE_DLOPEN_NOTES`. You can use * this CMake snippet to check for support: * * ```cmake * include(CheckCSourceCompiles) * find_package(SDL3 REQUIRED CONFIG COMPONENTS Headers) * list(APPEND CMAKE_REQUIRED_LIBRARIES SDL3::Headers) * check_c_source_compiles([==[ * #include * SDL_ELF_NOTE_DLOPEN("sdl-video", * "Support for video through SDL", * SDL_ELF_NOTE_DLOPEN_PRIORITY_SUGGESTED, * "libSDL-1.2.so.0", "libSDL-2.0.so.0", "libSDL3.so.0" * ) * int main(int argc, char *argv[]) { * return argc + argv[0][1]; * } * ]==] COMPILER_SUPPORTS_SDL_ELF_NOTE_DLOPEN) * if(NOT COMPILER_SUPPORTS_SDL_ELF_NOTE_DLOPEN) * add_compile_definitions(-DSDL_DISABLE_DLOPEN_NOTE) * endif() * ``` */ #ifndef SDL_dlopennote_h #define SDL_dlopennote_h /** * Use this macro with SDL_ELF_NOTE_DLOPEN() to note that a dynamic shared * library dependency is optional. * * Optional functionality uses the dependency, the binary will work and the * dependency is only needed for full-featured installations. * * \since This macro is available since SDL 3.4.0. * * \sa SDL_ELF_NOTE_DLOPEN * \sa SDL_ELF_NOTE_DLOPEN_PRIORITY_RECOMMENDED * \sa SDL_ELF_NOTE_DLOPEN_PRIORITY_REQUIRED */ #define SDL_ELF_NOTE_DLOPEN_PRIORITY_SUGGESTED "suggested" /** * Use this macro with SDL_ELF_NOTE_DLOPEN() to note that a dynamic shared * library dependency is recommended. * * Important functionality needs the dependency, the binary will work but in * most cases the dependency should be provided. * * \since This macro is available since SDL 3.4.0. * * \sa SDL_ELF_NOTE_DLOPEN * \sa SDL_ELF_NOTE_DLOPEN_PRIORITY_SUGGESTED * \sa SDL_ELF_NOTE_DLOPEN_PRIORITY_REQUIRED */ #define SDL_ELF_NOTE_DLOPEN_PRIORITY_RECOMMENDED "recommended" /** * Use this macro with SDL_ELF_NOTE_DLOPEN() to note that a dynamic shared * library dependency is required. * * Core functionality needs the dependency, the binary will not work if it * cannot be found. * * \since This macro is available since SDL 3.4.0. * * \sa SDL_ELF_NOTE_DLOPEN * \sa SDL_ELF_NOTE_DLOPEN_PRIORITY_SUGGESTED * \sa SDL_ELF_NOTE_DLOPEN_PRIORITY_RECOMMENDED */ #define SDL_ELF_NOTE_DLOPEN_PRIORITY_REQUIRED "required" #if !defined(SDL_PLATFORM_UNIX) || defined(SDL_PLATFORM_ANDROID) /* The dlopen note functionality isn't used on this platform */ #ifndef SDL_DISABLE_DLOPEN_NOTES #define SDL_DISABLE_DLOPEN_NOTES #endif #elif defined(__GNUC__) && (__GNUC__ < 3 || (__GNUC__ == 3 && __GNUC_MINOR__ < 1)) /* gcc < 3.1 too old */ #ifndef SDL_DISABLE_DLOPEN_NOTES #define SDL_DISABLE_DLOPEN_NOTES #endif #endif /* SDL_PLATFORM_UNIX || SDL_PLATFORM_ANDROID */ #if defined(__ELF__) && !defined(SDL_DISABLE_DLOPEN_NOTES) #include #define SDL_ELF_NOTE_DLOPEN_VENDOR "FDO" #define SDL_ELF_NOTE_DLOPEN_TYPE 0x407c0c0aU #define SDL_ELF_NOTE_INTERNAL2(json, variable_name) \ __attribute__((aligned(4), used, section(".note.dlopen"))) \ static const struct { \ struct { \ Uint32 n_namesz; \ Uint32 n_descsz; \ Uint32 n_type; \ } nhdr; \ char name[4]; \ __attribute__((aligned(4))) char dlopen_json[sizeof(json)]; \ } variable_name = { \ { \ sizeof(SDL_ELF_NOTE_DLOPEN_VENDOR), \ sizeof(json), \ SDL_ELF_NOTE_DLOPEN_TYPE \ }, \ SDL_ELF_NOTE_DLOPEN_VENDOR, \ json \ } #define SDL_ELF_NOTE_INTERNAL(json, variable_name) \ SDL_ELF_NOTE_INTERNAL2(json, variable_name) #define SDL_DLNOTE_JSON_ARRAY1(N1) "[\"" N1 "\"]" #define SDL_DLNOTE_JSON_ARRAY2(N1,N2) "[\"" N1 "\",\"" N2 "\"]" #define SDL_DLNOTE_JSON_ARRAY3(N1,N2,N3) "[\"" N1 "\",\"" N2 "\",\"" N3 "\"]" #define SDL_DLNOTE_JSON_ARRAY4(N1,N2,N3,N4) "[\"" N1 "\",\"" N2 "\",\"" N3 "\",\"" N4 "\"]" #define SDL_DLNOTE_JSON_ARRAY5(N1,N2,N3,N4,N5) "[\"" N1 "\",\"" N2 "\",\"" N3 "\",\"" N4 "\",\"" N5 "\"]" #define SDL_DLNOTE_JSON_ARRAY6(N1,N2,N3,N4,N5,N6) "[\"" N1 "\",\"" N2 "\",\"" N3 "\",\"" N4 "\",\"" N5 "\",\"" N6 "\"]" #define SDL_DLNOTE_JSON_ARRAY7(N1,N2,N3,N4,N5,N6,N7) "[\"" N1 "\",\"" N2 "\",\"" N3 "\",\"" N4 "\",\"" N5 "\",\"" N6 "\",\"" N7 "\"]" #define SDL_DLNOTE_JSON_ARRAY8(N1,N2,N3,N4,N5,N6,N7,N8) "[\"" N1 "\",\"" N2 "\",\"" N3 "\",\"" N4 "\",\"" N5 "\",\"" N6 "\",\"" N7 "\",\"" N8 "\"]" #define SDL_DLNOTE_JSON_ARRAY_GET(N1,N2,N3,N4,N5,N6,N7,N8,NAME,...) NAME #define SDL_DLNOTE_JSON_ARRAY(...) \ SDL_DLNOTE_JSON_ARRAY_GET( \ __VA_ARGS__, \ SDL_DLNOTE_JSON_ARRAY8, \ SDL_DLNOTE_JSON_ARRAY7, \ SDL_DLNOTE_JSON_ARRAY6, \ SDL_DLNOTE_JSON_ARRAY5, \ SDL_DLNOTE_JSON_ARRAY4, \ SDL_DLNOTE_JSON_ARRAY3, \ SDL_DLNOTE_JSON_ARRAY2, \ SDL_DLNOTE_JSON_ARRAY1 \ )(__VA_ARGS__) /* Create "unique" variable name using __LINE__, * so creating multiple elf notes on the same line is not supported */ #define SDL_DLNOTE_JOIN2(A,B) A##B #define SDL_DLNOTE_JOIN(A,B) SDL_DLNOTE_JOIN2(A,B) #define SDL_DLNOTE_UNIQUE_NAME SDL_DLNOTE_JOIN(s_SDL_dlopen_note_, __LINE__) /** * Add a note that your application has dynamic shared library dependencies. * * You can do this by adding the following to the global scope: * * ```c * SDL_ELF_NOTE_DLOPEN( * "png", * "Support for loading PNG images using libpng (required for APNG)", * SDL_ELF_NOTE_DLOPEN_PRIORITY_RECOMMENDED, * "libpng12.so.0" * ) * ``` * * A trailing semicolon is not needed. * * Or if you support multiple versions of a library, you can list them: * * ```c * // Our app supports SDL1, SDL2, and SDL3 by dynamically loading them * SDL_ELF_NOTE_DLOPEN( * "SDL", * "Create windows through SDL video backend", * SDL_ELF_NOTE_DLOPEN_PRIORITY_REQUIRED * "libSDL-1.2.so.0", "libSDL2-2.0.so.0", "libSDL3.so.0" * ) * ``` * * This macro is not available for compilers that do not support variadic * macro's. * * \since This macro is available since SDL 3.4.0. * * \sa SDL_ELF_NOTE_DLOPEN_PRIORITY_SUGGESTED * \sa SDL_ELF_NOTE_DLOPEN_PRIORITY_RECOMMENDED * \sa SDL_ELF_NOTE_DLOPEN_PRIORITY_REQUIRED */ #define SDL_ELF_NOTE_DLOPEN(feature, description, priority, ...) \ SDL_ELF_NOTE_INTERNAL( \ "[{\"feature\":\"" feature \ "\",\"description\":\"" description \ "\",\"priority\":\"" priority \ "\",\"soname\":" SDL_DLNOTE_JSON_ARRAY(__VA_ARGS__) "}]", \ SDL_DLNOTE_UNIQUE_NAME); #elif defined(__GNUC__) && __GNUC__ < 3 #define SDL_ELF_NOTE_DLOPEN(args...) #elif defined(_MSC_VER) && _MSC_VER < 1400 /* Variadic macros are not supported */ #else #define SDL_ELF_NOTE_DLOPEN(...) #endif #endif /* SDL_dlopennote_h */ ================================================ FILE: deps/include/SDL3/SDL_egl.h ================================================ /* Simple DirectMedia Layer Copyright (C) 1997-2026 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ /* * This is a simple file to encapsulate the EGL API headers. */ #include #if !defined(_MSC_VER) && !defined(SDL_PLATFORM_ANDROID) && !defined(SDL_USE_BUILTIN_OPENGL_DEFINITIONS) #if defined(SDL_PLATFORM_VITA) #include #include #include #endif #include #include #else /* _MSC_VER */ /* EGL headers for Visual Studio */ #ifndef __khrplatform_h_ #define __khrplatform_h_ /* ** Copyright (c) 2008-2018 The Khronos Group Inc. ** ** Permission is hereby granted, free of charge, to any person obtaining a ** copy of this software and/or associated documentation files (the ** "Materials"), to deal in the Materials without restriction, including ** without limitation the rights to use, copy, modify, merge, publish, ** distribute, sublicense, and/or sell copies of the Materials, and to ** permit persons to whom the Materials are 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 Materials. ** ** THE MATERIALS ARE 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 ** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. */ /* Khronos platform-specific types and definitions. * * The master copy of khrplatform.h is maintained in the Khronos EGL * Registry repository at https://github.com/KhronosGroup/EGL-Registry * The last semantic modification to khrplatform.h was at commit ID: * 67a3e0864c2d75ea5287b9f3d2eb74a745936692 * * Adopters may modify this file to suit their platform. Adopters are * encouraged to submit platform specific modifications to the Khronos * group so that they can be included in future versions of this file. * Please submit changes by filing pull requests or issues on * the EGL Registry repository linked above. * * * See the Implementer's Guidelines for information about where this file * should be located on your system and for more details of its use: * http://www.khronos.org/registry/implementers_guide.pdf * * This file should be included as * #include * by Khronos client API header files that use its types and defines. * * The types in khrplatform.h should only be used to define API-specific types. * * Types defined in khrplatform.h: * khronos_int8_t signed 8 bit * khronos_uint8_t unsigned 8 bit * khronos_int16_t signed 16 bit * khronos_uint16_t unsigned 16 bit * khronos_int32_t signed 32 bit * khronos_uint32_t unsigned 32 bit * khronos_int64_t signed 64 bit * khronos_uint64_t unsigned 64 bit * khronos_intptr_t signed same number of bits as a pointer * khronos_uintptr_t unsigned same number of bits as a pointer * khronos_ssize_t signed size * khronos_usize_t unsigned size * khronos_float_t signed 32 bit floating point * khronos_time_ns_t unsigned 64 bit time in nanoseconds * khronos_utime_nanoseconds_t unsigned time interval or absolute time in * nanoseconds * khronos_stime_nanoseconds_t signed time interval in nanoseconds * khronos_boolean_enum_t enumerated boolean type. This should * only be used as a base type when a client API's boolean type is * an enum. Client APIs which use an integer or other type for * booleans cannot use this as the base type for their boolean. * * Tokens defined in khrplatform.h: * * KHRONOS_FALSE, KHRONOS_TRUE Enumerated boolean false/true values. * * KHRONOS_SUPPORT_INT64 is 1 if 64 bit integers are supported; otherwise 0. * KHRONOS_SUPPORT_FLOAT is 1 if floats are supported; otherwise 0. * * Calling convention macros defined in this file: * KHRONOS_APICALL * KHRONOS_APIENTRY * KHRONOS_APIATTRIBUTES * * These may be used in function prototypes as: * * KHRONOS_APICALL void KHRONOS_APIENTRY funcname( * int arg1, * int arg2) KHRONOS_APIATTRIBUTES; */ #if defined(__SCITECH_SNAP__) && !defined(KHRONOS_STATIC) # define KHRONOS_STATIC 1 #endif /*------------------------------------------------------------------------- * Definition of KHRONOS_APICALL *------------------------------------------------------------------------- * This precedes the return type of the function in the function prototype. */ #if defined(KHRONOS_STATIC) /* If the preprocessor constant KHRONOS_STATIC is defined, make the * header compatible with static linking. */ # define KHRONOS_APICALL #elif defined(_WIN32) # define KHRONOS_APICALL __declspec(dllimport) #elif defined (__SYMBIAN32__) # define KHRONOS_APICALL IMPORT_C #elif defined(__ANDROID__) # define KHRONOS_APICALL __attribute__((visibility("default"))) #else # define KHRONOS_APICALL #endif /*------------------------------------------------------------------------- * Definition of KHRONOS_APIENTRY *------------------------------------------------------------------------- * This follows the return type of the function and precedes the function * name in the function prototype. */ #if defined(_WIN32) && !defined(_WIN32_WCE) && !defined(__SCITECH_SNAP__) /* Win32 but not WinCE */ # define KHRONOS_APIENTRY __stdcall #else # define KHRONOS_APIENTRY #endif /*------------------------------------------------------------------------- * Definition of KHRONOS_APIATTRIBUTES *------------------------------------------------------------------------- * This follows the closing parenthesis of the function prototype arguments. */ #if defined (__ARMCC_2__) #define KHRONOS_APIATTRIBUTES __softfp #else #define KHRONOS_APIATTRIBUTES #endif /*------------------------------------------------------------------------- * basic type definitions *-----------------------------------------------------------------------*/ #if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || defined(__GNUC__) || defined(__SCO__) || defined(__USLC__) /* * Using */ #include typedef int32_t khronos_int32_t; typedef uint32_t khronos_uint32_t; typedef int64_t khronos_int64_t; typedef uint64_t khronos_uint64_t; #define KHRONOS_SUPPORT_INT64 1 #define KHRONOS_SUPPORT_FLOAT 1 /* * To support platform where unsigned long cannot be used interchangeably with * inptr_t (e.g. CHERI-extended ISAs), we can use the stdint.h intptr_t. * Ideally, we could just use (u)intptr_t everywhere, but this could result in * ABI breakage if khronos_uintptr_t is changed from unsigned long to * unsigned long long or similar (this results in different C++ name mangling). * To avoid changes for existing platforms, we restrict usage of intptr_t to * platforms where the size of a pointer is larger than the size of long. */ #if defined(__SIZEOF_LONG__) && defined(__SIZEOF_POINTER__) #if __SIZEOF_POINTER__ > __SIZEOF_LONG__ #define KHRONOS_USE_INTPTR_T #endif #endif #elif defined(__VMS ) || defined(__sgi) /* * Using */ #include typedef int32_t khronos_int32_t; typedef uint32_t khronos_uint32_t; typedef int64_t khronos_int64_t; typedef uint64_t khronos_uint64_t; #define KHRONOS_SUPPORT_INT64 1 #define KHRONOS_SUPPORT_FLOAT 1 #elif defined(_WIN32) && !defined(__SCITECH_SNAP__) /* * Win32 */ typedef __int32 khronos_int32_t; typedef unsigned __int32 khronos_uint32_t; typedef __int64 khronos_int64_t; typedef unsigned __int64 khronos_uint64_t; #define KHRONOS_SUPPORT_INT64 1 #define KHRONOS_SUPPORT_FLOAT 1 #elif defined(__sun__) || defined(__digital__) /* * Sun or Digital */ typedef int khronos_int32_t; typedef unsigned int khronos_uint32_t; #if defined(__arch64__) || defined(_LP64) typedef long int khronos_int64_t; typedef unsigned long int khronos_uint64_t; #else typedef long long int khronos_int64_t; typedef unsigned long long int khronos_uint64_t; #endif /* __arch64__ */ #define KHRONOS_SUPPORT_INT64 1 #define KHRONOS_SUPPORT_FLOAT 1 #elif 0 /* * Hypothetical platform with no float or int64 support */ typedef int khronos_int32_t; typedef unsigned int khronos_uint32_t; #define KHRONOS_SUPPORT_INT64 0 #define KHRONOS_SUPPORT_FLOAT 0 #else /* * Generic fallback */ #include typedef int32_t khronos_int32_t; typedef uint32_t khronos_uint32_t; typedef int64_t khronos_int64_t; typedef uint64_t khronos_uint64_t; #define KHRONOS_SUPPORT_INT64 1 #define KHRONOS_SUPPORT_FLOAT 1 #endif /* * Types that are (so far) the same on all platforms */ typedef signed char khronos_int8_t; typedef unsigned char khronos_uint8_t; typedef signed short int khronos_int16_t; typedef unsigned short int khronos_uint16_t; /* * Types that differ between LLP64 and LP64 architectures - in LLP64, * pointers are 64 bits, but 'long' is still 32 bits. Win64 appears * to be the only LLP64 architecture in current use. */ #ifdef KHRONOS_USE_INTPTR_T typedef intptr_t khronos_intptr_t; typedef uintptr_t khronos_uintptr_t; #elif defined(_WIN64) typedef signed long long int khronos_intptr_t; typedef unsigned long long int khronos_uintptr_t; #else typedef signed long int khronos_intptr_t; typedef unsigned long int khronos_uintptr_t; #endif #if defined(_WIN64) typedef signed long long int khronos_ssize_t; typedef unsigned long long int khronos_usize_t; #else typedef signed long int khronos_ssize_t; typedef unsigned long int khronos_usize_t; #endif #if KHRONOS_SUPPORT_FLOAT /* * Float type */ typedef float khronos_float_t; #endif #if KHRONOS_SUPPORT_INT64 /* Time types * * These types can be used to represent a time interval in nanoseconds or * an absolute Unadjusted System Time. Unadjusted System Time is the number * of nanoseconds since some arbitrary system event (e.g. since the last * time the system booted). The Unadjusted System Time is an unsigned * 64 bit value that wraps back to 0 every 584 years. Time intervals * may be either signed or unsigned. */ typedef khronos_uint64_t khronos_utime_nanoseconds_t; typedef khronos_int64_t khronos_stime_nanoseconds_t; #endif /* * Dummy value used to pad enum types to 32 bits. */ #ifndef KHRONOS_MAX_ENUM #define KHRONOS_MAX_ENUM 0x7FFFFFFF #endif /* * Enumerated boolean type * * Values other than zero should be considered to be true. Therefore * comparisons should not be made against KHRONOS_TRUE. */ typedef enum { KHRONOS_FALSE = 0, KHRONOS_TRUE = 1, KHRONOS_BOOLEAN_ENUM_FORCE_SIZE = KHRONOS_MAX_ENUM } khronos_boolean_enum_t; #endif /* __khrplatform_h_ */ #ifndef __eglplatform_h_ #define __eglplatform_h_ /* ** Copyright 2007-2020 The Khronos Group Inc. ** SPDX-License-Identifier: Apache-2.0 */ /* Platform-specific types and definitions for egl.h * * Adopters may modify khrplatform.h and this file to suit their platform. * You are encouraged to submit all modifications to the Khronos group so that * they can be included in future versions of this file. Please submit changes * by filing an issue or pull request on the public Khronos EGL Registry, at * https://www.github.com/KhronosGroup/EGL-Registry/ */ /*#include */ /* Macros used in EGL function prototype declarations. * * EGL functions should be prototyped as: * * EGLAPI return-type EGLAPIENTRY eglFunction(arguments); * typedef return-type (EXPAPIENTRYP PFNEGLFUNCTIONPROC) (arguments); * * KHRONOS_APICALL and KHRONOS_APIENTRY are defined in KHR/khrplatform.h */ #ifndef EGLAPI #define EGLAPI KHRONOS_APICALL #endif #ifndef EGLAPIENTRY #define EGLAPIENTRY KHRONOS_APIENTRY #endif #define EGLAPIENTRYP EGLAPIENTRY* /* The types NativeDisplayType, NativeWindowType, and NativePixmapType * are aliases of window-system-dependent types, such as X Display * or * Windows Device Context. They must be defined in platform-specific * code below. The EGL-prefixed versions of Native*Type are the same * types, renamed in EGL 1.3 so all types in the API start with "EGL". * * Khronos STRONGLY RECOMMENDS that you use the default definitions * provided below, since these changes affect both binary and source * portability of applications using EGL running on different EGL * implementations. */ #if defined(EGL_NO_PLATFORM_SPECIFIC_TYPES) typedef void *EGLNativeDisplayType; typedef void *EGLNativePixmapType; typedef void *EGLNativeWindowType; #elif defined(_WIN32) || defined(__VC32__) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__) /* Win32 and WinCE */ #ifndef WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN 1 #endif #include typedef HDC EGLNativeDisplayType; typedef HBITMAP EGLNativePixmapType; typedef HWND EGLNativeWindowType; #elif defined(SDL_PLATFORM_EMSCRIPTEN) typedef int EGLNativeDisplayType; typedef int EGLNativePixmapType; typedef int EGLNativeWindowType; #elif defined(__WINSCW__) || defined(__SYMBIAN32__) /* Symbian */ typedef int EGLNativeDisplayType; typedef void *EGLNativePixmapType; typedef void *EGLNativeWindowType; #elif defined(WL_EGL_PLATFORM) typedef struct wl_display *EGLNativeDisplayType; typedef struct wl_egl_pixmap *EGLNativePixmapType; typedef struct wl_egl_window *EGLNativeWindowType; #elif defined(__GBM__) typedef struct gbm_device *EGLNativeDisplayType; typedef struct gbm_bo *EGLNativePixmapType; typedef void *EGLNativeWindowType; #elif defined(__ANDROID__) || defined(ANDROID) struct ANativeWindow; struct egl_native_pixmap_t; typedef void* EGLNativeDisplayType; typedef struct egl_native_pixmap_t* EGLNativePixmapType; typedef struct ANativeWindow* EGLNativeWindowType; #elif defined(USE_OZONE) typedef intptr_t EGLNativeDisplayType; typedef intptr_t EGLNativePixmapType; typedef intptr_t EGLNativeWindowType; #elif defined(USE_X11) /* X11 (tentative) */ #include #include typedef Display *EGLNativeDisplayType; typedef Pixmap EGLNativePixmapType; typedef Window EGLNativeWindowType; #elif defined(__unix__) typedef void *EGLNativeDisplayType; typedef khronos_uintptr_t EGLNativePixmapType; typedef khronos_uintptr_t EGLNativeWindowType; #elif defined(__APPLE__) typedef int EGLNativeDisplayType; typedef void *EGLNativePixmapType; typedef void *EGLNativeWindowType; #elif defined(__HAIKU__) #include typedef void *EGLNativeDisplayType; typedef khronos_uintptr_t EGLNativePixmapType; typedef khronos_uintptr_t EGLNativeWindowType; #elif defined(__Fuchsia__) typedef void *EGLNativeDisplayType; typedef khronos_uintptr_t EGLNativePixmapType; typedef khronos_uintptr_t EGLNativeWindowType; #else #error "Platform not recognized" #endif /* EGL 1.2 types, renamed for consistency in EGL 1.3 */ typedef EGLNativeDisplayType NativeDisplayType; typedef EGLNativePixmapType NativePixmapType; typedef EGLNativeWindowType NativeWindowType; /* Define EGLint. This must be a signed integral type large enough to contain * all legal attribute names and values passed into and out of EGL, whether * their type is boolean, bitmask, enumerant (symbolic constant), integer, * handle, or other. While in general a 32-bit integer will suffice, if * handles are 64 bit types, then EGLint should be defined as a signed 64-bit * integer type. */ typedef khronos_int32_t EGLint; /* C++ / C typecast macros for special EGL handle values */ #if defined(__cplusplus) #define EGL_CAST(type, value) (static_cast(value)) #else #define EGL_CAST(type, value) ((type) (value)) #endif #endif /* __eglplatform_h */ #ifndef __egl_h_ #define __egl_h_ 1 #ifdef __cplusplus extern "C" { #endif /* ** Copyright 2013-2020 The Khronos Group Inc. ** SPDX-License-Identifier: Apache-2.0 ** ** This header is generated from the Khronos EGL XML API Registry. ** The current version of the Registry, generator scripts ** used to make the header, and the header can be found at ** http://www.khronos.org/registry/egl ** ** Khronos $Git commit SHA1: 6fb1daea15 $ on $Git commit date: 2022-05-25 09:41:13 -0600 $ */ /*#include */ #ifndef EGL_EGL_PROTOTYPES #define EGL_EGL_PROTOTYPES 1 #endif /* Generated on date 20220525 */ /* Generated C header for: * API: egl * Versions considered: .* * Versions emitted: .* * Default extensions included: None * Additional extensions included: _nomatch_^ * Extensions removed: _nomatch_^ */ #ifndef EGL_VERSION_1_0 #define EGL_VERSION_1_0 1 typedef unsigned int EGLBoolean; typedef void *EGLDisplay; /*#include */ /*#include */ typedef void *EGLConfig; typedef void *EGLSurface; typedef void *EGLContext; typedef void (*__eglMustCastToProperFunctionPointerType)(void); #define EGL_ALPHA_SIZE 0x3021 #define EGL_BAD_ACCESS 0x3002 #define EGL_BAD_ALLOC 0x3003 #define EGL_BAD_ATTRIBUTE 0x3004 #define EGL_BAD_CONFIG 0x3005 #define EGL_BAD_CONTEXT 0x3006 #define EGL_BAD_CURRENT_SURFACE 0x3007 #define EGL_BAD_DISPLAY 0x3008 #define EGL_BAD_MATCH 0x3009 #define EGL_BAD_NATIVE_PIXMAP 0x300A #define EGL_BAD_NATIVE_WINDOW 0x300B #define EGL_BAD_PARAMETER 0x300C #define EGL_BAD_SURFACE 0x300D #define EGL_BLUE_SIZE 0x3022 #define EGL_BUFFER_SIZE 0x3020 #define EGL_CONFIG_CAVEAT 0x3027 #define EGL_CONFIG_ID 0x3028 #define EGL_CORE_NATIVE_ENGINE 0x305B #define EGL_DEPTH_SIZE 0x3025 #define EGL_DONT_CARE EGL_CAST(EGLint,-1) #define EGL_DRAW 0x3059 #define EGL_EXTENSIONS 0x3055 #define EGL_FALSE 0 #define EGL_GREEN_SIZE 0x3023 #define EGL_HEIGHT 0x3056 #define EGL_LARGEST_PBUFFER 0x3058 #define EGL_LEVEL 0x3029 #define EGL_MAX_PBUFFER_HEIGHT 0x302A #define EGL_MAX_PBUFFER_PIXELS 0x302B #define EGL_MAX_PBUFFER_WIDTH 0x302C #define EGL_NATIVE_RENDERABLE 0x302D #define EGL_NATIVE_VISUAL_ID 0x302E #define EGL_NATIVE_VISUAL_TYPE 0x302F #define EGL_NONE 0x3038 #define EGL_NON_CONFORMANT_CONFIG 0x3051 #define EGL_NOT_INITIALIZED 0x3001 #define EGL_NO_CONTEXT EGL_CAST(EGLContext,0) #define EGL_NO_DISPLAY EGL_CAST(EGLDisplay,0) #define EGL_NO_SURFACE EGL_CAST(EGLSurface,0) #define EGL_PBUFFER_BIT 0x0001 #define EGL_PIXMAP_BIT 0x0002 #define EGL_READ 0x305A #define EGL_RED_SIZE 0x3024 #define EGL_SAMPLES 0x3031 #define EGL_SAMPLE_BUFFERS 0x3032 #define EGL_SLOW_CONFIG 0x3050 #define EGL_STENCIL_SIZE 0x3026 #define EGL_SUCCESS 0x3000 #define EGL_SURFACE_TYPE 0x3033 #define EGL_TRANSPARENT_BLUE_VALUE 0x3035 #define EGL_TRANSPARENT_GREEN_VALUE 0x3036 #define EGL_TRANSPARENT_RED_VALUE 0x3037 #define EGL_TRANSPARENT_RGB 0x3052 #define EGL_TRANSPARENT_TYPE 0x3034 #define EGL_TRUE 1 #define EGL_VENDOR 0x3053 #define EGL_VERSION 0x3054 #define EGL_WIDTH 0x3057 #define EGL_WINDOW_BIT 0x0004 typedef EGLBoolean (EGLAPIENTRYP PFNEGLCHOOSECONFIGPROC) (EGLDisplay dpy, const EGLint *attrib_list, EGLConfig *configs, EGLint config_size, EGLint *num_config); typedef EGLBoolean (EGLAPIENTRYP PFNEGLCOPYBUFFERSPROC) (EGLDisplay dpy, EGLSurface surface, EGLNativePixmapType target); typedef EGLContext (EGLAPIENTRYP PFNEGLCREATECONTEXTPROC) (EGLDisplay dpy, EGLConfig config, EGLContext share_context, const EGLint *attrib_list); typedef EGLSurface (EGLAPIENTRYP PFNEGLCREATEPBUFFERSURFACEPROC) (EGLDisplay dpy, EGLConfig config, const EGLint *attrib_list); typedef EGLSurface (EGLAPIENTRYP PFNEGLCREATEPIXMAPSURFACEPROC) (EGLDisplay dpy, EGLConfig config, EGLNativePixmapType pixmap, const EGLint *attrib_list); typedef EGLSurface (EGLAPIENTRYP PFNEGLCREATEWINDOWSURFACEPROC) (EGLDisplay dpy, EGLConfig config, EGLNativeWindowType win, const EGLint *attrib_list); typedef EGLBoolean (EGLAPIENTRYP PFNEGLDESTROYCONTEXTPROC) (EGLDisplay dpy, EGLContext ctx); typedef EGLBoolean (EGLAPIENTRYP PFNEGLDESTROYSURFACEPROC) (EGLDisplay dpy, EGLSurface surface); typedef EGLBoolean (EGLAPIENTRYP PFNEGLGETCONFIGATTRIBPROC) (EGLDisplay dpy, EGLConfig config, EGLint attribute, EGLint *value); typedef EGLBoolean (EGLAPIENTRYP PFNEGLGETCONFIGSPROC) (EGLDisplay dpy, EGLConfig *configs, EGLint config_size, EGLint *num_config); typedef EGLDisplay (EGLAPIENTRYP PFNEGLGETCURRENTDISPLAYPROC) (void); typedef EGLSurface (EGLAPIENTRYP PFNEGLGETCURRENTSURFACEPROC) (EGLint readdraw); typedef EGLDisplay (EGLAPIENTRYP PFNEGLGETDISPLAYPROC) (EGLNativeDisplayType display_id); typedef EGLint (EGLAPIENTRYP PFNEGLGETERRORPROC) (void); typedef __eglMustCastToProperFunctionPointerType (EGLAPIENTRYP PFNEGLGETPROCADDRESSPROC) (const char *procname); typedef EGLBoolean (EGLAPIENTRYP PFNEGLINITIALIZEPROC) (EGLDisplay dpy, EGLint *major, EGLint *minor); typedef EGLBoolean (EGLAPIENTRYP PFNEGLMAKECURRENTPROC) (EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext ctx); typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYCONTEXTPROC) (EGLDisplay dpy, EGLContext ctx, EGLint attribute, EGLint *value); typedef const char *(EGLAPIENTRYP PFNEGLQUERYSTRINGPROC) (EGLDisplay dpy, EGLint name); typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYSURFACEPROC) (EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint *value); typedef EGLBoolean (EGLAPIENTRYP PFNEGLSWAPBUFFERSPROC) (EGLDisplay dpy, EGLSurface surface); typedef EGLBoolean (EGLAPIENTRYP PFNEGLTERMINATEPROC) (EGLDisplay dpy); typedef EGLBoolean (EGLAPIENTRYP PFNEGLWAITGLPROC) (void); typedef EGLBoolean (EGLAPIENTRYP PFNEGLWAITNATIVEPROC) (EGLint engine); #if EGL_EGL_PROTOTYPES EGLAPI EGLBoolean EGLAPIENTRY eglChooseConfig (EGLDisplay dpy, const EGLint *attrib_list, EGLConfig *configs, EGLint config_size, EGLint *num_config); EGLAPI EGLBoolean EGLAPIENTRY eglCopyBuffers (EGLDisplay dpy, EGLSurface surface, EGLNativePixmapType target); EGLAPI EGLContext EGLAPIENTRY eglCreateContext (EGLDisplay dpy, EGLConfig config, EGLContext share_context, const EGLint *attrib_list); EGLAPI EGLSurface EGLAPIENTRY eglCreatePbufferSurface (EGLDisplay dpy, EGLConfig config, const EGLint *attrib_list); EGLAPI EGLSurface EGLAPIENTRY eglCreatePixmapSurface (EGLDisplay dpy, EGLConfig config, EGLNativePixmapType pixmap, const EGLint *attrib_list); EGLAPI EGLSurface EGLAPIENTRY eglCreateWindowSurface (EGLDisplay dpy, EGLConfig config, EGLNativeWindowType win, const EGLint *attrib_list); EGLAPI EGLBoolean EGLAPIENTRY eglDestroyContext (EGLDisplay dpy, EGLContext ctx); EGLAPI EGLBoolean EGLAPIENTRY eglDestroySurface (EGLDisplay dpy, EGLSurface surface); EGLAPI EGLBoolean EGLAPIENTRY eglGetConfigAttrib (EGLDisplay dpy, EGLConfig config, EGLint attribute, EGLint *value); EGLAPI EGLBoolean EGLAPIENTRY eglGetConfigs (EGLDisplay dpy, EGLConfig *configs, EGLint config_size, EGLint *num_config); EGLAPI EGLDisplay EGLAPIENTRY eglGetCurrentDisplay (void); EGLAPI EGLSurface EGLAPIENTRY eglGetCurrentSurface (EGLint readdraw); EGLAPI EGLDisplay EGLAPIENTRY eglGetDisplay (EGLNativeDisplayType display_id); EGLAPI EGLint EGLAPIENTRY eglGetError (void); EGLAPI __eglMustCastToProperFunctionPointerType EGLAPIENTRY eglGetProcAddress (const char *procname); EGLAPI EGLBoolean EGLAPIENTRY eglInitialize (EGLDisplay dpy, EGLint *major, EGLint *minor); EGLAPI EGLBoolean EGLAPIENTRY eglMakeCurrent (EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext ctx); EGLAPI EGLBoolean EGLAPIENTRY eglQueryContext (EGLDisplay dpy, EGLContext ctx, EGLint attribute, EGLint *value); EGLAPI const char *EGLAPIENTRY eglQueryString (EGLDisplay dpy, EGLint name); EGLAPI EGLBoolean EGLAPIENTRY eglQuerySurface (EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint *value); EGLAPI EGLBoolean EGLAPIENTRY eglSwapBuffers (EGLDisplay dpy, EGLSurface surface); EGLAPI EGLBoolean EGLAPIENTRY eglTerminate (EGLDisplay dpy); EGLAPI EGLBoolean EGLAPIENTRY eglWaitGL (void); EGLAPI EGLBoolean EGLAPIENTRY eglWaitNative (EGLint engine); #endif #endif /* EGL_VERSION_1_0 */ #ifndef EGL_VERSION_1_1 #define EGL_VERSION_1_1 1 #define EGL_BACK_BUFFER 0x3084 #define EGL_BIND_TO_TEXTURE_RGB 0x3039 #define EGL_BIND_TO_TEXTURE_RGBA 0x303A #define EGL_CONTEXT_LOST 0x300E #define EGL_MIN_SWAP_INTERVAL 0x303B #define EGL_MAX_SWAP_INTERVAL 0x303C #define EGL_MIPMAP_TEXTURE 0x3082 #define EGL_MIPMAP_LEVEL 0x3083 #define EGL_NO_TEXTURE 0x305C #define EGL_TEXTURE_2D 0x305F #define EGL_TEXTURE_FORMAT 0x3080 #define EGL_TEXTURE_RGB 0x305D #define EGL_TEXTURE_RGBA 0x305E #define EGL_TEXTURE_TARGET 0x3081 typedef EGLBoolean (EGLAPIENTRYP PFNEGLBINDTEXIMAGEPROC) (EGLDisplay dpy, EGLSurface surface, EGLint buffer); typedef EGLBoolean (EGLAPIENTRYP PFNEGLRELEASETEXIMAGEPROC) (EGLDisplay dpy, EGLSurface surface, EGLint buffer); typedef EGLBoolean (EGLAPIENTRYP PFNEGLSURFACEATTRIBPROC) (EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint value); typedef EGLBoolean (EGLAPIENTRYP PFNEGLSWAPINTERVALPROC) (EGLDisplay dpy, EGLint interval); #if EGL_EGL_PROTOTYPES EGLAPI EGLBoolean EGLAPIENTRY eglBindTexImage (EGLDisplay dpy, EGLSurface surface, EGLint buffer); EGLAPI EGLBoolean EGLAPIENTRY eglReleaseTexImage (EGLDisplay dpy, EGLSurface surface, EGLint buffer); EGLAPI EGLBoolean EGLAPIENTRY eglSurfaceAttrib (EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint value); EGLAPI EGLBoolean EGLAPIENTRY eglSwapInterval (EGLDisplay dpy, EGLint interval); #endif #endif /* EGL_VERSION_1_1 */ #ifndef EGL_VERSION_1_2 #define EGL_VERSION_1_2 1 typedef unsigned int EGLenum; typedef void *EGLClientBuffer; #define EGL_ALPHA_FORMAT 0x3088 #define EGL_ALPHA_FORMAT_NONPRE 0x308B #define EGL_ALPHA_FORMAT_PRE 0x308C #define EGL_ALPHA_MASK_SIZE 0x303E #define EGL_BUFFER_PRESERVED 0x3094 #define EGL_BUFFER_DESTROYED 0x3095 #define EGL_CLIENT_APIS 0x308D #define EGL_COLORSPACE 0x3087 #define EGL_COLORSPACE_sRGB 0x3089 #define EGL_COLORSPACE_LINEAR 0x308A #define EGL_COLOR_BUFFER_TYPE 0x303F #define EGL_CONTEXT_CLIENT_TYPE 0x3097 #define EGL_DISPLAY_SCALING 10000 #define EGL_HORIZONTAL_RESOLUTION 0x3090 #define EGL_LUMINANCE_BUFFER 0x308F #define EGL_LUMINANCE_SIZE 0x303D #define EGL_OPENGL_ES_BIT 0x0001 #define EGL_OPENVG_BIT 0x0002 #define EGL_OPENGL_ES_API 0x30A0 #define EGL_OPENVG_API 0x30A1 #define EGL_OPENVG_IMAGE 0x3096 #define EGL_PIXEL_ASPECT_RATIO 0x3092 #define EGL_RENDERABLE_TYPE 0x3040 #define EGL_RENDER_BUFFER 0x3086 #define EGL_RGB_BUFFER 0x308E #define EGL_SINGLE_BUFFER 0x3085 #define EGL_SWAP_BEHAVIOR 0x3093 #define EGL_UNKNOWN EGL_CAST(EGLint,-1) #define EGL_VERTICAL_RESOLUTION 0x3091 typedef EGLBoolean (EGLAPIENTRYP PFNEGLBINDAPIPROC) (EGLenum api); typedef EGLenum (EGLAPIENTRYP PFNEGLQUERYAPIPROC) (void); typedef EGLSurface (EGLAPIENTRYP PFNEGLCREATEPBUFFERFROMCLIENTBUFFERPROC) (EGLDisplay dpy, EGLenum buftype, EGLClientBuffer buffer, EGLConfig config, const EGLint *attrib_list); typedef EGLBoolean (EGLAPIENTRYP PFNEGLRELEASETHREADPROC) (void); typedef EGLBoolean (EGLAPIENTRYP PFNEGLWAITCLIENTPROC) (void); #if EGL_EGL_PROTOTYPES EGLAPI EGLBoolean EGLAPIENTRY eglBindAPI (EGLenum api); EGLAPI EGLenum EGLAPIENTRY eglQueryAPI (void); EGLAPI EGLSurface EGLAPIENTRY eglCreatePbufferFromClientBuffer (EGLDisplay dpy, EGLenum buftype, EGLClientBuffer buffer, EGLConfig config, const EGLint *attrib_list); EGLAPI EGLBoolean EGLAPIENTRY eglReleaseThread (void); EGLAPI EGLBoolean EGLAPIENTRY eglWaitClient (void); #endif #endif /* EGL_VERSION_1_2 */ #ifndef EGL_VERSION_1_3 #define EGL_VERSION_1_3 1 #define EGL_CONFORMANT 0x3042 #define EGL_CONTEXT_CLIENT_VERSION 0x3098 #define EGL_MATCH_NATIVE_PIXMAP 0x3041 #define EGL_OPENGL_ES2_BIT 0x0004 #define EGL_VG_ALPHA_FORMAT 0x3088 #define EGL_VG_ALPHA_FORMAT_NONPRE 0x308B #define EGL_VG_ALPHA_FORMAT_PRE 0x308C #define EGL_VG_ALPHA_FORMAT_PRE_BIT 0x0040 #define EGL_VG_COLORSPACE 0x3087 #define EGL_VG_COLORSPACE_sRGB 0x3089 #define EGL_VG_COLORSPACE_LINEAR 0x308A #define EGL_VG_COLORSPACE_LINEAR_BIT 0x0020 #endif /* EGL_VERSION_1_3 */ #ifndef EGL_VERSION_1_4 #define EGL_VERSION_1_4 1 #define EGL_DEFAULT_DISPLAY EGL_CAST(EGLNativeDisplayType,0) #define EGL_MULTISAMPLE_RESOLVE_BOX_BIT 0x0200 #define EGL_MULTISAMPLE_RESOLVE 0x3099 #define EGL_MULTISAMPLE_RESOLVE_DEFAULT 0x309A #define EGL_MULTISAMPLE_RESOLVE_BOX 0x309B #define EGL_OPENGL_API 0x30A2 #define EGL_OPENGL_BIT 0x0008 #define EGL_SWAP_BEHAVIOR_PRESERVED_BIT 0x0400 typedef EGLContext (EGLAPIENTRYP PFNEGLGETCURRENTCONTEXTPROC) (void); #if EGL_EGL_PROTOTYPES EGLAPI EGLContext EGLAPIENTRY eglGetCurrentContext (void); #endif #endif /* EGL_VERSION_1_4 */ #ifndef EGL_VERSION_1_5 #define EGL_VERSION_1_5 1 typedef void *EGLSync; typedef intptr_t EGLAttrib; typedef khronos_utime_nanoseconds_t EGLTime; typedef void *EGLImage; #define EGL_CONTEXT_MAJOR_VERSION 0x3098 #define EGL_CONTEXT_MINOR_VERSION 0x30FB #define EGL_CONTEXT_OPENGL_PROFILE_MASK 0x30FD #define EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY 0x31BD #define EGL_NO_RESET_NOTIFICATION 0x31BE #define EGL_LOSE_CONTEXT_ON_RESET 0x31BF #define EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT 0x00000001 #define EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT 0x00000002 #define EGL_CONTEXT_OPENGL_DEBUG 0x31B0 #define EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE 0x31B1 #define EGL_CONTEXT_OPENGL_ROBUST_ACCESS 0x31B2 #define EGL_OPENGL_ES3_BIT 0x00000040 #define EGL_CL_EVENT_HANDLE 0x309C #define EGL_SYNC_CL_EVENT 0x30FE #define EGL_SYNC_CL_EVENT_COMPLETE 0x30FF #define EGL_SYNC_PRIOR_COMMANDS_COMPLETE 0x30F0 #define EGL_SYNC_TYPE 0x30F7 #define EGL_SYNC_STATUS 0x30F1 #define EGL_SYNC_CONDITION 0x30F8 #define EGL_SIGNALED 0x30F2 #define EGL_UNSIGNALED 0x30F3 #define EGL_SYNC_FLUSH_COMMANDS_BIT 0x0001 #define EGL_FOREVER 0xFFFFFFFFFFFFFFFFull #define EGL_TIMEOUT_EXPIRED 0x30F5 #define EGL_CONDITION_SATISFIED 0x30F6 #define EGL_NO_SYNC EGL_CAST(EGLSync,0) #define EGL_SYNC_FENCE 0x30F9 #define EGL_GL_COLORSPACE 0x309D #define EGL_GL_COLORSPACE_SRGB 0x3089 #define EGL_GL_COLORSPACE_LINEAR 0x308A #define EGL_GL_RENDERBUFFER 0x30B9 #define EGL_GL_TEXTURE_2D 0x30B1 #define EGL_GL_TEXTURE_LEVEL 0x30BC #define EGL_GL_TEXTURE_3D 0x30B2 #define EGL_GL_TEXTURE_ZOFFSET 0x30BD #define EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_X 0x30B3 #define EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_X 0x30B4 #define EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_Y 0x30B5 #define EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Y 0x30B6 #define EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_Z 0x30B7 #define EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Z 0x30B8 #define EGL_IMAGE_PRESERVED 0x30D2 #define EGL_NO_IMAGE EGL_CAST(EGLImage,0) typedef EGLSync (EGLAPIENTRYP PFNEGLCREATESYNCPROC) (EGLDisplay dpy, EGLenum type, const EGLAttrib *attrib_list); typedef EGLBoolean (EGLAPIENTRYP PFNEGLDESTROYSYNCPROC) (EGLDisplay dpy, EGLSync sync); typedef EGLint (EGLAPIENTRYP PFNEGLCLIENTWAITSYNCPROC) (EGLDisplay dpy, EGLSync sync, EGLint flags, EGLTime timeout); typedef EGLBoolean (EGLAPIENTRYP PFNEGLGETSYNCATTRIBPROC) (EGLDisplay dpy, EGLSync sync, EGLint attribute, EGLAttrib *value); typedef EGLImage (EGLAPIENTRYP PFNEGLCREATEIMAGEPROC) (EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer, const EGLAttrib *attrib_list); typedef EGLBoolean (EGLAPIENTRYP PFNEGLDESTROYIMAGEPROC) (EGLDisplay dpy, EGLImage image); typedef EGLDisplay (EGLAPIENTRYP PFNEGLGETPLATFORMDISPLAYPROC) (EGLenum platform, void *native_display, const EGLAttrib *attrib_list); typedef EGLSurface (EGLAPIENTRYP PFNEGLCREATEPLATFORMWINDOWSURFACEPROC) (EGLDisplay dpy, EGLConfig config, void *native_window, const EGLAttrib *attrib_list); typedef EGLSurface (EGLAPIENTRYP PFNEGLCREATEPLATFORMPIXMAPSURFACEPROC) (EGLDisplay dpy, EGLConfig config, void *native_pixmap, const EGLAttrib *attrib_list); typedef EGLBoolean (EGLAPIENTRYP PFNEGLWAITSYNCPROC) (EGLDisplay dpy, EGLSync sync, EGLint flags); #if EGL_EGL_PROTOTYPES EGLAPI EGLSync EGLAPIENTRY eglCreateSync (EGLDisplay dpy, EGLenum type, const EGLAttrib *attrib_list); EGLAPI EGLBoolean EGLAPIENTRY eglDestroySync (EGLDisplay dpy, EGLSync sync); EGLAPI EGLint EGLAPIENTRY eglClientWaitSync (EGLDisplay dpy, EGLSync sync, EGLint flags, EGLTime timeout); EGLAPI EGLBoolean EGLAPIENTRY eglGetSyncAttrib (EGLDisplay dpy, EGLSync sync, EGLint attribute, EGLAttrib *value); EGLAPI EGLImage EGLAPIENTRY eglCreateImage (EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer, const EGLAttrib *attrib_list); EGLAPI EGLBoolean EGLAPIENTRY eglDestroyImage (EGLDisplay dpy, EGLImage image); EGLAPI EGLDisplay EGLAPIENTRY eglGetPlatformDisplay (EGLenum platform, void *native_display, const EGLAttrib *attrib_list); EGLAPI EGLSurface EGLAPIENTRY eglCreatePlatformWindowSurface (EGLDisplay dpy, EGLConfig config, void *native_window, const EGLAttrib *attrib_list); EGLAPI EGLSurface EGLAPIENTRY eglCreatePlatformPixmapSurface (EGLDisplay dpy, EGLConfig config, void *native_pixmap, const EGLAttrib *attrib_list); EGLAPI EGLBoolean EGLAPIENTRY eglWaitSync (EGLDisplay dpy, EGLSync sync, EGLint flags); #endif #endif /* EGL_VERSION_1_5 */ #ifdef __cplusplus } #endif #endif /* __egl_h_ */ #ifndef __eglext_h_ #define __eglext_h_ 1 #ifdef __cplusplus extern "C" { #endif /* ** Copyright 2013-2020 The Khronos Group Inc. ** SPDX-License-Identifier: Apache-2.0 ** ** This header is generated from the Khronos EGL XML API Registry. ** The current version of the Registry, generator scripts ** used to make the header, and the header can be found at ** http://www.khronos.org/registry/egl ** ** Khronos $Git commit SHA1: 6fb1daea15 $ on $Git commit date: 2022-05-25 09:41:13 -0600 $ */ /*#include */ #define EGL_EGLEXT_VERSION 20220525 /* Generated C header for: * API: egl * Versions considered: .* * Versions emitted: _nomatch_^ * Default extensions included: egl * Additional extensions included: _nomatch_^ * Extensions removed: _nomatch_^ */ #ifndef EGL_KHR_cl_event #define EGL_KHR_cl_event 1 #define EGL_CL_EVENT_HANDLE_KHR 0x309C #define EGL_SYNC_CL_EVENT_KHR 0x30FE #define EGL_SYNC_CL_EVENT_COMPLETE_KHR 0x30FF #endif /* EGL_KHR_cl_event */ #ifndef EGL_KHR_cl_event2 #define EGL_KHR_cl_event2 1 typedef void *EGLSyncKHR; typedef intptr_t EGLAttribKHR; typedef EGLSyncKHR (EGLAPIENTRYP PFNEGLCREATESYNC64KHRPROC) (EGLDisplay dpy, EGLenum type, const EGLAttribKHR *attrib_list); #ifdef EGL_EGLEXT_PROTOTYPES EGLAPI EGLSyncKHR EGLAPIENTRY eglCreateSync64KHR (EGLDisplay dpy, EGLenum type, const EGLAttribKHR *attrib_list); #endif #endif /* EGL_KHR_cl_event2 */ #ifndef EGL_KHR_client_get_all_proc_addresses #define EGL_KHR_client_get_all_proc_addresses 1 #endif /* EGL_KHR_client_get_all_proc_addresses */ #ifndef EGL_KHR_config_attribs #define EGL_KHR_config_attribs 1 #define EGL_CONFORMANT_KHR 0x3042 #define EGL_VG_COLORSPACE_LINEAR_BIT_KHR 0x0020 #define EGL_VG_ALPHA_FORMAT_PRE_BIT_KHR 0x0040 #endif /* EGL_KHR_config_attribs */ #ifndef EGL_KHR_context_flush_control #define EGL_KHR_context_flush_control 1 #define EGL_CONTEXT_RELEASE_BEHAVIOR_NONE_KHR 0 #define EGL_CONTEXT_RELEASE_BEHAVIOR_KHR 0x2097 #define EGL_CONTEXT_RELEASE_BEHAVIOR_FLUSH_KHR 0x2098 #endif /* EGL_KHR_context_flush_control */ #ifndef EGL_KHR_create_context #define EGL_KHR_create_context 1 #define EGL_CONTEXT_MAJOR_VERSION_KHR 0x3098 #define EGL_CONTEXT_MINOR_VERSION_KHR 0x30FB #define EGL_CONTEXT_FLAGS_KHR 0x30FC #define EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR 0x30FD #define EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_KHR 0x31BD #define EGL_NO_RESET_NOTIFICATION_KHR 0x31BE #define EGL_LOSE_CONTEXT_ON_RESET_KHR 0x31BF #define EGL_CONTEXT_OPENGL_DEBUG_BIT_KHR 0x00000001 #define EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR 0x00000002 #define EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR 0x00000004 #define EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT_KHR 0x00000001 #define EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT_KHR 0x00000002 #define EGL_OPENGL_ES3_BIT_KHR 0x00000040 #endif /* EGL_KHR_create_context */ #ifndef EGL_KHR_create_context_no_error #define EGL_KHR_create_context_no_error 1 #define EGL_CONTEXT_OPENGL_NO_ERROR_KHR 0x31B3 #endif /* EGL_KHR_create_context_no_error */ #ifndef EGL_KHR_debug #define EGL_KHR_debug 1 typedef void *EGLLabelKHR; typedef void *EGLObjectKHR; typedef void (EGLAPIENTRY *EGLDEBUGPROCKHR)(EGLenum error,const char *command,EGLint messageType,EGLLabelKHR threadLabel,EGLLabelKHR objectLabel,const char* message); #define EGL_OBJECT_THREAD_KHR 0x33B0 #define EGL_OBJECT_DISPLAY_KHR 0x33B1 #define EGL_OBJECT_CONTEXT_KHR 0x33B2 #define EGL_OBJECT_SURFACE_KHR 0x33B3 #define EGL_OBJECT_IMAGE_KHR 0x33B4 #define EGL_OBJECT_SYNC_KHR 0x33B5 #define EGL_OBJECT_STREAM_KHR 0x33B6 #define EGL_DEBUG_MSG_CRITICAL_KHR 0x33B9 #define EGL_DEBUG_MSG_ERROR_KHR 0x33BA #define EGL_DEBUG_MSG_WARN_KHR 0x33BB #define EGL_DEBUG_MSG_INFO_KHR 0x33BC #define EGL_DEBUG_CALLBACK_KHR 0x33B8 typedef EGLint (EGLAPIENTRYP PFNEGLDEBUGMESSAGECONTROLKHRPROC) (EGLDEBUGPROCKHR callback, const EGLAttrib *attrib_list); typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYDEBUGKHRPROC) (EGLint attribute, EGLAttrib *value); typedef EGLint (EGLAPIENTRYP PFNEGLLABELOBJECTKHRPROC) (EGLDisplay display, EGLenum objectType, EGLObjectKHR object, EGLLabelKHR label); #ifdef EGL_EGLEXT_PROTOTYPES EGLAPI EGLint EGLAPIENTRY eglDebugMessageControlKHR (EGLDEBUGPROCKHR callback, const EGLAttrib *attrib_list); EGLAPI EGLBoolean EGLAPIENTRY eglQueryDebugKHR (EGLint attribute, EGLAttrib *value); EGLAPI EGLint EGLAPIENTRY eglLabelObjectKHR (EGLDisplay display, EGLenum objectType, EGLObjectKHR object, EGLLabelKHR label); #endif #endif /* EGL_KHR_debug */ #ifndef EGL_KHR_display_reference #define EGL_KHR_display_reference 1 #define EGL_TRACK_REFERENCES_KHR 0x3352 typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYDISPLAYATTRIBKHRPROC) (EGLDisplay dpy, EGLint name, EGLAttrib *value); #ifdef EGL_EGLEXT_PROTOTYPES EGLAPI EGLBoolean EGLAPIENTRY eglQueryDisplayAttribKHR (EGLDisplay dpy, EGLint name, EGLAttrib *value); #endif #endif /* EGL_KHR_display_reference */ #ifndef EGL_KHR_fence_sync #define EGL_KHR_fence_sync 1 typedef khronos_utime_nanoseconds_t EGLTimeKHR; #ifdef KHRONOS_SUPPORT_INT64 #define EGL_SYNC_PRIOR_COMMANDS_COMPLETE_KHR 0x30F0 #define EGL_SYNC_CONDITION_KHR 0x30F8 #define EGL_SYNC_FENCE_KHR 0x30F9 typedef EGLSyncKHR (EGLAPIENTRYP PFNEGLCREATESYNCKHRPROC) (EGLDisplay dpy, EGLenum type, const EGLint *attrib_list); typedef EGLBoolean (EGLAPIENTRYP PFNEGLDESTROYSYNCKHRPROC) (EGLDisplay dpy, EGLSyncKHR sync); typedef EGLint (EGLAPIENTRYP PFNEGLCLIENTWAITSYNCKHRPROC) (EGLDisplay dpy, EGLSyncKHR sync, EGLint flags, EGLTimeKHR timeout); typedef EGLBoolean (EGLAPIENTRYP PFNEGLGETSYNCATTRIBKHRPROC) (EGLDisplay dpy, EGLSyncKHR sync, EGLint attribute, EGLint *value); #ifdef EGL_EGLEXT_PROTOTYPES EGLAPI EGLSyncKHR EGLAPIENTRY eglCreateSyncKHR (EGLDisplay dpy, EGLenum type, const EGLint *attrib_list); EGLAPI EGLBoolean EGLAPIENTRY eglDestroySyncKHR (EGLDisplay dpy, EGLSyncKHR sync); EGLAPI EGLint EGLAPIENTRY eglClientWaitSyncKHR (EGLDisplay dpy, EGLSyncKHR sync, EGLint flags, EGLTimeKHR timeout); EGLAPI EGLBoolean EGLAPIENTRY eglGetSyncAttribKHR (EGLDisplay dpy, EGLSyncKHR sync, EGLint attribute, EGLint *value); #endif #endif /* KHRONOS_SUPPORT_INT64 */ #endif /* EGL_KHR_fence_sync */ #ifndef EGL_KHR_get_all_proc_addresses #define EGL_KHR_get_all_proc_addresses 1 #endif /* EGL_KHR_get_all_proc_addresses */ #ifndef EGL_KHR_gl_colorspace #define EGL_KHR_gl_colorspace 1 #define EGL_GL_COLORSPACE_KHR 0x309D #define EGL_GL_COLORSPACE_SRGB_KHR 0x3089 #define EGL_GL_COLORSPACE_LINEAR_KHR 0x308A #endif /* EGL_KHR_gl_colorspace */ #ifndef EGL_KHR_gl_renderbuffer_image #define EGL_KHR_gl_renderbuffer_image 1 #define EGL_GL_RENDERBUFFER_KHR 0x30B9 #endif /* EGL_KHR_gl_renderbuffer_image */ #ifndef EGL_KHR_gl_texture_2D_image #define EGL_KHR_gl_texture_2D_image 1 #define EGL_GL_TEXTURE_2D_KHR 0x30B1 #define EGL_GL_TEXTURE_LEVEL_KHR 0x30BC #endif /* EGL_KHR_gl_texture_2D_image */ #ifndef EGL_KHR_gl_texture_3D_image #define EGL_KHR_gl_texture_3D_image 1 #define EGL_GL_TEXTURE_3D_KHR 0x30B2 #define EGL_GL_TEXTURE_ZOFFSET_KHR 0x30BD #endif /* EGL_KHR_gl_texture_3D_image */ #ifndef EGL_KHR_gl_texture_cubemap_image #define EGL_KHR_gl_texture_cubemap_image 1 #define EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_X_KHR 0x30B3 #define EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_X_KHR 0x30B4 #define EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_Y_KHR 0x30B5 #define EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_KHR 0x30B6 #define EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_Z_KHR 0x30B7 #define EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_KHR 0x30B8 #endif /* EGL_KHR_gl_texture_cubemap_image */ #ifndef EGL_KHR_image #define EGL_KHR_image 1 typedef void *EGLImageKHR; #define EGL_NATIVE_PIXMAP_KHR 0x30B0 #define EGL_NO_IMAGE_KHR EGL_CAST(EGLImageKHR,0) typedef EGLImageKHR (EGLAPIENTRYP PFNEGLCREATEIMAGEKHRPROC) (EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer, const EGLint *attrib_list); typedef EGLBoolean (EGLAPIENTRYP PFNEGLDESTROYIMAGEKHRPROC) (EGLDisplay dpy, EGLImageKHR image); #ifdef EGL_EGLEXT_PROTOTYPES EGLAPI EGLImageKHR EGLAPIENTRY eglCreateImageKHR (EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer, const EGLint *attrib_list); EGLAPI EGLBoolean EGLAPIENTRY eglDestroyImageKHR (EGLDisplay dpy, EGLImageKHR image); #endif #endif /* EGL_KHR_image */ #ifndef EGL_KHR_image_base #define EGL_KHR_image_base 1 #define EGL_IMAGE_PRESERVED_KHR 0x30D2 #endif /* EGL_KHR_image_base */ #ifndef EGL_KHR_image_pixmap #define EGL_KHR_image_pixmap 1 #endif /* EGL_KHR_image_pixmap */ #ifndef EGL_KHR_lock_surface #define EGL_KHR_lock_surface 1 #define EGL_READ_SURFACE_BIT_KHR 0x0001 #define EGL_WRITE_SURFACE_BIT_KHR 0x0002 #define EGL_LOCK_SURFACE_BIT_KHR 0x0080 #define EGL_OPTIMAL_FORMAT_BIT_KHR 0x0100 #define EGL_MATCH_FORMAT_KHR 0x3043 #define EGL_FORMAT_RGB_565_EXACT_KHR 0x30C0 #define EGL_FORMAT_RGB_565_KHR 0x30C1 #define EGL_FORMAT_RGBA_8888_EXACT_KHR 0x30C2 #define EGL_FORMAT_RGBA_8888_KHR 0x30C3 #define EGL_MAP_PRESERVE_PIXELS_KHR 0x30C4 #define EGL_LOCK_USAGE_HINT_KHR 0x30C5 #define EGL_BITMAP_POINTER_KHR 0x30C6 #define EGL_BITMAP_PITCH_KHR 0x30C7 #define EGL_BITMAP_ORIGIN_KHR 0x30C8 #define EGL_BITMAP_PIXEL_RED_OFFSET_KHR 0x30C9 #define EGL_BITMAP_PIXEL_GREEN_OFFSET_KHR 0x30CA #define EGL_BITMAP_PIXEL_BLUE_OFFSET_KHR 0x30CB #define EGL_BITMAP_PIXEL_ALPHA_OFFSET_KHR 0x30CC #define EGL_BITMAP_PIXEL_LUMINANCE_OFFSET_KHR 0x30CD #define EGL_LOWER_LEFT_KHR 0x30CE #define EGL_UPPER_LEFT_KHR 0x30CF typedef EGLBoolean (EGLAPIENTRYP PFNEGLLOCKSURFACEKHRPROC) (EGLDisplay dpy, EGLSurface surface, const EGLint *attrib_list); typedef EGLBoolean (EGLAPIENTRYP PFNEGLUNLOCKSURFACEKHRPROC) (EGLDisplay dpy, EGLSurface surface); #ifdef EGL_EGLEXT_PROTOTYPES EGLAPI EGLBoolean EGLAPIENTRY eglLockSurfaceKHR (EGLDisplay dpy, EGLSurface surface, const EGLint *attrib_list); EGLAPI EGLBoolean EGLAPIENTRY eglUnlockSurfaceKHR (EGLDisplay dpy, EGLSurface surface); #endif #endif /* EGL_KHR_lock_surface */ #ifndef EGL_KHR_lock_surface2 #define EGL_KHR_lock_surface2 1 #define EGL_BITMAP_PIXEL_SIZE_KHR 0x3110 #endif /* EGL_KHR_lock_surface2 */ #ifndef EGL_KHR_lock_surface3 #define EGL_KHR_lock_surface3 1 typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYSURFACE64KHRPROC) (EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLAttribKHR *value); #ifdef EGL_EGLEXT_PROTOTYPES EGLAPI EGLBoolean EGLAPIENTRY eglQuerySurface64KHR (EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLAttribKHR *value); #endif #endif /* EGL_KHR_lock_surface3 */ #ifndef EGL_KHR_mutable_render_buffer #define EGL_KHR_mutable_render_buffer 1 #define EGL_MUTABLE_RENDER_BUFFER_BIT_KHR 0x1000 #endif /* EGL_KHR_mutable_render_buffer */ #ifndef EGL_KHR_no_config_context #define EGL_KHR_no_config_context 1 #define EGL_NO_CONFIG_KHR EGL_CAST(EGLConfig,0) #endif /* EGL_KHR_no_config_context */ #ifndef EGL_KHR_partial_update #define EGL_KHR_partial_update 1 #define EGL_BUFFER_AGE_KHR 0x313D typedef EGLBoolean (EGLAPIENTRYP PFNEGLSETDAMAGEREGIONKHRPROC) (EGLDisplay dpy, EGLSurface surface, EGLint *rects, EGLint n_rects); #ifdef EGL_EGLEXT_PROTOTYPES EGLAPI EGLBoolean EGLAPIENTRY eglSetDamageRegionKHR (EGLDisplay dpy, EGLSurface surface, EGLint *rects, EGLint n_rects); #endif #endif /* EGL_KHR_partial_update */ #ifndef EGL_KHR_platform_android #define EGL_KHR_platform_android 1 #define EGL_PLATFORM_ANDROID_KHR 0x3141 #endif /* EGL_KHR_platform_android */ #ifndef EGL_KHR_platform_gbm #define EGL_KHR_platform_gbm 1 #define EGL_PLATFORM_GBM_KHR 0x31D7 #endif /* EGL_KHR_platform_gbm */ #ifndef EGL_KHR_platform_wayland #define EGL_KHR_platform_wayland 1 #define EGL_PLATFORM_WAYLAND_KHR 0x31D8 #endif /* EGL_KHR_platform_wayland */ #ifndef EGL_KHR_platform_x11 #define EGL_KHR_platform_x11 1 #define EGL_PLATFORM_X11_KHR 0x31D5 #define EGL_PLATFORM_X11_SCREEN_KHR 0x31D6 #endif /* EGL_KHR_platform_x11 */ #ifndef EGL_KHR_reusable_sync #define EGL_KHR_reusable_sync 1 #ifdef KHRONOS_SUPPORT_INT64 #define EGL_SYNC_STATUS_KHR 0x30F1 #define EGL_SIGNALED_KHR 0x30F2 #define EGL_UNSIGNALED_KHR 0x30F3 #define EGL_TIMEOUT_EXPIRED_KHR 0x30F5 #define EGL_CONDITION_SATISFIED_KHR 0x30F6 #define EGL_SYNC_TYPE_KHR 0x30F7 #define EGL_SYNC_REUSABLE_KHR 0x30FA #define EGL_SYNC_FLUSH_COMMANDS_BIT_KHR 0x0001 #define EGL_FOREVER_KHR 0xFFFFFFFFFFFFFFFFull #define EGL_NO_SYNC_KHR EGL_CAST(EGLSyncKHR,0) typedef EGLBoolean (EGLAPIENTRYP PFNEGLSIGNALSYNCKHRPROC) (EGLDisplay dpy, EGLSyncKHR sync, EGLenum mode); #ifdef EGL_EGLEXT_PROTOTYPES EGLAPI EGLBoolean EGLAPIENTRY eglSignalSyncKHR (EGLDisplay dpy, EGLSyncKHR sync, EGLenum mode); #endif #endif /* KHRONOS_SUPPORT_INT64 */ #endif /* EGL_KHR_reusable_sync */ #ifndef EGL_KHR_stream #define EGL_KHR_stream 1 typedef void *EGLStreamKHR; typedef khronos_uint64_t EGLuint64KHR; #ifdef KHRONOS_SUPPORT_INT64 #define EGL_NO_STREAM_KHR EGL_CAST(EGLStreamKHR,0) #define EGL_CONSUMER_LATENCY_USEC_KHR 0x3210 #define EGL_PRODUCER_FRAME_KHR 0x3212 #define EGL_CONSUMER_FRAME_KHR 0x3213 #define EGL_STREAM_STATE_KHR 0x3214 #define EGL_STREAM_STATE_CREATED_KHR 0x3215 #define EGL_STREAM_STATE_CONNECTING_KHR 0x3216 #define EGL_STREAM_STATE_EMPTY_KHR 0x3217 #define EGL_STREAM_STATE_NEW_FRAME_AVAILABLE_KHR 0x3218 #define EGL_STREAM_STATE_OLD_FRAME_AVAILABLE_KHR 0x3219 #define EGL_STREAM_STATE_DISCONNECTED_KHR 0x321A #define EGL_BAD_STREAM_KHR 0x321B #define EGL_BAD_STATE_KHR 0x321C typedef EGLStreamKHR (EGLAPIENTRYP PFNEGLCREATESTREAMKHRPROC) (EGLDisplay dpy, const EGLint *attrib_list); typedef EGLBoolean (EGLAPIENTRYP PFNEGLDESTROYSTREAMKHRPROC) (EGLDisplay dpy, EGLStreamKHR stream); typedef EGLBoolean (EGLAPIENTRYP PFNEGLSTREAMATTRIBKHRPROC) (EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLint value); typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYSTREAMKHRPROC) (EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLint *value); typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYSTREAMU64KHRPROC) (EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLuint64KHR *value); #ifdef EGL_EGLEXT_PROTOTYPES EGLAPI EGLStreamKHR EGLAPIENTRY eglCreateStreamKHR (EGLDisplay dpy, const EGLint *attrib_list); EGLAPI EGLBoolean EGLAPIENTRY eglDestroyStreamKHR (EGLDisplay dpy, EGLStreamKHR stream); EGLAPI EGLBoolean EGLAPIENTRY eglStreamAttribKHR (EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLint value); EGLAPI EGLBoolean EGLAPIENTRY eglQueryStreamKHR (EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLint *value); EGLAPI EGLBoolean EGLAPIENTRY eglQueryStreamu64KHR (EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLuint64KHR *value); #endif #endif /* KHRONOS_SUPPORT_INT64 */ #endif /* EGL_KHR_stream */ #ifndef EGL_KHR_stream_attrib #define EGL_KHR_stream_attrib 1 #ifdef KHRONOS_SUPPORT_INT64 typedef EGLStreamKHR (EGLAPIENTRYP PFNEGLCREATESTREAMATTRIBKHRPROC) (EGLDisplay dpy, const EGLAttrib *attrib_list); typedef EGLBoolean (EGLAPIENTRYP PFNEGLSETSTREAMATTRIBKHRPROC) (EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLAttrib value); typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYSTREAMATTRIBKHRPROC) (EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLAttrib *value); typedef EGLBoolean (EGLAPIENTRYP PFNEGLSTREAMCONSUMERACQUIREATTRIBKHRPROC) (EGLDisplay dpy, EGLStreamKHR stream, const EGLAttrib *attrib_list); typedef EGLBoolean (EGLAPIENTRYP PFNEGLSTREAMCONSUMERRELEASEATTRIBKHRPROC) (EGLDisplay dpy, EGLStreamKHR stream, const EGLAttrib *attrib_list); #ifdef EGL_EGLEXT_PROTOTYPES EGLAPI EGLStreamKHR EGLAPIENTRY eglCreateStreamAttribKHR (EGLDisplay dpy, const EGLAttrib *attrib_list); EGLAPI EGLBoolean EGLAPIENTRY eglSetStreamAttribKHR (EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLAttrib value); EGLAPI EGLBoolean EGLAPIENTRY eglQueryStreamAttribKHR (EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLAttrib *value); EGLAPI EGLBoolean EGLAPIENTRY eglStreamConsumerAcquireAttribKHR (EGLDisplay dpy, EGLStreamKHR stream, const EGLAttrib *attrib_list); EGLAPI EGLBoolean EGLAPIENTRY eglStreamConsumerReleaseAttribKHR (EGLDisplay dpy, EGLStreamKHR stream, const EGLAttrib *attrib_list); #endif #endif /* KHRONOS_SUPPORT_INT64 */ #endif /* EGL_KHR_stream_attrib */ #ifndef EGL_KHR_stream_consumer_gltexture #define EGL_KHR_stream_consumer_gltexture 1 #ifdef EGL_KHR_stream #define EGL_CONSUMER_ACQUIRE_TIMEOUT_USEC_KHR 0x321E typedef EGLBoolean (EGLAPIENTRYP PFNEGLSTREAMCONSUMERGLTEXTUREEXTERNALKHRPROC) (EGLDisplay dpy, EGLStreamKHR stream); typedef EGLBoolean (EGLAPIENTRYP PFNEGLSTREAMCONSUMERACQUIREKHRPROC) (EGLDisplay dpy, EGLStreamKHR stream); typedef EGLBoolean (EGLAPIENTRYP PFNEGLSTREAMCONSUMERRELEASEKHRPROC) (EGLDisplay dpy, EGLStreamKHR stream); #ifdef EGL_EGLEXT_PROTOTYPES EGLAPI EGLBoolean EGLAPIENTRY eglStreamConsumerGLTextureExternalKHR (EGLDisplay dpy, EGLStreamKHR stream); EGLAPI EGLBoolean EGLAPIENTRY eglStreamConsumerAcquireKHR (EGLDisplay dpy, EGLStreamKHR stream); EGLAPI EGLBoolean EGLAPIENTRY eglStreamConsumerReleaseKHR (EGLDisplay dpy, EGLStreamKHR stream); #endif #endif /* EGL_KHR_stream */ #endif /* EGL_KHR_stream_consumer_gltexture */ #ifndef EGL_KHR_stream_cross_process_fd #define EGL_KHR_stream_cross_process_fd 1 typedef int EGLNativeFileDescriptorKHR; #ifdef EGL_KHR_stream #define EGL_NO_FILE_DESCRIPTOR_KHR EGL_CAST(EGLNativeFileDescriptorKHR,-1) typedef EGLNativeFileDescriptorKHR (EGLAPIENTRYP PFNEGLGETSTREAMFILEDESCRIPTORKHRPROC) (EGLDisplay dpy, EGLStreamKHR stream); typedef EGLStreamKHR (EGLAPIENTRYP PFNEGLCREATESTREAMFROMFILEDESCRIPTORKHRPROC) (EGLDisplay dpy, EGLNativeFileDescriptorKHR file_descriptor); #ifdef EGL_EGLEXT_PROTOTYPES EGLAPI EGLNativeFileDescriptorKHR EGLAPIENTRY eglGetStreamFileDescriptorKHR (EGLDisplay dpy, EGLStreamKHR stream); EGLAPI EGLStreamKHR EGLAPIENTRY eglCreateStreamFromFileDescriptorKHR (EGLDisplay dpy, EGLNativeFileDescriptorKHR file_descriptor); #endif #endif /* EGL_KHR_stream */ #endif /* EGL_KHR_stream_cross_process_fd */ #ifndef EGL_KHR_stream_fifo #define EGL_KHR_stream_fifo 1 #ifdef EGL_KHR_stream #define EGL_STREAM_FIFO_LENGTH_KHR 0x31FC #define EGL_STREAM_TIME_NOW_KHR 0x31FD #define EGL_STREAM_TIME_CONSUMER_KHR 0x31FE #define EGL_STREAM_TIME_PRODUCER_KHR 0x31FF typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYSTREAMTIMEKHRPROC) (EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLTimeKHR *value); #ifdef EGL_EGLEXT_PROTOTYPES EGLAPI EGLBoolean EGLAPIENTRY eglQueryStreamTimeKHR (EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLTimeKHR *value); #endif #endif /* EGL_KHR_stream */ #endif /* EGL_KHR_stream_fifo */ #ifndef EGL_KHR_stream_producer_aldatalocator #define EGL_KHR_stream_producer_aldatalocator 1 #ifdef EGL_KHR_stream #endif /* EGL_KHR_stream */ #endif /* EGL_KHR_stream_producer_aldatalocator */ #ifndef EGL_KHR_stream_producer_eglsurface #define EGL_KHR_stream_producer_eglsurface 1 #ifdef EGL_KHR_stream #define EGL_STREAM_BIT_KHR 0x0800 typedef EGLSurface (EGLAPIENTRYP PFNEGLCREATESTREAMPRODUCERSURFACEKHRPROC) (EGLDisplay dpy, EGLConfig config, EGLStreamKHR stream, const EGLint *attrib_list); #ifdef EGL_EGLEXT_PROTOTYPES EGLAPI EGLSurface EGLAPIENTRY eglCreateStreamProducerSurfaceKHR (EGLDisplay dpy, EGLConfig config, EGLStreamKHR stream, const EGLint *attrib_list); #endif #endif /* EGL_KHR_stream */ #endif /* EGL_KHR_stream_producer_eglsurface */ #ifndef EGL_KHR_surfaceless_context #define EGL_KHR_surfaceless_context 1 #endif /* EGL_KHR_surfaceless_context */ #ifndef EGL_KHR_swap_buffers_with_damage #define EGL_KHR_swap_buffers_with_damage 1 typedef EGLBoolean (EGLAPIENTRYP PFNEGLSWAPBUFFERSWITHDAMAGEKHRPROC) (EGLDisplay dpy, EGLSurface surface, const EGLint *rects, EGLint n_rects); #ifdef EGL_EGLEXT_PROTOTYPES EGLAPI EGLBoolean EGLAPIENTRY eglSwapBuffersWithDamageKHR (EGLDisplay dpy, EGLSurface surface, const EGLint *rects, EGLint n_rects); #endif #endif /* EGL_KHR_swap_buffers_with_damage */ #ifndef EGL_KHR_vg_parent_image #define EGL_KHR_vg_parent_image 1 #define EGL_VG_PARENT_IMAGE_KHR 0x30BA #endif /* EGL_KHR_vg_parent_image */ #ifndef EGL_KHR_wait_sync #define EGL_KHR_wait_sync 1 typedef EGLint (EGLAPIENTRYP PFNEGLWAITSYNCKHRPROC) (EGLDisplay dpy, EGLSyncKHR sync, EGLint flags); #ifdef EGL_EGLEXT_PROTOTYPES EGLAPI EGLint EGLAPIENTRY eglWaitSyncKHR (EGLDisplay dpy, EGLSyncKHR sync, EGLint flags); #endif #endif /* EGL_KHR_wait_sync */ #ifndef EGL_ANDROID_GLES_layers #define EGL_ANDROID_GLES_layers 1 #endif /* EGL_ANDROID_GLES_layers */ #ifndef EGL_ANDROID_blob_cache #define EGL_ANDROID_blob_cache 1 typedef khronos_ssize_t EGLsizeiANDROID; typedef void (*EGLSetBlobFuncANDROID) (const void *key, EGLsizeiANDROID keySize, const void *value, EGLsizeiANDROID valueSize); typedef EGLsizeiANDROID (*EGLGetBlobFuncANDROID) (const void *key, EGLsizeiANDROID keySize, void *value, EGLsizeiANDROID valueSize); typedef void (EGLAPIENTRYP PFNEGLSETBLOBCACHEFUNCSANDROIDPROC) (EGLDisplay dpy, EGLSetBlobFuncANDROID set, EGLGetBlobFuncANDROID get); #ifdef EGL_EGLEXT_PROTOTYPES EGLAPI void EGLAPIENTRY eglSetBlobCacheFuncsANDROID (EGLDisplay dpy, EGLSetBlobFuncANDROID set, EGLGetBlobFuncANDROID get); #endif #endif /* EGL_ANDROID_blob_cache */ #ifndef EGL_ANDROID_create_native_client_buffer #define EGL_ANDROID_create_native_client_buffer 1 #define EGL_NATIVE_BUFFER_USAGE_ANDROID 0x3143 #define EGL_NATIVE_BUFFER_USAGE_PROTECTED_BIT_ANDROID 0x00000001 #define EGL_NATIVE_BUFFER_USAGE_RENDERBUFFER_BIT_ANDROID 0x00000002 #define EGL_NATIVE_BUFFER_USAGE_TEXTURE_BIT_ANDROID 0x00000004 typedef EGLClientBuffer (EGLAPIENTRYP PFNEGLCREATENATIVECLIENTBUFFERANDROIDPROC) (const EGLint *attrib_list); #ifdef EGL_EGLEXT_PROTOTYPES EGLAPI EGLClientBuffer EGLAPIENTRY eglCreateNativeClientBufferANDROID (const EGLint *attrib_list); #endif #endif /* EGL_ANDROID_create_native_client_buffer */ #ifndef EGL_ANDROID_framebuffer_target #define EGL_ANDROID_framebuffer_target 1 #define EGL_FRAMEBUFFER_TARGET_ANDROID 0x3147 #endif /* EGL_ANDROID_framebuffer_target */ #ifndef EGL_ANDROID_front_buffer_auto_refresh #define EGL_ANDROID_front_buffer_auto_refresh 1 #define EGL_FRONT_BUFFER_AUTO_REFRESH_ANDROID 0x314C #endif /* EGL_ANDROID_front_buffer_auto_refresh */ #ifndef EGL_ANDROID_get_frame_timestamps #define EGL_ANDROID_get_frame_timestamps 1 typedef khronos_stime_nanoseconds_t EGLnsecsANDROID; #define EGL_TIMESTAMP_PENDING_ANDROID EGL_CAST(EGLnsecsANDROID,-2) #define EGL_TIMESTAMP_INVALID_ANDROID EGL_CAST(EGLnsecsANDROID,-1) #define EGL_TIMESTAMPS_ANDROID 0x3430 #define EGL_COMPOSITE_DEADLINE_ANDROID 0x3431 #define EGL_COMPOSITE_INTERVAL_ANDROID 0x3432 #define EGL_COMPOSITE_TO_PRESENT_LATENCY_ANDROID 0x3433 #define EGL_REQUESTED_PRESENT_TIME_ANDROID 0x3434 #define EGL_RENDERING_COMPLETE_TIME_ANDROID 0x3435 #define EGL_COMPOSITION_LATCH_TIME_ANDROID 0x3436 #define EGL_FIRST_COMPOSITION_START_TIME_ANDROID 0x3437 #define EGL_LAST_COMPOSITION_START_TIME_ANDROID 0x3438 #define EGL_FIRST_COMPOSITION_GPU_FINISHED_TIME_ANDROID 0x3439 #define EGL_DISPLAY_PRESENT_TIME_ANDROID 0x343A #define EGL_DEQUEUE_READY_TIME_ANDROID 0x343B #define EGL_READS_DONE_TIME_ANDROID 0x343C typedef EGLBoolean (EGLAPIENTRYP PFNEGLGETCOMPOSITORTIMINGSUPPORTEDANDROIDPROC) (EGLDisplay dpy, EGLSurface surface, EGLint name); typedef EGLBoolean (EGLAPIENTRYP PFNEGLGETCOMPOSITORTIMINGANDROIDPROC) (EGLDisplay dpy, EGLSurface surface, EGLint numTimestamps, const EGLint *names, EGLnsecsANDROID *values); typedef EGLBoolean (EGLAPIENTRYP PFNEGLGETNEXTFRAMEIDANDROIDPROC) (EGLDisplay dpy, EGLSurface surface, EGLuint64KHR *frameId); typedef EGLBoolean (EGLAPIENTRYP PFNEGLGETFRAMETIMESTAMPSUPPORTEDANDROIDPROC) (EGLDisplay dpy, EGLSurface surface, EGLint timestamp); typedef EGLBoolean (EGLAPIENTRYP PFNEGLGETFRAMETIMESTAMPSANDROIDPROC) (EGLDisplay dpy, EGLSurface surface, EGLuint64KHR frameId, EGLint numTimestamps, const EGLint *timestamps, EGLnsecsANDROID *values); #ifdef EGL_EGLEXT_PROTOTYPES EGLAPI EGLBoolean EGLAPIENTRY eglGetCompositorTimingSupportedANDROID (EGLDisplay dpy, EGLSurface surface, EGLint name); EGLAPI EGLBoolean EGLAPIENTRY eglGetCompositorTimingANDROID (EGLDisplay dpy, EGLSurface surface, EGLint numTimestamps, const EGLint *names, EGLnsecsANDROID *values); EGLAPI EGLBoolean EGLAPIENTRY eglGetNextFrameIdANDROID (EGLDisplay dpy, EGLSurface surface, EGLuint64KHR *frameId); EGLAPI EGLBoolean EGLAPIENTRY eglGetFrameTimestampSupportedANDROID (EGLDisplay dpy, EGLSurface surface, EGLint timestamp); EGLAPI EGLBoolean EGLAPIENTRY eglGetFrameTimestampsANDROID (EGLDisplay dpy, EGLSurface surface, EGLuint64KHR frameId, EGLint numTimestamps, const EGLint *timestamps, EGLnsecsANDROID *values); #endif #endif /* EGL_ANDROID_get_frame_timestamps */ #ifndef EGL_ANDROID_get_native_client_buffer #define EGL_ANDROID_get_native_client_buffer 1 struct AHardwareBuffer; typedef EGLClientBuffer (EGLAPIENTRYP PFNEGLGETNATIVECLIENTBUFFERANDROIDPROC) (const struct AHardwareBuffer *buffer); #ifdef EGL_EGLEXT_PROTOTYPES EGLAPI EGLClientBuffer EGLAPIENTRY eglGetNativeClientBufferANDROID (const struct AHardwareBuffer *buffer); #endif #endif /* EGL_ANDROID_get_native_client_buffer */ #ifndef EGL_ANDROID_image_native_buffer #define EGL_ANDROID_image_native_buffer 1 #define EGL_NATIVE_BUFFER_ANDROID 0x3140 #endif /* EGL_ANDROID_image_native_buffer */ #ifndef EGL_ANDROID_native_fence_sync #define EGL_ANDROID_native_fence_sync 1 #define EGL_SYNC_NATIVE_FENCE_ANDROID 0x3144 #define EGL_SYNC_NATIVE_FENCE_FD_ANDROID 0x3145 #define EGL_SYNC_NATIVE_FENCE_SIGNALED_ANDROID 0x3146 #define EGL_NO_NATIVE_FENCE_FD_ANDROID -1 typedef EGLint (EGLAPIENTRYP PFNEGLDUPNATIVEFENCEFDANDROIDPROC) (EGLDisplay dpy, EGLSyncKHR sync); #ifdef EGL_EGLEXT_PROTOTYPES EGLAPI EGLint EGLAPIENTRY eglDupNativeFenceFDANDROID (EGLDisplay dpy, EGLSyncKHR sync); #endif #endif /* EGL_ANDROID_native_fence_sync */ #ifndef EGL_ANDROID_presentation_time #define EGL_ANDROID_presentation_time 1 typedef EGLBoolean (EGLAPIENTRYP PFNEGLPRESENTATIONTIMEANDROIDPROC) (EGLDisplay dpy, EGLSurface surface, EGLnsecsANDROID time); #ifdef EGL_EGLEXT_PROTOTYPES EGLAPI EGLBoolean EGLAPIENTRY eglPresentationTimeANDROID (EGLDisplay dpy, EGLSurface surface, EGLnsecsANDROID time); #endif #endif /* EGL_ANDROID_presentation_time */ #ifndef EGL_ANDROID_recordable #define EGL_ANDROID_recordable 1 #define EGL_RECORDABLE_ANDROID 0x3142 #endif /* EGL_ANDROID_recordable */ #ifndef EGL_ANGLE_d3d_share_handle_client_buffer #define EGL_ANGLE_d3d_share_handle_client_buffer 1 #define EGL_D3D_TEXTURE_2D_SHARE_HANDLE_ANGLE 0x3200 #endif /* EGL_ANGLE_d3d_share_handle_client_buffer */ #ifndef EGL_ANGLE_device_d3d #define EGL_ANGLE_device_d3d 1 #define EGL_D3D9_DEVICE_ANGLE 0x33A0 #define EGL_D3D11_DEVICE_ANGLE 0x33A1 #endif /* EGL_ANGLE_device_d3d */ #ifndef EGL_ANGLE_query_surface_pointer #define EGL_ANGLE_query_surface_pointer 1 typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYSURFACEPOINTERANGLEPROC) (EGLDisplay dpy, EGLSurface surface, EGLint attribute, void **value); #ifdef EGL_EGLEXT_PROTOTYPES EGLAPI EGLBoolean EGLAPIENTRY eglQuerySurfacePointerANGLE (EGLDisplay dpy, EGLSurface surface, EGLint attribute, void **value); #endif #endif /* EGL_ANGLE_query_surface_pointer */ #ifndef EGL_ANGLE_surface_d3d_texture_2d_share_handle #define EGL_ANGLE_surface_d3d_texture_2d_share_handle 1 #endif /* EGL_ANGLE_surface_d3d_texture_2d_share_handle */ #ifndef EGL_ANGLE_sync_control_rate #define EGL_ANGLE_sync_control_rate 1 typedef EGLBoolean (EGLAPIENTRYP PFNEGLGETMSCRATEANGLEPROC) (EGLDisplay dpy, EGLSurface surface, EGLint *numerator, EGLint *denominator); #ifdef EGL_EGLEXT_PROTOTYPES EGLAPI EGLBoolean EGLAPIENTRY eglGetMscRateANGLE (EGLDisplay dpy, EGLSurface surface, EGLint *numerator, EGLint *denominator); #endif #endif /* EGL_ANGLE_sync_control_rate */ #ifndef EGL_ANGLE_window_fixed_size #define EGL_ANGLE_window_fixed_size 1 #define EGL_FIXED_SIZE_ANGLE 0x3201 #endif /* EGL_ANGLE_window_fixed_size */ #ifndef EGL_ARM_image_format #define EGL_ARM_image_format 1 #define EGL_COLOR_COMPONENT_TYPE_UNSIGNED_INTEGER_ARM 0x3287 #define EGL_COLOR_COMPONENT_TYPE_INTEGER_ARM 0x3288 #endif /* EGL_ARM_image_format */ #ifndef EGL_ARM_implicit_external_sync #define EGL_ARM_implicit_external_sync 1 #define EGL_SYNC_PRIOR_COMMANDS_IMPLICIT_EXTERNAL_ARM 0x328A #endif /* EGL_ARM_implicit_external_sync */ #ifndef EGL_ARM_pixmap_multisample_discard #define EGL_ARM_pixmap_multisample_discard 1 #define EGL_DISCARD_SAMPLES_ARM 0x3286 #endif /* EGL_ARM_pixmap_multisample_discard */ #ifndef EGL_EXT_bind_to_front #define EGL_EXT_bind_to_front 1 #define EGL_FRONT_BUFFER_EXT 0x3464 #endif /* EGL_EXT_bind_to_front */ #ifndef EGL_EXT_buffer_age #define EGL_EXT_buffer_age 1 #define EGL_BUFFER_AGE_EXT 0x313D #endif /* EGL_EXT_buffer_age */ #ifndef EGL_EXT_client_extensions #define EGL_EXT_client_extensions 1 #endif /* EGL_EXT_client_extensions */ #ifndef EGL_EXT_client_sync #define EGL_EXT_client_sync 1 #define EGL_SYNC_CLIENT_EXT 0x3364 #define EGL_SYNC_CLIENT_SIGNAL_EXT 0x3365 typedef EGLBoolean (EGLAPIENTRYP PFNEGLCLIENTSIGNALSYNCEXTPROC) (EGLDisplay dpy, EGLSync sync, const EGLAttrib *attrib_list); #ifdef EGL_EGLEXT_PROTOTYPES EGLAPI EGLBoolean EGLAPIENTRY eglClientSignalSyncEXT (EGLDisplay dpy, EGLSync sync, const EGLAttrib *attrib_list); #endif #endif /* EGL_EXT_client_sync */ #ifndef EGL_EXT_compositor #define EGL_EXT_compositor 1 #define EGL_PRIMARY_COMPOSITOR_CONTEXT_EXT 0x3460 #define EGL_EXTERNAL_REF_ID_EXT 0x3461 #define EGL_COMPOSITOR_DROP_NEWEST_FRAME_EXT 0x3462 #define EGL_COMPOSITOR_KEEP_NEWEST_FRAME_EXT 0x3463 typedef EGLBoolean (EGLAPIENTRYP PFNEGLCOMPOSITORSETCONTEXTLISTEXTPROC) (const EGLint *external_ref_ids, EGLint num_entries); typedef EGLBoolean (EGLAPIENTRYP PFNEGLCOMPOSITORSETCONTEXTATTRIBUTESEXTPROC) (EGLint external_ref_id, const EGLint *context_attributes, EGLint num_entries); typedef EGLBoolean (EGLAPIENTRYP PFNEGLCOMPOSITORSETWINDOWLISTEXTPROC) (EGLint external_ref_id, const EGLint *external_win_ids, EGLint num_entries); typedef EGLBoolean (EGLAPIENTRYP PFNEGLCOMPOSITORSETWINDOWATTRIBUTESEXTPROC) (EGLint external_win_id, const EGLint *window_attributes, EGLint num_entries); typedef EGLBoolean (EGLAPIENTRYP PFNEGLCOMPOSITORBINDTEXWINDOWEXTPROC) (EGLint external_win_id); typedef EGLBoolean (EGLAPIENTRYP PFNEGLCOMPOSITORSETSIZEEXTPROC) (EGLint external_win_id, EGLint width, EGLint height); typedef EGLBoolean (EGLAPIENTRYP PFNEGLCOMPOSITORSWAPPOLICYEXTPROC) (EGLint external_win_id, EGLint policy); #ifdef EGL_EGLEXT_PROTOTYPES EGLAPI EGLBoolean EGLAPIENTRY eglCompositorSetContextListEXT (const EGLint *external_ref_ids, EGLint num_entries); EGLAPI EGLBoolean EGLAPIENTRY eglCompositorSetContextAttributesEXT (EGLint external_ref_id, const EGLint *context_attributes, EGLint num_entries); EGLAPI EGLBoolean EGLAPIENTRY eglCompositorSetWindowListEXT (EGLint external_ref_id, const EGLint *external_win_ids, EGLint num_entries); EGLAPI EGLBoolean EGLAPIENTRY eglCompositorSetWindowAttributesEXT (EGLint external_win_id, const EGLint *window_attributes, EGLint num_entries); EGLAPI EGLBoolean EGLAPIENTRY eglCompositorBindTexWindowEXT (EGLint external_win_id); EGLAPI EGLBoolean EGLAPIENTRY eglCompositorSetSizeEXT (EGLint external_win_id, EGLint width, EGLint height); EGLAPI EGLBoolean EGLAPIENTRY eglCompositorSwapPolicyEXT (EGLint external_win_id, EGLint policy); #endif #endif /* EGL_EXT_compositor */ #ifndef EGL_EXT_config_select_group #define EGL_EXT_config_select_group 1 #define EGL_CONFIG_SELECT_GROUP_EXT 0x34C0 #endif /* EGL_EXT_config_select_group */ #ifndef EGL_EXT_create_context_robustness #define EGL_EXT_create_context_robustness 1 #define EGL_CONTEXT_OPENGL_ROBUST_ACCESS_EXT 0x30BF #define EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_EXT 0x3138 #define EGL_NO_RESET_NOTIFICATION_EXT 0x31BE #define EGL_LOSE_CONTEXT_ON_RESET_EXT 0x31BF #endif /* EGL_EXT_create_context_robustness */ #ifndef EGL_EXT_device_base #define EGL_EXT_device_base 1 typedef void *EGLDeviceEXT; #define EGL_NO_DEVICE_EXT EGL_CAST(EGLDeviceEXT,0) #define EGL_BAD_DEVICE_EXT 0x322B #define EGL_DEVICE_EXT 0x322C typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYDEVICEATTRIBEXTPROC) (EGLDeviceEXT device, EGLint attribute, EGLAttrib *value); typedef const char *(EGLAPIENTRYP PFNEGLQUERYDEVICESTRINGEXTPROC) (EGLDeviceEXT device, EGLint name); typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYDEVICESEXTPROC) (EGLint max_devices, EGLDeviceEXT *devices, EGLint *num_devices); typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYDISPLAYATTRIBEXTPROC) (EGLDisplay dpy, EGLint attribute, EGLAttrib *value); #ifdef EGL_EGLEXT_PROTOTYPES EGLAPI EGLBoolean EGLAPIENTRY eglQueryDeviceAttribEXT (EGLDeviceEXT device, EGLint attribute, EGLAttrib *value); EGLAPI const char *EGLAPIENTRY eglQueryDeviceStringEXT (EGLDeviceEXT device, EGLint name); EGLAPI EGLBoolean EGLAPIENTRY eglQueryDevicesEXT (EGLint max_devices, EGLDeviceEXT *devices, EGLint *num_devices); EGLAPI EGLBoolean EGLAPIENTRY eglQueryDisplayAttribEXT (EGLDisplay dpy, EGLint attribute, EGLAttrib *value); #endif #endif /* EGL_EXT_device_base */ #ifndef EGL_EXT_device_drm #define EGL_EXT_device_drm 1 #define EGL_DRM_DEVICE_FILE_EXT 0x3233 #define EGL_DRM_MASTER_FD_EXT 0x333C #endif /* EGL_EXT_device_drm */ #ifndef EGL_EXT_device_drm_render_node #define EGL_EXT_device_drm_render_node 1 #define EGL_DRM_RENDER_NODE_FILE_EXT 0x3377 #endif /* EGL_EXT_device_drm_render_node */ #ifndef EGL_EXT_device_enumeration #define EGL_EXT_device_enumeration 1 #endif /* EGL_EXT_device_enumeration */ #ifndef EGL_EXT_device_openwf #define EGL_EXT_device_openwf 1 #define EGL_OPENWF_DEVICE_ID_EXT 0x3237 #define EGL_OPENWF_DEVICE_EXT 0x333D #endif /* EGL_EXT_device_openwf */ #ifndef EGL_EXT_device_persistent_id #define EGL_EXT_device_persistent_id 1 #define EGL_DEVICE_UUID_EXT 0x335C #define EGL_DRIVER_UUID_EXT 0x335D #define EGL_DRIVER_NAME_EXT 0x335E typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYDEVICEBINARYEXTPROC) (EGLDeviceEXT device, EGLint name, EGLint max_size, void *value, EGLint *size); #ifdef EGL_EGLEXT_PROTOTYPES EGLAPI EGLBoolean EGLAPIENTRY eglQueryDeviceBinaryEXT (EGLDeviceEXT device, EGLint name, EGLint max_size, void *value, EGLint *size); #endif #endif /* EGL_EXT_device_persistent_id */ #ifndef EGL_EXT_device_query #define EGL_EXT_device_query 1 #endif /* EGL_EXT_device_query */ #ifndef EGL_EXT_device_query_name #define EGL_EXT_device_query_name 1 #define EGL_RENDERER_EXT 0x335F #endif /* EGL_EXT_device_query_name */ #ifndef EGL_EXT_explicit_device #define EGL_EXT_explicit_device 1 #endif /* EGL_EXT_explicit_device */ #ifndef EGL_EXT_gl_colorspace_bt2020_linear #define EGL_EXT_gl_colorspace_bt2020_linear 1 #define EGL_GL_COLORSPACE_BT2020_LINEAR_EXT 0x333F #endif /* EGL_EXT_gl_colorspace_bt2020_linear */ #ifndef EGL_EXT_gl_colorspace_bt2020_pq #define EGL_EXT_gl_colorspace_bt2020_pq 1 #define EGL_GL_COLORSPACE_BT2020_PQ_EXT 0x3340 #endif /* EGL_EXT_gl_colorspace_bt2020_pq */ #ifndef EGL_EXT_gl_colorspace_display_p3 #define EGL_EXT_gl_colorspace_display_p3 1 #define EGL_GL_COLORSPACE_DISPLAY_P3_EXT 0x3363 #endif /* EGL_EXT_gl_colorspace_display_p3 */ #ifndef EGL_EXT_gl_colorspace_display_p3_linear #define EGL_EXT_gl_colorspace_display_p3_linear 1 #define EGL_GL_COLORSPACE_DISPLAY_P3_LINEAR_EXT 0x3362 #endif /* EGL_EXT_gl_colorspace_display_p3_linear */ #ifndef EGL_EXT_gl_colorspace_display_p3_passthrough #define EGL_EXT_gl_colorspace_display_p3_passthrough 1 #define EGL_GL_COLORSPACE_DISPLAY_P3_PASSTHROUGH_EXT 0x3490 #endif /* EGL_EXT_gl_colorspace_display_p3_passthrough */ #ifndef EGL_EXT_gl_colorspace_scrgb #define EGL_EXT_gl_colorspace_scrgb 1 #define EGL_GL_COLORSPACE_SCRGB_EXT 0x3351 #endif /* EGL_EXT_gl_colorspace_scrgb */ #ifndef EGL_EXT_gl_colorspace_scrgb_linear #define EGL_EXT_gl_colorspace_scrgb_linear 1 #define EGL_GL_COLORSPACE_SCRGB_LINEAR_EXT 0x3350 #endif /* EGL_EXT_gl_colorspace_scrgb_linear */ #ifndef EGL_EXT_image_dma_buf_import #define EGL_EXT_image_dma_buf_import 1 #define EGL_LINUX_DMA_BUF_EXT 0x3270 #define EGL_LINUX_DRM_FOURCC_EXT 0x3271 #define EGL_DMA_BUF_PLANE0_FD_EXT 0x3272 #define EGL_DMA_BUF_PLANE0_OFFSET_EXT 0x3273 #define EGL_DMA_BUF_PLANE0_PITCH_EXT 0x3274 #define EGL_DMA_BUF_PLANE1_FD_EXT 0x3275 #define EGL_DMA_BUF_PLANE1_OFFSET_EXT 0x3276 #define EGL_DMA_BUF_PLANE1_PITCH_EXT 0x3277 #define EGL_DMA_BUF_PLANE2_FD_EXT 0x3278 #define EGL_DMA_BUF_PLANE2_OFFSET_EXT 0x3279 #define EGL_DMA_BUF_PLANE2_PITCH_EXT 0x327A #define EGL_YUV_COLOR_SPACE_HINT_EXT 0x327B #define EGL_SAMPLE_RANGE_HINT_EXT 0x327C #define EGL_YUV_CHROMA_HORIZONTAL_SITING_HINT_EXT 0x327D #define EGL_YUV_CHROMA_VERTICAL_SITING_HINT_EXT 0x327E #define EGL_ITU_REC601_EXT 0x327F #define EGL_ITU_REC709_EXT 0x3280 #define EGL_ITU_REC2020_EXT 0x3281 #define EGL_YUV_FULL_RANGE_EXT 0x3282 #define EGL_YUV_NARROW_RANGE_EXT 0x3283 #define EGL_YUV_CHROMA_SITING_0_EXT 0x3284 #define EGL_YUV_CHROMA_SITING_0_5_EXT 0x3285 #endif /* EGL_EXT_image_dma_buf_import */ #ifndef EGL_EXT_image_dma_buf_import_modifiers #define EGL_EXT_image_dma_buf_import_modifiers 1 #define EGL_DMA_BUF_PLANE3_FD_EXT 0x3440 #define EGL_DMA_BUF_PLANE3_OFFSET_EXT 0x3441 #define EGL_DMA_BUF_PLANE3_PITCH_EXT 0x3442 #define EGL_DMA_BUF_PLANE0_MODIFIER_LO_EXT 0x3443 #define EGL_DMA_BUF_PLANE0_MODIFIER_HI_EXT 0x3444 #define EGL_DMA_BUF_PLANE1_MODIFIER_LO_EXT 0x3445 #define EGL_DMA_BUF_PLANE1_MODIFIER_HI_EXT 0x3446 #define EGL_DMA_BUF_PLANE2_MODIFIER_LO_EXT 0x3447 #define EGL_DMA_BUF_PLANE2_MODIFIER_HI_EXT 0x3448 #define EGL_DMA_BUF_PLANE3_MODIFIER_LO_EXT 0x3449 #define EGL_DMA_BUF_PLANE3_MODIFIER_HI_EXT 0x344A typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYDMABUFFORMATSEXTPROC) (EGLDisplay dpy, EGLint max_formats, EGLint *formats, EGLint *num_formats); typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYDMABUFMODIFIERSEXTPROC) (EGLDisplay dpy, EGLint format, EGLint max_modifiers, EGLuint64KHR *modifiers, EGLBoolean *external_only, EGLint *num_modifiers); #ifdef EGL_EGLEXT_PROTOTYPES EGLAPI EGLBoolean EGLAPIENTRY eglQueryDmaBufFormatsEXT (EGLDisplay dpy, EGLint max_formats, EGLint *formats, EGLint *num_formats); EGLAPI EGLBoolean EGLAPIENTRY eglQueryDmaBufModifiersEXT (EGLDisplay dpy, EGLint format, EGLint max_modifiers, EGLuint64KHR *modifiers, EGLBoolean *external_only, EGLint *num_modifiers); #endif #endif /* EGL_EXT_image_dma_buf_import_modifiers */ #ifndef EGL_EXT_image_gl_colorspace #define EGL_EXT_image_gl_colorspace 1 #define EGL_GL_COLORSPACE_DEFAULT_EXT 0x314D #endif /* EGL_EXT_image_gl_colorspace */ #ifndef EGL_EXT_image_implicit_sync_control #define EGL_EXT_image_implicit_sync_control 1 #define EGL_IMPORT_SYNC_TYPE_EXT 0x3470 #define EGL_IMPORT_IMPLICIT_SYNC_EXT 0x3471 #define EGL_IMPORT_EXPLICIT_SYNC_EXT 0x3472 #endif /* EGL_EXT_image_implicit_sync_control */ #ifndef EGL_EXT_multiview_window #define EGL_EXT_multiview_window 1 #define EGL_MULTIVIEW_VIEW_COUNT_EXT 0x3134 #endif /* EGL_EXT_multiview_window */ #ifndef EGL_EXT_output_base #define EGL_EXT_output_base 1 typedef void *EGLOutputLayerEXT; typedef void *EGLOutputPortEXT; #define EGL_NO_OUTPUT_LAYER_EXT EGL_CAST(EGLOutputLayerEXT,0) #define EGL_NO_OUTPUT_PORT_EXT EGL_CAST(EGLOutputPortEXT,0) #define EGL_BAD_OUTPUT_LAYER_EXT 0x322D #define EGL_BAD_OUTPUT_PORT_EXT 0x322E #define EGL_SWAP_INTERVAL_EXT 0x322F typedef EGLBoolean (EGLAPIENTRYP PFNEGLGETOUTPUTLAYERSEXTPROC) (EGLDisplay dpy, const EGLAttrib *attrib_list, EGLOutputLayerEXT *layers, EGLint max_layers, EGLint *num_layers); typedef EGLBoolean (EGLAPIENTRYP PFNEGLGETOUTPUTPORTSEXTPROC) (EGLDisplay dpy, const EGLAttrib *attrib_list, EGLOutputPortEXT *ports, EGLint max_ports, EGLint *num_ports); typedef EGLBoolean (EGLAPIENTRYP PFNEGLOUTPUTLAYERATTRIBEXTPROC) (EGLDisplay dpy, EGLOutputLayerEXT layer, EGLint attribute, EGLAttrib value); typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYOUTPUTLAYERATTRIBEXTPROC) (EGLDisplay dpy, EGLOutputLayerEXT layer, EGLint attribute, EGLAttrib *value); typedef const char *(EGLAPIENTRYP PFNEGLQUERYOUTPUTLAYERSTRINGEXTPROC) (EGLDisplay dpy, EGLOutputLayerEXT layer, EGLint name); typedef EGLBoolean (EGLAPIENTRYP PFNEGLOUTPUTPORTATTRIBEXTPROC) (EGLDisplay dpy, EGLOutputPortEXT port, EGLint attribute, EGLAttrib value); typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYOUTPUTPORTATTRIBEXTPROC) (EGLDisplay dpy, EGLOutputPortEXT port, EGLint attribute, EGLAttrib *value); typedef const char *(EGLAPIENTRYP PFNEGLQUERYOUTPUTPORTSTRINGEXTPROC) (EGLDisplay dpy, EGLOutputPortEXT port, EGLint name); #ifdef EGL_EGLEXT_PROTOTYPES EGLAPI EGLBoolean EGLAPIENTRY eglGetOutputLayersEXT (EGLDisplay dpy, const EGLAttrib *attrib_list, EGLOutputLayerEXT *layers, EGLint max_layers, EGLint *num_layers); EGLAPI EGLBoolean EGLAPIENTRY eglGetOutputPortsEXT (EGLDisplay dpy, const EGLAttrib *attrib_list, EGLOutputPortEXT *ports, EGLint max_ports, EGLint *num_ports); EGLAPI EGLBoolean EGLAPIENTRY eglOutputLayerAttribEXT (EGLDisplay dpy, EGLOutputLayerEXT layer, EGLint attribute, EGLAttrib value); EGLAPI EGLBoolean EGLAPIENTRY eglQueryOutputLayerAttribEXT (EGLDisplay dpy, EGLOutputLayerEXT layer, EGLint attribute, EGLAttrib *value); EGLAPI const char *EGLAPIENTRY eglQueryOutputLayerStringEXT (EGLDisplay dpy, EGLOutputLayerEXT layer, EGLint name); EGLAPI EGLBoolean EGLAPIENTRY eglOutputPortAttribEXT (EGLDisplay dpy, EGLOutputPortEXT port, EGLint attribute, EGLAttrib value); EGLAPI EGLBoolean EGLAPIENTRY eglQueryOutputPortAttribEXT (EGLDisplay dpy, EGLOutputPortEXT port, EGLint attribute, EGLAttrib *value); EGLAPI const char *EGLAPIENTRY eglQueryOutputPortStringEXT (EGLDisplay dpy, EGLOutputPortEXT port, EGLint name); #endif #endif /* EGL_EXT_output_base */ #ifndef EGL_EXT_output_drm #define EGL_EXT_output_drm 1 #define EGL_DRM_CRTC_EXT 0x3234 #define EGL_DRM_PLANE_EXT 0x3235 #define EGL_DRM_CONNECTOR_EXT 0x3236 #endif /* EGL_EXT_output_drm */ #ifndef EGL_EXT_output_openwf #define EGL_EXT_output_openwf 1 #define EGL_OPENWF_PIPELINE_ID_EXT 0x3238 #define EGL_OPENWF_PORT_ID_EXT 0x3239 #endif /* EGL_EXT_output_openwf */ #ifndef EGL_EXT_pixel_format_float #define EGL_EXT_pixel_format_float 1 #define EGL_COLOR_COMPONENT_TYPE_EXT 0x3339 #define EGL_COLOR_COMPONENT_TYPE_FIXED_EXT 0x333A #define EGL_COLOR_COMPONENT_TYPE_FLOAT_EXT 0x333B #endif /* EGL_EXT_pixel_format_float */ #ifndef EGL_EXT_platform_base #define EGL_EXT_platform_base 1 typedef EGLDisplay (EGLAPIENTRYP PFNEGLGETPLATFORMDISPLAYEXTPROC) (EGLenum platform, void *native_display, const EGLint *attrib_list); typedef EGLSurface (EGLAPIENTRYP PFNEGLCREATEPLATFORMWINDOWSURFACEEXTPROC) (EGLDisplay dpy, EGLConfig config, void *native_window, const EGLint *attrib_list); typedef EGLSurface (EGLAPIENTRYP PFNEGLCREATEPLATFORMPIXMAPSURFACEEXTPROC) (EGLDisplay dpy, EGLConfig config, void *native_pixmap, const EGLint *attrib_list); #ifdef EGL_EGLEXT_PROTOTYPES EGLAPI EGLDisplay EGLAPIENTRY eglGetPlatformDisplayEXT (EGLenum platform, void *native_display, const EGLint *attrib_list); EGLAPI EGLSurface EGLAPIENTRY eglCreatePlatformWindowSurfaceEXT (EGLDisplay dpy, EGLConfig config, void *native_window, const EGLint *attrib_list); EGLAPI EGLSurface EGLAPIENTRY eglCreatePlatformPixmapSurfaceEXT (EGLDisplay dpy, EGLConfig config, void *native_pixmap, const EGLint *attrib_list); #endif #endif /* EGL_EXT_platform_base */ #ifndef EGL_EXT_platform_device #define EGL_EXT_platform_device 1 #define EGL_PLATFORM_DEVICE_EXT 0x313F #endif /* EGL_EXT_platform_device */ #ifndef EGL_EXT_platform_wayland #define EGL_EXT_platform_wayland 1 #define EGL_PLATFORM_WAYLAND_EXT 0x31D8 #endif /* EGL_EXT_platform_wayland */ #ifndef EGL_EXT_platform_x11 #define EGL_EXT_platform_x11 1 #define EGL_PLATFORM_X11_EXT 0x31D5 #define EGL_PLATFORM_X11_SCREEN_EXT 0x31D6 #endif /* EGL_EXT_platform_x11 */ #ifndef EGL_EXT_platform_xcb #define EGL_EXT_platform_xcb 1 #define EGL_PLATFORM_XCB_EXT 0x31DC #define EGL_PLATFORM_XCB_SCREEN_EXT 0x31DE #endif /* EGL_EXT_platform_xcb */ #ifndef EGL_EXT_present_opaque #define EGL_EXT_present_opaque 1 #define EGL_PRESENT_OPAQUE_EXT 0x31DF #endif /* EGL_EXT_present_opaque */ #ifndef EGL_EXT_protected_content #define EGL_EXT_protected_content 1 #define EGL_PROTECTED_CONTENT_EXT 0x32C0 #endif /* EGL_EXT_protected_content */ #ifndef EGL_EXT_protected_surface #define EGL_EXT_protected_surface 1 #endif /* EGL_EXT_protected_surface */ #ifndef EGL_EXT_stream_consumer_egloutput #define EGL_EXT_stream_consumer_egloutput 1 typedef EGLBoolean (EGLAPIENTRYP PFNEGLSTREAMCONSUMEROUTPUTEXTPROC) (EGLDisplay dpy, EGLStreamKHR stream, EGLOutputLayerEXT layer); #ifdef EGL_EGLEXT_PROTOTYPES EGLAPI EGLBoolean EGLAPIENTRY eglStreamConsumerOutputEXT (EGLDisplay dpy, EGLStreamKHR stream, EGLOutputLayerEXT layer); #endif #endif /* EGL_EXT_stream_consumer_egloutput */ #ifndef EGL_EXT_surface_CTA861_3_metadata #define EGL_EXT_surface_CTA861_3_metadata 1 #define EGL_CTA861_3_MAX_CONTENT_LIGHT_LEVEL_EXT 0x3360 #define EGL_CTA861_3_MAX_FRAME_AVERAGE_LEVEL_EXT 0x3361 #endif /* EGL_EXT_surface_CTA861_3_metadata */ #ifndef EGL_EXT_surface_SMPTE2086_metadata #define EGL_EXT_surface_SMPTE2086_metadata 1 #define EGL_SMPTE2086_DISPLAY_PRIMARY_RX_EXT 0x3341 #define EGL_SMPTE2086_DISPLAY_PRIMARY_RY_EXT 0x3342 #define EGL_SMPTE2086_DISPLAY_PRIMARY_GX_EXT 0x3343 #define EGL_SMPTE2086_DISPLAY_PRIMARY_GY_EXT 0x3344 #define EGL_SMPTE2086_DISPLAY_PRIMARY_BX_EXT 0x3345 #define EGL_SMPTE2086_DISPLAY_PRIMARY_BY_EXT 0x3346 #define EGL_SMPTE2086_WHITE_POINT_X_EXT 0x3347 #define EGL_SMPTE2086_WHITE_POINT_Y_EXT 0x3348 #define EGL_SMPTE2086_MAX_LUMINANCE_EXT 0x3349 #define EGL_SMPTE2086_MIN_LUMINANCE_EXT 0x334A #define EGL_METADATA_SCALING_EXT 50000 #endif /* EGL_EXT_surface_SMPTE2086_metadata */ #ifndef EGL_EXT_surface_compression #define EGL_EXT_surface_compression 1 #define EGL_SURFACE_COMPRESSION_EXT 0x34B0 #define EGL_SURFACE_COMPRESSION_PLANE1_EXT 0x328E #define EGL_SURFACE_COMPRESSION_PLANE2_EXT 0x328F #define EGL_SURFACE_COMPRESSION_FIXED_RATE_NONE_EXT 0x34B1 #define EGL_SURFACE_COMPRESSION_FIXED_RATE_DEFAULT_EXT 0x34B2 #define EGL_SURFACE_COMPRESSION_FIXED_RATE_1BPC_EXT 0x34B4 #define EGL_SURFACE_COMPRESSION_FIXED_RATE_2BPC_EXT 0x34B5 #define EGL_SURFACE_COMPRESSION_FIXED_RATE_3BPC_EXT 0x34B6 #define EGL_SURFACE_COMPRESSION_FIXED_RATE_4BPC_EXT 0x34B7 #define EGL_SURFACE_COMPRESSION_FIXED_RATE_5BPC_EXT 0x34B8 #define EGL_SURFACE_COMPRESSION_FIXED_RATE_6BPC_EXT 0x34B9 #define EGL_SURFACE_COMPRESSION_FIXED_RATE_7BPC_EXT 0x34BA #define EGL_SURFACE_COMPRESSION_FIXED_RATE_8BPC_EXT 0x34BB #define EGL_SURFACE_COMPRESSION_FIXED_RATE_9BPC_EXT 0x34BC #define EGL_SURFACE_COMPRESSION_FIXED_RATE_10BPC_EXT 0x34BD #define EGL_SURFACE_COMPRESSION_FIXED_RATE_11BPC_EXT 0x34BE #define EGL_SURFACE_COMPRESSION_FIXED_RATE_12BPC_EXT 0x34BF typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYSUPPORTEDCOMPRESSIONRATESEXTPROC) (EGLDisplay dpy, EGLConfig config, const EGLAttrib *attrib_list, EGLint *rates, EGLint rate_size, EGLint *num_rates); #ifdef EGL_EGLEXT_PROTOTYPES EGLAPI EGLBoolean EGLAPIENTRY eglQuerySupportedCompressionRatesEXT (EGLDisplay dpy, EGLConfig config, const EGLAttrib *attrib_list, EGLint *rates, EGLint rate_size, EGLint *num_rates); #endif #endif /* EGL_EXT_surface_compression */ #ifndef EGL_EXT_swap_buffers_with_damage #define EGL_EXT_swap_buffers_with_damage 1 typedef EGLBoolean (EGLAPIENTRYP PFNEGLSWAPBUFFERSWITHDAMAGEEXTPROC) (EGLDisplay dpy, EGLSurface surface, const EGLint *rects, EGLint n_rects); #ifdef EGL_EGLEXT_PROTOTYPES EGLAPI EGLBoolean EGLAPIENTRY eglSwapBuffersWithDamageEXT (EGLDisplay dpy, EGLSurface surface, const EGLint *rects, EGLint n_rects); #endif #endif /* EGL_EXT_swap_buffers_with_damage */ #ifndef EGL_EXT_sync_reuse #define EGL_EXT_sync_reuse 1 typedef EGLBoolean (EGLAPIENTRYP PFNEGLUNSIGNALSYNCEXTPROC) (EGLDisplay dpy, EGLSync sync, const EGLAttrib *attrib_list); #ifdef EGL_EGLEXT_PROTOTYPES EGLAPI EGLBoolean EGLAPIENTRY eglUnsignalSyncEXT (EGLDisplay dpy, EGLSync sync, const EGLAttrib *attrib_list); #endif #endif /* EGL_EXT_sync_reuse */ #ifndef EGL_EXT_yuv_surface #define EGL_EXT_yuv_surface 1 #define EGL_YUV_ORDER_EXT 0x3301 #define EGL_YUV_NUMBER_OF_PLANES_EXT 0x3311 #define EGL_YUV_SUBSAMPLE_EXT 0x3312 #define EGL_YUV_DEPTH_RANGE_EXT 0x3317 #define EGL_YUV_CSC_STANDARD_EXT 0x330A #define EGL_YUV_PLANE_BPP_EXT 0x331A #define EGL_YUV_BUFFER_EXT 0x3300 #define EGL_YUV_ORDER_YUV_EXT 0x3302 #define EGL_YUV_ORDER_YVU_EXT 0x3303 #define EGL_YUV_ORDER_YUYV_EXT 0x3304 #define EGL_YUV_ORDER_UYVY_EXT 0x3305 #define EGL_YUV_ORDER_YVYU_EXT 0x3306 #define EGL_YUV_ORDER_VYUY_EXT 0x3307 #define EGL_YUV_ORDER_AYUV_EXT 0x3308 #define EGL_YUV_SUBSAMPLE_4_2_0_EXT 0x3313 #define EGL_YUV_SUBSAMPLE_4_2_2_EXT 0x3314 #define EGL_YUV_SUBSAMPLE_4_4_4_EXT 0x3315 #define EGL_YUV_DEPTH_RANGE_LIMITED_EXT 0x3318 #define EGL_YUV_DEPTH_RANGE_FULL_EXT 0x3319 #define EGL_YUV_CSC_STANDARD_601_EXT 0x330B #define EGL_YUV_CSC_STANDARD_709_EXT 0x330C #define EGL_YUV_CSC_STANDARD_2020_EXT 0x330D #define EGL_YUV_PLANE_BPP_0_EXT 0x331B #define EGL_YUV_PLANE_BPP_8_EXT 0x331C #define EGL_YUV_PLANE_BPP_10_EXT 0x331D #endif /* EGL_EXT_yuv_surface */ #ifndef EGL_HI_clientpixmap #define EGL_HI_clientpixmap 1 struct EGLClientPixmapHI { void *pData; EGLint iWidth; EGLint iHeight; EGLint iStride; }; #define EGL_CLIENT_PIXMAP_POINTER_HI 0x8F74 typedef EGLSurface (EGLAPIENTRYP PFNEGLCREATEPIXMAPSURFACEHIPROC) (EGLDisplay dpy, EGLConfig config, struct EGLClientPixmapHI *pixmap); #ifdef EGL_EGLEXT_PROTOTYPES EGLAPI EGLSurface EGLAPIENTRY eglCreatePixmapSurfaceHI (EGLDisplay dpy, EGLConfig config, struct EGLClientPixmapHI *pixmap); #endif #endif /* EGL_HI_clientpixmap */ #ifndef EGL_HI_colorformats #define EGL_HI_colorformats 1 #define EGL_COLOR_FORMAT_HI 0x8F70 #define EGL_COLOR_RGB_HI 0x8F71 #define EGL_COLOR_RGBA_HI 0x8F72 #define EGL_COLOR_ARGB_HI 0x8F73 #endif /* EGL_HI_colorformats */ #ifndef EGL_IMG_context_priority #define EGL_IMG_context_priority 1 #define EGL_CONTEXT_PRIORITY_LEVEL_IMG 0x3100 #define EGL_CONTEXT_PRIORITY_HIGH_IMG 0x3101 #define EGL_CONTEXT_PRIORITY_MEDIUM_IMG 0x3102 #define EGL_CONTEXT_PRIORITY_LOW_IMG 0x3103 #endif /* EGL_IMG_context_priority */ #ifndef EGL_IMG_image_plane_attribs #define EGL_IMG_image_plane_attribs 1 #define EGL_NATIVE_BUFFER_MULTIPLANE_SEPARATE_IMG 0x3105 #define EGL_NATIVE_BUFFER_PLANE_OFFSET_IMG 0x3106 #endif /* EGL_IMG_image_plane_attribs */ #ifndef EGL_MESA_drm_image #define EGL_MESA_drm_image 1 #define EGL_DRM_BUFFER_FORMAT_MESA 0x31D0 #define EGL_DRM_BUFFER_USE_MESA 0x31D1 #define EGL_DRM_BUFFER_FORMAT_ARGB32_MESA 0x31D2 #define EGL_DRM_BUFFER_MESA 0x31D3 #define EGL_DRM_BUFFER_STRIDE_MESA 0x31D4 #define EGL_DRM_BUFFER_USE_SCANOUT_MESA 0x00000001 #define EGL_DRM_BUFFER_USE_SHARE_MESA 0x00000002 #define EGL_DRM_BUFFER_USE_CURSOR_MESA 0x00000004 typedef EGLImageKHR (EGLAPIENTRYP PFNEGLCREATEDRMIMAGEMESAPROC) (EGLDisplay dpy, const EGLint *attrib_list); typedef EGLBoolean (EGLAPIENTRYP PFNEGLEXPORTDRMIMAGEMESAPROC) (EGLDisplay dpy, EGLImageKHR image, EGLint *name, EGLint *handle, EGLint *stride); #ifdef EGL_EGLEXT_PROTOTYPES EGLAPI EGLImageKHR EGLAPIENTRY eglCreateDRMImageMESA (EGLDisplay dpy, const EGLint *attrib_list); EGLAPI EGLBoolean EGLAPIENTRY eglExportDRMImageMESA (EGLDisplay dpy, EGLImageKHR image, EGLint *name, EGLint *handle, EGLint *stride); #endif #endif /* EGL_MESA_drm_image */ #ifndef EGL_MESA_image_dma_buf_export #define EGL_MESA_image_dma_buf_export 1 typedef EGLBoolean (EGLAPIENTRYP PFNEGLEXPORTDMABUFIMAGEQUERYMESAPROC) (EGLDisplay dpy, EGLImageKHR image, int *fourcc, int *num_planes, EGLuint64KHR *modifiers); typedef EGLBoolean (EGLAPIENTRYP PFNEGLEXPORTDMABUFIMAGEMESAPROC) (EGLDisplay dpy, EGLImageKHR image, int *fds, EGLint *strides, EGLint *offsets); #ifdef EGL_EGLEXT_PROTOTYPES EGLAPI EGLBoolean EGLAPIENTRY eglExportDMABUFImageQueryMESA (EGLDisplay dpy, EGLImageKHR image, int *fourcc, int *num_planes, EGLuint64KHR *modifiers); EGLAPI EGLBoolean EGLAPIENTRY eglExportDMABUFImageMESA (EGLDisplay dpy, EGLImageKHR image, int *fds, EGLint *strides, EGLint *offsets); #endif #endif /* EGL_MESA_image_dma_buf_export */ #ifndef EGL_MESA_platform_gbm #define EGL_MESA_platform_gbm 1 #define EGL_PLATFORM_GBM_MESA 0x31D7 #endif /* EGL_MESA_platform_gbm */ #ifndef EGL_MESA_platform_surfaceless #define EGL_MESA_platform_surfaceless 1 #define EGL_PLATFORM_SURFACELESS_MESA 0x31DD #endif /* EGL_MESA_platform_surfaceless */ #ifndef EGL_MESA_query_driver #define EGL_MESA_query_driver 1 typedef char *(EGLAPIENTRYP PFNEGLGETDISPLAYDRIVERCONFIGPROC) (EGLDisplay dpy); typedef const char *(EGLAPIENTRYP PFNEGLGETDISPLAYDRIVERNAMEPROC) (EGLDisplay dpy); #ifdef EGL_EGLEXT_PROTOTYPES EGLAPI char *EGLAPIENTRY eglGetDisplayDriverConfig (EGLDisplay dpy); EGLAPI const char *EGLAPIENTRY eglGetDisplayDriverName (EGLDisplay dpy); #endif #endif /* EGL_MESA_query_driver */ #ifndef EGL_NOK_swap_region #define EGL_NOK_swap_region 1 typedef EGLBoolean (EGLAPIENTRYP PFNEGLSWAPBUFFERSREGIONNOKPROC) (EGLDisplay dpy, EGLSurface surface, EGLint numRects, const EGLint *rects); #ifdef EGL_EGLEXT_PROTOTYPES EGLAPI EGLBoolean EGLAPIENTRY eglSwapBuffersRegionNOK (EGLDisplay dpy, EGLSurface surface, EGLint numRects, const EGLint *rects); #endif #endif /* EGL_NOK_swap_region */ #ifndef EGL_NOK_swap_region2 #define EGL_NOK_swap_region2 1 typedef EGLBoolean (EGLAPIENTRYP PFNEGLSWAPBUFFERSREGION2NOKPROC) (EGLDisplay dpy, EGLSurface surface, EGLint numRects, const EGLint *rects); #ifdef EGL_EGLEXT_PROTOTYPES EGLAPI EGLBoolean EGLAPIENTRY eglSwapBuffersRegion2NOK (EGLDisplay dpy, EGLSurface surface, EGLint numRects, const EGLint *rects); #endif #endif /* EGL_NOK_swap_region2 */ #ifndef EGL_NOK_texture_from_pixmap #define EGL_NOK_texture_from_pixmap 1 #define EGL_Y_INVERTED_NOK 0x307F #endif /* EGL_NOK_texture_from_pixmap */ #ifndef EGL_NV_3dvision_surface #define EGL_NV_3dvision_surface 1 #define EGL_AUTO_STEREO_NV 0x3136 #endif /* EGL_NV_3dvision_surface */ #ifndef EGL_NV_context_priority_realtime #define EGL_NV_context_priority_realtime 1 #define EGL_CONTEXT_PRIORITY_REALTIME_NV 0x3357 #endif /* EGL_NV_context_priority_realtime */ #ifndef EGL_NV_coverage_sample #define EGL_NV_coverage_sample 1 #define EGL_COVERAGE_BUFFERS_NV 0x30E0 #define EGL_COVERAGE_SAMPLES_NV 0x30E1 #endif /* EGL_NV_coverage_sample */ #ifndef EGL_NV_coverage_sample_resolve #define EGL_NV_coverage_sample_resolve 1 #define EGL_COVERAGE_SAMPLE_RESOLVE_NV 0x3131 #define EGL_COVERAGE_SAMPLE_RESOLVE_DEFAULT_NV 0x3132 #define EGL_COVERAGE_SAMPLE_RESOLVE_NONE_NV 0x3133 #endif /* EGL_NV_coverage_sample_resolve */ #ifndef EGL_NV_cuda_event #define EGL_NV_cuda_event 1 #define EGL_CUDA_EVENT_HANDLE_NV 0x323B #define EGL_SYNC_CUDA_EVENT_NV 0x323C #define EGL_SYNC_CUDA_EVENT_COMPLETE_NV 0x323D #endif /* EGL_NV_cuda_event */ #ifndef EGL_NV_depth_nonlinear #define EGL_NV_depth_nonlinear 1 #define EGL_DEPTH_ENCODING_NV 0x30E2 #define EGL_DEPTH_ENCODING_NONE_NV 0 #define EGL_DEPTH_ENCODING_NONLINEAR_NV 0x30E3 #endif /* EGL_NV_depth_nonlinear */ #ifndef EGL_NV_device_cuda #define EGL_NV_device_cuda 1 #define EGL_CUDA_DEVICE_NV 0x323A #endif /* EGL_NV_device_cuda */ #ifndef EGL_NV_native_query #define EGL_NV_native_query 1 typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYNATIVEDISPLAYNVPROC) (EGLDisplay dpy, EGLNativeDisplayType *display_id); typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYNATIVEWINDOWNVPROC) (EGLDisplay dpy, EGLSurface surf, EGLNativeWindowType *window); typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYNATIVEPIXMAPNVPROC) (EGLDisplay dpy, EGLSurface surf, EGLNativePixmapType *pixmap); #ifdef EGL_EGLEXT_PROTOTYPES EGLAPI EGLBoolean EGLAPIENTRY eglQueryNativeDisplayNV (EGLDisplay dpy, EGLNativeDisplayType *display_id); EGLAPI EGLBoolean EGLAPIENTRY eglQueryNativeWindowNV (EGLDisplay dpy, EGLSurface surf, EGLNativeWindowType *window); EGLAPI EGLBoolean EGLAPIENTRY eglQueryNativePixmapNV (EGLDisplay dpy, EGLSurface surf, EGLNativePixmapType *pixmap); #endif #endif /* EGL_NV_native_query */ #ifndef EGL_NV_post_convert_rounding #define EGL_NV_post_convert_rounding 1 #endif /* EGL_NV_post_convert_rounding */ #ifndef EGL_NV_post_sub_buffer #define EGL_NV_post_sub_buffer 1 #define EGL_POST_SUB_BUFFER_SUPPORTED_NV 0x30BE typedef EGLBoolean (EGLAPIENTRYP PFNEGLPOSTSUBBUFFERNVPROC) (EGLDisplay dpy, EGLSurface surface, EGLint x, EGLint y, EGLint width, EGLint height); #ifdef EGL_EGLEXT_PROTOTYPES EGLAPI EGLBoolean EGLAPIENTRY eglPostSubBufferNV (EGLDisplay dpy, EGLSurface surface, EGLint x, EGLint y, EGLint width, EGLint height); #endif #endif /* EGL_NV_post_sub_buffer */ #ifndef EGL_NV_quadruple_buffer #define EGL_NV_quadruple_buffer 1 #define EGL_QUADRUPLE_BUFFER_NV 0x3231 #endif /* EGL_NV_quadruple_buffer */ #ifndef EGL_NV_robustness_video_memory_purge #define EGL_NV_robustness_video_memory_purge 1 #define EGL_GENERATE_RESET_ON_VIDEO_MEMORY_PURGE_NV 0x334C #endif /* EGL_NV_robustness_video_memory_purge */ #ifndef EGL_NV_stream_consumer_eglimage #define EGL_NV_stream_consumer_eglimage 1 #define EGL_STREAM_CONSUMER_IMAGE_NV 0x3373 #define EGL_STREAM_IMAGE_ADD_NV 0x3374 #define EGL_STREAM_IMAGE_REMOVE_NV 0x3375 #define EGL_STREAM_IMAGE_AVAILABLE_NV 0x3376 typedef EGLBoolean (EGLAPIENTRYP PFNEGLSTREAMIMAGECONSUMERCONNECTNVPROC) (EGLDisplay dpy, EGLStreamKHR stream, EGLint num_modifiers, const EGLuint64KHR *modifiers, const EGLAttrib *attrib_list); typedef EGLint (EGLAPIENTRYP PFNEGLQUERYSTREAMCONSUMEREVENTNVPROC) (EGLDisplay dpy, EGLStreamKHR stream, EGLTime timeout, EGLenum *event, EGLAttrib *aux); typedef EGLBoolean (EGLAPIENTRYP PFNEGLSTREAMACQUIREIMAGENVPROC) (EGLDisplay dpy, EGLStreamKHR stream, EGLImage *pImage, EGLSync sync); typedef EGLBoolean (EGLAPIENTRYP PFNEGLSTREAMRELEASEIMAGENVPROC) (EGLDisplay dpy, EGLStreamKHR stream, EGLImage image, EGLSync sync); #ifdef EGL_EGLEXT_PROTOTYPES EGLAPI EGLBoolean EGLAPIENTRY eglStreamImageConsumerConnectNV (EGLDisplay dpy, EGLStreamKHR stream, EGLint num_modifiers, const EGLuint64KHR *modifiers, const EGLAttrib *attrib_list); EGLAPI EGLint EGLAPIENTRY eglQueryStreamConsumerEventNV (EGLDisplay dpy, EGLStreamKHR stream, EGLTime timeout, EGLenum *event, EGLAttrib *aux); EGLAPI EGLBoolean EGLAPIENTRY eglStreamAcquireImageNV (EGLDisplay dpy, EGLStreamKHR stream, EGLImage *pImage, EGLSync sync); EGLAPI EGLBoolean EGLAPIENTRY eglStreamReleaseImageNV (EGLDisplay dpy, EGLStreamKHR stream, EGLImage image, EGLSync sync); #endif #endif /* EGL_NV_stream_consumer_eglimage */ #ifndef EGL_NV_stream_consumer_gltexture_yuv #define EGL_NV_stream_consumer_gltexture_yuv 1 #define EGL_YUV_PLANE0_TEXTURE_UNIT_NV 0x332C #define EGL_YUV_PLANE1_TEXTURE_UNIT_NV 0x332D #define EGL_YUV_PLANE2_TEXTURE_UNIT_NV 0x332E typedef EGLBoolean (EGLAPIENTRYP PFNEGLSTREAMCONSUMERGLTEXTUREEXTERNALATTRIBSNVPROC) (EGLDisplay dpy, EGLStreamKHR stream, const EGLAttrib *attrib_list); #ifdef EGL_EGLEXT_PROTOTYPES EGLAPI EGLBoolean EGLAPIENTRY eglStreamConsumerGLTextureExternalAttribsNV (EGLDisplay dpy, EGLStreamKHR stream, const EGLAttrib *attrib_list); #endif #endif /* EGL_NV_stream_consumer_gltexture_yuv */ #ifndef EGL_NV_stream_cross_display #define EGL_NV_stream_cross_display 1 #define EGL_STREAM_CROSS_DISPLAY_NV 0x334E #endif /* EGL_NV_stream_cross_display */ #ifndef EGL_NV_stream_cross_object #define EGL_NV_stream_cross_object 1 #define EGL_STREAM_CROSS_OBJECT_NV 0x334D #endif /* EGL_NV_stream_cross_object */ #ifndef EGL_NV_stream_cross_partition #define EGL_NV_stream_cross_partition 1 #define EGL_STREAM_CROSS_PARTITION_NV 0x323F #endif /* EGL_NV_stream_cross_partition */ #ifndef EGL_NV_stream_cross_process #define EGL_NV_stream_cross_process 1 #define EGL_STREAM_CROSS_PROCESS_NV 0x3245 #endif /* EGL_NV_stream_cross_process */ #ifndef EGL_NV_stream_cross_system #define EGL_NV_stream_cross_system 1 #define EGL_STREAM_CROSS_SYSTEM_NV 0x334F #endif /* EGL_NV_stream_cross_system */ #ifndef EGL_NV_stream_dma #define EGL_NV_stream_dma 1 #define EGL_STREAM_DMA_NV 0x3371 #define EGL_STREAM_DMA_SERVER_NV 0x3372 #endif /* EGL_NV_stream_dma */ #ifndef EGL_NV_stream_fifo_next #define EGL_NV_stream_fifo_next 1 #define EGL_PENDING_FRAME_NV 0x3329 #define EGL_STREAM_TIME_PENDING_NV 0x332A #endif /* EGL_NV_stream_fifo_next */ #ifndef EGL_NV_stream_fifo_synchronous #define EGL_NV_stream_fifo_synchronous 1 #define EGL_STREAM_FIFO_SYNCHRONOUS_NV 0x3336 #endif /* EGL_NV_stream_fifo_synchronous */ #ifndef EGL_NV_stream_flush #define EGL_NV_stream_flush 1 typedef EGLBoolean (EGLAPIENTRYP PFNEGLSTREAMFLUSHNVPROC) (EGLDisplay dpy, EGLStreamKHR stream); #ifdef EGL_EGLEXT_PROTOTYPES EGLAPI EGLBoolean EGLAPIENTRY eglStreamFlushNV (EGLDisplay dpy, EGLStreamKHR stream); #endif #endif /* EGL_NV_stream_flush */ #ifndef EGL_NV_stream_frame_limits #define EGL_NV_stream_frame_limits 1 #define EGL_PRODUCER_MAX_FRAME_HINT_NV 0x3337 #define EGL_CONSUMER_MAX_FRAME_HINT_NV 0x3338 #endif /* EGL_NV_stream_frame_limits */ #ifndef EGL_NV_stream_metadata #define EGL_NV_stream_metadata 1 #define EGL_MAX_STREAM_METADATA_BLOCKS_NV 0x3250 #define EGL_MAX_STREAM_METADATA_BLOCK_SIZE_NV 0x3251 #define EGL_MAX_STREAM_METADATA_TOTAL_SIZE_NV 0x3252 #define EGL_PRODUCER_METADATA_NV 0x3253 #define EGL_CONSUMER_METADATA_NV 0x3254 #define EGL_PENDING_METADATA_NV 0x3328 #define EGL_METADATA0_SIZE_NV 0x3255 #define EGL_METADATA1_SIZE_NV 0x3256 #define EGL_METADATA2_SIZE_NV 0x3257 #define EGL_METADATA3_SIZE_NV 0x3258 #define EGL_METADATA0_TYPE_NV 0x3259 #define EGL_METADATA1_TYPE_NV 0x325A #define EGL_METADATA2_TYPE_NV 0x325B #define EGL_METADATA3_TYPE_NV 0x325C typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYDISPLAYATTRIBNVPROC) (EGLDisplay dpy, EGLint attribute, EGLAttrib *value); typedef EGLBoolean (EGLAPIENTRYP PFNEGLSETSTREAMMETADATANVPROC) (EGLDisplay dpy, EGLStreamKHR stream, EGLint n, EGLint offset, EGLint size, const void *data); typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYSTREAMMETADATANVPROC) (EGLDisplay dpy, EGLStreamKHR stream, EGLenum name, EGLint n, EGLint offset, EGLint size, void *data); #ifdef EGL_EGLEXT_PROTOTYPES EGLAPI EGLBoolean EGLAPIENTRY eglQueryDisplayAttribNV (EGLDisplay dpy, EGLint attribute, EGLAttrib *value); EGLAPI EGLBoolean EGLAPIENTRY eglSetStreamMetadataNV (EGLDisplay dpy, EGLStreamKHR stream, EGLint n, EGLint offset, EGLint size, const void *data); EGLAPI EGLBoolean EGLAPIENTRY eglQueryStreamMetadataNV (EGLDisplay dpy, EGLStreamKHR stream, EGLenum name, EGLint n, EGLint offset, EGLint size, void *data); #endif #endif /* EGL_NV_stream_metadata */ #ifndef EGL_NV_stream_origin #define EGL_NV_stream_origin 1 #define EGL_STREAM_FRAME_ORIGIN_X_NV 0x3366 #define EGL_STREAM_FRAME_ORIGIN_Y_NV 0x3367 #define EGL_STREAM_FRAME_MAJOR_AXIS_NV 0x3368 #define EGL_CONSUMER_AUTO_ORIENTATION_NV 0x3369 #define EGL_PRODUCER_AUTO_ORIENTATION_NV 0x336A #define EGL_LEFT_NV 0x336B #define EGL_RIGHT_NV 0x336C #define EGL_TOP_NV 0x336D #define EGL_BOTTOM_NV 0x336E #define EGL_X_AXIS_NV 0x336F #define EGL_Y_AXIS_NV 0x3370 #endif /* EGL_NV_stream_origin */ #ifndef EGL_NV_stream_remote #define EGL_NV_stream_remote 1 #define EGL_STREAM_STATE_INITIALIZING_NV 0x3240 #define EGL_STREAM_TYPE_NV 0x3241 #define EGL_STREAM_PROTOCOL_NV 0x3242 #define EGL_STREAM_ENDPOINT_NV 0x3243 #define EGL_STREAM_LOCAL_NV 0x3244 #define EGL_STREAM_PRODUCER_NV 0x3247 #define EGL_STREAM_CONSUMER_NV 0x3248 #define EGL_STREAM_PROTOCOL_FD_NV 0x3246 #endif /* EGL_NV_stream_remote */ #ifndef EGL_NV_stream_reset #define EGL_NV_stream_reset 1 #define EGL_SUPPORT_RESET_NV 0x3334 #define EGL_SUPPORT_REUSE_NV 0x3335 typedef EGLBoolean (EGLAPIENTRYP PFNEGLRESETSTREAMNVPROC) (EGLDisplay dpy, EGLStreamKHR stream); #ifdef EGL_EGLEXT_PROTOTYPES EGLAPI EGLBoolean EGLAPIENTRY eglResetStreamNV (EGLDisplay dpy, EGLStreamKHR stream); #endif #endif /* EGL_NV_stream_reset */ #ifndef EGL_NV_stream_socket #define EGL_NV_stream_socket 1 #define EGL_STREAM_PROTOCOL_SOCKET_NV 0x324B #define EGL_SOCKET_HANDLE_NV 0x324C #define EGL_SOCKET_TYPE_NV 0x324D #endif /* EGL_NV_stream_socket */ #ifndef EGL_NV_stream_socket_inet #define EGL_NV_stream_socket_inet 1 #define EGL_SOCKET_TYPE_INET_NV 0x324F #endif /* EGL_NV_stream_socket_inet */ #ifndef EGL_NV_stream_socket_unix #define EGL_NV_stream_socket_unix 1 #define EGL_SOCKET_TYPE_UNIX_NV 0x324E #endif /* EGL_NV_stream_socket_unix */ #ifndef EGL_NV_stream_sync #define EGL_NV_stream_sync 1 #define EGL_SYNC_NEW_FRAME_NV 0x321F typedef EGLSyncKHR (EGLAPIENTRYP PFNEGLCREATESTREAMSYNCNVPROC) (EGLDisplay dpy, EGLStreamKHR stream, EGLenum type, const EGLint *attrib_list); #ifdef EGL_EGLEXT_PROTOTYPES EGLAPI EGLSyncKHR EGLAPIENTRY eglCreateStreamSyncNV (EGLDisplay dpy, EGLStreamKHR stream, EGLenum type, const EGLint *attrib_list); #endif #endif /* EGL_NV_stream_sync */ #ifndef EGL_NV_sync #define EGL_NV_sync 1 typedef void *EGLSyncNV; typedef khronos_utime_nanoseconds_t EGLTimeNV; #ifdef KHRONOS_SUPPORT_INT64 #define EGL_SYNC_PRIOR_COMMANDS_COMPLETE_NV 0x30E6 #define EGL_SYNC_STATUS_NV 0x30E7 #define EGL_SIGNALED_NV 0x30E8 #define EGL_UNSIGNALED_NV 0x30E9 #define EGL_SYNC_FLUSH_COMMANDS_BIT_NV 0x0001 #define EGL_FOREVER_NV 0xFFFFFFFFFFFFFFFFull #define EGL_ALREADY_SIGNALED_NV 0x30EA #define EGL_TIMEOUT_EXPIRED_NV 0x30EB #define EGL_CONDITION_SATISFIED_NV 0x30EC #define EGL_SYNC_TYPE_NV 0x30ED #define EGL_SYNC_CONDITION_NV 0x30EE #define EGL_SYNC_FENCE_NV 0x30EF #define EGL_NO_SYNC_NV EGL_CAST(EGLSyncNV,0) typedef EGLSyncNV (EGLAPIENTRYP PFNEGLCREATEFENCESYNCNVPROC) (EGLDisplay dpy, EGLenum condition, const EGLint *attrib_list); typedef EGLBoolean (EGLAPIENTRYP PFNEGLDESTROYSYNCNVPROC) (EGLSyncNV sync); typedef EGLBoolean (EGLAPIENTRYP PFNEGLFENCENVPROC) (EGLSyncNV sync); typedef EGLint (EGLAPIENTRYP PFNEGLCLIENTWAITSYNCNVPROC) (EGLSyncNV sync, EGLint flags, EGLTimeNV timeout); typedef EGLBoolean (EGLAPIENTRYP PFNEGLSIGNALSYNCNVPROC) (EGLSyncNV sync, EGLenum mode); typedef EGLBoolean (EGLAPIENTRYP PFNEGLGETSYNCATTRIBNVPROC) (EGLSyncNV sync, EGLint attribute, EGLint *value); #ifdef EGL_EGLEXT_PROTOTYPES EGLAPI EGLSyncNV EGLAPIENTRY eglCreateFenceSyncNV (EGLDisplay dpy, EGLenum condition, const EGLint *attrib_list); EGLAPI EGLBoolean EGLAPIENTRY eglDestroySyncNV (EGLSyncNV sync); EGLAPI EGLBoolean EGLAPIENTRY eglFenceNV (EGLSyncNV sync); EGLAPI EGLint EGLAPIENTRY eglClientWaitSyncNV (EGLSyncNV sync, EGLint flags, EGLTimeNV timeout); EGLAPI EGLBoolean EGLAPIENTRY eglSignalSyncNV (EGLSyncNV sync, EGLenum mode); EGLAPI EGLBoolean EGLAPIENTRY eglGetSyncAttribNV (EGLSyncNV sync, EGLint attribute, EGLint *value); #endif #endif /* KHRONOS_SUPPORT_INT64 */ #endif /* EGL_NV_sync */ #ifndef EGL_NV_system_time #define EGL_NV_system_time 1 typedef khronos_utime_nanoseconds_t EGLuint64NV; #ifdef KHRONOS_SUPPORT_INT64 typedef EGLuint64NV (EGLAPIENTRYP PFNEGLGETSYSTEMTIMEFREQUENCYNVPROC) (void); typedef EGLuint64NV (EGLAPIENTRYP PFNEGLGETSYSTEMTIMENVPROC) (void); #ifdef EGL_EGLEXT_PROTOTYPES EGLAPI EGLuint64NV EGLAPIENTRY eglGetSystemTimeFrequencyNV (void); EGLAPI EGLuint64NV EGLAPIENTRY eglGetSystemTimeNV (void); #endif #endif /* KHRONOS_SUPPORT_INT64 */ #endif /* EGL_NV_system_time */ #ifndef EGL_NV_triple_buffer #define EGL_NV_triple_buffer 1 #define EGL_TRIPLE_BUFFER_NV 0x3230 #endif /* EGL_NV_triple_buffer */ #ifndef EGL_TIZEN_image_native_buffer #define EGL_TIZEN_image_native_buffer 1 #define EGL_NATIVE_BUFFER_TIZEN 0x32A0 #endif /* EGL_TIZEN_image_native_buffer */ #ifndef EGL_TIZEN_image_native_surface #define EGL_TIZEN_image_native_surface 1 #define EGL_NATIVE_SURFACE_TIZEN 0x32A1 #endif /* EGL_TIZEN_image_native_surface */ #ifndef EGL_WL_bind_wayland_display #define EGL_WL_bind_wayland_display 1 #define PFNEGLBINDWAYLANDDISPLAYWL PFNEGLBINDWAYLANDDISPLAYWLPROC #define PFNEGLUNBINDWAYLANDDISPLAYWL PFNEGLUNBINDWAYLANDDISPLAYWLPROC #define PFNEGLQUERYWAYLANDBUFFERWL PFNEGLQUERYWAYLANDBUFFERWLPROC struct wl_display; struct wl_resource; #define EGL_WAYLAND_BUFFER_WL 0x31D5 #define EGL_WAYLAND_PLANE_WL 0x31D6 #define EGL_TEXTURE_Y_U_V_WL 0x31D7 #define EGL_TEXTURE_Y_UV_WL 0x31D8 #define EGL_TEXTURE_Y_XUXV_WL 0x31D9 #define EGL_TEXTURE_EXTERNAL_WL 0x31DA #define EGL_WAYLAND_Y_INVERTED_WL 0x31DB typedef EGLBoolean (EGLAPIENTRYP PFNEGLBINDWAYLANDDISPLAYWLPROC) (EGLDisplay dpy, struct wl_display *display); typedef EGLBoolean (EGLAPIENTRYP PFNEGLUNBINDWAYLANDDISPLAYWLPROC) (EGLDisplay dpy, struct wl_display *display); typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYWAYLANDBUFFERWLPROC) (EGLDisplay dpy, struct wl_resource *buffer, EGLint attribute, EGLint *value); #ifdef EGL_EGLEXT_PROTOTYPES EGLAPI EGLBoolean EGLAPIENTRY eglBindWaylandDisplayWL (EGLDisplay dpy, struct wl_display *display); EGLAPI EGLBoolean EGLAPIENTRY eglUnbindWaylandDisplayWL (EGLDisplay dpy, struct wl_display *display); EGLAPI EGLBoolean EGLAPIENTRY eglQueryWaylandBufferWL (EGLDisplay dpy, struct wl_resource *buffer, EGLint attribute, EGLint *value); #endif #endif /* EGL_WL_bind_wayland_display */ #ifndef EGL_WL_create_wayland_buffer_from_image #define EGL_WL_create_wayland_buffer_from_image 1 #define PFNEGLCREATEWAYLANDBUFFERFROMIMAGEWL PFNEGLCREATEWAYLANDBUFFERFROMIMAGEWLPROC struct wl_buffer; typedef struct wl_buffer *(EGLAPIENTRYP PFNEGLCREATEWAYLANDBUFFERFROMIMAGEWLPROC) (EGLDisplay dpy, EGLImageKHR image); #ifdef EGL_EGLEXT_PROTOTYPES EGLAPI struct wl_buffer *EGLAPIENTRY eglCreateWaylandBufferFromImageWL (EGLDisplay dpy, EGLImageKHR image); #endif #endif /* EGL_WL_create_wayland_buffer_from_image */ #ifdef __cplusplus } #endif #endif /* __eglext_h_ */ #endif /* _MSC_VER */ ================================================ FILE: deps/include/SDL3/SDL_endian.h ================================================ /* Simple DirectMedia Layer Copyright (C) 1997-2026 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ /** * # CategoryEndian * * Functions converting endian-specific values to different byte orders. * * These functions either unconditionally swap byte order (SDL_Swap16, * SDL_Swap32, SDL_Swap64, SDL_SwapFloat), or they swap to/from the system's * native byte order (SDL_Swap16LE, SDL_Swap16BE, SDL_Swap32LE, SDL_Swap32BE, * SDL_Swap32LE, SDL_Swap32BE, SDL_SwapFloatLE, SDL_SwapFloatBE). In the * latter case, the functionality is provided by macros that become no-ops if * a swap isn't necessary: on an x86 (littleendian) processor, SDL_Swap32LE * does nothing, but SDL_Swap32BE reverses the bytes of the data. On a PowerPC * processor (bigendian), the macros behavior is reversed. * * The swap routines are inline functions, and attempt to use compiler * intrinsics, inline assembly, and other magic to make byteswapping * efficient. */ #ifndef SDL_endian_h_ #define SDL_endian_h_ #include #if defined(_MSC_VER) && (_MSC_VER >= 1400) /* As of Clang 11, '_m_prefetchw' is conflicting with the winnt.h's version, so we define the needed '_m_prefetch' here as a pseudo-header, until the issue is fixed. */ #if defined(__clang__) && !SDL_HAS_BUILTIN(_m_prefetch) #ifndef __PRFCHWINTRIN_H #define __PRFCHWINTRIN_H static __inline__ void __attribute__((__always_inline__, __nodebug__)) _m_prefetch(void *__P) { __builtin_prefetch(__P, 0, 3 /* _MM_HINT_T0 */); } #endif /* __PRFCHWINTRIN_H */ #endif /* __clang__ */ #include #endif /** * \name The two types of endianness */ /* @{ */ /** * A value to represent littleendian byteorder. * * This is used with the preprocessor macro SDL_BYTEORDER, to determine a * platform's byte ordering: * * ```c * #if SDL_BYTEORDER == SDL_LIL_ENDIAN * SDL_Log("This system is littleendian."); * #endif * ``` * * \since This macro is available since SDL 3.2.0. * * \sa SDL_BYTEORDER * \sa SDL_BIG_ENDIAN */ #define SDL_LIL_ENDIAN 1234 /** * A value to represent bigendian byteorder. * * This is used with the preprocessor macro SDL_BYTEORDER, to determine a * platform's byte ordering: * * ```c * #if SDL_BYTEORDER == SDL_BIG_ENDIAN * SDL_Log("This system is bigendian."); * #endif * ``` * * \since This macro is available since SDL 3.2.0. * * \sa SDL_BYTEORDER * \sa SDL_LIL_ENDIAN */ #define SDL_BIG_ENDIAN 4321 /* @} */ #ifndef SDL_BYTEORDER #ifdef SDL_WIKI_DOCUMENTATION_SECTION /** * A macro that reports the target system's byte order. * * This is set to either SDL_LIL_ENDIAN or SDL_BIG_ENDIAN (and maybe other * values in the future, if something else becomes popular). This can be * tested with the preprocessor, so decisions can be made at compile time. * * ```c * #if SDL_BYTEORDER == SDL_BIG_ENDIAN * SDL_Log("This system is bigendian."); * #endif * ``` * * \since This macro is available since SDL 3.2.0. * * \sa SDL_LIL_ENDIAN * \sa SDL_BIG_ENDIAN */ #define SDL_BYTEORDER SDL_LIL_ENDIAN___or_maybe___SDL_BIG_ENDIAN #elif defined(SDL_PLATFORM_LINUX) || defined(__GLIBC__) #include #define SDL_BYTEORDER __BYTE_ORDER #elif defined(SDL_PLATFORM_SOLARIS) #include #if defined(_LITTLE_ENDIAN) #define SDL_BYTEORDER SDL_LIL_ENDIAN #elif defined(_BIG_ENDIAN) #define SDL_BYTEORDER SDL_BIG_ENDIAN #else #error Unsupported endianness #endif #elif defined(SDL_PLATFORM_OPENBSD) || defined(__DragonFly__) #include #define SDL_BYTEORDER BYTE_ORDER #elif defined(SDL_PLATFORM_FREEBSD) || defined(SDL_PLATFORM_NETBSD) #include #define SDL_BYTEORDER BYTE_ORDER /* predefs from newer gcc and clang versions: */ #elif defined(__ORDER_LITTLE_ENDIAN__) && defined(__ORDER_BIG_ENDIAN__) && defined(__BYTE_ORDER__) #if (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__) #define SDL_BYTEORDER SDL_LIL_ENDIAN #elif (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__) #define SDL_BYTEORDER SDL_BIG_ENDIAN #else #error Unsupported endianness #endif /**/ #else #if defined(__hppa__) || \ defined(__m68k__) || defined(mc68000) || defined(_M_M68K) || \ (defined(__MIPS__) && defined(__MIPSEB__)) || \ defined(__ppc__) || defined(__POWERPC__) || defined(__powerpc__) || defined(__PPC__) || \ defined(__sparc__) || defined(__sparc) #define SDL_BYTEORDER SDL_BIG_ENDIAN #else #define SDL_BYTEORDER SDL_LIL_ENDIAN #endif #endif /* SDL_PLATFORM_LINUX */ #endif /* !SDL_BYTEORDER */ #ifndef SDL_FLOATWORDORDER #ifdef SDL_WIKI_DOCUMENTATION_SECTION /** * A macro that reports the target system's floating point word order. * * This is set to either SDL_LIL_ENDIAN or SDL_BIG_ENDIAN (and maybe other * values in the future, if something else becomes popular). This can be * tested with the preprocessor, so decisions can be made at compile time. * * ```c * #if SDL_FLOATWORDORDER == SDL_BIG_ENDIAN * SDL_Log("This system's floats are bigendian."); * #endif * ``` * * \since This macro is available since SDL 3.2.0. * * \sa SDL_LIL_ENDIAN * \sa SDL_BIG_ENDIAN */ #define SDL_FLOATWORDORDER SDL_LIL_ENDIAN___or_maybe___SDL_BIG_ENDIAN /* predefs from newer gcc versions: */ #elif defined(__ORDER_LITTLE_ENDIAN__) && defined(__ORDER_BIG_ENDIAN__) && defined(__FLOAT_WORD_ORDER__) #if (__FLOAT_WORD_ORDER__ == __ORDER_LITTLE_ENDIAN__) #define SDL_FLOATWORDORDER SDL_LIL_ENDIAN #elif (__FLOAT_WORD_ORDER__ == __ORDER_BIG_ENDIAN__) #define SDL_FLOATWORDORDER SDL_BIG_ENDIAN #else #error Unsupported endianness #endif /**/ #elif defined(__MAVERICK__) /* For Maverick, float words are always little-endian. */ #define SDL_FLOATWORDORDER SDL_LIL_ENDIAN #elif (defined(__arm__) || defined(__thumb__)) && !defined(__VFP_FP__) && !defined(__ARM_EABI__) /* For FPA, float words are always big-endian. */ #define SDL_FLOATWORDORDER SDL_BIG_ENDIAN #else /* By default, assume that floats words follow the memory system mode. */ #define SDL_FLOATWORDORDER SDL_BYTEORDER #endif /* SDL_WIKI_DOCUMENTATION_SECTION */ #endif /* !SDL_FLOATWORDORDER */ #include /* Set up for C function definitions, even when using C++ */ #ifdef __cplusplus extern "C" { #endif /* various modern compilers may have builtin swap */ #if defined(__GNUC__) || defined(__clang__) # define HAS_BUILTIN_BSWAP16 (SDL_HAS_BUILTIN(__builtin_bswap16)) || \ (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8)) # define HAS_BUILTIN_BSWAP32 (SDL_HAS_BUILTIN(__builtin_bswap32)) || \ (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)) # define HAS_BUILTIN_BSWAP64 (SDL_HAS_BUILTIN(__builtin_bswap64)) || \ (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)) /* this one is broken */ # define HAS_BROKEN_BSWAP (__GNUC__ == 2 && __GNUC_MINOR__ <= 95) #else # define HAS_BUILTIN_BSWAP16 0 # define HAS_BUILTIN_BSWAP32 0 # define HAS_BUILTIN_BSWAP64 0 # define HAS_BROKEN_BSWAP 0 #endif /* Byte swap 16-bit integer. */ #ifndef SDL_WIKI_DOCUMENTATION_SECTION #if HAS_BUILTIN_BSWAP16 #define SDL_Swap16(x) __builtin_bswap16(x) #elif (defined(_MSC_VER) && (_MSC_VER >= 1400)) && !defined(__ICL) #pragma intrinsic(_byteswap_ushort) #define SDL_Swap16(x) _byteswap_ushort(x) #elif defined(__i386__) && !HAS_BROKEN_BSWAP SDL_FORCE_INLINE Uint16 SDL_Swap16(Uint16 x) { __asm__("xchgb %b0,%h0": "=q"(x):"0"(x)); return x; } #elif defined(__x86_64__) SDL_FORCE_INLINE Uint16 SDL_Swap16(Uint16 x) { __asm__("xchgb %b0,%h0": "=abcd"(x):"0"(x)); return x; } #elif (defined(__powerpc__) || defined(__ppc__)) SDL_FORCE_INLINE Uint16 SDL_Swap16(Uint16 x) { int result; __asm__("rlwimi %0,%2,8,16,23": "=&r"(result):"0"(x >> 8), "r"(x)); return (Uint16)result; } #elif (defined(__m68k__) && !defined(__mcoldfire__)) SDL_FORCE_INLINE Uint16 SDL_Swap16(Uint16 x) { __asm__("rorw #8,%0": "=d"(x): "0"(x):"cc"); return x; } #elif defined(__WATCOMC__) && defined(__386__) extern __inline Uint16 SDL_Swap16(Uint16); #pragma aux SDL_Swap16 = \ "xchg al, ah" \ parm [ax] \ modify [ax]; #else SDL_FORCE_INLINE Uint16 SDL_Swap16(Uint16 x) { return SDL_static_cast(Uint16, ((x << 8) | (x >> 8))); } #endif #endif /* Byte swap 32-bit integer. */ #ifndef SDL_WIKI_DOCUMENTATION_SECTION #if HAS_BUILTIN_BSWAP32 #define SDL_Swap32(x) __builtin_bswap32(x) #elif (defined(_MSC_VER) && (_MSC_VER >= 1400)) && !defined(__ICL) #pragma intrinsic(_byteswap_ulong) #define SDL_Swap32(x) _byteswap_ulong(x) #elif defined(__i386__) && !HAS_BROKEN_BSWAP SDL_FORCE_INLINE Uint32 SDL_Swap32(Uint32 x) { __asm__("bswap %0": "=r"(x):"0"(x)); return x; } #elif defined(__x86_64__) SDL_FORCE_INLINE Uint32 SDL_Swap32(Uint32 x) { __asm__("bswapl %0": "=r"(x):"0"(x)); return x; } #elif (defined(__powerpc__) || defined(__ppc__)) SDL_FORCE_INLINE Uint32 SDL_Swap32(Uint32 x) { Uint32 result; __asm__("rlwimi %0,%2,24,16,23": "=&r"(result): "0" (x>>24), "r"(x)); __asm__("rlwimi %0,%2,8,8,15" : "=&r"(result): "0" (result), "r"(x)); __asm__("rlwimi %0,%2,24,0,7" : "=&r"(result): "0" (result), "r"(x)); return result; } #elif (defined(__m68k__) && !defined(__mcoldfire__)) SDL_FORCE_INLINE Uint32 SDL_Swap32(Uint32 x) { __asm__("rorw #8,%0\n\tswap %0\n\trorw #8,%0": "=d"(x): "0"(x):"cc"); return x; } #elif defined(__WATCOMC__) && defined(__386__) extern __inline Uint32 SDL_Swap32(Uint32); #pragma aux SDL_Swap32 = \ "bswap eax" \ parm [eax] \ modify [eax]; #else SDL_FORCE_INLINE Uint32 SDL_Swap32(Uint32 x) { return SDL_static_cast(Uint32, ((x << 24) | ((x << 8) & 0x00FF0000) | ((x >> 8) & 0x0000FF00) | (x >> 24))); } #endif #endif /* Byte swap 64-bit integer. */ #ifndef SDL_WIKI_DOCUMENTATION_SECTION #if HAS_BUILTIN_BSWAP64 #define SDL_Swap64(x) __builtin_bswap64(x) #elif (defined(_MSC_VER) && (_MSC_VER >= 1400)) && !defined(__ICL) #pragma intrinsic(_byteswap_uint64) #define SDL_Swap64(x) _byteswap_uint64(x) #elif defined(__i386__) && !HAS_BROKEN_BSWAP SDL_FORCE_INLINE Uint64 SDL_Swap64(Uint64 x) { union { struct { Uint32 a, b; } s; Uint64 u; } v; v.u = x; __asm__("bswapl %0 ; bswapl %1 ; xchgl %0,%1" : "=r"(v.s.a), "=r"(v.s.b) : "0" (v.s.a), "1"(v.s.b)); return v.u; } #elif defined(__x86_64__) SDL_FORCE_INLINE Uint64 SDL_Swap64(Uint64 x) { __asm__("bswapq %0": "=r"(x):"0"(x)); return x; } #elif defined(__WATCOMC__) && defined(__386__) extern __inline Uint64 SDL_Swap64(Uint64); #pragma aux SDL_Swap64 = \ "bswap eax" \ "bswap edx" \ "xchg eax,edx" \ parm [eax edx] \ modify [eax edx]; #else SDL_FORCE_INLINE Uint64 SDL_Swap64(Uint64 x) { Uint32 hi, lo; /* Separate into high and low 32-bit values and swap them */ lo = SDL_static_cast(Uint32, x & 0xFFFFFFFF); x >>= 32; hi = SDL_static_cast(Uint32, x & 0xFFFFFFFF); x = SDL_Swap32(lo); x <<= 32; x |= SDL_Swap32(hi); return (x); } #endif #endif /** * Byte-swap a floating point number. * * This will always byte-swap the value, whether it's currently in the native * byteorder of the system or not. You should use SDL_SwapFloatLE or * SDL_SwapFloatBE instead, in most cases. * * Note that this is a forced-inline function in a header, and not a public * API function available in the SDL library (which is to say, the code is * embedded in the calling program and the linker and dynamic loader will not * be able to find this function inside SDL itself). * * \param x the value to byte-swap. * \returns x, with its bytes in the opposite endian order. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. */ SDL_FORCE_INLINE float SDL_SwapFloat(float x) { union { float f; Uint32 ui32; } swapper; swapper.f = x; swapper.ui32 = SDL_Swap32(swapper.ui32); return swapper.f; } /* remove extra macros */ #undef HAS_BROKEN_BSWAP #undef HAS_BUILTIN_BSWAP16 #undef HAS_BUILTIN_BSWAP32 #undef HAS_BUILTIN_BSWAP64 #ifdef SDL_WIKI_DOCUMENTATION_SECTION /** * Byte-swap an unsigned 16-bit number. * * This will always byte-swap the value, whether it's currently in the native * byteorder of the system or not. You should use SDL_Swap16LE or SDL_Swap16BE * instead, in most cases. * * Note that this is a forced-inline function in a header, and not a public * API function available in the SDL library (which is to say, the code is * embedded in the calling program and the linker and dynamic loader will not * be able to find this function inside SDL itself). * * \param x the value to byte-swap. * \returns `x`, with its bytes in the opposite endian order. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. */ SDL_FORCE_INLINE Uint16 SDL_Swap16(Uint16 x) { return x_but_byteswapped; } /** * Byte-swap an unsigned 32-bit number. * * This will always byte-swap the value, whether it's currently in the native * byteorder of the system or not. You should use SDL_Swap32LE or SDL_Swap32BE * instead, in most cases. * * Note that this is a forced-inline function in a header, and not a public * API function available in the SDL library (which is to say, the code is * embedded in the calling program and the linker and dynamic loader will not * be able to find this function inside SDL itself). * * \param x the value to byte-swap. * \returns `x`, with its bytes in the opposite endian order. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. */ SDL_FORCE_INLINE Uint32 SDL_Swap32(Uint32 x) { return x_but_byteswapped; } /** * Byte-swap an unsigned 64-bit number. * * This will always byte-swap the value, whether it's currently in the native * byteorder of the system or not. You should use SDL_Swap64LE or SDL_Swap64BE * instead, in most cases. * * Note that this is a forced-inline function in a header, and not a public * API function available in the SDL library (which is to say, the code is * embedded in the calling program and the linker and dynamic loader will not * be able to find this function inside SDL itself). * * \param x the value to byte-swap. * \returns `x`, with its bytes in the opposite endian order. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. */ SDL_FORCE_INLINE Uint64 SDL_Swap64(Uint64 x) { return x_but_byteswapped; } /** * Swap a 16-bit value from littleendian to native byte order. * * If this is running on a littleendian system, `x` is returned unchanged. * * This macro never references `x` more than once, avoiding side effects. * * \param x the value to swap, in littleendian byte order. * \returns `x` in native byte order. * * \threadsafety It is safe to call this macro from any thread. * * \since This macro is available since SDL 3.2.0. */ #define SDL_Swap16LE(x) SwapOnlyIfNecessary(x) /** * Swap a 32-bit value from littleendian to native byte order. * * If this is running on a littleendian system, `x` is returned unchanged. * * This macro never references `x` more than once, avoiding side effects. * * \param x the value to swap, in littleendian byte order. * \returns `x` in native byte order. * * \threadsafety It is safe to call this macro from any thread. * * \since This macro is available since SDL 3.2.0. */ #define SDL_Swap32LE(x) SwapOnlyIfNecessary(x) /** * Swap a 64-bit value from littleendian to native byte order. * * If this is running on a littleendian system, `x` is returned unchanged. * * This macro never references `x` more than once, avoiding side effects. * * \param x the value to swap, in littleendian byte order. * \returns `x` in native byte order. * * \threadsafety It is safe to call this macro from any thread. * * \since This macro is available since SDL 3.2.0. */ #define SDL_Swap64LE(x) SwapOnlyIfNecessary(x) /** * Swap a floating point value from littleendian to native byte order. * * If this is running on a littleendian system, `x` is returned unchanged. * * This macro never references `x` more than once, avoiding side effects. * * \param x the value to swap, in littleendian byte order. * \returns `x` in native byte order. * * \threadsafety It is safe to call this macro from any thread. * * \since This macro is available since SDL 3.2.0. */ #define SDL_SwapFloatLE(x) SwapOnlyIfNecessary(x) /** * Swap a 16-bit value from bigendian to native byte order. * * If this is running on a bigendian system, `x` is returned unchanged. * * This macro never references `x` more than once, avoiding side effects. * * \param x the value to swap, in bigendian byte order. * \returns `x` in native byte order. * * \threadsafety It is safe to call this macro from any thread. * * \since This macro is available since SDL 3.2.0. */ #define SDL_Swap16BE(x) SwapOnlyIfNecessary(x) /** * Swap a 32-bit value from bigendian to native byte order. * * If this is running on a bigendian system, `x` is returned unchanged. * * This macro never references `x` more than once, avoiding side effects. * * \param x the value to swap, in bigendian byte order. * \returns `x` in native byte order. * * \threadsafety It is safe to call this macro from any thread. * * \since This macro is available since SDL 3.2.0. */ #define SDL_Swap32BE(x) SwapOnlyIfNecessary(x) /** * Swap a 64-bit value from bigendian to native byte order. * * If this is running on a bigendian system, `x` is returned unchanged. * * This macro never references `x` more than once, avoiding side effects. * * \param x the value to swap, in bigendian byte order. * \returns `x` in native byte order. * * \threadsafety It is safe to call this macro from any thread. * * \since This macro is available since SDL 3.2.0. */ #define SDL_Swap64BE(x) SwapOnlyIfNecessary(x) /** * Swap a floating point value from bigendian to native byte order. * * If this is running on a bigendian system, `x` is returned unchanged. * * This macro never references `x` more than once, avoiding side effects. * * \param x the value to swap, in bigendian byte order. * \returns `x` in native byte order. * * \threadsafety It is safe to call this macro from any thread. * * \since This macro is available since SDL 3.2.0. */ #define SDL_SwapFloatBE(x) SwapOnlyIfNecessary(x) #elif SDL_BYTEORDER == SDL_LIL_ENDIAN #define SDL_Swap16LE(x) (x) #define SDL_Swap32LE(x) (x) #define SDL_Swap64LE(x) (x) #define SDL_SwapFloatLE(x) (x) #define SDL_Swap16BE(x) SDL_Swap16(x) #define SDL_Swap32BE(x) SDL_Swap32(x) #define SDL_Swap64BE(x) SDL_Swap64(x) #define SDL_SwapFloatBE(x) SDL_SwapFloat(x) #else #define SDL_Swap16LE(x) SDL_Swap16(x) #define SDL_Swap32LE(x) SDL_Swap32(x) #define SDL_Swap64LE(x) SDL_Swap64(x) #define SDL_SwapFloatLE(x) SDL_SwapFloat(x) #define SDL_Swap16BE(x) (x) #define SDL_Swap32BE(x) (x) #define SDL_Swap64BE(x) (x) #define SDL_SwapFloatBE(x) (x) #endif /* Ends C function definitions when using C++ */ #ifdef __cplusplus } #endif #include #endif /* SDL_endian_h_ */ ================================================ FILE: deps/include/SDL3/SDL_error.h ================================================ /* Simple DirectMedia Layer Copyright (C) 1997-2026 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ /** * # CategoryError * * Simple error message routines for SDL. * * Most apps will interface with these APIs in exactly one function: when * almost any SDL function call reports failure, you can get a human-readable * string of the problem from SDL_GetError(). * * These strings are maintained per-thread, and apps are welcome to set their * own errors, which is popular when building libraries on top of SDL for * other apps to consume. These strings are set by calling SDL_SetError(). * * A common usage pattern is to have a function that returns true for success * and false for failure, and do this when something fails: * * ```c * if (something_went_wrong) { * return SDL_SetError("The thing broke in this specific way: %d", errcode); * } * ``` * * It's also common to just return `false` in this case if the failing thing * is known to call SDL_SetError(), so errors simply propagate through. */ #ifndef SDL_error_h_ #define SDL_error_h_ #include #include /* Set up for C function definitions, even when using C++ */ #ifdef __cplusplus extern "C" { #endif /* Public functions */ /** * Set the SDL error message for the current thread. * * Calling this function will replace any previous error message that was set. * * This function always returns false, since SDL frequently uses false to * signify a failing result, leading to this idiom: * * ```c * if (error_code) { * return SDL_SetError("This operation has failed: %d", error_code); * } * ``` * * \param fmt a printf()-style message format string. * \param ... additional parameters matching % tokens in the `fmt` string, if * any. * \returns false. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_ClearError * \sa SDL_GetError * \sa SDL_SetErrorV */ extern SDL_DECLSPEC bool SDLCALL SDL_SetError(SDL_PRINTF_FORMAT_STRING const char *fmt, ...) SDL_PRINTF_VARARG_FUNC(1); /** * Set the SDL error message for the current thread. * * Calling this function will replace any previous error message that was set. * * \param fmt a printf()-style message format string. * \param ap a variable argument list. * \returns false. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_ClearError * \sa SDL_GetError * \sa SDL_SetError */ extern SDL_DECLSPEC bool SDLCALL SDL_SetErrorV(SDL_PRINTF_FORMAT_STRING const char *fmt, va_list ap) SDL_PRINTF_VARARG_FUNCV(1); /** * Set an error indicating that memory allocation failed. * * This function does not do any memory allocation. * * \returns false. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC bool SDLCALL SDL_OutOfMemory(void); /** * Retrieve a message about the last error that occurred on the current * thread. * * It is possible for multiple errors to occur before calling SDL_GetError(). * Only the last error is returned. * * The message is only applicable when an SDL function has signaled an error. * You must check the return values of SDL function calls to determine when to * appropriately call SDL_GetError(). You should *not* use the results of * SDL_GetError() to decide if an error has occurred! Sometimes SDL will set * an error string even when reporting success. * * SDL will *not* clear the error string for successful API calls. You *must* * check return values for failure cases before you can assume the error * string applies. * * Error strings are set per-thread, so an error set in a different thread * will not interfere with the current thread's operation. * * The returned value is a thread-local string which will remain valid until * the current thread's error string is changed. The caller should make a copy * if the value is needed after the next SDL API call. * * \returns a message with information about the specific error that occurred, * or an empty string if there hasn't been an error message set since * the last call to SDL_ClearError(). * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_ClearError * \sa SDL_SetError */ extern SDL_DECLSPEC const char * SDLCALL SDL_GetError(void); /** * Clear any previous error message for this thread. * * \returns true. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetError * \sa SDL_SetError */ extern SDL_DECLSPEC bool SDLCALL SDL_ClearError(void); /** * \name Internal error functions * * \internal * Private error reporting function - used internally. */ /* @{ */ /** * A macro to standardize error reporting on unsupported operations. * * This simply calls SDL_SetError() with a standardized error string, for * convenience, consistency, and clarity. * * \threadsafety It is safe to call this macro from any thread. * * \since This macro is available since SDL 3.2.0. */ #define SDL_Unsupported() SDL_SetError("That operation is not supported") /** * A macro to standardize error reporting on unsupported operations. * * This simply calls SDL_SetError() with a standardized error string, for * convenience, consistency, and clarity. * * A common usage pattern inside SDL is this: * * ```c * bool MyFunction(const char *str) { * if (!str) { * return SDL_InvalidParamError("str"); // returns false. * } * DoSomething(str); * return true; * } * ``` * * \threadsafety It is safe to call this macro from any thread. * * \since This macro is available since SDL 3.2.0. */ #define SDL_InvalidParamError(param) SDL_SetError("Parameter '%s' is invalid", (param)) /* @} *//* Internal error functions */ /* Ends C function definitions when using C++ */ #ifdef __cplusplus } #endif #include #endif /* SDL_error_h_ */ ================================================ FILE: deps/include/SDL3/SDL_events.h ================================================ /* Simple DirectMedia Layer Copyright (C) 1997-2026 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ /** * # CategoryEvents * * Event queue management. * * It's extremely common--often required--that an app deal with SDL's event * queue. Almost all useful information about interactions with the real world * flow through here: the user interacting with the computer and app, hardware * coming and going, the system changing in some way, etc. * * An app generally takes a moment, perhaps at the start of a new frame, to * examine any events that have occurred since the last time and process or * ignore them. This is generally done by calling SDL_PollEvent() in a loop * until it returns false (or, if using the main callbacks, events are * provided one at a time in calls to SDL_AppEvent() before the next call to * SDL_AppIterate(); in this scenario, the app does not call SDL_PollEvent() * at all). * * There is other forms of control, too: SDL_PeepEvents() has more * functionality at the cost of more complexity, and SDL_WaitEvent() can block * the process until something interesting happens, which might be beneficial * for certain types of programs on low-power hardware. One may also call * SDL_AddEventWatch() to set a callback when new events arrive. * * The app is free to generate their own events, too: SDL_PushEvent allows the * app to put events onto the queue for later retrieval; SDL_RegisterEvents * can guarantee that these events have a type that isn't in use by other * parts of the system. */ #ifndef SDL_events_h_ #define SDL_events_h_ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include /* Set up for C function definitions, even when using C++ */ #ifdef __cplusplus extern "C" { #endif /* General keyboard/mouse/pen state definitions */ /** * The types of events that can be delivered. * * \since This enum is available since SDL 3.2.0. */ typedef enum SDL_EventType { SDL_EVENT_FIRST = 0, /**< Unused (do not remove) */ /* Application events */ SDL_EVENT_QUIT = 0x100, /**< User-requested quit */ /* These application events have special meaning on iOS and Android, see README-ios.md and README-android.md for details */ SDL_EVENT_TERMINATING, /**< The application is being terminated by the OS. This event must be handled in a callback set with SDL_AddEventWatch(). Called on iOS in applicationWillTerminate() Called on Android in onDestroy() */ SDL_EVENT_LOW_MEMORY, /**< The application is low on memory, free memory if possible. This event must be handled in a callback set with SDL_AddEventWatch(). Called on iOS in applicationDidReceiveMemoryWarning() Called on Android in onTrimMemory() */ SDL_EVENT_WILL_ENTER_BACKGROUND, /**< The application is about to enter the background. This event must be handled in a callback set with SDL_AddEventWatch(). Called on iOS in applicationWillResignActive() Called on Android in onPause() */ SDL_EVENT_DID_ENTER_BACKGROUND, /**< The application did enter the background and may not get CPU for some time. This event must be handled in a callback set with SDL_AddEventWatch(). Called on iOS in applicationDidEnterBackground() Called on Android in onPause() */ SDL_EVENT_WILL_ENTER_FOREGROUND, /**< The application is about to enter the foreground. This event must be handled in a callback set with SDL_AddEventWatch(). Called on iOS in applicationWillEnterForeground() Called on Android in onResume() */ SDL_EVENT_DID_ENTER_FOREGROUND, /**< The application is now interactive. This event must be handled in a callback set with SDL_AddEventWatch(). Called on iOS in applicationDidBecomeActive() Called on Android in onResume() */ SDL_EVENT_LOCALE_CHANGED, /**< The user's locale preferences have changed. */ SDL_EVENT_SYSTEM_THEME_CHANGED, /**< The system theme changed */ /* Display events */ /* 0x150 was SDL_DISPLAYEVENT, reserve the number for sdl2-compat */ SDL_EVENT_DISPLAY_ORIENTATION = 0x151, /**< Display orientation has changed to data1 */ SDL_EVENT_DISPLAY_ADDED, /**< Display has been added to the system */ SDL_EVENT_DISPLAY_REMOVED, /**< Display has been removed from the system */ SDL_EVENT_DISPLAY_MOVED, /**< Display has changed position */ SDL_EVENT_DISPLAY_DESKTOP_MODE_CHANGED, /**< Display has changed desktop mode */ SDL_EVENT_DISPLAY_CURRENT_MODE_CHANGED, /**< Display has changed current mode */ SDL_EVENT_DISPLAY_CONTENT_SCALE_CHANGED, /**< Display has changed content scale */ SDL_EVENT_DISPLAY_USABLE_BOUNDS_CHANGED, /**< Display has changed usable bounds */ SDL_EVENT_DISPLAY_FIRST = SDL_EVENT_DISPLAY_ORIENTATION, SDL_EVENT_DISPLAY_LAST = SDL_EVENT_DISPLAY_USABLE_BOUNDS_CHANGED, /* Window events */ /* 0x200 was SDL_WINDOWEVENT, reserve the number for sdl2-compat */ /* 0x201 was SDL_SYSWMEVENT, reserve the number for sdl2-compat */ SDL_EVENT_WINDOW_SHOWN = 0x202, /**< Window has been shown */ SDL_EVENT_WINDOW_HIDDEN, /**< Window has been hidden */ SDL_EVENT_WINDOW_EXPOSED, /**< Window has been exposed and should be redrawn, and can be redrawn directly from event watchers for this event. data1 is 1 for live-resize expose events, 0 otherwise. */ SDL_EVENT_WINDOW_MOVED, /**< Window has been moved to data1, data2 */ SDL_EVENT_WINDOW_RESIZED, /**< Window has been resized to data1xdata2 */ SDL_EVENT_WINDOW_PIXEL_SIZE_CHANGED,/**< The pixel size of the window has changed to data1xdata2 */ SDL_EVENT_WINDOW_METAL_VIEW_RESIZED,/**< The pixel size of a Metal view associated with the window has changed */ SDL_EVENT_WINDOW_MINIMIZED, /**< Window has been minimized */ SDL_EVENT_WINDOW_MAXIMIZED, /**< Window has been maximized */ SDL_EVENT_WINDOW_RESTORED, /**< Window has been restored to normal size and position */ SDL_EVENT_WINDOW_MOUSE_ENTER, /**< Window has gained mouse focus */ SDL_EVENT_WINDOW_MOUSE_LEAVE, /**< Window has lost mouse focus */ SDL_EVENT_WINDOW_FOCUS_GAINED, /**< Window has gained keyboard focus */ SDL_EVENT_WINDOW_FOCUS_LOST, /**< Window has lost keyboard focus */ SDL_EVENT_WINDOW_CLOSE_REQUESTED, /**< The window manager requests that the window be closed */ SDL_EVENT_WINDOW_HIT_TEST, /**< Window had a hit test that wasn't SDL_HITTEST_NORMAL */ SDL_EVENT_WINDOW_ICCPROF_CHANGED, /**< The ICC profile of the window's display has changed */ SDL_EVENT_WINDOW_DISPLAY_CHANGED, /**< Window has been moved to display data1 */ SDL_EVENT_WINDOW_DISPLAY_SCALE_CHANGED, /**< Window display scale has been changed */ SDL_EVENT_WINDOW_SAFE_AREA_CHANGED, /**< The window safe area has been changed */ SDL_EVENT_WINDOW_OCCLUDED, /**< The window has been occluded */ SDL_EVENT_WINDOW_ENTER_FULLSCREEN, /**< The window has entered fullscreen mode */ SDL_EVENT_WINDOW_LEAVE_FULLSCREEN, /**< The window has left fullscreen mode */ SDL_EVENT_WINDOW_DESTROYED, /**< The window with the associated ID is being or has been destroyed. If this message is being handled in an event watcher, the window handle is still valid and can still be used to retrieve any properties associated with the window. Otherwise, the handle has already been destroyed and all resources associated with it are invalid */ SDL_EVENT_WINDOW_HDR_STATE_CHANGED, /**< Window HDR properties have changed */ SDL_EVENT_WINDOW_FIRST = SDL_EVENT_WINDOW_SHOWN, SDL_EVENT_WINDOW_LAST = SDL_EVENT_WINDOW_HDR_STATE_CHANGED, /* Keyboard events */ SDL_EVENT_KEY_DOWN = 0x300, /**< Key pressed */ SDL_EVENT_KEY_UP, /**< Key released */ SDL_EVENT_TEXT_EDITING, /**< Keyboard text editing (composition) */ SDL_EVENT_TEXT_INPUT, /**< Keyboard text input */ SDL_EVENT_KEYMAP_CHANGED, /**< Keymap changed due to a system event such as an input language or keyboard layout change. */ SDL_EVENT_KEYBOARD_ADDED, /**< A new keyboard has been inserted into the system */ SDL_EVENT_KEYBOARD_REMOVED, /**< A keyboard has been removed */ SDL_EVENT_TEXT_EDITING_CANDIDATES, /**< Keyboard text editing candidates */ SDL_EVENT_SCREEN_KEYBOARD_SHOWN, /**< The on-screen keyboard has been shown */ SDL_EVENT_SCREEN_KEYBOARD_HIDDEN, /**< The on-screen keyboard has been hidden */ /* Mouse events */ SDL_EVENT_MOUSE_MOTION = 0x400, /**< Mouse moved */ SDL_EVENT_MOUSE_BUTTON_DOWN, /**< Mouse button pressed */ SDL_EVENT_MOUSE_BUTTON_UP, /**< Mouse button released */ SDL_EVENT_MOUSE_WHEEL, /**< Mouse wheel motion */ SDL_EVENT_MOUSE_ADDED, /**< A new mouse has been inserted into the system */ SDL_EVENT_MOUSE_REMOVED, /**< A mouse has been removed */ /* Joystick events */ SDL_EVENT_JOYSTICK_AXIS_MOTION = 0x600, /**< Joystick axis motion */ SDL_EVENT_JOYSTICK_BALL_MOTION, /**< Joystick trackball motion */ SDL_EVENT_JOYSTICK_HAT_MOTION, /**< Joystick hat position change */ SDL_EVENT_JOYSTICK_BUTTON_DOWN, /**< Joystick button pressed */ SDL_EVENT_JOYSTICK_BUTTON_UP, /**< Joystick button released */ SDL_EVENT_JOYSTICK_ADDED, /**< A new joystick has been inserted into the system */ SDL_EVENT_JOYSTICK_REMOVED, /**< An opened joystick has been removed */ SDL_EVENT_JOYSTICK_BATTERY_UPDATED, /**< Joystick battery level change */ SDL_EVENT_JOYSTICK_UPDATE_COMPLETE, /**< Joystick update is complete */ /* Gamepad events */ SDL_EVENT_GAMEPAD_AXIS_MOTION = 0x650, /**< Gamepad axis motion */ SDL_EVENT_GAMEPAD_BUTTON_DOWN, /**< Gamepad button pressed */ SDL_EVENT_GAMEPAD_BUTTON_UP, /**< Gamepad button released */ SDL_EVENT_GAMEPAD_ADDED, /**< A new gamepad has been inserted into the system */ SDL_EVENT_GAMEPAD_REMOVED, /**< A gamepad has been removed */ SDL_EVENT_GAMEPAD_REMAPPED, /**< The gamepad mapping was updated */ SDL_EVENT_GAMEPAD_TOUCHPAD_DOWN, /**< Gamepad touchpad was touched */ SDL_EVENT_GAMEPAD_TOUCHPAD_MOTION, /**< Gamepad touchpad finger was moved */ SDL_EVENT_GAMEPAD_TOUCHPAD_UP, /**< Gamepad touchpad finger was lifted */ SDL_EVENT_GAMEPAD_SENSOR_UPDATE, /**< Gamepad sensor was updated */ SDL_EVENT_GAMEPAD_UPDATE_COMPLETE, /**< Gamepad update is complete */ SDL_EVENT_GAMEPAD_STEAM_HANDLE_UPDATED, /**< Gamepad Steam handle has changed */ /* Touch events */ SDL_EVENT_FINGER_DOWN = 0x700, SDL_EVENT_FINGER_UP, SDL_EVENT_FINGER_MOTION, SDL_EVENT_FINGER_CANCELED, /* Pinch events */ SDL_EVENT_PINCH_BEGIN = 0x710, /**< Pinch gesture started */ SDL_EVENT_PINCH_UPDATE, /**< Pinch gesture updated */ SDL_EVENT_PINCH_END, /**< Pinch gesture ended */ /* 0x800, 0x801, and 0x802 were the Gesture events from SDL2. Do not reuse these values! sdl2-compat needs them! */ /* Clipboard events */ SDL_EVENT_CLIPBOARD_UPDATE = 0x900, /**< The clipboard changed */ /* Drag and drop events */ SDL_EVENT_DROP_FILE = 0x1000, /**< The system requests a file open */ SDL_EVENT_DROP_TEXT, /**< text/plain drag-and-drop event */ SDL_EVENT_DROP_BEGIN, /**< A new set of drops is beginning (NULL filename) */ SDL_EVENT_DROP_COMPLETE, /**< Current set of drops is now complete (NULL filename) */ SDL_EVENT_DROP_POSITION, /**< Position while moving over the window */ /* Audio hotplug events */ SDL_EVENT_AUDIO_DEVICE_ADDED = 0x1100, /**< A new audio device is available */ SDL_EVENT_AUDIO_DEVICE_REMOVED, /**< An audio device has been removed. */ SDL_EVENT_AUDIO_DEVICE_FORMAT_CHANGED, /**< An audio device's format has been changed by the system. */ /* Sensor events */ SDL_EVENT_SENSOR_UPDATE = 0x1200, /**< A sensor was updated */ /* Pressure-sensitive pen events */ SDL_EVENT_PEN_PROXIMITY_IN = 0x1300, /**< Pressure-sensitive pen has become available */ SDL_EVENT_PEN_PROXIMITY_OUT, /**< Pressure-sensitive pen has become unavailable */ SDL_EVENT_PEN_DOWN, /**< Pressure-sensitive pen touched drawing surface */ SDL_EVENT_PEN_UP, /**< Pressure-sensitive pen stopped touching drawing surface */ SDL_EVENT_PEN_BUTTON_DOWN, /**< Pressure-sensitive pen button pressed */ SDL_EVENT_PEN_BUTTON_UP, /**< Pressure-sensitive pen button released */ SDL_EVENT_PEN_MOTION, /**< Pressure-sensitive pen is moving on the tablet */ SDL_EVENT_PEN_AXIS, /**< Pressure-sensitive pen angle/pressure/etc changed */ /* Camera hotplug events */ SDL_EVENT_CAMERA_DEVICE_ADDED = 0x1400, /**< A new camera device is available */ SDL_EVENT_CAMERA_DEVICE_REMOVED, /**< A camera device has been removed. */ SDL_EVENT_CAMERA_DEVICE_APPROVED, /**< A camera device has been approved for use by the user. */ SDL_EVENT_CAMERA_DEVICE_DENIED, /**< A camera device has been denied for use by the user. */ /* Render events */ SDL_EVENT_RENDER_TARGETS_RESET = 0x2000, /**< The render targets have been reset and their contents need to be updated */ SDL_EVENT_RENDER_DEVICE_RESET, /**< The device has been reset and all textures need to be recreated */ SDL_EVENT_RENDER_DEVICE_LOST, /**< The device has been lost and can't be recovered. */ /* Reserved events for private platforms */ SDL_EVENT_PRIVATE0 = 0x4000, SDL_EVENT_PRIVATE1, SDL_EVENT_PRIVATE2, SDL_EVENT_PRIVATE3, /* Internal events */ SDL_EVENT_POLL_SENTINEL = 0x7F00, /**< Signals the end of an event poll cycle */ /** Events SDL_EVENT_USER through SDL_EVENT_LAST are for your use, * and should be allocated with SDL_RegisterEvents() */ SDL_EVENT_USER = 0x8000, /** * This last event is only for bounding internal arrays */ SDL_EVENT_LAST = 0xFFFF, /* This just makes sure the enum is the size of Uint32 */ SDL_EVENT_ENUM_PADDING = 0x7FFFFFFF } SDL_EventType; /** * Fields shared by every event * * \since This struct is available since SDL 3.2.0. */ typedef struct SDL_CommonEvent { Uint32 type; /**< Event type, shared with all events, Uint32 to cover user events which are not in the SDL_EventType enumeration */ Uint32 reserved; Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */ } SDL_CommonEvent; /** * Display state change event data (event.display.*) * * \since This struct is available since SDL 3.2.0. */ typedef struct SDL_DisplayEvent { SDL_EventType type; /**< SDL_EVENT_DISPLAY_* */ Uint32 reserved; Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */ SDL_DisplayID displayID;/**< The associated display */ Sint32 data1; /**< event dependent data */ Sint32 data2; /**< event dependent data */ } SDL_DisplayEvent; /** * Window state change event data (event.window.*) * * \since This struct is available since SDL 3.2.0. */ typedef struct SDL_WindowEvent { SDL_EventType type; /**< SDL_EVENT_WINDOW_* */ Uint32 reserved; Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */ SDL_WindowID windowID; /**< The associated window */ Sint32 data1; /**< event dependent data */ Sint32 data2; /**< event dependent data */ } SDL_WindowEvent; /** * Keyboard device event structure (event.kdevice.*) * * \since This struct is available since SDL 3.2.0. */ typedef struct SDL_KeyboardDeviceEvent { SDL_EventType type; /**< SDL_EVENT_KEYBOARD_ADDED or SDL_EVENT_KEYBOARD_REMOVED */ Uint32 reserved; Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */ SDL_KeyboardID which; /**< The keyboard instance id */ } SDL_KeyboardDeviceEvent; /** * Keyboard button event structure (event.key.*) * * The `key` is the base SDL_Keycode generated by pressing the `scancode` * using the current keyboard layout, applying any options specified in * SDL_HINT_KEYCODE_OPTIONS. You can get the SDL_Keycode corresponding to the * event scancode and modifiers directly from the keyboard layout, bypassing * SDL_HINT_KEYCODE_OPTIONS, by calling SDL_GetKeyFromScancode(). * * \since This struct is available since SDL 3.2.0. * * \sa SDL_GetKeyFromScancode * \sa SDL_HINT_KEYCODE_OPTIONS */ typedef struct SDL_KeyboardEvent { SDL_EventType type; /**< SDL_EVENT_KEY_DOWN or SDL_EVENT_KEY_UP */ Uint32 reserved; Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */ SDL_WindowID windowID; /**< The window with keyboard focus, if any */ SDL_KeyboardID which; /**< The keyboard instance id, or 0 if unknown or virtual */ SDL_Scancode scancode; /**< SDL physical key code */ SDL_Keycode key; /**< SDL virtual key code */ SDL_Keymod mod; /**< current key modifiers */ Uint16 raw; /**< The platform dependent scancode for this event */ bool down; /**< true if the key is pressed */ bool repeat; /**< true if this is a key repeat */ } SDL_KeyboardEvent; /** * Keyboard text editing event structure (event.edit.*) * * The start cursor is the position, in UTF-8 characters, where new typing * will be inserted into the editing text. The length is the number of UTF-8 * characters that will be replaced by new typing. * * \since This struct is available since SDL 3.2.0. */ typedef struct SDL_TextEditingEvent { SDL_EventType type; /**< SDL_EVENT_TEXT_EDITING */ Uint32 reserved; Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */ SDL_WindowID windowID; /**< The window with keyboard focus, if any */ const char *text; /**< The editing text */ Sint32 start; /**< The start cursor of selected editing text, or -1 if not set */ Sint32 length; /**< The length of selected editing text, or -1 if not set */ } SDL_TextEditingEvent; /** * Keyboard IME candidates event structure (event.edit_candidates.*) * * \since This struct is available since SDL 3.2.0. */ typedef struct SDL_TextEditingCandidatesEvent { SDL_EventType type; /**< SDL_EVENT_TEXT_EDITING_CANDIDATES */ Uint32 reserved; Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */ SDL_WindowID windowID; /**< The window with keyboard focus, if any */ const char * const *candidates; /**< The list of candidates, or NULL if there are no candidates available */ Sint32 num_candidates; /**< The number of strings in `candidates` */ Sint32 selected_candidate; /**< The index of the selected candidate, or -1 if no candidate is selected */ bool horizontal; /**< true if the list is horizontal, false if it's vertical */ Uint8 padding1; Uint8 padding2; Uint8 padding3; } SDL_TextEditingCandidatesEvent; /** * Keyboard text input event structure (event.text.*) * * This event will never be delivered unless text input is enabled by calling * SDL_StartTextInput(). Text input is disabled by default! * * \since This struct is available since SDL 3.2.0. * * \sa SDL_StartTextInput * \sa SDL_StopTextInput */ typedef struct SDL_TextInputEvent { SDL_EventType type; /**< SDL_EVENT_TEXT_INPUT */ Uint32 reserved; Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */ SDL_WindowID windowID; /**< The window with keyboard focus, if any */ const char *text; /**< The input text, UTF-8 encoded */ } SDL_TextInputEvent; /** * Mouse device event structure (event.mdevice.*) * * \since This struct is available since SDL 3.2.0. */ typedef struct SDL_MouseDeviceEvent { SDL_EventType type; /**< SDL_EVENT_MOUSE_ADDED or SDL_EVENT_MOUSE_REMOVED */ Uint32 reserved; Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */ SDL_MouseID which; /**< The mouse instance id */ } SDL_MouseDeviceEvent; /** * Mouse motion event structure (event.motion.*) * * \since This struct is available since SDL 3.2.0. */ typedef struct SDL_MouseMotionEvent { SDL_EventType type; /**< SDL_EVENT_MOUSE_MOTION */ Uint32 reserved; Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */ SDL_WindowID windowID; /**< The window with mouse focus, if any */ SDL_MouseID which; /**< The mouse instance id in relative mode, SDL_TOUCH_MOUSEID for touch events, or 0 */ SDL_MouseButtonFlags state; /**< The current button state */ float x; /**< X coordinate, relative to window */ float y; /**< Y coordinate, relative to window */ float xrel; /**< The relative motion in the X direction */ float yrel; /**< The relative motion in the Y direction */ } SDL_MouseMotionEvent; /** * Mouse button event structure (event.button.*) * * \since This struct is available since SDL 3.2.0. */ typedef struct SDL_MouseButtonEvent { SDL_EventType type; /**< SDL_EVENT_MOUSE_BUTTON_DOWN or SDL_EVENT_MOUSE_BUTTON_UP */ Uint32 reserved; Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */ SDL_WindowID windowID; /**< The window with mouse focus, if any */ SDL_MouseID which; /**< The mouse instance id in relative mode, SDL_TOUCH_MOUSEID for touch events, or 0 */ Uint8 button; /**< The mouse button index */ bool down; /**< true if the button is pressed */ Uint8 clicks; /**< 1 for single-click, 2 for double-click, etc. */ Uint8 padding; float x; /**< X coordinate, relative to window */ float y; /**< Y coordinate, relative to window */ } SDL_MouseButtonEvent; /** * Mouse wheel event structure (event.wheel.*) * * \since This struct is available since SDL 3.2.0. */ typedef struct SDL_MouseWheelEvent { SDL_EventType type; /**< SDL_EVENT_MOUSE_WHEEL */ Uint32 reserved; Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */ SDL_WindowID windowID; /**< The window with mouse focus, if any */ SDL_MouseID which; /**< The mouse instance id in relative mode or 0 */ float x; /**< The amount scrolled horizontally, positive to the right and negative to the left */ float y; /**< The amount scrolled vertically, positive away from the user and negative toward the user */ SDL_MouseWheelDirection direction; /**< Set to one of the SDL_MOUSEWHEEL_* defines. When FLIPPED the values in X and Y will be opposite. Multiply by -1 to change them back */ float mouse_x; /**< X coordinate, relative to window */ float mouse_y; /**< Y coordinate, relative to window */ Sint32 integer_x; /**< The amount scrolled horizontally, accumulated to whole scroll "ticks" (added in 3.2.12) */ Sint32 integer_y; /**< The amount scrolled vertically, accumulated to whole scroll "ticks" (added in 3.2.12) */ } SDL_MouseWheelEvent; /** * Joystick axis motion event structure (event.jaxis.*) * * \since This struct is available since SDL 3.2.0. */ typedef struct SDL_JoyAxisEvent { SDL_EventType type; /**< SDL_EVENT_JOYSTICK_AXIS_MOTION */ Uint32 reserved; Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */ SDL_JoystickID which; /**< The joystick instance id */ Uint8 axis; /**< The joystick axis index */ Uint8 padding1; Uint8 padding2; Uint8 padding3; Sint16 value; /**< The axis value (range: -32768 to 32767) */ Uint16 padding4; } SDL_JoyAxisEvent; /** * Joystick trackball motion event structure (event.jball.*) * * \since This struct is available since SDL 3.2.0. */ typedef struct SDL_JoyBallEvent { SDL_EventType type; /**< SDL_EVENT_JOYSTICK_BALL_MOTION */ Uint32 reserved; Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */ SDL_JoystickID which; /**< The joystick instance id */ Uint8 ball; /**< The joystick trackball index */ Uint8 padding1; Uint8 padding2; Uint8 padding3; Sint16 xrel; /**< The relative motion in the X direction */ Sint16 yrel; /**< The relative motion in the Y direction */ } SDL_JoyBallEvent; /** * Joystick hat position change event structure (event.jhat.*) * * \since This struct is available since SDL 3.2.0. */ typedef struct SDL_JoyHatEvent { SDL_EventType type; /**< SDL_EVENT_JOYSTICK_HAT_MOTION */ Uint32 reserved; Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */ SDL_JoystickID which; /**< The joystick instance id */ Uint8 hat; /**< The joystick hat index */ Uint8 value; /**< The hat position value. * \sa SDL_HAT_LEFTUP SDL_HAT_UP SDL_HAT_RIGHTUP * \sa SDL_HAT_LEFT SDL_HAT_CENTERED SDL_HAT_RIGHT * \sa SDL_HAT_LEFTDOWN SDL_HAT_DOWN SDL_HAT_RIGHTDOWN * * Note that zero means the POV is centered. */ Uint8 padding1; Uint8 padding2; } SDL_JoyHatEvent; /** * Joystick button event structure (event.jbutton.*) * * \since This struct is available since SDL 3.2.0. */ typedef struct SDL_JoyButtonEvent { SDL_EventType type; /**< SDL_EVENT_JOYSTICK_BUTTON_DOWN or SDL_EVENT_JOYSTICK_BUTTON_UP */ Uint32 reserved; Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */ SDL_JoystickID which; /**< The joystick instance id */ Uint8 button; /**< The joystick button index */ bool down; /**< true if the button is pressed */ Uint8 padding1; Uint8 padding2; } SDL_JoyButtonEvent; /** * Joystick device event structure (event.jdevice.*) * * SDL will send JOYSTICK_ADDED events for devices that are already plugged in * during SDL_Init. * * \since This struct is available since SDL 3.2.0. * * \sa SDL_GamepadDeviceEvent */ typedef struct SDL_JoyDeviceEvent { SDL_EventType type; /**< SDL_EVENT_JOYSTICK_ADDED or SDL_EVENT_JOYSTICK_REMOVED or SDL_EVENT_JOYSTICK_UPDATE_COMPLETE */ Uint32 reserved; Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */ SDL_JoystickID which; /**< The joystick instance id */ } SDL_JoyDeviceEvent; /** * Joystick battery level change event structure (event.jbattery.*) * * \since This struct is available since SDL 3.2.0. */ typedef struct SDL_JoyBatteryEvent { SDL_EventType type; /**< SDL_EVENT_JOYSTICK_BATTERY_UPDATED */ Uint32 reserved; Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */ SDL_JoystickID which; /**< The joystick instance id */ SDL_PowerState state; /**< The joystick battery state */ int percent; /**< The joystick battery percent charge remaining */ } SDL_JoyBatteryEvent; /** * Gamepad axis motion event structure (event.gaxis.*) * * \since This struct is available since SDL 3.2.0. */ typedef struct SDL_GamepadAxisEvent { SDL_EventType type; /**< SDL_EVENT_GAMEPAD_AXIS_MOTION */ Uint32 reserved; Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */ SDL_JoystickID which; /**< The joystick instance id */ Uint8 axis; /**< The gamepad axis (SDL_GamepadAxis) */ Uint8 padding1; Uint8 padding2; Uint8 padding3; Sint16 value; /**< The axis value (range: -32768 to 32767) */ Uint16 padding4; } SDL_GamepadAxisEvent; /** * Gamepad button event structure (event.gbutton.*) * * \since This struct is available since SDL 3.2.0. */ typedef struct SDL_GamepadButtonEvent { SDL_EventType type; /**< SDL_EVENT_GAMEPAD_BUTTON_DOWN or SDL_EVENT_GAMEPAD_BUTTON_UP */ Uint32 reserved; Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */ SDL_JoystickID which; /**< The joystick instance id */ Uint8 button; /**< The gamepad button (SDL_GamepadButton) */ bool down; /**< true if the button is pressed */ Uint8 padding1; Uint8 padding2; } SDL_GamepadButtonEvent; /** * Gamepad device event structure (event.gdevice.*) * * Joysticks that are supported gamepads receive both an SDL_JoyDeviceEvent * and an SDL_GamepadDeviceEvent. * * SDL will send GAMEPAD_ADDED events for joysticks that are already plugged * in during SDL_Init() and are recognized as gamepads. It will also send * events for joysticks that get gamepad mappings at runtime. * * \since This struct is available since SDL 3.2.0. * * \sa SDL_JoyDeviceEvent */ typedef struct SDL_GamepadDeviceEvent { SDL_EventType type; /**< SDL_EVENT_GAMEPAD_ADDED, SDL_EVENT_GAMEPAD_REMOVED, or SDL_EVENT_GAMEPAD_REMAPPED, SDL_EVENT_GAMEPAD_UPDATE_COMPLETE or SDL_EVENT_GAMEPAD_STEAM_HANDLE_UPDATED */ Uint32 reserved; Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */ SDL_JoystickID which; /**< The joystick instance id */ } SDL_GamepadDeviceEvent; /** * Gamepad touchpad event structure (event.gtouchpad.*) * * \since This struct is available since SDL 3.2.0. */ typedef struct SDL_GamepadTouchpadEvent { SDL_EventType type; /**< SDL_EVENT_GAMEPAD_TOUCHPAD_DOWN or SDL_EVENT_GAMEPAD_TOUCHPAD_MOTION or SDL_EVENT_GAMEPAD_TOUCHPAD_UP */ Uint32 reserved; Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */ SDL_JoystickID which; /**< The joystick instance id */ Sint32 touchpad; /**< The index of the touchpad */ Sint32 finger; /**< The index of the finger on the touchpad */ float x; /**< Normalized in the range 0...1 with 0 being on the left */ float y; /**< Normalized in the range 0...1 with 0 being at the top */ float pressure; /**< Normalized in the range 0...1 */ } SDL_GamepadTouchpadEvent; /** * Gamepad sensor event structure (event.gsensor.*) * * \since This struct is available since SDL 3.2.0. */ typedef struct SDL_GamepadSensorEvent { SDL_EventType type; /**< SDL_EVENT_GAMEPAD_SENSOR_UPDATE */ Uint32 reserved; Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */ SDL_JoystickID which; /**< The joystick instance id */ Sint32 sensor; /**< The type of the sensor, one of the values of SDL_SensorType */ float data[3]; /**< Up to 3 values from the sensor, as defined in SDL_sensor.h */ Uint64 sensor_timestamp; /**< The timestamp of the sensor reading in nanoseconds, not necessarily synchronized with the system clock */ } SDL_GamepadSensorEvent; /** * Audio device event structure (event.adevice.*) * * Note that SDL will send a SDL_EVENT_AUDIO_DEVICE_ADDED event for every * device it discovers during initialization. After that, this event will only * arrive when a device is hotplugged during the program's run. * * \since This struct is available since SDL 3.2.0. */ typedef struct SDL_AudioDeviceEvent { SDL_EventType type; /**< SDL_EVENT_AUDIO_DEVICE_ADDED, or SDL_EVENT_AUDIO_DEVICE_REMOVED, or SDL_EVENT_AUDIO_DEVICE_FORMAT_CHANGED */ Uint32 reserved; Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */ SDL_AudioDeviceID which; /**< SDL_AudioDeviceID for the device being added or removed or changing */ bool recording; /**< false if a playback device, true if a recording device. */ Uint8 padding1; Uint8 padding2; Uint8 padding3; } SDL_AudioDeviceEvent; /** * Camera device event structure (event.cdevice.*) * * \since This struct is available since SDL 3.2.0. */ typedef struct SDL_CameraDeviceEvent { SDL_EventType type; /**< SDL_EVENT_CAMERA_DEVICE_ADDED, SDL_EVENT_CAMERA_DEVICE_REMOVED, SDL_EVENT_CAMERA_DEVICE_APPROVED, SDL_EVENT_CAMERA_DEVICE_DENIED */ Uint32 reserved; Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */ SDL_CameraID which; /**< SDL_CameraID for the device being added or removed or changing */ } SDL_CameraDeviceEvent; /** * Renderer event structure (event.render.*) * * \since This struct is available since SDL 3.2.0. */ typedef struct SDL_RenderEvent { SDL_EventType type; /**< SDL_EVENT_RENDER_TARGETS_RESET, SDL_EVENT_RENDER_DEVICE_RESET, SDL_EVENT_RENDER_DEVICE_LOST */ Uint32 reserved; Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */ SDL_WindowID windowID; /**< The window containing the renderer in question. */ } SDL_RenderEvent; /** * Touch finger event structure (event.tfinger.*) * * Coordinates in this event are normalized. `x` and `y` are normalized to a * range between 0.0f and 1.0f, relative to the window, so (0,0) is the top * left and (1,1) is the bottom right. Delta coordinates `dx` and `dy` are * normalized in the ranges of -1.0f (traversed all the way from the bottom or * right to all the way up or left) to 1.0f (traversed all the way from the * top or left to all the way down or right). * * Note that while the coordinates are _normalized_, they are not _clamped_, * which means in some circumstances you can get a value outside of this * range. For example, a renderer using logical presentation might give a * negative value when the touch is in the letterboxing. Some platforms might * report a touch outside of the window, which will also be outside of the * range. * * \since This struct is available since SDL 3.2.0. */ typedef struct SDL_TouchFingerEvent { SDL_EventType type; /**< SDL_EVENT_FINGER_DOWN, SDL_EVENT_FINGER_UP, SDL_EVENT_FINGER_MOTION, or SDL_EVENT_FINGER_CANCELED */ Uint32 reserved; Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */ SDL_TouchID touchID; /**< The touch device id */ SDL_FingerID fingerID; float x; /**< Normalized in the range 0...1 */ float y; /**< Normalized in the range 0...1 */ float dx; /**< Normalized in the range -1...1 */ float dy; /**< Normalized in the range -1...1 */ float pressure; /**< Normalized in the range 0...1 */ SDL_WindowID windowID; /**< The window underneath the finger, if any */ } SDL_TouchFingerEvent; /** * Pinch event structure (event.pinch.*) */ typedef struct SDL_PinchFingerEvent { SDL_EventType type; /**< ::SDL_EVENT_PINCH_BEGIN or ::SDL_EVENT_PINCH_UPDATE or ::SDL_EVENT_PINCH_END */ Uint32 reserved; Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */ float scale; /**< The scale change since the last SDL_EVENT_PINCH_UPDATE. Scale < 1 is "zoom out". Scale > 1 is "zoom in". */ SDL_WindowID windowID; /**< The window underneath the finger, if any */ } SDL_PinchFingerEvent; /** * Pressure-sensitive pen proximity event structure (event.pproximity.*) * * When a pen becomes visible to the system (it is close enough to a tablet, * etc), SDL will send an SDL_EVENT_PEN_PROXIMITY_IN event with the new pen's * ID. This ID is valid until the pen leaves proximity again (has been removed * from the tablet's area, the tablet has been unplugged, etc). If the same * pen reenters proximity again, it will be given a new ID. * * Note that "proximity" means "close enough for the tablet to know the tool * is there." The pen touching and lifting off from the tablet while not * leaving the area are handled by SDL_EVENT_PEN_DOWN and SDL_EVENT_PEN_UP. * * Not all platforms have a window associated with the pen during proximity * events. Some wait until motion/button/etc events to offer this info. * * \since This struct is available since SDL 3.2.0. */ typedef struct SDL_PenProximityEvent { SDL_EventType type; /**< SDL_EVENT_PEN_PROXIMITY_IN or SDL_EVENT_PEN_PROXIMITY_OUT */ Uint32 reserved; Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */ SDL_WindowID windowID; /**< The window with pen focus, if any */ SDL_PenID which; /**< The pen instance id */ } SDL_PenProximityEvent; /** * Pressure-sensitive pen motion event structure (event.pmotion.*) * * Depending on the hardware, you may get motion events when the pen is not * touching a tablet, for tracking a pen even when it isn't drawing. You * should listen for SDL_EVENT_PEN_DOWN and SDL_EVENT_PEN_UP events, or check * `pen_state & SDL_PEN_INPUT_DOWN` to decide if a pen is "drawing" when * dealing with pen motion. * * \since This struct is available since SDL 3.2.0. */ typedef struct SDL_PenMotionEvent { SDL_EventType type; /**< SDL_EVENT_PEN_MOTION */ Uint32 reserved; Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */ SDL_WindowID windowID; /**< The window with pen focus, if any */ SDL_PenID which; /**< The pen instance id */ SDL_PenInputFlags pen_state; /**< Complete pen input state at time of event */ float x; /**< X coordinate, relative to window */ float y; /**< Y coordinate, relative to window */ } SDL_PenMotionEvent; /** * Pressure-sensitive pen touched event structure (event.ptouch.*) * * These events come when a pen touches a surface (a tablet, etc), or lifts * off from one. * * \since This struct is available since SDL 3.2.0. */ typedef struct SDL_PenTouchEvent { SDL_EventType type; /**< SDL_EVENT_PEN_DOWN or SDL_EVENT_PEN_UP */ Uint32 reserved; Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */ SDL_WindowID windowID; /**< The window with pen focus, if any */ SDL_PenID which; /**< The pen instance id */ SDL_PenInputFlags pen_state; /**< Complete pen input state at time of event */ float x; /**< X coordinate, relative to window */ float y; /**< Y coordinate, relative to window */ bool eraser; /**< true if eraser end is used (not all pens support this). */ bool down; /**< true if the pen is touching or false if the pen is lifted off */ } SDL_PenTouchEvent; /** * Pressure-sensitive pen button event structure (event.pbutton.*) * * This is for buttons on the pen itself that the user might click. The pen * itself pressing down to draw triggers a SDL_EVENT_PEN_DOWN event instead. * * \since This struct is available since SDL 3.2.0. */ typedef struct SDL_PenButtonEvent { SDL_EventType type; /**< SDL_EVENT_PEN_BUTTON_DOWN or SDL_EVENT_PEN_BUTTON_UP */ Uint32 reserved; Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */ SDL_WindowID windowID; /**< The window with mouse focus, if any */ SDL_PenID which; /**< The pen instance id */ SDL_PenInputFlags pen_state; /**< Complete pen input state at time of event */ float x; /**< X coordinate, relative to window */ float y; /**< Y coordinate, relative to window */ Uint8 button; /**< The pen button index (first button is 1). */ bool down; /**< true if the button is pressed */ } SDL_PenButtonEvent; /** * Pressure-sensitive pen pressure / angle event structure (event.paxis.*) * * You might get some of these events even if the pen isn't touching the * tablet. * * \since This struct is available since SDL 3.2.0. */ typedef struct SDL_PenAxisEvent { SDL_EventType type; /**< SDL_EVENT_PEN_AXIS */ Uint32 reserved; Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */ SDL_WindowID windowID; /**< The window with pen focus, if any */ SDL_PenID which; /**< The pen instance id */ SDL_PenInputFlags pen_state; /**< Complete pen input state at time of event */ float x; /**< X coordinate, relative to window */ float y; /**< Y coordinate, relative to window */ SDL_PenAxis axis; /**< Axis that has changed */ float value; /**< New value of axis */ } SDL_PenAxisEvent; /** * An event used to drop text or request a file open by the system * (event.drop.*) * * \since This struct is available since SDL 3.2.0. */ typedef struct SDL_DropEvent { SDL_EventType type; /**< SDL_EVENT_DROP_BEGIN or SDL_EVENT_DROP_FILE or SDL_EVENT_DROP_TEXT or SDL_EVENT_DROP_COMPLETE or SDL_EVENT_DROP_POSITION */ Uint32 reserved; Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */ SDL_WindowID windowID; /**< The window that was dropped on, if any */ float x; /**< X coordinate, relative to window (not on begin) */ float y; /**< Y coordinate, relative to window (not on begin) */ const char *source; /**< The source app that sent this drop event, or NULL if that isn't available */ const char *data; /**< The text for SDL_EVENT_DROP_TEXT and the file name for SDL_EVENT_DROP_FILE, NULL for other events */ } SDL_DropEvent; /** * An event triggered when the clipboard contents have changed * (event.clipboard.*) * * \since This struct is available since SDL 3.2.0. */ typedef struct SDL_ClipboardEvent { SDL_EventType type; /**< SDL_EVENT_CLIPBOARD_UPDATE */ Uint32 reserved; Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */ bool owner; /**< are we owning the clipboard (internal update) */ Sint32 num_mime_types; /**< number of mime types */ const char **mime_types; /**< current mime types */ } SDL_ClipboardEvent; /** * Sensor event structure (event.sensor.*) * * \since This struct is available since SDL 3.2.0. */ typedef struct SDL_SensorEvent { SDL_EventType type; /**< SDL_EVENT_SENSOR_UPDATE */ Uint32 reserved; Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */ SDL_SensorID which; /**< The instance ID of the sensor */ float data[6]; /**< Up to 6 values from the sensor - additional values can be queried using SDL_GetSensorData() */ Uint64 sensor_timestamp; /**< The timestamp of the sensor reading in nanoseconds, not necessarily synchronized with the system clock */ } SDL_SensorEvent; /** * The "quit requested" event * * \since This struct is available since SDL 3.2.0. */ typedef struct SDL_QuitEvent { SDL_EventType type; /**< SDL_EVENT_QUIT */ Uint32 reserved; Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */ } SDL_QuitEvent; /** * A user-defined event type (event.user.*) * * This event is unique; it is never created by SDL, but only by the * application. The event can be pushed onto the event queue using * SDL_PushEvent(). The contents of the structure members are completely up to * the programmer; the only requirement is that '''type''' is a value obtained * from SDL_RegisterEvents(). * * \since This struct is available since SDL 3.2.0. */ typedef struct SDL_UserEvent { Uint32 type; /**< SDL_EVENT_USER through SDL_EVENT_LAST, Uint32 because these are not in the SDL_EventType enumeration */ Uint32 reserved; Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */ SDL_WindowID windowID; /**< The associated window if any */ Sint32 code; /**< User defined event code */ void *data1; /**< User defined data pointer */ void *data2; /**< User defined data pointer */ } SDL_UserEvent; /** * The structure for all events in SDL. * * The SDL_Event structure is the core of all event handling in SDL. SDL_Event * is a union of all event structures used in SDL. * * \since This struct is available since SDL 3.2.0. */ typedef union SDL_Event { Uint32 type; /**< Event type, shared with all events, Uint32 to cover user events which are not in the SDL_EventType enumeration */ SDL_CommonEvent common; /**< Common event data */ SDL_DisplayEvent display; /**< Display event data */ SDL_WindowEvent window; /**< Window event data */ SDL_KeyboardDeviceEvent kdevice; /**< Keyboard device change event data */ SDL_KeyboardEvent key; /**< Keyboard event data */ SDL_TextEditingEvent edit; /**< Text editing event data */ SDL_TextEditingCandidatesEvent edit_candidates; /**< Text editing candidates event data */ SDL_TextInputEvent text; /**< Text input event data */ SDL_MouseDeviceEvent mdevice; /**< Mouse device change event data */ SDL_MouseMotionEvent motion; /**< Mouse motion event data */ SDL_MouseButtonEvent button; /**< Mouse button event data */ SDL_MouseWheelEvent wheel; /**< Mouse wheel event data */ SDL_JoyDeviceEvent jdevice; /**< Joystick device change event data */ SDL_JoyAxisEvent jaxis; /**< Joystick axis event data */ SDL_JoyBallEvent jball; /**< Joystick ball event data */ SDL_JoyHatEvent jhat; /**< Joystick hat event data */ SDL_JoyButtonEvent jbutton; /**< Joystick button event data */ SDL_JoyBatteryEvent jbattery; /**< Joystick battery event data */ SDL_GamepadDeviceEvent gdevice; /**< Gamepad device event data */ SDL_GamepadAxisEvent gaxis; /**< Gamepad axis event data */ SDL_GamepadButtonEvent gbutton; /**< Gamepad button event data */ SDL_GamepadTouchpadEvent gtouchpad; /**< Gamepad touchpad event data */ SDL_GamepadSensorEvent gsensor; /**< Gamepad sensor event data */ SDL_AudioDeviceEvent adevice; /**< Audio device event data */ SDL_CameraDeviceEvent cdevice; /**< Camera device event data */ SDL_SensorEvent sensor; /**< Sensor event data */ SDL_QuitEvent quit; /**< Quit request event data */ SDL_UserEvent user; /**< Custom event data */ SDL_TouchFingerEvent tfinger; /**< Touch finger event data */ SDL_PinchFingerEvent pinch; /**< Pinch event data */ SDL_PenProximityEvent pproximity; /**< Pen proximity event data */ SDL_PenTouchEvent ptouch; /**< Pen tip touching event data */ SDL_PenMotionEvent pmotion; /**< Pen motion event data */ SDL_PenButtonEvent pbutton; /**< Pen button event data */ SDL_PenAxisEvent paxis; /**< Pen axis event data */ SDL_RenderEvent render; /**< Render event data */ SDL_DropEvent drop; /**< Drag and drop event data */ SDL_ClipboardEvent clipboard; /**< Clipboard event data */ /* This is necessary for ABI compatibility between Visual C++ and GCC. Visual C++ will respect the push pack pragma and use 52 bytes (size of SDL_TextEditingEvent, the largest structure for 32-bit and 64-bit architectures) for this union, and GCC will use the alignment of the largest datatype within the union, which is 8 bytes on 64-bit architectures. So... we'll add padding to force the size to be the same for both. On architectures where pointers are 16 bytes, this needs rounding up to the next multiple of 16, 64, and on architectures where pointers are even larger the size of SDL_UserEvent will dominate as being 3 pointers. */ Uint8 padding[128]; } SDL_Event; /* Make sure we haven't broken binary compatibility */ SDL_COMPILE_TIME_ASSERT(SDL_Event, sizeof(SDL_Event) == sizeof((SDL_static_cast(SDL_Event *, NULL))->padding)); /* Function prototypes */ /** * Pump the event loop, gathering events from the input devices. * * This function updates the event queue and internal input device state. * * SDL_PumpEvents() gathers all the pending input information from devices and * places it in the event queue. Without calls to SDL_PumpEvents() no events * would ever be placed on the queue. Often the need for calls to * SDL_PumpEvents() is hidden from the user since SDL_PollEvent() and * SDL_WaitEvent() implicitly call SDL_PumpEvents(). However, if you are not * polling or waiting for events (e.g. you are filtering them), then you must * call SDL_PumpEvents() to force an event queue update. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_PollEvent * \sa SDL_WaitEvent */ extern SDL_DECLSPEC void SDLCALL SDL_PumpEvents(void); /* @{ */ /** * The type of action to request from SDL_PeepEvents(). * * \since This enum is available since SDL 3.2.0. */ typedef enum SDL_EventAction { SDL_ADDEVENT, /**< Add events to the back of the queue. */ SDL_PEEKEVENT, /**< Check but don't remove events from the queue front. */ SDL_GETEVENT /**< Retrieve/remove events from the front of the queue. */ } SDL_EventAction; /** * Check the event queue for messages and optionally return them. * * `action` may be any of the following: * * - `SDL_ADDEVENT`: up to `numevents` events will be added to the back of the * event queue. * - `SDL_PEEKEVENT`: `numevents` events at the front of the event queue, * within the specified minimum and maximum type, will be returned to the * caller and will _not_ be removed from the queue. If you pass NULL for * `events`, then `numevents` is ignored and the total number of matching * events will be returned. * - `SDL_GETEVENT`: up to `numevents` events at the front of the event queue, * within the specified minimum and maximum type, will be returned to the * caller and will be removed from the queue. * * You may have to call SDL_PumpEvents() before calling this function. * Otherwise, the events may not be ready to be filtered when you call * SDL_PeepEvents(). * * \param events destination buffer for the retrieved events, may be NULL to * leave the events in the queue and return the number of events * that would have been stored. * \param numevents if action is SDL_ADDEVENT, the number of events to add * back to the event queue; if action is SDL_PEEKEVENT or * SDL_GETEVENT, the maximum number of events to retrieve. * \param action action to take; see [Remarks](#remarks) for details. * \param minType minimum value of the event type to be considered; * SDL_EVENT_FIRST is a safe choice. * \param maxType maximum value of the event type to be considered; * SDL_EVENT_LAST is a safe choice. * \returns the number of events actually stored or -1 on failure; call * SDL_GetError() for more information. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_PollEvent * \sa SDL_PumpEvents * \sa SDL_PushEvent */ extern SDL_DECLSPEC int SDLCALL SDL_PeepEvents(SDL_Event *events, int numevents, SDL_EventAction action, Uint32 minType, Uint32 maxType); /* @} */ /** * Check for the existence of a certain event type in the event queue. * * If you need to check for a range of event types, use SDL_HasEvents() * instead. * * \param type the type of event to be queried; see SDL_EventType for details. * \returns true if events matching `type` are present, or false if events * matching `type` are not present. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_HasEvents */ extern SDL_DECLSPEC bool SDLCALL SDL_HasEvent(Uint32 type); /** * Check for the existence of certain event types in the event queue. * * If you need to check for a single event type, use SDL_HasEvent() instead. * * \param minType the low end of event type to be queried, inclusive; see * SDL_EventType for details. * \param maxType the high end of event type to be queried, inclusive; see * SDL_EventType for details. * \returns true if events with type >= `minType` and <= `maxType` are * present, or false if not. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_HasEvents */ extern SDL_DECLSPEC bool SDLCALL SDL_HasEvents(Uint32 minType, Uint32 maxType); /** * Clear events of a specific type from the event queue. * * This will unconditionally remove any events from the queue that match * `type`. If you need to remove a range of event types, use SDL_FlushEvents() * instead. * * It's also normal to just ignore events you don't care about in your event * loop without calling this function. * * This function only affects currently queued events. If you want to make * sure that all pending OS events are flushed, you can call SDL_PumpEvents() * on the main thread immediately before the flush call. * * If you have user events with custom data that needs to be freed, you should * use SDL_PeepEvents() to remove and clean up those events before calling * this function. * * \param type the type of event to be cleared; see SDL_EventType for details. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_FlushEvents */ extern SDL_DECLSPEC void SDLCALL SDL_FlushEvent(Uint32 type); /** * Clear events of a range of types from the event queue. * * This will unconditionally remove any events from the queue that are in the * range of `minType` to `maxType`, inclusive. If you need to remove a single * event type, use SDL_FlushEvent() instead. * * It's also normal to just ignore events you don't care about in your event * loop without calling this function. * * This function only affects currently queued events. If you want to make * sure that all pending OS events are flushed, you can call SDL_PumpEvents() * on the main thread immediately before the flush call. * * \param minType the low end of event type to be cleared, inclusive; see * SDL_EventType for details. * \param maxType the high end of event type to be cleared, inclusive; see * SDL_EventType for details. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_FlushEvent */ extern SDL_DECLSPEC void SDLCALL SDL_FlushEvents(Uint32 minType, Uint32 maxType); /** * Poll for currently pending events. * * If `event` is not NULL, the next event is removed from the queue and stored * in the SDL_Event structure pointed to by `event`. * * If `event` is NULL, it simply returns true if there is an event in the * queue, but will not remove it from the queue. * * As this function may implicitly call SDL_PumpEvents(), you can only call * this function in the thread that initialized the video subsystem. * * SDL_PollEvent() is the favored way of receiving system events since it can * be done from the main loop and does not suspend the main loop while waiting * on an event to be posted. * * The common practice is to fully process the event queue once every frame, * usually as a first step before updating the game's state: * * ```c * while (game_is_still_running) { * SDL_Event event; * while (SDL_PollEvent(&event)) { // poll until all events are handled! * // decide what to do with this event. * } * * // update game state, draw the current frame * } * ``` * * Note that Windows (and possibly other platforms) has a quirk about how it * handles events while dragging/resizing a window, which can cause this * function to block for significant amounts of time. Technical explanations * and solutions are discussed on the wiki: * * https://wiki.libsdl.org/SDL3/AppFreezeDuringDrag * * \param event the SDL_Event structure to be filled with the next event from * the queue, or NULL. * \returns true if this got an event or false if there are none available. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_PushEvent * \sa SDL_WaitEvent * \sa SDL_WaitEventTimeout */ extern SDL_DECLSPEC bool SDLCALL SDL_PollEvent(SDL_Event *event); /** * Wait indefinitely for the next available event. * * If `event` is not NULL, the next event is removed from the queue and stored * in the SDL_Event structure pointed to by `event`. * * As this function may implicitly call SDL_PumpEvents(), you can only call * this function in the thread that initialized the video subsystem. * * \param event the SDL_Event structure to be filled in with the next event * from the queue, or NULL. * \returns true on success or false if there was an error while waiting for * events; call SDL_GetError() for more information. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_PollEvent * \sa SDL_PushEvent * \sa SDL_WaitEventTimeout */ extern SDL_DECLSPEC bool SDLCALL SDL_WaitEvent(SDL_Event *event); /** * Wait until the specified timeout (in milliseconds) for the next available * event. * * If `event` is not NULL, the next event is removed from the queue and stored * in the SDL_Event structure pointed to by `event`. * * As this function may implicitly call SDL_PumpEvents(), you can only call * this function in the thread that initialized the video subsystem. * * The timeout is not guaranteed, the actual wait time could be longer due to * system scheduling. * * \param event the SDL_Event structure to be filled in with the next event * from the queue, or NULL. * \param timeoutMS the maximum number of milliseconds to wait for the next * available event. * \returns true if this got an event or false if the timeout elapsed without * any events available. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_PollEvent * \sa SDL_PushEvent * \sa SDL_WaitEvent */ extern SDL_DECLSPEC bool SDLCALL SDL_WaitEventTimeout(SDL_Event *event, Sint32 timeoutMS); /** * Add an event to the event queue. * * The event queue can actually be used as a two way communication channel. * Not only can events be read from the queue, but the user can also push * their own events onto it. `event` is a pointer to the event structure you * wish to push onto the queue. The event is copied into the queue, and the * caller may dispose of the memory pointed to after SDL_PushEvent() returns. * * Note: Pushing device input events onto the queue doesn't modify the state * of the device within SDL. * * Note: Events pushed onto the queue with SDL_PushEvent() get passed through * the event filter but events added with SDL_PeepEvents() do not. * * For pushing application-specific events, please use SDL_RegisterEvents() to * get an event type that does not conflict with other code that also wants * its own custom event types. * * \param event the SDL_Event to be added to the queue. * \returns true on success, false if the event was filtered or on failure; * call SDL_GetError() for more information. A common reason for * error is the event queue being full. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_PeepEvents * \sa SDL_PollEvent * \sa SDL_RegisterEvents */ extern SDL_DECLSPEC bool SDLCALL SDL_PushEvent(SDL_Event *event); /** * A function pointer used for callbacks that watch the event queue. * * \param userdata what was passed as `userdata` to SDL_SetEventFilter() or * SDL_AddEventWatch, etc. * \param event the event that triggered the callback. * \returns true to permit event to be added to the queue, and false to * disallow it. When used with SDL_AddEventWatch, the return value is * ignored. * * \threadsafety SDL may call this callback at any time from any thread; the * application is responsible for locking resources the callback * touches that need to be protected. * * \since This datatype is available since SDL 3.2.0. * * \sa SDL_SetEventFilter * \sa SDL_AddEventWatch */ typedef bool (SDLCALL *SDL_EventFilter)(void *userdata, SDL_Event *event); /** * Set up a filter to process all events before they are added to the internal * event queue. * * If you just want to see events without modifying them or preventing them * from being queued, you should use SDL_AddEventWatch() instead. * * If the filter function returns true when called, then the event will be * added to the internal queue. If it returns false, then the event will be * dropped from the queue, but the internal state will still be updated. This * allows selective filtering of dynamically arriving events. * * **WARNING**: Be very careful of what you do in the event filter function, * as it may run in a different thread! The exception is handling of * SDL_EVENT_WINDOW_EXPOSED, which is guaranteed to be sent from the OS on the * main thread and you are expected to redraw your window in response to this * event. * * On platforms that support it, if the quit event is generated by an * interrupt signal (e.g. pressing Ctrl-C), it will be delivered to the * application at the next event poll. * * Note: Disabled events never make it to the event filter function; see * SDL_SetEventEnabled(). * * Note: Events pushed onto the queue with SDL_PushEvent() get passed through * the event filter, but events pushed onto the queue with SDL_PeepEvents() do * not. * * \param filter a function to call when an event happens. * \param userdata a pointer that is passed to `filter`. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_AddEventWatch * \sa SDL_SetEventEnabled * \sa SDL_GetEventFilter * \sa SDL_PeepEvents * \sa SDL_PushEvent */ extern SDL_DECLSPEC void SDLCALL SDL_SetEventFilter(SDL_EventFilter filter, void *userdata); /** * Query the current event filter. * * This function can be used to "chain" filters, by saving the existing filter * before replacing it with a function that will call that saved filter. * * \param filter the current callback function will be stored here. * \param userdata the pointer that is passed to the current event filter will * be stored here. * \returns true on success or false if there is no event filter set. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_SetEventFilter */ extern SDL_DECLSPEC bool SDLCALL SDL_GetEventFilter(SDL_EventFilter *filter, void **userdata); /** * Add a callback to be triggered when an event is added to the event queue. * * `filter` will be called when an event happens, and its return value is * ignored. * * **WARNING**: Be very careful of what you do in the event filter function, * as it may run in a different thread! * * If the quit event is generated by a signal (e.g. SIGINT), it will bypass * the internal queue and be delivered to the watch callback immediately, and * arrive at the next event poll. * * Note: the callback is called for events posted by the user through * SDL_PushEvent(), but not for disabled events, nor for events by a filter * callback set with SDL_SetEventFilter(), nor for events posted by the user * through SDL_PeepEvents(). * * \param filter an SDL_EventFilter function to call when an event happens. * \param userdata a pointer that is passed to `filter`. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_RemoveEventWatch * \sa SDL_SetEventFilter */ extern SDL_DECLSPEC bool SDLCALL SDL_AddEventWatch(SDL_EventFilter filter, void *userdata); /** * Remove an event watch callback added with SDL_AddEventWatch(). * * This function takes the same input as SDL_AddEventWatch() to identify and * delete the corresponding callback. * * \param filter the function originally passed to SDL_AddEventWatch(). * \param userdata the pointer originally passed to SDL_AddEventWatch(). * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_AddEventWatch */ extern SDL_DECLSPEC void SDLCALL SDL_RemoveEventWatch(SDL_EventFilter filter, void *userdata); /** * Run a specific filter function on the current event queue, removing any * events for which the filter returns false. * * See SDL_SetEventFilter() for more information. Unlike SDL_SetEventFilter(), * this function does not change the filter permanently, it only uses the * supplied filter until this function returns. * * \param filter the SDL_EventFilter function to call when an event happens. * \param userdata a pointer that is passed to `filter`. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetEventFilter * \sa SDL_SetEventFilter */ extern SDL_DECLSPEC void SDLCALL SDL_FilterEvents(SDL_EventFilter filter, void *userdata); /** * Set the state of processing events by type. * * \param type the type of event; see SDL_EventType for details. * \param enabled whether to process the event or not. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_EventEnabled */ extern SDL_DECLSPEC void SDLCALL SDL_SetEventEnabled(Uint32 type, bool enabled); /** * Query the state of processing events by type. * * \param type the type of event; see SDL_EventType for details. * \returns true if the event is being processed, false otherwise. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_SetEventEnabled */ extern SDL_DECLSPEC bool SDLCALL SDL_EventEnabled(Uint32 type); /** * Allocate a set of user-defined events, and return the beginning event * number for that set of events. * * \param numevents the number of events to be allocated. * \returns the beginning event number, or 0 if numevents is invalid or if * there are not enough user-defined events left. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_PushEvent */ extern SDL_DECLSPEC Uint32 SDLCALL SDL_RegisterEvents(int numevents); /** * Get window associated with an event. * * \param event an event containing a `windowID`. * \returns the associated window on success or NULL if there is none. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_PollEvent * \sa SDL_WaitEvent * \sa SDL_WaitEventTimeout */ extern SDL_DECLSPEC SDL_Window * SDLCALL SDL_GetWindowFromEvent(const SDL_Event *event); /** * Generate an English description of an event. * * This will fill `buf` with a null-terminated string that might look * something like this: * * ``` * SDL_EVENT_MOUSE_MOTION (timestamp=1140256324 windowid=2 which=0 state=0 x=492.99 y=139.09 xrel=52 yrel=6) * ``` * * The exact format of the string is not guaranteed; it is intended for * logging purposes, to be read by a human, and not parsed by a computer. * * The returned value follows the same rules as SDL_snprintf(): `buf` will * always be NULL-terminated (unless `buflen` is zero), and will be truncated * if `buflen` is too small. The return code is the number of bytes needed for * the complete string, not counting the NULL-terminator, whether the string * was truncated or not. Unlike SDL_snprintf(), though, this function never * returns -1. * * \param event an event to describe. May be NULL. * \param buf the buffer to fill with the description string. May be NULL. * \param buflen the maximum bytes that can be written to `buf`. * \returns number of bytes needed for the full string, not counting the * null-terminator byte. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.4.0. */ extern SDL_DECLSPEC int SDLCALL SDL_GetEventDescription(const SDL_Event *event, char *buf, int buflen); /* Ends C function definitions when using C++ */ #ifdef __cplusplus } #endif #include #endif /* SDL_events_h_ */ ================================================ FILE: deps/include/SDL3/SDL_filesystem.h ================================================ /* Simple DirectMedia Layer Copyright (C) 1997-2026 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ /** * # CategoryFilesystem * * SDL offers an API for examining and manipulating the system's filesystem. * This covers most things one would need to do with directories, except for * actual file I/O (which is covered by [CategoryIOStream](CategoryIOStream) * and [CategoryAsyncIO](CategoryAsyncIO) instead). * * There are functions to answer necessary path questions: * * - Where is my app's data? SDL_GetBasePath(). * - Where can I safely write files? SDL_GetPrefPath(). * - Where are paths like Downloads, Desktop, Music? SDL_GetUserFolder(). * - What is this thing at this location? SDL_GetPathInfo(). * - What items live in this folder? SDL_EnumerateDirectory(). * - What items live in this folder by wildcard? SDL_GlobDirectory(). * - What is my current working directory? SDL_GetCurrentDirectory(). * * SDL also offers functions to manipulate the directory tree: renaming, * removing, copying files. */ #ifndef SDL_filesystem_h_ #define SDL_filesystem_h_ #include #include #include /* Set up for C function definitions, even when using C++ */ #ifdef __cplusplus extern "C" { #endif /** * Get the directory where the application was run from. * * SDL caches the result of this call internally, but the first call to this * function is not necessarily fast, so plan accordingly. * * **macOS and iOS Specific Functionality**: If the application is in a ".app" * bundle, this function returns the Resource directory (e.g. * MyApp.app/Contents/Resources/). This behaviour can be overridden by adding * a property to the Info.plist file. Adding a string key with the name * SDL_FILESYSTEM_BASE_DIR_TYPE with a supported value will change the * behaviour. * * Supported values for the SDL_FILESYSTEM_BASE_DIR_TYPE property (Given an * application in /Applications/SDLApp/MyApp.app): * * - `resource`: bundle resource directory (the default). For example: * `/Applications/SDLApp/MyApp.app/Contents/Resources` * - `bundle`: the Bundle directory. For example: * `/Applications/SDLApp/MyApp.app/` * - `parent`: the containing directory of the bundle. For example: * `/Applications/SDLApp/` * * **Android Specific Functionality**: This function returns "./", which * allows filesystem operations to use internal storage and the asset system. * * **Nintendo 3DS Specific Functionality**: This function returns "romfs" * directory of the application as it is uncommon to store resources outside * the executable. As such it is not a writable directory. * * The returned path is guaranteed to end with a path separator ('\\' on * Windows, '/' on most other platforms). * * \returns an absolute path in UTF-8 encoding to the application data * directory. NULL will be returned on error or when the platform * doesn't implement this functionality, call SDL_GetError() for more * information. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetPrefPath */ extern SDL_DECLSPEC const char * SDLCALL SDL_GetBasePath(void); /** * Get the user-and-app-specific path where files can be written. * * Get the "pref dir". This is meant to be where users can write personal * files (preferences and save games, etc) that are specific to your * application. This directory is unique per user, per application. * * This function will decide the appropriate location in the native * filesystem, create the directory if necessary, and return a string of the * absolute path to the directory in UTF-8 encoding. * * On Windows, the string might look like: * * `C:\\Users\\bob\\AppData\\Roaming\\My Company\\My Program Name\\` * * On Linux, the string might look like: * * `/home/bob/.local/share/My Program Name/` * * On macOS, the string might look like: * * `/Users/bob/Library/Application Support/My Program Name/` * * You should assume the path returned by this function is the only safe place * to write files (and that SDL_GetBasePath(), while it might be writable, or * even the parent of the returned path, isn't where you should be writing * things). * * Both the org and app strings may become part of a directory name, so please * follow these rules: * * - Try to use the same org string (_including case-sensitivity_) for all * your applications that use this function. * - Always use a unique app string for each one, and make sure it never * changes for an app once you've decided on it. * - Unicode characters are legal, as long as they are UTF-8 encoded, but... * - ...only use letters, numbers, and spaces. Avoid punctuation like "Game * Name 2: Bad Guy's Revenge!" ... "Game Name 2" is sufficient. * * Due to historical mistakes, `org` is allowed to be NULL or "". In such * cases, SDL will omit the org subdirectory, including on platforms where it * shouldn't, and including on platforms where this would make your app fail * certification for an app store. New apps should definitely specify a real * string for `org`. * * The returned path is guaranteed to end with a path separator ('\\' on * Windows, '/' on most other platforms). * * \param org the name of your organization. * \param app the name of your application. * \returns a UTF-8 string of the user directory in platform-dependent * notation. NULL if there's a problem (creating directory failed, * etc.). This should be freed with SDL_free() when it is no longer * needed. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetBasePath */ extern SDL_DECLSPEC char * SDLCALL SDL_GetPrefPath(const char *org, const char *app); /** * The type of the OS-provided default folder for a specific purpose. * * Note that the Trash folder isn't included here, because trashing files * usually involves extra OS-specific functionality to remember the file's * original location. * * The folders supported per platform are: * * | | Windows | macOS/iOS | tvOS | Unix (XDG) | Haiku | Emscripten | * | ----------- | ------- | --------- | ---- | ---------- | ----- | ---------- | * | HOME | X | X | | X | X | X | * | DESKTOP | X | X | | X | X | | * | DOCUMENTS | X | X | | X | | | * | DOWNLOADS | Vista+ | X | | X | | | * | MUSIC | X | X | | X | | | * | PICTURES | X | X | | X | | | * | PUBLICSHARE | | X | | X | | | * | SAVEDGAMES | Vista+ | | | | | | * | SCREENSHOTS | Vista+ | | | | | | * | TEMPLATES | X | X | | X | | | * | VIDEOS | X | X* | | X | | | * * Note that on macOS/iOS, the Videos folder is called "Movies". * * \since This enum is available since SDL 3.2.0. * * \sa SDL_GetUserFolder */ typedef enum SDL_Folder { SDL_FOLDER_HOME, /**< The folder which contains all of the current user's data, preferences, and documents. It usually contains most of the other folders. If a requested folder does not exist, the home folder can be considered a safe fallback to store a user's documents. */ SDL_FOLDER_DESKTOP, /**< The folder of files that are displayed on the desktop. Note that the existence of a desktop folder does not guarantee that the system does show icons on its desktop; certain GNU/Linux distros with a graphical environment may not have desktop icons. */ SDL_FOLDER_DOCUMENTS, /**< User document files, possibly application-specific. This is a good place to save a user's projects. */ SDL_FOLDER_DOWNLOADS, /**< Standard folder for user files downloaded from the internet. */ SDL_FOLDER_MUSIC, /**< Music files that can be played using a standard music player (mp3, ogg...). */ SDL_FOLDER_PICTURES, /**< Image files that can be displayed using a standard viewer (png, jpg...). */ SDL_FOLDER_PUBLICSHARE, /**< Files that are meant to be shared with other users on the same computer. */ SDL_FOLDER_SAVEDGAMES, /**< Save files for games. */ SDL_FOLDER_SCREENSHOTS, /**< Application screenshots. */ SDL_FOLDER_TEMPLATES, /**< Template files to be used when the user requests the desktop environment to create a new file in a certain folder, such as "New Text File.txt". Any file in the Templates folder can be used as a starting point for a new file. */ SDL_FOLDER_VIDEOS, /**< Video files that can be played using a standard video player (mp4, webm...). */ SDL_FOLDER_COUNT /**< Total number of types in this enum, not a folder type by itself. */ } SDL_Folder; /** * Finds the most suitable user folder for a specific purpose. * * Many OSes provide certain standard folders for certain purposes, such as * storing pictures, music or videos for a certain user. This function gives * the path for many of those special locations. * * This function is specifically for _user_ folders, which are meant for the * user to access and manage. For application-specific folders, meant to hold * data for the application to manage, see SDL_GetBasePath() and * SDL_GetPrefPath(). * * The returned path is guaranteed to end with a path separator ('\\' on * Windows, '/' on most other platforms). * * If NULL is returned, the error may be obtained with SDL_GetError(). * * \param folder the type of folder to find. * \returns either a null-terminated C string containing the full path to the * folder, or NULL if an error happened. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC const char * SDLCALL SDL_GetUserFolder(SDL_Folder folder); /* Abstract filesystem interface */ /** * Types of filesystem entries. * * Note that there may be other sorts of items on a filesystem: devices, named * pipes, etc. They are currently reported as SDL_PATHTYPE_OTHER. * * \since This enum is available since SDL 3.2.0. * * \sa SDL_PathInfo */ typedef enum SDL_PathType { SDL_PATHTYPE_NONE, /**< path does not exist */ SDL_PATHTYPE_FILE, /**< a normal file */ SDL_PATHTYPE_DIRECTORY, /**< a directory */ SDL_PATHTYPE_OTHER /**< something completely different like a device node (not a symlink, those are always followed) */ } SDL_PathType; /** * Information about a path on the filesystem. * * \since This datatype is available since SDL 3.2.0. * * \sa SDL_GetPathInfo * \sa SDL_GetStoragePathInfo */ typedef struct SDL_PathInfo { SDL_PathType type; /**< the path type */ Uint64 size; /**< the file size in bytes */ SDL_Time create_time; /**< the time when the path was created */ SDL_Time modify_time; /**< the last time the path was modified */ SDL_Time access_time; /**< the last time the path was read */ } SDL_PathInfo; /** * Flags for path matching. * * \since This datatype is available since SDL 3.2.0. * * \sa SDL_GlobDirectory * \sa SDL_GlobStorageDirectory */ typedef Uint32 SDL_GlobFlags; #define SDL_GLOB_CASEINSENSITIVE (1u << 0) /** * Create a directory, and any missing parent directories. * * This reports success if `path` already exists as a directory. * * If parent directories are missing, it will also create them. Note that if * this fails, it will not remove any parent directories it already made. * * \param path the path of the directory to create. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC bool SDLCALL SDL_CreateDirectory(const char *path); /** * Possible results from an enumeration callback. * * \since This enum is available since SDL 3.2.0. * * \sa SDL_EnumerateDirectoryCallback */ typedef enum SDL_EnumerationResult { SDL_ENUM_CONTINUE, /**< Value that requests that enumeration continue. */ SDL_ENUM_SUCCESS, /**< Value that requests that enumeration stop, successfully. */ SDL_ENUM_FAILURE /**< Value that requests that enumeration stop, as a failure. */ } SDL_EnumerationResult; /** * Callback for directory enumeration. * * Enumeration of directory entries will continue until either all entries * have been provided to the callback, or the callback has requested a stop * through its return value. * * Returning SDL_ENUM_CONTINUE will let enumeration proceed, calling the * callback with further entries. SDL_ENUM_SUCCESS and SDL_ENUM_FAILURE will * terminate the enumeration early, and dictate the return value of the * enumeration function itself. * * `dirname` is guaranteed to end with a path separator ('\\' on Windows, '/' * on most other platforms). * * \param userdata an app-controlled pointer that is passed to the callback. * \param dirname the directory that is being enumerated. * \param fname the next entry in the enumeration. * \returns how the enumeration should proceed. * * \since This datatype is available since SDL 3.2.0. * * \sa SDL_EnumerateDirectory */ typedef SDL_EnumerationResult (SDLCALL *SDL_EnumerateDirectoryCallback)(void *userdata, const char *dirname, const char *fname); /** * Enumerate a directory through a callback function. * * This function provides every directory entry through an app-provided * callback, called once for each directory entry, until all results have been * provided or the callback returns either SDL_ENUM_SUCCESS or * SDL_ENUM_FAILURE. * * This will return false if there was a system problem in general, or if a * callback returns SDL_ENUM_FAILURE. A successful return means a callback * returned SDL_ENUM_SUCCESS to halt enumeration, or all directory entries * were enumerated. * * \param path the path of the directory to enumerate. * \param callback a function that is called for each entry in the directory. * \param userdata a pointer that is passed to `callback`. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC bool SDLCALL SDL_EnumerateDirectory(const char *path, SDL_EnumerateDirectoryCallback callback, void *userdata); /** * Remove a file or an empty directory. * * Directories that are not empty will fail; this function will not recursely * delete directory trees. * * \param path the path to remove from the filesystem. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC bool SDLCALL SDL_RemovePath(const char *path); /** * Rename a file or directory. * * If the file at `newpath` already exists, it will be replaced. * * Note that this will not copy files across filesystems/drives/volumes, as * that is a much more complicated (and possibly time-consuming) operation. * * Which is to say, if this function fails, SDL_CopyFile() to a temporary file * in the same directory as `newpath`, then SDL_RenamePath() from the * temporary file to `newpath` and SDL_RemovePath() on `oldpath` might work * for files. Renaming a non-empty directory across filesystems is * dramatically more complex, however. * * \param oldpath the old path. * \param newpath the new path. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC bool SDLCALL SDL_RenamePath(const char *oldpath, const char *newpath); /** * Copy a file. * * If the file at `newpath` already exists, it will be overwritten with the * contents of the file at `oldpath`. * * This function will block until the copy is complete, which might be a * significant time for large files on slow disks. On some platforms, the copy * can be handed off to the OS itself, but on others SDL might just open both * paths, and read from one and write to the other. * * Note that this is not an atomic operation! If something tries to read from * `newpath` while the copy is in progress, it will see an incomplete copy of * the data, and if the calling thread terminates (or the power goes out) * during the copy, `newpath`'s previous contents will be gone, replaced with * an incomplete copy of the data. To avoid this risk, it is recommended that * the app copy to a temporary file in the same directory as `newpath`, and if * the copy is successful, use SDL_RenamePath() to replace `newpath` with the * temporary file. This will ensure that reads of `newpath` will either see a * complete copy of the data, or it will see the pre-copy state of `newpath`. * * This function attempts to synchronize the newly-copied data to disk before * returning, if the platform allows it, so that the renaming trick will not * have a problem in a system crash or power failure, where the file could be * renamed but the contents never made it from the system file cache to the * physical disk. * * If the copy fails for any reason, the state of `newpath` is undefined. It * might be half a copy, it might be the untouched data of what was already * there, or it might be a zero-byte file, etc. * * \param oldpath the old path. * \param newpath the new path. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety It is safe to call this function from any thread, but this * operation is not atomic, so the app might need to protect * access to specific paths from other threads if appropriate. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC bool SDLCALL SDL_CopyFile(const char *oldpath, const char *newpath); /** * Get information about a filesystem path. * * Symlinks, on filesystems that support them, are always followed, so you * will always get information on what the symlink eventually points to, and * not the symlink itself. * * \param path the path to query. * \param info a pointer filled in with information about the path, or NULL to * check for the existence of a file. * \returns true on success or false if the file doesn't exist, or another * failure; call SDL_GetError() for more information. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC bool SDLCALL SDL_GetPathInfo(const char *path, SDL_PathInfo *info); /** * Enumerate a directory tree, filtered by pattern, and return a list. * * Files are filtered out if they don't match the string in `pattern`, which * may contain wildcard characters `*` (match everything) and `?` (match one * character). If pattern is NULL, no filtering is done and all results are * returned. Subdirectories are permitted, and are specified with a path * separator of `/`. Wildcard characters `*` and `?` never match a path * separator. * * `flags` may be set to SDL_GLOB_CASEINSENSITIVE to make the pattern matching * case-insensitive. * * The returned array is always NULL-terminated, for your iterating * convenience, but if `count` is non-NULL, on return it will contain the * number of items in the array, not counting the NULL terminator. * * \param path the path of the directory to enumerate. * \param pattern the pattern that files in the directory must match. Can be * NULL. * \param flags `SDL_GLOB_*` bitflags that affect this search. * \param count on return, will be set to the number of items in the returned * array. Can be NULL. * \returns an array of strings on success or NULL on failure; call * SDL_GetError() for more information. This is a single allocation * that should be freed with SDL_free() when it is no longer needed. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC char ** SDLCALL SDL_GlobDirectory(const char *path, const char *pattern, SDL_GlobFlags flags, int *count); /** * Get what the system believes is the "current working directory." * * For systems without a concept of a current working directory, this will * still attempt to provide something reasonable. * * SDL does not provide a means to _change_ the current working directory; for * platforms without this concept, this would cause surprises with file access * outside of SDL. * * The returned path is guaranteed to end with a path separator ('\\' on * Windows, '/' on most other platforms). * * \returns a UTF-8 string of the current working directory in * platform-dependent notation. NULL if there's a problem. This * should be freed with SDL_free() when it is no longer needed. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC char * SDLCALL SDL_GetCurrentDirectory(void); /* Ends C function definitions when using C++ */ #ifdef __cplusplus } #endif #include #endif /* SDL_filesystem_h_ */ ================================================ FILE: deps/include/SDL3/SDL_gamepad.h ================================================ /* Simple DirectMedia Layer Copyright (C) 1997-2026 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ /** * # CategoryGamepad * * SDL provides a low-level joystick API, which just treats joysticks as an * arbitrary pile of buttons, axes, and hat switches. If you're planning to * write your own control configuration screen, this can give you a lot of * flexibility, but that's a lot of work, and most things that we consider * "joysticks" now are actually console-style gamepads. So SDL provides the * gamepad API on top of the lower-level joystick functionality. * * The difference between a joystick and a gamepad is that a gamepad tells you * _where_ a button or axis is on the device. You don't speak to gamepads in * terms of arbitrary numbers like "button 3" or "axis 2" but in standard * locations: the d-pad, the shoulder buttons, triggers, A/B/X/Y (or * X/O/Square/Triangle, if you will). * * One turns a joystick into a gamepad by providing a magic configuration * string, which tells SDL the details of a specific device: when you see this * specific hardware, if button 2 gets pressed, this is actually D-Pad Up, * etc. * * SDL has many popular controllers configured out of the box, and users can * add their own controller details through an environment variable if it's * otherwise unknown to SDL. * * In order to use these functions, SDL_Init() must have been called with the * SDL_INIT_GAMEPAD flag. This causes SDL to scan the system for gamepads, and * load appropriate drivers. * * If you're using SDL gamepad support in a Steam game, you must call * SteamAPI_InitEx() before calling SDL_Init(). * * If you would like to receive gamepad updates while the application is in * the background, you should set the following hint before calling * SDL_Init(): SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS * * Gamepads support various optional features such as rumble, color LEDs, * touchpad, gyro, etc. The support for these features varies depending on the * controller and OS support available. You can check for LED and rumble * capabilities at runtime by calling SDL_GetGamepadProperties() and checking * the various capability properties. You can check for touchpad by calling * SDL_GetNumGamepadTouchpads() and check for gyro and accelerometer by * calling SDL_GamepadHasSensor(). * * By default SDL will try to use the most capable driver available, but you * can tune which OS drivers to use with the various joystick hints in * SDL_hints.h. * * Your application should always support gamepad hotplugging. On some * platforms like Xbox, Steam Deck, etc., this is a requirement for * certification. On other platforms, like macOS and Windows when using * Windows.Gaming.Input, controllers may not be available at startup and will * come in at some point after you've started processing events. */ #ifndef SDL_gamepad_h_ #define SDL_gamepad_h_ #include #include #include #include #include #include #include #include #include /* Set up for C function definitions, even when using C++ */ #ifdef __cplusplus extern "C" { #endif /** * The structure used to identify an SDL gamepad * * \since This struct is available since SDL 3.2.0. */ typedef struct SDL_Gamepad SDL_Gamepad; /** * Standard gamepad types. * * This type does not necessarily map to first-party controllers from * Microsoft/Sony/Nintendo; in many cases, third-party controllers can report * as these, either because they were designed for a specific console, or they * simply most closely match that console's controllers (does it have A/B/X/Y * buttons or X/O/Square/Triangle? Does it have a touchpad? etc). */ typedef enum SDL_GamepadType { SDL_GAMEPAD_TYPE_UNKNOWN = 0, SDL_GAMEPAD_TYPE_STANDARD, SDL_GAMEPAD_TYPE_XBOX360, SDL_GAMEPAD_TYPE_XBOXONE, SDL_GAMEPAD_TYPE_PS3, SDL_GAMEPAD_TYPE_PS4, SDL_GAMEPAD_TYPE_PS5, SDL_GAMEPAD_TYPE_NINTENDO_SWITCH_PRO, SDL_GAMEPAD_TYPE_NINTENDO_SWITCH_JOYCON_LEFT, SDL_GAMEPAD_TYPE_NINTENDO_SWITCH_JOYCON_RIGHT, SDL_GAMEPAD_TYPE_NINTENDO_SWITCH_JOYCON_PAIR, SDL_GAMEPAD_TYPE_GAMECUBE, SDL_GAMEPAD_TYPE_COUNT } SDL_GamepadType; /** * The list of buttons available on a gamepad * * For controllers that use a diamond pattern for the face buttons, the * south/east/west/north buttons below correspond to the locations in the * diamond pattern. For Xbox controllers, this would be A/B/X/Y, for Nintendo * Switch controllers, this would be B/A/Y/X, for GameCube controllers this * would be A/X/B/Y, for PlayStation controllers this would be * Cross/Circle/Square/Triangle. * * For controllers that don't use a diamond pattern for the face buttons, the * south/east/west/north buttons indicate the buttons labeled A, B, C, D, or * 1, 2, 3, 4, or for controllers that aren't labeled, they are the primary, * secondary, etc. buttons. * * The activate action is often the south button and the cancel action is * often the east button, but in some regions this is reversed, so your game * should allow remapping actions based on user preferences. * * You can query the labels for the face buttons using * SDL_GetGamepadButtonLabel() * * \since This enum is available since SDL 3.2.0. */ typedef enum SDL_GamepadButton { SDL_GAMEPAD_BUTTON_INVALID = -1, SDL_GAMEPAD_BUTTON_SOUTH, /**< Bottom face button (e.g. Xbox A button) */ SDL_GAMEPAD_BUTTON_EAST, /**< Right face button (e.g. Xbox B button) */ SDL_GAMEPAD_BUTTON_WEST, /**< Left face button (e.g. Xbox X button) */ SDL_GAMEPAD_BUTTON_NORTH, /**< Top face button (e.g. Xbox Y button) */ SDL_GAMEPAD_BUTTON_BACK, SDL_GAMEPAD_BUTTON_GUIDE, SDL_GAMEPAD_BUTTON_START, SDL_GAMEPAD_BUTTON_LEFT_STICK, SDL_GAMEPAD_BUTTON_RIGHT_STICK, SDL_GAMEPAD_BUTTON_LEFT_SHOULDER, SDL_GAMEPAD_BUTTON_RIGHT_SHOULDER, SDL_GAMEPAD_BUTTON_DPAD_UP, SDL_GAMEPAD_BUTTON_DPAD_DOWN, SDL_GAMEPAD_BUTTON_DPAD_LEFT, SDL_GAMEPAD_BUTTON_DPAD_RIGHT, SDL_GAMEPAD_BUTTON_MISC1, /**< Additional button (e.g. Xbox Series X share button, PS5 microphone button, Nintendo Switch Pro capture button, Amazon Luna microphone button, Google Stadia capture button) */ SDL_GAMEPAD_BUTTON_RIGHT_PADDLE1, /**< Upper or primary paddle, under your right hand (e.g. Xbox Elite paddle P1, DualSense Edge RB button, Right Joy-Con SR button) */ SDL_GAMEPAD_BUTTON_LEFT_PADDLE1, /**< Upper or primary paddle, under your left hand (e.g. Xbox Elite paddle P3, DualSense Edge LB button, Left Joy-Con SL button) */ SDL_GAMEPAD_BUTTON_RIGHT_PADDLE2, /**< Lower or secondary paddle, under your right hand (e.g. Xbox Elite paddle P2, DualSense Edge right Fn button, Right Joy-Con SL button) */ SDL_GAMEPAD_BUTTON_LEFT_PADDLE2, /**< Lower or secondary paddle, under your left hand (e.g. Xbox Elite paddle P4, DualSense Edge left Fn button, Left Joy-Con SR button) */ SDL_GAMEPAD_BUTTON_TOUCHPAD, /**< PS4/PS5 touchpad button */ SDL_GAMEPAD_BUTTON_MISC2, /**< Additional button */ SDL_GAMEPAD_BUTTON_MISC3, /**< Additional button (e.g. Nintendo GameCube left trigger click) */ SDL_GAMEPAD_BUTTON_MISC4, /**< Additional button (e.g. Nintendo GameCube right trigger click) */ SDL_GAMEPAD_BUTTON_MISC5, /**< Additional button */ SDL_GAMEPAD_BUTTON_MISC6, /**< Additional button */ SDL_GAMEPAD_BUTTON_COUNT } SDL_GamepadButton; /** * The set of gamepad button labels * * This isn't a complete set, just the face buttons to make it easy to show * button prompts. * * For a complete set, you should look at the button and gamepad type and have * a set of symbols that work well with your art style. * * \since This enum is available since SDL 3.2.0. */ typedef enum SDL_GamepadButtonLabel { SDL_GAMEPAD_BUTTON_LABEL_UNKNOWN, SDL_GAMEPAD_BUTTON_LABEL_A, SDL_GAMEPAD_BUTTON_LABEL_B, SDL_GAMEPAD_BUTTON_LABEL_X, SDL_GAMEPAD_BUTTON_LABEL_Y, SDL_GAMEPAD_BUTTON_LABEL_CROSS, SDL_GAMEPAD_BUTTON_LABEL_CIRCLE, SDL_GAMEPAD_BUTTON_LABEL_SQUARE, SDL_GAMEPAD_BUTTON_LABEL_TRIANGLE } SDL_GamepadButtonLabel; /** * The list of axes available on a gamepad * * Thumbstick axis values range from SDL_JOYSTICK_AXIS_MIN to * SDL_JOYSTICK_AXIS_MAX, and are centered within ~8000 of zero, though * advanced UI will allow users to set or autodetect the dead zone, which * varies between gamepads. * * Trigger axis values range from 0 (released) to SDL_JOYSTICK_AXIS_MAX (fully * pressed) when reported by SDL_GetGamepadAxis(). Note that this is not the * same range that will be reported by the lower-level SDL_GetJoystickAxis(). * * \since This enum is available since SDL 3.2.0. */ typedef enum SDL_GamepadAxis { SDL_GAMEPAD_AXIS_INVALID = -1, SDL_GAMEPAD_AXIS_LEFTX, SDL_GAMEPAD_AXIS_LEFTY, SDL_GAMEPAD_AXIS_RIGHTX, SDL_GAMEPAD_AXIS_RIGHTY, SDL_GAMEPAD_AXIS_LEFT_TRIGGER, SDL_GAMEPAD_AXIS_RIGHT_TRIGGER, SDL_GAMEPAD_AXIS_COUNT } SDL_GamepadAxis; /** * Types of gamepad control bindings. * * A gamepad is a collection of bindings that map arbitrary joystick buttons, * axes and hat switches to specific positions on a generic console-style * gamepad. This enum is used as part of SDL_GamepadBinding to specify those * mappings. * * \since This enum is available since SDL 3.2.0. */ typedef enum SDL_GamepadBindingType { SDL_GAMEPAD_BINDTYPE_NONE = 0, SDL_GAMEPAD_BINDTYPE_BUTTON, SDL_GAMEPAD_BINDTYPE_AXIS, SDL_GAMEPAD_BINDTYPE_HAT } SDL_GamepadBindingType; /** * A mapping between one joystick input to a gamepad control. * * A gamepad has a collection of several bindings, to say, for example, when * joystick button number 5 is pressed, that should be treated like the * gamepad's "start" button. * * SDL has these bindings built-in for many popular controllers, and can add * more with a simple text string. Those strings are parsed into a collection * of these structs to make it easier to operate on the data. * * \since This struct is available since SDL 3.2.0. * * \sa SDL_GetGamepadBindings */ typedef struct SDL_GamepadBinding { SDL_GamepadBindingType input_type; union { int button; struct { int axis; int axis_min; int axis_max; } axis; struct { int hat; int hat_mask; } hat; } input; SDL_GamepadBindingType output_type; union { SDL_GamepadButton button; struct { SDL_GamepadAxis axis; int axis_min; int axis_max; } axis; } output; } SDL_GamepadBinding; /** * Add support for gamepads that SDL is unaware of or change the binding of an * existing gamepad. * * The mapping string has the format "GUID,name,mapping", where GUID is the * string value from SDL_GUIDToString(), name is the human readable string for * the device and mappings are gamepad mappings to joystick ones. Under * Windows there is a reserved GUID of "xinput" that covers all XInput * devices. The mapping format for joystick is: * * - `bX`: a joystick button, index X * - `hX.Y`: hat X with value Y * - `aX`: axis X of the joystick * * Buttons can be used as a gamepad axes and vice versa. * * If a device with this GUID is already plugged in, SDL will generate an * SDL_EVENT_GAMEPAD_ADDED event. * * This string shows an example of a valid mapping for a gamepad: * * ```c * "341a3608000000000000504944564944,Afterglow PS3 Controller,a:b1,b:b2,y:b3,x:b0,start:b9,guide:b12,back:b8,dpup:h0.1,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,leftshoulder:b4,rightshoulder:b5,leftstick:b10,rightstick:b11,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:b6,righttrigger:b7" * ``` * * \param mapping the mapping string. * \returns 1 if a new mapping is added, 0 if an existing mapping is updated, * -1 on failure; call SDL_GetError() for more information. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_AddGamepadMappingsFromFile * \sa SDL_AddGamepadMappingsFromIO * \sa SDL_GetGamepadMapping * \sa SDL_GetGamepadMappingForGUID * \sa SDL_HINT_GAMECONTROLLERCONFIG * \sa SDL_HINT_GAMECONTROLLERCONFIG_FILE * \sa SDL_EVENT_GAMEPAD_ADDED */ extern SDL_DECLSPEC int SDLCALL SDL_AddGamepadMapping(const char *mapping); /** * Load a set of gamepad mappings from an SDL_IOStream. * * You can call this function several times, if needed, to load different * database files. * * If a new mapping is loaded for an already known gamepad GUID, the later * version will overwrite the one currently loaded. * * Any new mappings for already plugged in controllers will generate * SDL_EVENT_GAMEPAD_ADDED events. * * Mappings not belonging to the current platform or with no platform field * specified will be ignored (i.e. mappings for Linux will be ignored in * Windows, etc). * * This function will load the text database entirely in memory before * processing it, so take this into consideration if you are in a memory * constrained environment. * * \param src the data stream for the mappings to be added. * \param closeio if true, calls SDL_CloseIO() on `src` before returning, even * in the case of an error. * \returns the number of mappings added or -1 on failure; call SDL_GetError() * for more information. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_AddGamepadMapping * \sa SDL_AddGamepadMappingsFromFile * \sa SDL_GetGamepadMapping * \sa SDL_GetGamepadMappingForGUID * \sa SDL_HINT_GAMECONTROLLERCONFIG * \sa SDL_HINT_GAMECONTROLLERCONFIG_FILE * \sa SDL_EVENT_GAMEPAD_ADDED */ extern SDL_DECLSPEC int SDLCALL SDL_AddGamepadMappingsFromIO(SDL_IOStream *src, bool closeio); /** * Load a set of gamepad mappings from a file. * * You can call this function several times, if needed, to load different * database files. * * If a new mapping is loaded for an already known gamepad GUID, the later * version will overwrite the one currently loaded. * * Any new mappings for already plugged in controllers will generate * SDL_EVENT_GAMEPAD_ADDED events. * * Mappings not belonging to the current platform or with no platform field * specified will be ignored (i.e. mappings for Linux will be ignored in * Windows, etc). * * \param file the mappings file to load. * \returns the number of mappings added or -1 on failure; call SDL_GetError() * for more information. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_AddGamepadMapping * \sa SDL_AddGamepadMappingsFromIO * \sa SDL_GetGamepadMapping * \sa SDL_GetGamepadMappingForGUID * \sa SDL_HINT_GAMECONTROLLERCONFIG * \sa SDL_HINT_GAMECONTROLLERCONFIG_FILE * \sa SDL_EVENT_GAMEPAD_ADDED */ extern SDL_DECLSPEC int SDLCALL SDL_AddGamepadMappingsFromFile(const char *file); /** * Reinitialize the SDL mapping database to its initial state. * * This will generate gamepad events as needed if device mappings change. * * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC bool SDLCALL SDL_ReloadGamepadMappings(void); /** * Get the current gamepad mappings. * * \param count a pointer filled in with the number of mappings returned, can * be NULL. * \returns an array of the mapping strings, NULL-terminated, or NULL on * failure; call SDL_GetError() for more information. This is a * single allocation that should be freed with SDL_free() when it is * no longer needed. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC char ** SDLCALL SDL_GetGamepadMappings(int *count); /** * Get the gamepad mapping string for a given GUID. * * \param guid a structure containing the GUID for which a mapping is desired. * \returns a mapping string or NULL on failure; call SDL_GetError() for more * information. This should be freed with SDL_free() when it is no * longer needed. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetJoystickGUIDForID * \sa SDL_GetJoystickGUID */ extern SDL_DECLSPEC char * SDLCALL SDL_GetGamepadMappingForGUID(SDL_GUID guid); /** * Get the current mapping of a gamepad. * * Details about mappings are discussed with SDL_AddGamepadMapping(). * * \param gamepad the gamepad you want to get the current mapping for. * \returns a string that has the gamepad's mapping or NULL if no mapping is * available; call SDL_GetError() for more information. This should * be freed with SDL_free() when it is no longer needed. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_AddGamepadMapping * \sa SDL_GetGamepadMappingForID * \sa SDL_GetGamepadMappingForGUID * \sa SDL_SetGamepadMapping */ extern SDL_DECLSPEC char * SDLCALL SDL_GetGamepadMapping(SDL_Gamepad *gamepad); /** * Set the current mapping of a joystick or gamepad. * * Details about mappings are discussed with SDL_AddGamepadMapping(). * * \param instance_id the joystick instance ID. * \param mapping the mapping to use for this device, or NULL to clear the * mapping. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_AddGamepadMapping * \sa SDL_GetGamepadMapping */ extern SDL_DECLSPEC bool SDLCALL SDL_SetGamepadMapping(SDL_JoystickID instance_id, const char *mapping); /** * Return whether a gamepad is currently connected. * * \returns true if a gamepad is connected, false otherwise. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetGamepads */ extern SDL_DECLSPEC bool SDLCALL SDL_HasGamepad(void); /** * Get a list of currently connected gamepads. * * \param count a pointer filled in with the number of gamepads returned, may * be NULL. * \returns a 0 terminated array of joystick instance IDs or NULL on failure; * call SDL_GetError() for more information. This should be freed * with SDL_free() when it is no longer needed. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_HasGamepad * \sa SDL_OpenGamepad */ extern SDL_DECLSPEC SDL_JoystickID * SDLCALL SDL_GetGamepads(int *count); /** * Check if the given joystick is supported by the gamepad interface. * * \param instance_id the joystick instance ID. * \returns true if the given joystick is supported by the gamepad interface, * false if it isn't or it's an invalid index. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetJoysticks * \sa SDL_OpenGamepad */ extern SDL_DECLSPEC bool SDLCALL SDL_IsGamepad(SDL_JoystickID instance_id); /** * Get the implementation dependent name of a gamepad. * * This can be called before any gamepads are opened. * * \param instance_id the joystick instance ID. * \returns the name of the selected gamepad. If no name can be found, this * function returns NULL; call SDL_GetError() for more information. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetGamepadName * \sa SDL_GetGamepads */ extern SDL_DECLSPEC const char * SDLCALL SDL_GetGamepadNameForID(SDL_JoystickID instance_id); /** * Get the implementation dependent path of a gamepad. * * This can be called before any gamepads are opened. * * \param instance_id the joystick instance ID. * \returns the path of the selected gamepad. If no path can be found, this * function returns NULL; call SDL_GetError() for more information. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetGamepadPath * \sa SDL_GetGamepads */ extern SDL_DECLSPEC const char * SDLCALL SDL_GetGamepadPathForID(SDL_JoystickID instance_id); /** * Get the player index of a gamepad. * * This can be called before any gamepads are opened. * * \param instance_id the joystick instance ID. * \returns the player index of a gamepad, or -1 if it's not available. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetGamepadPlayerIndex * \sa SDL_GetGamepads */ extern SDL_DECLSPEC int SDLCALL SDL_GetGamepadPlayerIndexForID(SDL_JoystickID instance_id); /** * Get the implementation-dependent GUID of a gamepad. * * This can be called before any gamepads are opened. * * \param instance_id the joystick instance ID. * \returns the GUID of the selected gamepad. If called on an invalid index, * this function returns a zero GUID. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GUIDToString * \sa SDL_GetGamepads */ extern SDL_DECLSPEC SDL_GUID SDLCALL SDL_GetGamepadGUIDForID(SDL_JoystickID instance_id); /** * Get the USB vendor ID of a gamepad, if available. * * This can be called before any gamepads are opened. If the vendor ID isn't * available this function returns 0. * * \param instance_id the joystick instance ID. * \returns the USB vendor ID of the selected gamepad. If called on an invalid * index, this function returns zero. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetGamepadVendor * \sa SDL_GetGamepads */ extern SDL_DECLSPEC Uint16 SDLCALL SDL_GetGamepadVendorForID(SDL_JoystickID instance_id); /** * Get the USB product ID of a gamepad, if available. * * This can be called before any gamepads are opened. If the product ID isn't * available this function returns 0. * * \param instance_id the joystick instance ID. * \returns the USB product ID of the selected gamepad. If called on an * invalid index, this function returns zero. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetGamepadProduct * \sa SDL_GetGamepads */ extern SDL_DECLSPEC Uint16 SDLCALL SDL_GetGamepadProductForID(SDL_JoystickID instance_id); /** * Get the product version of a gamepad, if available. * * This can be called before any gamepads are opened. If the product version * isn't available this function returns 0. * * \param instance_id the joystick instance ID. * \returns the product version of the selected gamepad. If called on an * invalid index, this function returns zero. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetGamepadProductVersion * \sa SDL_GetGamepads */ extern SDL_DECLSPEC Uint16 SDLCALL SDL_GetGamepadProductVersionForID(SDL_JoystickID instance_id); /** * Get the type of a gamepad. * * This can be called before any gamepads are opened. * * \param instance_id the joystick instance ID. * \returns the gamepad type. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetGamepadType * \sa SDL_GetGamepads * \sa SDL_GetRealGamepadTypeForID */ extern SDL_DECLSPEC SDL_GamepadType SDLCALL SDL_GetGamepadTypeForID(SDL_JoystickID instance_id); /** * Get the type of a gamepad, ignoring any mapping override. * * This can be called before any gamepads are opened. * * \param instance_id the joystick instance ID. * \returns the gamepad type. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetGamepadTypeForID * \sa SDL_GetGamepads * \sa SDL_GetRealGamepadType */ extern SDL_DECLSPEC SDL_GamepadType SDLCALL SDL_GetRealGamepadTypeForID(SDL_JoystickID instance_id); /** * Get the mapping of a gamepad. * * This can be called before any gamepads are opened. * * \param instance_id the joystick instance ID. * \returns the mapping string. Returns NULL if no mapping is available. This * should be freed with SDL_free() when it is no longer needed. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetGamepads * \sa SDL_GetGamepadMapping */ extern SDL_DECLSPEC char * SDLCALL SDL_GetGamepadMappingForID(SDL_JoystickID instance_id); /** * Open a gamepad for use. * * \param instance_id the joystick instance ID. * \returns a gamepad identifier or NULL if an error occurred; call * SDL_GetError() for more information. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_CloseGamepad * \sa SDL_IsGamepad */ extern SDL_DECLSPEC SDL_Gamepad * SDLCALL SDL_OpenGamepad(SDL_JoystickID instance_id); /** * Get the SDL_Gamepad associated with a joystick instance ID, if it has been * opened. * * \param instance_id the joystick instance ID of the gamepad. * \returns an SDL_Gamepad on success or NULL on failure or if it hasn't been * opened yet; call SDL_GetError() for more information. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC SDL_Gamepad * SDLCALL SDL_GetGamepadFromID(SDL_JoystickID instance_id); /** * Get the SDL_Gamepad associated with a player index. * * \param player_index the player index, which different from the instance ID. * \returns the SDL_Gamepad associated with a player index. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetGamepadPlayerIndex * \sa SDL_SetGamepadPlayerIndex */ extern SDL_DECLSPEC SDL_Gamepad * SDLCALL SDL_GetGamepadFromPlayerIndex(int player_index); /** * Get the properties associated with an opened gamepad. * * These properties are shared with the underlying joystick object. * * The following read-only properties are provided by SDL: * * - `SDL_PROP_GAMEPAD_CAP_MONO_LED_BOOLEAN`: true if this gamepad has an LED * that has adjustable brightness * - `SDL_PROP_GAMEPAD_CAP_RGB_LED_BOOLEAN`: true if this gamepad has an LED * that has adjustable color * - `SDL_PROP_GAMEPAD_CAP_PLAYER_LED_BOOLEAN`: true if this gamepad has a * player LED * - `SDL_PROP_GAMEPAD_CAP_RUMBLE_BOOLEAN`: true if this gamepad has * left/right rumble * - `SDL_PROP_GAMEPAD_CAP_TRIGGER_RUMBLE_BOOLEAN`: true if this gamepad has * simple trigger rumble * * \param gamepad a gamepad identifier previously returned by * SDL_OpenGamepad(). * \returns a valid property ID on success or 0 on failure; call * SDL_GetError() for more information. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC SDL_PropertiesID SDLCALL SDL_GetGamepadProperties(SDL_Gamepad *gamepad); #define SDL_PROP_GAMEPAD_CAP_MONO_LED_BOOLEAN SDL_PROP_JOYSTICK_CAP_MONO_LED_BOOLEAN #define SDL_PROP_GAMEPAD_CAP_RGB_LED_BOOLEAN SDL_PROP_JOYSTICK_CAP_RGB_LED_BOOLEAN #define SDL_PROP_GAMEPAD_CAP_PLAYER_LED_BOOLEAN SDL_PROP_JOYSTICK_CAP_PLAYER_LED_BOOLEAN #define SDL_PROP_GAMEPAD_CAP_RUMBLE_BOOLEAN SDL_PROP_JOYSTICK_CAP_RUMBLE_BOOLEAN #define SDL_PROP_GAMEPAD_CAP_TRIGGER_RUMBLE_BOOLEAN SDL_PROP_JOYSTICK_CAP_TRIGGER_RUMBLE_BOOLEAN /** * Get the instance ID of an opened gamepad. * * \param gamepad a gamepad identifier previously returned by * SDL_OpenGamepad(). * \returns the instance ID of the specified gamepad on success or 0 on * failure; call SDL_GetError() for more information. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC SDL_JoystickID SDLCALL SDL_GetGamepadID(SDL_Gamepad *gamepad); /** * Get the implementation-dependent name for an opened gamepad. * * \param gamepad a gamepad identifier previously returned by * SDL_OpenGamepad(). * \returns the implementation dependent name for the gamepad, or NULL if * there is no name or the identifier passed is invalid. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetGamepadNameForID */ extern SDL_DECLSPEC const char * SDLCALL SDL_GetGamepadName(SDL_Gamepad *gamepad); /** * Get the implementation-dependent path for an opened gamepad. * * \param gamepad a gamepad identifier previously returned by * SDL_OpenGamepad(). * \returns the implementation dependent path for the gamepad, or NULL if * there is no path or the identifier passed is invalid. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetGamepadPathForID */ extern SDL_DECLSPEC const char * SDLCALL SDL_GetGamepadPath(SDL_Gamepad *gamepad); /** * Get the type of an opened gamepad. * * \param gamepad the gamepad object to query. * \returns the gamepad type, or SDL_GAMEPAD_TYPE_UNKNOWN if it's not * available. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetGamepadTypeForID */ extern SDL_DECLSPEC SDL_GamepadType SDLCALL SDL_GetGamepadType(SDL_Gamepad *gamepad); /** * Get the type of an opened gamepad, ignoring any mapping override. * * \param gamepad the gamepad object to query. * \returns the gamepad type, or SDL_GAMEPAD_TYPE_UNKNOWN if it's not * available. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetRealGamepadTypeForID */ extern SDL_DECLSPEC SDL_GamepadType SDLCALL SDL_GetRealGamepadType(SDL_Gamepad *gamepad); /** * Get the player index of an opened gamepad. * * For XInput gamepads this returns the XInput user index. * * \param gamepad the gamepad object to query. * \returns the player index for gamepad, or -1 if it's not available. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_SetGamepadPlayerIndex */ extern SDL_DECLSPEC int SDLCALL SDL_GetGamepadPlayerIndex(SDL_Gamepad *gamepad); /** * Set the player index of an opened gamepad. * * \param gamepad the gamepad object to adjust. * \param player_index player index to assign to this gamepad, or -1 to clear * the player index and turn off player LEDs. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetGamepadPlayerIndex */ extern SDL_DECLSPEC bool SDLCALL SDL_SetGamepadPlayerIndex(SDL_Gamepad *gamepad, int player_index); /** * Get the USB vendor ID of an opened gamepad, if available. * * If the vendor ID isn't available this function returns 0. * * \param gamepad the gamepad object to query. * \returns the USB vendor ID, or zero if unavailable. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetGamepadVendorForID */ extern SDL_DECLSPEC Uint16 SDLCALL SDL_GetGamepadVendor(SDL_Gamepad *gamepad); /** * Get the USB product ID of an opened gamepad, if available. * * If the product ID isn't available this function returns 0. * * \param gamepad the gamepad object to query. * \returns the USB product ID, or zero if unavailable. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetGamepadProductForID */ extern SDL_DECLSPEC Uint16 SDLCALL SDL_GetGamepadProduct(SDL_Gamepad *gamepad); /** * Get the product version of an opened gamepad, if available. * * If the product version isn't available this function returns 0. * * \param gamepad the gamepad object to query. * \returns the USB product version, or zero if unavailable. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetGamepadProductVersionForID */ extern SDL_DECLSPEC Uint16 SDLCALL SDL_GetGamepadProductVersion(SDL_Gamepad *gamepad); /** * Get the firmware version of an opened gamepad, if available. * * If the firmware version isn't available this function returns 0. * * \param gamepad the gamepad object to query. * \returns the gamepad firmware version, or zero if unavailable. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC Uint16 SDLCALL SDL_GetGamepadFirmwareVersion(SDL_Gamepad *gamepad); /** * Get the serial number of an opened gamepad, if available. * * Returns the serial number of the gamepad, or NULL if it is not available. * * \param gamepad the gamepad object to query. * \returns the serial number, or NULL if unavailable. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC const char * SDLCALL SDL_GetGamepadSerial(SDL_Gamepad *gamepad); /** * Get the Steam Input handle of an opened gamepad, if available. * * Returns an InputHandle_t for the gamepad that can be used with Steam Input * API: https://partner.steamgames.com/doc/api/ISteamInput * * \param gamepad the gamepad object to query. * \returns the gamepad handle, or 0 if unavailable. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC Uint64 SDLCALL SDL_GetGamepadSteamHandle(SDL_Gamepad *gamepad); /** * Get the connection state of a gamepad. * * \param gamepad the gamepad object to query. * \returns the connection state on success or * `SDL_JOYSTICK_CONNECTION_INVALID` on failure; call SDL_GetError() * for more information. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC SDL_JoystickConnectionState SDLCALL SDL_GetGamepadConnectionState(SDL_Gamepad *gamepad); /** * Get the battery state of a gamepad. * * You should never take a battery status as absolute truth. Batteries * (especially failing batteries) are delicate hardware, and the values * reported here are best estimates based on what that hardware reports. It's * not uncommon for older batteries to lose stored power much faster than it * reports, or completely drain when reporting it has 20 percent left, etc. * * \param gamepad the gamepad object to query. * \param percent a pointer filled in with the percentage of battery life * left, between 0 and 100, or NULL to ignore. This will be * filled in with -1 we can't determine a value or there is no * battery. * \returns the current battery state. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC SDL_PowerState SDLCALL SDL_GetGamepadPowerInfo(SDL_Gamepad *gamepad, int *percent); /** * Check if a gamepad has been opened and is currently connected. * * \param gamepad a gamepad identifier previously returned by * SDL_OpenGamepad(). * \returns true if the gamepad has been opened and is currently connected, or * false if not. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC bool SDLCALL SDL_GamepadConnected(SDL_Gamepad *gamepad); /** * Get the underlying joystick from a gamepad. * * This function will give you a SDL_Joystick object, which allows you to use * the SDL_Joystick functions with a SDL_Gamepad object. This would be useful * for getting a joystick's position at any given time, even if it hasn't * moved (moving it would produce an event, which would have the axis' value). * * The pointer returned is owned by the SDL_Gamepad. You should not call * SDL_CloseJoystick() on it, for example, since doing so will likely cause * SDL to crash. * * \param gamepad the gamepad object that you want to get a joystick from. * \returns an SDL_Joystick object, or NULL on failure; call SDL_GetError() * for more information. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC SDL_Joystick * SDLCALL SDL_GetGamepadJoystick(SDL_Gamepad *gamepad); /** * Set the state of gamepad event processing. * * If gamepad events are disabled, you must call SDL_UpdateGamepads() yourself * and check the state of the gamepad when you want gamepad information. * * \param enabled whether to process gamepad events or not. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GamepadEventsEnabled * \sa SDL_UpdateGamepads */ extern SDL_DECLSPEC void SDLCALL SDL_SetGamepadEventsEnabled(bool enabled); /** * Query the state of gamepad event processing. * * If gamepad events are disabled, you must call SDL_UpdateGamepads() yourself * and check the state of the gamepad when you want gamepad information. * * \returns true if gamepad events are being processed, false otherwise. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_SetGamepadEventsEnabled */ extern SDL_DECLSPEC bool SDLCALL SDL_GamepadEventsEnabled(void); /** * Get the SDL joystick layer bindings for a gamepad. * * \param gamepad a gamepad. * \param count a pointer filled in with the number of bindings returned. * \returns a NULL terminated array of pointers to bindings or NULL on * failure; call SDL_GetError() for more information. This is a * single allocation that should be freed with SDL_free() when it is * no longer needed. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC SDL_GamepadBinding ** SDLCALL SDL_GetGamepadBindings(SDL_Gamepad *gamepad, int *count); /** * Manually pump gamepad updates if not using the loop. * * This function is called automatically by the event loop if events are * enabled. Under such circumstances, it will not be necessary to call this * function. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC void SDLCALL SDL_UpdateGamepads(void); /** * Convert a string into SDL_GamepadType enum. * * This function is called internally to translate SDL_Gamepad mapping strings * for the underlying joystick device into the consistent SDL_Gamepad mapping. * You do not normally need to call this function unless you are parsing * SDL_Gamepad mappings in your own code. * * \param str string representing a SDL_GamepadType type. * \returns the SDL_GamepadType enum corresponding to the input string, or * `SDL_GAMEPAD_TYPE_UNKNOWN` if no match was found. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetGamepadStringForType */ extern SDL_DECLSPEC SDL_GamepadType SDLCALL SDL_GetGamepadTypeFromString(const char *str); /** * Convert from an SDL_GamepadType enum to a string. * * \param type an enum value for a given SDL_GamepadType. * \returns a string for the given type, or NULL if an invalid type is * specified. The string returned is of the format used by * SDL_Gamepad mapping strings. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetGamepadTypeFromString */ extern SDL_DECLSPEC const char * SDLCALL SDL_GetGamepadStringForType(SDL_GamepadType type); /** * Convert a string into SDL_GamepadAxis enum. * * This function is called internally to translate SDL_Gamepad mapping strings * for the underlying joystick device into the consistent SDL_Gamepad mapping. * You do not normally need to call this function unless you are parsing * SDL_Gamepad mappings in your own code. * * Note specially that "righttrigger" and "lefttrigger" map to * `SDL_GAMEPAD_AXIS_RIGHT_TRIGGER` and `SDL_GAMEPAD_AXIS_LEFT_TRIGGER`, * respectively. * * \param str string representing a SDL_Gamepad axis. * \returns the SDL_GamepadAxis enum corresponding to the input string, or * `SDL_GAMEPAD_AXIS_INVALID` if no match was found. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetGamepadStringForAxis */ extern SDL_DECLSPEC SDL_GamepadAxis SDLCALL SDL_GetGamepadAxisFromString(const char *str); /** * Convert from an SDL_GamepadAxis enum to a string. * * \param axis an enum value for a given SDL_GamepadAxis. * \returns a string for the given axis, or NULL if an invalid axis is * specified. The string returned is of the format used by * SDL_Gamepad mapping strings. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetGamepadAxisFromString */ extern SDL_DECLSPEC const char * SDLCALL SDL_GetGamepadStringForAxis(SDL_GamepadAxis axis); /** * Query whether a gamepad has a given axis. * * This merely reports whether the gamepad's mapping defined this axis, as * that is all the information SDL has about the physical device. * * \param gamepad a gamepad. * \param axis an axis enum value (an SDL_GamepadAxis value). * \returns true if the gamepad has this axis, false otherwise. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GamepadHasButton * \sa SDL_GetGamepadAxis */ extern SDL_DECLSPEC bool SDLCALL SDL_GamepadHasAxis(SDL_Gamepad *gamepad, SDL_GamepadAxis axis); /** * Get the current state of an axis control on a gamepad. * * The axis indices start at index 0. * * For thumbsticks, the state is a value ranging from -32768 (up/left) to * 32767 (down/right). * * Triggers range from 0 when released to 32767 when fully pressed, and never * return a negative value. Note that this differs from the value reported by * the lower-level SDL_GetJoystickAxis(), which normally uses the full range. * * Note that for invalid gamepads or axes, this will return 0. Zero is also a * valid value in normal operation; usually it means a centered axis. * * \param gamepad a gamepad. * \param axis an axis index (one of the SDL_GamepadAxis values). * \returns axis state. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GamepadHasAxis * \sa SDL_GetGamepadButton */ extern SDL_DECLSPEC Sint16 SDLCALL SDL_GetGamepadAxis(SDL_Gamepad *gamepad, SDL_GamepadAxis axis); /** * Convert a string into an SDL_GamepadButton enum. * * This function is called internally to translate SDL_Gamepad mapping strings * for the underlying joystick device into the consistent SDL_Gamepad mapping. * You do not normally need to call this function unless you are parsing * SDL_Gamepad mappings in your own code. * * \param str string representing a SDL_Gamepad button. * \returns the SDL_GamepadButton enum corresponding to the input string, or * `SDL_GAMEPAD_BUTTON_INVALID` if no match was found. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetGamepadStringForButton */ extern SDL_DECLSPEC SDL_GamepadButton SDLCALL SDL_GetGamepadButtonFromString(const char *str); /** * Convert from an SDL_GamepadButton enum to a string. * * \param button an enum value for a given SDL_GamepadButton. * \returns a string for the given button, or NULL if an invalid button is * specified. The string returned is of the format used by * SDL_Gamepad mapping strings. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetGamepadButtonFromString */ extern SDL_DECLSPEC const char * SDLCALL SDL_GetGamepadStringForButton(SDL_GamepadButton button); /** * Query whether a gamepad has a given button. * * This merely reports whether the gamepad's mapping defined this button, as * that is all the information SDL has about the physical device. * * \param gamepad a gamepad. * \param button a button enum value (an SDL_GamepadButton value). * \returns true if the gamepad has this button, false otherwise. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GamepadHasAxis */ extern SDL_DECLSPEC bool SDLCALL SDL_GamepadHasButton(SDL_Gamepad *gamepad, SDL_GamepadButton button); /** * Get the current state of a button on a gamepad. * * \param gamepad a gamepad. * \param button a button index (one of the SDL_GamepadButton values). * \returns true if the button is pressed, false otherwise. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GamepadHasButton * \sa SDL_GetGamepadAxis */ extern SDL_DECLSPEC bool SDLCALL SDL_GetGamepadButton(SDL_Gamepad *gamepad, SDL_GamepadButton button); /** * Get the label of a button on a gamepad. * * \param type the type of gamepad to check. * \param button a button index (one of the SDL_GamepadButton values). * \returns the SDL_GamepadButtonLabel enum corresponding to the button label. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetGamepadButtonLabel */ extern SDL_DECLSPEC SDL_GamepadButtonLabel SDLCALL SDL_GetGamepadButtonLabelForType(SDL_GamepadType type, SDL_GamepadButton button); /** * Get the label of a button on a gamepad. * * \param gamepad a gamepad. * \param button a button index (one of the SDL_GamepadButton values). * \returns the SDL_GamepadButtonLabel enum corresponding to the button label. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetGamepadButtonLabelForType */ extern SDL_DECLSPEC SDL_GamepadButtonLabel SDLCALL SDL_GetGamepadButtonLabel(SDL_Gamepad *gamepad, SDL_GamepadButton button); /** * Get the number of touchpads on a gamepad. * * \param gamepad a gamepad. * \returns number of touchpads. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetNumGamepadTouchpadFingers */ extern SDL_DECLSPEC int SDLCALL SDL_GetNumGamepadTouchpads(SDL_Gamepad *gamepad); /** * Get the number of supported simultaneous fingers on a touchpad on a game * gamepad. * * \param gamepad a gamepad. * \param touchpad a touchpad. * \returns number of supported simultaneous fingers. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetGamepadTouchpadFinger * \sa SDL_GetNumGamepadTouchpads */ extern SDL_DECLSPEC int SDLCALL SDL_GetNumGamepadTouchpadFingers(SDL_Gamepad *gamepad, int touchpad); /** * Get the current state of a finger on a touchpad on a gamepad. * * \param gamepad a gamepad. * \param touchpad a touchpad. * \param finger a finger. * \param down a pointer filled with true if the finger is down, false * otherwise, may be NULL. * \param x a pointer filled with the x position, normalized 0 to 1, with the * origin in the upper left, may be NULL. * \param y a pointer filled with the y position, normalized 0 to 1, with the * origin in the upper left, may be NULL. * \param pressure a pointer filled with pressure value, may be NULL. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetNumGamepadTouchpadFingers */ extern SDL_DECLSPEC bool SDLCALL SDL_GetGamepadTouchpadFinger(SDL_Gamepad *gamepad, int touchpad, int finger, bool *down, float *x, float *y, float *pressure); /** * Return whether a gamepad has a particular sensor. * * \param gamepad the gamepad to query. * \param type the type of sensor to query. * \returns true if the sensor exists, false otherwise. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetGamepadSensorData * \sa SDL_GetGamepadSensorDataRate * \sa SDL_SetGamepadSensorEnabled */ extern SDL_DECLSPEC bool SDLCALL SDL_GamepadHasSensor(SDL_Gamepad *gamepad, SDL_SensorType type); /** * Set whether data reporting for a gamepad sensor is enabled. * * \param gamepad the gamepad to update. * \param type the type of sensor to enable/disable. * \param enabled whether data reporting should be enabled. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GamepadHasSensor * \sa SDL_GamepadSensorEnabled */ extern SDL_DECLSPEC bool SDLCALL SDL_SetGamepadSensorEnabled(SDL_Gamepad *gamepad, SDL_SensorType type, bool enabled); /** * Query whether sensor data reporting is enabled for a gamepad. * * \param gamepad the gamepad to query. * \param type the type of sensor to query. * \returns true if the sensor is enabled, false otherwise. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_SetGamepadSensorEnabled */ extern SDL_DECLSPEC bool SDLCALL SDL_GamepadSensorEnabled(SDL_Gamepad *gamepad, SDL_SensorType type); /** * Get the data rate (number of events per second) of a gamepad sensor. * * \param gamepad the gamepad to query. * \param type the type of sensor to query. * \returns the data rate, or 0.0f if the data rate is not available. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC float SDLCALL SDL_GetGamepadSensorDataRate(SDL_Gamepad *gamepad, SDL_SensorType type); /** * Get the current state of a gamepad sensor. * * The number of values and interpretation of the data is sensor dependent. * See the remarks in SDL_SensorType for details for each type of sensor. * * \param gamepad the gamepad to query. * \param type the type of sensor to query. * \param data a pointer filled with the current sensor state. * \param num_values the number of values to write to data. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC bool SDLCALL SDL_GetGamepadSensorData(SDL_Gamepad *gamepad, SDL_SensorType type, float *data, int num_values); /** * Start a rumble effect on a gamepad. * * Each call to this function cancels any previous rumble effect, and calling * it with 0 intensity stops any rumbling. * * This function requires you to process SDL events or call * SDL_UpdateJoysticks() to update rumble state. * * \param gamepad the gamepad to vibrate. * \param low_frequency_rumble the intensity of the low frequency (left) * rumble motor, from 0 to 0xFFFF. * \param high_frequency_rumble the intensity of the high frequency (right) * rumble motor, from 0 to 0xFFFF. * \param duration_ms the duration of the rumble effect, in milliseconds. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC bool SDLCALL SDL_RumbleGamepad(SDL_Gamepad *gamepad, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble, Uint32 duration_ms); /** * Start a rumble effect in the gamepad's triggers. * * Each call to this function cancels any previous trigger rumble effect, and * calling it with 0 intensity stops any rumbling. * * Note that this is rumbling of the _triggers_ and not the gamepad as a * whole. This is currently only supported on Xbox One gamepads. If you want * the (more common) whole-gamepad rumble, use SDL_RumbleGamepad() instead. * * This function requires you to process SDL events or call * SDL_UpdateJoysticks() to update rumble state. * * \param gamepad the gamepad to vibrate. * \param left_rumble the intensity of the left trigger rumble motor, from 0 * to 0xFFFF. * \param right_rumble the intensity of the right trigger rumble motor, from 0 * to 0xFFFF. * \param duration_ms the duration of the rumble effect, in milliseconds. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_RumbleGamepad */ extern SDL_DECLSPEC bool SDLCALL SDL_RumbleGamepadTriggers(SDL_Gamepad *gamepad, Uint16 left_rumble, Uint16 right_rumble, Uint32 duration_ms); /** * Update a gamepad's LED color. * * An example of a joystick LED is the light on the back of a PlayStation 4's * DualShock 4 controller. * * For gamepads with a single color LED, the maximum of the RGB values will be * used as the LED brightness. * * \param gamepad the gamepad to update. * \param red the intensity of the red LED. * \param green the intensity of the green LED. * \param blue the intensity of the blue LED. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC bool SDLCALL SDL_SetGamepadLED(SDL_Gamepad *gamepad, Uint8 red, Uint8 green, Uint8 blue); /** * Send a gamepad specific effect packet. * * \param gamepad the gamepad to affect. * \param data the data to send to the gamepad. * \param size the size of the data to send to the gamepad. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC bool SDLCALL SDL_SendGamepadEffect(SDL_Gamepad *gamepad, const void *data, int size); /** * Close a gamepad previously opened with SDL_OpenGamepad(). * * \param gamepad a gamepad identifier previously returned by * SDL_OpenGamepad(). * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_OpenGamepad */ extern SDL_DECLSPEC void SDLCALL SDL_CloseGamepad(SDL_Gamepad *gamepad); /** * Return the sfSymbolsName for a given button on a gamepad on Apple * platforms. * * \param gamepad the gamepad to query. * \param button a button on the gamepad. * \returns the sfSymbolsName or NULL if the name can't be found. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetGamepadAppleSFSymbolsNameForAxis */ extern SDL_DECLSPEC const char * SDLCALL SDL_GetGamepadAppleSFSymbolsNameForButton(SDL_Gamepad *gamepad, SDL_GamepadButton button); /** * Return the sfSymbolsName for a given axis on a gamepad on Apple platforms. * * \param gamepad the gamepad to query. * \param axis an axis on the gamepad. * \returns the sfSymbolsName or NULL if the name can't be found. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetGamepadAppleSFSymbolsNameForButton */ extern SDL_DECLSPEC const char * SDLCALL SDL_GetGamepadAppleSFSymbolsNameForAxis(SDL_Gamepad *gamepad, SDL_GamepadAxis axis); /* Ends C function definitions when using C++ */ #ifdef __cplusplus } #endif #include #endif /* SDL_gamepad_h_ */ ================================================ FILE: deps/include/SDL3/SDL_gpu.h ================================================ /* Simple DirectMedia Layer Copyright (C) 1997-2026 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ /* WIKI CATEGORY: GPU */ /** * # CategoryGPU * * The GPU API offers a cross-platform way for apps to talk to modern graphics * hardware. It offers both 3D graphics and compute support, in the style of * Metal, Vulkan, and Direct3D 12. * * A basic workflow might be something like this: * * The app creates a GPU device with SDL_CreateGPUDevice(), and assigns it to * a window with SDL_ClaimWindowForGPUDevice()--although strictly speaking you * can render offscreen entirely, perhaps for image processing, and not use a * window at all. * * Next, the app prepares static data (things that are created once and used * over and over). For example: * * - Shaders (programs that run on the GPU): use SDL_CreateGPUShader(). * - Vertex buffers (arrays of geometry data) and other rendering data: use * SDL_CreateGPUBuffer() and SDL_UploadToGPUBuffer(). * - Textures (images): use SDL_CreateGPUTexture() and * SDL_UploadToGPUTexture(). * - Samplers (how textures should be read from): use SDL_CreateGPUSampler(). * - Render pipelines (precalculated rendering state): use * SDL_CreateGPUGraphicsPipeline() * * To render, the app creates one or more command buffers, with * SDL_AcquireGPUCommandBuffer(). Command buffers collect rendering * instructions that will be submitted to the GPU in batch. Complex scenes can * use multiple command buffers, maybe configured across multiple threads in * parallel, as long as they are submitted in the correct order, but many apps * will just need one command buffer per frame. * * Rendering can happen to a texture (what other APIs call a "render target") * or it can happen to the swapchain texture (which is just a special texture * that represents a window's contents). The app can use * SDL_WaitAndAcquireGPUSwapchainTexture() to render to the window. * * Rendering actually happens in a Render Pass, which is encoded into a * command buffer. One can encode multiple render passes (or alternate between * render and compute passes) in a single command buffer, but many apps might * simply need a single render pass in a single command buffer. Render Passes * can render to up to four color textures and one depth texture * simultaneously. If the set of textures being rendered to needs to change, * the Render Pass must be ended and a new one must be begun. * * The app calls SDL_BeginGPURenderPass(). Then it sets states it needs for * each draw: * * - SDL_BindGPUGraphicsPipeline() * - SDL_SetGPUViewport() * - SDL_BindGPUVertexBuffers() * - SDL_BindGPUVertexSamplers() * - etc * * Then, make the actual draw commands with these states: * * - SDL_DrawGPUPrimitives() * - SDL_DrawGPUPrimitivesIndirect() * - SDL_DrawGPUIndexedPrimitivesIndirect() * - etc * * After all the drawing commands for a pass are complete, the app should call * SDL_EndGPURenderPass(). Once a render pass ends all render-related state is * reset. * * The app can begin new Render Passes and make new draws in the same command * buffer until the entire scene is rendered. * * Once all of the render commands for the scene are complete, the app calls * SDL_SubmitGPUCommandBuffer() to send it to the GPU for processing. * * If the app needs to read back data from texture or buffers, the API has an * efficient way of doing this, provided that the app is willing to tolerate * some latency. When the app uses SDL_DownloadFromGPUTexture() or * SDL_DownloadFromGPUBuffer(), submitting the command buffer with * SDL_SubmitGPUCommandBufferAndAcquireFence() will return a fence handle that * the app can poll or wait on in a thread. Once the fence indicates that the * command buffer is done processing, it is safe to read the downloaded data. * Make sure to call SDL_ReleaseGPUFence() when done with the fence. * * The API also has "compute" support. The app calls SDL_BeginGPUComputePass() * with compute-writeable textures and/or buffers, which can be written to in * a compute shader. Then it sets states it needs for the compute dispatches: * * - SDL_BindGPUComputePipeline() * - SDL_BindGPUComputeStorageBuffers() * - SDL_BindGPUComputeStorageTextures() * * Then, dispatch compute work: * * - SDL_DispatchGPUCompute() * * For advanced users, this opens up powerful GPU-driven workflows. * * Graphics and compute pipelines require the use of shaders, which as * mentioned above are small programs executed on the GPU. Each backend * (Vulkan, Metal, D3D12) requires a different shader format. When the app * creates the GPU device, the app lets the device know which shader formats * the app can provide. It will then select the appropriate backend depending * on the available shader formats and the backends available on the platform. * When creating shaders, the app must provide the correct shader format for * the selected backend. If you would like to learn more about why the API * works this way, there is a detailed * [blog post](https://moonside.games/posts/layers-all-the-way-down/) * explaining this situation. * * It is optimal for apps to pre-compile the shader formats they might use, * but for ease of use SDL provides a separate project, * [SDL_shadercross](https://github.com/libsdl-org/SDL_shadercross) * , for performing runtime shader cross-compilation. It also has a CLI * interface for offline precompilation as well. * * This is an extremely quick overview that leaves out several important * details. Already, though, one can see that GPU programming can be quite * complex! If you just need simple 2D graphics, the * [Render API](https://wiki.libsdl.org/SDL3/CategoryRender) * is much easier to use but still hardware-accelerated. That said, even for * 2D applications the performance benefits and expressiveness of the GPU API * are significant. * * The GPU API targets a feature set with a wide range of hardware support and * ease of portability. It is designed so that the app won't have to branch * itself by querying feature support. If you need cutting-edge features with * limited hardware support, this API is probably not for you. * * Examples demonstrating proper usage of this API can be found * [here](https://github.com/TheSpydog/SDL_gpu_examples) * . * * ## Performance considerations * * Here are some basic tips for maximizing your rendering performance. * * - Beginning a new render pass is relatively expensive. Use as few render * passes as you can. * - Minimize the amount of state changes. For example, binding a pipeline is * relatively cheap, but doing it hundreds of times when you don't need to * will slow the performance significantly. * - Perform your data uploads as early as possible in the frame. * - Don't churn resources. Creating and releasing resources is expensive. * It's better to create what you need up front and cache it. * - Don't use uniform buffers for large amounts of data (more than a matrix * or so). Use a storage buffer instead. * - Use cycling correctly. There is a detailed explanation of cycling further * below. * - Use culling techniques to minimize pixel writes. The less writing the GPU * has to do the better. Culling can be a very advanced topic but even * simple culling techniques can boost performance significantly. * * In general try to remember the golden rule of performance: doing things is * more expensive than not doing things. Don't Touch The Driver! * * ## FAQ * * **Question: When are you adding more advanced features, like ray tracing or * mesh shaders?** * * Answer: We don't have immediate plans to add more bleeding-edge features, * but we certainly might in the future, when these features prove worthwhile, * and reasonable to implement across several platforms and underlying APIs. * So while these things are not in the "never" category, they are definitely * not "near future" items either. * * **Question: Why is my shader not working?** * * Answer: A common oversight when using shaders is not properly laying out * the shader resources/registers correctly. The GPU API is very strict with * how it wants resources to be laid out and it's difficult for the API to * automatically validate shaders to see if they have a compatible layout. See * the documentation for SDL_CreateGPUShader() and * SDL_CreateGPUComputePipeline() for information on the expected layout. * * Another common issue is not setting the correct number of samplers, * textures, and buffers in SDL_GPUShaderCreateInfo. If possible use shader * reflection to extract the required information from the shader * automatically instead of manually filling in the struct's values. * * **Question: My application isn't performing very well. Is this the GPU * API's fault?** * * Answer: No. Long answer: The GPU API is a relatively thin layer over the * underlying graphics API. While it's possible that we have done something * inefficiently, it's very unlikely especially if you are relatively * inexperienced with GPU rendering. Please see the performance tips above and * make sure you are following them. Additionally, tools like * [RenderDoc](https://renderdoc.org/) * can be very helpful for diagnosing incorrect behavior and performance * issues. * * ## System Requirements * * ### Vulkan * * SDL driver name: "vulkan" (for use in SDL_CreateGPUDevice() and * SDL_PROP_GPU_DEVICE_CREATE_NAME_STRING) * * Supported on Windows, Linux, Nintendo Switch, and certain Android devices. * Requires Vulkan 1.0 with the following extensions and device features: * * - `VK_KHR_swapchain` * - `VK_KHR_maintenance1` * - `independentBlend` * - `imageCubeArray` * - `depthClamp` * - `shaderClipDistance` * - `drawIndirectFirstInstance` * - `sampleRateShading` * * You can remove some of these requirements to increase compatibility with * Android devices by using these properties when creating the GPU device with * SDL_CreateGPUDeviceWithProperties(): * * - SDL_PROP_GPU_DEVICE_CREATE_FEATURE_CLIP_DISTANCE_BOOLEAN * - SDL_PROP_GPU_DEVICE_CREATE_FEATURE_DEPTH_CLAMPING_BOOLEAN * - SDL_PROP_GPU_DEVICE_CREATE_FEATURE_INDIRECT_DRAW_FIRST_INSTANCE_BOOLEAN * - SDL_PROP_GPU_DEVICE_CREATE_FEATURE_ANISOTROPY_BOOLEAN * * ### D3D12 * * SDL driver name: "direct3d12" * * Supported on Windows 10 or newer, Xbox One (GDK), and Xbox Series X|S * (GDK). Requires a GPU that supports DirectX 12 Feature Level 11_0 and * Resource Binding Tier 2 or above. * * You can remove the Tier 2 resource binding requirement to support Intel * Haswell and Broadwell GPUs by using this property when creating the GPU * device with SDL_CreateGPUDeviceWithProperties(): * * - SDL_PROP_GPU_DEVICE_CREATE_D3D12_ALLOW_FEWER_RESOURCE_SLOTS_BOOLEAN * * ### Metal * * SDL driver name: "metal" * * Supported on macOS 10.14+ and iOS/tvOS 13.0+. Hardware requirements vary by * operating system: * * - macOS requires an Apple Silicon or * [Intel Mac2 family](https://developer.apple.com/documentation/metal/mtlfeatureset/mtlfeatureset_macos_gpufamily2_v1?language=objc) * GPU * - iOS/tvOS requires an A9 GPU or newer * - iOS Simulator and tvOS Simulator are unsupported * * ## Coordinate System * * The GPU API uses a left-handed coordinate system, following the convention * of D3D12 and Metal. Specifically: * * - **Normalized Device Coordinates:** The lower-left corner has an x,y * coordinate of `(-1.0, -1.0)`. The upper-right corner is `(1.0, 1.0)`. Z * values range from `[0.0, 1.0]` where 0 is the near plane. * - **Viewport Coordinates:** The top-left corner has an x,y coordinate of * `(0, 0)` and extends to the bottom-right corner at `(viewportWidth, * viewportHeight)`. +Y is down. * - **Texture Coordinates:** The top-left corner has an x,y coordinate of * `(0, 0)` and extends to the bottom-right corner at `(1.0, 1.0)`. +Y is * down. * * If the backend driver differs from this convention (e.g. Vulkan, which has * an NDC that assumes +Y is down), SDL will automatically convert the * coordinate system behind the scenes, so you don't need to perform any * coordinate flipping logic in your shaders. * * ## Uniform Data * * Uniforms are for passing data to shaders. The uniform data will be constant * across all executions of the shader. * * There are 4 available uniform slots per shader stage (where the stages are * vertex, fragment, and compute). Uniform data pushed to a slot on a stage * keeps its value throughout the command buffer until you call the relevant * Push function on that slot again. * * For example, you could write your vertex shaders to read a camera matrix * from uniform binding slot 0, push the camera matrix at the start of the * command buffer, and that data will be used for every subsequent draw call. * * It is valid to push uniform data during a render or compute pass. * * Uniforms are best for pushing small amounts of data. If you are pushing * more than a matrix or two per call you should consider using a storage * buffer instead. * * ## A Note On Cycling * * When using a command buffer, operations do not occur immediately - they * occur some time after the command buffer is submitted. * * When a resource is used in a pending or active command buffer, it is * considered to be "bound". When a resource is no longer used in any pending * or active command buffers, it is considered to be "unbound". * * If data resources are bound, it is unspecified when that data will be * unbound unless you acquire a fence when submitting the command buffer and * wait on it. However, this doesn't mean you need to track resource usage * manually. * * All of the functions and structs that involve writing to a resource have a * "cycle" bool. SDL_GPUTransferBuffer, SDL_GPUBuffer, and SDL_GPUTexture all * effectively function as ring buffers on internal resources. When cycle is * true, if the resource is bound, the cycle rotates to the next unbound * internal resource, or if none are available, a new one is created. This * means you don't have to worry about complex state tracking and * synchronization as long as cycling is correctly employed. * * For example: you can call SDL_MapGPUTransferBuffer(), write texture data, * SDL_UnmapGPUTransferBuffer(), and then SDL_UploadToGPUTexture(). The next * time you write texture data to the transfer buffer, if you set the cycle * param to true, you don't have to worry about overwriting any data that is * not yet uploaded. * * Another example: If you are using a texture in a render pass every frame, * this can cause a data dependency between frames. If you set cycle to true * in the SDL_GPUColorTargetInfo struct, you can prevent this data dependency. * * Cycling will never undefine already bound data. When cycling, all data in * the resource is considered to be undefined for subsequent commands until * that data is written again. You must take care not to read undefined data. * * Note that when cycling a texture, the entire texture will be cycled, even * if only part of the texture is used in the call, so you must consider the * entire texture to contain undefined data after cycling. * * You must also take care not to overwrite a section of data that has been * referenced in a command without cycling first. It is OK to overwrite * unreferenced data in a bound resource without cycling, but overwriting a * section of data that has already been referenced will produce unexpected * results. * * ## Debugging * * At some point of your GPU journey, you will probably encounter issues that * are not traceable with regular debugger - for example, your code compiles * but you get an empty screen, or your shader fails in runtime. * * For debugging such cases, there are tools that allow visually inspecting * the whole GPU frame, every drawcall, every bound resource, memory buffers, * etc. They are the following, per platform: * * * For Windows/Linux, use * [RenderDoc](https://renderdoc.org/) * * For MacOS (Metal), use Xcode built-in debugger (Open XCode, go to Debug > * Debug Executable..., select your application, set "GPU Frame Capture" to * "Metal" in scheme "Options" window, run your app, and click the small * Metal icon on the bottom to capture a frame) * * Aside from that, you may want to enable additional debug layers to receive * more detailed error messages, based on your GPU backend: * * * For D3D12, the debug layer is an optional feature that can be installed * via "Windows Settings -> System -> Optional features" and adding the * "Graphics Tools" optional feature. * * For Vulkan, you will need to install Vulkan SDK on Windows, and on Linux, * you usually have some sort of `vulkan-validation-layers` system package * that should be installed. * * For Metal, it should be enough just to run the application from XCode to * receive detailed errors or warnings in the output. * * Don't hesitate to use tools as RenderDoc when encountering runtime issues * or unexpected output on screen, quick GPU frame inspection can usually help * you fix the majority of such problems. */ #ifndef SDL_gpu_h_ #define SDL_gpu_h_ #include #include #include #include #include #include #include #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ /* Type Declarations */ /** * An opaque handle representing the SDL_GPU context. * * \since This struct is available since SDL 3.2.0. */ typedef struct SDL_GPUDevice SDL_GPUDevice; /** * An opaque handle representing a buffer. * * Used for vertices, indices, indirect draw commands, and general compute * data. * * \since This struct is available since SDL 3.2.0. * * \sa SDL_CreateGPUBuffer * \sa SDL_UploadToGPUBuffer * \sa SDL_DownloadFromGPUBuffer * \sa SDL_CopyGPUBufferToBuffer * \sa SDL_BindGPUVertexBuffers * \sa SDL_BindGPUIndexBuffer * \sa SDL_BindGPUVertexStorageBuffers * \sa SDL_BindGPUFragmentStorageBuffers * \sa SDL_DrawGPUPrimitivesIndirect * \sa SDL_DrawGPUIndexedPrimitivesIndirect * \sa SDL_BindGPUComputeStorageBuffers * \sa SDL_DispatchGPUComputeIndirect * \sa SDL_ReleaseGPUBuffer */ typedef struct SDL_GPUBuffer SDL_GPUBuffer; /** * An opaque handle representing a transfer buffer. * * Used for transferring data to and from the device. * * \since This struct is available since SDL 3.2.0. * * \sa SDL_CreateGPUTransferBuffer * \sa SDL_MapGPUTransferBuffer * \sa SDL_UnmapGPUTransferBuffer * \sa SDL_UploadToGPUBuffer * \sa SDL_UploadToGPUTexture * \sa SDL_DownloadFromGPUBuffer * \sa SDL_DownloadFromGPUTexture * \sa SDL_ReleaseGPUTransferBuffer */ typedef struct SDL_GPUTransferBuffer SDL_GPUTransferBuffer; /** * An opaque handle representing a texture. * * \since This struct is available since SDL 3.2.0. * * \sa SDL_CreateGPUTexture * \sa SDL_UploadToGPUTexture * \sa SDL_DownloadFromGPUTexture * \sa SDL_CopyGPUTextureToTexture * \sa SDL_BindGPUVertexSamplers * \sa SDL_BindGPUVertexStorageTextures * \sa SDL_BindGPUFragmentSamplers * \sa SDL_BindGPUFragmentStorageTextures * \sa SDL_BindGPUComputeStorageTextures * \sa SDL_GenerateMipmapsForGPUTexture * \sa SDL_BlitGPUTexture * \sa SDL_ReleaseGPUTexture */ typedef struct SDL_GPUTexture SDL_GPUTexture; /** * An opaque handle representing a sampler. * * \since This struct is available since SDL 3.2.0. * * \sa SDL_CreateGPUSampler * \sa SDL_BindGPUVertexSamplers * \sa SDL_BindGPUFragmentSamplers * \sa SDL_ReleaseGPUSampler */ typedef struct SDL_GPUSampler SDL_GPUSampler; /** * An opaque handle representing a compiled shader object. * * \since This struct is available since SDL 3.2.0. * * \sa SDL_CreateGPUShader * \sa SDL_CreateGPUGraphicsPipeline * \sa SDL_ReleaseGPUShader */ typedef struct SDL_GPUShader SDL_GPUShader; /** * An opaque handle representing a compute pipeline. * * Used during compute passes. * * \since This struct is available since SDL 3.2.0. * * \sa SDL_CreateGPUComputePipeline * \sa SDL_BindGPUComputePipeline * \sa SDL_ReleaseGPUComputePipeline */ typedef struct SDL_GPUComputePipeline SDL_GPUComputePipeline; /** * An opaque handle representing a graphics pipeline. * * Used during render passes. * * \since This struct is available since SDL 3.2.0. * * \sa SDL_CreateGPUGraphicsPipeline * \sa SDL_BindGPUGraphicsPipeline * \sa SDL_ReleaseGPUGraphicsPipeline */ typedef struct SDL_GPUGraphicsPipeline SDL_GPUGraphicsPipeline; /** * An opaque handle representing a command buffer. * * Most state is managed via command buffers. When setting state using a * command buffer, that state is local to the command buffer. * * Commands only begin execution on the GPU once SDL_SubmitGPUCommandBuffer is * called. Once the command buffer is submitted, it is no longer valid to use * it. * * Command buffers are executed in submission order. If you submit command * buffer A and then command buffer B all commands in A will begin executing * before any command in B begins executing. * * In multi-threading scenarios, you should only access a command buffer on * the thread you acquired it from. * * \since This struct is available since SDL 3.2.0. * * \sa SDL_AcquireGPUCommandBuffer * \sa SDL_SubmitGPUCommandBuffer * \sa SDL_SubmitGPUCommandBufferAndAcquireFence */ typedef struct SDL_GPUCommandBuffer SDL_GPUCommandBuffer; /** * An opaque handle representing a render pass. * * This handle is transient and should not be held or referenced after * SDL_EndGPURenderPass is called. * * \since This struct is available since SDL 3.2.0. * * \sa SDL_BeginGPURenderPass * \sa SDL_EndGPURenderPass */ typedef struct SDL_GPURenderPass SDL_GPURenderPass; /** * An opaque handle representing a compute pass. * * This handle is transient and should not be held or referenced after * SDL_EndGPUComputePass is called. * * \since This struct is available since SDL 3.2.0. * * \sa SDL_BeginGPUComputePass * \sa SDL_EndGPUComputePass */ typedef struct SDL_GPUComputePass SDL_GPUComputePass; /** * An opaque handle representing a copy pass. * * This handle is transient and should not be held or referenced after * SDL_EndGPUCopyPass is called. * * \since This struct is available since SDL 3.2.0. * * \sa SDL_BeginGPUCopyPass * \sa SDL_EndGPUCopyPass */ typedef struct SDL_GPUCopyPass SDL_GPUCopyPass; /** * An opaque handle representing a fence. * * \since This struct is available since SDL 3.2.0. * * \sa SDL_SubmitGPUCommandBufferAndAcquireFence * \sa SDL_QueryGPUFence * \sa SDL_WaitForGPUFences * \sa SDL_ReleaseGPUFence */ typedef struct SDL_GPUFence SDL_GPUFence; /** * Specifies the primitive topology of a graphics pipeline. * * If you are using POINTLIST you must include a point size output in the * vertex shader. * * - For HLSL compiling to SPIRV you must decorate a float output with * [[vk::builtin("PointSize")]]. * - For GLSL you must set the gl_PointSize builtin. * - For MSL you must include a float output with the [[point_size]] * decorator. * * Note that sized point topology is totally unsupported on D3D12. Any size * other than 1 will be ignored. In general, you should avoid using point * topology for both compatibility and performance reasons. You WILL regret * using it. * * \since This enum is available since SDL 3.2.0. * * \sa SDL_CreateGPUGraphicsPipeline */ typedef enum SDL_GPUPrimitiveType { SDL_GPU_PRIMITIVETYPE_TRIANGLELIST, /**< A series of separate triangles. */ SDL_GPU_PRIMITIVETYPE_TRIANGLESTRIP, /**< A series of connected triangles. */ SDL_GPU_PRIMITIVETYPE_LINELIST, /**< A series of separate lines. */ SDL_GPU_PRIMITIVETYPE_LINESTRIP, /**< A series of connected lines. */ SDL_GPU_PRIMITIVETYPE_POINTLIST /**< A series of separate points. */ } SDL_GPUPrimitiveType; /** * Specifies how the contents of a texture attached to a render pass are * treated at the beginning of the render pass. * * \since This enum is available since SDL 3.2.0. * * \sa SDL_BeginGPURenderPass */ typedef enum SDL_GPULoadOp { SDL_GPU_LOADOP_LOAD, /**< The previous contents of the texture will be preserved. */ SDL_GPU_LOADOP_CLEAR, /**< The contents of the texture will be cleared to a color. */ SDL_GPU_LOADOP_DONT_CARE /**< The previous contents of the texture need not be preserved. The contents will be undefined. */ } SDL_GPULoadOp; /** * Specifies how the contents of a texture attached to a render pass are * treated at the end of the render pass. * * \since This enum is available since SDL 3.2.0. * * \sa SDL_BeginGPURenderPass */ typedef enum SDL_GPUStoreOp { SDL_GPU_STOREOP_STORE, /**< The contents generated during the render pass will be written to memory. */ SDL_GPU_STOREOP_DONT_CARE, /**< The contents generated during the render pass are not needed and may be discarded. The contents will be undefined. */ SDL_GPU_STOREOP_RESOLVE, /**< The multisample contents generated during the render pass will be resolved to a non-multisample texture. The contents in the multisample texture may then be discarded and will be undefined. */ SDL_GPU_STOREOP_RESOLVE_AND_STORE /**< The multisample contents generated during the render pass will be resolved to a non-multisample texture. The contents in the multisample texture will be written to memory. */ } SDL_GPUStoreOp; /** * Specifies the size of elements in an index buffer. * * \since This enum is available since SDL 3.2.0. * * \sa SDL_CreateGPUGraphicsPipeline */ typedef enum SDL_GPUIndexElementSize { SDL_GPU_INDEXELEMENTSIZE_16BIT, /**< The index elements are 16-bit. */ SDL_GPU_INDEXELEMENTSIZE_32BIT /**< The index elements are 32-bit. */ } SDL_GPUIndexElementSize; /** * Specifies the pixel format of a texture. * * Texture format support varies depending on driver, hardware, and usage * flags. In general, you should use SDL_GPUTextureSupportsFormat to query if * a format is supported before using it. However, there are a few guaranteed * formats. * * FIXME: Check universal support for 32-bit component formats FIXME: Check * universal support for SIMULTANEOUS_READ_WRITE * * For SAMPLER usage, the following formats are universally supported: * * - R8G8B8A8_UNORM * - B8G8R8A8_UNORM * - R8_UNORM * - R8_SNORM * - R8G8_UNORM * - R8G8_SNORM * - R8G8B8A8_SNORM * - R16_FLOAT * - R16G16_FLOAT * - R16G16B16A16_FLOAT * - R32_FLOAT * - R32G32_FLOAT * - R32G32B32A32_FLOAT * - R11G11B10_UFLOAT * - R8G8B8A8_UNORM_SRGB * - B8G8R8A8_UNORM_SRGB * - D16_UNORM * * For COLOR_TARGET usage, the following formats are universally supported: * * - R8G8B8A8_UNORM * - B8G8R8A8_UNORM * - R8_UNORM * - R16_FLOAT * - R16G16_FLOAT * - R16G16B16A16_FLOAT * - R32_FLOAT * - R32G32_FLOAT * - R32G32B32A32_FLOAT * - R8_UINT * - R8G8_UINT * - R8G8B8A8_UINT * - R16_UINT * - R16G16_UINT * - R16G16B16A16_UINT * - R8_INT * - R8G8_INT * - R8G8B8A8_INT * - R16_INT * - R16G16_INT * - R16G16B16A16_INT * - R8G8B8A8_UNORM_SRGB * - B8G8R8A8_UNORM_SRGB * * For STORAGE usages, the following formats are universally supported: * * - R8G8B8A8_UNORM * - R8G8B8A8_SNORM * - R16G16B16A16_FLOAT * - R32_FLOAT * - R32G32_FLOAT * - R32G32B32A32_FLOAT * - R8G8B8A8_UINT * - R16G16B16A16_UINT * - R8G8B8A8_INT * - R16G16B16A16_INT * * For DEPTH_STENCIL_TARGET usage, the following formats are universally * supported: * * - D16_UNORM * - Either (but not necessarily both!) D24_UNORM or D32_FLOAT * - Either (but not necessarily both!) D24_UNORM_S8_UINT or D32_FLOAT_S8_UINT * * Unless D16_UNORM is sufficient for your purposes, always check which of * D24/D32 is supported before creating a depth-stencil texture! * * \since This enum is available since SDL 3.2.0. * * \sa SDL_CreateGPUTexture * \sa SDL_GPUTextureSupportsFormat */ typedef enum SDL_GPUTextureFormat { SDL_GPU_TEXTUREFORMAT_INVALID, /* Unsigned Normalized Float Color Formats */ SDL_GPU_TEXTUREFORMAT_A8_UNORM, SDL_GPU_TEXTUREFORMAT_R8_UNORM, SDL_GPU_TEXTUREFORMAT_R8G8_UNORM, SDL_GPU_TEXTUREFORMAT_R8G8B8A8_UNORM, SDL_GPU_TEXTUREFORMAT_R16_UNORM, SDL_GPU_TEXTUREFORMAT_R16G16_UNORM, SDL_GPU_TEXTUREFORMAT_R16G16B16A16_UNORM, SDL_GPU_TEXTUREFORMAT_R10G10B10A2_UNORM, SDL_GPU_TEXTUREFORMAT_B5G6R5_UNORM, SDL_GPU_TEXTUREFORMAT_B5G5R5A1_UNORM, SDL_GPU_TEXTUREFORMAT_B4G4R4A4_UNORM, SDL_GPU_TEXTUREFORMAT_B8G8R8A8_UNORM, /* Compressed Unsigned Normalized Float Color Formats */ SDL_GPU_TEXTUREFORMAT_BC1_RGBA_UNORM, SDL_GPU_TEXTUREFORMAT_BC2_RGBA_UNORM, SDL_GPU_TEXTUREFORMAT_BC3_RGBA_UNORM, SDL_GPU_TEXTUREFORMAT_BC4_R_UNORM, SDL_GPU_TEXTUREFORMAT_BC5_RG_UNORM, SDL_GPU_TEXTUREFORMAT_BC7_RGBA_UNORM, /* Compressed Signed Float Color Formats */ SDL_GPU_TEXTUREFORMAT_BC6H_RGB_FLOAT, /* Compressed Unsigned Float Color Formats */ SDL_GPU_TEXTUREFORMAT_BC6H_RGB_UFLOAT, /* Signed Normalized Float Color Formats */ SDL_GPU_TEXTUREFORMAT_R8_SNORM, SDL_GPU_TEXTUREFORMAT_R8G8_SNORM, SDL_GPU_TEXTUREFORMAT_R8G8B8A8_SNORM, SDL_GPU_TEXTUREFORMAT_R16_SNORM, SDL_GPU_TEXTUREFORMAT_R16G16_SNORM, SDL_GPU_TEXTUREFORMAT_R16G16B16A16_SNORM, /* Signed Float Color Formats */ SDL_GPU_TEXTUREFORMAT_R16_FLOAT, SDL_GPU_TEXTUREFORMAT_R16G16_FLOAT, SDL_GPU_TEXTUREFORMAT_R16G16B16A16_FLOAT, SDL_GPU_TEXTUREFORMAT_R32_FLOAT, SDL_GPU_TEXTUREFORMAT_R32G32_FLOAT, SDL_GPU_TEXTUREFORMAT_R32G32B32A32_FLOAT, /* Unsigned Float Color Formats */ SDL_GPU_TEXTUREFORMAT_R11G11B10_UFLOAT, /* Unsigned Integer Color Formats */ SDL_GPU_TEXTUREFORMAT_R8_UINT, SDL_GPU_TEXTUREFORMAT_R8G8_UINT, SDL_GPU_TEXTUREFORMAT_R8G8B8A8_UINT, SDL_GPU_TEXTUREFORMAT_R16_UINT, SDL_GPU_TEXTUREFORMAT_R16G16_UINT, SDL_GPU_TEXTUREFORMAT_R16G16B16A16_UINT, SDL_GPU_TEXTUREFORMAT_R32_UINT, SDL_GPU_TEXTUREFORMAT_R32G32_UINT, SDL_GPU_TEXTUREFORMAT_R32G32B32A32_UINT, /* Signed Integer Color Formats */ SDL_GPU_TEXTUREFORMAT_R8_INT, SDL_GPU_TEXTUREFORMAT_R8G8_INT, SDL_GPU_TEXTUREFORMAT_R8G8B8A8_INT, SDL_GPU_TEXTUREFORMAT_R16_INT, SDL_GPU_TEXTUREFORMAT_R16G16_INT, SDL_GPU_TEXTUREFORMAT_R16G16B16A16_INT, SDL_GPU_TEXTUREFORMAT_R32_INT, SDL_GPU_TEXTUREFORMAT_R32G32_INT, SDL_GPU_TEXTUREFORMAT_R32G32B32A32_INT, /* SRGB Unsigned Normalized Color Formats */ SDL_GPU_TEXTUREFORMAT_R8G8B8A8_UNORM_SRGB, SDL_GPU_TEXTUREFORMAT_B8G8R8A8_UNORM_SRGB, /* Compressed SRGB Unsigned Normalized Color Formats */ SDL_GPU_TEXTUREFORMAT_BC1_RGBA_UNORM_SRGB, SDL_GPU_TEXTUREFORMAT_BC2_RGBA_UNORM_SRGB, SDL_GPU_TEXTUREFORMAT_BC3_RGBA_UNORM_SRGB, SDL_GPU_TEXTUREFORMAT_BC7_RGBA_UNORM_SRGB, /* Depth Formats */ SDL_GPU_TEXTUREFORMAT_D16_UNORM, SDL_GPU_TEXTUREFORMAT_D24_UNORM, SDL_GPU_TEXTUREFORMAT_D32_FLOAT, SDL_GPU_TEXTUREFORMAT_D24_UNORM_S8_UINT, SDL_GPU_TEXTUREFORMAT_D32_FLOAT_S8_UINT, /* Compressed ASTC Normalized Float Color Formats*/ SDL_GPU_TEXTUREFORMAT_ASTC_4x4_UNORM, SDL_GPU_TEXTUREFORMAT_ASTC_5x4_UNORM, SDL_GPU_TEXTUREFORMAT_ASTC_5x5_UNORM, SDL_GPU_TEXTUREFORMAT_ASTC_6x5_UNORM, SDL_GPU_TEXTUREFORMAT_ASTC_6x6_UNORM, SDL_GPU_TEXTUREFORMAT_ASTC_8x5_UNORM, SDL_GPU_TEXTUREFORMAT_ASTC_8x6_UNORM, SDL_GPU_TEXTUREFORMAT_ASTC_8x8_UNORM, SDL_GPU_TEXTUREFORMAT_ASTC_10x5_UNORM, SDL_GPU_TEXTUREFORMAT_ASTC_10x6_UNORM, SDL_GPU_TEXTUREFORMAT_ASTC_10x8_UNORM, SDL_GPU_TEXTUREFORMAT_ASTC_10x10_UNORM, SDL_GPU_TEXTUREFORMAT_ASTC_12x10_UNORM, SDL_GPU_TEXTUREFORMAT_ASTC_12x12_UNORM, /* Compressed SRGB ASTC Normalized Float Color Formats*/ SDL_GPU_TEXTUREFORMAT_ASTC_4x4_UNORM_SRGB, SDL_GPU_TEXTUREFORMAT_ASTC_5x4_UNORM_SRGB, SDL_GPU_TEXTUREFORMAT_ASTC_5x5_UNORM_SRGB, SDL_GPU_TEXTUREFORMAT_ASTC_6x5_UNORM_SRGB, SDL_GPU_TEXTUREFORMAT_ASTC_6x6_UNORM_SRGB, SDL_GPU_TEXTUREFORMAT_ASTC_8x5_UNORM_SRGB, SDL_GPU_TEXTUREFORMAT_ASTC_8x6_UNORM_SRGB, SDL_GPU_TEXTUREFORMAT_ASTC_8x8_UNORM_SRGB, SDL_GPU_TEXTUREFORMAT_ASTC_10x5_UNORM_SRGB, SDL_GPU_TEXTUREFORMAT_ASTC_10x6_UNORM_SRGB, SDL_GPU_TEXTUREFORMAT_ASTC_10x8_UNORM_SRGB, SDL_GPU_TEXTUREFORMAT_ASTC_10x10_UNORM_SRGB, SDL_GPU_TEXTUREFORMAT_ASTC_12x10_UNORM_SRGB, SDL_GPU_TEXTUREFORMAT_ASTC_12x12_UNORM_SRGB, /* Compressed ASTC Signed Float Color Formats*/ SDL_GPU_TEXTUREFORMAT_ASTC_4x4_FLOAT, SDL_GPU_TEXTUREFORMAT_ASTC_5x4_FLOAT, SDL_GPU_TEXTUREFORMAT_ASTC_5x5_FLOAT, SDL_GPU_TEXTUREFORMAT_ASTC_6x5_FLOAT, SDL_GPU_TEXTUREFORMAT_ASTC_6x6_FLOAT, SDL_GPU_TEXTUREFORMAT_ASTC_8x5_FLOAT, SDL_GPU_TEXTUREFORMAT_ASTC_8x6_FLOAT, SDL_GPU_TEXTUREFORMAT_ASTC_8x8_FLOAT, SDL_GPU_TEXTUREFORMAT_ASTC_10x5_FLOAT, SDL_GPU_TEXTUREFORMAT_ASTC_10x6_FLOAT, SDL_GPU_TEXTUREFORMAT_ASTC_10x8_FLOAT, SDL_GPU_TEXTUREFORMAT_ASTC_10x10_FLOAT, SDL_GPU_TEXTUREFORMAT_ASTC_12x10_FLOAT, SDL_GPU_TEXTUREFORMAT_ASTC_12x12_FLOAT } SDL_GPUTextureFormat; /** * Specifies how a texture is intended to be used by the client. * * A texture must have at least one usage flag. Note that some usage flag * combinations are invalid. * * With regards to compute storage usage, READ | WRITE means that you can have * shader A that only writes into the texture and shader B that only reads * from the texture and bind the same texture to either shader respectively. * SIMULTANEOUS means that you can do reads and writes within the same shader * or compute pass. It also implies that atomic ops can be used, since those * are read-modify-write operations. If you use SIMULTANEOUS, you are * responsible for avoiding data races, as there is no data synchronization * within a compute pass. Note that SIMULTANEOUS usage is only supported by a * limited number of texture formats. * * \since This datatype is available since SDL 3.2.0. * * \sa SDL_CreateGPUTexture */ typedef Uint32 SDL_GPUTextureUsageFlags; #define SDL_GPU_TEXTUREUSAGE_SAMPLER (1u << 0) /**< Texture supports sampling. */ #define SDL_GPU_TEXTUREUSAGE_COLOR_TARGET (1u << 1) /**< Texture is a color render target. */ #define SDL_GPU_TEXTUREUSAGE_DEPTH_STENCIL_TARGET (1u << 2) /**< Texture is a depth stencil target. */ #define SDL_GPU_TEXTUREUSAGE_GRAPHICS_STORAGE_READ (1u << 3) /**< Texture supports storage reads in graphics stages. */ #define SDL_GPU_TEXTUREUSAGE_COMPUTE_STORAGE_READ (1u << 4) /**< Texture supports storage reads in the compute stage. */ #define SDL_GPU_TEXTUREUSAGE_COMPUTE_STORAGE_WRITE (1u << 5) /**< Texture supports storage writes in the compute stage. */ #define SDL_GPU_TEXTUREUSAGE_COMPUTE_STORAGE_SIMULTANEOUS_READ_WRITE (1u << 6) /**< Texture supports reads and writes in the same compute shader. This is NOT equivalent to READ | WRITE. */ /** * Specifies the type of a texture. * * \since This enum is available since SDL 3.2.0. * * \sa SDL_CreateGPUTexture */ typedef enum SDL_GPUTextureType { SDL_GPU_TEXTURETYPE_2D, /**< The texture is a 2-dimensional image. */ SDL_GPU_TEXTURETYPE_2D_ARRAY, /**< The texture is a 2-dimensional array image. */ SDL_GPU_TEXTURETYPE_3D, /**< The texture is a 3-dimensional image. */ SDL_GPU_TEXTURETYPE_CUBE, /**< The texture is a cube image. */ SDL_GPU_TEXTURETYPE_CUBE_ARRAY /**< The texture is a cube array image. */ } SDL_GPUTextureType; /** * Specifies the sample count of a texture. * * Used in multisampling. Note that this value only applies when the texture * is used as a render target. * * \since This enum is available since SDL 3.2.0. * * \sa SDL_CreateGPUTexture * \sa SDL_GPUTextureSupportsSampleCount */ typedef enum SDL_GPUSampleCount { SDL_GPU_SAMPLECOUNT_1, /**< No multisampling. */ SDL_GPU_SAMPLECOUNT_2, /**< MSAA 2x */ SDL_GPU_SAMPLECOUNT_4, /**< MSAA 4x */ SDL_GPU_SAMPLECOUNT_8 /**< MSAA 8x */ } SDL_GPUSampleCount; /** * Specifies the face of a cube map. * * Can be passed in as the layer field in texture-related structs. * * \since This enum is available since SDL 3.2.0. */ typedef enum SDL_GPUCubeMapFace { SDL_GPU_CUBEMAPFACE_POSITIVEX, SDL_GPU_CUBEMAPFACE_NEGATIVEX, SDL_GPU_CUBEMAPFACE_POSITIVEY, SDL_GPU_CUBEMAPFACE_NEGATIVEY, SDL_GPU_CUBEMAPFACE_POSITIVEZ, SDL_GPU_CUBEMAPFACE_NEGATIVEZ } SDL_GPUCubeMapFace; /** * Specifies how a buffer is intended to be used by the client. * * A buffer must have at least one usage flag. Note that some usage flag * combinations are invalid. * * Unlike textures, READ | WRITE can be used for simultaneous read-write * usage. The same data synchronization concerns as textures apply. * * If you use a STORAGE flag, the data in the buffer must respect std140 * layout conventions. In practical terms this means you must ensure that vec3 * and vec4 fields are 16-byte aligned. * * \since This datatype is available since SDL 3.2.0. * * \sa SDL_CreateGPUBuffer */ typedef Uint32 SDL_GPUBufferUsageFlags; #define SDL_GPU_BUFFERUSAGE_VERTEX (1u << 0) /**< Buffer is a vertex buffer. */ #define SDL_GPU_BUFFERUSAGE_INDEX (1u << 1) /**< Buffer is an index buffer. */ #define SDL_GPU_BUFFERUSAGE_INDIRECT (1u << 2) /**< Buffer is an indirect buffer. */ #define SDL_GPU_BUFFERUSAGE_GRAPHICS_STORAGE_READ (1u << 3) /**< Buffer supports storage reads in graphics stages. */ #define SDL_GPU_BUFFERUSAGE_COMPUTE_STORAGE_READ (1u << 4) /**< Buffer supports storage reads in the compute stage. */ #define SDL_GPU_BUFFERUSAGE_COMPUTE_STORAGE_WRITE (1u << 5) /**< Buffer supports storage writes in the compute stage. */ /** * Specifies how a transfer buffer is intended to be used by the client. * * Note that mapping and copying FROM an upload transfer buffer or TO a * download transfer buffer is undefined behavior. * * \since This enum is available since SDL 3.2.0. * * \sa SDL_CreateGPUTransferBuffer */ typedef enum SDL_GPUTransferBufferUsage { SDL_GPU_TRANSFERBUFFERUSAGE_UPLOAD, SDL_GPU_TRANSFERBUFFERUSAGE_DOWNLOAD } SDL_GPUTransferBufferUsage; /** * Specifies which stage a shader program corresponds to. * * \since This enum is available since SDL 3.2.0. * * \sa SDL_CreateGPUShader */ typedef enum SDL_GPUShaderStage { SDL_GPU_SHADERSTAGE_VERTEX, SDL_GPU_SHADERSTAGE_FRAGMENT } SDL_GPUShaderStage; /** * Specifies the format of shader code. * * Each format corresponds to a specific backend that accepts it. * * \since This datatype is available since SDL 3.2.0. * * \sa SDL_CreateGPUShader */ typedef Uint32 SDL_GPUShaderFormat; #define SDL_GPU_SHADERFORMAT_INVALID 0 #define SDL_GPU_SHADERFORMAT_PRIVATE (1u << 0) /**< Shaders for NDA'd platforms. */ #define SDL_GPU_SHADERFORMAT_SPIRV (1u << 1) /**< SPIR-V shaders for Vulkan. */ #define SDL_GPU_SHADERFORMAT_DXBC (1u << 2) /**< DXBC SM5_1 shaders for D3D12. */ #define SDL_GPU_SHADERFORMAT_DXIL (1u << 3) /**< DXIL SM6_0 shaders for D3D12. */ #define SDL_GPU_SHADERFORMAT_MSL (1u << 4) /**< MSL shaders for Metal. */ #define SDL_GPU_SHADERFORMAT_METALLIB (1u << 5) /**< Precompiled metallib shaders for Metal. */ /** * Specifies the format of a vertex attribute. * * \since This enum is available since SDL 3.2.0. * * \sa SDL_CreateGPUGraphicsPipeline */ typedef enum SDL_GPUVertexElementFormat { SDL_GPU_VERTEXELEMENTFORMAT_INVALID, /* 32-bit Signed Integers */ SDL_GPU_VERTEXELEMENTFORMAT_INT, SDL_GPU_VERTEXELEMENTFORMAT_INT2, SDL_GPU_VERTEXELEMENTFORMAT_INT3, SDL_GPU_VERTEXELEMENTFORMAT_INT4, /* 32-bit Unsigned Integers */ SDL_GPU_VERTEXELEMENTFORMAT_UINT, SDL_GPU_VERTEXELEMENTFORMAT_UINT2, SDL_GPU_VERTEXELEMENTFORMAT_UINT3, SDL_GPU_VERTEXELEMENTFORMAT_UINT4, /* 32-bit Floats */ SDL_GPU_VERTEXELEMENTFORMAT_FLOAT, SDL_GPU_VERTEXELEMENTFORMAT_FLOAT2, SDL_GPU_VERTEXELEMENTFORMAT_FLOAT3, SDL_GPU_VERTEXELEMENTFORMAT_FLOAT4, /* 8-bit Signed Integers */ SDL_GPU_VERTEXELEMENTFORMAT_BYTE2, SDL_GPU_VERTEXELEMENTFORMAT_BYTE4, /* 8-bit Unsigned Integers */ SDL_GPU_VERTEXELEMENTFORMAT_UBYTE2, SDL_GPU_VERTEXELEMENTFORMAT_UBYTE4, /* 8-bit Signed Normalized */ SDL_GPU_VERTEXELEMENTFORMAT_BYTE2_NORM, SDL_GPU_VERTEXELEMENTFORMAT_BYTE4_NORM, /* 8-bit Unsigned Normalized */ SDL_GPU_VERTEXELEMENTFORMAT_UBYTE2_NORM, SDL_GPU_VERTEXELEMENTFORMAT_UBYTE4_NORM, /* 16-bit Signed Integers */ SDL_GPU_VERTEXELEMENTFORMAT_SHORT2, SDL_GPU_VERTEXELEMENTFORMAT_SHORT4, /* 16-bit Unsigned Integers */ SDL_GPU_VERTEXELEMENTFORMAT_USHORT2, SDL_GPU_VERTEXELEMENTFORMAT_USHORT4, /* 16-bit Signed Normalized */ SDL_GPU_VERTEXELEMENTFORMAT_SHORT2_NORM, SDL_GPU_VERTEXELEMENTFORMAT_SHORT4_NORM, /* 16-bit Unsigned Normalized */ SDL_GPU_VERTEXELEMENTFORMAT_USHORT2_NORM, SDL_GPU_VERTEXELEMENTFORMAT_USHORT4_NORM, /* 16-bit Floats */ SDL_GPU_VERTEXELEMENTFORMAT_HALF2, SDL_GPU_VERTEXELEMENTFORMAT_HALF4 } SDL_GPUVertexElementFormat; /** * Specifies the rate at which vertex attributes are pulled from buffers. * * \since This enum is available since SDL 3.2.0. * * \sa SDL_CreateGPUGraphicsPipeline */ typedef enum SDL_GPUVertexInputRate { SDL_GPU_VERTEXINPUTRATE_VERTEX, /**< Attribute addressing is a function of the vertex index. */ SDL_GPU_VERTEXINPUTRATE_INSTANCE /**< Attribute addressing is a function of the instance index. */ } SDL_GPUVertexInputRate; /** * Specifies the fill mode of the graphics pipeline. * * \since This enum is available since SDL 3.2.0. * * \sa SDL_CreateGPUGraphicsPipeline */ typedef enum SDL_GPUFillMode { SDL_GPU_FILLMODE_FILL, /**< Polygons will be rendered via rasterization. */ SDL_GPU_FILLMODE_LINE /**< Polygon edges will be drawn as line segments. */ } SDL_GPUFillMode; /** * Specifies the facing direction in which triangle faces will be culled. * * \since This enum is available since SDL 3.2.0. * * \sa SDL_CreateGPUGraphicsPipeline */ typedef enum SDL_GPUCullMode { SDL_GPU_CULLMODE_NONE, /**< No triangles are culled. */ SDL_GPU_CULLMODE_FRONT, /**< Front-facing triangles are culled. */ SDL_GPU_CULLMODE_BACK /**< Back-facing triangles are culled. */ } SDL_GPUCullMode; /** * Specifies the vertex winding that will cause a triangle to be determined to * be front-facing. * * \since This enum is available since SDL 3.2.0. * * \sa SDL_CreateGPUGraphicsPipeline */ typedef enum SDL_GPUFrontFace { SDL_GPU_FRONTFACE_COUNTER_CLOCKWISE, /**< A triangle with counter-clockwise vertex winding will be considered front-facing. */ SDL_GPU_FRONTFACE_CLOCKWISE /**< A triangle with clockwise vertex winding will be considered front-facing. */ } SDL_GPUFrontFace; /** * Specifies a comparison operator for depth, stencil and sampler operations. * * \since This enum is available since SDL 3.2.0. * * \sa SDL_CreateGPUGraphicsPipeline */ typedef enum SDL_GPUCompareOp { SDL_GPU_COMPAREOP_INVALID, SDL_GPU_COMPAREOP_NEVER, /**< The comparison always evaluates false. */ SDL_GPU_COMPAREOP_LESS, /**< The comparison evaluates reference < test. */ SDL_GPU_COMPAREOP_EQUAL, /**< The comparison evaluates reference == test. */ SDL_GPU_COMPAREOP_LESS_OR_EQUAL, /**< The comparison evaluates reference <= test. */ SDL_GPU_COMPAREOP_GREATER, /**< The comparison evaluates reference > test. */ SDL_GPU_COMPAREOP_NOT_EQUAL, /**< The comparison evaluates reference != test. */ SDL_GPU_COMPAREOP_GREATER_OR_EQUAL, /**< The comparison evaluates reference >= test. */ SDL_GPU_COMPAREOP_ALWAYS /**< The comparison always evaluates true. */ } SDL_GPUCompareOp; /** * Specifies what happens to a stored stencil value if stencil tests fail or * pass. * * \since This enum is available since SDL 3.2.0. * * \sa SDL_CreateGPUGraphicsPipeline */ typedef enum SDL_GPUStencilOp { SDL_GPU_STENCILOP_INVALID, SDL_GPU_STENCILOP_KEEP, /**< Keeps the current value. */ SDL_GPU_STENCILOP_ZERO, /**< Sets the value to 0. */ SDL_GPU_STENCILOP_REPLACE, /**< Sets the value to reference. */ SDL_GPU_STENCILOP_INCREMENT_AND_CLAMP, /**< Increments the current value and clamps to the maximum value. */ SDL_GPU_STENCILOP_DECREMENT_AND_CLAMP, /**< Decrements the current value and clamps to 0. */ SDL_GPU_STENCILOP_INVERT, /**< Bitwise-inverts the current value. */ SDL_GPU_STENCILOP_INCREMENT_AND_WRAP, /**< Increments the current value and wraps back to 0. */ SDL_GPU_STENCILOP_DECREMENT_AND_WRAP /**< Decrements the current value and wraps to the maximum value. */ } SDL_GPUStencilOp; /** * Specifies the operator to be used when pixels in a render target are * blended with existing pixels in the texture. * * The source color is the value written by the fragment shader. The * destination color is the value currently existing in the texture. * * \since This enum is available since SDL 3.2.0. * * \sa SDL_CreateGPUGraphicsPipeline */ typedef enum SDL_GPUBlendOp { SDL_GPU_BLENDOP_INVALID, SDL_GPU_BLENDOP_ADD, /**< (source * source_factor) + (destination * destination_factor) */ SDL_GPU_BLENDOP_SUBTRACT, /**< (source * source_factor) - (destination * destination_factor) */ SDL_GPU_BLENDOP_REVERSE_SUBTRACT, /**< (destination * destination_factor) - (source * source_factor) */ SDL_GPU_BLENDOP_MIN, /**< min(source, destination) */ SDL_GPU_BLENDOP_MAX /**< max(source, destination) */ } SDL_GPUBlendOp; /** * Specifies a blending factor to be used when pixels in a render target are * blended with existing pixels in the texture. * * The source color is the value written by the fragment shader. The * destination color is the value currently existing in the texture. * * \since This enum is available since SDL 3.2.0. * * \sa SDL_CreateGPUGraphicsPipeline */ typedef enum SDL_GPUBlendFactor { SDL_GPU_BLENDFACTOR_INVALID, SDL_GPU_BLENDFACTOR_ZERO, /**< 0 */ SDL_GPU_BLENDFACTOR_ONE, /**< 1 */ SDL_GPU_BLENDFACTOR_SRC_COLOR, /**< source color */ SDL_GPU_BLENDFACTOR_ONE_MINUS_SRC_COLOR, /**< 1 - source color */ SDL_GPU_BLENDFACTOR_DST_COLOR, /**< destination color */ SDL_GPU_BLENDFACTOR_ONE_MINUS_DST_COLOR, /**< 1 - destination color */ SDL_GPU_BLENDFACTOR_SRC_ALPHA, /**< source alpha */ SDL_GPU_BLENDFACTOR_ONE_MINUS_SRC_ALPHA, /**< 1 - source alpha */ SDL_GPU_BLENDFACTOR_DST_ALPHA, /**< destination alpha */ SDL_GPU_BLENDFACTOR_ONE_MINUS_DST_ALPHA, /**< 1 - destination alpha */ SDL_GPU_BLENDFACTOR_CONSTANT_COLOR, /**< blend constant */ SDL_GPU_BLENDFACTOR_ONE_MINUS_CONSTANT_COLOR, /**< 1 - blend constant */ SDL_GPU_BLENDFACTOR_SRC_ALPHA_SATURATE /**< min(source alpha, 1 - destination alpha) */ } SDL_GPUBlendFactor; /** * Specifies which color components are written in a graphics pipeline. * * \since This datatype is available since SDL 3.2.0. * * \sa SDL_CreateGPUGraphicsPipeline */ typedef Uint8 SDL_GPUColorComponentFlags; #define SDL_GPU_COLORCOMPONENT_R (1u << 0) /**< the red component */ #define SDL_GPU_COLORCOMPONENT_G (1u << 1) /**< the green component */ #define SDL_GPU_COLORCOMPONENT_B (1u << 2) /**< the blue component */ #define SDL_GPU_COLORCOMPONENT_A (1u << 3) /**< the alpha component */ /** * Specifies a filter operation used by a sampler. * * \since This enum is available since SDL 3.2.0. * * \sa SDL_CreateGPUSampler */ typedef enum SDL_GPUFilter { SDL_GPU_FILTER_NEAREST, /**< Point filtering. */ SDL_GPU_FILTER_LINEAR /**< Linear filtering. */ } SDL_GPUFilter; /** * Specifies a mipmap mode used by a sampler. * * \since This enum is available since SDL 3.2.0. * * \sa SDL_CreateGPUSampler */ typedef enum SDL_GPUSamplerMipmapMode { SDL_GPU_SAMPLERMIPMAPMODE_NEAREST, /**< Point filtering. */ SDL_GPU_SAMPLERMIPMAPMODE_LINEAR /**< Linear filtering. */ } SDL_GPUSamplerMipmapMode; /** * Specifies behavior of texture sampling when the coordinates exceed the 0-1 * range. * * \since This enum is available since SDL 3.2.0. * * \sa SDL_CreateGPUSampler */ typedef enum SDL_GPUSamplerAddressMode { SDL_GPU_SAMPLERADDRESSMODE_REPEAT, /**< Specifies that the coordinates will wrap around. */ SDL_GPU_SAMPLERADDRESSMODE_MIRRORED_REPEAT, /**< Specifies that the coordinates will wrap around mirrored. */ SDL_GPU_SAMPLERADDRESSMODE_CLAMP_TO_EDGE /**< Specifies that the coordinates will clamp to the 0-1 range. */ } SDL_GPUSamplerAddressMode; /** * Specifies the timing that will be used to present swapchain textures to the * OS. * * VSYNC mode will always be supported. IMMEDIATE and MAILBOX modes may not be * supported on certain systems. * * It is recommended to query SDL_WindowSupportsGPUPresentMode after claiming * the window if you wish to change the present mode to IMMEDIATE or MAILBOX. * * - VSYNC: Waits for vblank before presenting. No tearing is possible. If * there is a pending image to present, the new image is enqueued for * presentation. Disallows tearing at the cost of visual latency. * - IMMEDIATE: Immediately presents. Lowest latency option, but tearing may * occur. * - MAILBOX: Waits for vblank before presenting. No tearing is possible. If * there is a pending image to present, the pending image is replaced by the * new image. Similar to VSYNC, but with reduced visual latency. * * \since This enum is available since SDL 3.2.0. * * \sa SDL_SetGPUSwapchainParameters * \sa SDL_WindowSupportsGPUPresentMode * \sa SDL_WaitAndAcquireGPUSwapchainTexture */ typedef enum SDL_GPUPresentMode { SDL_GPU_PRESENTMODE_VSYNC, SDL_GPU_PRESENTMODE_IMMEDIATE, SDL_GPU_PRESENTMODE_MAILBOX } SDL_GPUPresentMode; /** * Specifies the texture format and colorspace of the swapchain textures. * * SDR will always be supported. Other compositions may not be supported on * certain systems. * * It is recommended to query SDL_WindowSupportsGPUSwapchainComposition after * claiming the window if you wish to change the swapchain composition from * SDR. * * - SDR: B8G8R8A8 or R8G8B8A8 swapchain. Pixel values are in sRGB encoding. * - SDR_LINEAR: B8G8R8A8_SRGB or R8G8B8A8_SRGB swapchain. Pixel values are * stored in memory in sRGB encoding but accessed in shaders in "linear * sRGB" encoding which is sRGB but with a linear transfer function. * - HDR_EXTENDED_LINEAR: R16G16B16A16_FLOAT swapchain. Pixel values are in * extended linear sRGB encoding and permits values outside of the [0, 1] * range. * - HDR10_ST2084: A2R10G10B10 or A2B10G10R10 swapchain. Pixel values are in * BT.2020 ST2084 (PQ) encoding. * * \since This enum is available since SDL 3.2.0. * * \sa SDL_SetGPUSwapchainParameters * \sa SDL_WindowSupportsGPUSwapchainComposition * \sa SDL_WaitAndAcquireGPUSwapchainTexture */ typedef enum SDL_GPUSwapchainComposition { SDL_GPU_SWAPCHAINCOMPOSITION_SDR, SDL_GPU_SWAPCHAINCOMPOSITION_SDR_LINEAR, SDL_GPU_SWAPCHAINCOMPOSITION_HDR_EXTENDED_LINEAR, SDL_GPU_SWAPCHAINCOMPOSITION_HDR10_ST2084 } SDL_GPUSwapchainComposition; /* Structures */ /** * A structure specifying a viewport. * * \since This struct is available since SDL 3.2.0. * * \sa SDL_SetGPUViewport */ typedef struct SDL_GPUViewport { float x; /**< The left offset of the viewport. */ float y; /**< The top offset of the viewport. */ float w; /**< The width of the viewport. */ float h; /**< The height of the viewport. */ float min_depth; /**< The minimum depth of the viewport. */ float max_depth; /**< The maximum depth of the viewport. */ } SDL_GPUViewport; /** * A structure specifying parameters related to transferring data to or from a * texture. * * If either of `pixels_per_row` or `rows_per_layer` is zero, then width and * height of passed SDL_GPUTextureRegion to SDL_UploadToGPUTexture or * SDL_DownloadFromGPUTexture are used as default values respectively and data * is considered to be tightly packed. * * **WARNING**: On some older/integrated hardware, Direct3D 12 requires * texture data row pitch to be 256 byte aligned, and offsets to be aligned to * 512 bytes. If they are not, SDL will make a temporary copy of the data that * is properly aligned, but this adds overhead to the transfer process. Apps * can avoid this by aligning their data appropriately, or using a different * GPU backend than Direct3D 12. * * \since This struct is available since SDL 3.2.0. * * \sa SDL_UploadToGPUTexture * \sa SDL_DownloadFromGPUTexture */ typedef struct SDL_GPUTextureTransferInfo { SDL_GPUTransferBuffer *transfer_buffer; /**< The transfer buffer used in the transfer operation. */ Uint32 offset; /**< The starting byte of the image data in the transfer buffer. */ Uint32 pixels_per_row; /**< The number of pixels from one row to the next. */ Uint32 rows_per_layer; /**< The number of rows from one layer/depth-slice to the next. */ } SDL_GPUTextureTransferInfo; /** * A structure specifying a location in a transfer buffer. * * Used when transferring buffer data to or from a transfer buffer. * * \since This struct is available since SDL 3.2.0. * * \sa SDL_UploadToGPUBuffer * \sa SDL_DownloadFromGPUBuffer */ typedef struct SDL_GPUTransferBufferLocation { SDL_GPUTransferBuffer *transfer_buffer; /**< The transfer buffer used in the transfer operation. */ Uint32 offset; /**< The starting byte of the buffer data in the transfer buffer. */ } SDL_GPUTransferBufferLocation; /** * A structure specifying a location in a texture. * * Used when copying data from one texture to another. * * \since This struct is available since SDL 3.2.0. * * \sa SDL_CopyGPUTextureToTexture */ typedef struct SDL_GPUTextureLocation { SDL_GPUTexture *texture; /**< The texture used in the copy operation. */ Uint32 mip_level; /**< The mip level index of the location. */ Uint32 layer; /**< The layer index of the location. */ Uint32 x; /**< The left offset of the location. */ Uint32 y; /**< The top offset of the location. */ Uint32 z; /**< The front offset of the location. */ } SDL_GPUTextureLocation; /** * A structure specifying a region of a texture. * * Used when transferring data to or from a texture. * * \since This struct is available since SDL 3.2.0. * * \sa SDL_UploadToGPUTexture * \sa SDL_DownloadFromGPUTexture * \sa SDL_CreateGPUTexture */ typedef struct SDL_GPUTextureRegion { SDL_GPUTexture *texture; /**< The texture used in the copy operation. */ Uint32 mip_level; /**< The mip level index to transfer. */ Uint32 layer; /**< The layer index to transfer. */ Uint32 x; /**< The left offset of the region. */ Uint32 y; /**< The top offset of the region. */ Uint32 z; /**< The front offset of the region. */ Uint32 w; /**< The width of the region. */ Uint32 h; /**< The height of the region. */ Uint32 d; /**< The depth of the region. */ } SDL_GPUTextureRegion; /** * A structure specifying a region of a texture used in the blit operation. * * \since This struct is available since SDL 3.2.0. * * \sa SDL_BlitGPUTexture */ typedef struct SDL_GPUBlitRegion { SDL_GPUTexture *texture; /**< The texture. */ Uint32 mip_level; /**< The mip level index of the region. */ Uint32 layer_or_depth_plane; /**< The layer index or depth plane of the region. This value is treated as a layer index on 2D array and cube textures, and as a depth plane on 3D textures. */ Uint32 x; /**< The left offset of the region. */ Uint32 y; /**< The top offset of the region. */ Uint32 w; /**< The width of the region. */ Uint32 h; /**< The height of the region. */ } SDL_GPUBlitRegion; /** * A structure specifying a location in a buffer. * * Used when copying data between buffers. * * \since This struct is available since SDL 3.2.0. * * \sa SDL_CopyGPUBufferToBuffer */ typedef struct SDL_GPUBufferLocation { SDL_GPUBuffer *buffer; /**< The buffer. */ Uint32 offset; /**< The starting byte within the buffer. */ } SDL_GPUBufferLocation; /** * A structure specifying a region of a buffer. * * Used when transferring data to or from buffers. * * \since This struct is available since SDL 3.2.0. * * \sa SDL_UploadToGPUBuffer * \sa SDL_DownloadFromGPUBuffer */ typedef struct SDL_GPUBufferRegion { SDL_GPUBuffer *buffer; /**< The buffer. */ Uint32 offset; /**< The starting byte within the buffer. */ Uint32 size; /**< The size in bytes of the region. */ } SDL_GPUBufferRegion; /** * A structure specifying the parameters of an indirect draw command. * * Note that the `first_vertex` and `first_instance` parameters are NOT * compatible with built-in vertex/instance ID variables in shaders (for * example, SV_VertexID); GPU APIs and shader languages do not define these * built-in variables consistently, so if your shader depends on them, the * only way to keep behavior consistent and portable is to always pass 0 for * the correlating parameter in the draw calls. * * \since This struct is available since SDL 3.2.0. * * \sa SDL_DrawGPUPrimitivesIndirect */ typedef struct SDL_GPUIndirectDrawCommand { Uint32 num_vertices; /**< The number of vertices to draw. */ Uint32 num_instances; /**< The number of instances to draw. */ Uint32 first_vertex; /**< The index of the first vertex to draw. */ Uint32 first_instance; /**< The ID of the first instance to draw. */ } SDL_GPUIndirectDrawCommand; /** * A structure specifying the parameters of an indexed indirect draw command. * * Note that the `first_vertex` and `first_instance` parameters are NOT * compatible with built-in vertex/instance ID variables in shaders (for * example, SV_VertexID); GPU APIs and shader languages do not define these * built-in variables consistently, so if your shader depends on them, the * only way to keep behavior consistent and portable is to always pass 0 for * the correlating parameter in the draw calls. * * \since This struct is available since SDL 3.2.0. * * \sa SDL_DrawGPUIndexedPrimitivesIndirect */ typedef struct SDL_GPUIndexedIndirectDrawCommand { Uint32 num_indices; /**< The number of indices to draw per instance. */ Uint32 num_instances; /**< The number of instances to draw. */ Uint32 first_index; /**< The base index within the index buffer. */ Sint32 vertex_offset; /**< The value added to the vertex index before indexing into the vertex buffer. */ Uint32 first_instance; /**< The ID of the first instance to draw. */ } SDL_GPUIndexedIndirectDrawCommand; /** * A structure specifying the parameters of an indexed dispatch command. * * \since This struct is available since SDL 3.2.0. * * \sa SDL_DispatchGPUComputeIndirect */ typedef struct SDL_GPUIndirectDispatchCommand { Uint32 groupcount_x; /**< The number of local workgroups to dispatch in the X dimension. */ Uint32 groupcount_y; /**< The number of local workgroups to dispatch in the Y dimension. */ Uint32 groupcount_z; /**< The number of local workgroups to dispatch in the Z dimension. */ } SDL_GPUIndirectDispatchCommand; /* State structures */ /** * A structure specifying the parameters of a sampler. * * Note that mip_lod_bias is a no-op for the Metal driver. For Metal, LOD bias * must be applied via shader instead. * * \since This function is available since SDL 3.2.0. * * \sa SDL_CreateGPUSampler * \sa SDL_GPUFilter * \sa SDL_GPUSamplerMipmapMode * \sa SDL_GPUSamplerAddressMode * \sa SDL_GPUCompareOp */ typedef struct SDL_GPUSamplerCreateInfo { SDL_GPUFilter min_filter; /**< The minification filter to apply to lookups. */ SDL_GPUFilter mag_filter; /**< The magnification filter to apply to lookups. */ SDL_GPUSamplerMipmapMode mipmap_mode; /**< The mipmap filter to apply to lookups. */ SDL_GPUSamplerAddressMode address_mode_u; /**< The addressing mode for U coordinates outside [0, 1). */ SDL_GPUSamplerAddressMode address_mode_v; /**< The addressing mode for V coordinates outside [0, 1). */ SDL_GPUSamplerAddressMode address_mode_w; /**< The addressing mode for W coordinates outside [0, 1). */ float mip_lod_bias; /**< The bias to be added to mipmap LOD calculation. */ float max_anisotropy; /**< The anisotropy value clamp used by the sampler. If enable_anisotropy is false, this is ignored. */ SDL_GPUCompareOp compare_op; /**< The comparison operator to apply to fetched data before filtering. */ float min_lod; /**< Clamps the minimum of the computed LOD value. */ float max_lod; /**< Clamps the maximum of the computed LOD value. */ bool enable_anisotropy; /**< true to enable anisotropic filtering. */ bool enable_compare; /**< true to enable comparison against a reference value during lookups. */ Uint8 padding1; Uint8 padding2; SDL_PropertiesID props; /**< A properties ID for extensions. Should be 0 if no extensions are needed. */ } SDL_GPUSamplerCreateInfo; /** * A structure specifying the parameters of vertex buffers used in a graphics * pipeline. * * When you call SDL_BindGPUVertexBuffers, you specify the binding slots of * the vertex buffers. For example if you called SDL_BindGPUVertexBuffers with * a first_slot of 2 and num_bindings of 3, the binding slots 2, 3, 4 would be * used by the vertex buffers you pass in. * * Vertex attributes are linked to buffers via the buffer_slot field of * SDL_GPUVertexAttribute. For example, if an attribute has a buffer_slot of * 0, then that attribute belongs to the vertex buffer bound at slot 0. * * \since This struct is available since SDL 3.2.0. * * \sa SDL_GPUVertexAttribute * \sa SDL_GPUVertexInputRate */ typedef struct SDL_GPUVertexBufferDescription { Uint32 slot; /**< The binding slot of the vertex buffer. */ Uint32 pitch; /**< The size of a single element + the offset between elements. */ SDL_GPUVertexInputRate input_rate; /**< Whether attribute addressing is a function of the vertex index or instance index. */ Uint32 instance_step_rate; /**< Reserved for future use. Must be set to 0. */ } SDL_GPUVertexBufferDescription; /** * A structure specifying a vertex attribute. * * All vertex attribute locations provided to an SDL_GPUVertexInputState must * be unique. * * \since This struct is available since SDL 3.2.0. * * \sa SDL_GPUVertexBufferDescription * \sa SDL_GPUVertexInputState * \sa SDL_GPUVertexElementFormat */ typedef struct SDL_GPUVertexAttribute { Uint32 location; /**< The shader input location index. */ Uint32 buffer_slot; /**< The binding slot of the associated vertex buffer. */ SDL_GPUVertexElementFormat format; /**< The size and type of the attribute data. */ Uint32 offset; /**< The byte offset of this attribute relative to the start of the vertex element. */ } SDL_GPUVertexAttribute; /** * A structure specifying the parameters of a graphics pipeline vertex input * state. * * \since This struct is available since SDL 3.2.0. * * \sa SDL_GPUGraphicsPipelineCreateInfo * \sa SDL_GPUVertexBufferDescription * \sa SDL_GPUVertexAttribute */ typedef struct SDL_GPUVertexInputState { const SDL_GPUVertexBufferDescription *vertex_buffer_descriptions; /**< A pointer to an array of vertex buffer descriptions. */ Uint32 num_vertex_buffers; /**< The number of vertex buffer descriptions in the above array. */ const SDL_GPUVertexAttribute *vertex_attributes; /**< A pointer to an array of vertex attribute descriptions. */ Uint32 num_vertex_attributes; /**< The number of vertex attribute descriptions in the above array. */ } SDL_GPUVertexInputState; /** * A structure specifying the stencil operation state of a graphics pipeline. * * \since This struct is available since SDL 3.2.0. * * \sa SDL_GPUDepthStencilState */ typedef struct SDL_GPUStencilOpState { SDL_GPUStencilOp fail_op; /**< The action performed on samples that fail the stencil test. */ SDL_GPUStencilOp pass_op; /**< The action performed on samples that pass the depth and stencil tests. */ SDL_GPUStencilOp depth_fail_op; /**< The action performed on samples that pass the stencil test and fail the depth test. */ SDL_GPUCompareOp compare_op; /**< The comparison operator used in the stencil test. */ } SDL_GPUStencilOpState; /** * A structure specifying the blend state of a color target. * * \since This struct is available since SDL 3.2.0. * * \sa SDL_GPUColorTargetDescription * \sa SDL_GPUBlendFactor * \sa SDL_GPUBlendOp * \sa SDL_GPUColorComponentFlags */ typedef struct SDL_GPUColorTargetBlendState { SDL_GPUBlendFactor src_color_blendfactor; /**< The value to be multiplied by the source RGB value. */ SDL_GPUBlendFactor dst_color_blendfactor; /**< The value to be multiplied by the destination RGB value. */ SDL_GPUBlendOp color_blend_op; /**< The blend operation for the RGB components. */ SDL_GPUBlendFactor src_alpha_blendfactor; /**< The value to be multiplied by the source alpha. */ SDL_GPUBlendFactor dst_alpha_blendfactor; /**< The value to be multiplied by the destination alpha. */ SDL_GPUBlendOp alpha_blend_op; /**< The blend operation for the alpha component. */ SDL_GPUColorComponentFlags color_write_mask; /**< A bitmask specifying which of the RGBA components are enabled for writing. Writes to all channels if enable_color_write_mask is false. */ bool enable_blend; /**< Whether blending is enabled for the color target. */ bool enable_color_write_mask; /**< Whether the color write mask is enabled. */ Uint8 padding1; Uint8 padding2; } SDL_GPUColorTargetBlendState; /** * A structure specifying code and metadata for creating a shader object. * * \since This struct is available since SDL 3.2.0. * * \sa SDL_CreateGPUShader * \sa SDL_GPUShaderFormat * \sa SDL_GPUShaderStage */ typedef struct SDL_GPUShaderCreateInfo { size_t code_size; /**< The size in bytes of the code pointed to. */ const Uint8 *code; /**< A pointer to shader code. */ const char *entrypoint; /**< A pointer to a null-terminated UTF-8 string specifying the entry point function name for the shader. */ SDL_GPUShaderFormat format; /**< The format of the shader code. */ SDL_GPUShaderStage stage; /**< The stage the shader program corresponds to. */ Uint32 num_samplers; /**< The number of samplers defined in the shader. */ Uint32 num_storage_textures; /**< The number of storage textures defined in the shader. */ Uint32 num_storage_buffers; /**< The number of storage buffers defined in the shader. */ Uint32 num_uniform_buffers; /**< The number of uniform buffers defined in the shader. */ SDL_PropertiesID props; /**< A properties ID for extensions. Should be 0 if no extensions are needed. */ } SDL_GPUShaderCreateInfo; /** * A structure specifying the parameters of a texture. * * Usage flags can be bitwise OR'd together for combinations of usages. Note * that certain usage combinations are invalid, for example SAMPLER and * GRAPHICS_STORAGE. * * \since This struct is available since SDL 3.2.0. * * \sa SDL_CreateGPUTexture * \sa SDL_GPUTextureType * \sa SDL_GPUTextureFormat * \sa SDL_GPUTextureUsageFlags * \sa SDL_GPUSampleCount */ typedef struct SDL_GPUTextureCreateInfo { SDL_GPUTextureType type; /**< The base dimensionality of the texture. */ SDL_GPUTextureFormat format; /**< The pixel format of the texture. */ SDL_GPUTextureUsageFlags usage; /**< How the texture is intended to be used by the client. */ Uint32 width; /**< The width of the texture. */ Uint32 height; /**< The height of the texture. */ Uint32 layer_count_or_depth; /**< The layer count or depth of the texture. This value is treated as a layer count on 2D array textures, and as a depth value on 3D textures. */ Uint32 num_levels; /**< The number of mip levels in the texture. */ SDL_GPUSampleCount sample_count; /**< The number of samples per texel. Only applies if the texture is used as a render target. */ SDL_PropertiesID props; /**< A properties ID for extensions. Should be 0 if no extensions are needed. */ } SDL_GPUTextureCreateInfo; /** * A structure specifying the parameters of a buffer. * * Usage flags can be bitwise OR'd together for combinations of usages. Note * that certain combinations are invalid, for example VERTEX and INDEX. * * \since This struct is available since SDL 3.2.0. * * \sa SDL_CreateGPUBuffer * \sa SDL_GPUBufferUsageFlags */ typedef struct SDL_GPUBufferCreateInfo { SDL_GPUBufferUsageFlags usage; /**< How the buffer is intended to be used by the client. */ Uint32 size; /**< The size in bytes of the buffer. */ SDL_PropertiesID props; /**< A properties ID for extensions. Should be 0 if no extensions are needed. */ } SDL_GPUBufferCreateInfo; /** * A structure specifying the parameters of a transfer buffer. * * \since This struct is available since SDL 3.2.0. * * \sa SDL_CreateGPUTransferBuffer */ typedef struct SDL_GPUTransferBufferCreateInfo { SDL_GPUTransferBufferUsage usage; /**< How the transfer buffer is intended to be used by the client. */ Uint32 size; /**< The size in bytes of the transfer buffer. */ SDL_PropertiesID props; /**< A properties ID for extensions. Should be 0 if no extensions are needed. */ } SDL_GPUTransferBufferCreateInfo; /* Pipeline state structures */ /** * A structure specifying the parameters of the graphics pipeline rasterizer * state. * * Note that SDL_GPU_FILLMODE_LINE is not supported on many Android devices. * For those devices, the fill mode will automatically fall back to FILL. * * Also note that the D3D12 driver will enable depth clamping even if * enable_depth_clip is true. If you need this clamp+clip behavior, consider * enabling depth clip and then manually clamping depth in your fragment * shaders on Metal and Vulkan. * * \since This struct is available since SDL 3.2.0. * * \sa SDL_GPUGraphicsPipelineCreateInfo */ typedef struct SDL_GPURasterizerState { SDL_GPUFillMode fill_mode; /**< Whether polygons will be filled in or drawn as lines. */ SDL_GPUCullMode cull_mode; /**< The facing direction in which triangles will be culled. */ SDL_GPUFrontFace front_face; /**< The vertex winding that will cause a triangle to be determined as front-facing. */ float depth_bias_constant_factor; /**< A scalar factor controlling the depth value added to each fragment. */ float depth_bias_clamp; /**< The maximum depth bias of a fragment. */ float depth_bias_slope_factor; /**< A scalar factor applied to a fragment's slope in depth calculations. */ bool enable_depth_bias; /**< true to bias fragment depth values. */ bool enable_depth_clip; /**< true to enable depth clip, false to enable depth clamp. */ Uint8 padding1; Uint8 padding2; } SDL_GPURasterizerState; /** * A structure specifying the parameters of the graphics pipeline multisample * state. * * \since This struct is available since SDL 3.2.0. * * \sa SDL_GPUGraphicsPipelineCreateInfo */ typedef struct SDL_GPUMultisampleState { SDL_GPUSampleCount sample_count; /**< The number of samples to be used in rasterization. */ Uint32 sample_mask; /**< Reserved for future use. Must be set to 0. */ bool enable_mask; /**< Reserved for future use. Must be set to false. */ bool enable_alpha_to_coverage; /**< true enables the alpha-to-coverage feature. */ Uint8 padding2; Uint8 padding3; } SDL_GPUMultisampleState; /** * A structure specifying the parameters of the graphics pipeline depth * stencil state. * * \since This struct is available since SDL 3.2.0. * * \sa SDL_GPUGraphicsPipelineCreateInfo */ typedef struct SDL_GPUDepthStencilState { SDL_GPUCompareOp compare_op; /**< The comparison operator used for depth testing. */ SDL_GPUStencilOpState back_stencil_state; /**< The stencil op state for back-facing triangles. */ SDL_GPUStencilOpState front_stencil_state; /**< The stencil op state for front-facing triangles. */ Uint8 compare_mask; /**< Selects the bits of the stencil values participating in the stencil test. */ Uint8 write_mask; /**< Selects the bits of the stencil values updated by the stencil test. */ bool enable_depth_test; /**< true enables the depth test. */ bool enable_depth_write; /**< true enables depth writes. Depth writes are always disabled when enable_depth_test is false. */ bool enable_stencil_test; /**< true enables the stencil test. */ Uint8 padding1; Uint8 padding2; Uint8 padding3; } SDL_GPUDepthStencilState; /** * A structure specifying the parameters of color targets used in a graphics * pipeline. * * \since This struct is available since SDL 3.2.0. * * \sa SDL_GPUGraphicsPipelineTargetInfo */ typedef struct SDL_GPUColorTargetDescription { SDL_GPUTextureFormat format; /**< The pixel format of the texture to be used as a color target. */ SDL_GPUColorTargetBlendState blend_state; /**< The blend state to be used for the color target. */ } SDL_GPUColorTargetDescription; /** * A structure specifying the descriptions of render targets used in a * graphics pipeline. * * \since This struct is available since SDL 3.2.0. * * \sa SDL_GPUGraphicsPipelineCreateInfo * \sa SDL_GPUColorTargetDescription * \sa SDL_GPUTextureFormat */ typedef struct SDL_GPUGraphicsPipelineTargetInfo { const SDL_GPUColorTargetDescription *color_target_descriptions; /**< A pointer to an array of color target descriptions. */ Uint32 num_color_targets; /**< The number of color target descriptions in the above array. */ SDL_GPUTextureFormat depth_stencil_format; /**< The pixel format of the depth-stencil target. Ignored if has_depth_stencil_target is false. */ bool has_depth_stencil_target; /**< true specifies that the pipeline uses a depth-stencil target. */ Uint8 padding1; Uint8 padding2; Uint8 padding3; } SDL_GPUGraphicsPipelineTargetInfo; /** * A structure specifying the parameters of a graphics pipeline state. * * \since This struct is available since SDL 3.2.0. * * \sa SDL_CreateGPUGraphicsPipeline * \sa SDL_GPUShader * \sa SDL_GPUVertexInputState * \sa SDL_GPUPrimitiveType * \sa SDL_GPURasterizerState * \sa SDL_GPUMultisampleState * \sa SDL_GPUDepthStencilState * \sa SDL_GPUGraphicsPipelineTargetInfo */ typedef struct SDL_GPUGraphicsPipelineCreateInfo { SDL_GPUShader *vertex_shader; /**< The vertex shader used by the graphics pipeline. */ SDL_GPUShader *fragment_shader; /**< The fragment shader used by the graphics pipeline. */ SDL_GPUVertexInputState vertex_input_state; /**< The vertex layout of the graphics pipeline. */ SDL_GPUPrimitiveType primitive_type; /**< The primitive topology of the graphics pipeline. */ SDL_GPURasterizerState rasterizer_state; /**< The rasterizer state of the graphics pipeline. */ SDL_GPUMultisampleState multisample_state; /**< The multisample state of the graphics pipeline. */ SDL_GPUDepthStencilState depth_stencil_state; /**< The depth-stencil state of the graphics pipeline. */ SDL_GPUGraphicsPipelineTargetInfo target_info; /**< Formats and blend modes for the render targets of the graphics pipeline. */ SDL_PropertiesID props; /**< A properties ID for extensions. Should be 0 if no extensions are needed. */ } SDL_GPUGraphicsPipelineCreateInfo; /** * A structure specifying the parameters of a compute pipeline state. * * \since This struct is available since SDL 3.2.0. * * \sa SDL_CreateGPUComputePipeline * \sa SDL_GPUShaderFormat */ typedef struct SDL_GPUComputePipelineCreateInfo { size_t code_size; /**< The size in bytes of the compute shader code pointed to. */ const Uint8 *code; /**< A pointer to compute shader code. */ const char *entrypoint; /**< A pointer to a null-terminated UTF-8 string specifying the entry point function name for the shader. */ SDL_GPUShaderFormat format; /**< The format of the compute shader code. */ Uint32 num_samplers; /**< The number of samplers defined in the shader. */ Uint32 num_readonly_storage_textures; /**< The number of readonly storage textures defined in the shader. */ Uint32 num_readonly_storage_buffers; /**< The number of readonly storage buffers defined in the shader. */ Uint32 num_readwrite_storage_textures; /**< The number of read-write storage textures defined in the shader. */ Uint32 num_readwrite_storage_buffers; /**< The number of read-write storage buffers defined in the shader. */ Uint32 num_uniform_buffers; /**< The number of uniform buffers defined in the shader. */ Uint32 threadcount_x; /**< The number of threads in the X dimension. This should match the value in the shader. */ Uint32 threadcount_y; /**< The number of threads in the Y dimension. This should match the value in the shader. */ Uint32 threadcount_z; /**< The number of threads in the Z dimension. This should match the value in the shader. */ SDL_PropertiesID props; /**< A properties ID for extensions. Should be 0 if no extensions are needed. */ } SDL_GPUComputePipelineCreateInfo; /** * A structure specifying the parameters of a color target used by a render * pass. * * The load_op field determines what is done with the texture at the beginning * of the render pass. * * - LOAD: Loads the data currently in the texture. Not recommended for * multisample textures as it requires significant memory bandwidth. * - CLEAR: Clears the texture to a single color. * - DONT_CARE: The driver will do whatever it wants with the texture memory. * This is a good option if you know that every single pixel will be touched * in the render pass. * * The store_op field determines what is done with the color results of the * render pass. * * - STORE: Stores the results of the render pass in the texture. Not * recommended for multisample textures as it requires significant memory * bandwidth. * - DONT_CARE: The driver will do whatever it wants with the texture memory. * This is often a good option for depth/stencil textures. * - RESOLVE: Resolves a multisample texture into resolve_texture, which must * have a sample count of 1. Then the driver may discard the multisample * texture memory. This is the most performant method of resolving a * multisample target. * - RESOLVE_AND_STORE: Resolves a multisample texture into the * resolve_texture, which must have a sample count of 1. Then the driver * stores the multisample texture's contents. Not recommended as it requires * significant memory bandwidth. * * \since This struct is available since SDL 3.2.0. * * \sa SDL_BeginGPURenderPass * \sa SDL_FColor */ typedef struct SDL_GPUColorTargetInfo { SDL_GPUTexture *texture; /**< The texture that will be used as a color target by a render pass. */ Uint32 mip_level; /**< The mip level to use as a color target. */ Uint32 layer_or_depth_plane; /**< The layer index or depth plane to use as a color target. This value is treated as a layer index on 2D array and cube textures, and as a depth plane on 3D textures. */ SDL_FColor clear_color; /**< The color to clear the color target to at the start of the render pass. Ignored if SDL_GPU_LOADOP_CLEAR is not used. */ SDL_GPULoadOp load_op; /**< What is done with the contents of the color target at the beginning of the render pass. */ SDL_GPUStoreOp store_op; /**< What is done with the results of the render pass. */ SDL_GPUTexture *resolve_texture; /**< The texture that will receive the results of a multisample resolve operation. Ignored if a RESOLVE* store_op is not used. */ Uint32 resolve_mip_level; /**< The mip level of the resolve texture to use for the resolve operation. Ignored if a RESOLVE* store_op is not used. */ Uint32 resolve_layer; /**< The layer index of the resolve texture to use for the resolve operation. Ignored if a RESOLVE* store_op is not used. */ bool cycle; /**< true cycles the texture if the texture is bound and load_op is not LOAD */ bool cycle_resolve_texture; /**< true cycles the resolve texture if the resolve texture is bound. Ignored if a RESOLVE* store_op is not used. */ Uint8 padding1; Uint8 padding2; } SDL_GPUColorTargetInfo; /** * A structure specifying the parameters of a depth-stencil target used by a * render pass. * * The load_op field determines what is done with the depth contents of the * texture at the beginning of the render pass. * * - LOAD: Loads the depth values currently in the texture. * - CLEAR: Clears the texture to a single depth. * - DONT_CARE: The driver will do whatever it wants with the memory. This is * a good option if you know that every single pixel will be touched in the * render pass. * * The store_op field determines what is done with the depth results of the * render pass. * * - STORE: Stores the depth results in the texture. * - DONT_CARE: The driver will do whatever it wants with the depth results. * This is often a good option for depth/stencil textures that don't need to * be reused again. * * The stencil_load_op field determines what is done with the stencil contents * of the texture at the beginning of the render pass. * * - LOAD: Loads the stencil values currently in the texture. * - CLEAR: Clears the stencil values to a single value. * - DONT_CARE: The driver will do whatever it wants with the memory. This is * a good option if you know that every single pixel will be touched in the * render pass. * * The stencil_store_op field determines what is done with the stencil results * of the render pass. * * - STORE: Stores the stencil results in the texture. * - DONT_CARE: The driver will do whatever it wants with the stencil results. * This is often a good option for depth/stencil textures that don't need to * be reused again. * * Note that depth/stencil targets do not support multisample resolves. * * Due to ABI limitations, depth textures with more than 255 layers are not * supported. * * \since This struct is available since SDL 3.2.0. * * \sa SDL_BeginGPURenderPass */ typedef struct SDL_GPUDepthStencilTargetInfo { SDL_GPUTexture *texture; /**< The texture that will be used as the depth stencil target by the render pass. */ float clear_depth; /**< The value to clear the depth component to at the beginning of the render pass. Ignored if SDL_GPU_LOADOP_CLEAR is not used. */ SDL_GPULoadOp load_op; /**< What is done with the depth contents at the beginning of the render pass. */ SDL_GPUStoreOp store_op; /**< What is done with the depth results of the render pass. */ SDL_GPULoadOp stencil_load_op; /**< What is done with the stencil contents at the beginning of the render pass. */ SDL_GPUStoreOp stencil_store_op; /**< What is done with the stencil results of the render pass. */ bool cycle; /**< true cycles the texture if the texture is bound and any load ops are not LOAD */ Uint8 clear_stencil; /**< The value to clear the stencil component to at the beginning of the render pass. Ignored if SDL_GPU_LOADOP_CLEAR is not used. */ Uint8 mip_level; /**< The mip level to use as the depth stencil target. */ Uint8 layer; /**< The layer index to use as the depth stencil target. */ } SDL_GPUDepthStencilTargetInfo; /** * A structure containing parameters for a blit command. * * \since This struct is available since SDL 3.2.0. * * \sa SDL_BlitGPUTexture */ typedef struct SDL_GPUBlitInfo { SDL_GPUBlitRegion source; /**< The source region for the blit. */ SDL_GPUBlitRegion destination; /**< The destination region for the blit. */ SDL_GPULoadOp load_op; /**< What is done with the contents of the destination before the blit. */ SDL_FColor clear_color; /**< The color to clear the destination region to before the blit. Ignored if load_op is not SDL_GPU_LOADOP_CLEAR. */ SDL_FlipMode flip_mode; /**< The flip mode for the source region. */ SDL_GPUFilter filter; /**< The filter mode used when blitting. */ bool cycle; /**< true cycles the destination texture if it is already bound. */ Uint8 padding1; Uint8 padding2; Uint8 padding3; } SDL_GPUBlitInfo; /* Binding structs */ /** * A structure specifying parameters in a buffer binding call. * * \since This struct is available since SDL 3.2.0. * * \sa SDL_BindGPUVertexBuffers * \sa SDL_BindGPUIndexBuffer */ typedef struct SDL_GPUBufferBinding { SDL_GPUBuffer *buffer; /**< The buffer to bind. Must have been created with SDL_GPU_BUFFERUSAGE_VERTEX for SDL_BindGPUVertexBuffers, or SDL_GPU_BUFFERUSAGE_INDEX for SDL_BindGPUIndexBuffer. */ Uint32 offset; /**< The starting byte of the data to bind in the buffer. */ } SDL_GPUBufferBinding; /** * A structure specifying parameters in a sampler binding call. * * \since This struct is available since SDL 3.2.0. * * \sa SDL_BindGPUVertexSamplers * \sa SDL_BindGPUFragmentSamplers * \sa SDL_GPUTexture * \sa SDL_GPUSampler */ typedef struct SDL_GPUTextureSamplerBinding { SDL_GPUTexture *texture; /**< The texture to bind. Must have been created with SDL_GPU_TEXTUREUSAGE_SAMPLER. */ SDL_GPUSampler *sampler; /**< The sampler to bind. */ } SDL_GPUTextureSamplerBinding; /** * A structure specifying parameters related to binding buffers in a compute * pass. * * \since This struct is available since SDL 3.2.0. * * \sa SDL_BeginGPUComputePass */ typedef struct SDL_GPUStorageBufferReadWriteBinding { SDL_GPUBuffer *buffer; /**< The buffer to bind. Must have been created with SDL_GPU_BUFFERUSAGE_COMPUTE_STORAGE_WRITE. */ bool cycle; /**< true cycles the buffer if it is already bound. */ Uint8 padding1; Uint8 padding2; Uint8 padding3; } SDL_GPUStorageBufferReadWriteBinding; /** * A structure specifying parameters related to binding textures in a compute * pass. * * \since This struct is available since SDL 3.2.0. * * \sa SDL_BeginGPUComputePass */ typedef struct SDL_GPUStorageTextureReadWriteBinding { SDL_GPUTexture *texture; /**< The texture to bind. Must have been created with SDL_GPU_TEXTUREUSAGE_COMPUTE_STORAGE_WRITE or SDL_GPU_TEXTUREUSAGE_COMPUTE_STORAGE_SIMULTANEOUS_READ_WRITE. */ Uint32 mip_level; /**< The mip level index to bind. */ Uint32 layer; /**< The layer index to bind. */ bool cycle; /**< true cycles the texture if it is already bound. */ Uint8 padding1; Uint8 padding2; Uint8 padding3; } SDL_GPUStorageTextureReadWriteBinding; /* Functions */ /* Device */ /** * Checks for GPU runtime support. * * \param format_flags a bitflag indicating which shader formats the app is * able to provide. * \param name the preferred GPU driver, or NULL to let SDL pick the optimal * driver. * \returns true if supported, false otherwise. * * \since This function is available since SDL 3.2.0. * * \sa SDL_CreateGPUDevice */ extern SDL_DECLSPEC bool SDLCALL SDL_GPUSupportsShaderFormats( SDL_GPUShaderFormat format_flags, const char *name); /** * Checks for GPU runtime support. * * \param props the properties to use. * \returns true if supported, false otherwise. * * \since This function is available since SDL 3.2.0. * * \sa SDL_CreateGPUDeviceWithProperties */ extern SDL_DECLSPEC bool SDLCALL SDL_GPUSupportsProperties( SDL_PropertiesID props); /** * Creates a GPU context. * * The GPU driver name can be one of the following: * * - "vulkan": [Vulkan](CategoryGPU#vulkan) * - "direct3d12": [D3D12](CategoryGPU#d3d12) * - "metal": [Metal](CategoryGPU#metal) * - NULL: let SDL pick the optimal driver * * \param format_flags a bitflag indicating which shader formats the app is * able to provide. * \param debug_mode enable debug mode properties and validations. * \param name the preferred GPU driver, or NULL to let SDL pick the optimal * driver. * \returns a GPU context on success or NULL on failure; call SDL_GetError() * for more information. * * \since This function is available since SDL 3.2.0. * * \sa SDL_CreateGPUDeviceWithProperties * \sa SDL_GetGPUShaderFormats * \sa SDL_GetGPUDeviceDriver * \sa SDL_DestroyGPUDevice * \sa SDL_GPUSupportsShaderFormats */ extern SDL_DECLSPEC SDL_GPUDevice * SDLCALL SDL_CreateGPUDevice( SDL_GPUShaderFormat format_flags, bool debug_mode, const char *name); /** * Creates a GPU context. * * These are the supported properties: * * - `SDL_PROP_GPU_DEVICE_CREATE_DEBUGMODE_BOOLEAN`: enable debug mode * properties and validations, defaults to true. * - `SDL_PROP_GPU_DEVICE_CREATE_PREFERLOWPOWER_BOOLEAN`: enable to prefer * energy efficiency over maximum GPU performance, defaults to false. * - `SDL_PROP_GPU_DEVICE_CREATE_VERBOSE_BOOLEAN`: enable to automatically log * useful debug information on device creation, defaults to true. * - `SDL_PROP_GPU_DEVICE_CREATE_NAME_STRING`: the name of the GPU driver to * use, if a specific one is desired. * - `SDL_PROP_GPU_DEVICE_CREATE_FEATURE_CLIP_DISTANCE_BOOLEAN`: Enable Vulkan * device feature shaderClipDistance. If disabled, clip distances are not * supported in shader code: gl_ClipDistance[] built-ins of GLSL, * SV_ClipDistance0/1 semantics of HLSL and [[clip_distance]] attribute of * Metal. Disabling optional features allows the application to run on some * older Android devices. Defaults to true. * - `SDL_PROP_GPU_DEVICE_CREATE_FEATURE_DEPTH_CLAMPING_BOOLEAN`: Enable * Vulkan device feature depthClamp. If disabled, there is no depth clamp * support and enable_depth_clip in SDL_GPURasterizerState must always be * set to true. Disabling optional features allows the application to run on * some older Android devices. Defaults to true. * - `SDL_PROP_GPU_DEVICE_CREATE_FEATURE_INDIRECT_DRAW_FIRST_INSTANCE_BOOLEAN`: * Enable Vulkan device feature drawIndirectFirstInstance. If disabled, the * argument first_instance of SDL_GPUIndirectDrawCommand must be set to * zero. Disabling optional features allows the application to run on some * older Android devices. Defaults to true. * - `SDL_PROP_GPU_DEVICE_CREATE_FEATURE_ANISOTROPY_BOOLEAN`: Enable Vulkan * device feature samplerAnisotropy. If disabled, enable_anisotropy of * SDL_GPUSamplerCreateInfo must be set to false. Disabling optional * features allows the application to run on some older Android devices. * Defaults to true. * * These are the current shader format properties: * * - `SDL_PROP_GPU_DEVICE_CREATE_SHADERS_PRIVATE_BOOLEAN`: The app is able to * provide shaders for an NDA platform. * - `SDL_PROP_GPU_DEVICE_CREATE_SHADERS_SPIRV_BOOLEAN`: The app is able to * provide SPIR-V shaders if applicable. * - `SDL_PROP_GPU_DEVICE_CREATE_SHADERS_DXBC_BOOLEAN`: The app is able to * provide DXBC shaders if applicable * - `SDL_PROP_GPU_DEVICE_CREATE_SHADERS_DXIL_BOOLEAN`: The app is able to * provide DXIL shaders if applicable. * - `SDL_PROP_GPU_DEVICE_CREATE_SHADERS_MSL_BOOLEAN`: The app is able to * provide MSL shaders if applicable. * - `SDL_PROP_GPU_DEVICE_CREATE_SHADERS_METALLIB_BOOLEAN`: The app is able to * provide Metal shader libraries if applicable. * * With the D3D12 backend: * * - `SDL_PROP_GPU_DEVICE_CREATE_D3D12_SEMANTIC_NAME_STRING`: the prefix to * use for all vertex semantics, default is "TEXCOORD". * - `SDL_PROP_GPU_DEVICE_CREATE_D3D12_ALLOW_FEWER_RESOURCE_SLOTS_BOOLEAN`: By * default, Resourcing Binding Tier 2 is required for D3D12 support. * However, an application can set this property to true to enable Tier 1 * support, if (and only if) the application uses 8 or fewer storage * resources across all shader stages. As of writing, this property is * useful for targeting Intel Haswell and Broadwell GPUs; other hardware * either supports Tier 2 Resource Binding or does not support D3D12 in any * capacity. Defaults to false. * - `SDL_PROP_GPU_DEVICE_CREATE_D3D12_AGILITY_SDK_VERSION_NUMBER`: Certain * feature checks are only possible on Windows 11 by default. By setting * this alongside `SDL_PROP_GPU_DEVICE_CREATE_D3D12_AGILITY_SDK_PATH_STRING` * and vendoring D3D12Core.dll from the D3D12 Agility SDK, you can make * those feature checks possible on older platforms. The version you provide * must match the one given in the DLL. * - `SDL_PROP_GPU_DEVICE_CREATE_D3D12_AGILITY_SDK_PATH_STRING`: Certain * feature checks are only possible on Windows 11 by default. By setting * this alongside * `SDL_PROP_GPU_DEVICE_CREATE_D3D12_AGILITY_SDK_VERSION_NUMBER` and * vendoring D3D12Core.dll from the D3D12 Agility SDK, you can make those * feature checks possible on older platforms. The path you provide must be * relative to the executable path of your app. Be sure not to put the DLL * in the same directory as the exe; Microsoft strongly advises against * this! * * With the Vulkan backend: * * - `SDL_PROP_GPU_DEVICE_CREATE_VULKAN_REQUIRE_HARDWARE_ACCELERATION_BOOLEAN`: * By default, Vulkan device enumeration includes drivers of all types, * including software renderers (for example, the Lavapipe Mesa driver). * This can be useful if your application _requires_ SDL_GPU, but if you can * provide your own fallback renderer (for example, an OpenGL renderer) this * property can be set to true. Defaults to false. * - `SDL_PROP_GPU_DEVICE_CREATE_VULKAN_OPTIONS_POINTER`: a pointer to an * SDL_GPUVulkanOptions structure to be processed during device creation. * This allows configuring a variety of Vulkan-specific options such as * increasing the API version and opting into extensions aside from the * minimal set SDL requires. * * With the Metal backend: - * `SDL_PROP_GPU_DEVICE_CREATE_METAL_ALLOW_MACFAMILY1_BOOLEAN`: By default, * macOS support requires what Apple calls "MTLGPUFamilyMac2" hardware or * newer. However, an application can set this property to true to enable * support for "MTLGPUFamilyMac1" hardware, if (and only if) the application * does not write to sRGB textures. (For history's sake: MacFamily1 also does * not support indirect command buffers, MSAA depth resolve, and stencil * resolve/feedback, but these are not exposed features in SDL_GPU.) * * \param props the properties to use. * \returns a GPU context on success or NULL on failure; call SDL_GetError() * for more information. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetGPUShaderFormats * \sa SDL_GetGPUDeviceDriver * \sa SDL_DestroyGPUDevice * \sa SDL_GPUSupportsProperties */ extern SDL_DECLSPEC SDL_GPUDevice * SDLCALL SDL_CreateGPUDeviceWithProperties( SDL_PropertiesID props); #define SDL_PROP_GPU_DEVICE_CREATE_DEBUGMODE_BOOLEAN "SDL.gpu.device.create.debugmode" #define SDL_PROP_GPU_DEVICE_CREATE_PREFERLOWPOWER_BOOLEAN "SDL.gpu.device.create.preferlowpower" #define SDL_PROP_GPU_DEVICE_CREATE_VERBOSE_BOOLEAN "SDL.gpu.device.create.verbose" #define SDL_PROP_GPU_DEVICE_CREATE_NAME_STRING "SDL.gpu.device.create.name" #define SDL_PROP_GPU_DEVICE_CREATE_FEATURE_CLIP_DISTANCE_BOOLEAN "SDL.gpu.device.create.feature.clip_distance" #define SDL_PROP_GPU_DEVICE_CREATE_FEATURE_DEPTH_CLAMPING_BOOLEAN "SDL.gpu.device.create.feature.depth_clamping" #define SDL_PROP_GPU_DEVICE_CREATE_FEATURE_INDIRECT_DRAW_FIRST_INSTANCE_BOOLEAN "SDL.gpu.device.create.feature.indirect_draw_first_instance" #define SDL_PROP_GPU_DEVICE_CREATE_FEATURE_ANISOTROPY_BOOLEAN "SDL.gpu.device.create.feature.anisotropy" #define SDL_PROP_GPU_DEVICE_CREATE_SHADERS_PRIVATE_BOOLEAN "SDL.gpu.device.create.shaders.private" #define SDL_PROP_GPU_DEVICE_CREATE_SHADERS_SPIRV_BOOLEAN "SDL.gpu.device.create.shaders.spirv" #define SDL_PROP_GPU_DEVICE_CREATE_SHADERS_DXBC_BOOLEAN "SDL.gpu.device.create.shaders.dxbc" #define SDL_PROP_GPU_DEVICE_CREATE_SHADERS_DXIL_BOOLEAN "SDL.gpu.device.create.shaders.dxil" #define SDL_PROP_GPU_DEVICE_CREATE_SHADERS_MSL_BOOLEAN "SDL.gpu.device.create.shaders.msl" #define SDL_PROP_GPU_DEVICE_CREATE_SHADERS_METALLIB_BOOLEAN "SDL.gpu.device.create.shaders.metallib" #define SDL_PROP_GPU_DEVICE_CREATE_D3D12_ALLOW_FEWER_RESOURCE_SLOTS_BOOLEAN "SDL.gpu.device.create.d3d12.allowtier1resourcebinding" #define SDL_PROP_GPU_DEVICE_CREATE_D3D12_SEMANTIC_NAME_STRING "SDL.gpu.device.create.d3d12.semantic" #define SDL_PROP_GPU_DEVICE_CREATE_D3D12_AGILITY_SDK_VERSION_NUMBER "SDL.gpu.device.create.d3d12.agility_sdk_version" #define SDL_PROP_GPU_DEVICE_CREATE_D3D12_AGILITY_SDK_PATH_STRING "SDL.gpu.device.create.d3d12.agility_sdk_path" #define SDL_PROP_GPU_DEVICE_CREATE_VULKAN_REQUIRE_HARDWARE_ACCELERATION_BOOLEAN "SDL.gpu.device.create.vulkan.requirehardwareacceleration" #define SDL_PROP_GPU_DEVICE_CREATE_VULKAN_OPTIONS_POINTER "SDL.gpu.device.create.vulkan.options" #define SDL_PROP_GPU_DEVICE_CREATE_METAL_ALLOW_MACFAMILY1_BOOLEAN "SDL.gpu.device.create.metal.allowmacfamily1" /** * A structure specifying additional options when using Vulkan. * * When no such structure is provided, SDL will use Vulkan API version 1.0 and * a minimal set of features. The requested API version influences how the * feature_list is processed by SDL. When requesting API version 1.0, the * feature_list is ignored. Only the vulkan_10_physical_device_features and * the extension lists are used. When requesting API version 1.1, the * feature_list is scanned for feature structures introduced in Vulkan 1.1. * When requesting Vulkan 1.2 or higher, the feature_list is additionally * scanned for compound feature structs such as * VkPhysicalDeviceVulkan11Features. The device and instance extension lists, * as well as vulkan_10_physical_device_features, are always processed. * * \since This struct is available since SDL 3.4.0. */ typedef struct SDL_GPUVulkanOptions { Uint32 vulkan_api_version; /**< The Vulkan API version to request for the instance. Use Vulkan's VK_MAKE_VERSION or VK_MAKE_API_VERSION. */ void *feature_list; /**< Pointer to the first element of a chain of Vulkan feature structs. (Requires API version 1.1 or higher.)*/ void *vulkan_10_physical_device_features; /**< Pointer to a VkPhysicalDeviceFeatures struct to enable additional Vulkan 1.0 features. */ Uint32 device_extension_count; /**< Number of additional device extensions to require. */ const char **device_extension_names; /**< Pointer to a list of additional device extensions to require. */ Uint32 instance_extension_count; /**< Number of additional instance extensions to require. */ const char **instance_extension_names; /**< Pointer to a list of additional instance extensions to require. */ } SDL_GPUVulkanOptions; /** * Destroys a GPU context previously returned by SDL_CreateGPUDevice. * * \param device a GPU Context to destroy. * * \since This function is available since SDL 3.2.0. * * \sa SDL_CreateGPUDevice */ extern SDL_DECLSPEC void SDLCALL SDL_DestroyGPUDevice(SDL_GPUDevice *device); /** * Get the number of GPU drivers compiled into SDL. * * \returns the number of built in GPU drivers. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetGPUDriver */ extern SDL_DECLSPEC int SDLCALL SDL_GetNumGPUDrivers(void); /** * Get the name of a built in GPU driver. * * The GPU drivers are presented in the order in which they are normally * checked during initialization. * * The names of drivers are all simple, low-ASCII identifiers, like "vulkan", * "metal" or "direct3d12". These never have Unicode characters, and are not * meant to be proper names. * * \param index the index of a GPU driver. * \returns the name of the GPU driver with the given **index**. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetNumGPUDrivers */ extern SDL_DECLSPEC const char * SDLCALL SDL_GetGPUDriver(int index); /** * Returns the name of the backend used to create this GPU context. * * \param device a GPU context to query. * \returns the name of the device's driver, or NULL on error. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC const char * SDLCALL SDL_GetGPUDeviceDriver(SDL_GPUDevice *device); /** * Returns the supported shader formats for this GPU context. * * \param device a GPU context to query. * \returns a bitflag indicating which shader formats the driver is able to * consume. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC SDL_GPUShaderFormat SDLCALL SDL_GetGPUShaderFormats(SDL_GPUDevice *device); /** * Get the properties associated with a GPU device. * * All properties are optional and may differ between GPU backends and SDL * versions. * * The following properties are provided by SDL: * * `SDL_PROP_GPU_DEVICE_NAME_STRING`: Contains the name of the underlying * device as reported by the system driver. This string has no standardized * format, is highly inconsistent between hardware devices and drivers, and is * able to change at any time. Do not attempt to parse this string as it is * bound to fail at some point in the future when system drivers are updated, * new hardware devices are introduced, or when SDL adds new GPU backends or * modifies existing ones. * * Strings that have been found in the wild include: * * - GTX 970 * - GeForce GTX 970 * - NVIDIA GeForce GTX 970 * - Microsoft Direct3D12 (NVIDIA GeForce GTX 970) * - NVIDIA Graphics Device * - GeForce GPU * - P106-100 * - AMD 15D8:C9 * - AMD Custom GPU 0405 * - AMD Radeon (TM) Graphics * - ASUS Radeon RX 470 Series * - Intel(R) Arc(tm) A380 Graphics (DG2) * - Virtio-GPU Venus (NVIDIA TITAN V) * - SwiftShader Device (LLVM 16.0.0) * - llvmpipe (LLVM 15.0.4, 256 bits) * - Microsoft Basic Render Driver * - unknown device * * The above list shows that the same device can have different formats, the * vendor name may or may not appear in the string, the included vendor name * may not be the vendor of the chipset on the device, some manufacturers * include pseudo-legal marks while others don't, some devices may not use a * marketing name in the string, the device string may be wrapped by the name * of a translation interface, the device may be emulated in software, or the * string may contain generic text that does not identify the device at all. * * `SDL_PROP_GPU_DEVICE_DRIVER_NAME_STRING`: Contains the self-reported name * of the underlying system driver. * * Strings that have been found in the wild include: * * - Intel Corporation * - Intel open-source Mesa driver * - Qualcomm Technologies Inc. Adreno Vulkan Driver * - MoltenVK * - Mali-G715 * - venus * * `SDL_PROP_GPU_DEVICE_DRIVER_VERSION_STRING`: Contains the self-reported * version of the underlying system driver. This is a relatively short version * string in an unspecified format. If SDL_PROP_GPU_DEVICE_DRIVER_INFO_STRING * is available then that property should be preferred over this one as it may * contain additional information that is useful for identifying the exact * driver version used. * * Strings that have been found in the wild include: * * - 53.0.0 * - 0.405.2463 * - 32.0.15.6614 * * `SDL_PROP_GPU_DEVICE_DRIVER_INFO_STRING`: Contains the detailed version * information of the underlying system driver as reported by the driver. This * is an arbitrary string with no standardized format and it may contain * newlines. This property should be preferred over * SDL_PROP_GPU_DEVICE_DRIVER_VERSION_STRING if it is available as it usually * contains the same information but in a format that is easier to read. * * Strings that have been found in the wild include: * * - 101.6559 * - 1.2.11 * - Mesa 21.2.2 (LLVM 12.0.1) * - Mesa 22.2.0-devel (git-f226222 2022-04-14 impish-oibaf-ppa) * - v1.r53p0-00eac0.824c4f31403fb1fbf8ee1042422c2129 * * This string has also been observed to be a multiline string (which has a * trailing newline): * * ``` * Driver Build: 85da404, I46ff5fc46f, 1606794520 * Date: 11/30/20 * Compiler Version: EV031.31.04.01 * Driver Branch: promo490_3_Google * ``` * * \param device a GPU context to query. * \returns a valid property ID on success or 0 on failure; call * SDL_GetError() for more information. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.4.0. */ extern SDL_DECLSPEC SDL_PropertiesID SDLCALL SDL_GetGPUDeviceProperties(SDL_GPUDevice *device); #define SDL_PROP_GPU_DEVICE_NAME_STRING "SDL.gpu.device.name" #define SDL_PROP_GPU_DEVICE_DRIVER_NAME_STRING "SDL.gpu.device.driver_name" #define SDL_PROP_GPU_DEVICE_DRIVER_VERSION_STRING "SDL.gpu.device.driver_version" #define SDL_PROP_GPU_DEVICE_DRIVER_INFO_STRING "SDL.gpu.device.driver_info" /* State Creation */ /** * Creates a pipeline object to be used in a compute workflow. * * Shader resource bindings must be authored to follow a particular order * depending on the shader format. * * For SPIR-V shaders, use the following resource sets: * * - 0: Sampled textures, followed by read-only storage textures, followed by * read-only storage buffers * - 1: Read-write storage textures, followed by read-write storage buffers * - 2: Uniform buffers * * For DXBC and DXIL shaders, use the following register order: * * - (t[n], space0): Sampled textures, followed by read-only storage textures, * followed by read-only storage buffers * - (u[n], space1): Read-write storage textures, followed by read-write * storage buffers * - (b[n], space2): Uniform buffers * * For MSL/metallib, use the following order: * * - [[buffer]]: Uniform buffers, followed by read-only storage buffers, * followed by read-write storage buffers * - [[texture]]: Sampled textures, followed by read-only storage textures, * followed by read-write storage textures * * There are optional properties that can be provided through `props`. These * are the supported properties: * * - `SDL_PROP_GPU_COMPUTEPIPELINE_CREATE_NAME_STRING`: a name that can be * displayed in debugging tools. * * \param device a GPU Context. * \param createinfo a struct describing the state of the compute pipeline to * create. * \returns a compute pipeline object on success, or NULL on failure; call * SDL_GetError() for more information. * * \since This function is available since SDL 3.2.0. * * \sa SDL_BindGPUComputePipeline * \sa SDL_ReleaseGPUComputePipeline */ extern SDL_DECLSPEC SDL_GPUComputePipeline * SDLCALL SDL_CreateGPUComputePipeline( SDL_GPUDevice *device, const SDL_GPUComputePipelineCreateInfo *createinfo); #define SDL_PROP_GPU_COMPUTEPIPELINE_CREATE_NAME_STRING "SDL.gpu.computepipeline.create.name" /** * Creates a pipeline object to be used in a graphics workflow. * * There are optional properties that can be provided through `props`. These * are the supported properties: * * - `SDL_PROP_GPU_GRAPHICSPIPELINE_CREATE_NAME_STRING`: a name that can be * displayed in debugging tools. * * \param device a GPU Context. * \param createinfo a struct describing the state of the graphics pipeline to * create. * \returns a graphics pipeline object on success, or NULL on failure; call * SDL_GetError() for more information. * * \since This function is available since SDL 3.2.0. * * \sa SDL_CreateGPUShader * \sa SDL_BindGPUGraphicsPipeline * \sa SDL_ReleaseGPUGraphicsPipeline */ extern SDL_DECLSPEC SDL_GPUGraphicsPipeline * SDLCALL SDL_CreateGPUGraphicsPipeline( SDL_GPUDevice *device, const SDL_GPUGraphicsPipelineCreateInfo *createinfo); #define SDL_PROP_GPU_GRAPHICSPIPELINE_CREATE_NAME_STRING "SDL.gpu.graphicspipeline.create.name" /** * Creates a sampler object to be used when binding textures in a graphics * workflow. * * There are optional properties that can be provided through `props`. These * are the supported properties: * * - `SDL_PROP_GPU_SAMPLER_CREATE_NAME_STRING`: a name that can be displayed * in debugging tools. * * \param device a GPU Context. * \param createinfo a struct describing the state of the sampler to create. * \returns a sampler object on success, or NULL on failure; call * SDL_GetError() for more information. * * \since This function is available since SDL 3.2.0. * * \sa SDL_BindGPUVertexSamplers * \sa SDL_BindGPUFragmentSamplers * \sa SDL_ReleaseGPUSampler */ extern SDL_DECLSPEC SDL_GPUSampler * SDLCALL SDL_CreateGPUSampler( SDL_GPUDevice *device, const SDL_GPUSamplerCreateInfo *createinfo); #define SDL_PROP_GPU_SAMPLER_CREATE_NAME_STRING "SDL.gpu.sampler.create.name" /** * Creates a shader to be used when creating a graphics pipeline. * * Shader resource bindings must be authored to follow a particular order * depending on the shader format. * * For SPIR-V shaders, use the following resource sets: * * For vertex shaders: * * - 0: Sampled textures, followed by storage textures, followed by storage * buffers * - 1: Uniform buffers * * For fragment shaders: * * - 2: Sampled textures, followed by storage textures, followed by storage * buffers * - 3: Uniform buffers * * For DXBC and DXIL shaders, use the following register order: * * For vertex shaders: * * - (t[n], space0): Sampled textures, followed by storage textures, followed * by storage buffers * - (s[n], space0): Samplers with indices corresponding to the sampled * textures * - (b[n], space1): Uniform buffers * * For pixel shaders: * * - (t[n], space2): Sampled textures, followed by storage textures, followed * by storage buffers * - (s[n], space2): Samplers with indices corresponding to the sampled * textures * - (b[n], space3): Uniform buffers * * For MSL/metallib, use the following order: * * - [[texture]]: Sampled textures, followed by storage textures * - [[sampler]]: Samplers with indices corresponding to the sampled textures * - [[buffer]]: Uniform buffers, followed by storage buffers. Vertex buffer 0 * is bound at [[buffer(14)]], vertex buffer 1 at [[buffer(15)]], and so on. * Rather than manually authoring vertex buffer indices, use the * [[stage_in]] attribute which will automatically use the vertex input * information from the SDL_GPUGraphicsPipeline. * * Shader semantics other than system-value semantics do not matter in D3D12 * and for ease of use the SDL implementation assumes that non system-value * semantics will all be TEXCOORD. If you are using HLSL as the shader source * language, your vertex semantics should start at TEXCOORD0 and increment * like so: TEXCOORD1, TEXCOORD2, etc. If you wish to change the semantic * prefix to something other than TEXCOORD you can use * SDL_PROP_GPU_DEVICE_CREATE_D3D12_SEMANTIC_NAME_STRING with * SDL_CreateGPUDeviceWithProperties(). * * There are optional properties that can be provided through `props`. These * are the supported properties: * * - `SDL_PROP_GPU_SHADER_CREATE_NAME_STRING`: a name that can be displayed in * debugging tools. * * \param device a GPU Context. * \param createinfo a struct describing the state of the shader to create. * \returns a shader object on success, or NULL on failure; call * SDL_GetError() for more information. * * \since This function is available since SDL 3.2.0. * * \sa SDL_CreateGPUGraphicsPipeline * \sa SDL_ReleaseGPUShader */ extern SDL_DECLSPEC SDL_GPUShader * SDLCALL SDL_CreateGPUShader( SDL_GPUDevice *device, const SDL_GPUShaderCreateInfo *createinfo); #define SDL_PROP_GPU_SHADER_CREATE_NAME_STRING "SDL.gpu.shader.create.name" /** * Creates a texture object to be used in graphics or compute workflows. * * The contents of this texture are undefined until data is written to the * texture, either via SDL_UploadToGPUTexture or by performing a render or * compute pass with this texture as a target. * * Note that certain combinations of usage flags are invalid. For example, a * texture cannot have both the SAMPLER and GRAPHICS_STORAGE_READ flags. * * If you request a sample count higher than the hardware supports, the * implementation will automatically fall back to the highest available sample * count. * * There are optional properties that can be provided through * SDL_GPUTextureCreateInfo's `props`. These are the supported properties: * * - `SDL_PROP_GPU_TEXTURE_CREATE_D3D12_CLEAR_R_FLOAT`: (Direct3D 12 only) if * the texture usage is SDL_GPU_TEXTUREUSAGE_COLOR_TARGET, clear the texture * to a color with this red intensity. Defaults to zero. * - `SDL_PROP_GPU_TEXTURE_CREATE_D3D12_CLEAR_G_FLOAT`: (Direct3D 12 only) if * the texture usage is SDL_GPU_TEXTUREUSAGE_COLOR_TARGET, clear the texture * to a color with this green intensity. Defaults to zero. * - `SDL_PROP_GPU_TEXTURE_CREATE_D3D12_CLEAR_B_FLOAT`: (Direct3D 12 only) if * the texture usage is SDL_GPU_TEXTUREUSAGE_COLOR_TARGET, clear the texture * to a color with this blue intensity. Defaults to zero. * - `SDL_PROP_GPU_TEXTURE_CREATE_D3D12_CLEAR_A_FLOAT`: (Direct3D 12 only) if * the texture usage is SDL_GPU_TEXTUREUSAGE_COLOR_TARGET, clear the texture * to a color with this alpha intensity. Defaults to zero. * - `SDL_PROP_GPU_TEXTURE_CREATE_D3D12_CLEAR_DEPTH_FLOAT`: (Direct3D 12 only) * if the texture usage is SDL_GPU_TEXTUREUSAGE_DEPTH_STENCIL_TARGET, clear * the texture to a depth of this value. Defaults to zero. * - `SDL_PROP_GPU_TEXTURE_CREATE_D3D12_CLEAR_STENCIL_NUMBER`: (Direct3D 12 * only) if the texture usage is SDL_GPU_TEXTUREUSAGE_DEPTH_STENCIL_TARGET, * clear the texture to a stencil of this Uint8 value. Defaults to zero. * - `SDL_PROP_GPU_TEXTURE_CREATE_NAME_STRING`: a name that can be displayed * in debugging tools. * * \param device a GPU Context. * \param createinfo a struct describing the state of the texture to create. * \returns a texture object on success, or NULL on failure; call * SDL_GetError() for more information. * * \since This function is available since SDL 3.2.0. * * \sa SDL_UploadToGPUTexture * \sa SDL_DownloadFromGPUTexture * \sa SDL_BeginGPURenderPass * \sa SDL_BeginGPUComputePass * \sa SDL_BindGPUVertexSamplers * \sa SDL_BindGPUVertexStorageTextures * \sa SDL_BindGPUFragmentSamplers * \sa SDL_BindGPUFragmentStorageTextures * \sa SDL_BindGPUComputeStorageTextures * \sa SDL_BlitGPUTexture * \sa SDL_ReleaseGPUTexture * \sa SDL_GPUTextureSupportsFormat */ extern SDL_DECLSPEC SDL_GPUTexture * SDLCALL SDL_CreateGPUTexture( SDL_GPUDevice *device, const SDL_GPUTextureCreateInfo *createinfo); #define SDL_PROP_GPU_TEXTURE_CREATE_D3D12_CLEAR_R_FLOAT "SDL.gpu.texture.create.d3d12.clear.r" #define SDL_PROP_GPU_TEXTURE_CREATE_D3D12_CLEAR_G_FLOAT "SDL.gpu.texture.create.d3d12.clear.g" #define SDL_PROP_GPU_TEXTURE_CREATE_D3D12_CLEAR_B_FLOAT "SDL.gpu.texture.create.d3d12.clear.b" #define SDL_PROP_GPU_TEXTURE_CREATE_D3D12_CLEAR_A_FLOAT "SDL.gpu.texture.create.d3d12.clear.a" #define SDL_PROP_GPU_TEXTURE_CREATE_D3D12_CLEAR_DEPTH_FLOAT "SDL.gpu.texture.create.d3d12.clear.depth" #define SDL_PROP_GPU_TEXTURE_CREATE_D3D12_CLEAR_STENCIL_NUMBER "SDL.gpu.texture.create.d3d12.clear.stencil" #define SDL_PROP_GPU_TEXTURE_CREATE_NAME_STRING "SDL.gpu.texture.create.name" /** * Creates a buffer object to be used in graphics or compute workflows. * * The contents of this buffer are undefined until data is written to the * buffer. * * Note that certain combinations of usage flags are invalid. For example, a * buffer cannot have both the VERTEX and INDEX flags. * * If you use a STORAGE flag, the data in the buffer must respect std140 * layout conventions. In practical terms this means you must ensure that vec3 * and vec4 fields are 16-byte aligned. * * For better understanding of underlying concepts and memory management with * SDL GPU API, you may refer * [this blog post](https://moonside.games/posts/sdl-gpu-concepts-cycling/) * . * * There are optional properties that can be provided through `props`. These * are the supported properties: * * - `SDL_PROP_GPU_BUFFER_CREATE_NAME_STRING`: a name that can be displayed in * debugging tools. * * \param device a GPU Context. * \param createinfo a struct describing the state of the buffer to create. * \returns a buffer object on success, or NULL on failure; call * SDL_GetError() for more information. * * \since This function is available since SDL 3.2.0. * * \sa SDL_UploadToGPUBuffer * \sa SDL_DownloadFromGPUBuffer * \sa SDL_CopyGPUBufferToBuffer * \sa SDL_BindGPUVertexBuffers * \sa SDL_BindGPUIndexBuffer * \sa SDL_BindGPUVertexStorageBuffers * \sa SDL_BindGPUFragmentStorageBuffers * \sa SDL_DrawGPUPrimitivesIndirect * \sa SDL_DrawGPUIndexedPrimitivesIndirect * \sa SDL_BindGPUComputeStorageBuffers * \sa SDL_DispatchGPUComputeIndirect * \sa SDL_ReleaseGPUBuffer */ extern SDL_DECLSPEC SDL_GPUBuffer * SDLCALL SDL_CreateGPUBuffer( SDL_GPUDevice *device, const SDL_GPUBufferCreateInfo *createinfo); #define SDL_PROP_GPU_BUFFER_CREATE_NAME_STRING "SDL.gpu.buffer.create.name" /** * Creates a transfer buffer to be used when uploading to or downloading from * graphics resources. * * Download buffers can be particularly expensive to create, so it is good * practice to reuse them if data will be downloaded regularly. * * There are optional properties that can be provided through `props`. These * are the supported properties: * * - `SDL_PROP_GPU_TRANSFERBUFFER_CREATE_NAME_STRING`: a name that can be * displayed in debugging tools. * * \param device a GPU Context. * \param createinfo a struct describing the state of the transfer buffer to * create. * \returns a transfer buffer on success, or NULL on failure; call * SDL_GetError() for more information. * * \since This function is available since SDL 3.2.0. * * \sa SDL_UploadToGPUBuffer * \sa SDL_DownloadFromGPUBuffer * \sa SDL_UploadToGPUTexture * \sa SDL_DownloadFromGPUTexture * \sa SDL_ReleaseGPUTransferBuffer */ extern SDL_DECLSPEC SDL_GPUTransferBuffer * SDLCALL SDL_CreateGPUTransferBuffer( SDL_GPUDevice *device, const SDL_GPUTransferBufferCreateInfo *createinfo); #define SDL_PROP_GPU_TRANSFERBUFFER_CREATE_NAME_STRING "SDL.gpu.transferbuffer.create.name" /* Debug Naming */ /** * Sets an arbitrary string constant to label a buffer. * * You should use SDL_PROP_GPU_BUFFER_CREATE_NAME_STRING with * SDL_CreateGPUBuffer instead of this function to avoid thread safety issues. * * \param device a GPU Context. * \param buffer a buffer to attach the name to. * \param text a UTF-8 string constant to mark as the name of the buffer. * * \threadsafety This function is not thread safe, you must make sure the * buffer is not simultaneously used by any other thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_CreateGPUBuffer */ extern SDL_DECLSPEC void SDLCALL SDL_SetGPUBufferName( SDL_GPUDevice *device, SDL_GPUBuffer *buffer, const char *text); /** * Sets an arbitrary string constant to label a texture. * * You should use SDL_PROP_GPU_TEXTURE_CREATE_NAME_STRING with * SDL_CreateGPUTexture instead of this function to avoid thread safety * issues. * * \param device a GPU Context. * \param texture a texture to attach the name to. * \param text a UTF-8 string constant to mark as the name of the texture. * * \threadsafety This function is not thread safe, you must make sure the * texture is not simultaneously used by any other thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_CreateGPUTexture */ extern SDL_DECLSPEC void SDLCALL SDL_SetGPUTextureName( SDL_GPUDevice *device, SDL_GPUTexture *texture, const char *text); /** * Inserts an arbitrary string label into the command buffer callstream. * * Useful for debugging. * * On Direct3D 12, using SDL_InsertGPUDebugLabel requires * WinPixEventRuntime.dll to be in your PATH or in the same directory as your * executable. See * [here](https://devblogs.microsoft.com/pix/winpixeventruntime/) * for instructions on how to obtain it. * * \param command_buffer a command buffer. * \param text a UTF-8 string constant to insert as the label. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC void SDLCALL SDL_InsertGPUDebugLabel( SDL_GPUCommandBuffer *command_buffer, const char *text); /** * Begins a debug group with an arbitrary name. * * Used for denoting groups of calls when viewing the command buffer * callstream in a graphics debugging tool. * * Each call to SDL_PushGPUDebugGroup must have a corresponding call to * SDL_PopGPUDebugGroup. * * On Direct3D 12, using SDL_PushGPUDebugGroup requires WinPixEventRuntime.dll * to be in your PATH or in the same directory as your executable. See * [here](https://devblogs.microsoft.com/pix/winpixeventruntime/) * for instructions on how to obtain it. * * On some backends (e.g. Metal), pushing a debug group during a * render/blit/compute pass will create a group that is scoped to the native * pass rather than the command buffer. For best results, if you push a debug * group during a pass, always pop it in the same pass. * * \param command_buffer a command buffer. * \param name a UTF-8 string constant that names the group. * * \since This function is available since SDL 3.2.0. * * \sa SDL_PopGPUDebugGroup */ extern SDL_DECLSPEC void SDLCALL SDL_PushGPUDebugGroup( SDL_GPUCommandBuffer *command_buffer, const char *name); /** * Ends the most-recently pushed debug group. * * On Direct3D 12, using SDL_PopGPUDebugGroup requires WinPixEventRuntime.dll * to be in your PATH or in the same directory as your executable. See * [here](https://devblogs.microsoft.com/pix/winpixeventruntime/) * for instructions on how to obtain it. * * \param command_buffer a command buffer. * * \since This function is available since SDL 3.2.0. * * \sa SDL_PushGPUDebugGroup */ extern SDL_DECLSPEC void SDLCALL SDL_PopGPUDebugGroup( SDL_GPUCommandBuffer *command_buffer); /* Disposal */ /** * Frees the given texture as soon as it is safe to do so. * * You must not reference the texture after calling this function. * * \param device a GPU context. * \param texture a texture to be destroyed. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC void SDLCALL SDL_ReleaseGPUTexture( SDL_GPUDevice *device, SDL_GPUTexture *texture); /** * Frees the given sampler as soon as it is safe to do so. * * You must not reference the sampler after calling this function. * * \param device a GPU context. * \param sampler a sampler to be destroyed. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC void SDLCALL SDL_ReleaseGPUSampler( SDL_GPUDevice *device, SDL_GPUSampler *sampler); /** * Frees the given buffer as soon as it is safe to do so. * * You must not reference the buffer after calling this function. * * \param device a GPU context. * \param buffer a buffer to be destroyed. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC void SDLCALL SDL_ReleaseGPUBuffer( SDL_GPUDevice *device, SDL_GPUBuffer *buffer); /** * Frees the given transfer buffer as soon as it is safe to do so. * * You must not reference the transfer buffer after calling this function. * * \param device a GPU context. * \param transfer_buffer a transfer buffer to be destroyed. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC void SDLCALL SDL_ReleaseGPUTransferBuffer( SDL_GPUDevice *device, SDL_GPUTransferBuffer *transfer_buffer); /** * Frees the given compute pipeline as soon as it is safe to do so. * * You must not reference the compute pipeline after calling this function. * * \param device a GPU context. * \param compute_pipeline a compute pipeline to be destroyed. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC void SDLCALL SDL_ReleaseGPUComputePipeline( SDL_GPUDevice *device, SDL_GPUComputePipeline *compute_pipeline); /** * Frees the given shader as soon as it is safe to do so. * * You must not reference the shader after calling this function. * * \param device a GPU context. * \param shader a shader to be destroyed. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC void SDLCALL SDL_ReleaseGPUShader( SDL_GPUDevice *device, SDL_GPUShader *shader); /** * Frees the given graphics pipeline as soon as it is safe to do so. * * You must not reference the graphics pipeline after calling this function. * * \param device a GPU context. * \param graphics_pipeline a graphics pipeline to be destroyed. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC void SDLCALL SDL_ReleaseGPUGraphicsPipeline( SDL_GPUDevice *device, SDL_GPUGraphicsPipeline *graphics_pipeline); /** * Acquire a command buffer. * * This command buffer is managed by the implementation and should not be * freed by the user. The command buffer may only be used on the thread it was * acquired on. The command buffer should be submitted on the thread it was * acquired on. * * It is valid to acquire multiple command buffers on the same thread at once. * In fact a common design pattern is to acquire two command buffers per frame * where one is dedicated to render and compute passes and the other is * dedicated to copy passes and other preparatory work such as generating * mipmaps. Interleaving commands between the two command buffers reduces the * total amount of passes overall which improves rendering performance. * * \param device a GPU context. * \returns a command buffer, or NULL on failure; call SDL_GetError() for more * information. * * \since This function is available since SDL 3.2.0. * * \sa SDL_SubmitGPUCommandBuffer * \sa SDL_SubmitGPUCommandBufferAndAcquireFence */ extern SDL_DECLSPEC SDL_GPUCommandBuffer * SDLCALL SDL_AcquireGPUCommandBuffer( SDL_GPUDevice *device); /* Uniform Data */ /** * Pushes data to a vertex uniform slot on the command buffer. * * Subsequent draw calls in this command buffer will use this uniform data. * * The data being pushed must respect std140 layout conventions. In practical * terms this means you must ensure that vec3 and vec4 fields are 16-byte * aligned. * * For detailed information about accessing uniform data from a shader, please * refer to SDL_CreateGPUShader. * * \param command_buffer a command buffer. * \param slot_index the vertex uniform slot to push data to. * \param data client data to write. * \param length the length of the data to write. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC void SDLCALL SDL_PushGPUVertexUniformData( SDL_GPUCommandBuffer *command_buffer, Uint32 slot_index, const void *data, Uint32 length); /** * Pushes data to a fragment uniform slot on the command buffer. * * Subsequent draw calls in this command buffer will use this uniform data. * * The data being pushed must respect std140 layout conventions. In practical * terms this means you must ensure that vec3 and vec4 fields are 16-byte * aligned. * * \param command_buffer a command buffer. * \param slot_index the fragment uniform slot to push data to. * \param data client data to write. * \param length the length of the data to write. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC void SDLCALL SDL_PushGPUFragmentUniformData( SDL_GPUCommandBuffer *command_buffer, Uint32 slot_index, const void *data, Uint32 length); /** * Pushes data to a uniform slot on the command buffer. * * Subsequent draw calls in this command buffer will use this uniform data. * * The data being pushed must respect std140 layout conventions. In practical * terms this means you must ensure that vec3 and vec4 fields are 16-byte * aligned. * * \param command_buffer a command buffer. * \param slot_index the uniform slot to push data to. * \param data client data to write. * \param length the length of the data to write. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC void SDLCALL SDL_PushGPUComputeUniformData( SDL_GPUCommandBuffer *command_buffer, Uint32 slot_index, const void *data, Uint32 length); /* Graphics State */ /** * Begins a render pass on a command buffer. * * A render pass consists of a set of texture subresources (or depth slices in * the 3D texture case) which will be rendered to during the render pass, * along with corresponding clear values and load/store operations. All * operations related to graphics pipelines must take place inside of a render * pass. A default viewport and scissor state are automatically set when this * is called. You cannot begin another render pass, or begin a compute pass or * copy pass until you have ended the render pass. * * Using SDL_GPU_LOADOP_LOAD before any contents have been written to the * texture subresource will result in undefined behavior. SDL_GPU_LOADOP_CLEAR * will set the contents of the texture subresource to a single value before * any rendering is performed. It's fine to do an empty render pass using * SDL_GPU_STOREOP_STORE to clear a texture, but in general it's better to * think of clearing not as an independent operation but as something that's * done as the beginning of a render pass. * * \param command_buffer a command buffer. * \param color_target_infos an array of texture subresources with * corresponding clear values and load/store ops. * \param num_color_targets the number of color targets in the * color_target_infos array. * \param depth_stencil_target_info a texture subresource with corresponding * clear value and load/store ops, may be * NULL. * \returns a render pass handle. * * \since This function is available since SDL 3.2.0. * * \sa SDL_EndGPURenderPass */ extern SDL_DECLSPEC SDL_GPURenderPass * SDLCALL SDL_BeginGPURenderPass( SDL_GPUCommandBuffer *command_buffer, const SDL_GPUColorTargetInfo *color_target_infos, Uint32 num_color_targets, const SDL_GPUDepthStencilTargetInfo *depth_stencil_target_info); /** * Binds a graphics pipeline on a render pass to be used in rendering. * * A graphics pipeline must be bound before making any draw calls. * * \param render_pass a render pass handle. * \param graphics_pipeline the graphics pipeline to bind. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC void SDLCALL SDL_BindGPUGraphicsPipeline( SDL_GPURenderPass *render_pass, SDL_GPUGraphicsPipeline *graphics_pipeline); /** * Sets the current viewport state on a command buffer. * * \param render_pass a render pass handle. * \param viewport the viewport to set. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC void SDLCALL SDL_SetGPUViewport( SDL_GPURenderPass *render_pass, const SDL_GPUViewport *viewport); /** * Sets the current scissor state on a command buffer. * * \param render_pass a render pass handle. * \param scissor the scissor area to set. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC void SDLCALL SDL_SetGPUScissor( SDL_GPURenderPass *render_pass, const SDL_Rect *scissor); /** * Sets the current blend constants on a command buffer. * * \param render_pass a render pass handle. * \param blend_constants the blend constant color. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GPU_BLENDFACTOR_CONSTANT_COLOR * \sa SDL_GPU_BLENDFACTOR_ONE_MINUS_CONSTANT_COLOR */ extern SDL_DECLSPEC void SDLCALL SDL_SetGPUBlendConstants( SDL_GPURenderPass *render_pass, SDL_FColor blend_constants); /** * Sets the current stencil reference value on a command buffer. * * \param render_pass a render pass handle. * \param reference the stencil reference value to set. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC void SDLCALL SDL_SetGPUStencilReference( SDL_GPURenderPass *render_pass, Uint8 reference); /** * Binds vertex buffers on a command buffer for use with subsequent draw * calls. * * \param render_pass a render pass handle. * \param first_slot the vertex buffer slot to begin binding from. * \param bindings an array of SDL_GPUBufferBinding structs containing vertex * buffers and offset values. * \param num_bindings the number of bindings in the bindings array. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC void SDLCALL SDL_BindGPUVertexBuffers( SDL_GPURenderPass *render_pass, Uint32 first_slot, const SDL_GPUBufferBinding *bindings, Uint32 num_bindings); /** * Binds an index buffer on a command buffer for use with subsequent draw * calls. * * \param render_pass a render pass handle. * \param binding a pointer to a struct containing an index buffer and offset. * \param index_element_size whether the index values in the buffer are 16- or * 32-bit. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC void SDLCALL SDL_BindGPUIndexBuffer( SDL_GPURenderPass *render_pass, const SDL_GPUBufferBinding *binding, SDL_GPUIndexElementSize index_element_size); /** * Binds texture-sampler pairs for use on the vertex shader. * * The textures must have been created with SDL_GPU_TEXTUREUSAGE_SAMPLER. * * Be sure your shader is set up according to the requirements documented in * SDL_CreateGPUShader(). * * \param render_pass a render pass handle. * \param first_slot the vertex sampler slot to begin binding from. * \param texture_sampler_bindings an array of texture-sampler binding * structs. * \param num_bindings the number of texture-sampler pairs to bind from the * array. * * \since This function is available since SDL 3.2.0. * * \sa SDL_CreateGPUShader */ extern SDL_DECLSPEC void SDLCALL SDL_BindGPUVertexSamplers( SDL_GPURenderPass *render_pass, Uint32 first_slot, const SDL_GPUTextureSamplerBinding *texture_sampler_bindings, Uint32 num_bindings); /** * Binds storage textures for use on the vertex shader. * * These textures must have been created with * SDL_GPU_TEXTUREUSAGE_GRAPHICS_STORAGE_READ. * * Be sure your shader is set up according to the requirements documented in * SDL_CreateGPUShader(). * * \param render_pass a render pass handle. * \param first_slot the vertex storage texture slot to begin binding from. * \param storage_textures an array of storage textures. * \param num_bindings the number of storage texture to bind from the array. * * \since This function is available since SDL 3.2.0. * * \sa SDL_CreateGPUShader */ extern SDL_DECLSPEC void SDLCALL SDL_BindGPUVertexStorageTextures( SDL_GPURenderPass *render_pass, Uint32 first_slot, SDL_GPUTexture *const *storage_textures, Uint32 num_bindings); /** * Binds storage buffers for use on the vertex shader. * * These buffers must have been created with * SDL_GPU_BUFFERUSAGE_GRAPHICS_STORAGE_READ. * * Be sure your shader is set up according to the requirements documented in * SDL_CreateGPUShader(). * * \param render_pass a render pass handle. * \param first_slot the vertex storage buffer slot to begin binding from. * \param storage_buffers an array of buffers. * \param num_bindings the number of buffers to bind from the array. * * \since This function is available since SDL 3.2.0. * * \sa SDL_CreateGPUShader */ extern SDL_DECLSPEC void SDLCALL SDL_BindGPUVertexStorageBuffers( SDL_GPURenderPass *render_pass, Uint32 first_slot, SDL_GPUBuffer *const *storage_buffers, Uint32 num_bindings); /** * Binds texture-sampler pairs for use on the fragment shader. * * The textures must have been created with SDL_GPU_TEXTUREUSAGE_SAMPLER. * * Be sure your shader is set up according to the requirements documented in * SDL_CreateGPUShader(). * * \param render_pass a render pass handle. * \param first_slot the fragment sampler slot to begin binding from. * \param texture_sampler_bindings an array of texture-sampler binding * structs. * \param num_bindings the number of texture-sampler pairs to bind from the * array. * * \since This function is available since SDL 3.2.0. * * \sa SDL_CreateGPUShader */ extern SDL_DECLSPEC void SDLCALL SDL_BindGPUFragmentSamplers( SDL_GPURenderPass *render_pass, Uint32 first_slot, const SDL_GPUTextureSamplerBinding *texture_sampler_bindings, Uint32 num_bindings); /** * Binds storage textures for use on the fragment shader. * * These textures must have been created with * SDL_GPU_TEXTUREUSAGE_GRAPHICS_STORAGE_READ. * * Be sure your shader is set up according to the requirements documented in * SDL_CreateGPUShader(). * * \param render_pass a render pass handle. * \param first_slot the fragment storage texture slot to begin binding from. * \param storage_textures an array of storage textures. * \param num_bindings the number of storage textures to bind from the array. * * \since This function is available since SDL 3.2.0. * * \sa SDL_CreateGPUShader */ extern SDL_DECLSPEC void SDLCALL SDL_BindGPUFragmentStorageTextures( SDL_GPURenderPass *render_pass, Uint32 first_slot, SDL_GPUTexture *const *storage_textures, Uint32 num_bindings); /** * Binds storage buffers for use on the fragment shader. * * These buffers must have been created with * SDL_GPU_BUFFERUSAGE_GRAPHICS_STORAGE_READ. * * Be sure your shader is set up according to the requirements documented in * SDL_CreateGPUShader(). * * \param render_pass a render pass handle. * \param first_slot the fragment storage buffer slot to begin binding from. * \param storage_buffers an array of storage buffers. * \param num_bindings the number of storage buffers to bind from the array. * * \since This function is available since SDL 3.2.0. * * \sa SDL_CreateGPUShader */ extern SDL_DECLSPEC void SDLCALL SDL_BindGPUFragmentStorageBuffers( SDL_GPURenderPass *render_pass, Uint32 first_slot, SDL_GPUBuffer *const *storage_buffers, Uint32 num_bindings); /* Drawing */ /** * Draws data using bound graphics state with an index buffer and instancing * enabled. * * You must not call this function before binding a graphics pipeline. * * Note that the `first_vertex` and `first_instance` parameters are NOT * compatible with built-in vertex/instance ID variables in shaders (for * example, SV_VertexID); GPU APIs and shader languages do not define these * built-in variables consistently, so if your shader depends on them, the * only way to keep behavior consistent and portable is to always pass 0 for * the correlating parameter in the draw calls. * * \param render_pass a render pass handle. * \param num_indices the number of indices to draw per instance. * \param num_instances the number of instances to draw. * \param first_index the starting index within the index buffer. * \param vertex_offset value added to vertex index before indexing into the * vertex buffer. * \param first_instance the ID of the first instance to draw. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC void SDLCALL SDL_DrawGPUIndexedPrimitives( SDL_GPURenderPass *render_pass, Uint32 num_indices, Uint32 num_instances, Uint32 first_index, Sint32 vertex_offset, Uint32 first_instance); /** * Draws data using bound graphics state. * * You must not call this function before binding a graphics pipeline. * * Note that the `first_vertex` and `first_instance` parameters are NOT * compatible with built-in vertex/instance ID variables in shaders (for * example, SV_VertexID); GPU APIs and shader languages do not define these * built-in variables consistently, so if your shader depends on them, the * only way to keep behavior consistent and portable is to always pass 0 for * the correlating parameter in the draw calls. * * \param render_pass a render pass handle. * \param num_vertices the number of vertices to draw. * \param num_instances the number of instances that will be drawn. * \param first_vertex the index of the first vertex to draw. * \param first_instance the ID of the first instance to draw. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC void SDLCALL SDL_DrawGPUPrimitives( SDL_GPURenderPass *render_pass, Uint32 num_vertices, Uint32 num_instances, Uint32 first_vertex, Uint32 first_instance); /** * Draws data using bound graphics state and with draw parameters set from a * buffer. * * The buffer must consist of tightly-packed draw parameter sets that each * match the layout of SDL_GPUIndirectDrawCommand. You must not call this * function before binding a graphics pipeline. * * \param render_pass a render pass handle. * \param buffer a buffer containing draw parameters. * \param offset the offset to start reading from the draw buffer. * \param draw_count the number of draw parameter sets that should be read * from the draw buffer. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC void SDLCALL SDL_DrawGPUPrimitivesIndirect( SDL_GPURenderPass *render_pass, SDL_GPUBuffer *buffer, Uint32 offset, Uint32 draw_count); /** * Draws data using bound graphics state with an index buffer enabled and with * draw parameters set from a buffer. * * The buffer must consist of tightly-packed draw parameter sets that each * match the layout of SDL_GPUIndexedIndirectDrawCommand. You must not call * this function before binding a graphics pipeline. * * \param render_pass a render pass handle. * \param buffer a buffer containing draw parameters. * \param offset the offset to start reading from the draw buffer. * \param draw_count the number of draw parameter sets that should be read * from the draw buffer. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC void SDLCALL SDL_DrawGPUIndexedPrimitivesIndirect( SDL_GPURenderPass *render_pass, SDL_GPUBuffer *buffer, Uint32 offset, Uint32 draw_count); /** * Ends the given render pass. * * All bound graphics state on the render pass command buffer is unset. The * render pass handle is now invalid. * * \param render_pass a render pass handle. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC void SDLCALL SDL_EndGPURenderPass( SDL_GPURenderPass *render_pass); /* Compute Pass */ /** * Begins a compute pass on a command buffer. * * A compute pass is defined by a set of texture subresources and buffers that * may be written to by compute pipelines. These textures and buffers must * have been created with the COMPUTE_STORAGE_WRITE bit or the * COMPUTE_STORAGE_SIMULTANEOUS_READ_WRITE bit. If you do not create a texture * with COMPUTE_STORAGE_SIMULTANEOUS_READ_WRITE, you must not read from the * texture in the compute pass. All operations related to compute pipelines * must take place inside of a compute pass. You must not begin another * compute pass, or a render pass or copy pass before ending the compute pass. * * A VERY IMPORTANT NOTE - Reads and writes in compute passes are NOT * implicitly synchronized. This means you may cause data races by both * reading and writing a resource region in a compute pass, or by writing * multiple times to a resource region. If your compute work depends on * reading the completed output from a previous dispatch, you MUST end the * current compute pass and begin a new one before you can safely access the * data. Otherwise you will receive unexpected results. Reading and writing a * texture in the same compute pass is only supported by specific texture * formats. Make sure you check the format support! * * \param command_buffer a command buffer. * \param storage_texture_bindings an array of writeable storage texture * binding structs. * \param num_storage_texture_bindings the number of storage textures to bind * from the array. * \param storage_buffer_bindings an array of writeable storage buffer binding * structs. * \param num_storage_buffer_bindings the number of storage buffers to bind * from the array. * \returns a compute pass handle. * * \since This function is available since SDL 3.2.0. * * \sa SDL_EndGPUComputePass */ extern SDL_DECLSPEC SDL_GPUComputePass * SDLCALL SDL_BeginGPUComputePass( SDL_GPUCommandBuffer *command_buffer, const SDL_GPUStorageTextureReadWriteBinding *storage_texture_bindings, Uint32 num_storage_texture_bindings, const SDL_GPUStorageBufferReadWriteBinding *storage_buffer_bindings, Uint32 num_storage_buffer_bindings); /** * Binds a compute pipeline on a command buffer for use in compute dispatch. * * \param compute_pass a compute pass handle. * \param compute_pipeline a compute pipeline to bind. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC void SDLCALL SDL_BindGPUComputePipeline( SDL_GPUComputePass *compute_pass, SDL_GPUComputePipeline *compute_pipeline); /** * Binds texture-sampler pairs for use on the compute shader. * * The textures must have been created with SDL_GPU_TEXTUREUSAGE_SAMPLER. * * Be sure your shader is set up according to the requirements documented in * SDL_CreateGPUComputePipeline(). * * \param compute_pass a compute pass handle. * \param first_slot the compute sampler slot to begin binding from. * \param texture_sampler_bindings an array of texture-sampler binding * structs. * \param num_bindings the number of texture-sampler bindings to bind from the * array. * * \since This function is available since SDL 3.2.0. * * \sa SDL_CreateGPUComputePipeline */ extern SDL_DECLSPEC void SDLCALL SDL_BindGPUComputeSamplers( SDL_GPUComputePass *compute_pass, Uint32 first_slot, const SDL_GPUTextureSamplerBinding *texture_sampler_bindings, Uint32 num_bindings); /** * Binds storage textures as readonly for use on the compute pipeline. * * These textures must have been created with * SDL_GPU_TEXTUREUSAGE_COMPUTE_STORAGE_READ. * * Be sure your shader is set up according to the requirements documented in * SDL_CreateGPUComputePipeline(). * * \param compute_pass a compute pass handle. * \param first_slot the compute storage texture slot to begin binding from. * \param storage_textures an array of storage textures. * \param num_bindings the number of storage textures to bind from the array. * * \since This function is available since SDL 3.2.0. * * \sa SDL_CreateGPUComputePipeline */ extern SDL_DECLSPEC void SDLCALL SDL_BindGPUComputeStorageTextures( SDL_GPUComputePass *compute_pass, Uint32 first_slot, SDL_GPUTexture *const *storage_textures, Uint32 num_bindings); /** * Binds storage buffers as readonly for use on the compute pipeline. * * These buffers must have been created with * SDL_GPU_BUFFERUSAGE_COMPUTE_STORAGE_READ. * * Be sure your shader is set up according to the requirements documented in * SDL_CreateGPUComputePipeline(). * * \param compute_pass a compute pass handle. * \param first_slot the compute storage buffer slot to begin binding from. * \param storage_buffers an array of storage buffer binding structs. * \param num_bindings the number of storage buffers to bind from the array. * * \since This function is available since SDL 3.2.0. * * \sa SDL_CreateGPUComputePipeline */ extern SDL_DECLSPEC void SDLCALL SDL_BindGPUComputeStorageBuffers( SDL_GPUComputePass *compute_pass, Uint32 first_slot, SDL_GPUBuffer *const *storage_buffers, Uint32 num_bindings); /** * Dispatches compute work. * * You must not call this function before binding a compute pipeline. * * A VERY IMPORTANT NOTE If you dispatch multiple times in a compute pass, and * the dispatches write to the same resource region as each other, there is no * guarantee of which order the writes will occur. If the write order matters, * you MUST end the compute pass and begin another one. * * \param compute_pass a compute pass handle. * \param groupcount_x number of local workgroups to dispatch in the X * dimension. * \param groupcount_y number of local workgroups to dispatch in the Y * dimension. * \param groupcount_z number of local workgroups to dispatch in the Z * dimension. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC void SDLCALL SDL_DispatchGPUCompute( SDL_GPUComputePass *compute_pass, Uint32 groupcount_x, Uint32 groupcount_y, Uint32 groupcount_z); /** * Dispatches compute work with parameters set from a buffer. * * The buffer layout should match the layout of * SDL_GPUIndirectDispatchCommand. You must not call this function before * binding a compute pipeline. * * A VERY IMPORTANT NOTE If you dispatch multiple times in a compute pass, and * the dispatches write to the same resource region as each other, there is no * guarantee of which order the writes will occur. If the write order matters, * you MUST end the compute pass and begin another one. * * \param compute_pass a compute pass handle. * \param buffer a buffer containing dispatch parameters. * \param offset the offset to start reading from the dispatch buffer. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC void SDLCALL SDL_DispatchGPUComputeIndirect( SDL_GPUComputePass *compute_pass, SDL_GPUBuffer *buffer, Uint32 offset); /** * Ends the current compute pass. * * All bound compute state on the command buffer is unset. The compute pass * handle is now invalid. * * \param compute_pass a compute pass handle. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC void SDLCALL SDL_EndGPUComputePass( SDL_GPUComputePass *compute_pass); /* TransferBuffer Data */ /** * Maps a transfer buffer into application address space. * * You must unmap the transfer buffer before encoding upload commands. The * memory is owned by the graphics driver - do NOT call SDL_free() on the * returned pointer. * * \param device a GPU context. * \param transfer_buffer a transfer buffer. * \param cycle if true, cycles the transfer buffer if it is already bound. * \returns the address of the mapped transfer buffer memory, or NULL on * failure; call SDL_GetError() for more information. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC void * SDLCALL SDL_MapGPUTransferBuffer( SDL_GPUDevice *device, SDL_GPUTransferBuffer *transfer_buffer, bool cycle); /** * Unmaps a previously mapped transfer buffer. * * \param device a GPU context. * \param transfer_buffer a previously mapped transfer buffer. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC void SDLCALL SDL_UnmapGPUTransferBuffer( SDL_GPUDevice *device, SDL_GPUTransferBuffer *transfer_buffer); /* Copy Pass */ /** * Begins a copy pass on a command buffer. * * All operations related to copying to or from buffers or textures take place * inside a copy pass. You must not begin another copy pass, or a render pass * or compute pass before ending the copy pass. * * \param command_buffer a command buffer. * \returns a copy pass handle. * * \since This function is available since SDL 3.2.0. * * \sa SDL_EndGPUCopyPass */ extern SDL_DECLSPEC SDL_GPUCopyPass * SDLCALL SDL_BeginGPUCopyPass( SDL_GPUCommandBuffer *command_buffer); /** * Uploads data from a transfer buffer to a texture. * * The upload occurs on the GPU timeline. You may assume that the upload has * finished in subsequent commands. * * You must align the data in the transfer buffer to a multiple of the texel * size of the texture format. * * \param copy_pass a copy pass handle. * \param source the source transfer buffer with image layout information. * \param destination the destination texture region. * \param cycle if true, cycles the texture if the texture is bound, otherwise * overwrites the data. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC void SDLCALL SDL_UploadToGPUTexture( SDL_GPUCopyPass *copy_pass, const SDL_GPUTextureTransferInfo *source, const SDL_GPUTextureRegion *destination, bool cycle); /** * Uploads data from a transfer buffer to a buffer. * * The upload occurs on the GPU timeline. You may assume that the upload has * finished in subsequent commands. * * \param copy_pass a copy pass handle. * \param source the source transfer buffer with offset. * \param destination the destination buffer with offset and size. * \param cycle if true, cycles the buffer if it is already bound, otherwise * overwrites the data. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC void SDLCALL SDL_UploadToGPUBuffer( SDL_GPUCopyPass *copy_pass, const SDL_GPUTransferBufferLocation *source, const SDL_GPUBufferRegion *destination, bool cycle); /** * Performs a texture-to-texture copy. * * This copy occurs on the GPU timeline. You may assume the copy has finished * in subsequent commands. * * This function does not support copying between depth and color textures. * For those, copy the texture to a buffer and then to the destination * texture. * * \param copy_pass a copy pass handle. * \param source a source texture region. * \param destination a destination texture region. * \param w the width of the region to copy. * \param h the height of the region to copy. * \param d the depth of the region to copy. * \param cycle if true, cycles the destination texture if the destination * texture is bound, otherwise overwrites the data. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC void SDLCALL SDL_CopyGPUTextureToTexture( SDL_GPUCopyPass *copy_pass, const SDL_GPUTextureLocation *source, const SDL_GPUTextureLocation *destination, Uint32 w, Uint32 h, Uint32 d, bool cycle); /** * Performs a buffer-to-buffer copy. * * This copy occurs on the GPU timeline. You may assume the copy has finished * in subsequent commands. * * \param copy_pass a copy pass handle. * \param source the buffer and offset to copy from. * \param destination the buffer and offset to copy to. * \param size the length of the buffer to copy. * \param cycle if true, cycles the destination buffer if it is already bound, * otherwise overwrites the data. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC void SDLCALL SDL_CopyGPUBufferToBuffer( SDL_GPUCopyPass *copy_pass, const SDL_GPUBufferLocation *source, const SDL_GPUBufferLocation *destination, Uint32 size, bool cycle); /** * Copies data from a texture to a transfer buffer on the GPU timeline. * * This data is not guaranteed to be copied until the command buffer fence is * signaled. * * \param copy_pass a copy pass handle. * \param source the source texture region. * \param destination the destination transfer buffer with image layout * information. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC void SDLCALL SDL_DownloadFromGPUTexture( SDL_GPUCopyPass *copy_pass, const SDL_GPUTextureRegion *source, const SDL_GPUTextureTransferInfo *destination); /** * Copies data from a buffer to a transfer buffer on the GPU timeline. * * This data is not guaranteed to be copied until the command buffer fence is * signaled. * * \param copy_pass a copy pass handle. * \param source the source buffer with offset and size. * \param destination the destination transfer buffer with offset. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC void SDLCALL SDL_DownloadFromGPUBuffer( SDL_GPUCopyPass *copy_pass, const SDL_GPUBufferRegion *source, const SDL_GPUTransferBufferLocation *destination); /** * Ends the current copy pass. * * \param copy_pass a copy pass handle. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC void SDLCALL SDL_EndGPUCopyPass( SDL_GPUCopyPass *copy_pass); /** * Generates mipmaps for the given texture. * * This function must not be called inside of any pass. * * \param command_buffer a command_buffer. * \param texture a texture with more than 1 mip level. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC void SDLCALL SDL_GenerateMipmapsForGPUTexture( SDL_GPUCommandBuffer *command_buffer, SDL_GPUTexture *texture); /** * Blits from a source texture region to a destination texture region. * * This function must not be called inside of any pass. * * \param command_buffer a command buffer. * \param info the blit info struct containing the blit parameters. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC void SDLCALL SDL_BlitGPUTexture( SDL_GPUCommandBuffer *command_buffer, const SDL_GPUBlitInfo *info); /* Submission/Presentation */ /** * Determines whether a swapchain composition is supported by the window. * * The window must be claimed before calling this function. * * \param device a GPU context. * \param window an SDL_Window. * \param swapchain_composition the swapchain composition to check. * \returns true if supported, false if unsupported. * * \since This function is available since SDL 3.2.0. * * \sa SDL_ClaimWindowForGPUDevice */ extern SDL_DECLSPEC bool SDLCALL SDL_WindowSupportsGPUSwapchainComposition( SDL_GPUDevice *device, SDL_Window *window, SDL_GPUSwapchainComposition swapchain_composition); /** * Determines whether a presentation mode is supported by the window. * * The window must be claimed before calling this function. * * \param device a GPU context. * \param window an SDL_Window. * \param present_mode the presentation mode to check. * \returns true if supported, false if unsupported. * * \since This function is available since SDL 3.2.0. * * \sa SDL_ClaimWindowForGPUDevice */ extern SDL_DECLSPEC bool SDLCALL SDL_WindowSupportsGPUPresentMode( SDL_GPUDevice *device, SDL_Window *window, SDL_GPUPresentMode present_mode); /** * Claims a window, creating a swapchain structure for it. * * This must be called before SDL_AcquireGPUSwapchainTexture is called using * the window. You should only call this function from the thread that created * the window. * * The swapchain will be created with SDL_GPU_SWAPCHAINCOMPOSITION_SDR and * SDL_GPU_PRESENTMODE_VSYNC. If you want to have different swapchain * parameters, you must call SDL_SetGPUSwapchainParameters after claiming the * window. * * \param device a GPU context. * \param window an SDL_Window. * \returns true on success, or false on failure; call SDL_GetError() for more * information. * * \threadsafety This function should only be called from the thread that * created the window. * * \since This function is available since SDL 3.2.0. * * \sa SDL_WaitAndAcquireGPUSwapchainTexture * \sa SDL_ReleaseWindowFromGPUDevice * \sa SDL_WindowSupportsGPUPresentMode * \sa SDL_WindowSupportsGPUSwapchainComposition */ extern SDL_DECLSPEC bool SDLCALL SDL_ClaimWindowForGPUDevice( SDL_GPUDevice *device, SDL_Window *window); /** * Unclaims a window, destroying its swapchain structure. * * \param device a GPU context. * \param window an SDL_Window that has been claimed. * * \since This function is available since SDL 3.2.0. * * \sa SDL_ClaimWindowForGPUDevice */ extern SDL_DECLSPEC void SDLCALL SDL_ReleaseWindowFromGPUDevice( SDL_GPUDevice *device, SDL_Window *window); /** * Changes the swapchain parameters for the given claimed window. * * This function will fail if the requested present mode or swapchain * composition are unsupported by the device. Check if the parameters are * supported via SDL_WindowSupportsGPUPresentMode / * SDL_WindowSupportsGPUSwapchainComposition prior to calling this function. * * SDL_GPU_PRESENTMODE_VSYNC with SDL_GPU_SWAPCHAINCOMPOSITION_SDR is always * supported. * * \param device a GPU context. * \param window an SDL_Window that has been claimed. * \param swapchain_composition the desired composition of the swapchain. * \param present_mode the desired present mode for the swapchain. * \returns true if successful, false on error; call SDL_GetError() for more * information. * * \since This function is available since SDL 3.2.0. * * \sa SDL_WindowSupportsGPUPresentMode * \sa SDL_WindowSupportsGPUSwapchainComposition */ extern SDL_DECLSPEC bool SDLCALL SDL_SetGPUSwapchainParameters( SDL_GPUDevice *device, SDL_Window *window, SDL_GPUSwapchainComposition swapchain_composition, SDL_GPUPresentMode present_mode); /** * Configures the maximum allowed number of frames in flight. * * The default value when the device is created is 2. This means that after * you have submitted 2 frames for presentation, if the GPU has not finished * working on the first frame, SDL_AcquireGPUSwapchainTexture() will fill the * swapchain texture pointer with NULL, and * SDL_WaitAndAcquireGPUSwapchainTexture() will block. * * Higher values increase throughput at the expense of visual latency. Lower * values decrease visual latency at the expense of throughput. * * Note that calling this function will stall and flush the command queue to * prevent synchronization issues. * * The minimum value of allowed frames in flight is 1, and the maximum is 3. * * \param device a GPU context. * \param allowed_frames_in_flight the maximum number of frames that can be * pending on the GPU. * \returns true if successful, false on error; call SDL_GetError() for more * information. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC bool SDLCALL SDL_SetGPUAllowedFramesInFlight( SDL_GPUDevice *device, Uint32 allowed_frames_in_flight); /** * Obtains the texture format of the swapchain for the given window. * * Note that this format can change if the swapchain parameters change. * * \param device a GPU context. * \param window an SDL_Window that has been claimed. * \returns the texture format of the swapchain. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC SDL_GPUTextureFormat SDLCALL SDL_GetGPUSwapchainTextureFormat( SDL_GPUDevice *device, SDL_Window *window); /** * Acquire a texture to use in presentation. * * When a swapchain texture is acquired on a command buffer, it will * automatically be submitted for presentation when the command buffer is * submitted. The swapchain texture should only be referenced by the command * buffer used to acquire it. * * This function will fill the swapchain texture handle with NULL if too many * frames are in flight. This is not an error. This NULL pointer should not be * passed back into SDL. Instead, it should be considered as an indication to * wait until the swapchain is available. * * If you use this function, it is possible to create a situation where many * command buffers are allocated while the rendering context waits for the GPU * to catch up, which will cause memory usage to grow. You should use * SDL_WaitAndAcquireGPUSwapchainTexture() unless you know what you are doing * with timing. * * The swapchain texture is managed by the implementation and must not be * freed by the user. You MUST NOT call this function from any thread other * than the one that created the window. * * \param command_buffer a command buffer. * \param window a window that has been claimed. * \param swapchain_texture a pointer filled in with a swapchain texture * handle. * \param swapchain_texture_width a pointer filled in with the swapchain * texture width, may be NULL. * \param swapchain_texture_height a pointer filled in with the swapchain * texture height, may be NULL. * \returns true on success, false on error; call SDL_GetError() for more * information. * * \threadsafety This function should only be called from the thread that * created the window. * * \since This function is available since SDL 3.2.0. * * \sa SDL_ClaimWindowForGPUDevice * \sa SDL_SubmitGPUCommandBuffer * \sa SDL_SubmitGPUCommandBufferAndAcquireFence * \sa SDL_CancelGPUCommandBuffer * \sa SDL_GetWindowSizeInPixels * \sa SDL_WaitForGPUSwapchain * \sa SDL_WaitAndAcquireGPUSwapchainTexture * \sa SDL_SetGPUAllowedFramesInFlight */ extern SDL_DECLSPEC bool SDLCALL SDL_AcquireGPUSwapchainTexture( SDL_GPUCommandBuffer *command_buffer, SDL_Window *window, SDL_GPUTexture **swapchain_texture, Uint32 *swapchain_texture_width, Uint32 *swapchain_texture_height); /** * Blocks the thread until a swapchain texture is available to be acquired. * * \param device a GPU context. * \param window a window that has been claimed. * \returns true on success, false on failure; call SDL_GetError() for more * information. * * \threadsafety This function should only be called from the thread that * created the window. * * \since This function is available since SDL 3.2.0. * * \sa SDL_AcquireGPUSwapchainTexture * \sa SDL_WaitAndAcquireGPUSwapchainTexture * \sa SDL_SetGPUAllowedFramesInFlight */ extern SDL_DECLSPEC bool SDLCALL SDL_WaitForGPUSwapchain( SDL_GPUDevice *device, SDL_Window *window); /** * Blocks the thread until a swapchain texture is available to be acquired, * and then acquires it. * * When a swapchain texture is acquired on a command buffer, it will * automatically be submitted for presentation when the command buffer is * submitted. The swapchain texture should only be referenced by the command * buffer used to acquire it. It is an error to call * SDL_CancelGPUCommandBuffer() after a swapchain texture is acquired. * * This function can fill the swapchain texture handle with NULL in certain * cases, for example if the window is minimized. This is not an error. You * should always make sure to check whether the pointer is NULL before * actually using it. * * The swapchain texture is managed by the implementation and must not be * freed by the user. You MUST NOT call this function from any thread other * than the one that created the window. * * The swapchain texture is write-only and cannot be used as a sampler or for * another reading operation. * * \param command_buffer a command buffer. * \param window a window that has been claimed. * \param swapchain_texture a pointer filled in with a swapchain texture * handle. * \param swapchain_texture_width a pointer filled in with the swapchain * texture width, may be NULL. * \param swapchain_texture_height a pointer filled in with the swapchain * texture height, may be NULL. * \returns true on success, false on error; call SDL_GetError() for more * information. * * \threadsafety This function should only be called from the thread that * created the window. * * \since This function is available since SDL 3.2.0. * * \sa SDL_SubmitGPUCommandBuffer * \sa SDL_SubmitGPUCommandBufferAndAcquireFence * \sa SDL_AcquireGPUSwapchainTexture */ extern SDL_DECLSPEC bool SDLCALL SDL_WaitAndAcquireGPUSwapchainTexture( SDL_GPUCommandBuffer *command_buffer, SDL_Window *window, SDL_GPUTexture **swapchain_texture, Uint32 *swapchain_texture_width, Uint32 *swapchain_texture_height); /** * Submits a command buffer so its commands can be processed on the GPU. * * It is invalid to use the command buffer after this is called. * * This must be called from the thread the command buffer was acquired on. * * All commands in the submission are guaranteed to begin executing before any * command in a subsequent submission begins executing. * * \param command_buffer a command buffer. * \returns true on success, false on failure; call SDL_GetError() for more * information. * * \since This function is available since SDL 3.2.0. * * \sa SDL_AcquireGPUCommandBuffer * \sa SDL_WaitAndAcquireGPUSwapchainTexture * \sa SDL_AcquireGPUSwapchainTexture * \sa SDL_SubmitGPUCommandBufferAndAcquireFence */ extern SDL_DECLSPEC bool SDLCALL SDL_SubmitGPUCommandBuffer( SDL_GPUCommandBuffer *command_buffer); /** * Submits a command buffer so its commands can be processed on the GPU, and * acquires a fence associated with the command buffer. * * You must release this fence when it is no longer needed or it will cause a * leak. It is invalid to use the command buffer after this is called. * * This must be called from the thread the command buffer was acquired on. * * All commands in the submission are guaranteed to begin executing before any * command in a subsequent submission begins executing. * * \param command_buffer a command buffer. * \returns a fence associated with the command buffer, or NULL on failure; * call SDL_GetError() for more information. * * \since This function is available since SDL 3.2.0. * * \sa SDL_AcquireGPUCommandBuffer * \sa SDL_WaitAndAcquireGPUSwapchainTexture * \sa SDL_AcquireGPUSwapchainTexture * \sa SDL_SubmitGPUCommandBuffer * \sa SDL_ReleaseGPUFence */ extern SDL_DECLSPEC SDL_GPUFence * SDLCALL SDL_SubmitGPUCommandBufferAndAcquireFence( SDL_GPUCommandBuffer *command_buffer); /** * Cancels a command buffer. * * None of the enqueued commands are executed. * * It is an error to call this function after a swapchain texture has been * acquired. * * This must be called from the thread the command buffer was acquired on. * * You must not reference the command buffer after calling this function. * * \param command_buffer a command buffer. * \returns true on success, false on error; call SDL_GetError() for more * information. * * \since This function is available since SDL 3.2.0. * * \sa SDL_WaitAndAcquireGPUSwapchainTexture * \sa SDL_AcquireGPUCommandBuffer * \sa SDL_AcquireGPUSwapchainTexture */ extern SDL_DECLSPEC bool SDLCALL SDL_CancelGPUCommandBuffer( SDL_GPUCommandBuffer *command_buffer); /** * Blocks the thread until the GPU is completely idle. * * \param device a GPU context. * \returns true on success, false on failure; call SDL_GetError() for more * information. * * \since This function is available since SDL 3.2.0. * * \sa SDL_WaitForGPUFences */ extern SDL_DECLSPEC bool SDLCALL SDL_WaitForGPUIdle( SDL_GPUDevice *device); /** * Blocks the thread until the given fences are signaled. * * \param device a GPU context. * \param wait_all if 0, wait for any fence to be signaled, if 1, wait for all * fences to be signaled. * \param fences an array of fences to wait on. * \param num_fences the number of fences in the fences array. * \returns true on success, false on failure; call SDL_GetError() for more * information. * * \since This function is available since SDL 3.2.0. * * \sa SDL_SubmitGPUCommandBufferAndAcquireFence * \sa SDL_WaitForGPUIdle */ extern SDL_DECLSPEC bool SDLCALL SDL_WaitForGPUFences( SDL_GPUDevice *device, bool wait_all, SDL_GPUFence *const *fences, Uint32 num_fences); /** * Checks the status of a fence. * * \param device a GPU context. * \param fence a fence. * \returns true if the fence is signaled, false if it is not. * * \since This function is available since SDL 3.2.0. * * \sa SDL_SubmitGPUCommandBufferAndAcquireFence */ extern SDL_DECLSPEC bool SDLCALL SDL_QueryGPUFence( SDL_GPUDevice *device, SDL_GPUFence *fence); /** * Releases a fence obtained from SDL_SubmitGPUCommandBufferAndAcquireFence. * * You must not reference the fence after calling this function. * * \param device a GPU context. * \param fence a fence. * * \since This function is available since SDL 3.2.0. * * \sa SDL_SubmitGPUCommandBufferAndAcquireFence */ extern SDL_DECLSPEC void SDLCALL SDL_ReleaseGPUFence( SDL_GPUDevice *device, SDL_GPUFence *fence); /* Format Info */ /** * Obtains the texel block size for a texture format. * * \param format the texture format you want to know the texel size of. * \returns the texel block size of the texture format. * * \since This function is available since SDL 3.2.0. * * \sa SDL_UploadToGPUTexture */ extern SDL_DECLSPEC Uint32 SDLCALL SDL_GPUTextureFormatTexelBlockSize( SDL_GPUTextureFormat format); /** * Determines whether a texture format is supported for a given type and * usage. * * \param device a GPU context. * \param format the texture format to check. * \param type the type of texture (2D, 3D, Cube). * \param usage a bitmask of all usage scenarios to check. * \returns whether the texture format is supported for this type and usage. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC bool SDLCALL SDL_GPUTextureSupportsFormat( SDL_GPUDevice *device, SDL_GPUTextureFormat format, SDL_GPUTextureType type, SDL_GPUTextureUsageFlags usage); /** * Determines if a sample count for a texture format is supported. * * \param device a GPU context. * \param format the texture format to check. * \param sample_count the sample count to check. * \returns whether the sample count is supported for this texture format. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC bool SDLCALL SDL_GPUTextureSupportsSampleCount( SDL_GPUDevice *device, SDL_GPUTextureFormat format, SDL_GPUSampleCount sample_count); /** * Calculate the size in bytes of a texture format with dimensions. * * \param format a texture format. * \param width width in pixels. * \param height height in pixels. * \param depth_or_layer_count depth for 3D textures or layer count otherwise. * \returns the size of a texture with this format and dimensions. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC Uint32 SDLCALL SDL_CalculateGPUTextureFormatSize( SDL_GPUTextureFormat format, Uint32 width, Uint32 height, Uint32 depth_or_layer_count); /** * Get the SDL pixel format corresponding to a GPU texture format. * * \param format a texture format. * \returns the corresponding pixel format, or SDL_PIXELFORMAT_UNKNOWN if * there is no corresponding pixel format. * * \since This function is available since SDL 3.4.0. */ extern SDL_DECLSPEC SDL_PixelFormat SDLCALL SDL_GetPixelFormatFromGPUTextureFormat(SDL_GPUTextureFormat format); /** * Get the GPU texture format corresponding to an SDL pixel format. * * \param format a pixel format. * \returns the corresponding GPU texture format, or * SDL_GPU_TEXTUREFORMAT_INVALID if there is no corresponding GPU * texture format. * * \since This function is available since SDL 3.4.0. */ extern SDL_DECLSPEC SDL_GPUTextureFormat SDLCALL SDL_GetGPUTextureFormatFromPixelFormat(SDL_PixelFormat format); #ifdef SDL_PLATFORM_GDK /** * Call this to suspend GPU operation on Xbox when you receive the * SDL_EVENT_DID_ENTER_BACKGROUND event. * * Do NOT call any SDL_GPU functions after calling this function! This must * also be called before calling SDL_GDKSuspendComplete. * * \param device a GPU context. * * \since This function is available since SDL 3.2.0. * * \sa SDL_AddEventWatch */ extern SDL_DECLSPEC void SDLCALL SDL_GDKSuspendGPU(SDL_GPUDevice *device); /** * Call this to resume GPU operation on Xbox when you receive the * SDL_EVENT_WILL_ENTER_FOREGROUND event. * * When resuming, this function MUST be called before calling any other * SDL_GPU functions. * * \param device a GPU context. * * \since This function is available since SDL 3.2.0. * * \sa SDL_AddEventWatch */ extern SDL_DECLSPEC void SDLCALL SDL_GDKResumeGPU(SDL_GPUDevice *device); #endif /* SDL_PLATFORM_GDK */ #ifdef __cplusplus } #endif /* __cplusplus */ #include #endif /* SDL_gpu_h_ */ ================================================ FILE: deps/include/SDL3/SDL_guid.h ================================================ /* Simple DirectMedia Layer Copyright (C) 1997-2026 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ /* WIKI CATEGORY: GUID */ /** * # CategoryGUID * * A GUID is a 128-bit value that represents something that is uniquely * identifiable by this value: "globally unique." * * SDL provides functions to convert a GUID to/from a string. */ #ifndef SDL_guid_h_ #define SDL_guid_h_ #include #include /* Set up for C function definitions, even when using C++ */ #ifdef __cplusplus extern "C" { #endif /** * An SDL_GUID is a 128-bit identifier for an input device that identifies * that device across runs of SDL programs on the same platform. * * If the device is detached and then re-attached to a different port, or if * the base system is rebooted, the device should still report the same GUID. * * GUIDs are as precise as possible but are not guaranteed to distinguish * physically distinct but equivalent devices. For example, two game * controllers from the same vendor with the same product ID and revision may * have the same GUID. * * GUIDs may be platform-dependent (i.e., the same device may report different * GUIDs on different operating systems). * * \since This struct is available since SDL 3.2.0. */ typedef struct SDL_GUID { Uint8 data[16]; } SDL_GUID; /* Function prototypes */ /** * Get an ASCII string representation for a given SDL_GUID. * * \param guid the SDL_GUID you wish to convert to string. * \param pszGUID buffer in which to write the ASCII string. * \param cbGUID the size of pszGUID, should be at least 33 bytes. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_StringToGUID */ extern SDL_DECLSPEC void SDLCALL SDL_GUIDToString(SDL_GUID guid, char *pszGUID, int cbGUID); /** * Convert a GUID string into a SDL_GUID structure. * * Performs no error checking. If this function is given a string containing * an invalid GUID, the function will silently succeed, but the GUID generated * will not be useful. * * \param pchGUID string containing an ASCII representation of a GUID. * \returns a SDL_GUID structure. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GUIDToString */ extern SDL_DECLSPEC SDL_GUID SDLCALL SDL_StringToGUID(const char *pchGUID); /* Ends C function definitions when using C++ */ #ifdef __cplusplus } #endif #include #endif /* SDL_guid_h_ */ ================================================ FILE: deps/include/SDL3/SDL_haptic.h ================================================ /* Simple DirectMedia Layer Copyright (C) 1997-2026 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ /** * # CategoryHaptic * * The SDL haptic subsystem manages haptic (force feedback) devices. * * The basic usage is as follows: * * - Initialize the subsystem (SDL_INIT_HAPTIC). * - Open a haptic device. * - SDL_OpenHaptic() to open from index. * - SDL_OpenHapticFromJoystick() to open from an existing joystick. * - Create an effect (SDL_HapticEffect). * - Upload the effect with SDL_CreateHapticEffect(). * - Run the effect with SDL_RunHapticEffect(). * - (optional) Free the effect with SDL_DestroyHapticEffect(). * - Close the haptic device with SDL_CloseHaptic(). * * Simple rumble example: * * ```c * SDL_Haptic *haptic = NULL; * * // Open the device * SDL_HapticID *haptics = SDL_GetHaptics(NULL); * if (haptics) { * haptic = SDL_OpenHaptic(haptics[0]); * SDL_free(haptics); * } * if (haptic == NULL) * return; * * // Initialize simple rumble * if (!SDL_InitHapticRumble(haptic)) * return; * * // Play effect at 50% strength for 2 seconds * if (!SDL_PlayHapticRumble(haptic, 0.5, 2000)) * return; * SDL_Delay(2000); * * // Clean up * SDL_CloseHaptic(haptic); * ``` * * Complete example: * * ```c * bool test_haptic(SDL_Joystick *joystick) * { * SDL_Haptic *haptic; * SDL_HapticEffect effect; * SDL_HapticEffectID effect_id; * * // Open the device * haptic = SDL_OpenHapticFromJoystick(joystick); * if (haptic == NULL) return false; // Most likely joystick isn't haptic * * // See if it can do sine waves * if ((SDL_GetHapticFeatures(haptic) & SDL_HAPTIC_SINE)==0) { * SDL_CloseHaptic(haptic); // No sine effect * return false; * } * * // Create the effect * SDL_memset(&effect, 0, sizeof(SDL_HapticEffect)); // 0 is safe default * effect.type = SDL_HAPTIC_SINE; * effect.periodic.direction.type = SDL_HAPTIC_POLAR; // Polar coordinates * effect.periodic.direction.dir[0] = 18000; // Force comes from south * effect.periodic.period = 1000; // 1000 ms * effect.periodic.magnitude = 20000; // 20000/32767 strength * effect.periodic.length = 5000; // 5 seconds long * effect.periodic.attack_length = 1000; // Takes 1 second to get max strength * effect.periodic.fade_length = 1000; // Takes 1 second to fade away * * // Upload the effect * effect_id = SDL_CreateHapticEffect(haptic, &effect); * * // Test the effect * SDL_RunHapticEffect(haptic, effect_id, 1); * SDL_Delay(5000); // Wait for the effect to finish * * // We destroy the effect, although closing the device also does this * SDL_DestroyHapticEffect(haptic, effect_id); * * // Close the device * SDL_CloseHaptic(haptic); * * return true; // Success * } * ``` * * Note that the SDL haptic subsystem is not thread-safe. */ #ifndef SDL_haptic_h_ #define SDL_haptic_h_ #include #include #include #include /* Set up for C function definitions, even when using C++ */ #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ /* FIXME: * * At the moment the magnitude variables are mixed between signed/unsigned, and * it is also not made clear that ALL of those variables expect a max of 0x7FFF. * * Some platforms may have higher precision than that (Linux FF, Windows XInput) * so we should fix the inconsistency in favor of higher possible precision, * adjusting for platforms that use different scales. * -flibit */ /** * The haptic structure used to identify an SDL haptic. * * \since This struct is available since SDL 3.2.0. * * \sa SDL_OpenHaptic * \sa SDL_OpenHapticFromJoystick * \sa SDL_CloseHaptic */ typedef struct SDL_Haptic SDL_Haptic; /* * Misc defines. */ /** * Used to play a device an infinite number of times. * * \since This macro is available since SDL 3.2.0. * * \sa SDL_RunHapticEffect */ #define SDL_HAPTIC_INFINITY 4294967295U /** * \name Haptic features * * Different haptic features a device can have. */ /* @{ */ /** * \name Haptic effects */ /* @{ */ /** * Type of haptic effect. */ typedef Uint16 SDL_HapticEffectType; /** * Constant effect supported. * * Constant haptic effect. * * \since This macro is available since SDL 3.2.0. * * \sa SDL_HapticCondition */ #define SDL_HAPTIC_CONSTANT (1u<<0) /** * Sine wave effect supported. * * Periodic haptic effect that simulates sine waves. * * \since This macro is available since SDL 3.2.0. * * \sa SDL_HapticPeriodic */ #define SDL_HAPTIC_SINE (1u<<1) /** * Square wave effect supported. * * Periodic haptic effect that simulates square waves. * * \since This macro is available since SDL 3.2.0. * * \sa SDL_HapticPeriodic */ #define SDL_HAPTIC_SQUARE (1u<<2) /** * Triangle wave effect supported. * * Periodic haptic effect that simulates triangular waves. * * \since This macro is available since SDL 3.2.0. * * \sa SDL_HapticPeriodic */ #define SDL_HAPTIC_TRIANGLE (1u<<3) /** * Sawtoothup wave effect supported. * * Periodic haptic effect that simulates saw tooth up waves. * * \since This macro is available since SDL 3.2.0. * * \sa SDL_HapticPeriodic */ #define SDL_HAPTIC_SAWTOOTHUP (1u<<4) /** * Sawtoothdown wave effect supported. * * Periodic haptic effect that simulates saw tooth down waves. * * \since This macro is available since SDL 3.2.0. * * \sa SDL_HapticPeriodic */ #define SDL_HAPTIC_SAWTOOTHDOWN (1u<<5) /** * Ramp effect supported. * * Ramp haptic effect. * * \since This macro is available since SDL 3.2.0. * * \sa SDL_HapticRamp */ #define SDL_HAPTIC_RAMP (1u<<6) /** * Spring effect supported - uses axes position. * * Condition haptic effect that simulates a spring. Effect is based on the * axes position. * * \since This macro is available since SDL 3.2.0. * * \sa SDL_HapticCondition */ #define SDL_HAPTIC_SPRING (1u<<7) /** * Damper effect supported - uses axes velocity. * * Condition haptic effect that simulates dampening. Effect is based on the * axes velocity. * * \since This macro is available since SDL 3.2.0. * * \sa SDL_HapticCondition */ #define SDL_HAPTIC_DAMPER (1u<<8) /** * Inertia effect supported - uses axes acceleration. * * Condition haptic effect that simulates inertia. Effect is based on the axes * acceleration. * * \since This macro is available since SDL 3.2.0. * * \sa SDL_HapticCondition */ #define SDL_HAPTIC_INERTIA (1u<<9) /** * Friction effect supported - uses axes movement. * * Condition haptic effect that simulates friction. Effect is based on the * axes movement. * * \since This macro is available since SDL 3.2.0. * * \sa SDL_HapticCondition */ #define SDL_HAPTIC_FRICTION (1u<<10) /** * Left/Right effect supported. * * Haptic effect for direct control over high/low frequency motors. * * \since This macro is available since SDL 3.2.0. * * \sa SDL_HapticLeftRight */ #define SDL_HAPTIC_LEFTRIGHT (1u<<11) /** * Reserved for future use. * * \since This macro is available since SDL 3.2.0. */ #define SDL_HAPTIC_RESERVED1 (1u<<12) /** * Reserved for future use. * * \since This macro is available since SDL 3.2.0. */ #define SDL_HAPTIC_RESERVED2 (1u<<13) /** * Reserved for future use. * * \since This macro is available since SDL 3.2.0. */ #define SDL_HAPTIC_RESERVED3 (1u<<14) /** * Custom effect is supported. * * User defined custom haptic effect. * * \since This macro is available since SDL 3.2.0. */ #define SDL_HAPTIC_CUSTOM (1u<<15) /* @} *//* Haptic effects */ /* These last few are features the device has, not effects */ /** * Device can set global gain. * * Device supports setting the global gain. * * \since This macro is available since SDL 3.2.0. * * \sa SDL_SetHapticGain */ #define SDL_HAPTIC_GAIN (1u<<16) /** * Device can set autocenter. * * Device supports setting autocenter. * * \since This macro is available since SDL 3.2.0. * * \sa SDL_SetHapticAutocenter */ #define SDL_HAPTIC_AUTOCENTER (1u<<17) /** * Device can be queried for effect status. * * Device supports querying effect status. * * \since This macro is available since SDL 3.2.0. * * \sa SDL_GetHapticEffectStatus */ #define SDL_HAPTIC_STATUS (1u<<18) /** * Device can be paused. * * Devices supports being paused. * * \since This macro is available since SDL 3.2.0. * * \sa SDL_PauseHaptic * \sa SDL_ResumeHaptic */ #define SDL_HAPTIC_PAUSE (1u<<19) /** * \name Direction encodings */ /* @{ */ /** * Type of coordinates used for haptic direction. */ typedef Uint8 SDL_HapticDirectionType; /** * Uses polar coordinates for the direction. * * \since This macro is available since SDL 3.2.0. * * \sa SDL_HapticDirection */ #define SDL_HAPTIC_POLAR 0 /** * Uses cartesian coordinates for the direction. * * \since This macro is available since SDL 3.2.0. * * \sa SDL_HapticDirection */ #define SDL_HAPTIC_CARTESIAN 1 /** * Uses spherical coordinates for the direction. * * \since This macro is available since SDL 3.2.0. * * \sa SDL_HapticDirection */ #define SDL_HAPTIC_SPHERICAL 2 /** * Use this value to play an effect on the steering wheel axis. * * This provides better compatibility across platforms and devices as SDL will * guess the correct axis. * * \since This macro is available since SDL 3.2.0. * * \sa SDL_HapticDirection */ #define SDL_HAPTIC_STEERING_AXIS 3 /* @} *//* Direction encodings */ /* @} *//* Haptic features */ /** * ID for haptic effects. * * This is -1 if the ID is invalid. * * \sa SDL_CreateHapticEffect */ typedef int SDL_HapticEffectID; /** * Structure that represents a haptic direction. * * This is the direction where the force comes from, instead of the direction * in which the force is exerted. * * Directions can be specified by: * * - SDL_HAPTIC_POLAR : Specified by polar coordinates. * - SDL_HAPTIC_CARTESIAN : Specified by cartesian coordinates. * - SDL_HAPTIC_SPHERICAL : Specified by spherical coordinates. * * Cardinal directions of the haptic device are relative to the positioning of * the device. North is considered to be away from the user. * * The following diagram represents the cardinal directions: * * ``` * .--. * |__| .-------. * |=.| |.-----.| * |--| || || * | | |'-----'| * |__|~')_____(' * [ COMPUTER ] * * * North (0,-1) * ^ * | * | * (-1,0) West <----[ HAPTIC ]----> East (1,0) * | * | * v * South (0,1) * * * [ USER ] * \|||/ * (o o) * ---ooO-(_)-Ooo--- * ``` * * If type is SDL_HAPTIC_POLAR, direction is encoded by hundredths of a degree * starting north and turning clockwise. SDL_HAPTIC_POLAR only uses the first * `dir` parameter. The cardinal directions would be: * * - North: 0 (0 degrees) * - East: 9000 (90 degrees) * - South: 18000 (180 degrees) * - West: 27000 (270 degrees) * * If type is SDL_HAPTIC_CARTESIAN, direction is encoded by three positions (X * axis, Y axis and Z axis (with 3 axes)). SDL_HAPTIC_CARTESIAN uses the first * three `dir` parameters. The cardinal directions would be: * * - North: 0,-1, 0 * - East: 1, 0, 0 * - South: 0, 1, 0 * - West: -1, 0, 0 * * The Z axis represents the height of the effect if supported, otherwise it's * unused. In cartesian encoding (1, 2) would be the same as (2, 4), you can * use any multiple you want, only the direction matters. * * If type is SDL_HAPTIC_SPHERICAL, direction is encoded by two rotations. The * first two `dir` parameters are used. The `dir` parameters are as follows * (all values are in hundredths of degrees): * * - Degrees from (1, 0) rotated towards (0, 1). * - Degrees towards (0, 0, 1) (device needs at least 3 axes). * * Example of force coming from the south with all encodings (force coming * from the south means the user will have to pull the stick to counteract): * * ```c * SDL_HapticDirection direction; * * // Cartesian directions * direction.type = SDL_HAPTIC_CARTESIAN; // Using cartesian direction encoding. * direction.dir[0] = 0; // X position * direction.dir[1] = 1; // Y position * // Assuming the device has 2 axes, we don't need to specify third parameter. * * // Polar directions * direction.type = SDL_HAPTIC_POLAR; // We'll be using polar direction encoding. * direction.dir[0] = 18000; // Polar only uses first parameter * * // Spherical coordinates * direction.type = SDL_HAPTIC_SPHERICAL; // Spherical encoding * direction.dir[0] = 9000; // Since we only have two axes we don't need more parameters. * ``` * * \since This struct is available since SDL 3.2.0. * * \sa SDL_HAPTIC_POLAR * \sa SDL_HAPTIC_CARTESIAN * \sa SDL_HAPTIC_SPHERICAL * \sa SDL_HAPTIC_STEERING_AXIS * \sa SDL_HapticEffect * \sa SDL_GetNumHapticAxes */ typedef struct SDL_HapticDirection { SDL_HapticDirectionType type; /**< The type of encoding. */ Sint32 dir[3]; /**< The encoded direction. */ } SDL_HapticDirection; /** * A structure containing a template for a Constant effect. * * This struct is exclusively for the SDL_HAPTIC_CONSTANT effect. * * A constant effect applies a constant force in the specified direction to * the joystick. * * \since This struct is available since SDL 3.2.0. * * \sa SDL_HAPTIC_CONSTANT * \sa SDL_HapticEffect */ typedef struct SDL_HapticConstant { /* Header */ SDL_HapticEffectType type; /**< SDL_HAPTIC_CONSTANT */ SDL_HapticDirection direction; /**< Direction of the effect. */ /* Replay */ Uint32 length; /**< Duration of the effect. */ Uint16 delay; /**< Delay before starting the effect. */ /* Trigger */ Uint16 button; /**< Button that triggers the effect. */ Uint16 interval; /**< How soon it can be triggered again after button. */ /* Constant */ Sint16 level; /**< Strength of the constant effect. */ /* Envelope */ Uint16 attack_length; /**< Duration of the attack. */ Uint16 attack_level; /**< Level at the start of the attack. */ Uint16 fade_length; /**< Duration of the fade. */ Uint16 fade_level; /**< Level at the end of the fade. */ } SDL_HapticConstant; /** * A structure containing a template for a Periodic effect. * * The struct handles the following effects: * * - SDL_HAPTIC_SINE * - SDL_HAPTIC_SQUARE * - SDL_HAPTIC_TRIANGLE * - SDL_HAPTIC_SAWTOOTHUP * - SDL_HAPTIC_SAWTOOTHDOWN * * A periodic effect consists in a wave-shaped effect that repeats itself over * time. The type determines the shape of the wave and the parameters * determine the dimensions of the wave. * * Phase is given by hundredth of a degree meaning that giving the phase a * value of 9000 will displace it 25% of its period. Here are sample values: * * - 0: No phase displacement. * - 9000: Displaced 25% of its period. * - 18000: Displaced 50% of its period. * - 27000: Displaced 75% of its period. * - 36000: Displaced 100% of its period, same as 0, but 0 is preferred. * * Examples: * * ``` * SDL_HAPTIC_SINE * __ __ __ __ * / \ / \ / \ / * / \__/ \__/ \__/ * * SDL_HAPTIC_SQUARE * __ __ __ __ __ * | | | | | | | | | | * | |__| |__| |__| |__| | * * SDL_HAPTIC_TRIANGLE * /\ /\ /\ /\ /\ * / \ / \ / \ / \ / * / \/ \/ \/ \/ * * SDL_HAPTIC_SAWTOOTHUP * /| /| /| /| /| /| /| * / | / | / | / | / | / | / | * / |/ |/ |/ |/ |/ |/ | * * SDL_HAPTIC_SAWTOOTHDOWN * \ |\ |\ |\ |\ |\ |\ | * \ | \ | \ | \ | \ | \ | \ | * \| \| \| \| \| \| \| * ``` * * \since This struct is available since SDL 3.2.0. * * \sa SDL_HAPTIC_SINE * \sa SDL_HAPTIC_SQUARE * \sa SDL_HAPTIC_TRIANGLE * \sa SDL_HAPTIC_SAWTOOTHUP * \sa SDL_HAPTIC_SAWTOOTHDOWN * \sa SDL_HapticEffect */ typedef struct SDL_HapticPeriodic { /* Header */ SDL_HapticEffectType type; /**< SDL_HAPTIC_SINE, SDL_HAPTIC_SQUARE SDL_HAPTIC_TRIANGLE, SDL_HAPTIC_SAWTOOTHUP or SDL_HAPTIC_SAWTOOTHDOWN */ SDL_HapticDirection direction; /**< Direction of the effect. */ /* Replay */ Uint32 length; /**< Duration of the effect. */ Uint16 delay; /**< Delay before starting the effect. */ /* Trigger */ Uint16 button; /**< Button that triggers the effect. */ Uint16 interval; /**< How soon it can be triggered again after button. */ /* Periodic */ Uint16 period; /**< Period of the wave. */ Sint16 magnitude; /**< Peak value; if negative, equivalent to 180 degrees extra phase shift. */ Sint16 offset; /**< Mean value of the wave. */ Uint16 phase; /**< Positive phase shift given by hundredth of a degree. */ /* Envelope */ Uint16 attack_length; /**< Duration of the attack. */ Uint16 attack_level; /**< Level at the start of the attack. */ Uint16 fade_length; /**< Duration of the fade. */ Uint16 fade_level; /**< Level at the end of the fade. */ } SDL_HapticPeriodic; /** * A structure containing a template for a Condition effect. * * The struct handles the following effects: * * - SDL_HAPTIC_SPRING: Effect based on axes position. * - SDL_HAPTIC_DAMPER: Effect based on axes velocity. * - SDL_HAPTIC_INERTIA: Effect based on axes acceleration. * - SDL_HAPTIC_FRICTION: Effect based on axes movement. * * Direction is handled by condition internals instead of a direction member. * The condition effect specific members have three parameters. The first * refers to the X axis, the second refers to the Y axis and the third refers * to the Z axis. The right terms refer to the positive side of the axis and * the left terms refer to the negative side of the axis. Please refer to the * SDL_HapticDirection diagram for which side is positive and which is * negative. * * \since This struct is available since SDL 3.2.0. * * \sa SDL_HapticDirection * \sa SDL_HAPTIC_SPRING * \sa SDL_HAPTIC_DAMPER * \sa SDL_HAPTIC_INERTIA * \sa SDL_HAPTIC_FRICTION * \sa SDL_HapticEffect */ typedef struct SDL_HapticCondition { /* Header */ SDL_HapticEffectType type; /**< SDL_HAPTIC_SPRING, SDL_HAPTIC_DAMPER, SDL_HAPTIC_INERTIA or SDL_HAPTIC_FRICTION */ SDL_HapticDirection direction; /**< Direction of the effect. */ /* Replay */ Uint32 length; /**< Duration of the effect. */ Uint16 delay; /**< Delay before starting the effect. */ /* Trigger */ Uint16 button; /**< Button that triggers the effect. */ Uint16 interval; /**< How soon it can be triggered again after button. */ /* Condition */ Uint16 right_sat[3]; /**< Level when joystick is to the positive side; max 0xFFFF. */ Uint16 left_sat[3]; /**< Level when joystick is to the negative side; max 0xFFFF. */ Sint16 right_coeff[3]; /**< How fast to increase the force towards the positive side. */ Sint16 left_coeff[3]; /**< How fast to increase the force towards the negative side. */ Uint16 deadband[3]; /**< Size of the dead zone; max 0xFFFF: whole axis-range when 0-centered. */ Sint16 center[3]; /**< Position of the dead zone. */ } SDL_HapticCondition; /** * A structure containing a template for a Ramp effect. * * This struct is exclusively for the SDL_HAPTIC_RAMP effect. * * The ramp effect starts at start strength and ends at end strength. It * augments in linear fashion. If you use attack and fade with a ramp the * effects get added to the ramp effect making the effect become quadratic * instead of linear. * * \since This struct is available since SDL 3.2.0. * * \sa SDL_HAPTIC_RAMP * \sa SDL_HapticEffect */ typedef struct SDL_HapticRamp { /* Header */ SDL_HapticEffectType type; /**< SDL_HAPTIC_RAMP */ SDL_HapticDirection direction; /**< Direction of the effect. */ /* Replay */ Uint32 length; /**< Duration of the effect. */ Uint16 delay; /**< Delay before starting the effect. */ /* Trigger */ Uint16 button; /**< Button that triggers the effect. */ Uint16 interval; /**< How soon it can be triggered again after button. */ /* Ramp */ Sint16 start; /**< Beginning strength level. */ Sint16 end; /**< Ending strength level. */ /* Envelope */ Uint16 attack_length; /**< Duration of the attack. */ Uint16 attack_level; /**< Level at the start of the attack. */ Uint16 fade_length; /**< Duration of the fade. */ Uint16 fade_level; /**< Level at the end of the fade. */ } SDL_HapticRamp; /** * A structure containing a template for a Left/Right effect. * * This struct is exclusively for the SDL_HAPTIC_LEFTRIGHT effect. * * The Left/Right effect is used to explicitly control the large and small * motors, commonly found in modern game controllers. The small (right) motor * is high frequency, and the large (left) motor is low frequency. * * \since This struct is available since SDL 3.2.0. * * \sa SDL_HAPTIC_LEFTRIGHT * \sa SDL_HapticEffect */ typedef struct SDL_HapticLeftRight { /* Header */ SDL_HapticEffectType type; /**< SDL_HAPTIC_LEFTRIGHT */ /* Replay */ Uint32 length; /**< Duration of the effect in milliseconds. */ /* Rumble */ Uint16 large_magnitude; /**< Control of the large controller motor. */ Uint16 small_magnitude; /**< Control of the small controller motor. */ } SDL_HapticLeftRight; /** * A structure containing a template for the SDL_HAPTIC_CUSTOM effect. * * This struct is exclusively for the SDL_HAPTIC_CUSTOM effect. * * A custom force feedback effect is much like a periodic effect, where the * application can define its exact shape. You will have to allocate the data * yourself. Data should consist of channels * samples Uint16 samples. * * If channels is one, the effect is rotated using the defined direction. * Otherwise it uses the samples in data for the different axes. * * \since This struct is available since SDL 3.2.0. * * \sa SDL_HAPTIC_CUSTOM * \sa SDL_HapticEffect */ typedef struct SDL_HapticCustom { /* Header */ SDL_HapticEffectType type; /**< SDL_HAPTIC_CUSTOM */ SDL_HapticDirection direction; /**< Direction of the effect. */ /* Replay */ Uint32 length; /**< Duration of the effect. */ Uint16 delay; /**< Delay before starting the effect. */ /* Trigger */ Uint16 button; /**< Button that triggers the effect. */ Uint16 interval; /**< How soon it can be triggered again after button. */ /* Custom */ Uint8 channels; /**< Axes to use, minimum of one. */ Uint16 period; /**< Sample periods. */ Uint16 samples; /**< Amount of samples. */ Uint16 *data; /**< Should contain channels*samples items. */ /* Envelope */ Uint16 attack_length; /**< Duration of the attack. */ Uint16 attack_level; /**< Level at the start of the attack. */ Uint16 fade_length; /**< Duration of the fade. */ Uint16 fade_level; /**< Level at the end of the fade. */ } SDL_HapticCustom; /** * The generic template for any haptic effect. * * All values max at 32767 (0x7FFF). Signed values also can be negative. Time * values unless specified otherwise are in milliseconds. * * You can also pass SDL_HAPTIC_INFINITY to length instead of a 0-32767 value. * Neither delay, interval, attack_length nor fade_length support * SDL_HAPTIC_INFINITY. Fade will also not be used since effect never ends. * * Additionally, the SDL_HAPTIC_RAMP effect does not support a duration of * SDL_HAPTIC_INFINITY. * * Button triggers may not be supported on all devices, it is advised to not * use them if possible. Buttons start at index 1 instead of index 0 like the * joystick. * * If both attack_length and fade_level are 0, the envelope is not used, * otherwise both values are used. * * Common parts: * * ```c * // Replay - All effects have this * Uint32 length; // Duration of effect (ms). * Uint16 delay; // Delay before starting effect. * * // Trigger - All effects have this * Uint16 button; // Button that triggers effect. * Uint16 interval; // How soon before effect can be triggered again. * * // Envelope - All effects except condition effects have this * Uint16 attack_length; // Duration of the attack (ms). * Uint16 attack_level; // Level at the start of the attack. * Uint16 fade_length; // Duration of the fade out (ms). * Uint16 fade_level; // Level at the end of the fade. * ``` * * Here we have an example of a constant effect evolution in time: * * ``` * Strength * ^ * | * | effect level --> _________________ * | / \ * | / \ * | / \ * | / \ * | attack_level --> | \ * | | | <--- fade_level * | * +--------------------------------------------------> Time * [--] [---] * attack_length fade_length * * [------------------][-----------------------] * delay length * ``` * * Note either the attack_level or the fade_level may be above the actual * effect level. * * \since This struct is available since SDL 3.2.0. * * \sa SDL_HapticConstant * \sa SDL_HapticPeriodic * \sa SDL_HapticCondition * \sa SDL_HapticRamp * \sa SDL_HapticLeftRight * \sa SDL_HapticCustom */ typedef union SDL_HapticEffect { /* Common for all force feedback effects */ SDL_HapticEffectType type; /**< Effect type. */ SDL_HapticConstant constant; /**< Constant effect. */ SDL_HapticPeriodic periodic; /**< Periodic effect. */ SDL_HapticCondition condition; /**< Condition effect. */ SDL_HapticRamp ramp; /**< Ramp effect. */ SDL_HapticLeftRight leftright; /**< Left/Right effect. */ SDL_HapticCustom custom; /**< Custom effect. */ } SDL_HapticEffect; /** * This is a unique ID for a haptic device for the time it is connected to the * system, and is never reused for the lifetime of the application. * * If the haptic device is disconnected and reconnected, it will get a new ID. * * The value 0 is an invalid ID. * * \since This datatype is available since SDL 3.2.0. */ typedef Uint32 SDL_HapticID; /* Function prototypes */ /** * Get a list of currently connected haptic devices. * * \param count a pointer filled in with the number of haptic devices * returned, may be NULL. * \returns a 0 terminated array of haptic device instance IDs or NULL on * failure; call SDL_GetError() for more information. This should be * freed with SDL_free() when it is no longer needed. * * \since This function is available since SDL 3.2.0. * * \sa SDL_OpenHaptic */ extern SDL_DECLSPEC SDL_HapticID * SDLCALL SDL_GetHaptics(int *count); /** * Get the implementation dependent name of a haptic device. * * This can be called before any haptic devices are opened. * * \param instance_id the haptic device instance ID. * \returns the name of the selected haptic device. If no name can be found, * this function returns NULL; call SDL_GetError() for more * information. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetHapticName * \sa SDL_OpenHaptic */ extern SDL_DECLSPEC const char * SDLCALL SDL_GetHapticNameForID(SDL_HapticID instance_id); /** * Open a haptic device for use. * * The index passed as an argument refers to the N'th haptic device on this * system. * * When opening a haptic device, its gain will be set to maximum and * autocenter will be disabled. To modify these values use SDL_SetHapticGain() * and SDL_SetHapticAutocenter(). * * \param instance_id the haptic device instance ID. * \returns the device identifier or NULL on failure; call SDL_GetError() for * more information. * * \since This function is available since SDL 3.2.0. * * \sa SDL_CloseHaptic * \sa SDL_GetHaptics * \sa SDL_OpenHapticFromJoystick * \sa SDL_OpenHapticFromMouse * \sa SDL_SetHapticAutocenter * \sa SDL_SetHapticGain */ extern SDL_DECLSPEC SDL_Haptic * SDLCALL SDL_OpenHaptic(SDL_HapticID instance_id); /** * Get the SDL_Haptic associated with an instance ID, if it has been opened. * * \param instance_id the instance ID to get the SDL_Haptic for. * \returns an SDL_Haptic on success or NULL on failure or if it hasn't been * opened yet; call SDL_GetError() for more information. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC SDL_Haptic * SDLCALL SDL_GetHapticFromID(SDL_HapticID instance_id); /** * Get the instance ID of an opened haptic device. * * \param haptic the SDL_Haptic device to query. * \returns the instance ID of the specified haptic device on success or 0 on * failure; call SDL_GetError() for more information. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC SDL_HapticID SDLCALL SDL_GetHapticID(SDL_Haptic *haptic); /** * Get the implementation dependent name of a haptic device. * * \param haptic the SDL_Haptic obtained from SDL_OpenJoystick(). * \returns the name of the selected haptic device. If no name can be found, * this function returns NULL; call SDL_GetError() for more * information. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetHapticNameForID */ extern SDL_DECLSPEC const char * SDLCALL SDL_GetHapticName(SDL_Haptic *haptic); /** * Query whether or not the current mouse has haptic capabilities. * * \returns true if the mouse is haptic or false if it isn't. * * \since This function is available since SDL 3.2.0. * * \sa SDL_OpenHapticFromMouse */ extern SDL_DECLSPEC bool SDLCALL SDL_IsMouseHaptic(void); /** * Try to open a haptic device from the current mouse. * * \returns the haptic device identifier or NULL on failure; call * SDL_GetError() for more information. * * \since This function is available since SDL 3.2.0. * * \sa SDL_CloseHaptic * \sa SDL_IsMouseHaptic */ extern SDL_DECLSPEC SDL_Haptic * SDLCALL SDL_OpenHapticFromMouse(void); /** * Query if a joystick has haptic features. * * \param joystick the SDL_Joystick to test for haptic capabilities. * \returns true if the joystick is haptic or false if it isn't. * * \since This function is available since SDL 3.2.0. * * \sa SDL_OpenHapticFromJoystick */ extern SDL_DECLSPEC bool SDLCALL SDL_IsJoystickHaptic(SDL_Joystick *joystick); /** * Open a haptic device for use from a joystick device. * * You must still close the haptic device separately. It will not be closed * with the joystick. * * When opened from a joystick you should first close the haptic device before * closing the joystick device. If not, on some implementations the haptic * device will also get unallocated and you'll be unable to use force feedback * on that device. * * \param joystick the SDL_Joystick to create a haptic device from. * \returns a valid haptic device identifier on success or NULL on failure; * call SDL_GetError() for more information. * * \since This function is available since SDL 3.2.0. * * \sa SDL_CloseHaptic * \sa SDL_IsJoystickHaptic */ extern SDL_DECLSPEC SDL_Haptic * SDLCALL SDL_OpenHapticFromJoystick(SDL_Joystick *joystick); /** * Close a haptic device previously opened with SDL_OpenHaptic(). * * \param haptic the SDL_Haptic device to close. * * \since This function is available since SDL 3.2.0. * * \sa SDL_OpenHaptic */ extern SDL_DECLSPEC void SDLCALL SDL_CloseHaptic(SDL_Haptic *haptic); /** * Get the number of effects a haptic device can store. * * On some platforms this isn't fully supported, and therefore is an * approximation. Always check to see if your created effect was actually * created and do not rely solely on SDL_GetMaxHapticEffects(). * * \param haptic the SDL_Haptic device to query. * \returns the number of effects the haptic device can store or a negative * error code on failure; call SDL_GetError() for more information. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetMaxHapticEffectsPlaying * \sa SDL_GetHapticFeatures */ extern SDL_DECLSPEC int SDLCALL SDL_GetMaxHapticEffects(SDL_Haptic *haptic); /** * Get the number of effects a haptic device can play at the same time. * * This is not supported on all platforms, but will always return a value. * * \param haptic the SDL_Haptic device to query maximum playing effects. * \returns the number of effects the haptic device can play at the same time * or -1 on failure; call SDL_GetError() for more information. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetMaxHapticEffects * \sa SDL_GetHapticFeatures */ extern SDL_DECLSPEC int SDLCALL SDL_GetMaxHapticEffectsPlaying(SDL_Haptic *haptic); /** * Get the haptic device's supported features in bitwise manner. * * \param haptic the SDL_Haptic device to query. * \returns a list of supported haptic features in bitwise manner (OR'd), or 0 * on failure; call SDL_GetError() for more information. * * \since This function is available since SDL 3.2.0. * * \sa SDL_HapticEffectSupported * \sa SDL_GetMaxHapticEffects */ extern SDL_DECLSPEC Uint32 SDLCALL SDL_GetHapticFeatures(SDL_Haptic *haptic); /** * Get the number of haptic axes the device has. * * The number of haptic axes might be useful if working with the * SDL_HapticDirection effect. * * \param haptic the SDL_Haptic device to query. * \returns the number of axes on success or -1 on failure; call * SDL_GetError() for more information. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC int SDLCALL SDL_GetNumHapticAxes(SDL_Haptic *haptic); /** * Check to see if an effect is supported by a haptic device. * * \param haptic the SDL_Haptic device to query. * \param effect the desired effect to query. * \returns true if the effect is supported or false if it isn't. * * \since This function is available since SDL 3.2.0. * * \sa SDL_CreateHapticEffect * \sa SDL_GetHapticFeatures */ extern SDL_DECLSPEC bool SDLCALL SDL_HapticEffectSupported(SDL_Haptic *haptic, const SDL_HapticEffect *effect); /** * Create a new haptic effect on a specified device. * * \param haptic an SDL_Haptic device to create the effect on. * \param effect an SDL_HapticEffect structure containing the properties of * the effect to create. * \returns the ID of the effect on success or -1 on failure; call * SDL_GetError() for more information. * * \since This function is available since SDL 3.2.0. * * \sa SDL_DestroyHapticEffect * \sa SDL_RunHapticEffect * \sa SDL_UpdateHapticEffect */ extern SDL_DECLSPEC SDL_HapticEffectID SDLCALL SDL_CreateHapticEffect(SDL_Haptic *haptic, const SDL_HapticEffect *effect); /** * Update the properties of an effect. * * Can be used dynamically, although behavior when dynamically changing * direction may be strange. Specifically the effect may re-upload itself and * start playing from the start. You also cannot change the type either when * running SDL_UpdateHapticEffect(). * * \param haptic the SDL_Haptic device that has the effect. * \param effect the identifier of the effect to update. * \param data an SDL_HapticEffect structure containing the new effect * properties to use. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \since This function is available since SDL 3.2.0. * * \sa SDL_CreateHapticEffect * \sa SDL_RunHapticEffect */ extern SDL_DECLSPEC bool SDLCALL SDL_UpdateHapticEffect(SDL_Haptic *haptic, SDL_HapticEffectID effect, const SDL_HapticEffect *data); /** * Run the haptic effect on its associated haptic device. * * To repeat the effect over and over indefinitely, set `iterations` to * `SDL_HAPTIC_INFINITY`. (Repeats the envelope - attack and fade.) To make * one instance of the effect last indefinitely (so the effect does not fade), * set the effect's `length` in its structure/union to `SDL_HAPTIC_INFINITY` * instead. * * \param haptic the SDL_Haptic device to run the effect on. * \param effect the ID of the haptic effect to run. * \param iterations the number of iterations to run the effect; use * `SDL_HAPTIC_INFINITY` to repeat forever. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetHapticEffectStatus * \sa SDL_StopHapticEffect * \sa SDL_StopHapticEffects */ extern SDL_DECLSPEC bool SDLCALL SDL_RunHapticEffect(SDL_Haptic *haptic, SDL_HapticEffectID effect, Uint32 iterations); /** * Stop the haptic effect on its associated haptic device. * * \param haptic the SDL_Haptic device to stop the effect on. * \param effect the ID of the haptic effect to stop. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \since This function is available since SDL 3.2.0. * * \sa SDL_RunHapticEffect * \sa SDL_StopHapticEffects */ extern SDL_DECLSPEC bool SDLCALL SDL_StopHapticEffect(SDL_Haptic *haptic, SDL_HapticEffectID effect); /** * Destroy a haptic effect on the device. * * This will stop the effect if it's running. Effects are automatically * destroyed when the device is closed. * * \param haptic the SDL_Haptic device to destroy the effect on. * \param effect the ID of the haptic effect to destroy. * * \since This function is available since SDL 3.2.0. * * \sa SDL_CreateHapticEffect */ extern SDL_DECLSPEC void SDLCALL SDL_DestroyHapticEffect(SDL_Haptic *haptic, SDL_HapticEffectID effect); /** * Get the status of the current effect on the specified haptic device. * * Device must support the SDL_HAPTIC_STATUS feature. * * \param haptic the SDL_Haptic device to query for the effect status on. * \param effect the ID of the haptic effect to query its status. * \returns true if it is playing, false if it isn't playing or haptic status * isn't supported. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetHapticFeatures */ extern SDL_DECLSPEC bool SDLCALL SDL_GetHapticEffectStatus(SDL_Haptic *haptic, SDL_HapticEffectID effect); /** * Set the global gain of the specified haptic device. * * Device must support the SDL_HAPTIC_GAIN feature. * * The user may specify the maximum gain by setting the environment variable * `SDL_HAPTIC_GAIN_MAX` which should be between 0 and 100. All calls to * SDL_SetHapticGain() will scale linearly using `SDL_HAPTIC_GAIN_MAX` as the * maximum. * * \param haptic the SDL_Haptic device to set the gain on. * \param gain value to set the gain to, should be between 0 and 100 (0 - * 100). * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetHapticFeatures */ extern SDL_DECLSPEC bool SDLCALL SDL_SetHapticGain(SDL_Haptic *haptic, int gain); /** * Set the global autocenter of the device. * * Autocenter should be between 0 and 100. Setting it to 0 will disable * autocentering. * * Device must support the SDL_HAPTIC_AUTOCENTER feature. * * \param haptic the SDL_Haptic device to set autocentering on. * \param autocenter value to set autocenter to (0-100). * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetHapticFeatures */ extern SDL_DECLSPEC bool SDLCALL SDL_SetHapticAutocenter(SDL_Haptic *haptic, int autocenter); /** * Pause a haptic device. * * Device must support the `SDL_HAPTIC_PAUSE` feature. Call SDL_ResumeHaptic() * to resume playback. * * Do not modify the effects nor add new ones while the device is paused. That * can cause all sorts of weird errors. * * \param haptic the SDL_Haptic device to pause. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \since This function is available since SDL 3.2.0. * * \sa SDL_ResumeHaptic */ extern SDL_DECLSPEC bool SDLCALL SDL_PauseHaptic(SDL_Haptic *haptic); /** * Resume a haptic device. * * Call to unpause after SDL_PauseHaptic(). * * \param haptic the SDL_Haptic device to unpause. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \since This function is available since SDL 3.2.0. * * \sa SDL_PauseHaptic */ extern SDL_DECLSPEC bool SDLCALL SDL_ResumeHaptic(SDL_Haptic *haptic); /** * Stop all the currently playing effects on a haptic device. * * \param haptic the SDL_Haptic device to stop. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \since This function is available since SDL 3.2.0. * * \sa SDL_RunHapticEffect * \sa SDL_StopHapticEffect */ extern SDL_DECLSPEC bool SDLCALL SDL_StopHapticEffects(SDL_Haptic *haptic); /** * Check whether rumble is supported on a haptic device. * * \param haptic haptic device to check for rumble support. * \returns true if the effect is supported or false if it isn't. * * \since This function is available since SDL 3.2.0. * * \sa SDL_InitHapticRumble */ extern SDL_DECLSPEC bool SDLCALL SDL_HapticRumbleSupported(SDL_Haptic *haptic); /** * Initialize a haptic device for simple rumble playback. * * \param haptic the haptic device to initialize for simple rumble playback. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \since This function is available since SDL 3.2.0. * * \sa SDL_PlayHapticRumble * \sa SDL_StopHapticRumble * \sa SDL_HapticRumbleSupported */ extern SDL_DECLSPEC bool SDLCALL SDL_InitHapticRumble(SDL_Haptic *haptic); /** * Run a simple rumble effect on a haptic device. * * \param haptic the haptic device to play the rumble effect on. * \param strength strength of the rumble to play as a 0-1 float value. * \param length length of the rumble to play in milliseconds. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \since This function is available since SDL 3.2.0. * * \sa SDL_InitHapticRumble * \sa SDL_StopHapticRumble */ extern SDL_DECLSPEC bool SDLCALL SDL_PlayHapticRumble(SDL_Haptic *haptic, float strength, Uint32 length); /** * Stop the simple rumble on a haptic device. * * \param haptic the haptic device to stop the rumble effect on. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \since This function is available since SDL 3.2.0. * * \sa SDL_PlayHapticRumble */ extern SDL_DECLSPEC bool SDLCALL SDL_StopHapticRumble(SDL_Haptic *haptic); /* Ends C function definitions when using C++ */ #ifdef __cplusplus } #endif #include #endif /* SDL_haptic_h_ */ ================================================ FILE: deps/include/SDL3/SDL_hidapi.h ================================================ /* Simple DirectMedia Layer Copyright (C) 1997-2026 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ /* WIKI CATEGORY: HIDAPI */ /** * # CategoryHIDAPI * * Header file for SDL HIDAPI functions. * * This is an adaptation of the original HIDAPI interface by Alan Ott, and * includes source code licensed under the following license: * * ``` * HIDAPI - Multi-Platform library for * communication with HID devices. * * Copyright 2009, Alan Ott, Signal 11 Software. * All Rights Reserved. * * This software may be used by anyone for any reason so * long as the copyright notice in the source files * remains intact. * ``` * * (Note that this license is the same as item three of SDL's zlib license, so * it adds no new requirements on the user.) * * If you would like a version of SDL without this code, you can build SDL * with SDL_HIDAPI_DISABLED defined to 1. You might want to do this for * example on iOS or tvOS to avoid a dependency on the CoreBluetooth * framework. */ #ifndef SDL_hidapi_h_ #define SDL_hidapi_h_ #include #include #include #include /* Set up for C function definitions, even when using C++ */ #ifdef __cplusplus extern "C" { #endif /** * An opaque handle representing an open HID device. * * \since This struct is available since SDL 3.2.0. */ typedef struct SDL_hid_device SDL_hid_device; /** * HID underlying bus types. * * \since This enum is available since SDL 3.2.0. */ typedef enum SDL_hid_bus_type { /** Unknown bus type */ SDL_HID_API_BUS_UNKNOWN = 0x00, /** USB bus Specifications: https://usb.org/hid */ SDL_HID_API_BUS_USB = 0x01, /** Bluetooth or Bluetooth LE bus Specifications: https://www.bluetooth.com/specifications/specs/human-interface-device-profile-1-1-1/ https://www.bluetooth.com/specifications/specs/hid-service-1-0/ https://www.bluetooth.com/specifications/specs/hid-over-gatt-profile-1-0/ */ SDL_HID_API_BUS_BLUETOOTH = 0x02, /** I2C bus Specifications: https://docs.microsoft.com/previous-versions/windows/hardware/design/dn642101(v=vs.85) */ SDL_HID_API_BUS_I2C = 0x03, /** SPI bus Specifications: https://www.microsoft.com/download/details.aspx?id=103325 */ SDL_HID_API_BUS_SPI = 0x04 } SDL_hid_bus_type; /** hidapi info structure */ /** * Information about a connected HID device * * \since This struct is available since SDL 3.2.0. */ typedef struct SDL_hid_device_info { /** Platform-specific device path */ char *path; /** Device Vendor ID */ unsigned short vendor_id; /** Device Product ID */ unsigned short product_id; /** Serial Number */ wchar_t *serial_number; /** Device Release Number in binary-coded decimal, also known as Device Version Number */ unsigned short release_number; /** Manufacturer String */ wchar_t *manufacturer_string; /** Product string */ wchar_t *product_string; /** Usage Page for this Device/Interface (Windows/Mac/hidraw only) */ unsigned short usage_page; /** Usage for this Device/Interface (Windows/Mac/hidraw only) */ unsigned short usage; /** The USB interface which this logical device represents. Valid only if the device is a USB HID device. Set to -1 in all other cases. */ int interface_number; /** Additional information about the USB interface. Valid on libusb and Android implementations. */ int interface_class; int interface_subclass; int interface_protocol; /** Underlying bus type */ SDL_hid_bus_type bus_type; /** Pointer to the next device */ struct SDL_hid_device_info *next; } SDL_hid_device_info; /** * Initialize the HIDAPI library. * * This function initializes the HIDAPI library. Calling it is not strictly * necessary, as it will be called automatically by SDL_hid_enumerate() and * any of the SDL_hid_open_*() functions if it is needed. This function should * be called at the beginning of execution however, if there is a chance of * HIDAPI handles being opened by different threads simultaneously. * * Each call to this function should have a matching call to SDL_hid_exit() * * \returns 0 on success or a negative error code on failure; call * SDL_GetError() for more information. * * \since This function is available since SDL 3.2.0. * * \sa SDL_hid_exit */ extern SDL_DECLSPEC int SDLCALL SDL_hid_init(void); /** * Finalize the HIDAPI library. * * This function frees all of the static data associated with HIDAPI. It * should be called at the end of execution to avoid memory leaks. * * \returns 0 on success or a negative error code on failure; call * SDL_GetError() for more information. * * \since This function is available since SDL 3.2.0. * * \sa SDL_hid_init */ extern SDL_DECLSPEC int SDLCALL SDL_hid_exit(void); /** * Check to see if devices may have been added or removed. * * Enumerating the HID devices is an expensive operation, so you can call this * to see if there have been any system device changes since the last call to * this function. A change in the counter returned doesn't necessarily mean * that anything has changed, but you can call SDL_hid_enumerate() to get an * updated device list. * * Calling this function for the first time may cause a thread or other system * resource to be allocated to track device change notifications. * * \returns a change counter that is incremented with each potential device * change, or 0 if device change detection isn't available. * * \since This function is available since SDL 3.2.0. * * \sa SDL_hid_enumerate */ extern SDL_DECLSPEC Uint32 SDLCALL SDL_hid_device_change_count(void); /** * Enumerate the HID Devices. * * This function returns a linked list of all the HID devices attached to the * system which match vendor_id and product_id. If `vendor_id` is set to 0 * then any vendor matches. If `product_id` is set to 0 then any product * matches. If `vendor_id` and `product_id` are both set to 0, then all HID * devices will be returned. * * By default SDL will only enumerate controllers, to reduce risk of hanging * or crashing on bad drivers, but SDL_HINT_HIDAPI_ENUMERATE_ONLY_CONTROLLERS * can be set to "0" to enumerate all HID devices. * * \param vendor_id the Vendor ID (VID) of the types of device to open, or 0 * to match any vendor. * \param product_id the Product ID (PID) of the types of device to open, or 0 * to match any product. * \returns a pointer to a linked list of type SDL_hid_device_info, containing * information about the HID devices attached to the system, or NULL * in the case of failure. Free this linked list by calling * SDL_hid_free_enumeration(). * * \since This function is available since SDL 3.2.0. * * \sa SDL_hid_device_change_count */ extern SDL_DECLSPEC SDL_hid_device_info * SDLCALL SDL_hid_enumerate(unsigned short vendor_id, unsigned short product_id); /** * Free an enumeration linked list. * * This function frees a linked list created by SDL_hid_enumerate(). * * \param devs pointer to a list of struct_device returned from * SDL_hid_enumerate(). * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC void SDLCALL SDL_hid_free_enumeration(SDL_hid_device_info *devs); /** * Open a HID device using a Vendor ID (VID), Product ID (PID) and optionally * a serial number. * * If `serial_number` is NULL, the first device with the specified VID and PID * is opened. * * \param vendor_id the Vendor ID (VID) of the device to open. * \param product_id the Product ID (PID) of the device to open. * \param serial_number the Serial Number of the device to open (Optionally * NULL). * \returns a pointer to a SDL_hid_device object on success or NULL on * failure; call SDL_GetError() for more information. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC SDL_hid_device * SDLCALL SDL_hid_open(unsigned short vendor_id, unsigned short product_id, const wchar_t *serial_number); /** * Open a HID device by its path name. * * The path name be determined by calling SDL_hid_enumerate(), or a * platform-specific path name can be used (eg: /dev/hidraw0 on Linux). * * \param path the path name of the device to open. * \returns a pointer to a SDL_hid_device object on success or NULL on * failure; call SDL_GetError() for more information. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC SDL_hid_device * SDLCALL SDL_hid_open_path(const char *path); /** * Get the properties associated with an SDL_hid_device. * * The following read-only properties are provided by SDL: * * - `SDL_PROP_HIDAPI_LIBUSB_DEVICE_HANDLE_POINTER`: the libusb_device_handle * associated with the device, if it was opened using libusb. * * \param dev a device handle returned from SDL_hid_open(). * \returns a valid property ID on success or 0 on failure; call * SDL_GetError() for more information. * * \since This function is available since SDL 3.4.0. */ extern SDL_DECLSPEC SDL_PropertiesID SDLCALL SDL_hid_get_properties(SDL_hid_device *dev); #define SDL_PROP_HIDAPI_LIBUSB_DEVICE_HANDLE_POINTER "SDL.hidapi.libusb.device.handle" /** * Write an Output report to a HID device. * * The first byte of `data` must contain the Report ID. For devices which only * support a single report, this must be set to 0x0. The remaining bytes * contain the report data. Since the Report ID is mandatory, calls to * SDL_hid_write() will always contain one more byte than the report contains. * For example, if a hid report is 16 bytes long, 17 bytes must be passed to * SDL_hid_write(), the Report ID (or 0x0, for devices with a single report), * followed by the report data (16 bytes). In this example, the length passed * in would be 17. * * SDL_hid_write() will send the data on the first OUT endpoint, if one * exists. If it does not, it will send the data through the Control Endpoint * (Endpoint 0). * * \param dev a device handle returned from SDL_hid_open(). * \param data the data to send, including the report number as the first * byte. * \param length the length in bytes of the data to send. * \returns the actual number of bytes written and -1 on on failure; call * SDL_GetError() for more information. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC int SDLCALL SDL_hid_write(SDL_hid_device *dev, const unsigned char *data, size_t length); /** * Read an Input report from a HID device with timeout. * * Input reports are returned to the host through the INTERRUPT IN endpoint. * The first byte will contain the Report number if the device uses numbered * reports. * * \param dev a device handle returned from SDL_hid_open(). * \param data a buffer to put the read data into. * \param length the number of bytes to read. For devices with multiple * reports, make sure to read an extra byte for the report * number. * \param milliseconds timeout in milliseconds or -1 for blocking wait. * \returns the actual number of bytes read and -1 on on failure; call * SDL_GetError() for more information. If no packet was available to * be read within the timeout period, this function returns 0. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC int SDLCALL SDL_hid_read_timeout(SDL_hid_device *dev, unsigned char *data, size_t length, int milliseconds); /** * Read an Input report from a HID device. * * Input reports are returned to the host through the INTERRUPT IN endpoint. * The first byte will contain the Report number if the device uses numbered * reports. * * \param dev a device handle returned from SDL_hid_open(). * \param data a buffer to put the read data into. * \param length the number of bytes to read. For devices with multiple * reports, make sure to read an extra byte for the report * number. * \returns the actual number of bytes read and -1 on failure; call * SDL_GetError() for more information. If no packet was available to * be read and the handle is in non-blocking mode, this function * returns 0. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC int SDLCALL SDL_hid_read(SDL_hid_device *dev, unsigned char *data, size_t length); /** * Set the device handle to be non-blocking. * * In non-blocking mode calls to SDL_hid_read() will return immediately with a * value of 0 if there is no data to be read. In blocking mode, SDL_hid_read() * will wait (block) until there is data to read before returning. * * Nonblocking can be turned on and off at any time. * * \param dev a device handle returned from SDL_hid_open(). * \param nonblock enable or not the nonblocking reads - 1 to enable * nonblocking - 0 to disable nonblocking. * \returns 0 on success or a negative error code on failure; call * SDL_GetError() for more information. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC int SDLCALL SDL_hid_set_nonblocking(SDL_hid_device *dev, int nonblock); /** * Send a Feature report to the device. * * Feature reports are sent over the Control endpoint as a Set_Report * transfer. The first byte of `data` must contain the Report ID. For devices * which only support a single report, this must be set to 0x0. The remaining * bytes contain the report data. Since the Report ID is mandatory, calls to * SDL_hid_send_feature_report() will always contain one more byte than the * report contains. For example, if a hid report is 16 bytes long, 17 bytes * must be passed to SDL_hid_send_feature_report(): the Report ID (or 0x0, for * devices which do not use numbered reports), followed by the report data (16 * bytes). In this example, the length passed in would be 17. * * \param dev a device handle returned from SDL_hid_open(). * \param data the data to send, including the report number as the first * byte. * \param length the length in bytes of the data to send, including the report * number. * \returns the actual number of bytes written and -1 on failure; call * SDL_GetError() for more information. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC int SDLCALL SDL_hid_send_feature_report(SDL_hid_device *dev, const unsigned char *data, size_t length); /** * Get a feature report from a HID device. * * Set the first byte of `data` to the Report ID of the report to be read. * Make sure to allow space for this extra byte in `data`. Upon return, the * first byte will still contain the Report ID, and the report data will start * in data[1]. * * \param dev a device handle returned from SDL_hid_open(). * \param data a buffer to put the read data into, including the Report ID. * Set the first byte of `data` to the Report ID of the report to * be read, or set it to zero if your device does not use numbered * reports. * \param length the number of bytes to read, including an extra byte for the * report ID. The buffer can be longer than the actual report. * \returns the number of bytes read plus one for the report ID (which is * still in the first byte), or -1 on on failure; call SDL_GetError() * for more information. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC int SDLCALL SDL_hid_get_feature_report(SDL_hid_device *dev, unsigned char *data, size_t length); /** * Get an input report from a HID device. * * Set the first byte of `data` to the Report ID of the report to be read. * Make sure to allow space for this extra byte in `data`. Upon return, the * first byte will still contain the Report ID, and the report data will start * in data[1]. * * \param dev a device handle returned from SDL_hid_open(). * \param data a buffer to put the read data into, including the Report ID. * Set the first byte of `data` to the Report ID of the report to * be read, or set it to zero if your device does not use numbered * reports. * \param length the number of bytes to read, including an extra byte for the * report ID. The buffer can be longer than the actual report. * \returns the number of bytes read plus one for the report ID (which is * still in the first byte), or -1 on on failure; call SDL_GetError() * for more information. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC int SDLCALL SDL_hid_get_input_report(SDL_hid_device *dev, unsigned char *data, size_t length); /** * Close a HID device. * * \param dev a device handle returned from SDL_hid_open(). * \returns 0 on success or a negative error code on failure; call * SDL_GetError() for more information. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC int SDLCALL SDL_hid_close(SDL_hid_device *dev); /** * Get The Manufacturer String from a HID device. * * \param dev a device handle returned from SDL_hid_open(). * \param string a wide string buffer to put the data into. * \param maxlen the length of the buffer in multiples of wchar_t. * \returns 0 on success or a negative error code on failure; call * SDL_GetError() for more information. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC int SDLCALL SDL_hid_get_manufacturer_string(SDL_hid_device *dev, wchar_t *string, size_t maxlen); /** * Get The Product String from a HID device. * * \param dev a device handle returned from SDL_hid_open(). * \param string a wide string buffer to put the data into. * \param maxlen the length of the buffer in multiples of wchar_t. * \returns 0 on success or a negative error code on failure; call * SDL_GetError() for more information. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC int SDLCALL SDL_hid_get_product_string(SDL_hid_device *dev, wchar_t *string, size_t maxlen); /** * Get The Serial Number String from a HID device. * * \param dev a device handle returned from SDL_hid_open(). * \param string a wide string buffer to put the data into. * \param maxlen the length of the buffer in multiples of wchar_t. * \returns 0 on success or a negative error code on failure; call * SDL_GetError() for more information. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC int SDLCALL SDL_hid_get_serial_number_string(SDL_hid_device *dev, wchar_t *string, size_t maxlen); /** * Get a string from a HID device, based on its string index. * * \param dev a device handle returned from SDL_hid_open(). * \param string_index the index of the string to get. * \param string a wide string buffer to put the data into. * \param maxlen the length of the buffer in multiples of wchar_t. * \returns 0 on success or a negative error code on failure; call * SDL_GetError() for more information. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC int SDLCALL SDL_hid_get_indexed_string(SDL_hid_device *dev, int string_index, wchar_t *string, size_t maxlen); /** * Get the device info from a HID device. * * \param dev a device handle returned from SDL_hid_open(). * \returns a pointer to the SDL_hid_device_info for this hid_device or NULL * on failure; call SDL_GetError() for more information. This struct * is valid until the device is closed with SDL_hid_close(). * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC SDL_hid_device_info * SDLCALL SDL_hid_get_device_info(SDL_hid_device *dev); /** * Get a report descriptor from a HID device. * * User has to provide a preallocated buffer where descriptor will be copied * to. The recommended size for a preallocated buffer is 4096 bytes. * * \param dev a device handle returned from SDL_hid_open(). * \param buf the buffer to copy descriptor into. * \param buf_size the size of the buffer in bytes. * \returns the number of bytes actually copied or -1 on failure; call * SDL_GetError() for more information. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC int SDLCALL SDL_hid_get_report_descriptor(SDL_hid_device *dev, unsigned char *buf, size_t buf_size); /** * Start or stop a BLE scan on iOS and tvOS to pair Steam Controllers. * * \param active true to start the scan, false to stop the scan. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC void SDLCALL SDL_hid_ble_scan(bool active); /* Ends C function definitions when using C++ */ #ifdef __cplusplus } #endif #include #endif /* SDL_hidapi_h_ */ ================================================ FILE: deps/include/SDL3/SDL_hints.h ================================================ /* Simple DirectMedia Layer Copyright (C) 1997-2026 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ /** * # CategoryHints * * This file contains functions to set and get configuration hints, as well as * listing each of them alphabetically. * * The convention for naming hints is SDL_HINT_X, where "SDL_X" is the * environment variable that can be used to override the default. * * In general these hints are just that - they may or may not be supported or * applicable on any given platform, but they provide a way for an application * or user to give the library a hint as to how they would like the library to * work. */ #ifndef SDL_hints_h_ #define SDL_hints_h_ #include #include #include /* Set up for C function definitions, even when using C++ */ #ifdef __cplusplus extern "C" { #endif /** * Specify the behavior of Alt+Tab while the keyboard is grabbed. * * By default, SDL emulates Alt+Tab functionality while the keyboard is * grabbed and your window is full-screen. This prevents the user from getting * stuck in your application if you've enabled keyboard grab. * * The variable can be set to the following values: * * - "0": SDL will not handle Alt+Tab. Your application is responsible for * handling Alt+Tab while the keyboard is grabbed. * - "1": SDL will minimize your window when Alt+Tab is pressed (default) * * This hint can be set anytime. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_ALLOW_ALT_TAB_WHILE_GRABBED "SDL_ALLOW_ALT_TAB_WHILE_GRABBED" /** * A variable to control whether the SDL activity is allowed to be re-created. * * If this hint is true, the activity can be recreated on demand by the OS, * and Java static data and C++ static data remain with their current values. * If this hint is false, then SDL will call exit() when you return from your * main function and the application will be terminated and then started fresh * each time. * * The variable can be set to the following values: * * - "0": The application starts fresh at each launch. (default) * - "1": The application activity can be recreated by the OS. * * This hint can be set anytime. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_ANDROID_ALLOW_RECREATE_ACTIVITY "SDL_ANDROID_ALLOW_RECREATE_ACTIVITY" /** * A variable to control whether the event loop will block itself when the app * is paused. * * The variable can be set to the following values: * * - "0": Non blocking. * - "1": Blocking. (default) * * This hint should be set before SDL is initialized. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_ANDROID_BLOCK_ON_PAUSE "SDL_ANDROID_BLOCK_ON_PAUSE" /** * A variable to control whether low latency audio should be enabled. * * Some devices have poor quality output when this is enabled, but this is * usually an improvement in audio latency. * * The variable can be set to the following values: * * - "0": Low latency audio is not enabled. * - "1": Low latency audio is enabled. (default) * * This hint should be set before SDL audio is initialized. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_ANDROID_LOW_LATENCY_AUDIO "SDL_ANDROID_LOW_LATENCY_AUDIO" /** * A variable to control whether we trap the Android back button to handle it * manually. * * This is necessary for the right mouse button to work on some Android * devices, or to be able to trap the back button for use in your code * reliably. If this hint is true, the back button will show up as an * SDL_EVENT_KEY_DOWN / SDL_EVENT_KEY_UP pair with a keycode of * SDL_SCANCODE_AC_BACK. * * The variable can be set to the following values: * * - "0": Back button will be handled as usual for system. (default) * - "1": Back button will be trapped, allowing you to handle the key press * manually. (This will also let right mouse click work on systems where the * right mouse button functions as back.) * * This hint can be set anytime. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_ANDROID_TRAP_BACK_BUTTON "SDL_ANDROID_TRAP_BACK_BUTTON" /** * A variable setting the app ID string. * * This string is used by desktop compositors to identify and group windows * together, as well as match applications with associated desktop settings * and icons. * * This will override SDL_PROP_APP_METADATA_IDENTIFIER_STRING, if set by the * application. * * This hint should be set before SDL is initialized. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_APP_ID "SDL_APP_ID" /** * A variable setting the application name. * * This hint lets you specify the application name sent to the OS when * required. For example, this will often appear in volume control applets for * audio streams, and in lists of applications which are inhibiting the * screensaver. You should use a string that describes your program ("My Game * 2: The Revenge") * * This will override SDL_PROP_APP_METADATA_NAME_STRING, if set by the * application. * * This hint should be set before SDL is initialized. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_APP_NAME "SDL_APP_NAME" /** * A variable controlling whether controllers used with the Apple TV generate * UI events. * * When UI events are generated by controller input, the app will be * backgrounded when the Apple TV remote's menu button is pressed, and when * the pause or B buttons on gamepads are pressed. * * More information about properly making use of controllers for the Apple TV * can be found here: * https://developer.apple.com/tvos/human-interface-guidelines/remote-and-controllers/ * * The variable can be set to the following values: * * - "0": Controller input does not generate UI events. (default) * - "1": Controller input generates UI events. * * This hint can be set anytime. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_APPLE_TV_CONTROLLER_UI_EVENTS "SDL_APPLE_TV_CONTROLLER_UI_EVENTS" /** * A variable controlling whether the Apple TV remote's joystick axes will * automatically match the rotation of the remote. * * The variable can be set to the following values: * * - "0": Remote orientation does not affect joystick axes. (default) * - "1": Joystick axes are based on the orientation of the remote. * * This hint can be set anytime. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_APPLE_TV_REMOTE_ALLOW_ROTATION "SDL_APPLE_TV_REMOTE_ALLOW_ROTATION" /** * Specify the default ALSA audio device name. * * This variable is a specific audio device to open when the "default" audio * device is used. * * This hint will be ignored when opening the default playback device if * SDL_HINT_AUDIO_ALSA_DEFAULT_PLAYBACK_DEVICE is set, or when opening the * default recording device if SDL_HINT_AUDIO_ALSA_DEFAULT_RECORDING_DEVICE is * set. * * This hint should be set before an audio device is opened. * * \since This hint is available since SDL 3.2.0. * * \sa SDL_HINT_AUDIO_ALSA_DEFAULT_PLAYBACK_DEVICE * \sa SDL_HINT_AUDIO_ALSA_DEFAULT_RECORDING_DEVICE */ #define SDL_HINT_AUDIO_ALSA_DEFAULT_DEVICE "SDL_AUDIO_ALSA_DEFAULT_DEVICE" /** * Specify the default ALSA audio playback device name. * * This variable is a specific audio device to open for playback, when the * "default" audio device is used. * * If this hint isn't set, SDL will check SDL_HINT_AUDIO_ALSA_DEFAULT_DEVICE * before choosing a reasonable default. * * This hint should be set before an audio device is opened. * * \since This hint is available since SDL 3.2.0. * * \sa SDL_HINT_AUDIO_ALSA_DEFAULT_RECORDING_DEVICE * \sa SDL_HINT_AUDIO_ALSA_DEFAULT_DEVICE */ #define SDL_HINT_AUDIO_ALSA_DEFAULT_PLAYBACK_DEVICE "SDL_AUDIO_ALSA_DEFAULT_PLAYBACK_DEVICE" /** * Specify the default ALSA audio recording device name. * * This variable is a specific audio device to open for recording, when the * "default" audio device is used. * * If this hint isn't set, SDL will check SDL_HINT_AUDIO_ALSA_DEFAULT_DEVICE * before choosing a reasonable default. * * This hint should be set before an audio device is opened. * * \since This hint is available since SDL 3.2.0. * * \sa SDL_HINT_AUDIO_ALSA_DEFAULT_PLAYBACK_DEVICE * \sa SDL_HINT_AUDIO_ALSA_DEFAULT_DEVICE */ #define SDL_HINT_AUDIO_ALSA_DEFAULT_RECORDING_DEVICE "SDL_AUDIO_ALSA_DEFAULT_RECORDING_DEVICE" /** * A variable controlling the audio category on iOS and macOS. * * The variable can be set to the following values: * * - "ambient": Use the AVAudioSessionCategoryAmbient audio category, will be * muted by the phone mute switch (default) * - "playback": Use the AVAudioSessionCategoryPlayback category. * * For more information, see Apple's documentation: * https://developer.apple.com/library/content/documentation/Audio/Conceptual/AudioSessionProgrammingGuide/AudioSessionCategoriesandModes/AudioSessionCategoriesandModes.html * * This hint should be set before an audio device is opened. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_AUDIO_CATEGORY "SDL_AUDIO_CATEGORY" /** * A variable controlling the default audio channel count. * * If the application doesn't specify the audio channel count when opening the * device, this hint can be used to specify a default channel count that will * be used. This defaults to "1" for recording and "2" for playback devices. * * This hint should be set before an audio device is opened. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_AUDIO_CHANNELS "SDL_AUDIO_CHANNELS" /** * Specify an application icon name for an audio device. * * Some audio backends (such as Pulseaudio and Pipewire) allow you to set an * XDG icon name for your application. Among other things, this icon might * show up in a system control panel that lets the user adjust the volume on * specific audio streams instead of using one giant master volume slider. * Note that this is unrelated to the icon used by the windowing system, which * may be set with SDL_SetWindowIcon (or via desktop file on Wayland). * * Setting this to "" or leaving it unset will have SDL use a reasonable * default, "applications-games", which is likely to be installed. See * https://specifications.freedesktop.org/icon-theme-spec/icon-theme-spec-latest.html * and * https://specifications.freedesktop.org/icon-naming-spec/icon-naming-spec-latest.html * for the relevant XDG icon specs. * * This hint should be set before an audio device is opened. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_AUDIO_DEVICE_APP_ICON_NAME "SDL_AUDIO_DEVICE_APP_ICON_NAME" /** * A variable controlling device buffer size. * * This hint is an integer > 0, that represents the size of the device's * buffer in sample frames (stereo audio data in 16-bit format is 4 bytes per * sample frame, for example). * * SDL3 generally decides this value on behalf of the app, but if for some * reason the app needs to dictate this (because they want either lower * latency or higher throughput AND ARE WILLING TO DEAL WITH what that might * require of the app), they can specify it. * * SDL will try to accommodate this value, but there is no promise you'll get * the buffer size requested. Many platforms won't honor this request at all, * or might adjust it. * * This hint should be set before an audio device is opened. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_AUDIO_DEVICE_SAMPLE_FRAMES "SDL_AUDIO_DEVICE_SAMPLE_FRAMES" /** * Specify an audio stream name for an audio device. * * Some audio backends (such as PulseAudio) allow you to describe your audio * stream. Among other things, this description might show up in a system * control panel that lets the user adjust the volume on specific audio * streams instead of using one giant master volume slider. * * This hints lets you transmit that information to the OS. The contents of * this hint are used while opening an audio device. You should use a string * that describes your what your program is playing ("audio stream" is * probably sufficient in many cases, but this could be useful for something * like "team chat" if you have a headset playing VoIP audio separately). * * Setting this to "" or leaving it unset will have SDL use a reasonable * default: "audio stream" or something similar. * * Note that while this talks about audio streams, this is an OS-level * concept, so it applies to a physical audio device in this case, and not an * SDL_AudioStream, nor an SDL logical audio device. * * This hint should be set before an audio device is opened. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_AUDIO_DEVICE_STREAM_NAME "SDL_AUDIO_DEVICE_STREAM_NAME" /** * Specify an application role for an audio device. * * Some audio backends (such as Pipewire) allow you to describe the role of * your audio stream. Among other things, this description might show up in a * system control panel or software for displaying and manipulating media * playback/recording graphs. * * This hints lets you transmit that information to the OS. The contents of * this hint are used while opening an audio device. You should use a string * that describes your what your program is playing (Game, Music, Movie, * etc...). * * Setting this to "" or leaving it unset will have SDL use a reasonable * default: "Game" or something similar. * * Note that while this talks about audio streams, this is an OS-level * concept, so it applies to a physical audio device in this case, and not an * SDL_AudioStream, nor an SDL logical audio device. * * For Windows WASAPI audio, the following roles are supported, and map to * `AUDIO_STREAM_CATEGORY`: * * - "Other" (default) * - "Communications" - Real-time communications, such as VOIP or chat * - "Game" - Game audio * - "GameChat" - Game chat audio, similar to "Communications" except that * this will not attenuate other audio streams * - "Movie" - Music or sound with dialog * - "Media" - Music or sound without dialog * * Android's AAudio target supports this hint as of SDL 3.4.4. Android does * not support the exact same options as WASAPI, but for portability, will * attempt to map these same strings to the `aaudio_usage_t` constants. For * example, "Movie" and "Media" will both map to `AAUDIO_USAGE_MEDIA`, etc. * * If your application applies its own echo cancellation, gain control, and * noise reduction it should also set SDL_HINT_AUDIO_DEVICE_RAW_STREAM. * * This hint should be set before an audio device is opened. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_AUDIO_DEVICE_STREAM_ROLE "SDL_AUDIO_DEVICE_STREAM_ROLE" /** * Specify whether this audio device should do audio processing. * * Some operating systems perform echo cancellation, gain control, and noise * reduction as needed. If your application already handles these, you can set * this hint to prevent the OS from doing additional audio processing. * * This corresponds to the WASAPI audio option `AUDCLNT_STREAMOPTIONS_RAW`. * * The variable can be set to the following values: * * - "0": audio processing can be done by the OS. (default) * - "1": audio processing is done by the application. * * This hint should be set before an audio device is opened. * * \since This hint is available since SDL 3.4.0. */ #define SDL_HINT_AUDIO_DEVICE_RAW_STREAM "SDL_AUDIO_DEVICE_RAW_STREAM" /** * Specify the input file when recording audio using the disk audio driver. * * This defaults to "sdlaudio-in.raw" * * This hint should be set before an audio device is opened. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_AUDIO_DISK_INPUT_FILE "SDL_AUDIO_DISK_INPUT_FILE" /** * Specify the output file when playing audio using the disk audio driver. * * This defaults to "sdlaudio.raw" * * This hint should be set before an audio device is opened. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_AUDIO_DISK_OUTPUT_FILE "SDL_AUDIO_DISK_OUTPUT_FILE" /** * A variable controlling the audio rate when using the disk audio driver. * * The disk audio driver normally simulates real-time for the audio rate that * was specified, but you can use this variable to adjust this rate higher or * lower down to 0. The default value is "1.0". * * This hint should be set before an audio device is opened. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_AUDIO_DISK_TIMESCALE "SDL_AUDIO_DISK_TIMESCALE" /** * A variable that specifies an audio backend to use. * * By default, SDL will try all available audio backends in a reasonable order * until it finds one that can work, but this hint allows the app or user to * force a specific driver, such as "pipewire" if, say, you are on PulseAudio * but want to try talking to the lower level instead. * * This hint should be set before SDL is initialized. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_AUDIO_DRIVER "SDL_AUDIO_DRIVER" /** * A variable controlling the audio rate when using the dummy audio driver. * * The dummy audio driver normally simulates real-time for the audio rate that * was specified, but you can use this variable to adjust this rate higher or * lower down to 0. The default value is "1.0". * * This hint should be set before an audio device is opened. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_AUDIO_DUMMY_TIMESCALE "SDL_AUDIO_DUMMY_TIMESCALE" /** * A variable controlling the default audio format. * * If the application doesn't specify the audio format when opening the * device, this hint can be used to specify a default format that will be * used. * * The variable can be set to the following values: * * - "U8": Unsigned 8-bit audio * - "S8": Signed 8-bit audio * - "S16LE": Signed 16-bit little-endian audio * - "S16BE": Signed 16-bit big-endian audio * - "S16": Signed 16-bit native-endian audio (default) * - "S32LE": Signed 32-bit little-endian audio * - "S32BE": Signed 32-bit big-endian audio * - "S32": Signed 32-bit native-endian audio * - "F32LE": Floating point little-endian audio * - "F32BE": Floating point big-endian audio * - "F32": Floating point native-endian audio * * This hint should be set before an audio device is opened. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_AUDIO_FORMAT "SDL_AUDIO_FORMAT" /** * A variable controlling the default audio frequency. * * If the application doesn't specify the audio frequency when opening the * device, this hint can be used to specify a default frequency that will be * used. This defaults to "44100". * * This hint should be set before an audio device is opened. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_AUDIO_FREQUENCY "SDL_AUDIO_FREQUENCY" /** * A variable that causes SDL to not ignore audio "monitors". * * This is currently only used by the PulseAudio driver. * * By default, SDL ignores audio devices that aren't associated with physical * hardware. Changing this hint to "1" will expose anything SDL sees that * appears to be an audio source or sink. This will add "devices" to the list * that the user probably doesn't want or need, but it can be useful in * scenarios where you want to hook up SDL to some sort of virtual device, * etc. * * The variable can be set to the following values: * * - "0": Audio monitor devices will be ignored. (default) * - "1": Audio monitor devices will show up in the device list. * * This hint should be set before SDL is initialized. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_AUDIO_INCLUDE_MONITORS "SDL_AUDIO_INCLUDE_MONITORS" /** * A variable controlling whether SDL updates joystick state when getting * input events. * * The variable can be set to the following values: * * - "0": You'll call SDL_UpdateJoysticks() manually. * - "1": SDL will automatically call SDL_UpdateJoysticks(). (default) * * This hint can be set anytime. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_AUTO_UPDATE_JOYSTICKS "SDL_AUTO_UPDATE_JOYSTICKS" /** * A variable controlling whether SDL updates sensor state when getting input * events. * * The variable can be set to the following values: * * - "0": You'll call SDL_UpdateSensors() manually. * - "1": SDL will automatically call SDL_UpdateSensors(). (default) * * This hint can be set anytime. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_AUTO_UPDATE_SENSORS "SDL_AUTO_UPDATE_SENSORS" /** * Prevent SDL from using version 4 of the bitmap header when saving BMPs. * * The bitmap header version 4 is required for proper alpha channel support * and SDL will use it when required. Should this not be desired, this hint * can force the use of the 40 byte header version which is supported * everywhere. * * The variable can be set to the following values: * * - "0": Surfaces with a colorkey or an alpha channel are saved to a 32-bit * BMP file with an alpha mask. SDL will use the bitmap header version 4 and * set the alpha mask accordingly. (default) * - "1": Surfaces with a colorkey or an alpha channel are saved to a 32-bit * BMP file without an alpha mask. The alpha channel data will be in the * file, but applications are going to ignore it. * * This hint can be set anytime. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_BMP_SAVE_LEGACY_FORMAT "SDL_BMP_SAVE_LEGACY_FORMAT" /** * A variable that decides what camera backend to use. * * By default, SDL will try all available camera backends in a reasonable * order until it finds one that can work, but this hint allows the app or * user to force a specific target, such as "directshow" if, say, you are on * Windows Media Foundations but want to try DirectShow instead. * * The default value is unset, in which case SDL will try to figure out the * best camera backend on your behalf. This hint needs to be set before * SDL_Init() is called to be useful. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_CAMERA_DRIVER "SDL_CAMERA_DRIVER" /** * A variable that limits what CPU features are available. * * By default, SDL marks all features the current CPU supports as available. * This hint allows the enabled features to be limited to a subset. * * When the hint is unset, or empty, SDL will enable all detected CPU * features. * * The variable can be set to a comma separated list containing the following * items: * * - "all" * - "altivec" * - "sse" * - "sse2" * - "sse3" * - "sse41" * - "sse42" * - "avx" * - "avx2" * - "avx512f" * - "arm-simd" * - "neon" * - "lsx" * - "lasx" * * The items can be prefixed by '+'/'-' to add/remove features. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_CPU_FEATURE_MASK "SDL_CPU_FEATURE_MASK" /** * A variable controlling whether DirectInput should be used for controllers. * * The variable can be set to the following values: * * - "0": Disable DirectInput detection. * - "1": Enable DirectInput detection. (default) * * This hint should be set before SDL is initialized. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_JOYSTICK_DIRECTINPUT "SDL_JOYSTICK_DIRECTINPUT" /** * A variable that specifies a dialog backend to use. * * By default, SDL will try all available dialog backends in a reasonable * order until it finds one that can work, but this hint allows the app or * user to force a specific target. * * If the specified target does not exist or is not available, the * dialog-related function calls will fail. * * This hint currently only applies to platforms using the generic "Unix" * dialog implementation, but may be extended to more platforms in the future. * Note that some Unix and Unix-like platforms have their own implementation, * such as macOS and Haiku. * * The variable can be set to the following values: * * - NULL: Select automatically (default, all platforms) * - "portal": Use XDG Portals through DBus (Unix only) * - "zenity": Use the Zenity program (Unix only) * * More options may be added in the future. * * This hint can be set anytime. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_FILE_DIALOG_DRIVER "SDL_FILE_DIALOG_DRIVER" /** * Override for SDL_GetDisplayUsableBounds(). * * If set, this hint will override the expected results for * SDL_GetDisplayUsableBounds() for display index 0. Generally you don't want * to do this, but this allows an embedded system to request that some of the * screen be reserved for other uses when paired with a well-behaved * application. * * The contents of this hint must be 4 comma-separated integers, the first is * the bounds x, then y, width and height, in that order. * * This hint can be set anytime. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_DISPLAY_USABLE_BOUNDS "SDL_DISPLAY_USABLE_BOUNDS" /** * Set the level of checking for invalid parameters passed to SDL functions. * * The variable can be set to the following values: * * - "1": Enable fast parameter error checking, e.g. quick NULL checks, etc. * - "2": Enable full parameter error checking, e.g. validating objects are * the correct type, etc. (default) * * This hint can be set anytime. * * \since This hint is available since SDL 3.4.0. */ #define SDL_HINT_INVALID_PARAM_CHECKS "SDL_INVALID_PARAM_CHECKS" /** * Disable giving back control to the browser automatically when running with * asyncify. * * With -s ASYNCIFY, SDL calls emscripten_sleep during operations such as * refreshing the screen or polling events. * * This hint only applies to the emscripten platform. * * The variable can be set to the following values: * * - "0": Disable emscripten_sleep calls (if you give back browser control * manually or use asyncify for other purposes). * - "1": Enable emscripten_sleep calls. (default) * * This hint can be set anytime. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_EMSCRIPTEN_ASYNCIFY "SDL_EMSCRIPTEN_ASYNCIFY" /** * Specify the CSS selector used for the "default" window/canvas. * * This hint only applies to the emscripten platform. * * This hint should be set before creating a window. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_EMSCRIPTEN_CANVAS_SELECTOR "SDL_EMSCRIPTEN_CANVAS_SELECTOR" /** * Override the binding element for keyboard inputs for Emscripten builds. * * This hint only applies to the emscripten platform. * * The variable can be one of: * * - "#window": the javascript window object * - "#document": the javascript document object * - "#screen": the javascript window.screen object * - "#canvas": the WebGL canvas element * - "#none": Don't bind anything at all * - any other string without a leading # sign applies to the element on the * page with that ID. * * This hint should be set before creating a window. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_EMSCRIPTEN_KEYBOARD_ELEMENT "SDL_EMSCRIPTEN_KEYBOARD_ELEMENT" /** * A variable that controls whether the on-screen keyboard should be shown * when text input is active. * * The variable can be set to the following values: * * - "auto": The on-screen keyboard will be shown if there is no physical * keyboard attached. (default) * - "0": Do not show the on-screen keyboard. * - "1": Show the on-screen keyboard, if available. * * This hint must be set before SDL_StartTextInput() is called * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_ENABLE_SCREEN_KEYBOARD "SDL_ENABLE_SCREEN_KEYBOARD" /** * A variable containing a list of evdev devices to use if udev is not * available. * * The list of devices is in the form: * * deviceclass:path[,deviceclass:path[,...]] * * where device class is an integer representing the SDL_UDEV_deviceclass and * path is the full path to the event device. * * This hint should be set before SDL is initialized. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_EVDEV_DEVICES "SDL_EVDEV_DEVICES" /** * A variable controlling verbosity of the logging of SDL events pushed onto * the internal queue. * * The variable can be set to the following values, from least to most * verbose: * * - "0": Don't log any events. (default) * - "1": Log most events (other than the really spammy ones). * - "2": Include mouse and finger motion events. * * This is generally meant to be used to debug SDL itself, but can be useful * for application developers that need better visibility into what is going * on in the event queue. Logged events are sent through SDL_Log(), which * means by default they appear on stdout on most platforms or maybe * OutputDebugString() on Windows, and can be funneled by the app with * SDL_SetLogOutputFunction(), etc. * * This hint can be set anytime. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_EVENT_LOGGING "SDL_EVENT_LOGGING" /** * A variable controlling whether raising the window should be done more * forcefully. * * The variable can be set to the following values: * * - "0": Honor the OS policy for raising windows. (default) * - "1": Force the window to be raised, overriding any OS policy. * * At present, this is only an issue under MS Windows, which makes it nearly * impossible to programmatically move a window to the foreground, for * "security" reasons. See http://stackoverflow.com/a/34414846 for a * discussion. * * This hint can be set anytime. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_FORCE_RAISEWINDOW "SDL_FORCE_RAISEWINDOW" /** * A variable controlling how 3D acceleration is used to accelerate the SDL * screen surface. * * SDL can try to accelerate the SDL screen surface by using streaming * textures with a 3D rendering engine. This variable controls whether and how * this is done. * * The variable can be set to the following values: * * - "0": Disable 3D acceleration * - "1": Enable 3D acceleration, using the default renderer. (default) * - "X": Enable 3D acceleration, using X where X is one of the valid * rendering drivers. (e.g. "direct3d", "opengl", etc.) * * This hint should be set before calling SDL_GetWindowSurface() * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_FRAMEBUFFER_ACCELERATION "SDL_FRAMEBUFFER_ACCELERATION" /** * A variable that lets you manually hint extra gamecontroller db entries. * * The variable should be newline delimited rows of gamecontroller config * data, see SDL_gamepad.h * * You can update mappings after SDL is initialized with * SDL_GetGamepadMappingForGUID() and SDL_AddGamepadMapping() * * This hint should be set before SDL is initialized. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_GAMECONTROLLERCONFIG "SDL_GAMECONTROLLERCONFIG" /** * A variable that lets you provide a file with extra gamecontroller db * entries. * * The file should contain lines of gamecontroller config data, see * SDL_gamepad.h * * You can update mappings after SDL is initialized with * SDL_GetGamepadMappingForGUID() and SDL_AddGamepadMapping() * * This hint should be set before SDL is initialized. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_GAMECONTROLLERCONFIG_FILE "SDL_GAMECONTROLLERCONFIG_FILE" /** * A variable that overrides the automatic controller type detection. * * The variable should be comma separated entries, in the form: VID/PID=type * * The VID and PID should be hexadecimal with exactly 4 digits, e.g. 0x00fd * * This hint affects what low level protocol is used with the HIDAPI driver. * * The variable can be set to the following values: * * - "Xbox360" * - "XboxOne" * - "PS3" * - "PS4" * - "PS5" * - "SwitchPro" * * This hint should be set before SDL is initialized. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_GAMECONTROLLERTYPE "SDL_GAMECONTROLLERTYPE" /** * A variable containing a list of devices to skip when scanning for game * controllers. * * The format of the string is a comma separated list of USB VID/PID pairs in * hexadecimal form, e.g. * * 0xAAAA/0xBBBB,0xCCCC/0xDDDD * * The variable can also take the form of "@file", in which case the named * file will be loaded and interpreted as the value of the variable. * * This hint can be set anytime. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_GAMECONTROLLER_IGNORE_DEVICES "SDL_GAMECONTROLLER_IGNORE_DEVICES" /** * If set, all devices will be skipped when scanning for game controllers * except for the ones listed in this variable. * * The format of the string is a comma separated list of USB VID/PID pairs in * hexadecimal form, e.g. * * 0xAAAA/0xBBBB,0xCCCC/0xDDDD * * The variable can also take the form of "@file", in which case the named * file will be loaded and interpreted as the value of the variable. * * This hint can be set anytime. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_GAMECONTROLLER_IGNORE_DEVICES_EXCEPT "SDL_GAMECONTROLLER_IGNORE_DEVICES_EXCEPT" /** * A variable that controls whether the device's built-in accelerometer and * gyro should be used as sensors for gamepads. * * The variable can be set to the following values: * * - "0": Sensor fusion is disabled * - "1": Sensor fusion is enabled for all controllers that lack sensors * * Or the variable can be a comma separated list of USB VID/PID pairs in * hexadecimal form, e.g. * * 0xAAAA/0xBBBB,0xCCCC/0xDDDD * * The variable can also take the form of "@file", in which case the named * file will be loaded and interpreted as the value of the variable. * * This hint should be set before a gamepad is opened. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_GAMECONTROLLER_SENSOR_FUSION "SDL_GAMECONTROLLER_SENSOR_FUSION" /** * This variable sets the default text of the TextInput window on GDK * platforms. * * This hint is available only if SDL_GDK_TEXTINPUT defined. * * This hint should be set before calling SDL_StartTextInput() * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_GDK_TEXTINPUT_DEFAULT_TEXT "SDL_GDK_TEXTINPUT_DEFAULT_TEXT" /** * This variable sets the description of the TextInput window on GDK * platforms. * * This hint is available only if SDL_GDK_TEXTINPUT defined. * * This hint should be set before calling SDL_StartTextInput() * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_GDK_TEXTINPUT_DESCRIPTION "SDL_GDK_TEXTINPUT_DESCRIPTION" /** * This variable sets the maximum input length of the TextInput window on GDK * platforms. * * The value must be a stringified integer, for example "10" to allow for up * to 10 characters of text input. * * This hint is available only if SDL_GDK_TEXTINPUT defined. * * This hint should be set before calling SDL_StartTextInput() * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_GDK_TEXTINPUT_MAX_LENGTH "SDL_GDK_TEXTINPUT_MAX_LENGTH" /** * This variable sets the input scope of the TextInput window on GDK * platforms. * * Set this hint to change the XGameUiTextEntryInputScope value that will be * passed to the window creation function. The value must be a stringified * integer, for example "0" for XGameUiTextEntryInputScope::Default. * * This hint is available only if SDL_GDK_TEXTINPUT defined. * * This hint should be set before calling SDL_StartTextInput() * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_GDK_TEXTINPUT_SCOPE "SDL_GDK_TEXTINPUT_SCOPE" /** * This variable sets the title of the TextInput window on GDK platforms. * * This hint is available only if SDL_GDK_TEXTINPUT defined. * * This hint should be set before calling SDL_StartTextInput() * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_GDK_TEXTINPUT_TITLE "SDL_GDK_TEXTINPUT_TITLE" /** * A variable to control whether HIDAPI uses libusb for device access. * * By default libusb will only be used for a few devices that require direct * USB access, and this can be controlled with * SDL_HINT_HIDAPI_LIBUSB_WHITELIST. * * The variable can be set to the following values: * * - "0": HIDAPI will not use libusb for device access. * - "1": HIDAPI will use libusb for device access if available. (default) * * This hint should be set before SDL is initialized. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_HIDAPI_LIBUSB "SDL_HIDAPI_LIBUSB" /** * A variable to control whether HIDAPI uses libusb for GameCube adapters. * * The variable can be set to the following values: * * - "0": HIDAPI will not use libusb for GameCube adapters. * - "1": HIDAPI will use libusb for GameCube adapters if available. (default) * * This hint should be set before SDL is initialized. * * \since This hint is available since SDL 3.4.0. */ #define SDL_HINT_HIDAPI_LIBUSB_GAMECUBE "SDL_HIDAPI_LIBUSB_GAMECUBE" /** * A variable to control whether HIDAPI uses libusb only for whitelisted * devices. * * By default libusb will only be used for a few devices that require direct * USB access. * * The variable can be set to the following values: * * - "0": HIDAPI will use libusb for all device access. * - "1": HIDAPI will use libusb only for whitelisted devices. (default) * * This hint should be set before SDL is initialized. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_HIDAPI_LIBUSB_WHITELIST "SDL_HIDAPI_LIBUSB_WHITELIST" /** * A variable to control whether HIDAPI uses udev for device detection. * * The variable can be set to the following values: * * - "0": HIDAPI will poll for device changes. * - "1": HIDAPI will use udev for device detection. (default) * * This hint should be set before SDL is initialized. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_HIDAPI_UDEV "SDL_HIDAPI_UDEV" /** * A variable that specifies a GPU backend to use. * * By default, SDL will try all available GPU backends in a reasonable order * until it finds one that can work, but this hint allows the app or user to * force a specific target, such as "direct3d12" if, say, your hardware * supports Vulkan but you want to try using D3D12 instead. * * This hint should be set before any GPU functions are called. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_GPU_DRIVER "SDL_GPU_DRIVER" /** * A variable to control whether SDL_hid_enumerate() enumerates all HID * devices or only controllers. * * The variable can be set to the following values: * * - "0": SDL_hid_enumerate() will enumerate all HID devices. * - "1": SDL_hid_enumerate() will only enumerate controllers. (default) * * By default SDL will only enumerate controllers, to reduce risk of hanging * or crashing on devices with bad drivers and avoiding macOS keyboard capture * permission prompts. * * This hint can be set anytime. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_HIDAPI_ENUMERATE_ONLY_CONTROLLERS "SDL_HIDAPI_ENUMERATE_ONLY_CONTROLLERS" /** * A variable containing a list of devices to ignore in SDL_hid_enumerate(). * * The format of the string is a comma separated list of USB VID/PID pairs in * hexadecimal form, e.g. * * `0xAAAA/0xBBBB,0xCCCC/0xDDDD` * * For example, to ignore the Shanwan DS3 controller and any Valve controller, * you might use the string "0x2563/0x0523,0x28de/0x0000" * * This hint can be set anytime. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_HIDAPI_IGNORE_DEVICES "SDL_HIDAPI_IGNORE_DEVICES" /** * A variable describing what IME UI elements the application can display. * * By default IME UI is handled using native components by the OS where * possible, however this can interfere with or not be visible when exclusive * fullscreen mode is used. * * The variable can be set to a comma separated list containing the following * items: * * - "none" or "0": The application can't render any IME elements, and native * UI should be used. (default) * - "composition": The application handles SDL_EVENT_TEXT_EDITING events and * can render the composition text. * - "candidates": The application handles SDL_EVENT_TEXT_EDITING_CANDIDATES * and can render the candidate list. * * This hint should be set before SDL is initialized. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_IME_IMPLEMENTED_UI "SDL_IME_IMPLEMENTED_UI" /** * A variable controlling whether the home indicator bar on iPhone X and later * should be hidden. * * The variable can be set to the following values: * * - "0": The indicator bar is not hidden. (default for windowed applications) * - "1": The indicator bar is hidden and is shown when the screen is touched * (useful for movie playback applications). * - "2": The indicator bar is dim and the first swipe makes it visible and * the second swipe performs the "home" action. (default for fullscreen * applications) * * This hint can be set anytime. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_IOS_HIDE_HOME_INDICATOR "SDL_IOS_HIDE_HOME_INDICATOR" /** * A variable that lets you enable joystick (and gamecontroller) events even * when your app is in the background. * * The variable can be set to the following values: * * - "0": Disable joystick & gamecontroller input events when the application * is in the background. (default) * - "1": Enable joystick & gamecontroller input events when the application * is in the background. * * This hint can be set anytime. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS "SDL_JOYSTICK_ALLOW_BACKGROUND_EVENTS" /** * A variable containing a list of arcade stick style controllers. * * The format of the string is a comma separated list of USB VID/PID pairs in * hexadecimal form, e.g. * * `0xAAAA/0xBBBB,0xCCCC/0xDDDD` * * The variable can also take the form of "@file", in which case the named * file will be loaded and interpreted as the value of the variable. * * This hint can be set anytime. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_JOYSTICK_ARCADESTICK_DEVICES "SDL_JOYSTICK_ARCADESTICK_DEVICES" /** * A variable containing a list of devices that are not arcade stick style * controllers. * * This will override SDL_HINT_JOYSTICK_ARCADESTICK_DEVICES and the built in * device list. * * The format of the string is a comma separated list of USB VID/PID pairs in * hexadecimal form, e.g. * * `0xAAAA/0xBBBB,0xCCCC/0xDDDD` * * The variable can also take the form of "@file", in which case the named * file will be loaded and interpreted as the value of the variable. * * This hint can be set anytime. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_JOYSTICK_ARCADESTICK_DEVICES_EXCLUDED "SDL_JOYSTICK_ARCADESTICK_DEVICES_EXCLUDED" /** * A variable containing a list of devices that should not be considered * joysticks. * * The format of the string is a comma separated list of USB VID/PID pairs in * hexadecimal form, e.g. * * `0xAAAA/0xBBBB,0xCCCC/0xDDDD` * * The variable can also take the form of "@file", in which case the named * file will be loaded and interpreted as the value of the variable. * * This hint can be set anytime. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_JOYSTICK_BLACKLIST_DEVICES "SDL_JOYSTICK_BLACKLIST_DEVICES" /** * A variable containing a list of devices that should be considered * joysticks. * * This will override SDL_HINT_JOYSTICK_BLACKLIST_DEVICES and the built in * device list. * * The format of the string is a comma separated list of USB VID/PID pairs in * hexadecimal form, e.g. * * `0xAAAA/0xBBBB,0xCCCC/0xDDDD` * * The variable can also take the form of "@file", in which case the named * file will be loaded and interpreted as the value of the variable. * * This hint can be set anytime. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_JOYSTICK_BLACKLIST_DEVICES_EXCLUDED "SDL_JOYSTICK_BLACKLIST_DEVICES_EXCLUDED" /** * A variable containing a comma separated list of devices to open as * joysticks. * * This variable is currently only used by the Linux joystick driver. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_JOYSTICK_DEVICE "SDL_JOYSTICK_DEVICE" /** * A variable controlling whether enhanced reports should be used for * controllers when using the HIDAPI driver. * * Enhanced reports allow rumble and effects on Bluetooth PlayStation * controllers and gyro on Nintendo Switch controllers, but break Windows * DirectInput for other applications that don't use SDL. * * Once enhanced reports are enabled, they can't be disabled on PlayStation * controllers without power cycling the controller. * * The variable can be set to the following values: * * - "0": enhanced reports are not enabled. * - "1": enhanced reports are enabled. (default) * - "auto": enhanced features are advertised to the application, but SDL * doesn't change the controller report mode unless the application uses * them. * * This hint can be enabled anytime. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_JOYSTICK_ENHANCED_REPORTS "SDL_JOYSTICK_ENHANCED_REPORTS" /** * A variable containing a list of flightstick style controllers. * * The format of the string is a comma separated list of USB VID/PID pairs in * hexadecimal form, e.g. * * `0xAAAA/0xBBBB,0xCCCC/0xDDDD` * * The variable can also take the form of @file, in which case the named file * will be loaded and interpreted as the value of the variable. * * This hint can be set anytime. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_JOYSTICK_FLIGHTSTICK_DEVICES "SDL_JOYSTICK_FLIGHTSTICK_DEVICES" /** * A variable containing a list of devices that are not flightstick style * controllers. * * This will override SDL_HINT_JOYSTICK_FLIGHTSTICK_DEVICES and the built in * device list. * * The format of the string is a comma separated list of USB VID/PID pairs in * hexadecimal form, e.g. * * `0xAAAA/0xBBBB,0xCCCC/0xDDDD` * * The variable can also take the form of "@file", in which case the named * file will be loaded and interpreted as the value of the variable. * * This hint can be set anytime. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_JOYSTICK_FLIGHTSTICK_DEVICES_EXCLUDED "SDL_JOYSTICK_FLIGHTSTICK_DEVICES_EXCLUDED" /** * A variable controlling whether GameInput should be used for controller * handling on Windows. * * The variable can be set to the following values: * * - "0": GameInput is not used. * - "1": GameInput is used. * * The default is "1" on GDK platforms, and "0" otherwise. * * This hint should be set before SDL is initialized. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_JOYSTICK_GAMEINPUT "SDL_JOYSTICK_GAMEINPUT" /** * A variable controlling whether GameInput should be used for handling * GIP devices that require raw report processing, but aren't supported * by HIDRAW, such as Xbox One Guitars. * * Note that this is only supported with GameInput 3 or newer. * * The variable can be set to the following values: * * - "0": GameInput is not used to handle raw GIP devices. * - "1": GameInput is used. * * The default is "1" when using GameInput 3 or newer, and is "0" otherwise. * * This hint should be set before SDL is initialized. * * \since This hint is available since SDL 3.4.4. */ #define SDL_HINT_JOYSTICK_GAMEINPUT_RAW "SDL_JOYSTICK_GAMEINPUT_RAW" /** * A variable containing a list of devices known to have a GameCube form * factor. * * The format of the string is a comma separated list of USB VID/PID pairs in * hexadecimal form, e.g. * * `0xAAAA/0xBBBB,0xCCCC/0xDDDD` * * The variable can also take the form of "@file", in which case the named * file will be loaded and interpreted as the value of the variable. * * This hint can be set anytime. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_JOYSTICK_GAMECUBE_DEVICES "SDL_JOYSTICK_GAMECUBE_DEVICES" /** * A variable containing a list of devices known not to have a GameCube form * factor. * * This will override SDL_HINT_JOYSTICK_GAMECUBE_DEVICES and the built in * device list. * * The format of the string is a comma separated list of USB VID/PID pairs in * hexadecimal form, e.g. * * `0xAAAA/0xBBBB,0xCCCC/0xDDDD` * * The variable can also take the form of "@file", in which case the named * file will be loaded and interpreted as the value of the variable. * * This hint can be set anytime. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_JOYSTICK_GAMECUBE_DEVICES_EXCLUDED "SDL_JOYSTICK_GAMECUBE_DEVICES_EXCLUDED" /** * A variable controlling whether the HIDAPI joystick drivers should be used. * * The variable can be set to the following values: * * - "0": HIDAPI drivers are not used. * - "1": HIDAPI drivers are used. (default) * * This variable is the default for all drivers, but can be overridden by the * hints for specific drivers below. * * This hint should be set before initializing joysticks and gamepads. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_JOYSTICK_HIDAPI "SDL_JOYSTICK_HIDAPI" /** * A variable controlling whether Nintendo Switch Joy-Con controllers will be * combined into a single Pro-like controller when using the HIDAPI driver. * * The variable can be set to the following values: * * - "0": Left and right Joy-Con controllers will not be combined and each * will be a mini-gamepad. * - "1": Left and right Joy-Con controllers will be combined into a single * controller. (default) * * This hint should be set before initializing joysticks and gamepads. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_JOYSTICK_HIDAPI_COMBINE_JOY_CONS "SDL_JOYSTICK_HIDAPI_COMBINE_JOY_CONS" /** * A variable controlling whether the HIDAPI driver for Nintendo GameCube * controllers should be used. * * The variable can be set to the following values: * * - "0": HIDAPI driver is not used. * - "1": HIDAPI driver is used. * * The default is the value of SDL_HINT_JOYSTICK_HIDAPI * * This hint should be set before initializing joysticks and gamepads. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_JOYSTICK_HIDAPI_GAMECUBE "SDL_JOYSTICK_HIDAPI_GAMECUBE" /** * A variable controlling whether rumble is used to implement the GameCube * controller's 3 rumble modes, Stop(0), Rumble(1), and StopHard(2). * * This is useful for applications that need full compatibility for things * like ADSR envelopes. - Stop is implemented by setting low_frequency_rumble * to 0 and high_frequency_rumble >0 - Rumble is both at any arbitrary value - * StopHard is implemented by setting both low_frequency_rumble and * high_frequency_rumble to 0 * * The variable can be set to the following values: * * - "0": Normal rumble behavior is behavior is used. (default) * - "1": Proper GameCube controller rumble behavior is used. * * This hint can be set anytime. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_JOYSTICK_HIDAPI_GAMECUBE_RUMBLE_BRAKE "SDL_JOYSTICK_HIDAPI_GAMECUBE_RUMBLE_BRAKE" /** * A variable controlling whether the HIDAPI driver for Nintendo Switch * Joy-Cons should be used. * * The variable can be set to the following values: * * - "0": HIDAPI driver is not used. * - "1": HIDAPI driver is used. * * The default is the value of SDL_HINT_JOYSTICK_HIDAPI. * * This hint should be set before initializing joysticks and gamepads. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_JOYSTICK_HIDAPI_JOY_CONS "SDL_JOYSTICK_HIDAPI_JOY_CONS" /** * A variable controlling whether the Home button LED should be turned on when * a Nintendo Switch Joy-Con controller is opened. * * The variable can be set to the following values: * * - "0": home button LED is turned off * - "1": home button LED is turned on * * By default the Home button LED state is not changed. This hint can also be * set to a floating point value between 0.0 and 1.0 which controls the * brightness of the Home button LED. * * This hint can be set anytime. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_JOYSTICK_HIDAPI_JOYCON_HOME_LED "SDL_JOYSTICK_HIDAPI_JOYCON_HOME_LED" /** * A variable controlling whether the HIDAPI driver for Amazon Luna * controllers connected via Bluetooth should be used. * * The variable can be set to the following values: * * - "0": HIDAPI driver is not used. * - "1": HIDAPI driver is used. * * The default is the value of SDL_HINT_JOYSTICK_HIDAPI. * * This hint should be set before initializing joysticks and gamepads. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_JOYSTICK_HIDAPI_LUNA "SDL_JOYSTICK_HIDAPI_LUNA" /** * A variable controlling whether the HIDAPI driver for Nintendo Online * classic controllers should be used. * * The variable can be set to the following values: * * - "0": HIDAPI driver is not used. * - "1": HIDAPI driver is used. * * The default is the value of SDL_HINT_JOYSTICK_HIDAPI. * * This hint should be set before initializing joysticks and gamepads. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_JOYSTICK_HIDAPI_NINTENDO_CLASSIC "SDL_JOYSTICK_HIDAPI_NINTENDO_CLASSIC" /** * A variable controlling whether the HIDAPI driver for PS3 controllers should * be used. * * The variable can be set to the following values: * * - "0": HIDAPI driver is not used. * - "1": HIDAPI driver is used. * * The default is the value of SDL_HINT_JOYSTICK_HIDAPI on macOS, and "0" on * other platforms. * * For official Sony driver (sixaxis.sys) use * SDL_HINT_JOYSTICK_HIDAPI_PS3_SIXAXIS_DRIVER. See * https://github.com/ViGEm/DsHidMini for an alternative driver on Windows. * * This hint should be set before initializing joysticks and gamepads. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_JOYSTICK_HIDAPI_PS3 "SDL_JOYSTICK_HIDAPI_PS3" /** * A variable controlling whether the Sony driver (sixaxis.sys) for PS3 * controllers (Sixaxis/DualShock 3) should be used. * * The variable can be set to the following values: * * - "0": Sony driver (sixaxis.sys) is not used. * - "1": Sony driver (sixaxis.sys) is used. * * The default value is 0. * * This hint should be set before initializing joysticks and gamepads. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_JOYSTICK_HIDAPI_PS3_SIXAXIS_DRIVER "SDL_JOYSTICK_HIDAPI_PS3_SIXAXIS_DRIVER" /** * A variable controlling whether the HIDAPI driver for PS4 controllers should * be used. * * The variable can be set to the following values: * * - "0": HIDAPI driver is not used. * - "1": HIDAPI driver is used. * * The default is the value of SDL_HINT_JOYSTICK_HIDAPI. * * This hint should be set before initializing joysticks and gamepads. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_JOYSTICK_HIDAPI_PS4 "SDL_JOYSTICK_HIDAPI_PS4" /** * A variable controlling the update rate of the PS4 controller over Bluetooth * when using the HIDAPI driver. * * This defaults to 4 ms, to match the behavior over USB, and to be more * friendly to other Bluetooth devices and older Bluetooth hardware on the * computer. It can be set to "1" (1000Hz), "2" (500Hz) and "4" (250Hz) * * This hint can be set anytime, but only takes effect when extended input * reports are enabled. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_JOYSTICK_HIDAPI_PS4_REPORT_INTERVAL "SDL_JOYSTICK_HIDAPI_PS4_REPORT_INTERVAL" /** * A variable controlling whether the HIDAPI driver for PS5 controllers should * be used. * * The variable can be set to the following values: * * - "0": HIDAPI driver is not used. * - "1": HIDAPI driver is used. * * The default is the value of SDL_HINT_JOYSTICK_HIDAPI. * * This hint should be set before initializing joysticks and gamepads. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_JOYSTICK_HIDAPI_PS5 "SDL_JOYSTICK_HIDAPI_PS5" /** * A variable controlling whether the player LEDs should be lit to indicate * which player is associated with a PS5 controller. * * The variable can be set to the following values: * * - "0": player LEDs are not enabled. * - "1": player LEDs are enabled. (default) * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_JOYSTICK_HIDAPI_PS5_PLAYER_LED "SDL_JOYSTICK_HIDAPI_PS5_PLAYER_LED" /** * A variable controlling whether the HIDAPI driver for NVIDIA SHIELD * controllers should be used. * * The variable can be set to the following values: * * - "0": HIDAPI driver is not used. * - "1": HIDAPI driver is used. * * The default is the value of SDL_HINT_JOYSTICK_HIDAPI. * * This hint should be set before initializing joysticks and gamepads. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_JOYSTICK_HIDAPI_SHIELD "SDL_JOYSTICK_HIDAPI_SHIELD" /** * A variable controlling whether the HIDAPI driver for Google Stadia * controllers should be used. * * The variable can be set to the following values: * * - "0": HIDAPI driver is not used. * - "1": HIDAPI driver is used. * * The default is the value of SDL_HINT_JOYSTICK_HIDAPI. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_JOYSTICK_HIDAPI_STADIA "SDL_JOYSTICK_HIDAPI_STADIA" /** * A variable controlling whether the HIDAPI driver for Bluetooth Steam * Controllers should be used. * * The variable can be set to the following values: * * - "0": HIDAPI driver is not used. (default) * - "1": HIDAPI driver is used for Steam Controllers, which requires * Bluetooth access and may prompt the user for permission on iOS and * Android. * * This hint should be set before initializing joysticks and gamepads. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_JOYSTICK_HIDAPI_STEAM "SDL_JOYSTICK_HIDAPI_STEAM" /** * A variable controlling whether the Steam button LED should be turned on * when a Steam controller is opened. * * The variable can be set to the following values: * * - "0": Steam button LED is turned off. * - "1": Steam button LED is turned on. * * By default the Steam button LED state is not changed. This hint can also be * set to a floating point value between 0.0 and 1.0 which controls the * brightness of the Steam button LED. * * This hint can be set anytime. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_JOYSTICK_HIDAPI_STEAM_HOME_LED "SDL_JOYSTICK_HIDAPI_STEAM_HOME_LED" /** * A variable controlling whether the HIDAPI driver for the Steam Deck builtin * controller should be used. * * The variable can be set to the following values: * * - "0": HIDAPI driver is not used. * - "1": HIDAPI driver is used. * * The default is the value of SDL_HINT_JOYSTICK_HIDAPI. * * This hint should be set before initializing joysticks and gamepads. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_JOYSTICK_HIDAPI_STEAMDECK "SDL_JOYSTICK_HIDAPI_STEAMDECK" /** * A variable controlling whether the HIDAPI driver for HORI licensed Steam * controllers should be used. * * The variable can be set to the following values: * * - "0": HIDAPI driver is not used. * - "1": HIDAPI driver is used. * * The default is the value of SDL_HINT_JOYSTICK_HIDAPI. * * This hint should be set before initializing joysticks and gamepads. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_JOYSTICK_HIDAPI_STEAM_HORI "SDL_JOYSTICK_HIDAPI_STEAM_HORI" /** * A variable controlling whether the HIDAPI driver for some Logitech wheels * should be used. * * The variable can be set to the following values: * * - "0": HIDAPI driver is not used. * - "1": HIDAPI driver is used. * * The default is the value of SDL_HINT_JOYSTICK_HIDAPI. * * This hint should be set before initializing joysticks and gamepads. * * \since This hint is available since SDL 3.4.0. */ #define SDL_HINT_JOYSTICK_HIDAPI_LG4FF "SDL_JOYSTICK_HIDAPI_LG4FF" /** * A variable controlling whether the HIDAPI driver for 8BitDo controllers * should be used. * * The variable can be set to the following values: * * - "0": HIDAPI driver is not used. * - "1": HIDAPI driver is used. * * The default is the value of SDL_HINT_JOYSTICK_HIDAPI. * * This hint should be set before initializing joysticks and gamepads. * * \since This hint is available since SDL 3.4.0. */ #define SDL_HINT_JOYSTICK_HIDAPI_8BITDO "SDL_JOYSTICK_HIDAPI_8BITDO" /** * A variable controlling whether the HIDAPI driver for SInput controllers * should be used. * * More info - https://github.com/HandHeldLegend/SInput-HID * * The variable can be set to the following values: * * - "0": HIDAPI driver is not used. * - "1": HIDAPI driver is used. * * The default is the value of SDL_HINT_JOYSTICK_HIDAPI. * * This hint should be set before initializing joysticks and gamepads. * * \since This hint is available since SDL 3.4.0. */ #define SDL_HINT_JOYSTICK_HIDAPI_SINPUT "SDL_JOYSTICK_HIDAPI_SINPUT" /** * A variable controlling whether the HIDAPI driver for ZUIKI controllers * should be used. * * The variable can be set to the following values: * * - "0": HIDAPI driver is not used. * - "1": HIDAPI driver is used. * * The default is the value of SDL_HINT_JOYSTICK_HIDAPI. * * This hint should be set before initializing joysticks and gamepads. * * \since This hint is available since SDL 3.4.0. */ #define SDL_HINT_JOYSTICK_HIDAPI_ZUIKI "SDL_JOYSTICK_HIDAPI_ZUIKI" /** * A variable controlling whether the HIDAPI driver for Flydigi controllers * should be used. * * The variable can be set to the following values: * * - "0": HIDAPI driver is not used. * - "1": HIDAPI driver is used. * * The default is the value of SDL_HINT_JOYSTICK_HIDAPI. * * This hint should be set before initializing joysticks and gamepads. * * \since This hint is available since SDL 3.4.0. */ #define SDL_HINT_JOYSTICK_HIDAPI_FLYDIGI "SDL_JOYSTICK_HIDAPI_FLYDIGI" /** * A variable controlling whether the HIDAPI driver for Nintendo Switch * controllers should be used. * * The variable can be set to the following values: * * - "0": HIDAPI driver is not used. * - "1": HIDAPI driver is used. * * The default is the value of SDL_HINT_JOYSTICK_HIDAPI. * * This hint should be set before initializing joysticks and gamepads. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_JOYSTICK_HIDAPI_SWITCH "SDL_JOYSTICK_HIDAPI_SWITCH" /** * A variable controlling whether the Home button LED should be turned on when * a Nintendo Switch Pro controller is opened. * * The variable can be set to the following values: * * - "0": Home button LED is turned off. * - "1": Home button LED is turned on. * * By default the Home button LED state is not changed. This hint can also be * set to a floating point value between 0.0 and 1.0 which controls the * brightness of the Home button LED. * * This hint can be set anytime. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_JOYSTICK_HIDAPI_SWITCH_HOME_LED "SDL_JOYSTICK_HIDAPI_SWITCH_HOME_LED" /** * A variable controlling whether the player LEDs should be lit to indicate * which player is associated with a Nintendo Switch controller. * * The variable can be set to the following values: * * - "0": Player LEDs are not enabled. * - "1": Player LEDs are enabled. (default) * * This hint can be set anytime. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_JOYSTICK_HIDAPI_SWITCH_PLAYER_LED "SDL_JOYSTICK_HIDAPI_SWITCH_PLAYER_LED" /** * A variable controlling whether the HIDAPI driver for Nintendo Switch 2 * controllers should be used. * * The variable can be set to the following values: * * - "0": HIDAPI driver is not used. * - "1": HIDAPI driver is used. * * The default is the value of SDL_HINT_JOYSTICK_HIDAPI. * * This hint should be set before initializing joysticks and gamepads. * * \since This hint is available since SDL 3.4.0. */ #define SDL_HINT_JOYSTICK_HIDAPI_SWITCH2 "SDL_JOYSTICK_HIDAPI_SWITCH2" /** * A variable controlling whether Nintendo Switch Joy-Con controllers will be * in vertical mode when using the HIDAPI driver. * * The variable can be set to the following values: * * - "0": Left and right Joy-Con controllers will not be in vertical mode. * (default) * - "1": Left and right Joy-Con controllers will be in vertical mode. * * This hint should be set before opening a Joy-Con controller. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_JOYSTICK_HIDAPI_VERTICAL_JOY_CONS "SDL_JOYSTICK_HIDAPI_VERTICAL_JOY_CONS" /** * A variable controlling whether the HIDAPI driver for Nintendo Wii and Wii U * controllers should be used. * * The variable can be set to the following values: * * - "0": HIDAPI driver is not used. * - "1": HIDAPI driver is used. * * This driver doesn't work with the dolphinbar, so the default is false for * now. * * This hint should be set before initializing joysticks and gamepads. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_JOYSTICK_HIDAPI_WII "SDL_JOYSTICK_HIDAPI_WII" /** * A variable controlling whether the player LEDs should be lit to indicate * which player is associated with a Wii controller. * * The variable can be set to the following values: * * - "0": Player LEDs are not enabled. * - "1": Player LEDs are enabled. (default) * * This hint can be set anytime. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_JOYSTICK_HIDAPI_WII_PLAYER_LED "SDL_JOYSTICK_HIDAPI_WII_PLAYER_LED" /** * A variable controlling whether the HIDAPI driver for XBox controllers * should be used. * * The variable can be set to the following values: * * - "0": HIDAPI driver is not used. * - "1": HIDAPI driver is used. * * The default is "0" on Windows, otherwise the value of * SDL_HINT_JOYSTICK_HIDAPI * * This hint should be set before initializing joysticks and gamepads. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_JOYSTICK_HIDAPI_XBOX "SDL_JOYSTICK_HIDAPI_XBOX" /** * A variable controlling whether the HIDAPI driver for XBox 360 controllers * should be used. * * The variable can be set to the following values: * * - "0": HIDAPI driver is not used. * - "1": HIDAPI driver is used. * * The default is the value of SDL_HINT_JOYSTICK_HIDAPI_XBOX * * This hint should be set before initializing joysticks and gamepads. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_JOYSTICK_HIDAPI_XBOX_360 "SDL_JOYSTICK_HIDAPI_XBOX_360" /** * A variable controlling whether the player LEDs should be lit to indicate * which player is associated with an Xbox 360 controller. * * The variable can be set to the following values: * * - "0": Player LEDs are not enabled. * - "1": Player LEDs are enabled. (default) * * This hint can be set anytime. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_JOYSTICK_HIDAPI_XBOX_360_PLAYER_LED "SDL_JOYSTICK_HIDAPI_XBOX_360_PLAYER_LED" /** * A variable controlling whether the HIDAPI driver for XBox 360 wireless * controllers should be used. * * The variable can be set to the following values: * * - "0": HIDAPI driver is not used. * - "1": HIDAPI driver is used. * * The default is the value of SDL_HINT_JOYSTICK_HIDAPI_XBOX_360 * * This hint should be set before initializing joysticks and gamepads. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_JOYSTICK_HIDAPI_XBOX_360_WIRELESS "SDL_JOYSTICK_HIDAPI_XBOX_360_WIRELESS" /** * A variable controlling whether the HIDAPI driver for XBox One controllers * should be used. * * The variable can be set to the following values: * * - "0": HIDAPI driver is not used. * - "1": HIDAPI driver is used. * * The default is the value of SDL_HINT_JOYSTICK_HIDAPI_XBOX. * * This hint should be set before initializing joysticks and gamepads. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_JOYSTICK_HIDAPI_XBOX_ONE "SDL_JOYSTICK_HIDAPI_XBOX_ONE" /** * A variable controlling whether the Home button LED should be turned on when * an Xbox One controller is opened. * * The variable can be set to the following values: * * - "0": Home button LED is turned off. * - "1": Home button LED is turned on. * * By default the Home button LED state is not changed. This hint can also be * set to a floating point value between 0.0 and 1.0 which controls the * brightness of the Home button LED. The default brightness is 0.4. * * This hint can be set anytime. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_JOYSTICK_HIDAPI_XBOX_ONE_HOME_LED "SDL_JOYSTICK_HIDAPI_XBOX_ONE_HOME_LED" /** * A variable controlling whether the new HIDAPI driver for wired Xbox One * (GIP) controllers should be used. * * The variable can be set to the following values: * * - "0": HIDAPI driver is not used. * - "1": HIDAPI driver is used. * * The default is the value of SDL_HINT_JOYSTICK_HIDAPI_XBOX_ONE. * * This hint should be set before initializing joysticks and gamepads. * * \since This hint is available since SDL 3.4.0. */ #define SDL_HINT_JOYSTICK_HIDAPI_GIP "SDL_JOYSTICK_HIDAPI_GIP" /** * A variable controlling whether the new HIDAPI driver for wired Xbox One * (GIP) controllers should reset the controller if it can't get the metadata * from the controller. * * The variable can be set to the following values: * * - "0": Assume this is a generic controller. * - "1": Reset the controller to get metadata. * * By default the controller is not reset. * * This hint should be set before initializing joysticks and gamepads. * * \since This hint is available since SDL 3.4.0. */ #define SDL_HINT_JOYSTICK_HIDAPI_GIP_RESET_FOR_METADATA "SDL_JOYSTICK_HIDAPI_GIP_RESET_FOR_METADATA" /** * A variable controlling whether IOKit should be used for controller * handling. * * The variable can be set to the following values: * * - "0": IOKit is not used. * - "1": IOKit is used. (default) * * This hint should be set before SDL is initialized. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_JOYSTICK_IOKIT "SDL_JOYSTICK_IOKIT" /** * A variable controlling whether to use the classic /dev/input/js* joystick * interface or the newer /dev/input/event* joystick interface on Linux. * * The variable can be set to the following values: * * - "0": Use /dev/input/event* (default) * - "1": Use /dev/input/js* * * This hint should be set before SDL is initialized. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_JOYSTICK_LINUX_CLASSIC "SDL_JOYSTICK_LINUX_CLASSIC" /** * A variable controlling whether joysticks on Linux adhere to their * HID-defined deadzones or return unfiltered values. * * The variable can be set to the following values: * * - "0": Return unfiltered joystick axis values. (default) * - "1": Return axis values with deadzones taken into account. * * This hint should be set before a controller is opened. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_JOYSTICK_LINUX_DEADZONES "SDL_JOYSTICK_LINUX_DEADZONES" /** * A variable controlling whether joysticks on Linux will always treat 'hat' * axis inputs (ABS_HAT0X - ABS_HAT3Y) as 8-way digital hats without checking * whether they may be analog. * * The variable can be set to the following values: * * - "0": Only map hat axis inputs to digital hat outputs if the input axes * appear to actually be digital. (default) * - "1": Always handle the input axes numbered ABS_HAT0X to ABS_HAT3Y as * digital hats. * * This hint should be set before a controller is opened. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_JOYSTICK_LINUX_DIGITAL_HATS "SDL_JOYSTICK_LINUX_DIGITAL_HATS" /** * A variable controlling whether digital hats on Linux will apply deadzones * to their underlying input axes or use unfiltered values. * * The variable can be set to the following values: * * - "0": Return digital hat values based on unfiltered input axis values. * - "1": Return digital hat values with deadzones on the input axes taken * into account. (default) * * This hint should be set before a controller is opened. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_JOYSTICK_LINUX_HAT_DEADZONES "SDL_JOYSTICK_LINUX_HAT_DEADZONES" /** * A variable controlling whether GCController should be used for controller * handling. * * The variable can be set to the following values: * * - "0": GCController is not used. * - "1": GCController is used. (default) * * This hint should be set before SDL is initialized. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_JOYSTICK_MFI "SDL_JOYSTICK_MFI" /** * A variable controlling whether the RAWINPUT joystick drivers should be used * for better handling XInput-capable devices. * * The variable can be set to the following values: * * - "0": RAWINPUT drivers are not used. (default) * - "1": RAWINPUT drivers are used. * * This hint should be set before SDL is initialized. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_JOYSTICK_RAWINPUT "SDL_JOYSTICK_RAWINPUT" /** * A variable controlling whether the RAWINPUT driver should pull correlated * data from XInput. * * The variable can be set to the following values: * * - "0": RAWINPUT driver will only use data from raw input APIs. * - "1": RAWINPUT driver will also pull data from XInput and * Windows.Gaming.Input, providing better trigger axes, guide button * presses, and rumble support for Xbox controllers. (default) * * This hint should be set before a gamepad is opened. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_JOYSTICK_RAWINPUT_CORRELATE_XINPUT "SDL_JOYSTICK_RAWINPUT_CORRELATE_XINPUT" /** * A variable controlling whether the ROG Chakram mice should show up as * joysticks. * * The variable can be set to the following values: * * - "0": ROG Chakram mice do not show up as joysticks. (default) * - "1": ROG Chakram mice show up as joysticks. * * This hint should be set before SDL is initialized. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_JOYSTICK_ROG_CHAKRAM "SDL_JOYSTICK_ROG_CHAKRAM" /** * A variable controlling whether a separate thread should be used for * handling joystick detection and raw input messages on Windows. * * The variable can be set to the following values: * * - "0": A separate thread is not used. * - "1": A separate thread is used for handling raw input messages. (default) * * This hint should be set before SDL is initialized. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_JOYSTICK_THREAD "SDL_JOYSTICK_THREAD" /** * A variable containing a list of throttle style controllers. * * The format of the string is a comma separated list of USB VID/PID pairs in * hexadecimal form, e.g. * * `0xAAAA/0xBBBB,0xCCCC/0xDDDD` * * The variable can also take the form of "@file", in which case the named * file will be loaded and interpreted as the value of the variable. * * This hint can be set anytime. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_JOYSTICK_THROTTLE_DEVICES "SDL_JOYSTICK_THROTTLE_DEVICES" /** * A variable containing a list of devices that are not throttle style * controllers. * * This will override SDL_HINT_JOYSTICK_THROTTLE_DEVICES and the built in * device list. * * The format of the string is a comma separated list of USB VID/PID pairs in * hexadecimal form, e.g. * * `0xAAAA/0xBBBB,0xCCCC/0xDDDD` * * The variable can also take the form of "@file", in which case the named * file will be loaded and interpreted as the value of the variable. * * This hint can be set anytime. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_JOYSTICK_THROTTLE_DEVICES_EXCLUDED "SDL_JOYSTICK_THROTTLE_DEVICES_EXCLUDED" /** * A variable controlling whether Windows.Gaming.Input should be used for * controller handling. * * The variable can be set to the following values: * * - "0": WGI is not used. (default) * - "1": WGI is used. * * This hint should be set before SDL is initialized. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_JOYSTICK_WGI "SDL_JOYSTICK_WGI" /** * A variable containing a list of wheel style controllers. * * The format of the string is a comma separated list of USB VID/PID pairs in * hexadecimal form, e.g. * * `0xAAAA/0xBBBB,0xCCCC/0xDDDD` * * The variable can also take the form of "@file", in which case the named * file will be loaded and interpreted as the value of the variable. * * This hint can be set anytime. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_JOYSTICK_WHEEL_DEVICES "SDL_JOYSTICK_WHEEL_DEVICES" /** * A variable containing a list of devices that are not wheel style * controllers. * * This will override SDL_HINT_JOYSTICK_WHEEL_DEVICES and the built in device * list. * * The format of the string is a comma separated list of USB VID/PID pairs in * hexadecimal form, e.g. * * `0xAAAA/0xBBBB,0xCCCC/0xDDDD` * * The variable can also take the form of "@file", in which case the named * file will be loaded and interpreted as the value of the variable. * * This hint can be set anytime. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_JOYSTICK_WHEEL_DEVICES_EXCLUDED "SDL_JOYSTICK_WHEEL_DEVICES_EXCLUDED" /** * A variable containing a list of devices known to have all axes centered at * zero. * * The format of the string is a comma separated list of USB VID/PID pairs in * hexadecimal form, e.g. * * `0xAAAA/0xBBBB,0xCCCC/0xDDDD` * * The variable can also take the form of "@file", in which case the named * file will be loaded and interpreted as the value of the variable. * * This hint should be set before a controller is opened. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_JOYSTICK_ZERO_CENTERED_DEVICES "SDL_JOYSTICK_ZERO_CENTERED_DEVICES" /** * A variable containing a list of devices and their desired number of haptic * (force feedback) enabled axis. * * The format of the string is a comma separated list of USB VID/PID pairs in * hexadecimal form plus the number of desired axes, e.g. * * `0xAAAA/0xBBBB/1,0xCCCC/0xDDDD/3` * * This hint supports a "wildcard" device that will set the number of haptic * axes on all initialized haptic devices which were not defined explicitly in * this hint. * * `0xFFFF/0xFFFF/1` * * This hint should be set before a controller is opened. The number of haptic * axes won't exceed the number of real axes found on the device. * * \since This hint is available since SDL 3.2.5. */ #define SDL_HINT_JOYSTICK_HAPTIC_AXES "SDL_JOYSTICK_HAPTIC_AXES" /** * A variable that controls keycode representation in keyboard events. * * This variable is a comma separated set of options for translating keycodes * in events: * * - "none": Keycode options are cleared, this overrides other options. * - "hide_numpad": The numpad keysyms will be translated into their * non-numpad versions based on the current NumLock state. For example, * SDLK_KP_4 would become SDLK_4 if SDL_KMOD_NUM is set in the event * modifiers, and SDLK_LEFT if it is unset. * - "french_numbers": The number row on French keyboards is inverted, so * pressing the 1 key would yield the keycode SDLK_1, or '1', instead of * SDLK_AMPERSAND, or '&' * - "latin_letters": For keyboards using non-Latin letters, such as Russian * or Thai, the letter keys generate keycodes as though it had an English * QWERTY layout. e.g. pressing the key associated with SDL_SCANCODE_A on a * Russian keyboard would yield 'a' instead of a Cyrillic letter. * * The default value for this hint is "french_numbers,latin_letters" * * Some platforms like Emscripten only provide modified keycodes and the * options are not used. * * These options do not affect the return value of SDL_GetKeyFromScancode() or * SDL_GetScancodeFromKey(), they just apply to the keycode included in key * events. * * This hint can be set anytime. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_KEYCODE_OPTIONS "SDL_KEYCODE_OPTIONS" /** * A variable that controls what KMSDRM device to use. * * SDL might open something like "/dev/dri/cardNN" to access KMSDRM * functionality, where "NN" is a device index number. SDL makes a guess at * the best index to use (usually zero), but the app or user can set this hint * to a number between 0 and 99 to force selection. * * This hint should be set before SDL is initialized. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_KMSDRM_DEVICE_INDEX "SDL_KMSDRM_DEVICE_INDEX" /** * A variable that controls whether SDL requires DRM master access in order to * initialize the KMSDRM video backend. * * The DRM subsystem has a concept of a "DRM master" which is a DRM client * that has the ability to set planes, set cursor, etc. When SDL is DRM * master, it can draw to the screen using the SDL rendering APIs. Without DRM * master, SDL is still able to process input and query attributes of attached * displays, but it cannot change display state or draw to the screen * directly. * * In some cases, it can be useful to have the KMSDRM backend even if it * cannot be used for rendering. An app may want to use SDL for input * processing while using another rendering API (such as an MMAL overlay on * Raspberry Pi) or using its own code to render to DRM overlays that SDL * doesn't support. * * The variable can be set to the following values: * * - "0": SDL will allow usage of the KMSDRM backend without DRM master. * - "1": SDL Will require DRM master to use the KMSDRM backend. (default) * * This hint should be set before SDL is initialized. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_KMSDRM_REQUIRE_DRM_MASTER "SDL_KMSDRM_REQUIRE_DRM_MASTER" /** * A variable that controls whether KMSDRM will use "atomic" functionality. * * The KMSDRM backend can use atomic commits, if both DRM_CLIENT_CAP_ATOMIC * and DRM_CLIENT_CAP_UNIVERSAL_PLANES is supported by the system. As of SDL * 3.4.0, it will favor this functionality, but in case this doesn't work well * on a given system or other surprises, this hint can be used to disable it. * * This hint can not enable the functionality if it isn't available. * * The variable can be set to the following values: * * - "0": SDL will not use the KMSDRM "atomic" functionality. * - "1": SDL will allow usage of the KMSDRM "atomic" functionality. (default) * * This hint should be set before SDL is initialized. * * \since This hint is available since SDL 3.4.0. */ #define SDL_HINT_KMSDRM_ATOMIC "SDL_KMSDRM_ATOMIC" /** * A variable controlling the default SDL log levels. * * This variable is a comma separated set of category=level tokens that define * the default logging levels for SDL applications. * * The category can be a numeric category, one of "app", "error", "assert", * "system", "audio", "video", "render", "input", "test", or `*` for any * unspecified category. * * The level can be a numeric level, one of "verbose", "debug", "info", * "warn", "error", "critical", or "quiet" to disable that category. * * You can omit the category if you want to set the logging level for all * categories. * * If this hint isn't set, the default log levels are equivalent to: * * `app=info,assert=warn,test=verbose,*=error` * * If the `DEBUG_INVOCATION` environment variable is set to "1", the default * log levels are equivalent to: * * `assert=warn,test=verbose,*=debug` * * This hint can be set anytime. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_LOGGING "SDL_LOGGING" /** * A variable controlling whether to force the application to become the * foreground process when launched on macOS. * * The variable can be set to the following values: * * - "0": The application is brought to the foreground when launched. * (default) * - "1": The application may remain in the background when launched. * * This hint needs to be set before SDL_Init(). * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_MAC_BACKGROUND_APP "SDL_MAC_BACKGROUND_APP" /** * A variable that determines whether Ctrl+Click should generate a right-click * event on macOS. * * The variable can be set to the following values: * * - "0": Ctrl+Click does not generate a right mouse button click event. * (default) * - "1": Ctrl+Click generated a right mouse button click event. * * This hint can be set anytime. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_MAC_CTRL_CLICK_EMULATE_RIGHT_CLICK "SDL_MAC_CTRL_CLICK_EMULATE_RIGHT_CLICK" /** * A variable controlling whether dispatching OpenGL context updates should * block the dispatching thread until the main thread finishes processing on * macOS. * * The variable can be set to the following values: * * - "0": Dispatching OpenGL context updates will block the dispatching thread * until the main thread finishes processing. (default) * - "1": Dispatching OpenGL context updates will allow the dispatching thread * to continue execution. * * Generally you want the default, but if you have OpenGL code in a background * thread on a Mac, and the main thread hangs because it's waiting for that * background thread, but that background thread is also hanging because it's * waiting for the main thread to do an update, this might fix your issue. * * This hint can be set anytime. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_MAC_OPENGL_ASYNC_DISPATCH "SDL_MAC_OPENGL_ASYNC_DISPATCH" /** * A variable controlling whether the Option key on macOS should be remapped * to act as the Alt key. * * The variable can be set to the following values: * * - "none": The Option key is not remapped to Alt. (default) * - "only_left": Only the left Option key is remapped to Alt. * - "only_right": Only the right Option key is remapped to Alt. * - "both": Both Option keys are remapped to Alt. * * This will prevent the triggering of key compositions that rely on the * Option key, but will still send the Alt modifier for keyboard events. In * the case that both Alt and Option are pressed, the Option key will be * ignored. This is particularly useful for applications like terminal * emulators and graphical user interfaces (GUIs) that rely on Alt key * functionality for shortcuts or navigation. This does not apply to * SDL_GetKeyFromScancode and only has an effect if IME is enabled. * * This hint can be set anytime. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_MAC_OPTION_AS_ALT "SDL_MAC_OPTION_AS_ALT" /** * A variable controlling whether SDL_EVENT_MOUSE_WHEEL event values will have * momentum on macOS. * * The variable can be set to the following values: * * - "0": The mouse wheel events will have no momentum. (default) * - "1": The mouse wheel events will have momentum. * * This hint needs to be set before SDL_Init(). * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_MAC_SCROLL_MOMENTUM "SDL_MAC_SCROLL_MOMENTUM" /** * A variable controlling whether holding down a key will repeat the pressed * key or open the accents menu on macOS. * * The variable can be set to the following values: * * - "0": Holding a key will repeat the pressed key. * - "1": Holding a key will open the accents menu for that key. (default) * * This hint needs to be set before SDL_Init(). * * \since This hint is available since SDL 3.4.0. */ #define SDL_HINT_MAC_PRESS_AND_HOLD "SDL_MAC_PRESS_AND_HOLD" /** * Request SDL_AppIterate() be called at a specific rate. * * If this is set to a number, it represents Hz, so "60" means try to iterate * 60 times per second. "0" means to iterate as fast as possible. Negative * values are illegal, but reserved, in case they are useful in a future * revision of SDL. * * There are other strings that have special meaning. If set to "waitevent", * SDL_AppIterate will not be called until new event(s) have arrived (and been * processed by SDL_AppEvent). This can be useful for apps that are completely * idle except in response to input. * * On some platforms, or if you are using SDL_main instead of SDL_AppIterate, * this hint is ignored. When the hint can be used, it is allowed to be * changed at any time. * * This defaults to 0, and specifying NULL for the hint's value will restore * the default. * * This doesn't have to be an integer value. For example, "59.94" won't be * rounded to an integer rate; the digits after the decimal are actually * respected. * * This hint can be set anytime. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_MAIN_CALLBACK_RATE "SDL_MAIN_CALLBACK_RATE" /** * A variable controlling whether the mouse is captured while mouse buttons * are pressed. * * The variable can be set to the following values: * * - "0": The mouse is not captured while mouse buttons are pressed. * - "1": The mouse is captured while mouse buttons are pressed. * * By default the mouse is captured while mouse buttons are pressed so if the * mouse is dragged outside the window, the application continues to receive * mouse events until the button is released. * * This hint can be set anytime. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_MOUSE_AUTO_CAPTURE "SDL_MOUSE_AUTO_CAPTURE" /** * A variable setting the double click radius, in pixels. * * This hint can be set anytime. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_MOUSE_DOUBLE_CLICK_RADIUS "SDL_MOUSE_DOUBLE_CLICK_RADIUS" /** * A variable setting the double click time, in milliseconds. * * This hint can be set anytime. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_MOUSE_DOUBLE_CLICK_TIME "SDL_MOUSE_DOUBLE_CLICK_TIME" /** * A variable setting which system cursor to use as the default cursor. * * This should be an integer corresponding to the SDL_SystemCursor enum. The * default value is zero (SDL_SYSTEM_CURSOR_DEFAULT). * * This hint needs to be set before SDL_Init(). * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_MOUSE_DEFAULT_SYSTEM_CURSOR "SDL_MOUSE_DEFAULT_SYSTEM_CURSOR" /** * A variable setting whether we should scale cursors by the current display * scale. * * The variable can be set to the following values: * * - "0": Cursors will not change size based on the display content scale. * (default) * - "1": Cursors will automatically match the display content scale (e.g. a * 2x sized cursor will be used when the window is on a monitor with 200% * scale). This is currently implemented on Windows and Wayland. * * This hint needs to be set before creating cursors. * * \since This hint is available since SDL 3.4.0. */ #define SDL_HINT_MOUSE_DPI_SCALE_CURSORS "SDL_MOUSE_DPI_SCALE_CURSORS" /** * A variable controlling whether warping a hidden mouse cursor will activate * relative mouse mode. * * When this hint is set, the mouse cursor is hidden, and multiple warps to * the window center occur within a short time period, SDL will emulate mouse * warps using relative mouse mode. This can provide smoother and more * reliable mouse motion for some older games, which continuously calculate * the distance traveled by the mouse pointer and warp it back to the center * of the window, rather than using relative mouse motion. * * Note that relative mouse mode may have different mouse acceleration * behavior than pointer warps. * * If your application needs to repeatedly warp the hidden mouse cursor at a * high-frequency for other purposes, it should disable this hint. * * The variable can be set to the following values: * * - "0": Attempts to warp the mouse will always be made. * - "1": Some mouse warps will be emulated by forcing relative mouse mode. * (default) * * If not set, this is automatically enabled unless an application uses * relative mouse mode directly. * * This hint can be set anytime. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_MOUSE_EMULATE_WARP_WITH_RELATIVE "SDL_MOUSE_EMULATE_WARP_WITH_RELATIVE" /** * Allow mouse click events when clicking to focus an SDL window. * * The variable can be set to the following values: * * - "0": Ignore mouse clicks that activate a window. (default) * - "1": Generate events for mouse clicks that activate a window. * * This hint can be set anytime. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_MOUSE_FOCUS_CLICKTHROUGH "SDL_MOUSE_FOCUS_CLICKTHROUGH" /** * A variable setting the speed scale for mouse motion, in floating point, * when the mouse is not in relative mode. * * This hint can be set anytime. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_MOUSE_NORMAL_SPEED_SCALE "SDL_MOUSE_NORMAL_SPEED_SCALE" /** * A variable controlling whether relative mouse mode constrains the mouse to * the center of the window. * * Constraining to the center of the window works better for FPS games and * when the application is running over RDP. Constraining to the whole window * works better for 2D games and increases the chance that the mouse will be * in the correct position when using high DPI mice. * * The variable can be set to the following values: * * - "0": Relative mouse mode constrains the mouse to the window. * - "1": Relative mouse mode constrains the mouse to the center of the * window. (default) * * This hint can be set anytime. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_MOUSE_RELATIVE_MODE_CENTER "SDL_MOUSE_RELATIVE_MODE_CENTER" /** * A variable setting the scale for mouse motion, in floating point, when the * mouse is in relative mode. * * This hint can be set anytime. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_MOUSE_RELATIVE_SPEED_SCALE "SDL_MOUSE_RELATIVE_SPEED_SCALE" /** * A variable controlling whether the system mouse acceleration curve is used * for relative mouse motion. * * The variable can be set to the following values: * * - "0": Relative mouse motion will be unscaled. (default) * - "1": Relative mouse motion will be scaled using the system mouse * acceleration curve. * * If SDL_HINT_MOUSE_RELATIVE_SPEED_SCALE is set, that will be applied after * system speed scale. * * This hint can be set anytime. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_MOUSE_RELATIVE_SYSTEM_SCALE "SDL_MOUSE_RELATIVE_SYSTEM_SCALE" /** * A variable controlling whether a motion event should be generated for mouse * warping in relative mode. * * The variable can be set to the following values: * * - "0": Warping the mouse will not generate a motion event in relative mode * - "1": Warping the mouse will generate a motion event in relative mode * * By default warping the mouse will not generate motion events in relative * mode. This avoids the application having to filter out large relative * motion due to warping. * * This hint can be set anytime. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_MOUSE_RELATIVE_WARP_MOTION "SDL_MOUSE_RELATIVE_WARP_MOTION" /** * A variable controlling whether the hardware cursor stays visible when * relative mode is active. * * This variable can be set to the following values: * * - "0": The cursor will be hidden while relative mode is active (default) * - "1": The cursor will remain visible while relative mode is active * * Note that for systems without raw hardware inputs, relative mode is * implemented using warping, so the hardware cursor will visibly warp between * frames if this is enabled on those systems. * * This hint can be set anytime. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_MOUSE_RELATIVE_CURSOR_VISIBLE "SDL_MOUSE_RELATIVE_CURSOR_VISIBLE" /** * A variable controlling whether mouse events should generate synthetic touch * events. * * The variable can be set to the following values: * * - "0": Mouse events will not generate touch events. (default for desktop * platforms) * - "1": Mouse events will generate touch events. (default for mobile * platforms, such as Android and iOS) * * This hint can be set anytime. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_MOUSE_TOUCH_EVENTS "SDL_MOUSE_TOUCH_EVENTS" /** * A variable controlling whether the keyboard should be muted on the console. * * Normally the keyboard is muted while SDL applications are running so that * keyboard input doesn't show up as key strokes on the console. This hint * allows you to turn that off for debugging purposes. * * The variable can be set to the following values: * * - "0": Allow keystrokes to go through to the console. * - "1": Mute keyboard input so it doesn't show up on the console. (default) * * This hint should be set before SDL is initialized. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_MUTE_CONSOLE_KEYBOARD "SDL_MUTE_CONSOLE_KEYBOARD" /** * Tell SDL not to catch the SIGINT or SIGTERM signals on POSIX platforms. * * The variable can be set to the following values: * * - "0": SDL will install a SIGINT and SIGTERM handler, and when it catches a * signal, convert it into an SDL_EVENT_QUIT event. (default) * - "1": SDL will not install a signal handler at all. * * This hint should be set before SDL is initialized. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_NO_SIGNAL_HANDLERS "SDL_NO_SIGNAL_HANDLERS" /** * Specify the OpenGL library to load. * * This hint should be set before creating an OpenGL window or creating an * OpenGL context. If this hint isn't set, SDL will choose a reasonable * default. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_OPENGL_LIBRARY "SDL_OPENGL_LIBRARY" /** * Specify the EGL library to load. * * This hint should be set before creating an OpenGL window or creating an * OpenGL context. This hint is only considered if SDL is using EGL to manage * OpenGL contexts. If this hint isn't set, SDL will choose a reasonable * default. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_EGL_LIBRARY "SDL_EGL_LIBRARY" /** * A variable controlling what driver to use for OpenGL ES contexts. * * On some platforms, currently Windows and X11, OpenGL drivers may support * creating contexts with an OpenGL ES profile. By default SDL uses these * profiles, when available, otherwise it attempts to load an OpenGL ES * library, e.g. that provided by the ANGLE project. This variable controls * whether SDL follows this default behaviour or will always load an OpenGL ES * library. * * Circumstances where this is useful include - Testing an app with a * particular OpenGL ES implementation, e.g ANGLE, or emulator, e.g. those * from ARM, Imagination or Qualcomm. - Resolving OpenGL ES function addresses * at link time by linking with the OpenGL ES library instead of querying them * at run time with SDL_GL_GetProcAddress(). * * Caution: for an application to work with the default behaviour across * different OpenGL drivers it must query the OpenGL ES function addresses at * run time using SDL_GL_GetProcAddress(). * * This variable is ignored on most platforms because OpenGL ES is native or * not supported. * * The variable can be set to the following values: * * - "0": Use ES profile of OpenGL, if available. (default) * - "1": Load OpenGL ES library using the default library names. * * This hint should be set before SDL is initialized. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_OPENGL_ES_DRIVER "SDL_OPENGL_ES_DRIVER" /** * A variable controlling whether to force an sRGB-capable OpenGL context. * * At OpenGL context creation time, some platforms can request an sRGB-capable * context. However, sometimes any form of the request can cause surprising * results on some drivers, platforms, and hardware. Usually the surprise is * in the form of rendering that is either a little darker or a little * brighter than intended. * * This hint allows the user to override the app's sRGB requests and either * force a specific value, or avoid requesting anything at all, depending on * what makes things work correctly for their system. * * This is meant as a fail-safe; apps should probably not explicitly set this, * and most users should not, either. * * Note that some platforms cannot make this request at all, and on all * platforms this request can be denied by the operating system. * * In addition to attempting to obtain the type of sRGB-capable OpenGL context * requested by this hint, SDL will try to force the state of * GL_FRAMEBUFFER_SRGB on the new context, if appropriate. * * The variable can be set to the following values: * * - "0": Force a request for an OpenGL context that is _not_ sRGB-capable. * - "1": Force a request for an OpenGL context that _is_ sRGB-capable. * - "skip": Don't make any request for an sRGB-capable context (don't specify * the attribute at all during context creation time). * - any other string is undefined behavior. * * If unset, or set to an empty string, SDL will make a request using the * value the app specified with the SDL_GL_FRAMEBUFFER_SRGB_CAPABLE attribute. * * This hint should be set before an OpenGL context is created. * * \since This hint is available since SDL 3.4.2. */ #define SDL_HINT_OPENGL_FORCE_SRGB_FRAMEBUFFER "SDL_OPENGL_FORCE_SRGB_FRAMEBUFFER" /** * Mechanism to specify openvr_api library location * * By default, when using the OpenVR driver, it will search for the API * library in the current folder. But, if you wish to use a system API you can * specify that by using this hint. This should be the full or relative path * to a .dll on Windows or .so on Linux. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_OPENVR_LIBRARY "SDL_OPENVR_LIBRARY" /** * A variable controlling which orientations are allowed on iOS/Android. * * In some circumstances it is necessary to be able to explicitly control * which UI orientations are allowed. * * This variable is a space delimited list of the following values: * * - "LandscapeLeft" * - "LandscapeRight" * - "Portrait" * - "PortraitUpsideDown" * * This hint should be set before SDL is initialized. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_ORIENTATIONS "SDL_ORIENTATIONS" /** * A variable controlling the use of a sentinel event when polling the event * queue. * * When polling for events, SDL_PumpEvents is used to gather new events from * devices. If a device keeps producing new events between calls to * SDL_PumpEvents, a poll loop will become stuck until the new events stop. * This is most noticeable when moving a high frequency mouse. * * The variable can be set to the following values: * * - "0": Disable poll sentinels. * - "1": Enable poll sentinels. (default) * * This hint can be set anytime. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_POLL_SENTINEL "SDL_POLL_SENTINEL" /** * Override for SDL_GetPreferredLocales(). * * If set, this will be favored over anything the OS might report for the * user's preferred locales. Changing this hint at runtime will not generate a * SDL_EVENT_LOCALE_CHANGED event (but if you can change the hint, you can * push your own event, if you want). * * The format of this hint is a comma-separated list of language and locale, * combined with an underscore, as is a common format: "en_GB". Locale is * optional: "en". So you might have a list like this: "en_GB,jp,es_PT" * * This hint can be set anytime. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_PREFERRED_LOCALES "SDL_PREFERRED_LOCALES" /** * A variable that decides whether to send SDL_EVENT_QUIT when closing the * last window. * * The variable can be set to the following values: * * - "0": SDL will not send an SDL_EVENT_QUIT event when the last window is * requesting to close. Note that in this case, there are still other * legitimate reasons one might get an SDL_EVENT_QUIT event: choosing "Quit" * from the macOS menu bar, sending a SIGINT (ctrl-c) on Unix, etc. * - "1": SDL will send a quit event when the last window is requesting to * close. (default) * * If there is at least one active system tray icon, SDL_EVENT_QUIT will * instead be sent when both the last window will be closed and the last tray * icon will be destroyed. * * This hint can be set anytime. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_QUIT_ON_LAST_WINDOW_CLOSE "SDL_QUIT_ON_LAST_WINDOW_CLOSE" /** * A variable controlling whether the Direct3D device is initialized for * thread-safe operations. * * The variable can be set to the following values: * * - "0": Thread-safety is not enabled. (default) * - "1": Thread-safety is enabled. * * This hint should be set before creating a renderer. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_RENDER_DIRECT3D_THREADSAFE "SDL_RENDER_DIRECT3D_THREADSAFE" /** * A variable controlling whether to enable Direct3D 11+'s Debug Layer. * * This variable does not have any effect on the Direct3D 9 based renderer. * * The variable can be set to the following values: * * - "0": Disable Debug Layer use. (default) * - "1": Enable Debug Layer use. * * This hint should be set before creating a renderer. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_RENDER_DIRECT3D11_DEBUG "SDL_RENDER_DIRECT3D11_DEBUG" /** * A variable controlling whether to use the Direct3D 11 WARP software * rasterizer. * * For more information, see: * https://learn.microsoft.com/en-us/windows/win32/direct3darticles/directx-warp * * The variable can be set to the following values: * * - "0": Disable WARP rasterizer. (default) * - "1": Enable WARP rasterizer. * * This hint should be set before creating a renderer. * * \since This hint is available since SDL 3.4.0. */ #define SDL_HINT_RENDER_DIRECT3D11_WARP "SDL_RENDER_DIRECT3D11_WARP" /** * A variable controlling whether to enable Vulkan Validation Layers. * * This variable can be set to the following values: * * - "0": Disable Validation Layer use * - "1": Enable Validation Layer use * * By default, SDL does not use Vulkan Validation Layers. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_RENDER_VULKAN_DEBUG "SDL_RENDER_VULKAN_DEBUG" /** * A variable controlling whether to create the GPU device in debug mode. * * This variable can be set to the following values: * * - "0": Disable debug mode use (default) * - "1": Enable debug mode use * * This hint should be set before creating a renderer. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_RENDER_GPU_DEBUG "SDL_RENDER_GPU_DEBUG" /** * A variable controlling whether to prefer a low-power GPU on multi-GPU * systems. * * This variable can be set to the following values: * * - "0": Prefer high-performance GPU (default) * - "1": Prefer low-power GPU * * This hint should be set before creating a renderer. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_RENDER_GPU_LOW_POWER "SDL_RENDER_GPU_LOW_POWER" /** * A variable specifying which render driver to use. * * If the application doesn't pick a specific renderer to use, this variable * specifies the name of the preferred renderer. If the preferred renderer * can't be initialized, creating a renderer will fail. * * This variable is case insensitive and can be set to the following values: * * - "direct3d" * - "direct3d11" * - "direct3d12" * - "opengl" * - "opengles2" * - "opengles" * - "metal" * - "vulkan" * - "gpu" * - "software" * * This hint accepts a comma-separated list of driver names, and each will be * tried in the order listed when creating a renderer until one succeeds or * all of them fail. * * The default varies by platform, but it's the first one in the list that is * available on the current platform. * * This hint should be set before creating a renderer. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_RENDER_DRIVER "SDL_RENDER_DRIVER" /** * A variable controlling how the 2D render API renders lines. * * The variable can be set to the following values: * * - "0": Use the default line drawing method (Bresenham's line algorithm) * - "1": Use the driver point API using Bresenham's line algorithm (correct, * draws many points) * - "2": Use the driver line API (occasionally misses line endpoints based on * hardware driver quirks * - "3": Use the driver geometry API (correct, draws thicker diagonal lines) * * This hint should be set before creating a renderer. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_RENDER_LINE_METHOD "SDL_RENDER_LINE_METHOD" /** * A variable controlling whether the Metal render driver select low power * device over default one. * * The variable can be set to the following values: * * - "0": Use the preferred OS device. (default) * - "1": Select a low power device. * * This hint should be set before creating a renderer. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_RENDER_METAL_PREFER_LOW_POWER_DEVICE "SDL_RENDER_METAL_PREFER_LOW_POWER_DEVICE" /** * A variable controlling whether updates to the SDL screen surface should be * synchronized with the vertical refresh, to avoid tearing. * * This hint overrides the application preference when creating a renderer. * * The variable can be set to the following values: * * - "0": Disable vsync. (default) * - "1": Enable vsync. * * This hint should be set before creating a renderer. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_RENDER_VSYNC "SDL_RENDER_VSYNC" /** * A variable to control whether the return key on the soft keyboard should * hide the soft keyboard on Android and iOS. * * This hint sets the default value of SDL_PROP_TEXTINPUT_MULTILINE_BOOLEAN. * * The variable can be set to the following values: * * - "0": The return key will be handled as a key event. (default) * - "1": The return key will hide the keyboard. * * This hint can be set anytime. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_RETURN_KEY_HIDES_IME "SDL_RETURN_KEY_HIDES_IME" /** * A variable containing a list of ROG gamepad capable mice. * * The format of the string is a comma separated list of USB VID/PID pairs in * hexadecimal form, e.g. * * `0xAAAA/0xBBBB,0xCCCC/0xDDDD` * * The variable can also take the form of "@file", in which case the named * file will be loaded and interpreted as the value of the variable. * * This hint should be set before SDL is initialized. * * \since This hint is available since SDL 3.2.0. * * \sa SDL_HINT_ROG_GAMEPAD_MICE_EXCLUDED */ #define SDL_HINT_ROG_GAMEPAD_MICE "SDL_ROG_GAMEPAD_MICE" /** * A variable containing a list of devices that are not ROG gamepad capable * mice. * * This will override SDL_HINT_ROG_GAMEPAD_MICE and the built in device list. * * The format of the string is a comma separated list of USB VID/PID pairs in * hexadecimal form, e.g. * * `0xAAAA/0xBBBB,0xCCCC/0xDDDD` * * The variable can also take the form of "@file", in which case the named * file will be loaded and interpreted as the value of the variable. * * This hint should be set before SDL is initialized. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_ROG_GAMEPAD_MICE_EXCLUDED "SDL_ROG_GAMEPAD_MICE_EXCLUDED" /** * A variable controlling the width of the PS2's framebuffer in pixels. * * By default, the variable is "640". * * \since This hint is available since SDL 3.4.0. */ #define SDL_HINT_PS2_GS_WIDTH "SDL_PS2_GS_WIDTH" /** * A variable controlling the height of the PS2's framebuffer in pixels. * * By default, the variable is "448". * * \since This hint is available since SDL 3.4.0. */ #define SDL_HINT_PS2_GS_HEIGHT "SDL_PS2_GS_HEIGHT" /** * A variable controlling whether the signal is interlaced or progressive. * * The variable can be set to the following values: * * - "0": Image is interlaced. (default) * - "1": Image is progressive. * * \since This hint is available since SDL 3.4.0. */ #define SDL_HINT_PS2_GS_PROGRESSIVE "SDL_PS2_GS_PROGRESSIVE" /** * A variable controlling the video mode of the console. * * The variable can be set to the following values: * * - "": Console-native. (default) * - "NTSC": 60hz region. * - "PAL": 50hz region. * * \since This hint is available since SDL 3.4.0. */ #define SDL_HINT_PS2_GS_MODE "SDL_PS2_GS_MODE" /** * A variable controlling which Dispmanx layer to use on a Raspberry PI. * * Also known as Z-order. The variable can take a negative or positive value. * The default is 10000. * * This hint should be set before SDL is initialized. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_RPI_VIDEO_LAYER "SDL_RPI_VIDEO_LAYER" /** * Specify an "activity name" for screensaver inhibition. * * Some platforms, notably Linux desktops, list the applications which are * inhibiting the screensaver or other power-saving features. * * This hint lets you specify the "activity name" sent to the OS when * SDL_DisableScreenSaver() is used (or the screensaver is automatically * disabled). The contents of this hint are used when the screensaver is * disabled. You should use a string that describes what your program is doing * (and, therefore, why the screensaver is disabled). For example, "Playing a * game" or "Watching a video". * * Setting this to "" or leaving it unset will have SDL use a reasonable * default: "Playing a game" or something similar. * * This hint should be set before calling SDL_DisableScreenSaver() * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_SCREENSAVER_INHIBIT_ACTIVITY_NAME "SDL_SCREENSAVER_INHIBIT_ACTIVITY_NAME" /** * A variable controlling whether SDL calls dbus_shutdown() on quit. * * This is useful as a debug tool to validate memory leaks, but shouldn't ever * be set in production applications, as other libraries used by the * application might use dbus under the hood and this can cause crashes if * they continue after SDL_Quit(). * * The variable can be set to the following values: * * - "0": SDL will not call dbus_shutdown() on quit. (default) * - "1": SDL will call dbus_shutdown() on quit. * * This hint can be set anytime. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_SHUTDOWN_DBUS_ON_QUIT "SDL_SHUTDOWN_DBUS_ON_QUIT" /** * A variable that specifies a backend to use for title storage. * * By default, SDL will try all available storage backends in a reasonable * order until it finds one that can work, but this hint allows the app or * user to force a specific target, such as "pc" if, say, you are on Steam but * want to avoid SteamRemoteStorage for title data. * * This hint should be set before SDL is initialized. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_STORAGE_TITLE_DRIVER "SDL_STORAGE_TITLE_DRIVER" /** * A variable that specifies a backend to use for user storage. * * By default, SDL will try all available storage backends in a reasonable * order until it finds one that can work, but this hint allows the app or * user to force a specific target, such as "pc" if, say, you are on Steam but * want to avoid SteamRemoteStorage for user data. * * This hint should be set before SDL is initialized. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_STORAGE_USER_DRIVER "SDL_STORAGE_USER_DRIVER" /** * Specifies whether SDL_THREAD_PRIORITY_TIME_CRITICAL should be treated as * realtime. * * On some platforms, like Linux, a realtime priority thread may be subject to * restrictions that require special handling by the application. This hint * exists to let SDL know that the app is prepared to handle said * restrictions. * * On Linux, SDL will apply the following configuration to any thread that * becomes realtime: * * - The SCHED_RESET_ON_FORK bit will be set on the scheduling policy, * - An RLIMIT_RTTIME budget will be configured to the rtkit specified limit. * - Exceeding this limit will result in the kernel sending SIGKILL to the * app, refer to the man pages for more information. * * The variable can be set to the following values: * * - "0": default platform specific behaviour * - "1": Force SDL_THREAD_PRIORITY_TIME_CRITICAL to a realtime scheduling * policy * * This hint should be set before calling SDL_SetCurrentThreadPriority() * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_THREAD_FORCE_REALTIME_TIME_CRITICAL "SDL_THREAD_FORCE_REALTIME_TIME_CRITICAL" /** * A string specifying additional information to use with * SDL_SetCurrentThreadPriority. * * By default SDL_SetCurrentThreadPriority will make appropriate system * changes in order to apply a thread priority. For example on systems using * pthreads the scheduler policy is changed automatically to a policy that * works well with a given priority. Code which has specific requirements can * override SDL's default behavior with this hint. * * pthread hint values are "current", "other", "fifo" and "rr". Currently no * other platform hint values are defined but may be in the future. * * On Linux, the kernel may send SIGKILL to realtime tasks which exceed the * distro configured execution budget for rtkit. This budget can be queried * through RLIMIT_RTTIME after calling SDL_SetCurrentThreadPriority(). * * This hint should be set before calling SDL_SetCurrentThreadPriority() * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_THREAD_PRIORITY_POLICY "SDL_THREAD_PRIORITY_POLICY" /** * A variable that controls the timer resolution, in milliseconds. * * The higher resolution the timer, the more frequently the CPU services timer * interrupts, and the more precise delays are, but this takes up power and * CPU time. This hint is only used on Windows. * * See this blog post for more information: * http://randomascii.wordpress.com/2013/07/08/windows-timer-resolution-megawatts-wasted/ * * The default value is "1". * * If this variable is set to "0", the system timer resolution is not set. * * This hint can be set anytime. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_TIMER_RESOLUTION "SDL_TIMER_RESOLUTION" /** * A variable controlling whether touch events should generate synthetic mouse * events. * * The variable can be set to the following values: * * - "0": Touch events will not generate mouse events. * - "1": Touch events will generate mouse events. (default) * * This hint can be set anytime. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_TOUCH_MOUSE_EVENTS "SDL_TOUCH_MOUSE_EVENTS" /** * A variable controlling whether trackpads should be treated as touch * devices. * * On macOS (and possibly other platforms in the future), SDL will report * touches on a trackpad as mouse input, which is generally what users expect * from this device; however, these are often actually full multitouch-capable * touch devices, so it might be preferable to some apps to treat them as * such. * * The variable can be set to the following values: * * - "0": Trackpad will send mouse events. (default) * - "1": Trackpad will send touch events. * * This hint should be set before SDL is initialized. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_TRACKPAD_IS_TOUCH_ONLY "SDL_TRACKPAD_IS_TOUCH_ONLY" /** * A variable controlling whether the Android / tvOS remotes should be listed * as joystick devices, instead of sending keyboard events. * * The variable can be set to the following values: * * - "0": Remotes send enter/escape/arrow key events. * - "1": Remotes are available as 2 axis, 2 button joysticks. (default) * * This hint should be set before SDL is initialized. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_TV_REMOTE_AS_JOYSTICK "SDL_TV_REMOTE_AS_JOYSTICK" /** * A variable controlling whether the screensaver is enabled. * * The variable can be set to the following values: * * - "0": Disable screensaver. (default) * - "1": Enable screensaver. * * This hint should be set before SDL is initialized. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_VIDEO_ALLOW_SCREENSAVER "SDL_VIDEO_ALLOW_SCREENSAVER" /** * A comma separated list containing the names of the displays that SDL should * sort to the front of the display list. * * When this hint is set, displays with matching name strings will be * prioritized in the list of displays, as exposed by calling * SDL_GetDisplays(), with the first listed becoming the primary display. The * naming convention can vary depending on the environment, but it is usually * a connector name (e.g. 'DP-1', 'DP-2', 'HDMI-A-1', etc...). * * On Wayland desktops, the connector names associated with displays can be * found in the `name` property of the info output from `wayland-info -i * wl_output`. On X11 desktops, the `xrandr` utility can be used to retrieve * the connector names associated with displays. * * This hint is currently supported on the following drivers: * * - KMSDRM (kmsdrm) * - Wayland (wayland) * - X11 (x11) * * This hint should be set before SDL is initialized. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_VIDEO_DISPLAY_PRIORITY "SDL_VIDEO_DISPLAY_PRIORITY" /** * Tell the video driver that we only want a double buffer. * * By default, most lowlevel 2D APIs will use a triple buffer scheme that * wastes no CPU time on waiting for vsync after issuing a flip, but * introduces a frame of latency. On the other hand, using a double buffer * scheme instead is recommended for cases where low latency is an important * factor because we save a whole frame of latency. * * We do so by waiting for vsync immediately after issuing a flip, usually * just after eglSwapBuffers call in the backend's *_SwapWindow function. * * This hint is currently supported on the following drivers: * * - Raspberry Pi (raspberrypi) * - Wayland (wayland) * * This hint should be set before SDL is initialized. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_VIDEO_DOUBLE_BUFFER "SDL_VIDEO_DOUBLE_BUFFER" /** * A variable that specifies a video backend to use. * * By default, SDL will try all available video backends in a reasonable order * until it finds one that can work, but this hint allows the app or user to * force a specific target, such as "x11" if, say, you are on Wayland but want * to try talking to the X server instead. * * This hint accepts a comma-separated list of driver names, and each will be * tried in the order listed during init, until one succeeds or all of them * fail. * * This hint should be set before SDL is initialized. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_VIDEO_DRIVER "SDL_VIDEO_DRIVER" /** * A variable controlling whether the dummy video driver saves output frames. * * - "0": Video frames are not saved to disk. (default) * - "1": Video frames are saved to files in the format "SDL_windowX-Y.bmp", * where X is the window ID, and Y is the frame number. * * This hint can be set anytime. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_VIDEO_DUMMY_SAVE_FRAMES "SDL_VIDEO_DUMMY_SAVE_FRAMES" /** * If eglGetPlatformDisplay fails, fall back to calling eglGetDisplay. * * The variable can be set to one of the following values: * * - "0": Do not fall back to eglGetDisplay. * - "1": Fall back to eglGetDisplay if eglGetPlatformDisplay fails. (default) * * This hint should be set before SDL is initialized. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_VIDEO_EGL_ALLOW_GETDISPLAY_FALLBACK "SDL_VIDEO_EGL_ALLOW_GETDISPLAY_FALLBACK" /** * A variable controlling whether the OpenGL context should be created with * EGL. * * The variable can be set to the following values: * * - "0": Use platform-specific GL context creation API (GLX, WGL, CGL, etc). * (default) * - "1": Use EGL * * This hint should be set before SDL is initialized. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_VIDEO_FORCE_EGL "SDL_VIDEO_FORCE_EGL" /** * A variable that specifies the policy for fullscreen Spaces on macOS. * * The variable can be set to the following values: * * - "0": Disable Spaces support (FULLSCREEN_DESKTOP won't use them and * SDL_WINDOW_RESIZABLE windows won't offer the "fullscreen" button on their * titlebars). * - "1": Enable Spaces support (FULLSCREEN_DESKTOP will use them and * SDL_WINDOW_RESIZABLE windows will offer the "fullscreen" button on their * titlebars). (default) * * This hint should be set before creating a window. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_VIDEO_MAC_FULLSCREEN_SPACES "SDL_VIDEO_MAC_FULLSCREEN_SPACES" /** * A variable that specifies the menu visibility when a window is fullscreen * in Spaces on macOS. * * The variable can be set to the following values: * * - "0": The menu will be hidden when the window is in a fullscreen space, * and not accessible by moving the mouse to the top of the screen. * - "1": The menu will be accessible when the window is in a fullscreen * space. * - "auto": The menu will be hidden if fullscreen mode was toggled on * programmatically via `SDL_SetWindowFullscreen()`, and accessible if * fullscreen was entered via the "fullscreen" button on the window title * bar. (default) * * This hint can be set anytime. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_VIDEO_MAC_FULLSCREEN_MENU_VISIBILITY "SDL_VIDEO_MAC_FULLSCREEN_MENU_VISIBILITY" /** * A variable indicating whether the metal layer drawable size should be * updated for the SDL_EVENT_WINDOW_PIXEL_SIZE_CHANGED event on macOS. * * The variable can be set to the following values: * * - "0": the metal layer drawable size will not be updated on the * SDL_EVENT_WINDOW_PIXEL_SIZE_CHANGED event. * - "1": the metal layer drawable size will be updated on the * SDL_EVENT_WINDOW_PIXEL_SIZE_CHANGED event. (default) * * This hint should be set before SDL_Metal_CreateView called. * * \since This hint is available since SDL 3.4.0. */ #define SDL_HINT_VIDEO_METAL_AUTO_RESIZE_DRAWABLE "SDL_VIDEO_METAL_AUTO_RESIZE_DRAWABLE" /** * A variable controlling whether SDL will attempt to automatically set the * destination display to a mode most closely matching that of the previous * display if an exclusive fullscreen window is moved onto it. * * The variable can be set to the following values: * * - "0": SDL will not attempt to automatically set a matching mode on the * destination display. If an exclusive fullscreen window is moved to a new * display, the window will become fullscreen desktop. * - "1": SDL will attempt to automatically set a mode on the destination * display that most closely matches the mode of the display that the * exclusive fullscreen window was previously on. (default) * * This hint can be set anytime. * * \since This hint is available since SDL 3.4.0. */ #define SDL_HINT_VIDEO_MATCH_EXCLUSIVE_MODE_ON_MOVE "SDL_VIDEO_MATCH_EXCLUSIVE_MODE_ON_MOVE" /** * A variable controlling whether fullscreen windows are minimized when they * lose focus. * * The variable can be set to the following values: * * - "0": Fullscreen windows will not be minimized when they lose focus. * - "1": Fullscreen windows are minimized when they lose focus. * - "auto": Fullscreen windows are minimized when they lose focus if they use * exclusive fullscreen modes, so the desktop video mode is restored. * (default) * * This hint can be set anytime. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS "SDL_VIDEO_MINIMIZE_ON_FOCUS_LOSS" /** * A variable controlling whether the offscreen video driver saves output * frames. * * This only saves frames that are generated using software rendering, not * accelerated OpenGL rendering. * * - "0": Video frames are not saved to disk. (default) * - "1": Video frames are saved to files in the format "SDL_windowX-Y.bmp", * where X is the window ID, and Y is the frame number. * * This hint can be set anytime. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_VIDEO_OFFSCREEN_SAVE_FRAMES "SDL_VIDEO_OFFSCREEN_SAVE_FRAMES" /** * A variable controlling whether all window operations will block until * complete. * * Window systems that run asynchronously may not have the results of window * operations that resize or move the window applied immediately upon the * return of the requesting function. Setting this hint will cause such * operations to block after every call until the pending operation has * completed. Setting this to '1' is the equivalent of calling * SDL_SyncWindow() after every function call. * * Be aware that amount of time spent blocking while waiting for window * operations to complete can be quite lengthy, as animations may have to * complete, which can take upwards of multiple seconds in some cases. * * The variable can be set to the following values: * * - "0": Window operations are non-blocking. (default) * - "1": Window operations will block until completed. * * This hint can be set anytime. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_VIDEO_SYNC_WINDOW_OPERATIONS "SDL_VIDEO_SYNC_WINDOW_OPERATIONS" /** * A variable controlling whether the libdecor Wayland backend is allowed to * be used. * * libdecor is used over xdg-shell when xdg-decoration protocol is * unavailable. * * The variable can be set to the following values: * * - "0": libdecor use is disabled. * - "1": libdecor use is enabled. (default) * * This hint should be set before SDL is initialized. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_VIDEO_WAYLAND_ALLOW_LIBDECOR "SDL_VIDEO_WAYLAND_ALLOW_LIBDECOR" /** * A variable controlling whether video mode emulation is enabled under * Wayland. * * When this hint is set, a standard set of emulated CVT video modes will be * exposed for use by the application. If it is disabled, the only modes * exposed will be the logical desktop size and, in the case of a scaled * desktop, the native display resolution. * * The variable can be set to the following values: * * - "0": Video mode emulation is disabled. * - "1": Video mode emulation is enabled. (default) * * This hint should be set before SDL is initialized. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_VIDEO_WAYLAND_MODE_EMULATION "SDL_VIDEO_WAYLAND_MODE_EMULATION" /** * A variable controlling how modes with a non-native aspect ratio are * displayed under Wayland. * * When this hint is set, the requested scaling will be used when displaying * fullscreen video modes that don't match the display's native aspect ratio. * This is contingent on compositor viewport support. * * The variable can be set to the following values: * * - "aspect" - Video modes will be displayed scaled, in their proper aspect * ratio, with black bars. * - "stretch" - Video modes will be scaled to fill the entire display. * (default) * - "none" - Video modes will be displayed as 1:1 with no scaling. * * This hint should be set before creating a window. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_VIDEO_WAYLAND_MODE_SCALING "SDL_VIDEO_WAYLAND_MODE_SCALING" /** * A variable controlling whether the libdecor Wayland backend is preferred * over native decorations. * * When this hint is set, libdecor will be used to provide window decorations, * even if xdg-decoration is available. (Note that, by default, libdecor will * use xdg-decoration itself if available). * * The variable can be set to the following values: * * - "0": libdecor is enabled only if server-side decorations are unavailable. * (default) * - "1": libdecor is always enabled if available. * * This hint should be set before SDL is initialized. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_VIDEO_WAYLAND_PREFER_LIBDECOR "SDL_VIDEO_WAYLAND_PREFER_LIBDECOR" /** * A variable forcing non-DPI-aware Wayland windows to output at 1:1 scaling. * * This must be set before initializing the video subsystem. * * When this hint is set, Wayland windows that are not flagged as being * DPI-aware will be output with scaling designed to force 1:1 pixel mapping. * * This is intended to allow legacy applications to be displayed without * desktop scaling being applied, and has issues with certain display * configurations, as this forces the window to behave in a way that Wayland * desktops were not designed to accommodate: * * - Rounding errors can result with odd window sizes and/or desktop scales, * which can cause the window contents to appear slightly blurry. * - Positioning the window may be imprecise due to unit conversions and * rounding. * - The window may be unusably small on scaled desktops. * - The window may jump in size when moving between displays of different * scale factors. * - Displays may appear to overlap when using a multi-monitor setup with * scaling enabled. * - Possible loss of cursor precision due to the logical size of the window * being reduced. * * New applications should be designed with proper DPI awareness handling * instead of enabling this. * * The variable can be set to the following values: * * - "0": Windows will be scaled normally. * - "1": Windows will be forced to scale to achieve 1:1 output. * * This hint should be set before creating a window. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_VIDEO_WAYLAND_SCALE_TO_DISPLAY "SDL_VIDEO_WAYLAND_SCALE_TO_DISPLAY" /** * A variable specifying which shader compiler to preload when using the * Chrome ANGLE binaries. * * SDL has EGL and OpenGL ES2 support on Windows via the ANGLE project. It can * use two different sets of binaries, those compiled by the user from source * or those provided by the Chrome browser. In the later case, these binaries * require that SDL loads a DLL providing the shader compiler. * * The variable can be set to the following values: * * - "d3dcompiler_46.dll" - best for Vista or later. (default) * - "d3dcompiler_43.dll" - for XP support. * - "none" - do not load any library, useful if you compiled ANGLE from * source and included the compiler in your binaries. * * This hint should be set before SDL is initialized. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_VIDEO_WIN_D3DCOMPILER "SDL_VIDEO_WIN_D3DCOMPILER" /** * A variable controlling whether SDL should call XSelectInput() to enable * input events on X11 windows wrapped by SDL windows. * * The variable can be set to the following values: * * - "0": Don't call XSelectInput(), assuming the native window code has done * it already. * - "1": Call XSelectInput() to enable input events. (default) * * This hint should be set before creating a window. * * \since This hint is available since SDL 3.2.10. */ #define SDL_HINT_VIDEO_X11_EXTERNAL_WINDOW_INPUT "SDL_VIDEO_X11_EXTERNAL_WINDOW_INPUT" /** * A variable controlling whether the X11 _NET_WM_BYPASS_COMPOSITOR hint * should be used. * * The variable can be set to the following values: * * - "0": Disable _NET_WM_BYPASS_COMPOSITOR. * - "1": Enable _NET_WM_BYPASS_COMPOSITOR. (default) * * This hint should be set before creating a window. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_VIDEO_X11_NET_WM_BYPASS_COMPOSITOR "SDL_VIDEO_X11_NET_WM_BYPASS_COMPOSITOR" /** * A variable controlling whether the X11 _NET_WM_PING protocol should be * supported. * * By default SDL will use _NET_WM_PING, but for applications that know they * will not always be able to respond to ping requests in a timely manner they * can turn it off to avoid the window manager thinking the app is hung. * * The variable can be set to the following values: * * - "0": Disable _NET_WM_PING. * - "1": Enable _NET_WM_PING. (default) * * This hint should be set before creating a window. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_VIDEO_X11_NET_WM_PING "SDL_VIDEO_X11_NET_WM_PING" /** * A variable controlling whether SDL uses DirectColor visuals. * * The variable can be set to the following values: * * - "0": Disable DirectColor visuals. * - "1": Enable DirectColor visuals. (default) * * This hint should be set before initializing the video subsystem. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_VIDEO_X11_NODIRECTCOLOR "SDL_VIDEO_X11_NODIRECTCOLOR" /** * A variable forcing the content scaling factor for X11 displays. * * The variable can be set to a floating point value in the range 1.0-10.0f * * This hint should be set before SDL is initialized. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_VIDEO_X11_SCALING_FACTOR "SDL_VIDEO_X11_SCALING_FACTOR" /** * A variable forcing the visual ID used for X11 display modes. * * This hint should be set before initializing the video subsystem. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_VIDEO_X11_VISUALID "SDL_VIDEO_X11_VISUALID" /** * A variable forcing the visual ID chosen for new X11 windows. * * This hint should be set before creating a window. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_VIDEO_X11_WINDOW_VISUALID "SDL_VIDEO_X11_WINDOW_VISUALID" /** * A variable controlling whether the X11 XRandR extension should be used. * * The variable can be set to the following values: * * - "0": Disable XRandR. * - "1": Enable XRandR. (default) * * This hint should be set before SDL is initialized. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_VIDEO_X11_XRANDR "SDL_VIDEO_X11_XRANDR" /** * A variable controlling whether touch should be enabled on the back panel of * the PlayStation Vita. * * The variable can be set to the following values: * * - "0": Disable touch on the back panel. * - "1": Enable touch on the back panel. (default) * * This hint should be set before SDL is initialized. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_VITA_ENABLE_BACK_TOUCH "SDL_VITA_ENABLE_BACK_TOUCH" /** * A variable controlling whether touch should be enabled on the front panel * of the PlayStation Vita. * * The variable can be set to the following values: * * - "0": Disable touch on the front panel. * - "1": Enable touch on the front panel. (default) * * This hint should be set before SDL is initialized. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_VITA_ENABLE_FRONT_TOUCH "SDL_VITA_ENABLE_FRONT_TOUCH" /** * A variable controlling the module path on the PlayStation Vita. * * This hint defaults to "app0:module" * * This hint should be set before SDL is initialized. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_VITA_MODULE_PATH "SDL_VITA_MODULE_PATH" /** * A variable controlling whether to perform PVR initialization on the * PlayStation Vita. * * - "0": Skip PVR initialization. * - "1": Perform the normal PVR initialization. (default) * * This hint should be set before SDL is initialized. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_VITA_PVR_INIT "SDL_VITA_PVR_INIT" /** * A variable overriding the resolution reported on the PlayStation Vita. * * The variable can be set to the following values: * * - "544": 544p (default) * - "720": 725p for PSTV * - "1080": 1088i for PSTV * * This hint should be set before SDL is initialized. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_VITA_RESOLUTION "SDL_VITA_RESOLUTION" /** * A variable controlling whether OpenGL should be used instead of OpenGL ES * on the PlayStation Vita. * * The variable can be set to the following values: * * - "0": Use OpenGL ES. (default) * - "1": Use OpenGL. * * This hint should be set before SDL is initialized. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_VITA_PVR_OPENGL "SDL_VITA_PVR_OPENGL" /** * A variable controlling which touchpad should generate synthetic mouse * events. * * The variable can be set to the following values: * * - "0": Only front touchpad should generate mouse events. (default) * - "1": Only back touchpad should generate mouse events. * - "2": Both touchpads should generate mouse events. * * This hint can be set anytime. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_VITA_TOUCH_MOUSE_DEVICE "SDL_VITA_TOUCH_MOUSE_DEVICE" /** * A variable overriding the display index used in SDL_Vulkan_CreateSurface() * * The display index starts at 0, which is the default. * * This hint should be set before calling SDL_Vulkan_CreateSurface() * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_VULKAN_DISPLAY "SDL_VULKAN_DISPLAY" /** * Specify the Vulkan library to load. * * This hint should be set before creating a Vulkan window or calling * SDL_Vulkan_LoadLibrary(). * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_VULKAN_LIBRARY "SDL_VULKAN_LIBRARY" /** * A variable controlling how the fact chunk affects the loading of a WAVE * file. * * The fact chunk stores information about the number of samples of a WAVE * file. The Standards Update from Microsoft notes that this value can be used * to 'determine the length of the data in seconds'. This is especially useful * for compressed formats (for which this is a mandatory chunk) if they * produce multiple sample frames per block and truncating the block is not * allowed. The fact chunk can exactly specify how many sample frames there * should be in this case. * * Unfortunately, most application seem to ignore the fact chunk and so SDL * ignores it by default as well. * * The variable can be set to the following values: * * - "truncate" - Use the number of samples to truncate the wave data if the * fact chunk is present and valid. * - "strict" - Like "truncate", but raise an error if the fact chunk is * invalid, not present for non-PCM formats, or if the data chunk doesn't * have that many samples. * - "ignorezero" - Like "truncate", but ignore fact chunk if the number of * samples is zero. * - "ignore" - Ignore fact chunk entirely. (default) * * This hint should be set before calling SDL_LoadWAV() or SDL_LoadWAV_IO() * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_WAVE_FACT_CHUNK "SDL_WAVE_FACT_CHUNK" /** * A variable controlling the maximum number of chunks in a WAVE file. * * This sets an upper bound on the number of chunks in a WAVE file to avoid * wasting time on malformed or corrupt WAVE files. This defaults to "10000". * * This hint should be set before calling SDL_LoadWAV() or SDL_LoadWAV_IO() * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_WAVE_CHUNK_LIMIT "SDL_WAVE_CHUNK_LIMIT" /** * A variable controlling how the size of the RIFF chunk affects the loading * of a WAVE file. * * The size of the RIFF chunk (which includes all the sub-chunks of the WAVE * file) is not always reliable. In case the size is wrong, it's possible to * just ignore it and step through the chunks until a fixed limit is reached. * * Note that files that have trailing data unrelated to the WAVE file or * corrupt files may slow down the loading process without a reliable * boundary. By default, SDL stops after 10000 chunks to prevent wasting time. * Use SDL_HINT_WAVE_CHUNK_LIMIT to adjust this value. * * The variable can be set to the following values: * * - "force" - Always use the RIFF chunk size as a boundary for the chunk * search. * - "ignorezero" - Like "force", but a zero size searches up to 4 GiB. * (default) * - "ignore" - Ignore the RIFF chunk size and always search up to 4 GiB. * - "maximum" - Search for chunks until the end of file. (not recommended) * * This hint should be set before calling SDL_LoadWAV() or SDL_LoadWAV_IO() * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_WAVE_RIFF_CHUNK_SIZE "SDL_WAVE_RIFF_CHUNK_SIZE" /** * A variable controlling how a truncated WAVE file is handled. * * A WAVE file is considered truncated if any of the chunks are incomplete or * the data chunk size is not a multiple of the block size. By default, SDL * decodes until the first incomplete block, as most applications seem to do. * * The variable can be set to the following values: * * - "verystrict" - Raise an error if the file is truncated. * - "strict" - Like "verystrict", but the size of the RIFF chunk is ignored. * - "dropframe" - Decode until the first incomplete sample frame. * - "dropblock" - Decode until the first incomplete block. (default) * * This hint should be set before calling SDL_LoadWAV() or SDL_LoadWAV_IO() * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_WAVE_TRUNCATION "SDL_WAVE_TRUNCATION" /** * A variable controlling whether the window is activated when the * SDL_RaiseWindow function is called. * * The variable can be set to the following values: * * - "0": The window is not activated when the SDL_RaiseWindow function is * called. * - "1": The window is activated when the SDL_RaiseWindow function is called. * (default) * * This hint can be set anytime. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_WINDOW_ACTIVATE_WHEN_RAISED "SDL_WINDOW_ACTIVATE_WHEN_RAISED" /** * A variable controlling whether the window is activated when the * SDL_ShowWindow function is called. * * The variable can be set to the following values: * * - "0": The window is not activated when the SDL_ShowWindow function is * called. * - "1": The window is activated when the SDL_ShowWindow function is called. * (default) * * This hint can be set anytime. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_WINDOW_ACTIVATE_WHEN_SHOWN "SDL_WINDOW_ACTIVATE_WHEN_SHOWN" /** * If set to "0" then never set the top-most flag on an SDL Window even if the * application requests it. * * This is a debugging aid for developers and not expected to be used by end * users. * * The variable can be set to the following values: * * - "0": don't allow topmost * - "1": allow topmost (default) * * This hint can be set anytime. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_WINDOW_ALLOW_TOPMOST "SDL_WINDOW_ALLOW_TOPMOST" /** * A variable controlling whether the window frame and title bar are * interactive when the cursor is hidden. * * The variable can be set to the following values: * * - "0": The window frame is not interactive when the cursor is hidden (no * move, resize, etc). * - "1": The window frame is interactive when the cursor is hidden. (default) * * This hint can be set anytime. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_WINDOW_FRAME_USABLE_WHILE_CURSOR_HIDDEN "SDL_WINDOW_FRAME_USABLE_WHILE_CURSOR_HIDDEN" /** * A variable controlling whether SDL generates window-close events for Alt+F4 * on Windows. * * The variable can be set to the following values: * * - "0": SDL will only do normal key handling for Alt+F4. * - "1": SDL will generate a window-close event when it sees Alt+F4. * (default) * * This hint can be set anytime. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_WINDOWS_CLOSE_ON_ALT_F4 "SDL_WINDOWS_CLOSE_ON_ALT_F4" /** * A variable controlling whether menus can be opened with their keyboard * shortcut (Alt+mnemonic). * * If the mnemonics are enabled, then menus can be opened by pressing the Alt * key and the corresponding mnemonic (for example, Alt+F opens the File * menu). However, in case an invalid mnemonic is pressed, Windows makes an * audible beep to convey that nothing happened. This is true even if the * window has no menu at all! * * Because most SDL applications don't have menus, and some want to use the * Alt key for other purposes, SDL disables mnemonics (and the beeping) by * default. * * Note: This also affects keyboard events: with mnemonics enabled, when a * menu is opened from the keyboard, you will not receive a KEYUP event for * the mnemonic key, and *might* not receive one for Alt. * * The variable can be set to the following values: * * - "0": Alt+mnemonic does nothing, no beeping. (default) * - "1": Alt+mnemonic opens menus, invalid mnemonics produce a beep. * * This hint can be set anytime. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_WINDOWS_ENABLE_MENU_MNEMONICS "SDL_WINDOWS_ENABLE_MENU_MNEMONICS" /** * A variable controlling whether the windows message loop is processed by * SDL. * * The variable can be set to the following values: * * - "0": The window message loop is not run. * - "1": The window message loop is processed in SDL_PumpEvents(). (default) * * This hint can be set anytime. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_WINDOWS_ENABLE_MESSAGELOOP "SDL_WINDOWS_ENABLE_MESSAGELOOP" /** * A variable controlling whether GameInput is used for raw keyboard and mouse * on Windows. * * The variable can be set to the following values: * * - "0": GameInput is not used for raw keyboard and mouse events. (default) * - "1": GameInput is used for raw keyboard and mouse events, if available. * * This hint should be set before SDL is initialized. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_WINDOWS_GAMEINPUT "SDL_WINDOWS_GAMEINPUT" /** * A variable controlling whether raw keyboard events are used on Windows. * * The variable can be set to the following values: * * - "0": The Windows message loop is used for keyboard events. (default) * - "1": Low latency raw keyboard events are used. * * This hint can be set anytime. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_WINDOWS_RAW_KEYBOARD "SDL_WINDOWS_RAW_KEYBOARD" /** * A variable controlling whether or not the RIDEV_NOHOTKEYS flag is set when * enabling Windows raw keyboard events. * * This blocks any hotkeys that have been registered by applications from * having any effect beyond generating raw WM_INPUT events. * * This flag does not affect system-hotkeys like ALT-TAB or CTRL-ALT-DEL, but * does affect the Windows Logo key since it is a userland hotkey registered * by explorer.exe. * * The variable can be set to the following values: * * - "0": Hotkeys are not excluded. (default) * - "1": Hotkeys are excluded. * * This hint can be set anytime. * * \since This hint is available since SDL 3.4.0. */ #define SDL_HINT_WINDOWS_RAW_KEYBOARD_EXCLUDE_HOTKEYS "SDL_WINDOWS_RAW_KEYBOARD_EXCLUDE_HOTKEYS" /** * A variable controlling whether the RIDEV_INPUTSINK flag is set when * enabling Windows raw keyboard events. * * This enables the window to still receive input even if not in foreground. * * Focused windows that receive text input will still prevent input events from triggering. * * - "0": Input is not received when not in focus or foreground. (default) * - "1": Input will be received even when not in focus or foreground. * * This hint can be set anytime. * * \since This hint is available since SDL 3.4.4. */ #define SDL_HINT_WINDOWS_RAW_KEYBOARD_INPUTSINK "SDL_WINDOWS_RAW_KEYBOARD_INPUTSINK" /** * A variable controlling whether SDL uses Kernel Semaphores on Windows. * * Kernel Semaphores are inter-process and require a context switch on every * interaction. On Windows 8 and newer, the WaitOnAddress API is available. * Using that and atomics to implement semaphores increases performance. SDL * will fall back to Kernel Objects on older OS versions or if forced to by * this hint. * * The variable can be set to the following values: * * - "0": Use Atomics and WaitOnAddress API when available, otherwise fall * back to Kernel Objects. (default) * - "1": Force the use of Kernel Objects in all cases. * * This hint should be set before SDL is initialized. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_WINDOWS_FORCE_SEMAPHORE_KERNEL "SDL_WINDOWS_FORCE_SEMAPHORE_KERNEL" /** * A variable to specify custom icon resource id from RC file on Windows * platform. * * This hint should be set before SDL is initialized. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_WINDOWS_INTRESOURCE_ICON "SDL_WINDOWS_INTRESOURCE_ICON" /** * A variable to specify custom icon resource id from RC file on Windows * platform. * * This hint should be set before SDL is initialized. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_WINDOWS_INTRESOURCE_ICON_SMALL "SDL_WINDOWS_INTRESOURCE_ICON_SMALL" /** * A variable controlling whether SDL uses the D3D9Ex API introduced in * Windows Vista, instead of normal D3D9. * * Direct3D 9Ex contains changes to state management that can eliminate device * loss errors during scenarios like Alt+Tab or UAC prompts. D3D9Ex may * require some changes to your application to cope with the new behavior, so * this is disabled by default. * * For more information on Direct3D 9Ex, see: * * - https://docs.microsoft.com/en-us/windows/win32/direct3darticles/graphics-apis-in-windows-vista#direct3d-9ex * - https://docs.microsoft.com/en-us/windows/win32/direct3darticles/direct3d-9ex-improvements * * The variable can be set to the following values: * * - "0": Use the original Direct3D 9 API. (default) * - "1": Use the Direct3D 9Ex API on Vista and later (and fall back if D3D9Ex * is unavailable) * * This hint should be set before SDL is initialized. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_WINDOWS_USE_D3D9EX "SDL_WINDOWS_USE_D3D9EX" /** * A variable controlling whether SDL will clear the window contents when the * WM_ERASEBKGND message is received. * * The variable can be set to the following values: * * - "0"/"never": Never clear the window. * - "1"/"initial": Clear the window when the first WM_ERASEBKGND event fires. * (default) * - "2"/"always": Clear the window on every WM_ERASEBKGND event. * * This hint should be set before creating a window. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_WINDOWS_ERASE_BACKGROUND_MODE "SDL_WINDOWS_ERASE_BACKGROUND_MODE" /** * A variable controlling whether X11 windows are marked as override-redirect. * * If set, this _might_ increase framerate at the expense of the desktop not * working as expected. Override-redirect windows aren't noticed by the window * manager at all. * * You should probably only use this for fullscreen windows, and you probably * shouldn't even use it for that. But it's here if you want to try! * * The variable can be set to the following values: * * - "0": Do not mark the window as override-redirect. (default) * - "1": Mark the window as override-redirect. * * This hint should be set before creating a window. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_X11_FORCE_OVERRIDE_REDIRECT "SDL_X11_FORCE_OVERRIDE_REDIRECT" /** * A variable specifying the type of an X11 window. * * During SDL_CreateWindow, SDL uses the _NET_WM_WINDOW_TYPE X11 property to * report to the window manager the type of window it wants to create. This * might be set to various things if SDL_WINDOW_TOOLTIP or * SDL_WINDOW_POPUP_MENU, etc, were specified. For "normal" windows that * haven't set a specific type, this hint can be used to specify a custom * type. For example, a dock window might set this to * "_NET_WM_WINDOW_TYPE_DOCK". * * This hint should be set before creating a window. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_X11_WINDOW_TYPE "SDL_X11_WINDOW_TYPE" /** * Specify the XCB library to load for the X11 driver. * * The default is platform-specific, often "libX11-xcb.so.1". * * This hint should be set before initializing the video subsystem. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_X11_XCB_LIBRARY "SDL_X11_XCB_LIBRARY" /** * A variable controlling whether XInput should be used for controller * handling. * * The variable can be set to the following values: * * - "0": XInput is not enabled. * - "1": XInput is enabled. (default) * * This hint should be set before SDL is initialized. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_XINPUT_ENABLED "SDL_XINPUT_ENABLED" /** * A variable controlling response to SDL_assert failures. * * The variable can be set to the following case-sensitive values: * * - "abort": Program terminates immediately. * - "break": Program triggers a debugger breakpoint. * - "retry": Program reruns the SDL_assert's test again. * - "ignore": Program continues on, ignoring this assertion failure this * time. * - "always_ignore": Program continues on, ignoring this assertion failure * for the rest of the run. * * Note that SDL_SetAssertionHandler offers a programmatic means to deal with * assertion failures through a callback, and this hint is largely intended to * be used via environment variables by end users and automated tools. * * This hint should be set before an assertion failure is triggered and can be * changed at any time. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_ASSERT "SDL_ASSERT" /** * A variable controlling whether pen events should generate synthetic mouse * events. * * The variable can be set to the following values: * * - "0": Pen events will not generate mouse events. * - "1": Pen events will generate mouse events. (default) * * This hint can be set anytime. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_PEN_MOUSE_EVENTS "SDL_PEN_MOUSE_EVENTS" /** * A variable controlling whether pen events should generate synthetic touch * events. * * The variable can be set to the following values: * * - "0": Pen events will not generate touch events. * - "1": Pen events will generate touch events. (default) * * This hint can be set anytime. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_PEN_TOUCH_EVENTS "SDL_PEN_TOUCH_EVENTS" /** * An enumeration of hint priorities. * * \since This enum is available since SDL 3.2.0. */ typedef enum SDL_HintPriority { SDL_HINT_DEFAULT, SDL_HINT_NORMAL, SDL_HINT_OVERRIDE } SDL_HintPriority; /** * Set a hint with a specific priority. * * The priority controls the behavior when setting a hint that already has a * value. Hints will replace existing hints of their priority and lower. * Environment variables are considered to have override priority. * * \param name the hint to set. * \param value the value of the hint variable. * \param priority the SDL_HintPriority level for the hint. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetHint * \sa SDL_ResetHint * \sa SDL_SetHint */ extern SDL_DECLSPEC bool SDLCALL SDL_SetHintWithPriority(const char *name, const char *value, SDL_HintPriority priority); /** * Set a hint with normal priority. * * Hints will not be set if there is an existing override hint or environment * variable that takes precedence. You can use SDL_SetHintWithPriority() to * set the hint with override priority instead. * * \param name the hint to set. * \param value the value of the hint variable. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetHint * \sa SDL_ResetHint * \sa SDL_SetHintWithPriority */ extern SDL_DECLSPEC bool SDLCALL SDL_SetHint(const char *name, const char *value); /** * Reset a hint to the default value. * * This will reset a hint to the value of the environment variable, or NULL if * the environment isn't set. Callbacks will be called normally with this * change. * * \param name the hint to set. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_SetHint * \sa SDL_ResetHints */ extern SDL_DECLSPEC bool SDLCALL SDL_ResetHint(const char *name); /** * Reset all hints to the default values. * * This will reset all hints to the value of the associated environment * variable, or NULL if the environment isn't set. Callbacks will be called * normally with this change. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_ResetHint */ extern SDL_DECLSPEC void SDLCALL SDL_ResetHints(void); /** * Get the value of a hint. * * \param name the hint to query. * \returns the string value of a hint or NULL if the hint isn't set. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_SetHint * \sa SDL_SetHintWithPriority */ extern SDL_DECLSPEC const char *SDLCALL SDL_GetHint(const char *name); /** * Get the boolean value of a hint variable. * * \param name the name of the hint to get the boolean value from. * \param default_value the value to return if the hint does not exist. * \returns the boolean value of a hint or the provided default value if the * hint does not exist. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetHint * \sa SDL_SetHint */ extern SDL_DECLSPEC bool SDLCALL SDL_GetHintBoolean(const char *name, bool default_value); /** * A callback used to send notifications of hint value changes. * * This is called an initial time during SDL_AddHintCallback with the hint's * current value, and then again each time the hint's value changes. In the * initial call, the current value is in both `oldValue` and `newValue`. * * \param userdata what was passed as `userdata` to SDL_AddHintCallback(). * \param name what was passed as `name` to SDL_AddHintCallback(). * \param oldValue the previous hint value. * \param newValue the new value hint is to be set to. * * \threadsafety This callback is fired from whatever thread is setting a new * hint value. SDL holds a lock on the hint subsystem when * calling this callback. * * \since This datatype is available since SDL 3.2.0. * * \sa SDL_AddHintCallback */ typedef void(SDLCALL *SDL_HintCallback)(void *userdata, const char *name, const char *oldValue, const char *newValue); /** * Add a function to watch a particular hint. * * The callback function is called _during_ this function, to provide it an * initial value, and again each time the hint's value changes. * * \param name the hint to watch. * \param callback An SDL_HintCallback function that will be called when the * hint value changes. * \param userdata a pointer to pass to the callback function. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_RemoveHintCallback */ extern SDL_DECLSPEC bool SDLCALL SDL_AddHintCallback(const char *name, SDL_HintCallback callback, void *userdata); /** * Remove a function watching a particular hint. * * \param name the hint being watched. * \param callback an SDL_HintCallback function that will be called when the * hint value changes. * \param userdata a pointer being passed to the callback function. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_AddHintCallback */ extern SDL_DECLSPEC void SDLCALL SDL_RemoveHintCallback(const char *name, SDL_HintCallback callback, void *userdata); /* Ends C function definitions when using C++ */ #ifdef __cplusplus } #endif #include #endif /* SDL_hints_h_ */ ================================================ FILE: deps/include/SDL3/SDL_init.h ================================================ /* Simple DirectMedia Layer Copyright (C) 1997-2026 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ /** * # CategoryInit * * All SDL programs need to initialize the library before starting to work * with it. * * Almost everything can simply call SDL_Init() near startup, with a handful * of flags to specify subsystems to touch. These are here to make sure SDL * does not even attempt to touch low-level pieces of the operating system * that you don't intend to use. For example, you might be using SDL for video * and input but chose an external library for audio, and in this case you * would just need to leave off the `SDL_INIT_AUDIO` flag to make sure that * external library has complete control. * * Most apps, when terminating, should call SDL_Quit(). This will clean up * (nearly) everything that SDL might have allocated, and crucially, it'll * make sure that the display's resolution is back to what the user expects if * you had previously changed it for your game. * * SDL3 apps are strongly encouraged to call SDL_SetAppMetadata() at startup * to fill in details about the program. This is completely optional, but it * helps in small ways (we can provide an About dialog box for the macOS menu, * we can name the app in the system's audio mixer, etc). Those that want to * provide a _lot_ of information should look at the more-detailed * SDL_SetAppMetadataProperty(). */ #ifndef SDL_init_h_ #define SDL_init_h_ #include #include #include #include /* Set up for C function definitions, even when using C++ */ #ifdef __cplusplus extern "C" { #endif /* As of version 0.5, SDL is loaded dynamically into the application */ /** * Initialization flags for SDL_Init and/or SDL_InitSubSystem * * These are the flags which may be passed to SDL_Init(). You should specify * the subsystems which you will be using in your application. * * \since This datatype is available since SDL 3.2.0. * * \sa SDL_Init * \sa SDL_Quit * \sa SDL_InitSubSystem * \sa SDL_QuitSubSystem * \sa SDL_WasInit */ typedef Uint32 SDL_InitFlags; #define SDL_INIT_AUDIO 0x00000010u /**< `SDL_INIT_AUDIO` implies `SDL_INIT_EVENTS` */ #define SDL_INIT_VIDEO 0x00000020u /**< `SDL_INIT_VIDEO` implies `SDL_INIT_EVENTS`, should be initialized on the main thread */ #define SDL_INIT_JOYSTICK 0x00000200u /**< `SDL_INIT_JOYSTICK` implies `SDL_INIT_EVENTS` */ #define SDL_INIT_HAPTIC 0x00001000u #define SDL_INIT_GAMEPAD 0x00002000u /**< `SDL_INIT_GAMEPAD` implies `SDL_INIT_JOYSTICK` */ #define SDL_INIT_EVENTS 0x00004000u #define SDL_INIT_SENSOR 0x00008000u /**< `SDL_INIT_SENSOR` implies `SDL_INIT_EVENTS` */ #define SDL_INIT_CAMERA 0x00010000u /**< `SDL_INIT_CAMERA` implies `SDL_INIT_EVENTS` */ /** * Return values for optional main callbacks. * * Returning SDL_APP_SUCCESS or SDL_APP_FAILURE from SDL_AppInit, * SDL_AppEvent, or SDL_AppIterate will terminate the program and report * success/failure to the operating system. What that means is * platform-dependent. On Unix, for example, on success, the process error * code will be zero, and on failure it will be 1. This interface doesn't * allow you to return specific exit codes, just whether there was an error * generally or not. * * Returning SDL_APP_CONTINUE from these functions will let the app continue * to run. * * See * [Main callbacks in SDL3](https://wiki.libsdl.org/SDL3/README-main-functions#main-callbacks-in-sdl3) * for complete details. * * \since This enum is available since SDL 3.2.0. */ typedef enum SDL_AppResult { SDL_APP_CONTINUE, /**< Value that requests that the app continue from the main callbacks. */ SDL_APP_SUCCESS, /**< Value that requests termination with success from the main callbacks. */ SDL_APP_FAILURE /**< Value that requests termination with error from the main callbacks. */ } SDL_AppResult; /** * Function pointer typedef for SDL_AppInit. * * These are used by SDL_EnterAppMainCallbacks. This mechanism operates behind * the scenes for apps using the optional main callbacks. Apps that want to * use this should just implement SDL_AppInit directly. * * \param appstate a place where the app can optionally store a pointer for * future use. * \param argc the standard ANSI C main's argc; number of elements in `argv`. * \param argv the standard ANSI C main's argv; array of command line * arguments. * \returns SDL_APP_FAILURE to terminate with an error, SDL_APP_SUCCESS to * terminate with success, SDL_APP_CONTINUE to continue. * * \since This datatype is available since SDL 3.2.0. */ typedef SDL_AppResult (SDLCALL *SDL_AppInit_func)(void **appstate, int argc, char *argv[]); /** * Function pointer typedef for SDL_AppIterate. * * These are used by SDL_EnterAppMainCallbacks. This mechanism operates behind * the scenes for apps using the optional main callbacks. Apps that want to * use this should just implement SDL_AppIterate directly. * * \param appstate an optional pointer, provided by the app in SDL_AppInit. * \returns SDL_APP_FAILURE to terminate with an error, SDL_APP_SUCCESS to * terminate with success, SDL_APP_CONTINUE to continue. * * \since This datatype is available since SDL 3.2.0. */ typedef SDL_AppResult (SDLCALL *SDL_AppIterate_func)(void *appstate); /** * Function pointer typedef for SDL_AppEvent. * * These are used by SDL_EnterAppMainCallbacks. This mechanism operates behind * the scenes for apps using the optional main callbacks. Apps that want to * use this should just implement SDL_AppEvent directly. * * \param appstate an optional pointer, provided by the app in SDL_AppInit. * \param event the new event for the app to examine. * \returns SDL_APP_FAILURE to terminate with an error, SDL_APP_SUCCESS to * terminate with success, SDL_APP_CONTINUE to continue. * * \since This datatype is available since SDL 3.2.0. */ typedef SDL_AppResult (SDLCALL *SDL_AppEvent_func)(void *appstate, SDL_Event *event); /** * Function pointer typedef for SDL_AppQuit. * * These are used by SDL_EnterAppMainCallbacks. This mechanism operates behind * the scenes for apps using the optional main callbacks. Apps that want to * use this should just implement SDL_AppEvent directly. * * \param appstate an optional pointer, provided by the app in SDL_AppInit. * \param result the result code that terminated the app (success or failure). * * \since This datatype is available since SDL 3.2.0. */ typedef void (SDLCALL *SDL_AppQuit_func)(void *appstate, SDL_AppResult result); /** * Initialize the SDL library. * * SDL_Init() simply forwards to calling SDL_InitSubSystem(). Therefore, the * two may be used interchangeably. Though for readability of your code * SDL_InitSubSystem() might be preferred. * * The file I/O (for example: SDL_IOFromFile) and threading (SDL_CreateThread) * subsystems are initialized by default. Message boxes * (SDL_ShowSimpleMessageBox) also attempt to work without initializing the * video subsystem, in hopes of being useful in showing an error dialog when * SDL_Init fails. You must specifically initialize other subsystems if you * use them in your application. * * Logging (such as SDL_Log) works without initialization, too. * * `flags` may be any of the following OR'd together: * * - `SDL_INIT_AUDIO`: audio subsystem; automatically initializes the events * subsystem * - `SDL_INIT_VIDEO`: video subsystem; automatically initializes the events * subsystem, should be initialized on the main thread. * - `SDL_INIT_JOYSTICK`: joystick subsystem; automatically initializes the * events subsystem * - `SDL_INIT_HAPTIC`: haptic (force feedback) subsystem * - `SDL_INIT_GAMEPAD`: gamepad subsystem; automatically initializes the * joystick subsystem * - `SDL_INIT_EVENTS`: events subsystem * - `SDL_INIT_SENSOR`: sensor subsystem; automatically initializes the events * subsystem * - `SDL_INIT_CAMERA`: camera subsystem; automatically initializes the events * subsystem * * Subsystem initialization is ref-counted, you must call SDL_QuitSubSystem() * for each SDL_InitSubSystem() to correctly shutdown a subsystem manually (or * call SDL_Quit() to force shutdown). If a subsystem is already loaded then * this call will increase the ref-count and return. * * Consider reporting some basic metadata about your application before * calling SDL_Init, using either SDL_SetAppMetadata() or * SDL_SetAppMetadataProperty(). * * \param flags subsystem initialization flags. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_SetAppMetadata * \sa SDL_SetAppMetadataProperty * \sa SDL_InitSubSystem * \sa SDL_Quit * \sa SDL_SetMainReady * \sa SDL_WasInit */ extern SDL_DECLSPEC bool SDLCALL SDL_Init(SDL_InitFlags flags); /** * Compatibility function to initialize the SDL library. * * This function and SDL_Init() are interchangeable. * * \param flags any of the flags used by SDL_Init(); see SDL_Init for details. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_Init * \sa SDL_Quit * \sa SDL_QuitSubSystem */ extern SDL_DECLSPEC bool SDLCALL SDL_InitSubSystem(SDL_InitFlags flags); /** * Shut down specific SDL subsystems. * * You still need to call SDL_Quit() even if you close all open subsystems * with SDL_QuitSubSystem(). * * \param flags any of the flags used by SDL_Init(); see SDL_Init for details. * * \threadsafety This function is not thread safe. * * \since This function is available since SDL 3.2.0. * * \sa SDL_InitSubSystem * \sa SDL_Quit */ extern SDL_DECLSPEC void SDLCALL SDL_QuitSubSystem(SDL_InitFlags flags); /** * Get a mask of the specified subsystems which are currently initialized. * * \param flags any of the flags used by SDL_Init(); see SDL_Init for details. * \returns a mask of all initialized subsystems if `flags` is 0, otherwise it * returns the initialization status of the specified subsystems. * * \threadsafety This function is not thread safe. * * \since This function is available since SDL 3.2.0. * * \sa SDL_Init * \sa SDL_InitSubSystem */ extern SDL_DECLSPEC SDL_InitFlags SDLCALL SDL_WasInit(SDL_InitFlags flags); /** * Clean up all initialized subsystems. * * You should call this function even if you have already shutdown each * initialized subsystem with SDL_QuitSubSystem(). It is safe to call this * function even in the case of errors in initialization. * * You can use this function with atexit() to ensure that it is run when your * application is shutdown, but it is not wise to do this from a library or * other dynamically loaded code. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_Init * \sa SDL_QuitSubSystem */ extern SDL_DECLSPEC void SDLCALL SDL_Quit(void); /** * Return whether this is the main thread. * * On Apple platforms, the main thread is the thread that runs your program's * main() entry point. On other platforms, the main thread is the one that * calls SDL_Init(SDL_INIT_VIDEO), which should usually be the one that runs * your program's main() entry point. If you are using the main callbacks, * SDL_AppInit(), SDL_AppIterate(), and SDL_AppQuit() are all called on the * main thread. * * \returns true if this thread is the main thread, or false otherwise. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_RunOnMainThread */ extern SDL_DECLSPEC bool SDLCALL SDL_IsMainThread(void); /** * Callback run on the main thread. * * \param userdata an app-controlled pointer that is passed to the callback. * * \since This datatype is available since SDL 3.2.0. * * \sa SDL_RunOnMainThread */ typedef void (SDLCALL *SDL_MainThreadCallback)(void *userdata); /** * Call a function on the main thread during event processing. * * If this is called on the main thread, the callback is executed immediately. * If this is called on another thread, this callback is queued for execution * on the main thread during event processing. * * Be careful of deadlocks when using this functionality. You should not have * the main thread wait for the current thread while this function is being * called with `wait_complete` true. * * \param callback the callback to call on the main thread. * \param userdata a pointer that is passed to `callback`. * \param wait_complete true to wait for the callback to complete, false to * return immediately. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_IsMainThread */ extern SDL_DECLSPEC bool SDLCALL SDL_RunOnMainThread(SDL_MainThreadCallback callback, void *userdata, bool wait_complete); /** * Specify basic metadata about your app. * * You can optionally provide metadata about your app to SDL. This is not * required, but strongly encouraged. * * There are several locations where SDL can make use of metadata (an "About" * box in the macOS menu bar, the name of the app can be shown on some audio * mixers, etc). Any piece of metadata can be left as NULL, if a specific * detail doesn't make sense for the app. * * This function should be called as early as possible, before SDL_Init. * Multiple calls to this function are allowed, but various state might not * change once it has been set up with a previous call to this function. * * Passing a NULL removes any previous metadata. * * This is a simplified interface for the most important information. You can * supply significantly more detailed metadata with * SDL_SetAppMetadataProperty(). * * \param appname The name of the application ("My Game 2: Bad Guy's * Revenge!"). * \param appversion The version of the application ("1.0.0beta5" or a git * hash, or whatever makes sense). * \param appidentifier A unique string in reverse-domain format that * identifies this app ("com.example.mygame2"). * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_SetAppMetadataProperty */ extern SDL_DECLSPEC bool SDLCALL SDL_SetAppMetadata(const char *appname, const char *appversion, const char *appidentifier); /** * Specify metadata about your app through a set of properties. * * You can optionally provide metadata about your app to SDL. This is not * required, but strongly encouraged. * * There are several locations where SDL can make use of metadata (an "About" * box in the macOS menu bar, the name of the app can be shown on some audio * mixers, etc). Any piece of metadata can be left out, if a specific detail * doesn't make sense for the app. * * This function should be called as early as possible, before SDL_Init. * Multiple calls to this function are allowed, but various state might not * change once it has been set up with a previous call to this function. * * Once set, this metadata can be read using SDL_GetAppMetadataProperty(). * * These are the supported properties: * * - `SDL_PROP_APP_METADATA_NAME_STRING`: The human-readable name of the * application, like "My Game 2: Bad Guy's Revenge!". This will show up * anywhere the OS shows the name of the application separately from window * titles, such as volume control applets, etc. This defaults to "SDL * Application". * - `SDL_PROP_APP_METADATA_VERSION_STRING`: The version of the app that is * running; there are no rules on format, so "1.0.3beta2" and "April 22nd, * 2024" and a git hash are all valid options. This has no default. * - `SDL_PROP_APP_METADATA_IDENTIFIER_STRING`: A unique string that * identifies this app. This must be in reverse-domain format, like * "com.example.mygame2". This string is used by desktop compositors to * identify and group windows together, as well as match applications with * associated desktop settings and icons. If you plan to package your * application in a container such as Flatpak, the app ID should match the * name of your Flatpak container as well. This has no default. * - `SDL_PROP_APP_METADATA_CREATOR_STRING`: The human-readable name of the * creator/developer/maker of this app, like "MojoWorkshop, LLC" * - `SDL_PROP_APP_METADATA_COPYRIGHT_STRING`: The human-readable copyright * notice, like "Copyright (c) 2024 MojoWorkshop, LLC" or whatnot. Keep this * to one line, don't paste a copy of a whole software license in here. This * has no default. * - `SDL_PROP_APP_METADATA_URL_STRING`: A URL to the app on the web. Maybe a * product page, or a storefront, or even a GitHub repository, for user's * further information This has no default. * - `SDL_PROP_APP_METADATA_TYPE_STRING`: The type of application this is. * Currently this string can be "game" for a video game, "mediaplayer" for a * media player, or generically "application" if nothing else applies. * Future versions of SDL might add new types. This defaults to * "application". * * \param name the name of the metadata property to set. * \param value the value of the property, or NULL to remove that property. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetAppMetadataProperty * \sa SDL_SetAppMetadata */ extern SDL_DECLSPEC bool SDLCALL SDL_SetAppMetadataProperty(const char *name, const char *value); #define SDL_PROP_APP_METADATA_NAME_STRING "SDL.app.metadata.name" #define SDL_PROP_APP_METADATA_VERSION_STRING "SDL.app.metadata.version" #define SDL_PROP_APP_METADATA_IDENTIFIER_STRING "SDL.app.metadata.identifier" #define SDL_PROP_APP_METADATA_CREATOR_STRING "SDL.app.metadata.creator" #define SDL_PROP_APP_METADATA_COPYRIGHT_STRING "SDL.app.metadata.copyright" #define SDL_PROP_APP_METADATA_URL_STRING "SDL.app.metadata.url" #define SDL_PROP_APP_METADATA_TYPE_STRING "SDL.app.metadata.type" /** * Get metadata about your app. * * This returns metadata previously set using SDL_SetAppMetadata() or * SDL_SetAppMetadataProperty(). See SDL_SetAppMetadataProperty() for the list * of available properties and their meanings. * * \param name the name of the metadata property to get. * \returns the current value of the metadata property, or the default if it * is not set, NULL for properties with no default. * * \threadsafety It is safe to call this function from any thread, although * the string returned is not protected and could potentially be * freed if you call SDL_SetAppMetadataProperty() to set that * property from another thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_SetAppMetadata * \sa SDL_SetAppMetadataProperty */ extern SDL_DECLSPEC const char * SDLCALL SDL_GetAppMetadataProperty(const char *name); /* Ends C function definitions when using C++ */ #ifdef __cplusplus } #endif #include #endif /* SDL_init_h_ */ ================================================ FILE: deps/include/SDL3/SDL_intrin.h ================================================ /* Simple DirectMedia Layer Copyright (C) 1997-2026 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ /* WIKI CATEGORY: Intrinsics */ /** * # CategoryIntrinsics * * SDL does some preprocessor gymnastics to determine if any CPU-specific * compiler intrinsics are available, as this is not necessarily an easy thing * to calculate, and sometimes depends on quirks of a system, versions of * build tools, and other external forces. * * Apps including SDL's headers will be able to check consistent preprocessor * definitions to decide if it's safe to use compiler intrinsics for a * specific CPU architecture. This check only tells you that the compiler is * capable of using those intrinsics; at runtime, you should still check if * they are available on the current system with the * [CPU info functions](https://wiki.libsdl.org/SDL3/CategoryCPUInfo) * , such as SDL_HasSSE() or SDL_HasNEON(). Otherwise, the process might crash * for using an unsupported CPU instruction. * * SDL only sets preprocessor defines for CPU intrinsics if they are * supported, so apps should check with `#ifdef` and not `#if`. * * SDL will also include the appropriate instruction-set-specific support * headers, so if SDL decides to define SDL_SSE2_INTRINSICS, it will also * `#include ` as well. */ #ifndef SDL_intrin_h_ #define SDL_intrin_h_ #include #ifdef SDL_WIKI_DOCUMENTATION_SECTION /** * Defined if (and only if) the compiler supports Loongarch LSX intrinsics. * * If this macro is defined, SDL will have already included `` * * \since This macro is available since SDL 3.2.0. * * \sa SDL_LASX_INTRINSICS */ #define SDL_LSX_INTRINSICS 1 /** * Defined if (and only if) the compiler supports Loongarch LSX intrinsics. * * If this macro is defined, SDL will have already included `` * * \since This macro is available since SDL 3.2.0. * * \sa SDL_LASX_INTRINSICS */ #define SDL_LASX_INTRINSICS 1 /** * Defined if (and only if) the compiler supports ARM NEON intrinsics. * * If this macro is defined, SDL will have already included `` * ``, ``, and ``, as appropriate. * * \since This macro is available since SDL 3.2.0. */ #define SDL_NEON_INTRINSICS 1 /** * Defined if (and only if) the compiler supports PowerPC Altivec intrinsics. * * If this macro is defined, SDL will have already included `` * * \since This macro is available since SDL 3.2.0. */ #define SDL_ALTIVEC_INTRINSICS 1 /** * Defined if (and only if) the compiler supports Intel MMX intrinsics. * * If this macro is defined, SDL will have already included `` * * \since This macro is available since SDL 3.2.0. * * \sa SDL_SSE_INTRINSICS */ #define SDL_MMX_INTRINSICS 1 /** * Defined if (and only if) the compiler supports Intel SSE intrinsics. * * If this macro is defined, SDL will have already included `` * * \since This macro is available since SDL 3.2.0. * * \sa SDL_SSE2_INTRINSICS * \sa SDL_SSE3_INTRINSICS * \sa SDL_SSE4_1_INTRINSICS * \sa SDL_SSE4_2_INTRINSICS */ #define SDL_SSE_INTRINSICS 1 /** * Defined if (and only if) the compiler supports Intel SSE2 intrinsics. * * If this macro is defined, SDL will have already included `` * * \since This macro is available since SDL 3.2.0. * * \sa SDL_SSE_INTRINSICS * \sa SDL_SSE3_INTRINSICS * \sa SDL_SSE4_1_INTRINSICS * \sa SDL_SSE4_2_INTRINSICS */ #define SDL_SSE2_INTRINSICS 1 /** * Defined if (and only if) the compiler supports Intel SSE3 intrinsics. * * If this macro is defined, SDL will have already included `` * * \since This macro is available since SDL 3.2.0. * * \sa SDL_SSE_INTRINSICS * \sa SDL_SSE2_INTRINSICS * \sa SDL_SSE4_1_INTRINSICS * \sa SDL_SSE4_2_INTRINSICS */ #define SDL_SSE3_INTRINSICS 1 /** * Defined if (and only if) the compiler supports Intel SSE4.1 intrinsics. * * If this macro is defined, SDL will have already included `` * * \since This macro is available since SDL 3.2.0. * * \sa SDL_SSE_INTRINSICS * \sa SDL_SSE2_INTRINSICS * \sa SDL_SSE3_INTRINSICS * \sa SDL_SSE4_2_INTRINSICS */ #define SDL_SSE4_1_INTRINSICS 1 /** * Defined if (and only if) the compiler supports Intel SSE4.2 intrinsics. * * If this macro is defined, SDL will have already included `` * * \since This macro is available since SDL 3.2.0. * * \sa SDL_SSE_INTRINSICS * \sa SDL_SSE2_INTRINSICS * \sa SDL_SSE3_INTRINSICS * \sa SDL_SSE4_1_INTRINSICS */ #define SDL_SSE4_2_INTRINSICS 1 /** * Defined if (and only if) the compiler supports Intel AVX intrinsics. * * If this macro is defined, SDL will have already included `` * * \since This macro is available since SDL 3.2.0. * * \sa SDL_AVX2_INTRINSICS * \sa SDL_AVX512F_INTRINSICS */ #define SDL_AVX_INTRINSICS 1 /** * Defined if (and only if) the compiler supports Intel AVX2 intrinsics. * * If this macro is defined, SDL will have already included `` * * \since This macro is available since SDL 3.2.0. * * \sa SDL_AVX_INTRINSICS * \sa SDL_AVX512F_INTRINSICS */ #define SDL_AVX2_INTRINSICS 1 /** * Defined if (and only if) the compiler supports Intel AVX-512F intrinsics. * * AVX-512F is also sometimes referred to as "AVX-512 Foundation." * * If this macro is defined, SDL will have already included `` * * \since This macro is available since SDL 3.2.0. * * \sa SDL_AVX_INTRINSICS * \sa SDL_AVX2_INTRINSICS */ #define SDL_AVX512F_INTRINSICS 1 #endif /* Need to do this here because intrin.h has C++ code in it */ /* Visual Studio 2005 has a bug where intrin.h conflicts with winnt.h */ #if defined(_MSC_VER) && (_MSC_VER >= 1500) && (defined(_M_IX86) || defined(_M_X64)) /* As of Clang 11, '_m_prefetchw' is conflicting with the winnt.h's version, so we define the needed '_m_prefetch' here as a pseudo-header, until the issue is fixed. */ #if defined(__clang__) && !SDL_HAS_BUILTIN(_m_prefetch) #ifndef __PRFCHWINTRIN_H #define __PRFCHWINTRIN_H static __inline__ void __attribute__((__always_inline__, __nodebug__)) _m_prefetch(void *__P) { __builtin_prefetch (__P, 0, 3 /* _MM_HINT_T0 */); } #endif /* __PRFCHWINTRIN_H */ #endif /* __clang__ */ #include #elif defined(__MINGW64_VERSION_MAJOR) #include #if defined(__ARM_NEON) && !defined(SDL_DISABLE_NEON) # define SDL_NEON_INTRINSICS 1 # include #endif #else /* altivec.h redefining bool causes a number of problems, see bugs 3993 and 4392, so you need to explicitly define SDL_ENABLE_ALTIVEC to have it included. */ #if defined(__ALTIVEC__) && defined(SDL_ENABLE_ALTIVEC) #define SDL_ALTIVEC_INTRINSICS 1 #include #endif #ifndef SDL_DISABLE_NEON # ifdef __ARM_NEON # define SDL_NEON_INTRINSICS 1 # include # elif defined(SDL_PLATFORM_WINDOWS) /* Visual Studio doesn't define __ARM_ARCH, but _M_ARM (if set, always 7), and _M_ARM64 (if set, always 1). */ # ifdef _M_ARM # define SDL_NEON_INTRINSICS 1 # include # include # define __ARM_NEON 1 /* Set __ARM_NEON so that it can be used elsewhere, at compile time */ # endif # if defined (_M_ARM64) # define SDL_NEON_INTRINSICS 1 # include # include # define __ARM_NEON 1 /* Set __ARM_NEON so that it can be used elsewhere, at compile time */ # define __ARM_ARCH 8 # endif # endif #endif #endif /* compiler version */ #ifdef SDL_WIKI_DOCUMENTATION_SECTION /** * A macro to decide if the compiler supports `__attribute__((target))`. * * Even though this is defined in SDL's public headers, it is generally not * used directly by apps. Apps should probably just use SDL_TARGETING * directly, instead. * * \since This macro is available since SDL 3.2.0. * * \sa SDL_TARGETING */ #define SDL_HAS_TARGET_ATTRIBS #elif defined(__loongarch64) && defined(__GNUC__) && (__GNUC__ >= 15) /* LoongArch requires GCC 15+ for target attribute support */ # define SDL_HAS_TARGET_ATTRIBS #elif defined(__clang__) && defined(__has_attribute) # if __has_attribute(target) # define SDL_HAS_TARGET_ATTRIBS # endif #elif defined(__GNUC__) && !defined(__loongarch64) && (__GNUC__ + (__GNUC_MINOR__ >= 9) > 4) /* gcc >= 4.9 */ # define SDL_HAS_TARGET_ATTRIBS #elif defined(__ICC) && __ICC >= 1600 # define SDL_HAS_TARGET_ATTRIBS #endif #ifdef SDL_WIKI_DOCUMENTATION_SECTION /** * A macro to tag a function as targeting a specific CPU architecture. * * This is a hint to the compiler that a function should be built with support * for a CPU instruction set that might be different than the rest of the * program. * * The particulars of this are explained in the GCC documentation: * * https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-target-function-attribute * * An example of using this feature is to turn on SSE2 support for a specific * function, even if the rest of the source code is not compiled to use SSE2 * code: * * ```c * #ifdef SDL_SSE2_INTRINSICS * static void SDL_TARGETING("sse2") DoSomethingWithSSE2(char *x) { * ...use SSE2 intrinsic functions, etc... * } * #endif * * // later... * #ifdef SDL_SSE2_INTRINSICS * if (SDL_HasSSE2()) { * DoSomethingWithSSE2(str); * } * #endif * ``` * * The application is, on a whole, built without SSE2 instructions, so it will * run on Intel machines that don't support SSE2. But then at runtime, it * checks if the system supports the instructions, and then calls into a * function that uses SSE2 opcodes. The ifdefs make sure that this code isn't * used on platforms that don't have SSE2 at all. * * On compilers without target support, this is defined to nothing. * * This symbol is used by SDL internally, but apps and other libraries are * welcome to use it for their own interfaces as well. * * \since This macro is available since SDL 3.2.0. */ #define SDL_TARGETING(x) __attribute__((target(x))) #elif defined(SDL_HAS_TARGET_ATTRIBS) # define SDL_TARGETING(x) __attribute__((target(x))) #else # define SDL_TARGETING(x) #endif #ifdef __loongarch64 # ifndef SDL_DISABLE_LSX # define SDL_LSX_INTRINSICS 1 # include # endif # ifndef SDL_DISABLE_LASX # define SDL_LASX_INTRINSICS 1 # include # endif #endif #if defined(__x86_64__) || defined(_M_X64) || defined(__i386__) || defined(_M_IX86) # if ((defined(_MSC_VER) && !defined(_M_X64)) || defined(__MMX__) || defined(SDL_HAS_TARGET_ATTRIBS)) && !defined(SDL_DISABLE_MMX) # define SDL_MMX_INTRINSICS 1 # include # endif # if (defined(_MSC_VER) || defined(__SSE__) || defined(SDL_HAS_TARGET_ATTRIBS)) && !defined(SDL_DISABLE_SSE) # define SDL_SSE_INTRINSICS 1 # include # endif # if (defined(_MSC_VER) || defined(__SSE2__) || defined(SDL_HAS_TARGET_ATTRIBS)) && !defined(SDL_DISABLE_SSE2) # define SDL_SSE2_INTRINSICS 1 # include # endif # if (defined(_MSC_VER) || defined(__SSE3__) || defined(SDL_HAS_TARGET_ATTRIBS)) && !defined(SDL_DISABLE_SSE3) # define SDL_SSE3_INTRINSICS 1 # include # endif # if (defined(_MSC_VER) || defined(__SSE4_1__) || defined(SDL_HAS_TARGET_ATTRIBS)) && !defined(SDL_DISABLE_SSE4_1) # define SDL_SSE4_1_INTRINSICS 1 # include # endif # if (defined(_MSC_VER) || defined(__SSE4_2__) || defined(SDL_HAS_TARGET_ATTRIBS)) && !defined(SDL_DISABLE_SSE4_2) # define SDL_SSE4_2_INTRINSICS 1 # include # endif # if defined(__clang__) && (defined(_MSC_VER) || defined(__SCE__)) && !defined(__AVX__) && !defined(SDL_DISABLE_AVX) # define SDL_DISABLE_AVX /* see https://reviews.llvm.org/D20291 and https://reviews.llvm.org/D79194 */ # endif # if (defined(_MSC_VER) || defined(__AVX__) || defined(SDL_HAS_TARGET_ATTRIBS)) && !defined(_M_ARM64EC) && !defined(SDL_DISABLE_AVX) # define SDL_AVX_INTRINSICS 1 # include # endif # if defined(__clang__) && (defined(_MSC_VER) || defined(__SCE__)) && !defined(__AVX2__) && !defined(SDL_DISABLE_AVX2) # define SDL_DISABLE_AVX2 /* see https://reviews.llvm.org/D20291 and https://reviews.llvm.org/D79194 */ # endif # if (defined(_MSC_VER) || defined(__AVX2__) || defined(SDL_HAS_TARGET_ATTRIBS)) && !defined(_M_ARM64EC) && !defined(SDL_DISABLE_AVX2) # define SDL_AVX2_INTRINSICS 1 # include # endif # if defined(__clang__) && (defined(_MSC_VER) || defined(__SCE__)) && !defined(__AVX512F__) && !defined(SDL_DISABLE_AVX512F) # define SDL_DISABLE_AVX512F /* see https://reviews.llvm.org/D20291 and https://reviews.llvm.org/D79194 */ # endif # if (defined(_MSC_VER) || defined(__AVX512F__) || defined(SDL_HAS_TARGET_ATTRIBS)) && !defined(_M_ARM64EC) && !defined(SDL_DISABLE_AVX512F) # define SDL_AVX512F_INTRINSICS 1 # include # endif #endif /* defined(__x86_64__) || defined(_M_X64) || defined(__i386__) || defined(_M_IX86) */ #endif /* SDL_intrin_h_ */ ================================================ FILE: deps/include/SDL3/SDL_iostream.h ================================================ /* Simple DirectMedia Layer Copyright (C) 1997-2026 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ /* WIKI CATEGORY: IOStream */ /** * # CategoryIOStream * * SDL provides an abstract interface for reading and writing data streams. It * offers implementations for files, memory, etc, and the app can provide * their own implementations, too. * * SDL_IOStream is not related to the standard C++ iostream class, other than * both are abstract interfaces to read/write data. */ #ifndef SDL_iostream_h_ #define SDL_iostream_h_ #include #include #include #include /* Set up for C function definitions, even when using C++ */ #ifdef __cplusplus extern "C" { #endif /** * SDL_IOStream status, set by a read or write operation. * * \since This enum is available since SDL 3.2.0. */ typedef enum SDL_IOStatus { SDL_IO_STATUS_READY, /**< Everything is ready (no errors and not EOF). */ SDL_IO_STATUS_ERROR, /**< Read or write I/O error */ SDL_IO_STATUS_EOF, /**< End of file */ SDL_IO_STATUS_NOT_READY, /**< Non blocking I/O, not ready */ SDL_IO_STATUS_READONLY, /**< Tried to write a read-only buffer */ SDL_IO_STATUS_WRITEONLY /**< Tried to read a write-only buffer */ } SDL_IOStatus; /** * Possible `whence` values for SDL_IOStream seeking. * * These map to the same "whence" concept that `fseek` or `lseek` use in the * standard C runtime. * * \since This enum is available since SDL 3.2.0. */ typedef enum SDL_IOWhence { SDL_IO_SEEK_SET, /**< Seek from the beginning of data */ SDL_IO_SEEK_CUR, /**< Seek relative to current read point */ SDL_IO_SEEK_END /**< Seek relative to the end of data */ } SDL_IOWhence; /** * The function pointers that drive an SDL_IOStream. * * Applications can provide this struct to SDL_OpenIO() to create their own * implementation of SDL_IOStream. This is not necessarily required, as SDL * already offers several common types of I/O streams, via functions like * SDL_IOFromFile() and SDL_IOFromMem(). * * This structure should be initialized using SDL_INIT_INTERFACE() * * \since This struct is available since SDL 3.2.0. * * \sa SDL_INIT_INTERFACE */ typedef struct SDL_IOStreamInterface { /* The version of this interface */ Uint32 version; /** * Return the number of bytes in this SDL_IOStream * * \return the total size of the data stream, or -1 on error. */ Sint64 (SDLCALL *size)(void *userdata); /** * Seek to `offset` relative to `whence`, one of stdio's whence values: * SDL_IO_SEEK_SET, SDL_IO_SEEK_CUR, SDL_IO_SEEK_END * * \return the final offset in the data stream, or -1 on error. */ Sint64 (SDLCALL *seek)(void *userdata, Sint64 offset, SDL_IOWhence whence); /** * Read up to `size` bytes from the data stream to the area pointed * at by `ptr`. `size` will always be > 0. * * On an incomplete read, you should set `*status` to a value from the * SDL_IOStatus enum. You do not have to explicitly set this on * a complete, successful read. * * \return the number of bytes read */ size_t (SDLCALL *read)(void *userdata, void *ptr, size_t size, SDL_IOStatus *status); /** * Write exactly `size` bytes from the area pointed at by `ptr` * to data stream. `size` will always be > 0. * * On an incomplete write, you should set `*status` to a value from the * SDL_IOStatus enum. You do not have to explicitly set this on * a complete, successful write. * * \return the number of bytes written */ size_t (SDLCALL *write)(void *userdata, const void *ptr, size_t size, SDL_IOStatus *status); /** * If the stream is buffering, make sure the data is written out. * * On failure, you should set `*status` to a value from the * SDL_IOStatus enum. You do not have to explicitly set this on * a successful flush. * * \return true if successful or false on write error when flushing data. */ bool (SDLCALL *flush)(void *userdata, SDL_IOStatus *status); /** * Close and free any allocated resources. * * This does not guarantee file writes will sync to physical media; they * can be in the system's file cache, waiting to go to disk. * * The SDL_IOStream is still destroyed even if this fails, so clean up anything * even if flushing buffers, etc, returns an error. * * \return true if successful or false on write error when flushing data. */ bool (SDLCALL *close)(void *userdata); } SDL_IOStreamInterface; /* Check the size of SDL_IOStreamInterface * * If this assert fails, either the compiler is padding to an unexpected size, * or the interface has been updated and this should be updated to match and * the code using this interface should be updated to handle the old version. */ SDL_COMPILE_TIME_ASSERT(SDL_IOStreamInterface_SIZE, (sizeof(void *) == 4 && sizeof(SDL_IOStreamInterface) == 28) || (sizeof(void *) == 8 && sizeof(SDL_IOStreamInterface) == 56)); /** * The read/write operation structure. * * This operates as an opaque handle. There are several APIs to create various * types of I/O streams, or an app can supply an SDL_IOStreamInterface to * SDL_OpenIO() to provide their own stream implementation behind this * struct's abstract interface. * * \since This struct is available since SDL 3.2.0. */ typedef struct SDL_IOStream SDL_IOStream; /** * \name IOFrom functions * * Functions to create SDL_IOStream structures from various data streams. */ /* @{ */ /** * Use this function to create a new SDL_IOStream structure for reading from * and/or writing to a named file. * * The `mode` string is treated roughly the same as in a call to the C * library's fopen(), even if SDL doesn't happen to use fopen() behind the * scenes. * * Available `mode` strings: * * - "r": Open a file for reading. The file must exist. * - "w": Create an empty file for writing. If a file with the same name * already exists its content is erased and the file is treated as a new * empty file. * - "wx": Create an empty file for writing. If a file with the same name * already exists, the call fails. * - "a": Append to a file. Writing operations append data at the end of the * file. The file is created if it does not exist. * - "r+": Open a file for update both reading and writing. The file must * exist. * - "w+": Create an empty file for both reading and writing. If a file with * the same name already exists its content is erased and the file is * treated as a new empty file. * - "w+x": Create an empty file for both reading and writing. If a file with * the same name already exists, the call fails. * - "a+": Open a file for reading and appending. All writing operations are * performed at the end of the file, protecting the previous content to be * overwritten. You can reposition (fseek, rewind) the internal pointer to * anywhere in the file for reading, but writing operations will move it * back to the end of file. The file is created if it does not exist. * * **NOTE**: In order to open a file as a binary file, a "b" character has to * be included in the `mode` string. This additional "b" character can either * be appended at the end of the string (thus making the following compound * modes: "rb", "wb", "ab", "r+b", "w+b", "a+b") or be inserted between the * letter and the "+" sign for the mixed modes ("rb+", "wb+", "ab+"). * Additional characters may follow the sequence, although they should have no * effect. For example, "t" is sometimes appended to make explicit the file is * a text file. * * This function supports Unicode filenames, but they must be encoded in UTF-8 * format, regardless of the underlying operating system. * * In Android, SDL_IOFromFile() can be used to open content:// URIs. As a * fallback, SDL_IOFromFile() will transparently open a matching filename in * the app's `assets`. * * Closing the SDL_IOStream will close SDL's internal file handle. * * The following properties may be set at creation time by SDL: * * - `SDL_PROP_IOSTREAM_WINDOWS_HANDLE_POINTER`: a pointer, that can be cast * to a win32 `HANDLE`, that this SDL_IOStream is using to access the * filesystem. If the program isn't running on Windows, or SDL used some * other method to access the filesystem, this property will not be set. * - `SDL_PROP_IOSTREAM_STDIO_FILE_POINTER`: a pointer, that can be cast to a * stdio `FILE *`, that this SDL_IOStream is using to access the filesystem. * If SDL used some other method to access the filesystem, this property * will not be set. PLEASE NOTE that if SDL is using a different C runtime * than your app, trying to use this pointer will almost certainly result in * a crash! This is mostly a problem on Windows; make sure you build SDL and * your app with the same compiler and settings to avoid it. * - `SDL_PROP_IOSTREAM_FILE_DESCRIPTOR_NUMBER`: a file descriptor that this * SDL_IOStream is using to access the filesystem. * - `SDL_PROP_IOSTREAM_ANDROID_AASSET_POINTER`: a pointer, that can be cast * to an Android NDK `AAsset *`, that this SDL_IOStream is using to access * the filesystem. If SDL used some other method to access the filesystem, * this property will not be set. * * \param file a UTF-8 string representing the filename to open. * \param mode an ASCII string representing the mode to be used for opening * the file. * \returns a pointer to the SDL_IOStream structure that is created or NULL on * failure; call SDL_GetError() for more information. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_CloseIO * \sa SDL_FlushIO * \sa SDL_ReadIO * \sa SDL_SeekIO * \sa SDL_TellIO * \sa SDL_WriteIO */ extern SDL_DECLSPEC SDL_IOStream * SDLCALL SDL_IOFromFile(const char *file, const char *mode); #define SDL_PROP_IOSTREAM_WINDOWS_HANDLE_POINTER "SDL.iostream.windows.handle" #define SDL_PROP_IOSTREAM_STDIO_FILE_POINTER "SDL.iostream.stdio.file" #define SDL_PROP_IOSTREAM_FILE_DESCRIPTOR_NUMBER "SDL.iostream.file_descriptor" #define SDL_PROP_IOSTREAM_ANDROID_AASSET_POINTER "SDL.iostream.android.aasset" /** * Use this function to prepare a read-write memory buffer for use with * SDL_IOStream. * * This function sets up an SDL_IOStream struct based on a memory area of a * certain size, for both read and write access. * * This memory buffer is not copied by the SDL_IOStream; the pointer you * provide must remain valid until you close the stream. * * If you need to make sure the SDL_IOStream never writes to the memory * buffer, you should use SDL_IOFromConstMem() with a read-only buffer of * memory instead. * * The following properties will be set at creation time by SDL: * * - `SDL_PROP_IOSTREAM_MEMORY_POINTER`: this will be the `mem` parameter that * was passed to this function. * - `SDL_PROP_IOSTREAM_MEMORY_SIZE_NUMBER`: this will be the `size` parameter * that was passed to this function. * * Additionally, the following properties are recognized: * * - `SDL_PROP_IOSTREAM_MEMORY_FREE_FUNC_POINTER`: if this property is set to * a non-NULL value it will be interpreted as a function of SDL_free_func * type and called with the passed `mem` pointer when closing the stream. By * default it is unset, i.e., the memory will not be freed. * * \param mem a pointer to a buffer to feed an SDL_IOStream stream. * \param size the buffer size, in bytes. * \returns a pointer to a new SDL_IOStream structure or NULL on failure; call * SDL_GetError() for more information. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_IOFromConstMem * \sa SDL_CloseIO * \sa SDL_FlushIO * \sa SDL_ReadIO * \sa SDL_SeekIO * \sa SDL_TellIO * \sa SDL_WriteIO */ extern SDL_DECLSPEC SDL_IOStream * SDLCALL SDL_IOFromMem(void *mem, size_t size); #define SDL_PROP_IOSTREAM_MEMORY_POINTER "SDL.iostream.memory.base" #define SDL_PROP_IOSTREAM_MEMORY_SIZE_NUMBER "SDL.iostream.memory.size" #define SDL_PROP_IOSTREAM_MEMORY_FREE_FUNC_POINTER "SDL.iostream.memory.free" /** * Use this function to prepare a read-only memory buffer for use with * SDL_IOStream. * * This function sets up an SDL_IOStream struct based on a memory area of a * certain size. It assumes the memory area is not writable. * * Attempting to write to this SDL_IOStream stream will report an error * without writing to the memory buffer. * * This memory buffer is not copied by the SDL_IOStream; the pointer you * provide must remain valid until you close the stream. * * If you need to write to a memory buffer, you should use SDL_IOFromMem() * with a writable buffer of memory instead. * * The following properties will be set at creation time by SDL: * * - `SDL_PROP_IOSTREAM_MEMORY_POINTER`: this will be the `mem` parameter that * was passed to this function. * - `SDL_PROP_IOSTREAM_MEMORY_SIZE_NUMBER`: this will be the `size` parameter * that was passed to this function. * * Additionally, the following properties are recognized: * * - `SDL_PROP_IOSTREAM_MEMORY_FREE_FUNC_POINTER`: if this property is set to * a non-NULL value it will be interpreted as a function of SDL_free_func * type and called with the passed `mem` pointer when closing the stream. By * default it is unset, i.e., the memory will not be freed. * * \param mem a pointer to a read-only buffer to feed an SDL_IOStream stream. * \param size the buffer size, in bytes. * \returns a pointer to a new SDL_IOStream structure or NULL on failure; call * SDL_GetError() for more information. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_IOFromMem * \sa SDL_CloseIO * \sa SDL_ReadIO * \sa SDL_SeekIO * \sa SDL_TellIO */ extern SDL_DECLSPEC SDL_IOStream * SDLCALL SDL_IOFromConstMem(const void *mem, size_t size); /** * Use this function to create an SDL_IOStream that is backed by dynamically * allocated memory. * * This supports the following properties to provide access to the memory and * control over allocations: * * - `SDL_PROP_IOSTREAM_DYNAMIC_MEMORY_POINTER`: a pointer to the internal * memory of the stream. This can be set to NULL to transfer ownership of * the memory to the application, which should free the memory with * SDL_free(). If this is done, the next operation on the stream must be * SDL_CloseIO(). * - `SDL_PROP_IOSTREAM_DYNAMIC_CHUNKSIZE_NUMBER`: memory will be allocated in * multiples of this size, defaulting to 1024. * * \returns a pointer to a new SDL_IOStream structure or NULL on failure; call * SDL_GetError() for more information. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_CloseIO * \sa SDL_ReadIO * \sa SDL_SeekIO * \sa SDL_TellIO * \sa SDL_WriteIO */ extern SDL_DECLSPEC SDL_IOStream * SDLCALL SDL_IOFromDynamicMem(void); #define SDL_PROP_IOSTREAM_DYNAMIC_MEMORY_POINTER "SDL.iostream.dynamic.memory" #define SDL_PROP_IOSTREAM_DYNAMIC_CHUNKSIZE_NUMBER "SDL.iostream.dynamic.chunksize" /* @} *//* IOFrom functions */ /** * Create a custom SDL_IOStream. * * Applications do not need to use this function unless they are providing * their own SDL_IOStream implementation. If you just need an SDL_IOStream to * read/write a common data source, you should use the built-in * implementations in SDL, like SDL_IOFromFile() or SDL_IOFromMem(), etc. * * This function makes a copy of `iface` and the caller does not need to keep * it around after this call. * * \param iface the interface that implements this SDL_IOStream, initialized * using SDL_INIT_INTERFACE(). * \param userdata the pointer that will be passed to the interface functions. * \returns a pointer to the allocated memory on success or NULL on failure; * call SDL_GetError() for more information. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_CloseIO * \sa SDL_INIT_INTERFACE * \sa SDL_IOFromConstMem * \sa SDL_IOFromFile * \sa SDL_IOFromMem */ extern SDL_DECLSPEC SDL_IOStream * SDLCALL SDL_OpenIO(const SDL_IOStreamInterface *iface, void *userdata); /** * Close and free an allocated SDL_IOStream structure. * * SDL_CloseIO() closes and cleans up the SDL_IOStream stream. It releases any * resources used by the stream and frees the SDL_IOStream itself. This * returns true on success, or false if the stream failed to flush to its * output (e.g. to disk). * * Note that if this fails to flush the stream for any reason, this function * reports an error, but the SDL_IOStream is still invalid once this function * returns. * * This call flushes any buffered writes to the operating system, but there * are no guarantees that those writes have gone to physical media; they might * be in the OS's file cache, waiting to go to disk later. If it's absolutely * crucial that writes go to disk immediately, so they are definitely stored * even if the power fails before the file cache would have caught up, one * should call SDL_FlushIO() before closing. Note that flushing takes time and * makes the system and your app operate less efficiently, so do so sparingly. * * \param context SDL_IOStream structure to close. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety Do not use the same SDL_IOStream from two threads at once. * * \since This function is available since SDL 3.2.0. * * \sa SDL_OpenIO */ extern SDL_DECLSPEC bool SDLCALL SDL_CloseIO(SDL_IOStream *context); /** * Get the properties associated with an SDL_IOStream. * * \param context a pointer to an SDL_IOStream structure. * \returns a valid property ID on success or 0 on failure; call * SDL_GetError() for more information. * * \threadsafety Do not use the same SDL_IOStream from two threads at once. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC SDL_PropertiesID SDLCALL SDL_GetIOProperties(SDL_IOStream *context); /** * Query the stream status of an SDL_IOStream. * * This information can be useful to decide if a short read or write was due * to an error, an EOF, or a non-blocking operation that isn't yet ready to * complete. * * An SDL_IOStream's status is only expected to change after a SDL_ReadIO or * SDL_WriteIO call; don't expect it to change if you just call this query * function in a tight loop. * * \param context the SDL_IOStream to query. * \returns an SDL_IOStatus enum with the current state. * * \threadsafety Do not use the same SDL_IOStream from two threads at once. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC SDL_IOStatus SDLCALL SDL_GetIOStatus(SDL_IOStream *context); /** * Use this function to get the size of the data stream in an SDL_IOStream. * * \param context the SDL_IOStream to get the size of the data stream from. * \returns the size of the data stream in the SDL_IOStream on success or a * negative error code on failure; call SDL_GetError() for more * information. * * \threadsafety Do not use the same SDL_IOStream from two threads at once. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC Sint64 SDLCALL SDL_GetIOSize(SDL_IOStream *context); /** * Seek within an SDL_IOStream data stream. * * This function seeks to byte `offset`, relative to `whence`. * * `whence` may be any of the following values: * * - `SDL_IO_SEEK_SET`: seek from the beginning of data * - `SDL_IO_SEEK_CUR`: seek relative to current read point * - `SDL_IO_SEEK_END`: seek relative to the end of data * * If this stream can not seek, it will return -1. * * \param context a pointer to an SDL_IOStream structure. * \param offset an offset in bytes, relative to `whence` location; can be * negative. * \param whence any of `SDL_IO_SEEK_SET`, `SDL_IO_SEEK_CUR`, * `SDL_IO_SEEK_END`. * \returns the final offset in the data stream after the seek or -1 on * failure; call SDL_GetError() for more information. * * \threadsafety Do not use the same SDL_IOStream from two threads at once. * * \since This function is available since SDL 3.2.0. * * \sa SDL_TellIO */ extern SDL_DECLSPEC Sint64 SDLCALL SDL_SeekIO(SDL_IOStream *context, Sint64 offset, SDL_IOWhence whence); /** * Determine the current read/write offset in an SDL_IOStream data stream. * * SDL_TellIO is actually a wrapper function that calls the SDL_IOStream's * `seek` method, with an offset of 0 bytes from `SDL_IO_SEEK_CUR`, to * simplify application development. * * \param context an SDL_IOStream data stream object from which to get the * current offset. * \returns the current offset in the stream, or -1 if the information can not * be determined. * * \threadsafety Do not use the same SDL_IOStream from two threads at once. * * \since This function is available since SDL 3.2.0. * * \sa SDL_SeekIO */ extern SDL_DECLSPEC Sint64 SDLCALL SDL_TellIO(SDL_IOStream *context); /** * Read from a data source. * * This function reads up `size` bytes from the data source to the area * pointed at by `ptr`. This function may read less bytes than requested. * * This function will return zero when the data stream is completely read, and * SDL_GetIOStatus() will return SDL_IO_STATUS_EOF. If zero is returned and * the stream is not at EOF, SDL_GetIOStatus() will return a different error * value and SDL_GetError() will offer a human-readable message. * * A request for zero bytes on a valid stream will return zero immediately * without accessing the stream, so the stream status (EOF, err, etc) will not * change. * * \param context a pointer to an SDL_IOStream structure. * \param ptr a pointer to a buffer to read data into. * \param size the number of bytes to read from the data source. * \returns the number of bytes read, or 0 on end of file or other failure; * call SDL_GetError() for more information. * * \threadsafety Do not use the same SDL_IOStream from two threads at once. * * \since This function is available since SDL 3.2.0. * * \sa SDL_WriteIO * \sa SDL_GetIOStatus */ extern SDL_DECLSPEC size_t SDLCALL SDL_ReadIO(SDL_IOStream *context, void *ptr, size_t size); /** * Write to an SDL_IOStream data stream. * * This function writes exactly `size` bytes from the area pointed at by `ptr` * to the stream. If this fails for any reason, it'll return less than `size` * to demonstrate how far the write progressed. On success, it returns `size`. * * On error, this function still attempts to write as much as possible, so it * might return a positive value less than the requested write size. * * The caller can use SDL_GetIOStatus() to determine if the problem is * recoverable, such as a non-blocking write that can simply be retried later, * or a fatal error. * * A request for zero bytes on a valid stream will return zero immediately * without accessing the stream, so the stream status (EOF, err, etc) will not * change. * * \param context a pointer to an SDL_IOStream structure. * \param ptr a pointer to a buffer containing data to write. * \param size the number of bytes to write. * \returns the number of bytes written, which will be less than `size` on * failure; call SDL_GetError() for more information. * * \threadsafety Do not use the same SDL_IOStream from two threads at once. * * \since This function is available since SDL 3.2.0. * * \sa SDL_IOprintf * \sa SDL_ReadIO * \sa SDL_SeekIO * \sa SDL_FlushIO * \sa SDL_GetIOStatus */ extern SDL_DECLSPEC size_t SDLCALL SDL_WriteIO(SDL_IOStream *context, const void *ptr, size_t size); /** * Print to an SDL_IOStream data stream. * * This function does formatted printing to the stream. * * \param context a pointer to an SDL_IOStream structure. * \param fmt a printf() style format string. * \param ... additional parameters matching % tokens in the `fmt` string, if * any. * \returns the number of bytes written or 0 on failure; call SDL_GetError() * for more information. * * \threadsafety Do not use the same SDL_IOStream from two threads at once. * * \since This function is available since SDL 3.2.0. * * \sa SDL_IOvprintf * \sa SDL_WriteIO */ extern SDL_DECLSPEC size_t SDLCALL SDL_IOprintf(SDL_IOStream *context, SDL_PRINTF_FORMAT_STRING const char *fmt, ...) SDL_PRINTF_VARARG_FUNC(2); /** * Print to an SDL_IOStream data stream. * * This function does formatted printing to the stream. * * \param context a pointer to an SDL_IOStream structure. * \param fmt a printf() style format string. * \param ap a variable argument list. * \returns the number of bytes written or 0 on failure; call SDL_GetError() * for more information. * * \threadsafety Do not use the same SDL_IOStream from two threads at once. * * \since This function is available since SDL 3.2.0. * * \sa SDL_IOprintf * \sa SDL_WriteIO */ extern SDL_DECLSPEC size_t SDLCALL SDL_IOvprintf(SDL_IOStream *context, SDL_PRINTF_FORMAT_STRING const char *fmt, va_list ap) SDL_PRINTF_VARARG_FUNCV(2); /** * Flush any buffered data in the stream. * * This function makes sure that any buffered data is written to the stream. * Normally this isn't necessary but if the stream is a pipe or socket it * guarantees that any pending data is sent. * * \param context SDL_IOStream structure to flush. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety Do not use the same SDL_IOStream from two threads at once. * * \since This function is available since SDL 3.2.0. * * \sa SDL_OpenIO * \sa SDL_WriteIO */ extern SDL_DECLSPEC bool SDLCALL SDL_FlushIO(SDL_IOStream *context); /** * Load all the data from an SDL data stream. * * The data is allocated with a zero byte at the end (null terminated) for * convenience. This extra byte is not included in the value reported via * `datasize`. * * The data should be freed with SDL_free(). * * \param src the SDL_IOStream to read all available data from. * \param datasize a pointer filled in with the number of bytes read, may be * NULL. * \param closeio if true, calls SDL_CloseIO() on `src` before returning, even * in the case of an error. * \returns the data or NULL on failure; call SDL_GetError() for more * information. * * \threadsafety Do not use the same SDL_IOStream from two threads at once. * * \since This function is available since SDL 3.2.0. * * \sa SDL_LoadFile * \sa SDL_SaveFile_IO */ extern SDL_DECLSPEC void * SDLCALL SDL_LoadFile_IO(SDL_IOStream *src, size_t *datasize, bool closeio); /** * Load all the data from a file path. * * The data is allocated with a zero byte at the end (null terminated) for * convenience. This extra byte is not included in the value reported via * `datasize`. * * The data should be freed with SDL_free(). * * \param file the path to read all available data from. * \param datasize if not NULL, will store the number of bytes read. * \returns the data or NULL on failure; call SDL_GetError() for more * information. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_LoadFile_IO * \sa SDL_SaveFile */ extern SDL_DECLSPEC void * SDLCALL SDL_LoadFile(const char *file, size_t *datasize); /** * Save all the data into an SDL data stream. * * \param src the SDL_IOStream to write all data to. * \param data the data to be written. If datasize is 0, may be NULL or a * invalid pointer. * \param datasize the number of bytes to be written. * \param closeio if true, calls SDL_CloseIO() on `src` before returning, even * in the case of an error. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety Do not use the same SDL_IOStream from two threads at once. * * \since This function is available since SDL 3.2.0. * * \sa SDL_SaveFile * \sa SDL_LoadFile_IO */ extern SDL_DECLSPEC bool SDLCALL SDL_SaveFile_IO(SDL_IOStream *src, const void *data, size_t datasize, bool closeio); /** * Save all the data into a file path. * * \param file the path to write all available data into. * \param data the data to be written. If datasize is 0, may be NULL or a * invalid pointer. * \param datasize the number of bytes to be written. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_SaveFile_IO * \sa SDL_LoadFile */ extern SDL_DECLSPEC bool SDLCALL SDL_SaveFile(const char *file, const void *data, size_t datasize); /** * \name Read endian functions * * Read an item of the specified endianness and return in native format. */ /* @{ */ /** * Use this function to read a byte from an SDL_IOStream. * * This function will return false when the data stream is completely read, * and SDL_GetIOStatus() will return SDL_IO_STATUS_EOF. If false is returned * and the stream is not at EOF, SDL_GetIOStatus() will return a different * error value and SDL_GetError() will offer a human-readable message. * * \param src the SDL_IOStream to read from. * \param value a pointer filled in with the data read. * \returns true on success or false on failure or EOF; call SDL_GetError() * for more information. * * \threadsafety Do not use the same SDL_IOStream from two threads at once. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC bool SDLCALL SDL_ReadU8(SDL_IOStream *src, Uint8 *value); /** * Use this function to read a signed byte from an SDL_IOStream. * * This function will return false when the data stream is completely read, * and SDL_GetIOStatus() will return SDL_IO_STATUS_EOF. If false is returned * and the stream is not at EOF, SDL_GetIOStatus() will return a different * error value and SDL_GetError() will offer a human-readable message. * * \param src the SDL_IOStream to read from. * \param value a pointer filled in with the data read. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety Do not use the same SDL_IOStream from two threads at once. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC bool SDLCALL SDL_ReadS8(SDL_IOStream *src, Sint8 *value); /** * Use this function to read 16 bits of little-endian data from an * SDL_IOStream and return in native format. * * SDL byteswaps the data only if necessary, so the data returned will be in * the native byte order. * * This function will return false when the data stream is completely read, * and SDL_GetIOStatus() will return SDL_IO_STATUS_EOF. If false is returned * and the stream is not at EOF, SDL_GetIOStatus() will return a different * error value and SDL_GetError() will offer a human-readable message. * * \param src the stream from which to read data. * \param value a pointer filled in with the data read. * \returns true on successful read or false on failure; call SDL_GetError() * for more information. * * \threadsafety Do not use the same SDL_IOStream from two threads at once. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC bool SDLCALL SDL_ReadU16LE(SDL_IOStream *src, Uint16 *value); /** * Use this function to read 16 bits of little-endian data from an * SDL_IOStream and return in native format. * * SDL byteswaps the data only if necessary, so the data returned will be in * the native byte order. * * This function will return false when the data stream is completely read, * and SDL_GetIOStatus() will return SDL_IO_STATUS_EOF. If false is returned * and the stream is not at EOF, SDL_GetIOStatus() will return a different * error value and SDL_GetError() will offer a human-readable message. * * \param src the stream from which to read data. * \param value a pointer filled in with the data read. * \returns true on successful read or false on failure; call SDL_GetError() * for more information. * * \threadsafety Do not use the same SDL_IOStream from two threads at once. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC bool SDLCALL SDL_ReadS16LE(SDL_IOStream *src, Sint16 *value); /** * Use this function to read 16 bits of big-endian data from an SDL_IOStream * and return in native format. * * SDL byteswaps the data only if necessary, so the data returned will be in * the native byte order. * * This function will return false when the data stream is completely read, * and SDL_GetIOStatus() will return SDL_IO_STATUS_EOF. If false is returned * and the stream is not at EOF, SDL_GetIOStatus() will return a different * error value and SDL_GetError() will offer a human-readable message. * * \param src the stream from which to read data. * \param value a pointer filled in with the data read. * \returns true on successful read or false on failure; call SDL_GetError() * for more information. * * \threadsafety Do not use the same SDL_IOStream from two threads at once. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC bool SDLCALL SDL_ReadU16BE(SDL_IOStream *src, Uint16 *value); /** * Use this function to read 16 bits of big-endian data from an SDL_IOStream * and return in native format. * * SDL byteswaps the data only if necessary, so the data returned will be in * the native byte order. * * This function will return false when the data stream is completely read, * and SDL_GetIOStatus() will return SDL_IO_STATUS_EOF. If false is returned * and the stream is not at EOF, SDL_GetIOStatus() will return a different * error value and SDL_GetError() will offer a human-readable message. * * \param src the stream from which to read data. * \param value a pointer filled in with the data read. * \returns true on successful read or false on failure; call SDL_GetError() * for more information. * * \threadsafety Do not use the same SDL_IOStream from two threads at once. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC bool SDLCALL SDL_ReadS16BE(SDL_IOStream *src, Sint16 *value); /** * Use this function to read 32 bits of little-endian data from an * SDL_IOStream and return in native format. * * SDL byteswaps the data only if necessary, so the data returned will be in * the native byte order. * * This function will return false when the data stream is completely read, * and SDL_GetIOStatus() will return SDL_IO_STATUS_EOF. If false is returned * and the stream is not at EOF, SDL_GetIOStatus() will return a different * error value and SDL_GetError() will offer a human-readable message. * * \param src the stream from which to read data. * \param value a pointer filled in with the data read. * \returns true on successful read or false on failure; call SDL_GetError() * for more information. * * \threadsafety Do not use the same SDL_IOStream from two threads at once. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC bool SDLCALL SDL_ReadU32LE(SDL_IOStream *src, Uint32 *value); /** * Use this function to read 32 bits of little-endian data from an * SDL_IOStream and return in native format. * * SDL byteswaps the data only if necessary, so the data returned will be in * the native byte order. * * This function will return false when the data stream is completely read, * and SDL_GetIOStatus() will return SDL_IO_STATUS_EOF. If false is returned * and the stream is not at EOF, SDL_GetIOStatus() will return a different * error value and SDL_GetError() will offer a human-readable message. * * \param src the stream from which to read data. * \param value a pointer filled in with the data read. * \returns true on successful read or false on failure; call SDL_GetError() * for more information. * * \threadsafety Do not use the same SDL_IOStream from two threads at once. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC bool SDLCALL SDL_ReadS32LE(SDL_IOStream *src, Sint32 *value); /** * Use this function to read 32 bits of big-endian data from an SDL_IOStream * and return in native format. * * SDL byteswaps the data only if necessary, so the data returned will be in * the native byte order. * * This function will return false when the data stream is completely read, * and SDL_GetIOStatus() will return SDL_IO_STATUS_EOF. If false is returned * and the stream is not at EOF, SDL_GetIOStatus() will return a different * error value and SDL_GetError() will offer a human-readable message. * * \param src the stream from which to read data. * \param value a pointer filled in with the data read. * \returns true on successful read or false on failure; call SDL_GetError() * for more information. * * \threadsafety Do not use the same SDL_IOStream from two threads at once. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC bool SDLCALL SDL_ReadU32BE(SDL_IOStream *src, Uint32 *value); /** * Use this function to read 32 bits of big-endian data from an SDL_IOStream * and return in native format. * * SDL byteswaps the data only if necessary, so the data returned will be in * the native byte order. * * This function will return false when the data stream is completely read, * and SDL_GetIOStatus() will return SDL_IO_STATUS_EOF. If false is returned * and the stream is not at EOF, SDL_GetIOStatus() will return a different * error value and SDL_GetError() will offer a human-readable message. * * \param src the stream from which to read data. * \param value a pointer filled in with the data read. * \returns true on successful read or false on failure; call SDL_GetError() * for more information. * * \threadsafety Do not use the same SDL_IOStream from two threads at once. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC bool SDLCALL SDL_ReadS32BE(SDL_IOStream *src, Sint32 *value); /** * Use this function to read 64 bits of little-endian data from an * SDL_IOStream and return in native format. * * SDL byteswaps the data only if necessary, so the data returned will be in * the native byte order. * * This function will return false when the data stream is completely read, * and SDL_GetIOStatus() will return SDL_IO_STATUS_EOF. If false is returned * and the stream is not at EOF, SDL_GetIOStatus() will return a different * error value and SDL_GetError() will offer a human-readable message. * * \param src the stream from which to read data. * \param value a pointer filled in with the data read. * \returns true on successful read or false on failure; call SDL_GetError() * for more information. * * \threadsafety Do not use the same SDL_IOStream from two threads at once. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC bool SDLCALL SDL_ReadU64LE(SDL_IOStream *src, Uint64 *value); /** * Use this function to read 64 bits of little-endian data from an * SDL_IOStream and return in native format. * * SDL byteswaps the data only if necessary, so the data returned will be in * the native byte order. * * This function will return false when the data stream is completely read, * and SDL_GetIOStatus() will return SDL_IO_STATUS_EOF. If false is returned * and the stream is not at EOF, SDL_GetIOStatus() will return a different * error value and SDL_GetError() will offer a human-readable message. * * \param src the stream from which to read data. * \param value a pointer filled in with the data read. * \returns true on successful read or false on failure; call SDL_GetError() * for more information. * * \threadsafety Do not use the same SDL_IOStream from two threads at once. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC bool SDLCALL SDL_ReadS64LE(SDL_IOStream *src, Sint64 *value); /** * Use this function to read 64 bits of big-endian data from an SDL_IOStream * and return in native format. * * SDL byteswaps the data only if necessary, so the data returned will be in * the native byte order. * * This function will return false when the data stream is completely read, * and SDL_GetIOStatus() will return SDL_IO_STATUS_EOF. If false is returned * and the stream is not at EOF, SDL_GetIOStatus() will return a different * error value and SDL_GetError() will offer a human-readable message. * * \param src the stream from which to read data. * \param value a pointer filled in with the data read. * \returns true on successful read or false on failure; call SDL_GetError() * for more information. * * \threadsafety Do not use the same SDL_IOStream from two threads at once. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC bool SDLCALL SDL_ReadU64BE(SDL_IOStream *src, Uint64 *value); /** * Use this function to read 64 bits of big-endian data from an SDL_IOStream * and return in native format. * * SDL byteswaps the data only if necessary, so the data returned will be in * the native byte order. * * This function will return false when the data stream is completely read, * and SDL_GetIOStatus() will return SDL_IO_STATUS_EOF. If false is returned * and the stream is not at EOF, SDL_GetIOStatus() will return a different * error value and SDL_GetError() will offer a human-readable message. * * \param src the stream from which to read data. * \param value a pointer filled in with the data read. * \returns true on successful read or false on failure; call SDL_GetError() * for more information. * * \threadsafety Do not use the same SDL_IOStream from two threads at once. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC bool SDLCALL SDL_ReadS64BE(SDL_IOStream *src, Sint64 *value); /* @} *//* Read endian functions */ /** * \name Write endian functions * * Write an item of native format to the specified endianness. */ /* @{ */ /** * Use this function to write a byte to an SDL_IOStream. * * \param dst the SDL_IOStream to write to. * \param value the byte value to write. * \returns true on successful write or false on failure; call SDL_GetError() * for more information. * * \threadsafety Do not use the same SDL_IOStream from two threads at once. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC bool SDLCALL SDL_WriteU8(SDL_IOStream *dst, Uint8 value); /** * Use this function to write a signed byte to an SDL_IOStream. * * \param dst the SDL_IOStream to write to. * \param value the byte value to write. * \returns true on successful write or false on failure; call SDL_GetError() * for more information. * * \threadsafety Do not use the same SDL_IOStream from two threads at once. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC bool SDLCALL SDL_WriteS8(SDL_IOStream *dst, Sint8 value); /** * Use this function to write 16 bits in native format to an SDL_IOStream as * little-endian data. * * SDL byteswaps the data only if necessary, so the application always * specifies native format, and the data written will be in little-endian * format. * * \param dst the stream to which data will be written. * \param value the data to be written, in native format. * \returns true on successful write or false on failure; call SDL_GetError() * for more information. * * \threadsafety Do not use the same SDL_IOStream from two threads at once. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC bool SDLCALL SDL_WriteU16LE(SDL_IOStream *dst, Uint16 value); /** * Use this function to write 16 bits in native format to an SDL_IOStream as * little-endian data. * * SDL byteswaps the data only if necessary, so the application always * specifies native format, and the data written will be in little-endian * format. * * \param dst the stream to which data will be written. * \param value the data to be written, in native format. * \returns true on successful write or false on failure; call SDL_GetError() * for more information. * * \threadsafety Do not use the same SDL_IOStream from two threads at once. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC bool SDLCALL SDL_WriteS16LE(SDL_IOStream *dst, Sint16 value); /** * Use this function to write 16 bits in native format to an SDL_IOStream as * big-endian data. * * SDL byteswaps the data only if necessary, so the application always * specifies native format, and the data written will be in big-endian format. * * \param dst the stream to which data will be written. * \param value the data to be written, in native format. * \returns true on successful write or false on failure; call SDL_GetError() * for more information. * * \threadsafety Do not use the same SDL_IOStream from two threads at once. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC bool SDLCALL SDL_WriteU16BE(SDL_IOStream *dst, Uint16 value); /** * Use this function to write 16 bits in native format to an SDL_IOStream as * big-endian data. * * SDL byteswaps the data only if necessary, so the application always * specifies native format, and the data written will be in big-endian format. * * \param dst the stream to which data will be written. * \param value the data to be written, in native format. * \returns true on successful write or false on failure; call SDL_GetError() * for more information. * * \threadsafety Do not use the same SDL_IOStream from two threads at once. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC bool SDLCALL SDL_WriteS16BE(SDL_IOStream *dst, Sint16 value); /** * Use this function to write 32 bits in native format to an SDL_IOStream as * little-endian data. * * SDL byteswaps the data only if necessary, so the application always * specifies native format, and the data written will be in little-endian * format. * * \param dst the stream to which data will be written. * \param value the data to be written, in native format. * \returns true on successful write or false on failure; call SDL_GetError() * for more information. * * \threadsafety Do not use the same SDL_IOStream from two threads at once. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC bool SDLCALL SDL_WriteU32LE(SDL_IOStream *dst, Uint32 value); /** * Use this function to write 32 bits in native format to an SDL_IOStream as * little-endian data. * * SDL byteswaps the data only if necessary, so the application always * specifies native format, and the data written will be in little-endian * format. * * \param dst the stream to which data will be written. * \param value the data to be written, in native format. * \returns true on successful write or false on failure; call SDL_GetError() * for more information. * * \threadsafety Do not use the same SDL_IOStream from two threads at once. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC bool SDLCALL SDL_WriteS32LE(SDL_IOStream *dst, Sint32 value); /** * Use this function to write 32 bits in native format to an SDL_IOStream as * big-endian data. * * SDL byteswaps the data only if necessary, so the application always * specifies native format, and the data written will be in big-endian format. * * \param dst the stream to which data will be written. * \param value the data to be written, in native format. * \returns true on successful write or false on failure; call SDL_GetError() * for more information. * * \threadsafety Do not use the same SDL_IOStream from two threads at once. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC bool SDLCALL SDL_WriteU32BE(SDL_IOStream *dst, Uint32 value); /** * Use this function to write 32 bits in native format to an SDL_IOStream as * big-endian data. * * SDL byteswaps the data only if necessary, so the application always * specifies native format, and the data written will be in big-endian format. * * \param dst the stream to which data will be written. * \param value the data to be written, in native format. * \returns true on successful write or false on failure; call SDL_GetError() * for more information. * * \threadsafety Do not use the same SDL_IOStream from two threads at once. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC bool SDLCALL SDL_WriteS32BE(SDL_IOStream *dst, Sint32 value); /** * Use this function to write 64 bits in native format to an SDL_IOStream as * little-endian data. * * SDL byteswaps the data only if necessary, so the application always * specifies native format, and the data written will be in little-endian * format. * * \param dst the stream to which data will be written. * \param value the data to be written, in native format. * \returns true on successful write or false on failure; call SDL_GetError() * for more information. * * \threadsafety Do not use the same SDL_IOStream from two threads at once. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC bool SDLCALL SDL_WriteU64LE(SDL_IOStream *dst, Uint64 value); /** * Use this function to write 64 bits in native format to an SDL_IOStream as * little-endian data. * * SDL byteswaps the data only if necessary, so the application always * specifies native format, and the data written will be in little-endian * format. * * \param dst the stream to which data will be written. * \param value the data to be written, in native format. * \returns true on successful write or false on failure; call SDL_GetError() * for more information. * * \threadsafety Do not use the same SDL_IOStream from two threads at once. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC bool SDLCALL SDL_WriteS64LE(SDL_IOStream *dst, Sint64 value); /** * Use this function to write 64 bits in native format to an SDL_IOStream as * big-endian data. * * SDL byteswaps the data only if necessary, so the application always * specifies native format, and the data written will be in big-endian format. * * \param dst the stream to which data will be written. * \param value the data to be written, in native format. * \returns true on successful write or false on failure; call SDL_GetError() * for more information. * * \threadsafety Do not use the same SDL_IOStream from two threads at once. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC bool SDLCALL SDL_WriteU64BE(SDL_IOStream *dst, Uint64 value); /** * Use this function to write 64 bits in native format to an SDL_IOStream as * big-endian data. * * SDL byteswaps the data only if necessary, so the application always * specifies native format, and the data written will be in big-endian format. * * \param dst the stream to which data will be written. * \param value the data to be written, in native format. * \returns true on successful write or false on failure; call SDL_GetError() * for more information. * * \threadsafety Do not use the same SDL_IOStream from two threads at once. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC bool SDLCALL SDL_WriteS64BE(SDL_IOStream *dst, Sint64 value); /* @} *//* Write endian functions */ /* Ends C function definitions when using C++ */ #ifdef __cplusplus } #endif #include #endif /* SDL_iostream_h_ */ ================================================ FILE: deps/include/SDL3/SDL_joystick.h ================================================ /* Simple DirectMedia Layer Copyright (C) 1997-2026 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ /** * # CategoryJoystick * * SDL joystick support. * * This is the lower-level joystick handling. If you want the simpler option, * where what each button does is well-defined, you should use the gamepad API * instead. * * The term "instance_id" is the current instantiation of a joystick device in * the system. If the joystick is removed and then re-inserted then it will * get a new instance_id. instance_id's are monotonically increasing * identifiers of a joystick plugged in. * * The term "player_index" is the number assigned to a player on a specific * controller. For XInput controllers this returns the XInput user index. Many * joysticks will not be able to supply this information. * * SDL_GUID is used as a stable 128-bit identifier for a joystick device that * does not change over time. It identifies class of the device (a X360 wired * controller for example). This identifier is platform dependent. * * In order to use these functions, SDL_Init() must have been called with the * SDL_INIT_JOYSTICK flag. This causes SDL to scan the system for joysticks, * and load appropriate drivers. * * If you would like to receive joystick updates while the application is in * the background, you should set the following hint before calling * SDL_Init(): SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS * * SDL can provide virtual joysticks as well: the app defines an imaginary * controller with SDL_AttachVirtualJoystick(), and then can provide inputs * for it via SDL_SetJoystickVirtualAxis(), SDL_SetJoystickVirtualButton(), * etc. As this data is supplied, it will look like a normal joystick to SDL, * just not backed by a hardware driver. This has been used to make unusual * devices, like VR headset controllers, look like normal joysticks, or * provide recording/playback of game inputs, etc. */ #ifndef SDL_joystick_h_ #define SDL_joystick_h_ #include #include #include #include #include #include #include #include /* Set up for C function definitions, even when using C++ */ #ifdef __cplusplus extern "C" { #endif #ifdef SDL_THREAD_SAFETY_ANALYSIS /* * This is not an exported symbol from SDL, this is only in the headers to * help Clang's thread safety analysis tools to function. Do not attempt * to access this symbol from your app, it will not work! */ extern SDL_Mutex *SDL_joystick_lock; #endif /** * The joystick structure used to identify an SDL joystick. * * This is opaque data. * * \since This struct is available since SDL 3.2.0. */ typedef struct SDL_Joystick SDL_Joystick; /** * This is a unique ID for a joystick for the time it is connected to the * system, and is never reused for the lifetime of the application. * * If the joystick is disconnected and reconnected, it will get a new ID. * * The value 0 is an invalid ID. * * \since This datatype is available since SDL 3.2.0. */ typedef Uint32 SDL_JoystickID; /** * An enum of some common joystick types. * * In some cases, SDL can identify a low-level joystick as being a certain * type of device, and will report it through SDL_GetJoystickType (or * SDL_GetJoystickTypeForID). * * This is by no means a complete list of everything that can be plugged into * a computer. * * You may refer to * [XInput Controller Types](https://learn.microsoft.com/en-us/windows/win32/xinput/xinput-and-controller-subtypes) * table for a general understanding of each joystick type. * * \since This enum is available since SDL 3.2.0. */ typedef enum SDL_JoystickType { SDL_JOYSTICK_TYPE_UNKNOWN, SDL_JOYSTICK_TYPE_GAMEPAD, SDL_JOYSTICK_TYPE_WHEEL, SDL_JOYSTICK_TYPE_ARCADE_STICK, SDL_JOYSTICK_TYPE_FLIGHT_STICK, SDL_JOYSTICK_TYPE_DANCE_PAD, SDL_JOYSTICK_TYPE_GUITAR, SDL_JOYSTICK_TYPE_DRUM_KIT, SDL_JOYSTICK_TYPE_ARCADE_PAD, SDL_JOYSTICK_TYPE_THROTTLE, SDL_JOYSTICK_TYPE_COUNT } SDL_JoystickType; /** * Possible connection states for a joystick device. * * This is used by SDL_GetJoystickConnectionState to report how a device is * connected to the system. * * \since This enum is available since SDL 3.2.0. */ typedef enum SDL_JoystickConnectionState { SDL_JOYSTICK_CONNECTION_INVALID = -1, SDL_JOYSTICK_CONNECTION_UNKNOWN, SDL_JOYSTICK_CONNECTION_WIRED, SDL_JOYSTICK_CONNECTION_WIRELESS } SDL_JoystickConnectionState; /** * The largest value an SDL_Joystick's axis can report. * * \since This macro is available since SDL 3.2.0. * * \sa SDL_JOYSTICK_AXIS_MIN */ #define SDL_JOYSTICK_AXIS_MAX 32767 /** * The smallest value an SDL_Joystick's axis can report. * * This is a negative number! * * \since This macro is available since SDL 3.2.0. * * \sa SDL_JOYSTICK_AXIS_MAX */ #define SDL_JOYSTICK_AXIS_MIN -32768 /* Function prototypes */ /** * Locking for atomic access to the joystick API. * * The SDL joystick functions are thread-safe, however you can lock the * joysticks while processing to guarantee that the joystick list won't change * and joystick and gamepad events will not be delivered. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC void SDLCALL SDL_LockJoysticks(void) SDL_ACQUIRE(SDL_joystick_lock); /** * Unlocking for atomic access to the joystick API. * * \threadsafety This should be called from the same thread that called * SDL_LockJoysticks(). * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC void SDLCALL SDL_UnlockJoysticks(void) SDL_RELEASE(SDL_joystick_lock); /** * Return whether a joystick is currently connected. * * \returns true if a joystick is connected, false otherwise. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetJoysticks */ extern SDL_DECLSPEC bool SDLCALL SDL_HasJoystick(void); /** * Get a list of currently connected joysticks. * * \param count a pointer filled in with the number of joysticks returned, may * be NULL. * \returns a 0 terminated array of joystick instance IDs or NULL on failure; * call SDL_GetError() for more information. This should be freed * with SDL_free() when it is no longer needed. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_HasJoystick * \sa SDL_OpenJoystick */ extern SDL_DECLSPEC SDL_JoystickID * SDLCALL SDL_GetJoysticks(int *count); /** * Get the implementation dependent name of a joystick. * * This can be called before any joysticks are opened. * * \param instance_id the joystick instance ID. * \returns the name of the selected joystick. If no name can be found, this * function returns NULL; call SDL_GetError() for more information. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetJoystickName * \sa SDL_GetJoysticks */ extern SDL_DECLSPEC const char * SDLCALL SDL_GetJoystickNameForID(SDL_JoystickID instance_id); /** * Get the implementation dependent path of a joystick. * * This can be called before any joysticks are opened. * * \param instance_id the joystick instance ID. * \returns the path of the selected joystick. If no path can be found, this * function returns NULL; call SDL_GetError() for more information. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetJoystickPath * \sa SDL_GetJoysticks */ extern SDL_DECLSPEC const char * SDLCALL SDL_GetJoystickPathForID(SDL_JoystickID instance_id); /** * Get the player index of a joystick. * * This can be called before any joysticks are opened. * * \param instance_id the joystick instance ID. * \returns the player index of a joystick, or -1 if it's not available. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetJoystickPlayerIndex * \sa SDL_GetJoysticks */ extern SDL_DECLSPEC int SDLCALL SDL_GetJoystickPlayerIndexForID(SDL_JoystickID instance_id); /** * Get the implementation-dependent GUID of a joystick. * * This can be called before any joysticks are opened. * * \param instance_id the joystick instance ID. * \returns the GUID of the selected joystick. If called with an invalid * instance_id, this function returns a zero GUID. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetJoystickGUID * \sa SDL_GUIDToString */ extern SDL_DECLSPEC SDL_GUID SDLCALL SDL_GetJoystickGUIDForID(SDL_JoystickID instance_id); /** * Get the USB vendor ID of a joystick, if available. * * This can be called before any joysticks are opened. If the vendor ID isn't * available this function returns 0. * * \param instance_id the joystick instance ID. * \returns the USB vendor ID of the selected joystick. If called with an * invalid instance_id, this function returns 0. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetJoystickVendor * \sa SDL_GetJoysticks */ extern SDL_DECLSPEC Uint16 SDLCALL SDL_GetJoystickVendorForID(SDL_JoystickID instance_id); /** * Get the USB product ID of a joystick, if available. * * This can be called before any joysticks are opened. If the product ID isn't * available this function returns 0. * * \param instance_id the joystick instance ID. * \returns the USB product ID of the selected joystick. If called with an * invalid instance_id, this function returns 0. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetJoystickProduct * \sa SDL_GetJoysticks */ extern SDL_DECLSPEC Uint16 SDLCALL SDL_GetJoystickProductForID(SDL_JoystickID instance_id); /** * Get the product version of a joystick, if available. * * This can be called before any joysticks are opened. If the product version * isn't available this function returns 0. * * \param instance_id the joystick instance ID. * \returns the product version of the selected joystick. If called with an * invalid instance_id, this function returns 0. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetJoystickProductVersion * \sa SDL_GetJoysticks */ extern SDL_DECLSPEC Uint16 SDLCALL SDL_GetJoystickProductVersionForID(SDL_JoystickID instance_id); /** * Get the type of a joystick, if available. * * This can be called before any joysticks are opened. * * \param instance_id the joystick instance ID. * \returns the SDL_JoystickType of the selected joystick. If called with an * invalid instance_id, this function returns * `SDL_JOYSTICK_TYPE_UNKNOWN`. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetJoystickType * \sa SDL_GetJoysticks */ extern SDL_DECLSPEC SDL_JoystickType SDLCALL SDL_GetJoystickTypeForID(SDL_JoystickID instance_id); /** * Open a joystick for use. * * The joystick subsystem must be initialized before a joystick can be opened * for use. * * \param instance_id the joystick instance ID. * \returns a joystick identifier or NULL on failure; call SDL_GetError() for * more information. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_CloseJoystick */ extern SDL_DECLSPEC SDL_Joystick * SDLCALL SDL_OpenJoystick(SDL_JoystickID instance_id); /** * Get the SDL_Joystick associated with an instance ID, if it has been opened. * * \param instance_id the instance ID to get the SDL_Joystick for. * \returns an SDL_Joystick on success or NULL on failure or if it hasn't been * opened yet; call SDL_GetError() for more information. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC SDL_Joystick * SDLCALL SDL_GetJoystickFromID(SDL_JoystickID instance_id); /** * Get the SDL_Joystick associated with a player index. * * \param player_index the player index to get the SDL_Joystick for. * \returns an SDL_Joystick on success or NULL on failure; call SDL_GetError() * for more information. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetJoystickPlayerIndex * \sa SDL_SetJoystickPlayerIndex */ extern SDL_DECLSPEC SDL_Joystick * SDLCALL SDL_GetJoystickFromPlayerIndex(int player_index); /** * The structure that describes a virtual joystick touchpad. * * \since This struct is available since SDL 3.2.0. * * \sa SDL_VirtualJoystickDesc */ typedef struct SDL_VirtualJoystickTouchpadDesc { Uint16 nfingers; /**< the number of simultaneous fingers on this touchpad */ Uint16 padding[3]; } SDL_VirtualJoystickTouchpadDesc; /** * The structure that describes a virtual joystick sensor. * * \since This struct is available since SDL 3.2.0. * * \sa SDL_VirtualJoystickDesc */ typedef struct SDL_VirtualJoystickSensorDesc { SDL_SensorType type; /**< the type of this sensor */ float rate; /**< the update frequency of this sensor, may be 0.0f */ } SDL_VirtualJoystickSensorDesc; /** * The structure that describes a virtual joystick. * * This structure should be initialized using SDL_INIT_INTERFACE(). All * elements of this structure are optional. * * \since This struct is available since SDL 3.2.0. * * \sa SDL_AttachVirtualJoystick * \sa SDL_INIT_INTERFACE * \sa SDL_VirtualJoystickSensorDesc * \sa SDL_VirtualJoystickTouchpadDesc */ typedef struct SDL_VirtualJoystickDesc { Uint32 version; /**< the version of this interface */ Uint16 type; /**< `SDL_JoystickType` */ Uint16 padding; /**< unused */ Uint16 vendor_id; /**< the USB vendor ID of this joystick */ Uint16 product_id; /**< the USB product ID of this joystick */ Uint16 naxes; /**< the number of axes on this joystick */ Uint16 nbuttons; /**< the number of buttons on this joystick */ Uint16 nballs; /**< the number of balls on this joystick */ Uint16 nhats; /**< the number of hats on this joystick */ Uint16 ntouchpads; /**< the number of touchpads on this joystick, requires `touchpads` to point at valid descriptions */ Uint16 nsensors; /**< the number of sensors on this joystick, requires `sensors` to point at valid descriptions */ Uint16 padding2[2]; /**< unused */ Uint32 button_mask; /**< A mask of which buttons are valid for this controller e.g. (1 << SDL_GAMEPAD_BUTTON_SOUTH) */ Uint32 axis_mask; /**< A mask of which axes are valid for this controller e.g. (1 << SDL_GAMEPAD_AXIS_LEFTX) */ const char *name; /**< the name of the joystick */ const SDL_VirtualJoystickTouchpadDesc *touchpads; /**< A pointer to an array of touchpad descriptions, required if `ntouchpads` is > 0 */ const SDL_VirtualJoystickSensorDesc *sensors; /**< A pointer to an array of sensor descriptions, required if `nsensors` is > 0 */ void *userdata; /**< User data pointer passed to callbacks */ void (SDLCALL *Update)(void *userdata); /**< Called when the joystick state should be updated */ void (SDLCALL *SetPlayerIndex)(void *userdata, int player_index); /**< Called when the player index is set */ bool (SDLCALL *Rumble)(void *userdata, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble); /**< Implements SDL_RumbleJoystick() */ bool (SDLCALL *RumbleTriggers)(void *userdata, Uint16 left_rumble, Uint16 right_rumble); /**< Implements SDL_RumbleJoystickTriggers() */ bool (SDLCALL *SetLED)(void *userdata, Uint8 red, Uint8 green, Uint8 blue); /**< Implements SDL_SetJoystickLED() */ bool (SDLCALL *SendEffect)(void *userdata, const void *data, int size); /**< Implements SDL_SendJoystickEffect() */ bool (SDLCALL *SetSensorsEnabled)(void *userdata, bool enabled); /**< Implements SDL_SetGamepadSensorEnabled() */ void (SDLCALL *Cleanup)(void *userdata); /**< Cleans up the userdata when the joystick is detached */ } SDL_VirtualJoystickDesc; /* Check the size of SDL_VirtualJoystickDesc * * If this assert fails, either the compiler is padding to an unexpected size, * or the interface has been updated and this should be updated to match and * the code using this interface should be updated to handle the old version. */ SDL_COMPILE_TIME_ASSERT(SDL_VirtualJoystickDesc_SIZE, (sizeof(void *) == 4 && sizeof(SDL_VirtualJoystickDesc) == 84) || (sizeof(void *) == 8 && sizeof(SDL_VirtualJoystickDesc) == 136)); /** * Attach a new virtual joystick. * * Apps can create virtual joysticks, that exist without hardware directly * backing them, and have program-supplied inputs. Once attached, a virtual * joystick looks like any other joystick that SDL can access. These can be * used to make other things look like joysticks, or provide pre-recorded * input, etc. * * Once attached, the app can send joystick inputs to the new virtual joystick * using SDL_SetJoystickVirtualAxis(), etc. * * When no longer needed, the virtual joystick can be removed by calling * SDL_DetachVirtualJoystick(). * * \param desc joystick description, initialized using SDL_INIT_INTERFACE(). * \returns the joystick instance ID, or 0 on failure; call SDL_GetError() for * more information. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_DetachVirtualJoystick * \sa SDL_SetJoystickVirtualAxis * \sa SDL_SetJoystickVirtualButton * \sa SDL_SetJoystickVirtualBall * \sa SDL_SetJoystickVirtualHat * \sa SDL_SetJoystickVirtualTouchpad * \sa SDL_SetJoystickVirtualSensorData */ extern SDL_DECLSPEC SDL_JoystickID SDLCALL SDL_AttachVirtualJoystick(const SDL_VirtualJoystickDesc *desc); /** * Detach a virtual joystick. * * \param instance_id the joystick instance ID, previously returned from * SDL_AttachVirtualJoystick(). * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_AttachVirtualJoystick */ extern SDL_DECLSPEC bool SDLCALL SDL_DetachVirtualJoystick(SDL_JoystickID instance_id); /** * Query whether or not a joystick is virtual. * * \param instance_id the joystick instance ID. * \returns true if the joystick is virtual, false otherwise. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC bool SDLCALL SDL_IsJoystickVirtual(SDL_JoystickID instance_id); /** * Set the state of an axis on an opened virtual joystick. * * Please note that values set here will not be applied until the next call to * SDL_UpdateJoysticks, which can either be called directly, or can be called * indirectly through various other SDL APIs, including, but not limited to * the following: SDL_PollEvent, SDL_PumpEvents, SDL_WaitEventTimeout, * SDL_WaitEvent. * * Note that when sending trigger axes, you should scale the value to the full * range of Sint16. For example, a trigger at rest would have the value of * `SDL_JOYSTICK_AXIS_MIN`. * * \param joystick the virtual joystick on which to set state. * \param axis the index of the axis on the virtual joystick to update. * \param value the new value for the specified axis. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_SetJoystickVirtualButton * \sa SDL_SetJoystickVirtualBall * \sa SDL_SetJoystickVirtualHat * \sa SDL_SetJoystickVirtualTouchpad * \sa SDL_SetJoystickVirtualSensorData */ extern SDL_DECLSPEC bool SDLCALL SDL_SetJoystickVirtualAxis(SDL_Joystick *joystick, int axis, Sint16 value); /** * Generate ball motion on an opened virtual joystick. * * Please note that values set here will not be applied until the next call to * SDL_UpdateJoysticks, which can either be called directly, or can be called * indirectly through various other SDL APIs, including, but not limited to * the following: SDL_PollEvent, SDL_PumpEvents, SDL_WaitEventTimeout, * SDL_WaitEvent. * * \param joystick the virtual joystick on which to set state. * \param ball the index of the ball on the virtual joystick to update. * \param xrel the relative motion on the X axis. * \param yrel the relative motion on the Y axis. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_SetJoystickVirtualAxis * \sa SDL_SetJoystickVirtualButton * \sa SDL_SetJoystickVirtualHat * \sa SDL_SetJoystickVirtualTouchpad * \sa SDL_SetJoystickVirtualSensorData */ extern SDL_DECLSPEC bool SDLCALL SDL_SetJoystickVirtualBall(SDL_Joystick *joystick, int ball, Sint16 xrel, Sint16 yrel); /** * Set the state of a button on an opened virtual joystick. * * Please note that values set here will not be applied until the next call to * SDL_UpdateJoysticks, which can either be called directly, or can be called * indirectly through various other SDL APIs, including, but not limited to * the following: SDL_PollEvent, SDL_PumpEvents, SDL_WaitEventTimeout, * SDL_WaitEvent. * * \param joystick the virtual joystick on which to set state. * \param button the index of the button on the virtual joystick to update. * \param down true if the button is pressed, false otherwise. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_SetJoystickVirtualAxis * \sa SDL_SetJoystickVirtualBall * \sa SDL_SetJoystickVirtualHat * \sa SDL_SetJoystickVirtualTouchpad * \sa SDL_SetJoystickVirtualSensorData */ extern SDL_DECLSPEC bool SDLCALL SDL_SetJoystickVirtualButton(SDL_Joystick *joystick, int button, bool down); /** * Set the state of a hat on an opened virtual joystick. * * Please note that values set here will not be applied until the next call to * SDL_UpdateJoysticks, which can either be called directly, or can be called * indirectly through various other SDL APIs, including, but not limited to * the following: SDL_PollEvent, SDL_PumpEvents, SDL_WaitEventTimeout, * SDL_WaitEvent. * * \param joystick the virtual joystick on which to set state. * \param hat the index of the hat on the virtual joystick to update. * \param value the new value for the specified hat. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_SetJoystickVirtualAxis * \sa SDL_SetJoystickVirtualButton * \sa SDL_SetJoystickVirtualBall * \sa SDL_SetJoystickVirtualTouchpad * \sa SDL_SetJoystickVirtualSensorData */ extern SDL_DECLSPEC bool SDLCALL SDL_SetJoystickVirtualHat(SDL_Joystick *joystick, int hat, Uint8 value); /** * Set touchpad finger state on an opened virtual joystick. * * Please note that values set here will not be applied until the next call to * SDL_UpdateJoysticks, which can either be called directly, or can be called * indirectly through various other SDL APIs, including, but not limited to * the following: SDL_PollEvent, SDL_PumpEvents, SDL_WaitEventTimeout, * SDL_WaitEvent. * * \param joystick the virtual joystick on which to set state. * \param touchpad the index of the touchpad on the virtual joystick to * update. * \param finger the index of the finger on the touchpad to set. * \param down true if the finger is pressed, false if the finger is released. * \param x the x coordinate of the finger on the touchpad, normalized 0 to 1, * with the origin in the upper left. * \param y the y coordinate of the finger on the touchpad, normalized 0 to 1, * with the origin in the upper left. * \param pressure the pressure of the finger. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_SetJoystickVirtualAxis * \sa SDL_SetJoystickVirtualButton * \sa SDL_SetJoystickVirtualBall * \sa SDL_SetJoystickVirtualHat * \sa SDL_SetJoystickVirtualSensorData */ extern SDL_DECLSPEC bool SDLCALL SDL_SetJoystickVirtualTouchpad(SDL_Joystick *joystick, int touchpad, int finger, bool down, float x, float y, float pressure); /** * Send a sensor update for an opened virtual joystick. * * Please note that values set here will not be applied until the next call to * SDL_UpdateJoysticks, which can either be called directly, or can be called * indirectly through various other SDL APIs, including, but not limited to * the following: SDL_PollEvent, SDL_PumpEvents, SDL_WaitEventTimeout, * SDL_WaitEvent. * * \param joystick the virtual joystick on which to set state. * \param type the type of the sensor on the virtual joystick to update. * \param sensor_timestamp a 64-bit timestamp in nanoseconds associated with * the sensor reading. * \param data the data associated with the sensor reading. * \param num_values the number of values pointed to by `data`. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_SetJoystickVirtualAxis * \sa SDL_SetJoystickVirtualButton * \sa SDL_SetJoystickVirtualBall * \sa SDL_SetJoystickVirtualHat * \sa SDL_SetJoystickVirtualTouchpad */ extern SDL_DECLSPEC bool SDLCALL SDL_SendJoystickVirtualSensorData(SDL_Joystick *joystick, SDL_SensorType type, Uint64 sensor_timestamp, const float *data, int num_values); /** * Get the properties associated with a joystick. * * The following read-only properties are provided by SDL: * * - `SDL_PROP_JOYSTICK_CAP_MONO_LED_BOOLEAN`: true if this joystick has an * LED that has adjustable brightness * - `SDL_PROP_JOYSTICK_CAP_RGB_LED_BOOLEAN`: true if this joystick has an LED * that has adjustable color * - `SDL_PROP_JOYSTICK_CAP_PLAYER_LED_BOOLEAN`: true if this joystick has a * player LED * - `SDL_PROP_JOYSTICK_CAP_RUMBLE_BOOLEAN`: true if this joystick has * left/right rumble * - `SDL_PROP_JOYSTICK_CAP_TRIGGER_RUMBLE_BOOLEAN`: true if this joystick has * simple trigger rumble * * \param joystick the SDL_Joystick obtained from SDL_OpenJoystick(). * \returns a valid property ID on success or 0 on failure; call * SDL_GetError() for more information. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC SDL_PropertiesID SDLCALL SDL_GetJoystickProperties(SDL_Joystick *joystick); #define SDL_PROP_JOYSTICK_CAP_MONO_LED_BOOLEAN "SDL.joystick.cap.mono_led" #define SDL_PROP_JOYSTICK_CAP_RGB_LED_BOOLEAN "SDL.joystick.cap.rgb_led" #define SDL_PROP_JOYSTICK_CAP_PLAYER_LED_BOOLEAN "SDL.joystick.cap.player_led" #define SDL_PROP_JOYSTICK_CAP_RUMBLE_BOOLEAN "SDL.joystick.cap.rumble" #define SDL_PROP_JOYSTICK_CAP_TRIGGER_RUMBLE_BOOLEAN "SDL.joystick.cap.trigger_rumble" /** * Get the implementation dependent name of a joystick. * * \param joystick the SDL_Joystick obtained from SDL_OpenJoystick(). * \returns the name of the selected joystick. If no name can be found, this * function returns NULL; call SDL_GetError() for more information. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetJoystickNameForID */ extern SDL_DECLSPEC const char * SDLCALL SDL_GetJoystickName(SDL_Joystick *joystick); /** * Get the implementation dependent path of a joystick. * * \param joystick the SDL_Joystick obtained from SDL_OpenJoystick(). * \returns the path of the selected joystick. If no path can be found, this * function returns NULL; call SDL_GetError() for more information. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetJoystickPathForID */ extern SDL_DECLSPEC const char * SDLCALL SDL_GetJoystickPath(SDL_Joystick *joystick); /** * Get the player index of an opened joystick. * * For XInput controllers this returns the XInput user index. Many joysticks * will not be able to supply this information. * * \param joystick the SDL_Joystick obtained from SDL_OpenJoystick(). * \returns the player index, or -1 if it's not available. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_SetJoystickPlayerIndex */ extern SDL_DECLSPEC int SDLCALL SDL_GetJoystickPlayerIndex(SDL_Joystick *joystick); /** * Set the player index of an opened joystick. * * \param joystick the SDL_Joystick obtained from SDL_OpenJoystick(). * \param player_index player index to assign to this joystick, or -1 to clear * the player index and turn off player LEDs. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetJoystickPlayerIndex */ extern SDL_DECLSPEC bool SDLCALL SDL_SetJoystickPlayerIndex(SDL_Joystick *joystick, int player_index); /** * Get the implementation-dependent GUID for the joystick. * * This function requires an open joystick. * * \param joystick the SDL_Joystick obtained from SDL_OpenJoystick(). * \returns the GUID of the given joystick. If called on an invalid index, * this function returns a zero GUID; call SDL_GetError() for more * information. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetJoystickGUIDForID * \sa SDL_GUIDToString */ extern SDL_DECLSPEC SDL_GUID SDLCALL SDL_GetJoystickGUID(SDL_Joystick *joystick); /** * Get the USB vendor ID of an opened joystick, if available. * * If the vendor ID isn't available this function returns 0. * * \param joystick the SDL_Joystick obtained from SDL_OpenJoystick(). * \returns the USB vendor ID of the selected joystick, or 0 if unavailable. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetJoystickVendorForID */ extern SDL_DECLSPEC Uint16 SDLCALL SDL_GetJoystickVendor(SDL_Joystick *joystick); /** * Get the USB product ID of an opened joystick, if available. * * If the product ID isn't available this function returns 0. * * \param joystick the SDL_Joystick obtained from SDL_OpenJoystick(). * \returns the USB product ID of the selected joystick, or 0 if unavailable. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetJoystickProductForID */ extern SDL_DECLSPEC Uint16 SDLCALL SDL_GetJoystickProduct(SDL_Joystick *joystick); /** * Get the product version of an opened joystick, if available. * * If the product version isn't available this function returns 0. * * \param joystick the SDL_Joystick obtained from SDL_OpenJoystick(). * \returns the product version of the selected joystick, or 0 if unavailable. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetJoystickProductVersionForID */ extern SDL_DECLSPEC Uint16 SDLCALL SDL_GetJoystickProductVersion(SDL_Joystick *joystick); /** * Get the firmware version of an opened joystick, if available. * * If the firmware version isn't available this function returns 0. * * \param joystick the SDL_Joystick obtained from SDL_OpenJoystick(). * \returns the firmware version of the selected joystick, or 0 if * unavailable. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC Uint16 SDLCALL SDL_GetJoystickFirmwareVersion(SDL_Joystick *joystick); /** * Get the serial number of an opened joystick, if available. * * Returns the serial number of the joystick, or NULL if it is not available. * * \param joystick the SDL_Joystick obtained from SDL_OpenJoystick(). * \returns the serial number of the selected joystick, or NULL if * unavailable. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC const char * SDLCALL SDL_GetJoystickSerial(SDL_Joystick *joystick); /** * Get the type of an opened joystick. * * \param joystick the SDL_Joystick obtained from SDL_OpenJoystick(). * \returns the SDL_JoystickType of the selected joystick. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetJoystickTypeForID */ extern SDL_DECLSPEC SDL_JoystickType SDLCALL SDL_GetJoystickType(SDL_Joystick *joystick); /** * Get the device information encoded in a SDL_GUID structure. * * \param guid the SDL_GUID you wish to get info about. * \param vendor a pointer filled in with the device VID, or 0 if not * available. * \param product a pointer filled in with the device PID, or 0 if not * available. * \param version a pointer filled in with the device version, or 0 if not * available. * \param crc16 a pointer filled in with a CRC used to distinguish different * products with the same VID/PID, or 0 if not available. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetJoystickGUIDForID */ extern SDL_DECLSPEC void SDLCALL SDL_GetJoystickGUIDInfo(SDL_GUID guid, Uint16 *vendor, Uint16 *product, Uint16 *version, Uint16 *crc16); /** * Get the status of a specified joystick. * * \param joystick the joystick to query. * \returns true if the joystick has been opened, false if it has not; call * SDL_GetError() for more information. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC bool SDLCALL SDL_JoystickConnected(SDL_Joystick *joystick); /** * Get the instance ID of an opened joystick. * * \param joystick an SDL_Joystick structure containing joystick information. * \returns the instance ID of the specified joystick on success or 0 on * failure; call SDL_GetError() for more information. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC SDL_JoystickID SDLCALL SDL_GetJoystickID(SDL_Joystick *joystick); /** * Get the number of general axis controls on a joystick. * * Often, the directional pad on a game controller will either look like 4 * separate buttons or a POV hat, and not axes, but all of this is up to the * device and platform. * * \param joystick an SDL_Joystick structure containing joystick information. * \returns the number of axis controls/number of axes on success or -1 on * failure; call SDL_GetError() for more information. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetJoystickAxis * \sa SDL_GetNumJoystickBalls * \sa SDL_GetNumJoystickButtons * \sa SDL_GetNumJoystickHats */ extern SDL_DECLSPEC int SDLCALL SDL_GetNumJoystickAxes(SDL_Joystick *joystick); /** * Get the number of trackballs on a joystick. * * Joystick trackballs have only relative motion events associated with them * and their state cannot be polled. * * Most joysticks do not have trackballs. * * \param joystick an SDL_Joystick structure containing joystick information. * \returns the number of trackballs on success or -1 on failure; call * SDL_GetError() for more information. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetJoystickBall * \sa SDL_GetNumJoystickAxes * \sa SDL_GetNumJoystickButtons * \sa SDL_GetNumJoystickHats */ extern SDL_DECLSPEC int SDLCALL SDL_GetNumJoystickBalls(SDL_Joystick *joystick); /** * Get the number of POV hats on a joystick. * * \param joystick an SDL_Joystick structure containing joystick information. * \returns the number of POV hats on success or -1 on failure; call * SDL_GetError() for more information. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetJoystickHat * \sa SDL_GetNumJoystickAxes * \sa SDL_GetNumJoystickBalls * \sa SDL_GetNumJoystickButtons */ extern SDL_DECLSPEC int SDLCALL SDL_GetNumJoystickHats(SDL_Joystick *joystick); /** * Get the number of buttons on a joystick. * * \param joystick an SDL_Joystick structure containing joystick information. * \returns the number of buttons on success or -1 on failure; call * SDL_GetError() for more information. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetJoystickButton * \sa SDL_GetNumJoystickAxes * \sa SDL_GetNumJoystickBalls * \sa SDL_GetNumJoystickHats */ extern SDL_DECLSPEC int SDLCALL SDL_GetNumJoystickButtons(SDL_Joystick *joystick); /** * Set the state of joystick event processing. * * If joystick events are disabled, you must call SDL_UpdateJoysticks() * yourself and check the state of the joystick when you want joystick * information. * * \param enabled whether to process joystick events or not. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_JoystickEventsEnabled * \sa SDL_UpdateJoysticks */ extern SDL_DECLSPEC void SDLCALL SDL_SetJoystickEventsEnabled(bool enabled); /** * Query the state of joystick event processing. * * If joystick events are disabled, you must call SDL_UpdateJoysticks() * yourself and check the state of the joystick when you want joystick * information. * * \returns true if joystick events are being processed, false otherwise. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_SetJoystickEventsEnabled */ extern SDL_DECLSPEC bool SDLCALL SDL_JoystickEventsEnabled(void); /** * Update the current state of the open joysticks. * * This is called automatically by the event loop if any joystick events are * enabled. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC void SDLCALL SDL_UpdateJoysticks(void); /** * Get the current state of an axis control on a joystick. * * SDL makes no promises about what part of the joystick any given axis refers * to. Your game should have some sort of configuration UI to let users * specify what each axis should be bound to. Alternately, SDL's higher-level * Game Controller API makes a great effort to apply order to this lower-level * interface, so you know that a specific axis is the "left thumb stick," etc. * * The value returned by SDL_GetJoystickAxis() is a signed integer (-32768 to * 32767) representing the current position of the axis. It may be necessary * to impose certain tolerances on these values to account for jitter. * * \param joystick an SDL_Joystick structure containing joystick information. * \param axis the axis to query; the axis indices start at index 0. * \returns a 16-bit signed integer representing the current position of the * axis or 0 on failure; call SDL_GetError() for more information. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetNumJoystickAxes */ extern SDL_DECLSPEC Sint16 SDLCALL SDL_GetJoystickAxis(SDL_Joystick *joystick, int axis); /** * Get the initial state of an axis control on a joystick. * * The state is a value ranging from -32768 to 32767. * * The axis indices start at index 0. * * \param joystick an SDL_Joystick structure containing joystick information. * \param axis the axis to query; the axis indices start at index 0. * \param state upon return, the initial value is supplied here. * \returns true if this axis has any initial value, or false if not. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC bool SDLCALL SDL_GetJoystickAxisInitialState(SDL_Joystick *joystick, int axis, Sint16 *state); /** * Get the ball axis change since the last poll. * * Trackballs can only return relative motion since the last call to * SDL_GetJoystickBall(), these motion deltas are placed into `dx` and `dy`. * * Most joysticks do not have trackballs. * * \param joystick the SDL_Joystick to query. * \param ball the ball index to query; ball indices start at index 0. * \param dx stores the difference in the x axis position since the last poll. * \param dy stores the difference in the y axis position since the last poll. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetNumJoystickBalls */ extern SDL_DECLSPEC bool SDLCALL SDL_GetJoystickBall(SDL_Joystick *joystick, int ball, int *dx, int *dy); /** * Get the current state of a POV hat on a joystick. * * The returned value will be one of the `SDL_HAT_*` values. * * \param joystick an SDL_Joystick structure containing joystick information. * \param hat the hat index to get the state from; indices start at index 0. * \returns the current hat position. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetNumJoystickHats */ extern SDL_DECLSPEC Uint8 SDLCALL SDL_GetJoystickHat(SDL_Joystick *joystick, int hat); #define SDL_HAT_CENTERED 0x00u #define SDL_HAT_UP 0x01u #define SDL_HAT_RIGHT 0x02u #define SDL_HAT_DOWN 0x04u #define SDL_HAT_LEFT 0x08u #define SDL_HAT_RIGHTUP (SDL_HAT_RIGHT|SDL_HAT_UP) #define SDL_HAT_RIGHTDOWN (SDL_HAT_RIGHT|SDL_HAT_DOWN) #define SDL_HAT_LEFTUP (SDL_HAT_LEFT|SDL_HAT_UP) #define SDL_HAT_LEFTDOWN (SDL_HAT_LEFT|SDL_HAT_DOWN) /** * Get the current state of a button on a joystick. * * \param joystick an SDL_Joystick structure containing joystick information. * \param button the button index to get the state from; indices start at * index 0. * \returns true if the button is pressed, false otherwise. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetNumJoystickButtons */ extern SDL_DECLSPEC bool SDLCALL SDL_GetJoystickButton(SDL_Joystick *joystick, int button); /** * Start a rumble effect. * * Each call to this function cancels any previous rumble effect, and calling * it with 0 intensity stops any rumbling. * * This function requires you to process SDL events or call * SDL_UpdateJoysticks() to update rumble state. * * \param joystick the joystick to vibrate. * \param low_frequency_rumble the intensity of the low frequency (left) * rumble motor, from 0 to 0xFFFF. * \param high_frequency_rumble the intensity of the high frequency (right) * rumble motor, from 0 to 0xFFFF. * \param duration_ms the duration of the rumble effect, in milliseconds. * \returns true, or false if rumble isn't supported on this joystick. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC bool SDLCALL SDL_RumbleJoystick(SDL_Joystick *joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble, Uint32 duration_ms); /** * Start a rumble effect in the joystick's triggers. * * Each call to this function cancels any previous trigger rumble effect, and * calling it with 0 intensity stops any rumbling. * * Note that this is rumbling of the _triggers_ and not the game controller as * a whole. This is currently only supported on Xbox One controllers. If you * want the (more common) whole-controller rumble, use SDL_RumbleJoystick() * instead. * * This function requires you to process SDL events or call * SDL_UpdateJoysticks() to update rumble state. * * \param joystick the joystick to vibrate. * \param left_rumble the intensity of the left trigger rumble motor, from 0 * to 0xFFFF. * \param right_rumble the intensity of the right trigger rumble motor, from 0 * to 0xFFFF. * \param duration_ms the duration of the rumble effect, in milliseconds. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_RumbleJoystick */ extern SDL_DECLSPEC bool SDLCALL SDL_RumbleJoystickTriggers(SDL_Joystick *joystick, Uint16 left_rumble, Uint16 right_rumble, Uint32 duration_ms); /** * Update a joystick's LED color. * * An example of a joystick LED is the light on the back of a PlayStation 4's * DualShock 4 controller. * * For joysticks with a single color LED, the maximum of the RGB values will * be used as the LED brightness. * * \param joystick the joystick to update. * \param red the intensity of the red LED. * \param green the intensity of the green LED. * \param blue the intensity of the blue LED. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC bool SDLCALL SDL_SetJoystickLED(SDL_Joystick *joystick, Uint8 red, Uint8 green, Uint8 blue); /** * Send a joystick specific effect packet. * * \param joystick the joystick to affect. * \param data the data to send to the joystick. * \param size the size of the data to send to the joystick. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC bool SDLCALL SDL_SendJoystickEffect(SDL_Joystick *joystick, const void *data, int size); /** * Close a joystick previously opened with SDL_OpenJoystick(). * * \param joystick the joystick device to close. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_OpenJoystick */ extern SDL_DECLSPEC void SDLCALL SDL_CloseJoystick(SDL_Joystick *joystick); /** * Get the connection state of a joystick. * * \param joystick the joystick to query. * \returns the connection state on success or * `SDL_JOYSTICK_CONNECTION_INVALID` on failure; call SDL_GetError() * for more information. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC SDL_JoystickConnectionState SDLCALL SDL_GetJoystickConnectionState(SDL_Joystick *joystick); /** * Get the battery state of a joystick. * * You should never take a battery status as absolute truth. Batteries * (especially failing batteries) are delicate hardware, and the values * reported here are best estimates based on what that hardware reports. It's * not uncommon for older batteries to lose stored power much faster than it * reports, or completely drain when reporting it has 20 percent left, etc. * * \param joystick the joystick to query. * \param percent a pointer filled in with the percentage of battery life * left, between 0 and 100, or NULL to ignore. This will be * filled in with -1 we can't determine a value or there is no * battery. * \returns the current battery state or `SDL_POWERSTATE_ERROR` on failure; * call SDL_GetError() for more information. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC SDL_PowerState SDLCALL SDL_GetJoystickPowerInfo(SDL_Joystick *joystick, int *percent); /* Ends C function definitions when using C++ */ #ifdef __cplusplus } #endif #include #endif /* SDL_joystick_h_ */ ================================================ FILE: deps/include/SDL3/SDL_keyboard.h ================================================ /* Simple DirectMedia Layer Copyright (C) 1997-2026 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ /** * # CategoryKeyboard * * SDL keyboard management. * * Please refer to the Best Keyboard Practices document for details on how * best to accept keyboard input in various types of programs: * * https://wiki.libsdl.org/SDL3/BestKeyboardPractices */ #ifndef SDL_keyboard_h_ #define SDL_keyboard_h_ #include #include #include #include #include #include #include #include /* Set up for C function definitions, even when using C++ */ #ifdef __cplusplus extern "C" { #endif /** * This is a unique ID for a keyboard for the time it is connected to the * system, and is never reused for the lifetime of the application. * * If the keyboard is disconnected and reconnected, it will get a new ID. * * The value 0 is an invalid ID. * * \since This datatype is available since SDL 3.2.0. */ typedef Uint32 SDL_KeyboardID; /* Function prototypes */ /** * Return whether a keyboard is currently connected. * * \returns true if a keyboard is connected, false otherwise. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetKeyboards */ extern SDL_DECLSPEC bool SDLCALL SDL_HasKeyboard(void); /** * Get a list of currently connected keyboards. * * Note that this will include any device or virtual driver that includes * keyboard functionality, including some mice, KVM switches, motherboard * power buttons, etc. You should wait for input from a device before you * consider it actively in use. * * \param count a pointer filled in with the number of keyboards returned, may * be NULL. * \returns a 0 terminated array of keyboards instance IDs or NULL on failure; * call SDL_GetError() for more information. This should be freed * with SDL_free() when it is no longer needed. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetKeyboardNameForID * \sa SDL_HasKeyboard */ extern SDL_DECLSPEC SDL_KeyboardID * SDLCALL SDL_GetKeyboards(int *count); /** * Get the name of a keyboard. * * This function returns "" if the keyboard doesn't have a name. * * \param instance_id the keyboard instance ID. * \returns the name of the selected keyboard or NULL on failure; call * SDL_GetError() for more information. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetKeyboards */ extern SDL_DECLSPEC const char * SDLCALL SDL_GetKeyboardNameForID(SDL_KeyboardID instance_id); /** * Query the window which currently has keyboard focus. * * \returns the window with keyboard focus. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC SDL_Window * SDLCALL SDL_GetKeyboardFocus(void); /** * Get a snapshot of the current state of the keyboard. * * The pointer returned is a pointer to an internal SDL array. It will be * valid for the whole lifetime of the application and should not be freed by * the caller. * * A array element with a value of true means that the key is pressed and a * value of false means that it is not. Indexes into this array are obtained * by using SDL_Scancode values. * * Use SDL_PumpEvents() to update the state array. * * This function gives you the current state after all events have been * processed, so if a key or button has been pressed and released before you * process events, then the pressed state will never show up in the * SDL_GetKeyboardState() calls. * * Note: This function doesn't take into account whether shift has been * pressed or not. * * \param numkeys if non-NULL, receives the length of the returned array. * \returns a pointer to an array of key states. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_PumpEvents * \sa SDL_ResetKeyboard */ extern SDL_DECLSPEC const bool * SDLCALL SDL_GetKeyboardState(int *numkeys); /** * Clear the state of the keyboard. * * This function will generate key up events for all pressed keys. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetKeyboardState */ extern SDL_DECLSPEC void SDLCALL SDL_ResetKeyboard(void); /** * Get the current key modifier state for the keyboard. * * \returns an OR'd combination of the modifier keys for the keyboard. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetKeyboardState * \sa SDL_SetModState */ extern SDL_DECLSPEC SDL_Keymod SDLCALL SDL_GetModState(void); /** * Set the current key modifier state for the keyboard. * * The inverse of SDL_GetModState(), SDL_SetModState() allows you to impose * modifier key states on your application. Simply pass your desired modifier * states into `modstate`. This value may be a bitwise, OR'd combination of * SDL_Keymod values. * * This does not change the keyboard state, only the key modifier flags that * SDL reports. * * \param modstate the desired SDL_Keymod for the keyboard. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetModState */ extern SDL_DECLSPEC void SDLCALL SDL_SetModState(SDL_Keymod modstate); /** * Get the key code corresponding to the given scancode according to the * current keyboard layout. * * If you want to get the keycode as it would be delivered in key events, * including options specified in SDL_HINT_KEYCODE_OPTIONS, then you should * pass `key_event` as true. Otherwise this function simply translates the * scancode based on the given modifier state. * * \param scancode the desired SDL_Scancode to query. * \param modstate the modifier state to use when translating the scancode to * a keycode. * \param key_event true if the keycode will be used in key events. * \returns the SDL_Keycode that corresponds to the given SDL_Scancode. * * \threadsafety This function is not thread safe. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetKeyName * \sa SDL_GetScancodeFromKey */ extern SDL_DECLSPEC SDL_Keycode SDLCALL SDL_GetKeyFromScancode(SDL_Scancode scancode, SDL_Keymod modstate, bool key_event); /** * Get the scancode corresponding to the given key code according to the * current keyboard layout. * * Note that there may be multiple scancode+modifier states that can generate * this keycode, this will just return the first one found. * * \param key the desired SDL_Keycode to query. * \param modstate a pointer to the modifier state that would be used when the * scancode generates this key, may be NULL. * \returns the SDL_Scancode that corresponds to the given SDL_Keycode. * * \threadsafety This function is not thread safe. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetKeyFromScancode * \sa SDL_GetScancodeName */ extern SDL_DECLSPEC SDL_Scancode SDLCALL SDL_GetScancodeFromKey(SDL_Keycode key, SDL_Keymod *modstate); /** * Set a human-readable name for a scancode. * * \param scancode the desired SDL_Scancode. * \param name the name to use for the scancode, encoded as UTF-8. The string * is not copied, so the pointer given to this function must stay * valid while SDL is being used. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety This function is not thread safe. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetScancodeName */ extern SDL_DECLSPEC bool SDLCALL SDL_SetScancodeName(SDL_Scancode scancode, const char *name); /** * Get a human-readable name for a scancode. * * **Warning**: The returned name is by design not stable across platforms, * e.g. the name for `SDL_SCANCODE_LGUI` is "Left GUI" under Linux but "Left * Windows" under Microsoft Windows, and some scancodes like * `SDL_SCANCODE_NONUSBACKSLASH` don't have any name at all. There are even * scancodes that share names, e.g. `SDL_SCANCODE_RETURN` and * `SDL_SCANCODE_RETURN2` (both called "Return"). This function is therefore * unsuitable for creating a stable cross-platform two-way mapping between * strings and scancodes. * * \param scancode the desired SDL_Scancode to query. * \returns a pointer to the name for the scancode. If the scancode doesn't * have a name this function returns an empty string (""). * * \threadsafety This function is not thread safe. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetScancodeFromKey * \sa SDL_GetScancodeFromName * \sa SDL_SetScancodeName */ extern SDL_DECLSPEC const char * SDLCALL SDL_GetScancodeName(SDL_Scancode scancode); /** * Get a scancode from a human-readable name. * * \param name the human-readable scancode name. * \returns the SDL_Scancode, or `SDL_SCANCODE_UNKNOWN` if the name wasn't * recognized; call SDL_GetError() for more information. * * \threadsafety This function is not thread safe. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetKeyFromName * \sa SDL_GetScancodeFromKey * \sa SDL_GetScancodeName */ extern SDL_DECLSPEC SDL_Scancode SDLCALL SDL_GetScancodeFromName(const char *name); /** * Get a human-readable name for a key. * * If the key doesn't have a name, this function returns an empty string (""). * * Letters will be presented in their uppercase form, if applicable. * * \param key the desired SDL_Keycode to query. * \returns a UTF-8 encoded string of the key name. * * \threadsafety This function is not thread safe. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetKeyFromName * \sa SDL_GetKeyFromScancode * \sa SDL_GetScancodeFromKey */ extern SDL_DECLSPEC const char * SDLCALL SDL_GetKeyName(SDL_Keycode key); /** * Get a key code from a human-readable name. * * \param name the human-readable key name. * \returns key code, or `SDLK_UNKNOWN` if the name wasn't recognized; call * SDL_GetError() for more information. * * \threadsafety This function is not thread safe. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetKeyFromScancode * \sa SDL_GetKeyName * \sa SDL_GetScancodeFromName */ extern SDL_DECLSPEC SDL_Keycode SDLCALL SDL_GetKeyFromName(const char *name); /** * Start accepting Unicode text input events in a window. * * This function will enable text input (SDL_EVENT_TEXT_INPUT and * SDL_EVENT_TEXT_EDITING events) in the specified window. Please use this * function paired with SDL_StopTextInput(). * * Text input events are not received by default. * * On some platforms using this function shows the screen keyboard and/or * activates an IME, which can prevent some key press events from being passed * through. * * \param window the window to enable text input. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_SetTextInputArea * \sa SDL_StartTextInputWithProperties * \sa SDL_StopTextInput * \sa SDL_TextInputActive */ extern SDL_DECLSPEC bool SDLCALL SDL_StartTextInput(SDL_Window *window); /** * Text input type. * * These are the valid values for SDL_PROP_TEXTINPUT_TYPE_NUMBER. Not every * value is valid on every platform, but where a value isn't supported, a * reasonable fallback will be used. * * \since This enum is available since SDL 3.2.0. * * \sa SDL_StartTextInputWithProperties */ typedef enum SDL_TextInputType { SDL_TEXTINPUT_TYPE_TEXT, /**< The input is text */ SDL_TEXTINPUT_TYPE_TEXT_NAME, /**< The input is a person's name */ SDL_TEXTINPUT_TYPE_TEXT_EMAIL, /**< The input is an e-mail address */ SDL_TEXTINPUT_TYPE_TEXT_USERNAME, /**< The input is a username */ SDL_TEXTINPUT_TYPE_TEXT_PASSWORD_HIDDEN, /**< The input is a secure password that is hidden */ SDL_TEXTINPUT_TYPE_TEXT_PASSWORD_VISIBLE, /**< The input is a secure password that is visible */ SDL_TEXTINPUT_TYPE_NUMBER, /**< The input is a number */ SDL_TEXTINPUT_TYPE_NUMBER_PASSWORD_HIDDEN, /**< The input is a secure PIN that is hidden */ SDL_TEXTINPUT_TYPE_NUMBER_PASSWORD_VISIBLE /**< The input is a secure PIN that is visible */ } SDL_TextInputType; /** * Auto capitalization type. * * These are the valid values for SDL_PROP_TEXTINPUT_CAPITALIZATION_NUMBER. * Not every value is valid on every platform, but where a value isn't * supported, a reasonable fallback will be used. * * \since This enum is available since SDL 3.2.0. * * \sa SDL_StartTextInputWithProperties */ typedef enum SDL_Capitalization { SDL_CAPITALIZE_NONE, /**< No auto-capitalization will be done */ SDL_CAPITALIZE_SENTENCES, /**< The first letter of sentences will be capitalized */ SDL_CAPITALIZE_WORDS, /**< The first letter of words will be capitalized */ SDL_CAPITALIZE_LETTERS /**< All letters will be capitalized */ } SDL_Capitalization; /** * Start accepting Unicode text input events in a window, with properties * describing the input. * * This function will enable text input (SDL_EVENT_TEXT_INPUT and * SDL_EVENT_TEXT_EDITING events) in the specified window. Please use this * function paired with SDL_StopTextInput(). * * Text input events are not received by default. * * On some platforms using this function shows the screen keyboard and/or * activates an IME, which can prevent some key press events from being passed * through. * * These are the supported properties: * * - `SDL_PROP_TEXTINPUT_TYPE_NUMBER` - an SDL_TextInputType value that * describes text being input, defaults to SDL_TEXTINPUT_TYPE_TEXT. * - `SDL_PROP_TEXTINPUT_CAPITALIZATION_NUMBER` - an SDL_Capitalization value * that describes how text should be capitalized, defaults to * SDL_CAPITALIZE_SENTENCES for normal text entry, SDL_CAPITALIZE_WORDS for * SDL_TEXTINPUT_TYPE_TEXT_NAME, and SDL_CAPITALIZE_NONE for e-mail * addresses, usernames, and passwords. * - `SDL_PROP_TEXTINPUT_AUTOCORRECT_BOOLEAN` - true to enable auto completion * and auto correction, defaults to true. * - `SDL_PROP_TEXTINPUT_MULTILINE_BOOLEAN` - true if multiple lines of text * are allowed. This defaults to true if SDL_HINT_RETURN_KEY_HIDES_IME is * "0" or is not set, and defaults to false if SDL_HINT_RETURN_KEY_HIDES_IME * is "1". * * On Android you can directly specify the input type: * * - `SDL_PROP_TEXTINPUT_ANDROID_INPUTTYPE_NUMBER` - the text input type to * use, overriding other properties. This is documented at * https://developer.android.com/reference/android/text/InputType * * \param window the window to enable text input. * \param props the properties to use. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_SetTextInputArea * \sa SDL_StartTextInput * \sa SDL_StopTextInput * \sa SDL_TextInputActive */ extern SDL_DECLSPEC bool SDLCALL SDL_StartTextInputWithProperties(SDL_Window *window, SDL_PropertiesID props); #define SDL_PROP_TEXTINPUT_TYPE_NUMBER "SDL.textinput.type" #define SDL_PROP_TEXTINPUT_CAPITALIZATION_NUMBER "SDL.textinput.capitalization" #define SDL_PROP_TEXTINPUT_AUTOCORRECT_BOOLEAN "SDL.textinput.autocorrect" #define SDL_PROP_TEXTINPUT_MULTILINE_BOOLEAN "SDL.textinput.multiline" #define SDL_PROP_TEXTINPUT_ANDROID_INPUTTYPE_NUMBER "SDL.textinput.android.inputtype" /** * Check whether or not Unicode text input events are enabled for a window. * * \param window the window to check. * \returns true if text input events are enabled else false. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_StartTextInput */ extern SDL_DECLSPEC bool SDLCALL SDL_TextInputActive(SDL_Window *window); /** * Stop receiving any text input events in a window. * * If SDL_StartTextInput() showed the screen keyboard, this function will hide * it. * * \param window the window to disable text input. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_StartTextInput */ extern SDL_DECLSPEC bool SDLCALL SDL_StopTextInput(SDL_Window *window); /** * Dismiss the composition window/IME without disabling the subsystem. * * \param window the window to affect. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_StartTextInput * \sa SDL_StopTextInput */ extern SDL_DECLSPEC bool SDLCALL SDL_ClearComposition(SDL_Window *window); /** * Set the area used to type Unicode text input. * * Native input methods may place a window with word suggestions near the * cursor, without covering the text being entered. * * \param window the window for which to set the text input area. * \param rect the SDL_Rect representing the text input area, in window * coordinates, or NULL to clear it. * \param cursor the offset of the current cursor location relative to * `rect->x`, in window coordinates. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetTextInputArea * \sa SDL_StartTextInput */ extern SDL_DECLSPEC bool SDLCALL SDL_SetTextInputArea(SDL_Window *window, const SDL_Rect *rect, int cursor); /** * Get the area used to type Unicode text input. * * This returns the values previously set by SDL_SetTextInputArea(). * * \param window the window for which to query the text input area. * \param rect a pointer to an SDL_Rect filled in with the text input area, * may be NULL. * \param cursor a pointer to the offset of the current cursor location * relative to `rect->x`, may be NULL. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_SetTextInputArea */ extern SDL_DECLSPEC bool SDLCALL SDL_GetTextInputArea(SDL_Window *window, SDL_Rect *rect, int *cursor); /** * Check whether the platform has screen keyboard support. * * \returns true if the platform has some screen keyboard support or false if * not. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_StartTextInput * \sa SDL_ScreenKeyboardShown */ extern SDL_DECLSPEC bool SDLCALL SDL_HasScreenKeyboardSupport(void); /** * Check whether the screen keyboard is shown for given window. * * \param window the window for which screen keyboard should be queried. * \returns true if screen keyboard is shown or false if not. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_HasScreenKeyboardSupport */ extern SDL_DECLSPEC bool SDLCALL SDL_ScreenKeyboardShown(SDL_Window *window); /* Ends C function definitions when using C++ */ #ifdef __cplusplus } #endif #include #endif /* SDL_keyboard_h_ */ ================================================ FILE: deps/include/SDL3/SDL_keycode.h ================================================ /* Simple DirectMedia Layer Copyright (C) 1997-2026 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ /** * # CategoryKeycode * * Defines constants which identify keyboard keys and modifiers. * * Please refer to the Best Keyboard Practices document for details on what * this information means and how best to use it. * * https://wiki.libsdl.org/SDL3/BestKeyboardPractices */ #ifndef SDL_keycode_h_ #define SDL_keycode_h_ #include #include /** * The SDL virtual key representation. * * Values of this type are used to represent keyboard keys using the current * layout of the keyboard. These values include Unicode values representing * the unmodified character that would be generated by pressing the key, or an * `SDLK_*` constant for those keys that do not generate characters. * * A special exception is the number keys at the top of the keyboard which map * by default to SDLK_0...SDLK_9 on AZERTY layouts. * * Keys with the `SDLK_EXTENDED_MASK` bit set do not map to a scancode or * Unicode code point. * * Many common keycodes are listed below, but this list is not exhaustive. * * \since This datatype is available since SDL 3.2.0. * * \sa SDL_HINT_KEYCODE_OPTIONS */ typedef Uint32 SDL_Keycode; #define SDLK_EXTENDED_MASK (1u << 29) #define SDLK_SCANCODE_MASK (1u << 30) #define SDL_SCANCODE_TO_KEYCODE(X) (X | SDLK_SCANCODE_MASK) #define SDLK_UNKNOWN 0x00000000u /**< 0 */ #define SDLK_RETURN 0x0000000du /**< '\r' */ #define SDLK_ESCAPE 0x0000001bu /**< '\x1B' */ #define SDLK_BACKSPACE 0x00000008u /**< '\b' */ #define SDLK_TAB 0x00000009u /**< '\t' */ #define SDLK_SPACE 0x00000020u /**< ' ' */ #define SDLK_EXCLAIM 0x00000021u /**< '!' */ #define SDLK_DBLAPOSTROPHE 0x00000022u /**< '"' */ #define SDLK_HASH 0x00000023u /**< '#' */ #define SDLK_DOLLAR 0x00000024u /**< '$' */ #define SDLK_PERCENT 0x00000025u /**< '%' */ #define SDLK_AMPERSAND 0x00000026u /**< '&' */ #define SDLK_APOSTROPHE 0x00000027u /**< '\'' */ #define SDLK_LEFTPAREN 0x00000028u /**< '(' */ #define SDLK_RIGHTPAREN 0x00000029u /**< ')' */ #define SDLK_ASTERISK 0x0000002au /**< '*' */ #define SDLK_PLUS 0x0000002bu /**< '+' */ #define SDLK_COMMA 0x0000002cu /**< ',' */ #define SDLK_MINUS 0x0000002du /**< '-' */ #define SDLK_PERIOD 0x0000002eu /**< '.' */ #define SDLK_SLASH 0x0000002fu /**< '/' */ #define SDLK_0 0x00000030u /**< '0' */ #define SDLK_1 0x00000031u /**< '1' */ #define SDLK_2 0x00000032u /**< '2' */ #define SDLK_3 0x00000033u /**< '3' */ #define SDLK_4 0x00000034u /**< '4' */ #define SDLK_5 0x00000035u /**< '5' */ #define SDLK_6 0x00000036u /**< '6' */ #define SDLK_7 0x00000037u /**< '7' */ #define SDLK_8 0x00000038u /**< '8' */ #define SDLK_9 0x00000039u /**< '9' */ #define SDLK_COLON 0x0000003au /**< ':' */ #define SDLK_SEMICOLON 0x0000003bu /**< ';' */ #define SDLK_LESS 0x0000003cu /**< '<' */ #define SDLK_EQUALS 0x0000003du /**< '=' */ #define SDLK_GREATER 0x0000003eu /**< '>' */ #define SDLK_QUESTION 0x0000003fu /**< '?' */ #define SDLK_AT 0x00000040u /**< '@' */ #define SDLK_LEFTBRACKET 0x0000005bu /**< '[' */ #define SDLK_BACKSLASH 0x0000005cu /**< '\\' */ #define SDLK_RIGHTBRACKET 0x0000005du /**< ']' */ #define SDLK_CARET 0x0000005eu /**< '^' */ #define SDLK_UNDERSCORE 0x0000005fu /**< '_' */ #define SDLK_GRAVE 0x00000060u /**< '`' */ #define SDLK_A 0x00000061u /**< 'a' */ #define SDLK_B 0x00000062u /**< 'b' */ #define SDLK_C 0x00000063u /**< 'c' */ #define SDLK_D 0x00000064u /**< 'd' */ #define SDLK_E 0x00000065u /**< 'e' */ #define SDLK_F 0x00000066u /**< 'f' */ #define SDLK_G 0x00000067u /**< 'g' */ #define SDLK_H 0x00000068u /**< 'h' */ #define SDLK_I 0x00000069u /**< 'i' */ #define SDLK_J 0x0000006au /**< 'j' */ #define SDLK_K 0x0000006bu /**< 'k' */ #define SDLK_L 0x0000006cu /**< 'l' */ #define SDLK_M 0x0000006du /**< 'm' */ #define SDLK_N 0x0000006eu /**< 'n' */ #define SDLK_O 0x0000006fu /**< 'o' */ #define SDLK_P 0x00000070u /**< 'p' */ #define SDLK_Q 0x00000071u /**< 'q' */ #define SDLK_R 0x00000072u /**< 'r' */ #define SDLK_S 0x00000073u /**< 's' */ #define SDLK_T 0x00000074u /**< 't' */ #define SDLK_U 0x00000075u /**< 'u' */ #define SDLK_V 0x00000076u /**< 'v' */ #define SDLK_W 0x00000077u /**< 'w' */ #define SDLK_X 0x00000078u /**< 'x' */ #define SDLK_Y 0x00000079u /**< 'y' */ #define SDLK_Z 0x0000007au /**< 'z' */ #define SDLK_LEFTBRACE 0x0000007bu /**< '{' */ #define SDLK_PIPE 0x0000007cu /**< '|' */ #define SDLK_RIGHTBRACE 0x0000007du /**< '}' */ #define SDLK_TILDE 0x0000007eu /**< '~' */ #define SDLK_DELETE 0x0000007fu /**< '\x7F' */ #define SDLK_PLUSMINUS 0x000000b1u /**< '\xB1' */ #define SDLK_CAPSLOCK 0x40000039u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_CAPSLOCK) */ #define SDLK_F1 0x4000003au /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F1) */ #define SDLK_F2 0x4000003bu /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F2) */ #define SDLK_F3 0x4000003cu /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F3) */ #define SDLK_F4 0x4000003du /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F4) */ #define SDLK_F5 0x4000003eu /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F5) */ #define SDLK_F6 0x4000003fu /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F6) */ #define SDLK_F7 0x40000040u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F7) */ #define SDLK_F8 0x40000041u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F8) */ #define SDLK_F9 0x40000042u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F9) */ #define SDLK_F10 0x40000043u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F10) */ #define SDLK_F11 0x40000044u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F11) */ #define SDLK_F12 0x40000045u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F12) */ #define SDLK_PRINTSCREEN 0x40000046u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_PRINTSCREEN) */ #define SDLK_SCROLLLOCK 0x40000047u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_SCROLLLOCK) */ #define SDLK_PAUSE 0x40000048u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_PAUSE) */ #define SDLK_INSERT 0x40000049u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_INSERT) */ #define SDLK_HOME 0x4000004au /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_HOME) */ #define SDLK_PAGEUP 0x4000004bu /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_PAGEUP) */ #define SDLK_END 0x4000004du /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_END) */ #define SDLK_PAGEDOWN 0x4000004eu /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_PAGEDOWN) */ #define SDLK_RIGHT 0x4000004fu /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_RIGHT) */ #define SDLK_LEFT 0x40000050u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_LEFT) */ #define SDLK_DOWN 0x40000051u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_DOWN) */ #define SDLK_UP 0x40000052u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_UP) */ #define SDLK_NUMLOCKCLEAR 0x40000053u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_NUMLOCKCLEAR) */ #define SDLK_KP_DIVIDE 0x40000054u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_DIVIDE) */ #define SDLK_KP_MULTIPLY 0x40000055u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_MULTIPLY) */ #define SDLK_KP_MINUS 0x40000056u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_MINUS) */ #define SDLK_KP_PLUS 0x40000057u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_PLUS) */ #define SDLK_KP_ENTER 0x40000058u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_ENTER) */ #define SDLK_KP_1 0x40000059u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_1) */ #define SDLK_KP_2 0x4000005au /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_2) */ #define SDLK_KP_3 0x4000005bu /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_3) */ #define SDLK_KP_4 0x4000005cu /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_4) */ #define SDLK_KP_5 0x4000005du /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_5) */ #define SDLK_KP_6 0x4000005eu /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_6) */ #define SDLK_KP_7 0x4000005fu /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_7) */ #define SDLK_KP_8 0x40000060u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_8) */ #define SDLK_KP_9 0x40000061u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_9) */ #define SDLK_KP_0 0x40000062u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_0) */ #define SDLK_KP_PERIOD 0x40000063u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_PERIOD) */ #define SDLK_APPLICATION 0x40000065u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_APPLICATION) */ #define SDLK_POWER 0x40000066u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_POWER) */ #define SDLK_KP_EQUALS 0x40000067u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_EQUALS) */ #define SDLK_F13 0x40000068u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F13) */ #define SDLK_F14 0x40000069u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F14) */ #define SDLK_F15 0x4000006au /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F15) */ #define SDLK_F16 0x4000006bu /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F16) */ #define SDLK_F17 0x4000006cu /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F17) */ #define SDLK_F18 0x4000006du /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F18) */ #define SDLK_F19 0x4000006eu /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F19) */ #define SDLK_F20 0x4000006fu /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F20) */ #define SDLK_F21 0x40000070u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F21) */ #define SDLK_F22 0x40000071u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F22) */ #define SDLK_F23 0x40000072u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F23) */ #define SDLK_F24 0x40000073u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F24) */ #define SDLK_EXECUTE 0x40000074u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_EXECUTE) */ #define SDLK_HELP 0x40000075u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_HELP) */ #define SDLK_MENU 0x40000076u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_MENU) */ #define SDLK_SELECT 0x40000077u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_SELECT) */ #define SDLK_STOP 0x40000078u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_STOP) */ #define SDLK_AGAIN 0x40000079u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_AGAIN) */ #define SDLK_UNDO 0x4000007au /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_UNDO) */ #define SDLK_CUT 0x4000007bu /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_CUT) */ #define SDLK_COPY 0x4000007cu /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_COPY) */ #define SDLK_PASTE 0x4000007du /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_PASTE) */ #define SDLK_FIND 0x4000007eu /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_FIND) */ #define SDLK_MUTE 0x4000007fu /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_MUTE) */ #define SDLK_VOLUMEUP 0x40000080u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_VOLUMEUP) */ #define SDLK_VOLUMEDOWN 0x40000081u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_VOLUMEDOWN) */ #define SDLK_KP_COMMA 0x40000085u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_COMMA) */ #define SDLK_KP_EQUALSAS400 0x40000086u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_EQUALSAS400) */ #define SDLK_ALTERASE 0x40000099u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_ALTERASE) */ #define SDLK_SYSREQ 0x4000009au /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_SYSREQ) */ #define SDLK_CANCEL 0x4000009bu /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_CANCEL) */ #define SDLK_CLEAR 0x4000009cu /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_CLEAR) */ #define SDLK_PRIOR 0x4000009du /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_PRIOR) */ #define SDLK_RETURN2 0x4000009eu /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_RETURN2) */ #define SDLK_SEPARATOR 0x4000009fu /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_SEPARATOR) */ #define SDLK_OUT 0x400000a0u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_OUT) */ #define SDLK_OPER 0x400000a1u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_OPER) */ #define SDLK_CLEARAGAIN 0x400000a2u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_CLEARAGAIN) */ #define SDLK_CRSEL 0x400000a3u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_CRSEL) */ #define SDLK_EXSEL 0x400000a4u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_EXSEL) */ #define SDLK_KP_00 0x400000b0u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_00) */ #define SDLK_KP_000 0x400000b1u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_000) */ #define SDLK_THOUSANDSSEPARATOR 0x400000b2u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_THOUSANDSSEPARATOR) */ #define SDLK_DECIMALSEPARATOR 0x400000b3u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_DECIMALSEPARATOR) */ #define SDLK_CURRENCYUNIT 0x400000b4u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_CURRENCYUNIT) */ #define SDLK_CURRENCYSUBUNIT 0x400000b5u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_CURRENCYSUBUNIT) */ #define SDLK_KP_LEFTPAREN 0x400000b6u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_LEFTPAREN) */ #define SDLK_KP_RIGHTPAREN 0x400000b7u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_RIGHTPAREN) */ #define SDLK_KP_LEFTBRACE 0x400000b8u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_LEFTBRACE) */ #define SDLK_KP_RIGHTBRACE 0x400000b9u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_RIGHTBRACE) */ #define SDLK_KP_TAB 0x400000bau /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_TAB) */ #define SDLK_KP_BACKSPACE 0x400000bbu /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_BACKSPACE) */ #define SDLK_KP_A 0x400000bcu /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_A) */ #define SDLK_KP_B 0x400000bdu /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_B) */ #define SDLK_KP_C 0x400000beu /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_C) */ #define SDLK_KP_D 0x400000bfu /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_D) */ #define SDLK_KP_E 0x400000c0u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_E) */ #define SDLK_KP_F 0x400000c1u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_F) */ #define SDLK_KP_XOR 0x400000c2u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_XOR) */ #define SDLK_KP_POWER 0x400000c3u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_POWER) */ #define SDLK_KP_PERCENT 0x400000c4u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_PERCENT) */ #define SDLK_KP_LESS 0x400000c5u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_LESS) */ #define SDLK_KP_GREATER 0x400000c6u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_GREATER) */ #define SDLK_KP_AMPERSAND 0x400000c7u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_AMPERSAND) */ #define SDLK_KP_DBLAMPERSAND 0x400000c8u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_DBLAMPERSAND) */ #define SDLK_KP_VERTICALBAR 0x400000c9u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_VERTICALBAR) */ #define SDLK_KP_DBLVERTICALBAR 0x400000cau /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_DBLVERTICALBAR) */ #define SDLK_KP_COLON 0x400000cbu /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_COLON) */ #define SDLK_KP_HASH 0x400000ccu /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_HASH) */ #define SDLK_KP_SPACE 0x400000cdu /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_SPACE) */ #define SDLK_KP_AT 0x400000ceu /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_AT) */ #define SDLK_KP_EXCLAM 0x400000cfu /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_EXCLAM) */ #define SDLK_KP_MEMSTORE 0x400000d0u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_MEMSTORE) */ #define SDLK_KP_MEMRECALL 0x400000d1u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_MEMRECALL) */ #define SDLK_KP_MEMCLEAR 0x400000d2u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_MEMCLEAR) */ #define SDLK_KP_MEMADD 0x400000d3u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_MEMADD) */ #define SDLK_KP_MEMSUBTRACT 0x400000d4u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_MEMSUBTRACT) */ #define SDLK_KP_MEMMULTIPLY 0x400000d5u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_MEMMULTIPLY) */ #define SDLK_KP_MEMDIVIDE 0x400000d6u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_MEMDIVIDE) */ #define SDLK_KP_PLUSMINUS 0x400000d7u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_PLUSMINUS) */ #define SDLK_KP_CLEAR 0x400000d8u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_CLEAR) */ #define SDLK_KP_CLEARENTRY 0x400000d9u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_CLEARENTRY) */ #define SDLK_KP_BINARY 0x400000dau /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_BINARY) */ #define SDLK_KP_OCTAL 0x400000dbu /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_OCTAL) */ #define SDLK_KP_DECIMAL 0x400000dcu /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_DECIMAL) */ #define SDLK_KP_HEXADECIMAL 0x400000ddu /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_HEXADECIMAL) */ #define SDLK_LCTRL 0x400000e0u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_LCTRL) */ #define SDLK_LSHIFT 0x400000e1u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_LSHIFT) */ #define SDLK_LALT 0x400000e2u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_LALT) */ #define SDLK_LGUI 0x400000e3u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_LGUI) */ #define SDLK_RCTRL 0x400000e4u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_RCTRL) */ #define SDLK_RSHIFT 0x400000e5u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_RSHIFT) */ #define SDLK_RALT 0x400000e6u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_RALT) */ #define SDLK_RGUI 0x400000e7u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_RGUI) */ #define SDLK_MODE 0x40000101u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_MODE) */ #define SDLK_SLEEP 0x40000102u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_SLEEP) */ #define SDLK_WAKE 0x40000103u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_WAKE) */ #define SDLK_CHANNEL_INCREMENT 0x40000104u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_CHANNEL_INCREMENT) */ #define SDLK_CHANNEL_DECREMENT 0x40000105u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_CHANNEL_DECREMENT) */ #define SDLK_MEDIA_PLAY 0x40000106u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_MEDIA_PLAY) */ #define SDLK_MEDIA_PAUSE 0x40000107u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_MEDIA_PAUSE) */ #define SDLK_MEDIA_RECORD 0x40000108u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_MEDIA_RECORD) */ #define SDLK_MEDIA_FAST_FORWARD 0x40000109u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_MEDIA_FAST_FORWARD) */ #define SDLK_MEDIA_REWIND 0x4000010au /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_MEDIA_REWIND) */ #define SDLK_MEDIA_NEXT_TRACK 0x4000010bu /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_MEDIA_NEXT_TRACK) */ #define SDLK_MEDIA_PREVIOUS_TRACK 0x4000010cu /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_MEDIA_PREVIOUS_TRACK) */ #define SDLK_MEDIA_STOP 0x4000010du /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_MEDIA_STOP) */ #define SDLK_MEDIA_EJECT 0x4000010eu /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_MEDIA_EJECT) */ #define SDLK_MEDIA_PLAY_PAUSE 0x4000010fu /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_MEDIA_PLAY_PAUSE) */ #define SDLK_MEDIA_SELECT 0x40000110u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_MEDIA_SELECT) */ #define SDLK_AC_NEW 0x40000111u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_AC_NEW) */ #define SDLK_AC_OPEN 0x40000112u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_AC_OPEN) */ #define SDLK_AC_CLOSE 0x40000113u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_AC_CLOSE) */ #define SDLK_AC_EXIT 0x40000114u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_AC_EXIT) */ #define SDLK_AC_SAVE 0x40000115u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_AC_SAVE) */ #define SDLK_AC_PRINT 0x40000116u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_AC_PRINT) */ #define SDLK_AC_PROPERTIES 0x40000117u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_AC_PROPERTIES) */ #define SDLK_AC_SEARCH 0x40000118u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_AC_SEARCH) */ #define SDLK_AC_HOME 0x40000119u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_AC_HOME) */ #define SDLK_AC_BACK 0x4000011au /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_AC_BACK) */ #define SDLK_AC_FORWARD 0x4000011bu /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_AC_FORWARD) */ #define SDLK_AC_STOP 0x4000011cu /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_AC_STOP) */ #define SDLK_AC_REFRESH 0x4000011du /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_AC_REFRESH) */ #define SDLK_AC_BOOKMARKS 0x4000011eu /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_AC_BOOKMARKS) */ #define SDLK_SOFTLEFT 0x4000011fu /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_SOFTLEFT) */ #define SDLK_SOFTRIGHT 0x40000120u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_SOFTRIGHT) */ #define SDLK_CALL 0x40000121u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_CALL) */ #define SDLK_ENDCALL 0x40000122u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_ENDCALL) */ #define SDLK_LEFT_TAB 0x20000001u /**< Extended key Left Tab */ #define SDLK_LEVEL5_SHIFT 0x20000002u /**< Extended key Level 5 Shift */ #define SDLK_MULTI_KEY_COMPOSE 0x20000003u /**< Extended key Multi-key Compose */ #define SDLK_LMETA 0x20000004u /**< Extended key Left Meta */ #define SDLK_RMETA 0x20000005u /**< Extended key Right Meta */ #define SDLK_LHYPER 0x20000006u /**< Extended key Left Hyper */ #define SDLK_RHYPER 0x20000007u /**< Extended key Right Hyper */ /** * Valid key modifiers (possibly OR'd together). * * \since This datatype is available since SDL 3.2.0. */ typedef Uint16 SDL_Keymod; #define SDL_KMOD_NONE 0x0000u /**< no modifier is applicable. */ #define SDL_KMOD_LSHIFT 0x0001u /**< the left Shift key is down. */ #define SDL_KMOD_RSHIFT 0x0002u /**< the right Shift key is down. */ #define SDL_KMOD_LEVEL5 0x0004u /**< the Level 5 Shift key is down. */ #define SDL_KMOD_LCTRL 0x0040u /**< the left Ctrl (Control) key is down. */ #define SDL_KMOD_RCTRL 0x0080u /**< the right Ctrl (Control) key is down. */ #define SDL_KMOD_LALT 0x0100u /**< the left Alt key is down. */ #define SDL_KMOD_RALT 0x0200u /**< the right Alt key is down. */ #define SDL_KMOD_LGUI 0x0400u /**< the left GUI key (often the Windows key) is down. */ #define SDL_KMOD_RGUI 0x0800u /**< the right GUI key (often the Windows key) is down. */ #define SDL_KMOD_NUM 0x1000u /**< the Num Lock key (may be located on an extended keypad) is down. */ #define SDL_KMOD_CAPS 0x2000u /**< the Caps Lock key is down. */ #define SDL_KMOD_MODE 0x4000u /**< the !AltGr key is down. */ #define SDL_KMOD_SCROLL 0x8000u /**< the Scroll Lock key is down. */ #define SDL_KMOD_CTRL (SDL_KMOD_LCTRL | SDL_KMOD_RCTRL) /**< Any Ctrl key is down. */ #define SDL_KMOD_SHIFT (SDL_KMOD_LSHIFT | SDL_KMOD_RSHIFT) /**< Any Shift key is down. */ #define SDL_KMOD_ALT (SDL_KMOD_LALT | SDL_KMOD_RALT) /**< Any Alt key is down. */ #define SDL_KMOD_GUI (SDL_KMOD_LGUI | SDL_KMOD_RGUI) /**< Any GUI key is down. */ #endif /* SDL_keycode_h_ */ ================================================ FILE: deps/include/SDL3/SDL_loadso.h ================================================ /* Simple DirectMedia Layer Copyright (C) 1997-2026 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ /* WIKI CATEGORY: SharedObject */ /** * # CategorySharedObject * * System-dependent library loading routines. * * Shared objects are code that is programmatically loadable at runtime. * Windows calls these "DLLs", Linux calls them "shared libraries", etc. * * To use them, build such a library, then call SDL_LoadObject() on it. Once * loaded, you can use SDL_LoadFunction() on that object to find the address * of its exported symbols. When done with the object, call SDL_UnloadObject() * to dispose of it. * * Some things to keep in mind: * * - These functions only work on C function names. Other languages may have * name mangling and intrinsic language support that varies from compiler to * compiler. * - Make sure you declare your function pointers with the same calling * convention as the actual library function. Your code will crash * mysteriously if you do not do this. * - Avoid namespace collisions. If you load a symbol from the library, it is * not defined whether or not it goes into the global symbol namespace for * the application. If it does and it conflicts with symbols in your code or * other shared libraries, you will not get the results you expect. :) * - Once a library is unloaded, all pointers into it obtained through * SDL_LoadFunction() become invalid, even if the library is later reloaded. * Don't unload a library if you plan to use these pointers in the future. * Notably: beware of giving one of these pointers to atexit(), since it may * call that pointer after the library unloads. */ #ifndef SDL_loadso_h_ #define SDL_loadso_h_ #include #include #include /* Set up for C function definitions, even when using C++ */ #ifdef __cplusplus extern "C" { #endif /** * An opaque datatype that represents a loaded shared object. * * \since This datatype is available since SDL 3.2.0. * * \sa SDL_LoadObject * \sa SDL_LoadFunction * \sa SDL_UnloadObject */ typedef struct SDL_SharedObject SDL_SharedObject; /** * Dynamically load a shared object. * * \param sofile a system-dependent name of the object file. * \returns an opaque pointer to the object handle or NULL on failure; call * SDL_GetError() for more information. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_LoadFunction * \sa SDL_UnloadObject */ extern SDL_DECLSPEC SDL_SharedObject * SDLCALL SDL_LoadObject(const char *sofile); /** * Look up the address of the named function in a shared object. * * This function pointer is no longer valid after calling SDL_UnloadObject(). * * This function can only look up C function names. Other languages may have * name mangling and intrinsic language support that varies from compiler to * compiler. * * Make sure you declare your function pointers with the same calling * convention as the actual library function. Your code will crash * mysteriously if you do not do this. * * If the requested function doesn't exist, NULL is returned. * * \param handle a valid shared object handle returned by SDL_LoadObject(). * \param name the name of the function to look up. * \returns a pointer to the function or NULL on failure; call SDL_GetError() * for more information. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_LoadObject */ extern SDL_DECLSPEC SDL_FunctionPointer SDLCALL SDL_LoadFunction(SDL_SharedObject *handle, const char *name); /** * Unload a shared object from memory. * * Note that any pointers from this object looked up through * SDL_LoadFunction() will no longer be valid. * * \param handle a valid shared object handle returned by SDL_LoadObject(). * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_LoadObject */ extern SDL_DECLSPEC void SDLCALL SDL_UnloadObject(SDL_SharedObject *handle); /* Ends C function definitions when using C++ */ #ifdef __cplusplus } #endif #include #endif /* SDL_loadso_h_ */ ================================================ FILE: deps/include/SDL3/SDL_locale.h ================================================ /* Simple DirectMedia Layer Copyright (C) 1997-2026 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ /** * # CategoryLocale * * SDL locale services. * * This provides a way to get a list of preferred locales (language plus * country) for the user. There is exactly one function: * SDL_GetPreferredLocales(), which handles all the heavy lifting, and offers * documentation on all the strange ways humans might have configured their * language settings. */ #ifndef SDL_locale_h #define SDL_locale_h #include #include #include /* Set up for C function definitions, even when using C++ */ #ifdef __cplusplus /* *INDENT-OFF* */ extern "C" { /* *INDENT-ON* */ #endif /** * A struct to provide locale data. * * Locale data is split into a spoken language, like English, and an optional * country, like Canada. The language will be in ISO-639 format (so English * would be "en"), and the country, if not NULL, will be an ISO-3166 country * code (so Canada would be "CA"). * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetPreferredLocales */ typedef struct SDL_Locale { const char *language; /**< A language name, like "en" for English. */ const char *country; /**< A country, like "US" for America. Can be NULL. */ } SDL_Locale; /** * Report the user's preferred locale. * * Returned language strings are in the format xx, where 'xx' is an ISO-639 * language specifier (such as "en" for English, "de" for German, etc). * Country strings are in the format YY, where "YY" is an ISO-3166 country * code (such as "US" for the United States, "CA" for Canada, etc). Country * might be NULL if there's no specific guidance on them (so you might get { * "en", "US" } for American English, but { "en", NULL } means "English * language, generically"). Language strings are never NULL, except to * terminate the array. * * Please note that not all of these strings are 2 characters; some are three * or more. * * The returned list of locales are in the order of the user's preference. For * example, a German citizen that is fluent in US English and knows enough * Japanese to navigate around Tokyo might have a list like: { "de", "en_US", * "jp", NULL }. Someone from England might prefer British English (where * "color" is spelled "colour", etc), but will settle for anything like it: { * "en_GB", "en", NULL }. * * This function returns NULL on error, including when the platform does not * supply this information at all. * * This might be a "slow" call that has to query the operating system. It's * best to ask for this once and save the results. However, this list can * change, usually because the user has changed a system preference outside of * your program; SDL will send an SDL_EVENT_LOCALE_CHANGED event in this case, * if possible, and you can call this function again to get an updated copy of * preferred locales. * * \param count a pointer filled in with the number of locales returned, may * be NULL. * \returns a NULL terminated array of locale pointers, or NULL on failure; * call SDL_GetError() for more information. This is a single * allocation that should be freed with SDL_free() when it is no * longer needed. * * \threadsafety This function is not thread safe. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC SDL_Locale ** SDLCALL SDL_GetPreferredLocales(int *count); /* Ends C function definitions when using C++ */ #ifdef __cplusplus /* *INDENT-OFF* */ } /* *INDENT-ON* */ #endif #include #endif /* SDL_locale_h */ ================================================ FILE: deps/include/SDL3/SDL_log.h ================================================ /* Simple DirectMedia Layer Copyright (C) 1997-2026 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ /** * # CategoryLog * * Simple log messages with priorities and categories. A message's * SDL_LogPriority signifies how important the message is. A message's * SDL_LogCategory signifies from what domain it belongs to. Every category * has a minimum priority specified: when a message belongs to that category, * it will only be sent out if it has that minimum priority or higher. * * SDL's own logs are sent below the default priority threshold, so they are * quiet by default. * * You can change the log verbosity programmatically using * SDL_SetLogPriority() or with SDL_SetHint(SDL_HINT_LOGGING, ...), or with * the "SDL_LOGGING" environment variable. This variable is a comma separated * set of category=level tokens that define the default logging levels for SDL * applications. * * The category can be a numeric category, one of "app", "error", "assert", * "system", "audio", "video", "render", "input", "test", or `*` for any * unspecified category. * * The level can be a numeric level, one of "trace", "verbose", "debug", * "info", "warn", "error", "critical", or "quiet" to disable that category. * * You can omit the category if you want to set the logging level for all * categories. * * If this hint isn't set, the default log levels are equivalent to: * * `app=info,assert=warn,test=verbose,*=error` * * Here's where the messages go on different platforms: * * - Windows: debug output stream * - Android: log output * - Others: standard error output (stderr) * * You don't need to have a newline (`\n`) on the end of messages, the * functions will do that for you. For consistent behavior cross-platform, you * shouldn't have any newlines in messages, such as to log multiple lines in * one call; unusual platform-specific behavior can be observed in such usage. * Do one log call per line instead, with no newlines in messages. * * Each log call is atomic, so you won't see log messages cut off one another * when logging from multiple threads. */ #ifndef SDL_log_h_ #define SDL_log_h_ #include #include /* Set up for C function definitions, even when using C++ */ #ifdef __cplusplus extern "C" { #endif /** * The predefined log categories * * By default the application and gpu categories are enabled at the INFO * level, the assert category is enabled at the WARN level, test is enabled at * the VERBOSE level and all other categories are enabled at the ERROR level. * * \since This enum is available since SDL 3.2.0. */ typedef enum SDL_LogCategory { SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_CATEGORY_ERROR, SDL_LOG_CATEGORY_ASSERT, SDL_LOG_CATEGORY_SYSTEM, SDL_LOG_CATEGORY_AUDIO, SDL_LOG_CATEGORY_VIDEO, SDL_LOG_CATEGORY_RENDER, SDL_LOG_CATEGORY_INPUT, SDL_LOG_CATEGORY_TEST, SDL_LOG_CATEGORY_GPU, /* Reserved for future SDL library use */ SDL_LOG_CATEGORY_RESERVED2, SDL_LOG_CATEGORY_RESERVED3, SDL_LOG_CATEGORY_RESERVED4, SDL_LOG_CATEGORY_RESERVED5, SDL_LOG_CATEGORY_RESERVED6, SDL_LOG_CATEGORY_RESERVED7, SDL_LOG_CATEGORY_RESERVED8, SDL_LOG_CATEGORY_RESERVED9, SDL_LOG_CATEGORY_RESERVED10, /* Beyond this point is reserved for application use, e.g. enum { MYAPP_CATEGORY_AWESOME1 = SDL_LOG_CATEGORY_CUSTOM, MYAPP_CATEGORY_AWESOME2, MYAPP_CATEGORY_AWESOME3, ... }; */ SDL_LOG_CATEGORY_CUSTOM } SDL_LogCategory; /** * The predefined log priorities * * \since This enum is available since SDL 3.2.0. */ typedef enum SDL_LogPriority { SDL_LOG_PRIORITY_INVALID, SDL_LOG_PRIORITY_TRACE, SDL_LOG_PRIORITY_VERBOSE, SDL_LOG_PRIORITY_DEBUG, SDL_LOG_PRIORITY_INFO, SDL_LOG_PRIORITY_WARN, SDL_LOG_PRIORITY_ERROR, SDL_LOG_PRIORITY_CRITICAL, SDL_LOG_PRIORITY_COUNT } SDL_LogPriority; /** * Set the priority of all log categories. * * \param priority the SDL_LogPriority to assign. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_ResetLogPriorities * \sa SDL_SetLogPriority */ extern SDL_DECLSPEC void SDLCALL SDL_SetLogPriorities(SDL_LogPriority priority); /** * Set the priority of a particular log category. * * \param category the category to assign a priority to. * \param priority the SDL_LogPriority to assign. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetLogPriority * \sa SDL_ResetLogPriorities * \sa SDL_SetLogPriorities */ extern SDL_DECLSPEC void SDLCALL SDL_SetLogPriority(int category, SDL_LogPriority priority); /** * Get the priority of a particular log category. * * \param category the category to query. * \returns the SDL_LogPriority for the requested category. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_SetLogPriority */ extern SDL_DECLSPEC SDL_LogPriority SDLCALL SDL_GetLogPriority(int category); /** * Reset all priorities to default. * * This is called by SDL_Quit(). * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_SetLogPriorities * \sa SDL_SetLogPriority */ extern SDL_DECLSPEC void SDLCALL SDL_ResetLogPriorities(void); /** * Set the text prepended to log messages of a given priority. * * By default SDL_LOG_PRIORITY_INFO and below have no prefix, and * SDL_LOG_PRIORITY_WARN and higher have a prefix showing their priority, e.g. * "WARNING: ". * * This function makes a copy of its string argument, **prefix**, so it is not * necessary to keep the value of **prefix** alive after the call returns. * * \param priority the SDL_LogPriority to modify. * \param prefix the prefix to use for that log priority, or NULL to use no * prefix. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_SetLogPriorities * \sa SDL_SetLogPriority */ extern SDL_DECLSPEC bool SDLCALL SDL_SetLogPriorityPrefix(SDL_LogPriority priority, const char *prefix); /** * Log a message with SDL_LOG_CATEGORY_APPLICATION and SDL_LOG_PRIORITY_INFO. * * \param fmt a printf() style message format string. * \param ... additional parameters matching % tokens in the `fmt` string, if * any. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_LogCritical * \sa SDL_LogDebug * \sa SDL_LogError * \sa SDL_LogInfo * \sa SDL_LogMessage * \sa SDL_LogMessageV * \sa SDL_LogTrace * \sa SDL_LogVerbose * \sa SDL_LogWarn */ extern SDL_DECLSPEC void SDLCALL SDL_Log(SDL_PRINTF_FORMAT_STRING const char *fmt, ...) SDL_PRINTF_VARARG_FUNC(1); /** * Log a message with SDL_LOG_PRIORITY_TRACE. * * \param category the category of the message. * \param fmt a printf() style message format string. * \param ... additional parameters matching % tokens in the **fmt** string, * if any. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_Log * \sa SDL_LogCritical * \sa SDL_LogDebug * \sa SDL_LogError * \sa SDL_LogInfo * \sa SDL_LogMessage * \sa SDL_LogMessageV * \sa SDL_LogVerbose * \sa SDL_LogWarn */ extern SDL_DECLSPEC void SDLCALL SDL_LogTrace(int category, SDL_PRINTF_FORMAT_STRING const char *fmt, ...) SDL_PRINTF_VARARG_FUNC(2); /** * Log a message with SDL_LOG_PRIORITY_VERBOSE. * * \param category the category of the message. * \param fmt a printf() style message format string. * \param ... additional parameters matching % tokens in the **fmt** string, * if any. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_Log * \sa SDL_LogCritical * \sa SDL_LogDebug * \sa SDL_LogError * \sa SDL_LogInfo * \sa SDL_LogMessage * \sa SDL_LogMessageV * \sa SDL_LogWarn */ extern SDL_DECLSPEC void SDLCALL SDL_LogVerbose(int category, SDL_PRINTF_FORMAT_STRING const char *fmt, ...) SDL_PRINTF_VARARG_FUNC(2); /** * Log a message with SDL_LOG_PRIORITY_DEBUG. * * \param category the category of the message. * \param fmt a printf() style message format string. * \param ... additional parameters matching % tokens in the **fmt** string, * if any. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_Log * \sa SDL_LogCritical * \sa SDL_LogError * \sa SDL_LogInfo * \sa SDL_LogMessage * \sa SDL_LogMessageV * \sa SDL_LogTrace * \sa SDL_LogVerbose * \sa SDL_LogWarn */ extern SDL_DECLSPEC void SDLCALL SDL_LogDebug(int category, SDL_PRINTF_FORMAT_STRING const char *fmt, ...) SDL_PRINTF_VARARG_FUNC(2); /** * Log a message with SDL_LOG_PRIORITY_INFO. * * \param category the category of the message. * \param fmt a printf() style message format string. * \param ... additional parameters matching % tokens in the **fmt** string, * if any. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_Log * \sa SDL_LogCritical * \sa SDL_LogDebug * \sa SDL_LogError * \sa SDL_LogMessage * \sa SDL_LogMessageV * \sa SDL_LogTrace * \sa SDL_LogVerbose * \sa SDL_LogWarn */ extern SDL_DECLSPEC void SDLCALL SDL_LogInfo(int category, SDL_PRINTF_FORMAT_STRING const char *fmt, ...) SDL_PRINTF_VARARG_FUNC(2); /** * Log a message with SDL_LOG_PRIORITY_WARN. * * \param category the category of the message. * \param fmt a printf() style message format string. * \param ... additional parameters matching % tokens in the **fmt** string, * if any. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_Log * \sa SDL_LogCritical * \sa SDL_LogDebug * \sa SDL_LogError * \sa SDL_LogInfo * \sa SDL_LogMessage * \sa SDL_LogMessageV * \sa SDL_LogTrace * \sa SDL_LogVerbose */ extern SDL_DECLSPEC void SDLCALL SDL_LogWarn(int category, SDL_PRINTF_FORMAT_STRING const char *fmt, ...) SDL_PRINTF_VARARG_FUNC(2); /** * Log a message with SDL_LOG_PRIORITY_ERROR. * * \param category the category of the message. * \param fmt a printf() style message format string. * \param ... additional parameters matching % tokens in the **fmt** string, * if any. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_Log * \sa SDL_LogCritical * \sa SDL_LogDebug * \sa SDL_LogInfo * \sa SDL_LogMessage * \sa SDL_LogMessageV * \sa SDL_LogTrace * \sa SDL_LogVerbose * \sa SDL_LogWarn */ extern SDL_DECLSPEC void SDLCALL SDL_LogError(int category, SDL_PRINTF_FORMAT_STRING const char *fmt, ...) SDL_PRINTF_VARARG_FUNC(2); /** * Log a message with SDL_LOG_PRIORITY_CRITICAL. * * \param category the category of the message. * \param fmt a printf() style message format string. * \param ... additional parameters matching % tokens in the **fmt** string, * if any. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_Log * \sa SDL_LogDebug * \sa SDL_LogError * \sa SDL_LogInfo * \sa SDL_LogMessage * \sa SDL_LogMessageV * \sa SDL_LogTrace * \sa SDL_LogVerbose * \sa SDL_LogWarn */ extern SDL_DECLSPEC void SDLCALL SDL_LogCritical(int category, SDL_PRINTF_FORMAT_STRING const char *fmt, ...) SDL_PRINTF_VARARG_FUNC(2); /** * Log a message with the specified category and priority. * * \param category the category of the message. * \param priority the priority of the message. * \param fmt a printf() style message format string. * \param ... additional parameters matching % tokens in the **fmt** string, * if any. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_Log * \sa SDL_LogCritical * \sa SDL_LogDebug * \sa SDL_LogError * \sa SDL_LogInfo * \sa SDL_LogMessageV * \sa SDL_LogTrace * \sa SDL_LogVerbose * \sa SDL_LogWarn */ extern SDL_DECLSPEC void SDLCALL SDL_LogMessage(int category, SDL_LogPriority priority, SDL_PRINTF_FORMAT_STRING const char *fmt, ...) SDL_PRINTF_VARARG_FUNC(3); /** * Log a message with the specified category and priority. * * \param category the category of the message. * \param priority the priority of the message. * \param fmt a printf() style message format string. * \param ap a variable argument list. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_Log * \sa SDL_LogCritical * \sa SDL_LogDebug * \sa SDL_LogError * \sa SDL_LogInfo * \sa SDL_LogMessage * \sa SDL_LogTrace * \sa SDL_LogVerbose * \sa SDL_LogWarn */ extern SDL_DECLSPEC void SDLCALL SDL_LogMessageV(int category, SDL_LogPriority priority, SDL_PRINTF_FORMAT_STRING const char *fmt, va_list ap) SDL_PRINTF_VARARG_FUNCV(3); /** * The prototype for the log output callback function. * * This function is called by SDL when there is new text to be logged. A mutex * is held so that this function is never called by more than one thread at * once. * * \param userdata what was passed as `userdata` to * SDL_SetLogOutputFunction(). * \param category the category of the message. * \param priority the priority of the message. * \param message the message being output. * * \since This datatype is available since SDL 3.2.0. */ typedef void (SDLCALL *SDL_LogOutputFunction)(void *userdata, int category, SDL_LogPriority priority, const char *message); /** * Get the default log output function. * * \returns the default log output callback. It should be called with NULL for * the userdata argument. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_SetLogOutputFunction * \sa SDL_GetLogOutputFunction */ extern SDL_DECLSPEC SDL_LogOutputFunction SDLCALL SDL_GetDefaultLogOutputFunction(void); /** * Get the current log output function. * * \param callback an SDL_LogOutputFunction filled in with the current log * callback. * \param userdata a pointer filled in with the pointer that is passed to * `callback`. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetDefaultLogOutputFunction * \sa SDL_SetLogOutputFunction */ extern SDL_DECLSPEC void SDLCALL SDL_GetLogOutputFunction(SDL_LogOutputFunction *callback, void **userdata); /** * Replace the default log output function with one of your own. * * \param callback an SDL_LogOutputFunction to call instead of the default. * \param userdata a pointer that is passed to `callback`. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetDefaultLogOutputFunction * \sa SDL_GetLogOutputFunction */ extern SDL_DECLSPEC void SDLCALL SDL_SetLogOutputFunction(SDL_LogOutputFunction callback, void *userdata); /* Ends C function definitions when using C++ */ #ifdef __cplusplus } #endif #include #endif /* SDL_log_h_ */ ================================================ FILE: deps/include/SDL3/SDL_main.h ================================================ /* Simple DirectMedia Layer Copyright (C) 1997-2026 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ /** * # CategoryMain * * Redefine main() if necessary so that it is called by SDL. * * In order to make this consistent on all platforms, the application's main() * should look like this: * * ```c * #include * #include * * int main(int argc, char *argv[]) * { * } * ``` * * SDL will take care of platform specific details on how it gets called. * * This is also where an app can be configured to use the main callbacks, via * the SDL_MAIN_USE_CALLBACKS macro. * * SDL_main.h is a "single-header library," which is to say that including * this header inserts code into your program, and you should only include it * once in most cases. SDL.h does not include this header automatically. * * For more information, see: * * https://wiki.libsdl.org/SDL3/README-main-functions */ #ifndef SDL_main_h_ #define SDL_main_h_ #include #include #include #include #ifdef SDL_WIKI_DOCUMENTATION_SECTION /** * Inform SDL that the app is providing an entry point instead of SDL. * * SDL does not define this macro, but will check if it is defined when * including `SDL_main.h`. If defined, SDL will expect the app to provide the * proper entry point for the platform, and all the other magic details * needed, like manually calling SDL_SetMainReady. * * Please see [README-main-functions](README-main-functions), (or * docs/README-main-functions.md in the source tree) for a more detailed * explanation. * * \since This macro is used by the headers since SDL 3.2.0. */ #define SDL_MAIN_HANDLED 1 /** * Inform SDL to use the main callbacks instead of main. * * SDL does not define this macro, but will check if it is defined when * including `SDL_main.h`. If defined, SDL will expect the app to provide * several functions: SDL_AppInit, SDL_AppEvent, SDL_AppIterate, and * SDL_AppQuit. The app should not provide a `main` function in this case, and * doing so will likely cause the build to fail. * * Please see [README-main-functions](README-main-functions), (or * docs/README-main-functions.md in the source tree) for a more detailed * explanation. * * \since This macro is used by the headers since SDL 3.2.0. * * \sa SDL_AppInit * \sa SDL_AppEvent * \sa SDL_AppIterate * \sa SDL_AppQuit */ #define SDL_MAIN_USE_CALLBACKS 1 /** * Defined if the target platform offers a special mainline through SDL. * * This won't be defined otherwise. If defined, SDL's headers will redefine * `main` to `SDL_main`. * * This macro is defined by `SDL_main.h`, which is not automatically included * by `SDL.h`. * * Even if available, an app can define SDL_MAIN_HANDLED and provide their * own, if they know what they're doing. * * This macro is used internally by SDL, and apps probably shouldn't rely on * it. * * \since This macro is available since SDL 3.2.0. */ #define SDL_MAIN_AVAILABLE /** * Defined if the target platform _requires_ a special mainline through SDL. * * This won't be defined otherwise. If defined, SDL's headers will redefine * `main` to `SDL_main`. * * This macro is defined by `SDL_main.h`, which is not automatically included * by `SDL.h`. * * Even if required, an app can define SDL_MAIN_HANDLED and provide their own, * if they know what they're doing. * * This macro is used internally by SDL, and apps probably shouldn't rely on * it. * * \since This macro is available since SDL 3.2.0. */ #define SDL_MAIN_NEEDED #endif #if defined(__has_include) #if __has_include("SDL_main_private.h") && __has_include("SDL_main_impl_private.h") #define SDL_PLATFORM_PRIVATE_MAIN #endif #endif #ifndef SDL_MAIN_HANDLED #if defined(SDL_PLATFORM_PRIVATE_MAIN) /* Private platforms may have their own ideas about entry points. */ #include "SDL_main_private.h" #elif defined(SDL_PLATFORM_WIN32) /* On Windows SDL provides WinMain(), which parses the command line and passes the arguments to your main function. If you provide your own WinMain(), you may define SDL_MAIN_HANDLED */ #define SDL_MAIN_AVAILABLE #elif defined(SDL_PLATFORM_GDK) /* On GDK, SDL provides a main function that initializes the game runtime. If you prefer to write your own WinMain-function instead of having SDL provide one that calls your main() function, #define SDL_MAIN_HANDLED before #include'ing SDL_main.h and call the SDL_RunApp function from your entry point. */ #define SDL_MAIN_NEEDED #elif defined(SDL_PLATFORM_IOS) || defined(SDL_PLATFORM_TVOS) /* On iOS and tvOS SDL provides a main function that creates an application delegate and starts the application run loop. To use it, just #include in the source file that contains your main() function. See src/video/uikit/SDL_uikitappdelegate.m for more details. */ #define SDL_MAIN_NEEDED #elif defined(SDL_PLATFORM_ANDROID) /* On Android SDL provides a Java class in SDLActivity.java that is the main activity entry point. See docs/README-android.md for more details on extending that class. */ #define SDL_MAIN_NEEDED /* As this is launched from Java, the real entry point (main() function) is outside of the the binary built from this code. This define makes sure that, unlike on other platforms, SDL_main.h and SDL_main_impl.h export an `SDL_main()` function (to be called from Java), but don't implement a native `int main(int argc, char* argv[])` or similar. */ #define SDL_MAIN_EXPORTED #elif defined(SDL_PLATFORM_EMSCRIPTEN) /* On Emscripten, SDL provides a main function that converts URL parameters that start with "SDL_" to environment variables, so they can be used as SDL hints, etc. This is 100% optional, so if you don't want this to happen, you may define SDL_MAIN_HANDLED */ #define SDL_MAIN_AVAILABLE #elif defined(SDL_PLATFORM_PSP) /* On PSP SDL provides a main function that sets the module info, activates the GPU and starts the thread required to be able to exit the software. If you provide this yourself, you may define SDL_MAIN_HANDLED */ #define SDL_MAIN_AVAILABLE #elif defined(SDL_PLATFORM_PS2) #define SDL_MAIN_AVAILABLE #define SDL_PS2_SKIP_IOP_RESET() \ void reset_IOP(); \ void reset_IOP() {} #elif defined(SDL_PLATFORM_3DS) /* On N3DS, SDL provides a main function that sets up the screens and storage. If you provide this yourself, you may define SDL_MAIN_HANDLED */ #define SDL_MAIN_AVAILABLE #endif #endif /* SDL_MAIN_HANDLED */ #ifdef SDL_WIKI_DOCUMENTATION_SECTION /** * A macro to tag a main entry point function as exported. * * Most platforms don't need this, and the macro will be defined to nothing. * Some, like Android, keep the entry points in a shared library and need to * explicitly export the symbols. * * External code rarely needs this, and if it needs something, it's almost * always SDL_DECLSPEC instead. * * \since This macro is available since SDL 3.2.0. * * \sa SDL_DECLSPEC */ #define SDLMAIN_DECLSPEC #elif defined(SDL_MAIN_EXPORTED) /* We need to export SDL_main so it can be launched from external code, like SDLActivity.java on Android */ #define SDLMAIN_DECLSPEC SDL_DECLSPEC #else /* usually this is empty */ #define SDLMAIN_DECLSPEC #endif /* SDL_WIKI_DOCUMENTATION_SECTION */ #if defined(SDL_MAIN_NEEDED) || defined(SDL_MAIN_AVAILABLE) || defined(SDL_MAIN_USE_CALLBACKS) #define main SDL_main #endif #include #include #ifdef __cplusplus extern "C" { #endif /* * You can (optionally!) define SDL_MAIN_USE_CALLBACKS before including * SDL_main.h, and then your application will _not_ have a standard * "main" entry point. Instead, it will operate as a collection of * functions that are called as necessary by the system. On some * platforms, this is just a layer where SDL drives your program * instead of your program driving SDL, on other platforms this might * hook into the OS to manage the lifecycle. Programs on most platforms * can use whichever approach they prefer, but the decision boils down * to: * * - Using a standard "main" function: this works like it always has for * the past 50+ years in C programming, and your app is in control. * - Using the callback functions: this might clean up some code, * avoid some #ifdef blocks in your program for some platforms, be more * resource-friendly to the system, and possibly be the primary way to * access some future platforms (but none require this at the moment). * * This is up to the app; both approaches are considered valid and supported * ways to write SDL apps. * * If using the callbacks, don't define a "main" function. Instead, implement * the functions listed below in your program. */ #ifdef SDL_MAIN_USE_CALLBACKS /** * App-implemented initial entry point for SDL_MAIN_USE_CALLBACKS apps. * * Apps implement this function when using SDL_MAIN_USE_CALLBACKS. If using a * standard "main" function, you should not supply this. * * This function is called by SDL once, at startup. The function should * initialize whatever is necessary, possibly create windows and open audio * devices, etc. The `argc` and `argv` parameters work like they would with a * standard "main" function. * * This function should not go into an infinite mainloop; it should do any * one-time setup it requires and then return. * * The app may optionally assign a pointer to `*appstate`. This pointer will * be provided on every future call to the other entry points, to allow * application state to be preserved between functions without the app needing * to use a global variable. If this isn't set, the pointer will be NULL in * future entry points. * * If this function returns SDL_APP_CONTINUE, the app will proceed to normal * operation, and will begin receiving repeated calls to SDL_AppIterate and * SDL_AppEvent for the life of the program. If this function returns * SDL_APP_FAILURE, SDL will call SDL_AppQuit and terminate the process with * an exit code that reports an error to the platform. If it returns * SDL_APP_SUCCESS, SDL calls SDL_AppQuit and terminates with an exit code * that reports success to the platform. * * This function is called by SDL on the main thread. * * \param appstate a place where the app can optionally store a pointer for * future use. * \param argc the standard ANSI C main's argc; number of elements in `argv`. * \param argv the standard ANSI C main's argv; array of command line * arguments. * \returns SDL_APP_FAILURE to terminate with an error, SDL_APP_SUCCESS to * terminate with success, SDL_APP_CONTINUE to continue. * * \threadsafety This function is called once by SDL, at startup, on a single * thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_AppIterate * \sa SDL_AppEvent * \sa SDL_AppQuit */ extern SDLMAIN_DECLSPEC SDL_AppResult SDLCALL SDL_AppInit(void **appstate, int argc, char *argv[]); /** * App-implemented iteration entry point for SDL_MAIN_USE_CALLBACKS apps. * * Apps implement this function when using SDL_MAIN_USE_CALLBACKS. If using a * standard "main" function, you should not supply this. * * This function is called repeatedly by SDL after SDL_AppInit returns * SDL_APP_CONTINUE. The function should operate as a single iteration the * program's primary loop; it should update whatever state it needs and draw a * new frame of video, usually. * * On some platforms, this function will be called at the refresh rate of the * display (which might change during the life of your app!). There are no * promises made about what frequency this function might run at. You should * use SDL's timer functions if you need to see how much time has passed since * the last iteration. * * There is no need to process the SDL event queue during this function; SDL * will send events as they arrive in SDL_AppEvent, and in most cases the * event queue will be empty when this function runs anyhow. * * This function should not go into an infinite mainloop; it should do one * iteration of whatever the program does and return. * * The `appstate` parameter is an optional pointer provided by the app during * SDL_AppInit(). If the app never provided a pointer, this will be NULL. * * If this function returns SDL_APP_CONTINUE, the app will continue normal * operation, receiving repeated calls to SDL_AppIterate and SDL_AppEvent for * the life of the program. If this function returns SDL_APP_FAILURE, SDL will * call SDL_AppQuit and terminate the process with an exit code that reports * an error to the platform. If it returns SDL_APP_SUCCESS, SDL calls * SDL_AppQuit and terminates with an exit code that reports success to the * platform. * * This function is called by SDL on the main thread. * * \param appstate an optional pointer, provided by the app in SDL_AppInit. * \returns SDL_APP_FAILURE to terminate with an error, SDL_APP_SUCCESS to * terminate with success, SDL_APP_CONTINUE to continue. * * \threadsafety This function may get called concurrently with SDL_AppEvent() * for events not pushed on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_AppInit * \sa SDL_AppEvent */ extern SDLMAIN_DECLSPEC SDL_AppResult SDLCALL SDL_AppIterate(void *appstate); /** * App-implemented event entry point for SDL_MAIN_USE_CALLBACKS apps. * * Apps implement this function when using SDL_MAIN_USE_CALLBACKS. If using a * standard "main" function, you should not supply this. * * This function is called as needed by SDL after SDL_AppInit returns * SDL_APP_CONTINUE. It is called once for each new event. * * There is (currently) no guarantee about what thread this will be called * from; whatever thread pushes an event onto SDL's queue will trigger this * function. SDL is responsible for pumping the event queue between each call * to SDL_AppIterate, so in normal operation one should only get events in a * serial fashion, but be careful if you have a thread that explicitly calls * SDL_PushEvent. SDL itself will push events to the queue on the main thread. * * Events sent to this function are not owned by the app; if you need to save * the data, you should copy it. * * This function should not go into an infinite mainloop; it should handle the * provided event appropriately and return. * * The `appstate` parameter is an optional pointer provided by the app during * SDL_AppInit(). If the app never provided a pointer, this will be NULL. * * If this function returns SDL_APP_CONTINUE, the app will continue normal * operation, receiving repeated calls to SDL_AppIterate and SDL_AppEvent for * the life of the program. If this function returns SDL_APP_FAILURE, SDL will * call SDL_AppQuit and terminate the process with an exit code that reports * an error to the platform. If it returns SDL_APP_SUCCESS, SDL calls * SDL_AppQuit and terminates with an exit code that reports success to the * platform. * * \param appstate an optional pointer, provided by the app in SDL_AppInit. * \param event the new event for the app to examine. * \returns SDL_APP_FAILURE to terminate with an error, SDL_APP_SUCCESS to * terminate with success, SDL_APP_CONTINUE to continue. * * \threadsafety This function may get called concurrently with * SDL_AppIterate() or SDL_AppQuit() for events not pushed from * the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_AppInit * \sa SDL_AppIterate */ extern SDLMAIN_DECLSPEC SDL_AppResult SDLCALL SDL_AppEvent(void *appstate, SDL_Event *event); /** * App-implemented deinit entry point for SDL_MAIN_USE_CALLBACKS apps. * * Apps implement this function when using SDL_MAIN_USE_CALLBACKS. If using a * standard "main" function, you should not supply this. * * This function is called once by SDL before terminating the program. * * This function will be called in all cases, even if SDL_AppInit requests * termination at startup. * * This function should not go into an infinite mainloop; it should * deinitialize any resources necessary, perform whatever shutdown activities, * and return. * * You do not need to call SDL_Quit() in this function, as SDL will call it * after this function returns and before the process terminates, but it is * safe to do so. * * The `appstate` parameter is an optional pointer provided by the app during * SDL_AppInit(). If the app never provided a pointer, this will be NULL. This * function call is the last time this pointer will be provided, so any * resources to it should be cleaned up here. * * This function is called by SDL on the main thread. * * \param appstate an optional pointer, provided by the app in SDL_AppInit. * \param result the result code that terminated the app (success or failure). * * \threadsafety SDL_AppEvent() may get called concurrently with this function * if other threads that push events are still active. * * \since This function is available since SDL 3.2.0. * * \sa SDL_AppInit */ extern SDLMAIN_DECLSPEC void SDLCALL SDL_AppQuit(void *appstate, SDL_AppResult result); #endif /* SDL_MAIN_USE_CALLBACKS */ /** * The prototype for the application's main() function * * \param argc an ANSI-C style main function's argc. * \param argv an ANSI-C style main function's argv. * \returns an ANSI-C main return code; generally 0 is considered successful * program completion, and small non-zero values are considered * errors. * * \since This datatype is available since SDL 3.2.0. */ typedef int (SDLCALL *SDL_main_func)(int argc, char *argv[]); /** * An app-supplied function for program entry. * * Apps do not directly create this function; they should create a standard * ANSI-C `main` function instead. If SDL needs to insert some startup code * before `main` runs, or the platform doesn't actually _use_ a function * called "main", SDL will do some macro magic to redefine `main` to * `SDL_main` and provide its own `main`. * * Apps should include `SDL_main.h` in the same file as their `main` function, * and they should not use that symbol for anything else in that file, as it * might get redefined. * * This function is only provided by the app if it isn't using * SDL_MAIN_USE_CALLBACKS. * * Program startup is a surprisingly complex topic. Please see * [README-main-functions](README-main-functions), (or * docs/README-main-functions.md in the source tree) for a more detailed * explanation. * * \param argc an ANSI-C style main function's argc. * \param argv an ANSI-C style main function's argv. * \returns an ANSI-C main return code; generally 0 is considered successful * program completion, and small non-zero values are considered * errors. * * \threadsafety This is the program entry point. * * \since This function is available since SDL 3.2.0. */ extern SDLMAIN_DECLSPEC int SDLCALL SDL_main(int argc, char *argv[]); /** * Circumvent failure of SDL_Init() when not using SDL_main() as an entry * point. * * This function is defined in SDL_main.h, along with the preprocessor rule to * redefine main() as SDL_main(). Thus to ensure that your main() function * will not be changed it is necessary to define SDL_MAIN_HANDLED before * including SDL.h. * * \threadsafety This function is not thread safe. * * \since This function is available since SDL 3.2.0. * * \sa SDL_Init */ extern SDL_DECLSPEC void SDLCALL SDL_SetMainReady(void); /** * Initializes and launches an SDL application, by doing platform-specific * initialization before calling your mainFunction and cleanups after it * returns, if that is needed for a specific platform, otherwise it just calls * mainFunction. * * You can use this if you want to use your own main() implementation without * using SDL_main (like when using SDL_MAIN_HANDLED). When using this, you do * *not* need SDL_SetMainReady(). * * If `argv` is NULL, SDL will provide command line arguments, either by * querying the OS for them if possible, or supplying a filler array if not. * * \param argc the argc parameter from the application's main() function, or 0 * if the platform's main-equivalent has no argc. * \param argv the argv parameter from the application's main() function, or * NULL if the platform's main-equivalent has no argv. * \param mainFunction your SDL app's C-style main(). NOT the function you're * calling this from! Its name doesn't matter; it doesn't * literally have to be `main`. * \param reserved should be NULL (reserved for future use, will probably be * platform-specific then). * \returns the return value from mainFunction: 0 on success, otherwise * failure; SDL_GetError() might have more information on the * failure. * * \threadsafety Generally this is called once, near startup, from the * process's initial thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC int SDLCALL SDL_RunApp(int argc, char *argv[], SDL_main_func mainFunction, void *reserved); /** * An entry point for SDL's use in SDL_MAIN_USE_CALLBACKS. * * Generally, you should not call this function directly. This only exists to * hand off work into SDL as soon as possible, where it has a lot more control * and functionality available, and make the inline code in SDL_main.h as * small as possible. * * Not all platforms use this, it's actual use is hidden in a magic * header-only library, and you should not call this directly unless you * _really_ know what you're doing. * * \param argc standard Unix main argc. * \param argv standard Unix main argv. * \param appinit the application's SDL_AppInit function. * \param appiter the application's SDL_AppIterate function. * \param appevent the application's SDL_AppEvent function. * \param appquit the application's SDL_AppQuit function. * \returns standard Unix main return value. * * \threadsafety It is not safe to call this anywhere except as the only * function call in SDL_main. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC int SDLCALL SDL_EnterAppMainCallbacks(int argc, char *argv[], SDL_AppInit_func appinit, SDL_AppIterate_func appiter, SDL_AppEvent_func appevent, SDL_AppQuit_func appquit); #if defined(SDL_PLATFORM_WINDOWS) /** * Register a win32 window class for SDL's use. * * This can be called to set the application window class at startup. It is * safe to call this multiple times, as long as every call is eventually * paired with a call to SDL_UnregisterApp, but a second registration attempt * while a previous registration is still active will be ignored, other than * to increment a counter. * * Most applications do not need to, and should not, call this directly; SDL * will call it when initializing the video subsystem. * * If `name` is NULL, SDL currently uses `(CS_BYTEALIGNCLIENT | CS_OWNDC)` for * the style, regardless of what is specified here. * * \param name the window class name, in UTF-8 encoding. If NULL, SDL * currently uses "SDL_app" but this isn't guaranteed. * \param style the value to use in WNDCLASSEX::style. * \param hInst the HINSTANCE to use in WNDCLASSEX::hInstance. If zero, SDL * will use `GetModuleHandle(NULL)` instead. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety This function is not thread safe. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC bool SDLCALL SDL_RegisterApp(const char *name, Uint32 style, void *hInst); /** * Deregister the win32 window class from an SDL_RegisterApp call. * * This can be called to undo the effects of SDL_RegisterApp. * * Most applications do not need to, and should not, call this directly; SDL * will call it when deinitializing the video subsystem. * * It is safe to call this multiple times, as long as every call is eventually * paired with a prior call to SDL_RegisterApp. The window class will only be * deregistered when the registration counter in SDL_RegisterApp decrements to * zero through calls to this function. * * \threadsafety This function is not thread safe. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC void SDLCALL SDL_UnregisterApp(void); #endif /* defined(SDL_PLATFORM_WINDOWS) */ /** * Callback from the application to let the suspend continue. * * This should be called from an event watch in response to an * `SDL_EVENT_DID_ENTER_BACKGROUND` event. * * When using SDL_Render, your event watch should be added _after_ creating * the `SDL_Renderer`; this allows the timing of the D3D12 command queue * suspension to execute in the correct order. * * When using SDL_GPU, this should be called after calling SDL_GDKSuspendGPU. * * If you're writing your own D3D12 renderer, this should be called after * calling `ID3D12CommandQueue::SuspendX`. * * This function is only needed for Xbox GDK support; all other platforms will * do nothing and set an "unsupported" error message. * * \threadsafety This function is not thread safe. * * \since This function is available since SDL 3.2.0. * * \sa SDL_AddEventWatch */ extern SDL_DECLSPEC void SDLCALL SDL_GDKSuspendComplete(void); #ifdef __cplusplus } #endif #include #if !defined(SDL_MAIN_HANDLED) && !defined(SDL_MAIN_NOIMPL) /* include header-only SDL_main implementations */ #if defined(SDL_MAIN_USE_CALLBACKS) || defined(SDL_MAIN_NEEDED) || defined(SDL_MAIN_AVAILABLE) /* platforms which main (-equivalent) can be implemented in plain C */ #include #endif #endif #endif /* SDL_main_h_ */ ================================================ FILE: deps/include/SDL3/SDL_main_impl.h ================================================ /* Simple DirectMedia Layer Copyright (C) 1997-2026 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ /* WIKI CATEGORY: Main */ #ifndef SDL_main_impl_h_ #define SDL_main_impl_h_ #ifndef SDL_main_h_ #error "This header should not be included directly, but only via SDL_main.h!" #endif /* if someone wants to include SDL_main.h but doesn't want the main handing magic, (maybe to call SDL_RegisterApp()) they can #define SDL_MAIN_HANDLED first. SDL_MAIN_NOIMPL is for SDL-internal usage (only affects implementation, not definition of SDL_MAIN_AVAILABLE etc in SDL_main.h) and if the user wants to have the SDL_main implementation (from this header) in another source file than their main() function, for example if SDL_main requires C++ and main() is implemented in plain C */ #if !defined(SDL_MAIN_HANDLED) && !defined(SDL_MAIN_NOIMPL) /* the implementations below must be able to use the implement real main(), nothing renamed (the user's main() will be renamed to SDL_main so it can be called from here) */ #ifdef main #undef main #endif #ifdef SDL_MAIN_USE_CALLBACKS #if 0 /* currently there are no platforms that _need_ a magic entry point here for callbacks, but if one shows up, implement it here. */ #else /* use a standard SDL_main, which the app SHOULD NOT ALSO SUPPLY. */ /* this define makes the normal SDL_main entry point stuff work...we just provide SDL_main() instead of the app. */ #define SDL_MAIN_CALLBACK_STANDARD 1 int SDL_main(int argc, char **argv) { return SDL_EnterAppMainCallbacks(argc, argv, SDL_AppInit, SDL_AppIterate, SDL_AppEvent, SDL_AppQuit); } #endif /* platform-specific tests */ #endif /* SDL_MAIN_USE_CALLBACKS */ /* set up the usual SDL_main stuff if we're not using callbacks or if we are but need the normal entry point, unless the real entry point needs to be somewhere else entirely, like Android where it's in Java code */ #if (!defined(SDL_MAIN_USE_CALLBACKS) || defined(SDL_MAIN_CALLBACK_STANDARD)) && !defined(SDL_MAIN_EXPORTED) #if defined(SDL_PLATFORM_PRIVATE_MAIN) /* Private platforms may have their own ideas about entry points. */ #include "SDL_main_impl_private.h" #elif defined(SDL_PLATFORM_WINDOWS) /* these defines/typedefs are needed for the WinMain() definition */ #ifndef WINAPI #define WINAPI __stdcall #endif typedef struct HINSTANCE__ * HINSTANCE; typedef char *LPSTR; typedef wchar_t *PWSTR; /* The VC++ compiler needs main/wmain defined, but not for GDK */ #if defined(_MSC_VER) && !defined(SDL_PLATFORM_GDK) /* This is where execution begins [console apps] */ #if defined(UNICODE) && UNICODE int wmain(int argc, wchar_t *wargv[], wchar_t *wenvp) { (void)argc; (void)wargv; (void)wenvp; return SDL_RunApp(0, NULL, SDL_main, NULL); } #else /* ANSI */ int main(int argc, char *argv[]) { (void)argc; (void)argv; return SDL_RunApp(0, NULL, SDL_main, NULL); } #endif /* UNICODE */ #endif /* _MSC_VER && ! SDL_PLATFORM_GDK */ /* This is where execution begins [windowed apps and GDK] */ #ifdef __cplusplus extern "C" { #endif #if defined(UNICODE) && UNICODE int WINAPI wWinMain(HINSTANCE hInst, HINSTANCE hPrev, PWSTR szCmdLine, int sw) #else /* ANSI */ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR szCmdLine, int sw) #endif { (void)hInst; (void)hPrev; (void)szCmdLine; (void)sw; return SDL_RunApp(0, NULL, SDL_main, NULL); } #ifdef __cplusplus } /* extern "C" */ #endif /* end of SDL_PLATFORM_WINDOWS impls */ #else /* platforms that use a standard main() and just call SDL_RunApp(), like iOS and 3DS */ int main(int argc, char *argv[]) { return SDL_RunApp(argc, argv, SDL_main, NULL); } /* end of impls for standard-conforming platforms */ #endif /* SDL_PLATFORM_WIN32 etc */ #endif /* !defined(SDL_MAIN_USE_CALLBACKS) || defined(SDL_MAIN_CALLBACK_STANDARD) */ /* rename users main() function to SDL_main() so it can be called from the wrappers above */ #define main SDL_main #endif /* SDL_MAIN_HANDLED */ #endif /* SDL_main_impl_h_ */ ================================================ FILE: deps/include/SDL3/SDL_messagebox.h ================================================ /* Simple DirectMedia Layer Copyright (C) 1997-2026 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ /** * # CategoryMessagebox * * SDL offers a simple message box API, which is useful for simple alerts, * such as informing the user when something fatal happens at startup without * the need to build a UI for it (or informing the user _before_ your UI is * ready). * * These message boxes are native system dialogs where possible. * * There is both a customizable function (SDL_ShowMessageBox()) that offers * lots of options for what to display and reports on what choice the user * made, and also a much-simplified version (SDL_ShowSimpleMessageBox()), * merely takes a text message and title, and waits until the user presses a * single "OK" UI button. Often, this is all that is necessary. */ #ifndef SDL_messagebox_h_ #define SDL_messagebox_h_ #include #include #include /* For SDL_Window */ #include /* Set up for C function definitions, even when using C++ */ #ifdef __cplusplus extern "C" { #endif /** * Message box flags. * * If supported will display warning icon, etc. * * \since This datatype is available since SDL 3.2.0. */ typedef Uint32 SDL_MessageBoxFlags; #define SDL_MESSAGEBOX_ERROR 0x00000010u /**< error dialog */ #define SDL_MESSAGEBOX_WARNING 0x00000020u /**< warning dialog */ #define SDL_MESSAGEBOX_INFORMATION 0x00000040u /**< informational dialog */ #define SDL_MESSAGEBOX_BUTTONS_LEFT_TO_RIGHT 0x00000080u /**< buttons placed left to right */ #define SDL_MESSAGEBOX_BUTTONS_RIGHT_TO_LEFT 0x00000100u /**< buttons placed right to left */ /** * SDL_MessageBoxButtonData flags. * * \since This datatype is available since SDL 3.2.0. */ typedef Uint32 SDL_MessageBoxButtonFlags; #define SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT 0x00000001u /**< Marks the default button when return is hit */ #define SDL_MESSAGEBOX_BUTTON_ESCAPEKEY_DEFAULT 0x00000002u /**< Marks the default button when escape is hit */ /** * Individual button data. * * \since This struct is available since SDL 3.2.0. */ typedef struct SDL_MessageBoxButtonData { SDL_MessageBoxButtonFlags flags; int buttonID; /**< User defined button id (value returned via SDL_ShowMessageBox) */ const char *text; /**< The UTF-8 button text */ } SDL_MessageBoxButtonData; /** * RGB value used in a message box color scheme * * \since This struct is available since SDL 3.2.0. */ typedef struct SDL_MessageBoxColor { Uint8 r, g, b; } SDL_MessageBoxColor; /** * An enumeration of indices inside the colors array of * SDL_MessageBoxColorScheme. */ typedef enum SDL_MessageBoxColorType { SDL_MESSAGEBOX_COLOR_BACKGROUND, SDL_MESSAGEBOX_COLOR_TEXT, SDL_MESSAGEBOX_COLOR_BUTTON_BORDER, SDL_MESSAGEBOX_COLOR_BUTTON_BACKGROUND, SDL_MESSAGEBOX_COLOR_BUTTON_SELECTED, SDL_MESSAGEBOX_COLOR_COUNT /**< Size of the colors array of SDL_MessageBoxColorScheme. */ } SDL_MessageBoxColorType; /** * A set of colors to use for message box dialogs * * \since This struct is available since SDL 3.2.0. */ typedef struct SDL_MessageBoxColorScheme { SDL_MessageBoxColor colors[SDL_MESSAGEBOX_COLOR_COUNT]; } SDL_MessageBoxColorScheme; /** * MessageBox structure containing title, text, window, etc. * * \since This struct is available since SDL 3.2.0. */ typedef struct SDL_MessageBoxData { SDL_MessageBoxFlags flags; SDL_Window *window; /**< Parent window, can be NULL */ const char *title; /**< UTF-8 title */ const char *message; /**< UTF-8 message text */ int numbuttons; const SDL_MessageBoxButtonData *buttons; const SDL_MessageBoxColorScheme *colorScheme; /**< SDL_MessageBoxColorScheme, can be NULL to use system settings */ } SDL_MessageBoxData; /** * Create a modal message box. * * If your needs aren't complex, it might be easier to use * SDL_ShowSimpleMessageBox. * * This function should be called on the thread that created the parent * window, or on the main thread if the messagebox has no parent. It will * block execution of that thread until the user clicks a button or closes the * messagebox. * * This function may be called at any time, even before SDL_Init(). This makes * it useful for reporting errors like a failure to create a renderer or * OpenGL context. * * On X11, SDL rolls its own dialog box with X11 primitives instead of a * formal toolkit like GTK+ or Qt. * * Note that if SDL_Init() would fail because there isn't any available video * target, this function is likely to fail for the same reasons. If this is a * concern, check the return value from this function and fall back to writing * to stderr if you can. * * \param messageboxdata the SDL_MessageBoxData structure with title, text and * other options. * \param buttonid the pointer to which user id of hit button should be * copied. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_ShowSimpleMessageBox */ extern SDL_DECLSPEC bool SDLCALL SDL_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid); /** * Display a simple modal message box. * * If your needs aren't complex, this function is preferred over * SDL_ShowMessageBox. * * `flags` may be any of the following: * * - `SDL_MESSAGEBOX_ERROR`: error dialog * - `SDL_MESSAGEBOX_WARNING`: warning dialog * - `SDL_MESSAGEBOX_INFORMATION`: informational dialog * * This function should be called on the thread that created the parent * window, or on the main thread if the messagebox has no parent. It will * block execution of that thread until the user clicks a button or closes the * messagebox. * * This function may be called at any time, even before SDL_Init(). This makes * it useful for reporting errors like a failure to create a renderer or * OpenGL context. * * On X11, SDL rolls its own dialog box with X11 primitives instead of a * formal toolkit like GTK+ or Qt. * * Note that if SDL_Init() would fail because there isn't any available video * target, this function is likely to fail for the same reasons. If this is a * concern, check the return value from this function and fall back to writing * to stderr if you can. * * \param flags an SDL_MessageBoxFlags value. * \param title UTF-8 title text. * \param message UTF-8 message text. * \param window the parent window, or NULL for no parent. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_ShowMessageBox */ extern SDL_DECLSPEC bool SDLCALL SDL_ShowSimpleMessageBox(SDL_MessageBoxFlags flags, const char *title, const char *message, SDL_Window *window); /* Ends C function definitions when using C++ */ #ifdef __cplusplus } #endif #include #endif /* SDL_messagebox_h_ */ ================================================ FILE: deps/include/SDL3/SDL_metal.h ================================================ /* Simple DirectMedia Layer Copyright (C) 1997-2026 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ /** * # CategoryMetal * * Functions to creating Metal layers and views on SDL windows. * * This provides some platform-specific glue for Apple platforms. Most macOS * and iOS apps can use SDL without these functions, but this API they can be * useful for specific OS-level integration tasks. */ #ifndef SDL_metal_h_ #define SDL_metal_h_ #include #include /* Set up for C function definitions, even when using C++ */ #ifdef __cplusplus extern "C" { #endif /** * A handle to a CAMetalLayer-backed NSView (macOS) or UIView (iOS/tvOS). * * \since This datatype is available since SDL 3.2.0. */ typedef void *SDL_MetalView; /** * \name Metal support functions */ /* @{ */ /** * Create a CAMetalLayer-backed NSView/UIView and attach it to the specified * window. * * On macOS, this does *not* associate a MTLDevice with the CAMetalLayer on * its own. It is up to user code to do that. * * The returned handle can be casted directly to a NSView or UIView. To access * the backing CAMetalLayer, call SDL_Metal_GetLayer(). * * \param window the window. * \returns handle NSView or UIView. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_Metal_DestroyView * \sa SDL_Metal_GetLayer */ extern SDL_DECLSPEC SDL_MetalView SDLCALL SDL_Metal_CreateView(SDL_Window *window); /** * Destroy an existing SDL_MetalView object. * * This should be called before SDL_DestroyWindow, if SDL_Metal_CreateView was * called after SDL_CreateWindow. * * \param view the SDL_MetalView object. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_Metal_CreateView */ extern SDL_DECLSPEC void SDLCALL SDL_Metal_DestroyView(SDL_MetalView view); /** * Get a pointer to the backing CAMetalLayer for the given view. * * \param view the SDL_MetalView object. * \returns a pointer. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC void * SDLCALL SDL_Metal_GetLayer(SDL_MetalView view); /* @} *//* Metal support functions */ /* Ends C function definitions when using C++ */ #ifdef __cplusplus } #endif #include #endif /* SDL_metal_h_ */ ================================================ FILE: deps/include/SDL3/SDL_misc.h ================================================ /* Simple DirectMedia Layer Copyright (C) 1997-2026 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ /** * # CategoryMisc * * SDL API functions that don't fit elsewhere. */ #ifndef SDL_misc_h_ #define SDL_misc_h_ #include #include #include /* Set up for C function definitions, even when using C++ */ #ifdef __cplusplus extern "C" { #endif /** * Open a URL/URI in the browser or other appropriate external application. * * Open a URL in a separate, system-provided application. How this works will * vary wildly depending on the platform. This will likely launch what makes * sense to handle a specific URL's protocol (a web browser for `http://`, * etc), but it might also be able to launch file managers for directories and * other things. * * What happens when you open a URL varies wildly as well: your game window * may lose focus (and may or may not lose focus if your game was fullscreen * or grabbing input at the time). On mobile devices, your app will likely * move to the background or your process might be paused. Any given platform * may or may not handle a given URL. * * If this is unimplemented (or simply unavailable) for a platform, this will * fail with an error. A successful result does not mean the URL loaded, just * that we launched _something_ to handle it (or at least believe we did). * * All this to say: this function can be useful, but you should definitely * test it on every platform you target. * * \param url a valid URL/URI to open. Use `file:///full/path/to/file` for * local files, if supported. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC bool SDLCALL SDL_OpenURL(const char *url); /* Ends C function definitions when using C++ */ #ifdef __cplusplus } #endif #include #endif /* SDL_misc_h_ */ ================================================ FILE: deps/include/SDL3/SDL_mouse.h ================================================ /* Simple DirectMedia Layer Copyright (C) 1997-2026 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ /** * # CategoryMouse * * Any GUI application has to deal with the mouse, and SDL provides functions * to manage mouse input and the displayed cursor. * * Most interactions with the mouse will come through the event subsystem. * Moving a mouse generates an SDL_EVENT_MOUSE_MOTION event, pushing a button * generates SDL_EVENT_MOUSE_BUTTON_DOWN, etc, but one can also query the * current state of the mouse at any time with SDL_GetMouseState(). * * For certain games, it's useful to disassociate the mouse cursor from mouse * input. An FPS, for example, would not want the player's motion to stop as * the mouse hits the edge of the window. For these scenarios, use * SDL_SetWindowRelativeMouseMode(), which hides the cursor, grabs mouse input * to the window, and reads mouse input no matter how far it moves. * * Games that want the system to track the mouse but want to draw their own * cursor can use SDL_HideCursor() and SDL_ShowCursor(). It might be more * efficient to let the system manage the cursor, if possible, using * SDL_SetCursor() with a custom image made through SDL_CreateColorCursor(), * or perhaps just a specific system cursor from SDL_CreateSystemCursor(). * * SDL can, on many platforms, differentiate between multiple connected mice, * allowing for interesting input scenarios and multiplayer games. They can be * enumerated with SDL_GetMice(), and SDL will send SDL_EVENT_MOUSE_ADDED and * SDL_EVENT_MOUSE_REMOVED events as they are connected and unplugged. * * Since many apps only care about basic mouse input, SDL offers a virtual * mouse device for touch and pen input, which often can make a desktop * application work on a touchscreen phone without any code changes. Apps that * care about touch/pen separately from mouse input should filter out events * with a `which` field of SDL_TOUCH_MOUSEID/SDL_PEN_MOUSEID. */ #ifndef SDL_mouse_h_ #define SDL_mouse_h_ #include #include #include #include #include /* Set up for C function definitions, even when using C++ */ #ifdef __cplusplus extern "C" { #endif /** * This is a unique ID for a mouse for the time it is connected to the system, * and is never reused for the lifetime of the application. * * If the mouse is disconnected and reconnected, it will get a new ID. * * The value 0 is an invalid ID. * * \since This datatype is available since SDL 3.2.0. */ typedef Uint32 SDL_MouseID; /** * The structure used to identify an SDL cursor. * * This is opaque data. * * \since This struct is available since SDL 3.2.0. */ typedef struct SDL_Cursor SDL_Cursor; /** * Cursor types for SDL_CreateSystemCursor(). * * \since This enum is available since SDL 3.2.0. */ typedef enum SDL_SystemCursor { SDL_SYSTEM_CURSOR_DEFAULT, /**< Default cursor. Usually an arrow. */ SDL_SYSTEM_CURSOR_TEXT, /**< Text selection. Usually an I-beam. */ SDL_SYSTEM_CURSOR_WAIT, /**< Wait. Usually an hourglass or watch or spinning ball. */ SDL_SYSTEM_CURSOR_CROSSHAIR, /**< Crosshair. */ SDL_SYSTEM_CURSOR_PROGRESS, /**< Program is busy but still interactive. Usually it's WAIT with an arrow. */ SDL_SYSTEM_CURSOR_NWSE_RESIZE, /**< Double arrow pointing northwest and southeast. */ SDL_SYSTEM_CURSOR_NESW_RESIZE, /**< Double arrow pointing northeast and southwest. */ SDL_SYSTEM_CURSOR_EW_RESIZE, /**< Double arrow pointing west and east. */ SDL_SYSTEM_CURSOR_NS_RESIZE, /**< Double arrow pointing north and south. */ SDL_SYSTEM_CURSOR_MOVE, /**< Four pointed arrow pointing north, south, east, and west. */ SDL_SYSTEM_CURSOR_NOT_ALLOWED, /**< Not permitted. Usually a slashed circle or crossbones. */ SDL_SYSTEM_CURSOR_POINTER, /**< Pointer that indicates a link. Usually a pointing hand. */ SDL_SYSTEM_CURSOR_NW_RESIZE, /**< Window resize top-left. This may be a single arrow or a double arrow like NWSE_RESIZE. */ SDL_SYSTEM_CURSOR_N_RESIZE, /**< Window resize top. May be NS_RESIZE. */ SDL_SYSTEM_CURSOR_NE_RESIZE, /**< Window resize top-right. May be NESW_RESIZE. */ SDL_SYSTEM_CURSOR_E_RESIZE, /**< Window resize right. May be EW_RESIZE. */ SDL_SYSTEM_CURSOR_SE_RESIZE, /**< Window resize bottom-right. May be NWSE_RESIZE. */ SDL_SYSTEM_CURSOR_S_RESIZE, /**< Window resize bottom. May be NS_RESIZE. */ SDL_SYSTEM_CURSOR_SW_RESIZE, /**< Window resize bottom-left. May be NESW_RESIZE. */ SDL_SYSTEM_CURSOR_W_RESIZE, /**< Window resize left. May be EW_RESIZE. */ SDL_SYSTEM_CURSOR_COUNT } SDL_SystemCursor; /** * Scroll direction types for the Scroll event * * \since This enum is available since SDL 3.2.0. */ typedef enum SDL_MouseWheelDirection { SDL_MOUSEWHEEL_NORMAL, /**< The scroll direction is normal */ SDL_MOUSEWHEEL_FLIPPED /**< The scroll direction is flipped / natural */ } SDL_MouseWheelDirection; /** * Animated cursor frame info. * * \since This struct is available since SDL 3.4.0. */ typedef struct SDL_CursorFrameInfo { SDL_Surface *surface; /**< The surface data for this frame */ Uint32 duration; /**< The frame duration in milliseconds (a duration of 0 is infinite) */ } SDL_CursorFrameInfo; /** * A bitmask of pressed mouse buttons, as reported by SDL_GetMouseState, etc. * * - Button 1: Left mouse button * - Button 2: Middle mouse button * - Button 3: Right mouse button * - Button 4: Side mouse button 1 * - Button 5: Side mouse button 2 * * \since This datatype is available since SDL 3.2.0. * * \sa SDL_GetMouseState * \sa SDL_GetGlobalMouseState * \sa SDL_GetRelativeMouseState */ typedef Uint32 SDL_MouseButtonFlags; #define SDL_BUTTON_LEFT 1 #define SDL_BUTTON_MIDDLE 2 #define SDL_BUTTON_RIGHT 3 #define SDL_BUTTON_X1 4 #define SDL_BUTTON_X2 5 #define SDL_BUTTON_MASK(X) (1u << ((X)-1)) #define SDL_BUTTON_LMASK SDL_BUTTON_MASK(SDL_BUTTON_LEFT) #define SDL_BUTTON_MMASK SDL_BUTTON_MASK(SDL_BUTTON_MIDDLE) #define SDL_BUTTON_RMASK SDL_BUTTON_MASK(SDL_BUTTON_RIGHT) #define SDL_BUTTON_X1MASK SDL_BUTTON_MASK(SDL_BUTTON_X1) #define SDL_BUTTON_X2MASK SDL_BUTTON_MASK(SDL_BUTTON_X2) /** * A callback used to transform mouse motion delta from raw values. * * This is called during SDL's handling of platform mouse events to scale the * values of the resulting motion delta. * * \param userdata what was passed as `userdata` to * SDL_SetRelativeMouseTransform(). * \param timestamp the associated time at which this mouse motion event was * received. * \param window the associated window to which this mouse motion event was * addressed. * \param mouseID the associated mouse from which this mouse motion event was * emitted. * \param x pointer to a variable that will be treated as the resulting x-axis * motion. * \param y pointer to a variable that will be treated as the resulting y-axis * motion. * * \threadsafety This callback is called by SDL's internal mouse input * processing procedure, which may be a thread separate from the * main event loop that is run at realtime priority. Stalling * this thread with too much work in the callback can therefore * potentially freeze the entire system. Care should be taken * with proper synchronization practices when adding other side * effects beyond mutation of the x and y values. * * \since This datatype is available since SDL 3.4.0. * * \sa SDL_SetRelativeMouseTransform */ typedef void (SDLCALL *SDL_MouseMotionTransformCallback)( void *userdata, Uint64 timestamp, SDL_Window *window, SDL_MouseID mouseID, float *x, float *y ); /* Function prototypes */ /** * Return whether a mouse is currently connected. * * \returns true if a mouse is connected, false otherwise. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetMice */ extern SDL_DECLSPEC bool SDLCALL SDL_HasMouse(void); /** * Get a list of currently connected mice. * * Note that this will include any device or virtual driver that includes * mouse functionality, including some game controllers, KVM switches, etc. * You should wait for input from a device before you consider it actively in * use. * * \param count a pointer filled in with the number of mice returned, may be * NULL. * \returns a 0 terminated array of mouse instance IDs or NULL on failure; * call SDL_GetError() for more information. This should be freed * with SDL_free() when it is no longer needed. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetMouseNameForID * \sa SDL_HasMouse */ extern SDL_DECLSPEC SDL_MouseID * SDLCALL SDL_GetMice(int *count); /** * Get the name of a mouse. * * This function returns "" if the mouse doesn't have a name. * * \param instance_id the mouse instance ID. * \returns the name of the selected mouse, or NULL on failure; call * SDL_GetError() for more information. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetMice */ extern SDL_DECLSPEC const char * SDLCALL SDL_GetMouseNameForID(SDL_MouseID instance_id); /** * Get the window which currently has mouse focus. * * \returns the window with mouse focus. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC SDL_Window * SDLCALL SDL_GetMouseFocus(void); /** * Query SDL's cache for the synchronous mouse button state and the * window-relative SDL-cursor position. * * This function returns the cached synchronous state as SDL understands it * from the last pump of the event queue. * * To query the platform for immediate asynchronous state, use * SDL_GetGlobalMouseState. * * Passing non-NULL pointers to `x` or `y` will write the destination with * respective x or y coordinates relative to the focused window. * * In Relative Mode, the SDL-cursor's position usually contradicts the * platform-cursor's position as manually calculated from * SDL_GetGlobalMouseState() and SDL_GetWindowPosition. * * \param x a pointer to receive the SDL-cursor's x-position from the focused * window's top left corner, can be NULL if unused. * \param y a pointer to receive the SDL-cursor's y-position from the focused * window's top left corner, can be NULL if unused. * \returns a 32-bit bitmask of the button state that can be bitwise-compared * against the SDL_BUTTON_MASK(X) macro. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetGlobalMouseState * \sa SDL_GetRelativeMouseState */ extern SDL_DECLSPEC SDL_MouseButtonFlags SDLCALL SDL_GetMouseState(float *x, float *y); /** * Query the platform for the asynchronous mouse button state and the * desktop-relative platform-cursor position. * * This function immediately queries the platform for the most recent * asynchronous state, more costly than retrieving SDL's cached state in * SDL_GetMouseState(). * * Passing non-NULL pointers to `x` or `y` will write the destination with * respective x or y coordinates relative to the desktop. * * In Relative Mode, the platform-cursor's position usually contradicts the * SDL-cursor's position as manually calculated from SDL_GetMouseState() and * SDL_GetWindowPosition. * * This function can be useful if you need to track the mouse outside of a * specific window and SDL_CaptureMouse() doesn't fit your needs. For example, * it could be useful if you need to track the mouse while dragging a window, * where coordinates relative to a window might not be in sync at all times. * * \param x a pointer to receive the platform-cursor's x-position from the * desktop's top left corner, can be NULL if unused. * \param y a pointer to receive the platform-cursor's y-position from the * desktop's top left corner, can be NULL if unused. * \returns a 32-bit bitmask of the button state that can be bitwise-compared * against the SDL_BUTTON_MASK(X) macro. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_CaptureMouse * \sa SDL_GetMouseState * \sa SDL_GetGlobalMouseState */ extern SDL_DECLSPEC SDL_MouseButtonFlags SDLCALL SDL_GetGlobalMouseState(float *x, float *y); /** * Query SDL's cache for the synchronous mouse button state and accumulated * mouse delta since last call. * * This function returns the cached synchronous state as SDL understands it * from the last pump of the event queue. * * To query the platform for immediate asynchronous state, use * SDL_GetGlobalMouseState. * * Passing non-NULL pointers to `x` or `y` will write the destination with * respective x or y deltas accumulated since the last call to this function * (or since event initialization). * * This function is useful for reducing overhead by processing relative mouse * inputs in one go per-frame instead of individually per-event, at the * expense of losing the order between events within the frame (e.g. quickly * pressing and releasing a button within the same frame). * * \param x a pointer to receive the x mouse delta accumulated since last * call, can be NULL if unused. * \param y a pointer to receive the y mouse delta accumulated since last * call, can be NULL if unused. * \returns a 32-bit bitmask of the button state that can be bitwise-compared * against the SDL_BUTTON_MASK(X) macro. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetMouseState * \sa SDL_GetGlobalMouseState */ extern SDL_DECLSPEC SDL_MouseButtonFlags SDLCALL SDL_GetRelativeMouseState(float *x, float *y); /** * Move the mouse cursor to the given position within the window. * * This function generates a mouse motion event if relative mode is not * enabled. If relative mode is enabled, you can force mouse events for the * warp by setting the SDL_HINT_MOUSE_RELATIVE_WARP_MOTION hint. * * Note that this function will appear to succeed, but not actually move the * mouse when used over Microsoft Remote Desktop. * * \param window the window to move the mouse into, or NULL for the current * mouse focus. * \param x the x coordinate within the window. * \param y the y coordinate within the window. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_WarpMouseGlobal */ extern SDL_DECLSPEC void SDLCALL SDL_WarpMouseInWindow(SDL_Window *window, float x, float y); /** * Move the mouse to the given position in global screen space. * * This function generates a mouse motion event. * * A failure of this function usually means that it is unsupported by a * platform. * * Note that this function will appear to succeed, but not actually move the * mouse when used over Microsoft Remote Desktop. * * \param x the x coordinate. * \param y the y coordinate. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_WarpMouseInWindow */ extern SDL_DECLSPEC bool SDLCALL SDL_WarpMouseGlobal(float x, float y); /** * Set a user-defined function by which to transform relative mouse inputs. * * This overrides the relative system scale and relative speed scale hints. * Should be called prior to enabling relative mouse mode, fails otherwise. * * \param callback a callback used to transform relative mouse motion, or NULL * for default behavior. * \param userdata a pointer that will be passed to `callback`. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.4.0. */ extern SDL_DECLSPEC bool SDLCALL SDL_SetRelativeMouseTransform(SDL_MouseMotionTransformCallback callback, void *userdata); /** * Set relative mouse mode for a window. * * While the window has focus and relative mouse mode is enabled, the cursor * is hidden, the mouse position is constrained to the window, and SDL will * report continuous relative mouse motion even if the mouse is at the edge of * the window. * * If you'd like to keep the mouse position fixed while in relative mode you * can use SDL_SetWindowMouseRect(). If you'd like the cursor to be at a * specific location when relative mode ends, you should use * SDL_WarpMouseInWindow() before disabling relative mode. * * This function will flush any pending mouse motion for this window. * * \param window the window to change. * \param enabled true to enable relative mode, false to disable. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetWindowRelativeMouseMode */ extern SDL_DECLSPEC bool SDLCALL SDL_SetWindowRelativeMouseMode(SDL_Window *window, bool enabled); /** * Query whether relative mouse mode is enabled for a window. * * \param window the window to query. * \returns true if relative mode is enabled for a window or false otherwise. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_SetWindowRelativeMouseMode */ extern SDL_DECLSPEC bool SDLCALL SDL_GetWindowRelativeMouseMode(SDL_Window *window); /** * Capture the mouse and to track input outside an SDL window. * * Capturing enables your app to obtain mouse events globally, instead of just * within your window. Not all video targets support this function. When * capturing is enabled, the current window will get all mouse events, but * unlike relative mode, no change is made to the cursor and it is not * restrained to your window. * * This function may also deny mouse input to other windows--both those in * your application and others on the system--so you should use this function * sparingly, and in small bursts. For example, you might want to track the * mouse while the user is dragging something, until the user releases a mouse * button. It is not recommended that you capture the mouse for long periods * of time, such as the entire time your app is running. For that, you should * probably use SDL_SetWindowRelativeMouseMode() or SDL_SetWindowMouseGrab(), * depending on your goals. * * While captured, mouse events still report coordinates relative to the * current (foreground) window, but those coordinates may be outside the * bounds of the window (including negative values). Capturing is only allowed * for the foreground window. If the window loses focus while capturing, the * capture will be disabled automatically. * * While capturing is enabled, the current window will have the * `SDL_WINDOW_MOUSE_CAPTURE` flag set. * * Please note that SDL will attempt to "auto capture" the mouse while the * user is pressing a button; this is to try and make mouse behavior more * consistent between platforms, and deal with the common case of a user * dragging the mouse outside of the window. This means that if you are * calling SDL_CaptureMouse() only to deal with this situation, you do not * have to (although it is safe to do so). If this causes problems for your * app, you can disable auto capture by setting the * `SDL_HINT_MOUSE_AUTO_CAPTURE` hint to zero. * * \param enabled true to enable capturing, false to disable. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetGlobalMouseState */ extern SDL_DECLSPEC bool SDLCALL SDL_CaptureMouse(bool enabled); /** * Create a cursor using the specified bitmap data and mask (in MSB format). * * `mask` has to be in MSB (Most Significant Bit) format. * * The cursor width (`w`) must be a multiple of 8 bits. * * The cursor is created in black and white according to the following: * * - data=0, mask=1: white * - data=1, mask=1: black * - data=0, mask=0: transparent * - data=1, mask=0: inverted color if possible, black if not. * * Cursors created with this function must be freed with SDL_DestroyCursor(). * * If you want to have a color cursor, or create your cursor from an * SDL_Surface, you should use SDL_CreateColorCursor(). Alternately, you can * hide the cursor and draw your own as part of your game's rendering, but it * will be bound to the framerate. * * Also, SDL_CreateSystemCursor() is available, which provides several * readily-available system cursors to pick from. * * \param data the color value for each pixel of the cursor. * \param mask the mask value for each pixel of the cursor. * \param w the width of the cursor. * \param h the height of the cursor. * \param hot_x the x-axis offset from the left of the cursor image to the * mouse x position, in the range of 0 to `w` - 1. * \param hot_y the y-axis offset from the top of the cursor image to the * mouse y position, in the range of 0 to `h` - 1. * \returns a new cursor with the specified parameters on success or NULL on * failure; call SDL_GetError() for more information. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_CreateAnimatedCursor * \sa SDL_CreateColorCursor * \sa SDL_CreateSystemCursor * \sa SDL_DestroyCursor * \sa SDL_SetCursor */ extern SDL_DECLSPEC SDL_Cursor * SDLCALL SDL_CreateCursor(const Uint8 *data, const Uint8 *mask, int w, int h, int hot_x, int hot_y); /** * Create a color cursor. * * If this function is passed a surface with alternate representations added * with SDL_AddSurfaceAlternateImage(), the surface will be interpreted as the * content to be used for 100% display scale, and the alternate * representations will be used for high DPI situations if * SDL_HINT_MOUSE_DPI_SCALE_CURSORS is enabled. For example, if the original * surface is 32x32, then on a 2x macOS display or 200% display scale on * Windows, a 64x64 version of the image will be used, if available. If a * matching version of the image isn't available, the closest larger size * image will be downscaled to the appropriate size and be used instead, if * available. Otherwise, the closest smaller image will be upscaled and be * used instead. * * \param surface an SDL_Surface structure representing the cursor image. * \param hot_x the x position of the cursor hot spot. * \param hot_y the y position of the cursor hot spot. * \returns the new cursor on success or NULL on failure; call SDL_GetError() * for more information. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_AddSurfaceAlternateImage * \sa SDL_CreateAnimatedCursor * \sa SDL_CreateCursor * \sa SDL_CreateSystemCursor * \sa SDL_DestroyCursor * \sa SDL_SetCursor */ extern SDL_DECLSPEC SDL_Cursor * SDLCALL SDL_CreateColorCursor(SDL_Surface *surface, int hot_x, int hot_y); /** * Create an animated color cursor. * * Animated cursors are composed of a sequential array of frames, specified as * surfaces and durations in an array of SDL_CursorFrameInfo structs. The hot * spot coordinates are universal to all frames, and all frames must have the * same dimensions. * * Frame durations are specified in milliseconds. A duration of 0 implies an * infinite frame time, and the animation will stop on that frame. To create a * one-shot animation, set the duration of the last frame in the sequence to * 0. * * If this function is passed surfaces with alternate representations added * with SDL_AddSurfaceAlternateImage(), the surfaces will be interpreted as * the content to be used for 100% display scale, and the alternate * representations will be used for high DPI situations. For example, if the * original surfaces are 32x32, then on a 2x macOS display or 200% display * scale on Windows, a 64x64 version of the image will be used, if available. * If a matching version of the image isn't available, the closest larger size * image will be downscaled to the appropriate size and be used instead, if * available. Otherwise, the closest smaller image will be upscaled and be * used instead. * * If the underlying platform does not support animated cursors, this function * will fall back to creating a static color cursor using the first frame in * the sequence. * * \param frames an array of cursor images composing the animation. * \param frame_count the number of frames in the sequence. * \param hot_x the x position of the cursor hot spot. * \param hot_y the y position of the cursor hot spot. * \returns the new cursor on success or NULL on failure; call SDL_GetError() * for more information. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.4.0. * * \sa SDL_AddSurfaceAlternateImage * \sa SDL_CreateCursor * \sa SDL_CreateColorCursor * \sa SDL_CreateSystemCursor * \sa SDL_DestroyCursor * \sa SDL_SetCursor */ extern SDL_DECLSPEC SDL_Cursor *SDLCALL SDL_CreateAnimatedCursor(SDL_CursorFrameInfo *frames, int frame_count, int hot_x, int hot_y); /** * Create a system cursor. * * \param id an SDL_SystemCursor enum value. * \returns a cursor on success or NULL on failure; call SDL_GetError() for * more information. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_DestroyCursor */ extern SDL_DECLSPEC SDL_Cursor * SDLCALL SDL_CreateSystemCursor(SDL_SystemCursor id); /** * Set the active cursor. * * This function sets the currently active cursor to the specified one. If the * cursor is currently visible, the change will be immediately represented on * the display. SDL_SetCursor(NULL) can be used to force cursor redraw, if * this is desired for any reason. * * \param cursor a cursor to make active. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetCursor */ extern SDL_DECLSPEC bool SDLCALL SDL_SetCursor(SDL_Cursor *cursor); /** * Get the active cursor. * * This function returns a pointer to the current cursor which is owned by the * library. It is not necessary to free the cursor with SDL_DestroyCursor(). * * \returns the active cursor or NULL if there is no mouse. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_SetCursor */ extern SDL_DECLSPEC SDL_Cursor * SDLCALL SDL_GetCursor(void); /** * Get the default cursor. * * You do not have to call SDL_DestroyCursor() on the return value, but it is * safe to do so. * * \returns the default cursor on success or NULL on failure; call * SDL_GetError() for more information. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC SDL_Cursor * SDLCALL SDL_GetDefaultCursor(void); /** * Free a previously-created cursor. * * Use this function to free cursor resources created with SDL_CreateCursor(), * SDL_CreateColorCursor() or SDL_CreateSystemCursor(). * * \param cursor the cursor to free. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_CreateAnimatedCursor * \sa SDL_CreateColorCursor * \sa SDL_CreateCursor * \sa SDL_CreateSystemCursor */ extern SDL_DECLSPEC void SDLCALL SDL_DestroyCursor(SDL_Cursor *cursor); /** * Show the cursor. * * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_CursorVisible * \sa SDL_HideCursor */ extern SDL_DECLSPEC bool SDLCALL SDL_ShowCursor(void); /** * Hide the cursor. * * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_CursorVisible * \sa SDL_ShowCursor */ extern SDL_DECLSPEC bool SDLCALL SDL_HideCursor(void); /** * Return whether the cursor is currently being shown. * * \returns `true` if the cursor is being shown, or `false` if the cursor is * hidden. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_HideCursor * \sa SDL_ShowCursor */ extern SDL_DECLSPEC bool SDLCALL SDL_CursorVisible(void); /* Ends C function definitions when using C++ */ #ifdef __cplusplus } #endif #include #endif /* SDL_mouse_h_ */ ================================================ FILE: deps/include/SDL3/SDL_mutex.h ================================================ /* Simple DirectMedia Layer Copyright (C) 1997-2026 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ #ifndef SDL_mutex_h_ #define SDL_mutex_h_ /** * # CategoryMutex * * SDL offers several thread synchronization primitives. This document can't * cover the complicated topic of thread safety, but reading up on what each * of these primitives are, why they are useful, and how to correctly use them * is vital to writing correct and safe multithreaded programs. * * - Mutexes: SDL_CreateMutex() * - Read/Write locks: SDL_CreateRWLock() * - Semaphores: SDL_CreateSemaphore() * - Condition variables: SDL_CreateCondition() * * SDL also offers a datatype, SDL_InitState, which can be used to make sure * only one thread initializes/deinitializes some resource that several * threads might try to use for the first time simultaneously. */ #include #include #include #include #ifdef SDL_WIKI_DOCUMENTATION_SECTION /** * Enable thread safety attributes, only with clang. * * The attributes can be safely erased when compiling with other compilers. * * To enable analysis, set these environment variables before running cmake: * * ```bash * export CC=clang * export CFLAGS="-DSDL_THREAD_SAFETY_ANALYSIS -Wthread-safety" * ``` */ #define SDL_THREAD_ANNOTATION_ATTRIBUTE__(x) __attribute__((x)) #elif defined(SDL_THREAD_SAFETY_ANALYSIS) && defined(__clang__) && (!defined(SWIG)) #define SDL_THREAD_ANNOTATION_ATTRIBUTE__(x) __attribute__((x)) #else #define SDL_THREAD_ANNOTATION_ATTRIBUTE__(x) /* no-op */ #endif /** * Wrapper around Clang thread safety analysis annotations. * * Please see https://clang.llvm.org/docs/ThreadSafetyAnalysis.html#mutex-h * * \since This macro is available since SDL 3.2.0. */ #define SDL_CAPABILITY(x) \ SDL_THREAD_ANNOTATION_ATTRIBUTE__(capability(x)) /** * Wrapper around Clang thread safety analysis annotations. * * Please see https://clang.llvm.org/docs/ThreadSafetyAnalysis.html#mutex-h * * \since This macro is available since SDL 3.2.0. */ #define SDL_SCOPED_CAPABILITY \ SDL_THREAD_ANNOTATION_ATTRIBUTE__(scoped_lockable) /** * Wrapper around Clang thread safety analysis annotations. * * Please see https://clang.llvm.org/docs/ThreadSafetyAnalysis.html#mutex-h * * \since This macro is available since SDL 3.2.0. */ #define SDL_GUARDED_BY(x) \ SDL_THREAD_ANNOTATION_ATTRIBUTE__(guarded_by(x)) /** * Wrapper around Clang thread safety analysis annotations. * * Please see https://clang.llvm.org/docs/ThreadSafetyAnalysis.html#mutex-h * * \since This macro is available since SDL 3.2.0. */ #define SDL_PT_GUARDED_BY(x) \ SDL_THREAD_ANNOTATION_ATTRIBUTE__(pt_guarded_by(x)) /** * Wrapper around Clang thread safety analysis annotations. * * Please see https://clang.llvm.org/docs/ThreadSafetyAnalysis.html#mutex-h * * \since This macro is available since SDL 3.2.0. */ #define SDL_ACQUIRED_BEFORE(x) \ SDL_THREAD_ANNOTATION_ATTRIBUTE__(acquired_before(x)) /** * Wrapper around Clang thread safety analysis annotations. * * Please see https://clang.llvm.org/docs/ThreadSafetyAnalysis.html#mutex-h * * \since This macro is available since SDL 3.2.0. */ #define SDL_ACQUIRED_AFTER(x) \ SDL_THREAD_ANNOTATION_ATTRIBUTE__(acquired_after(x)) /** * Wrapper around Clang thread safety analysis annotations. * * Please see https://clang.llvm.org/docs/ThreadSafetyAnalysis.html#mutex-h * * \since This macro is available since SDL 3.2.0. */ #define SDL_REQUIRES(x) \ SDL_THREAD_ANNOTATION_ATTRIBUTE__(requires_capability(x)) /** * Wrapper around Clang thread safety analysis annotations. * * Please see https://clang.llvm.org/docs/ThreadSafetyAnalysis.html#mutex-h * * \since This macro is available since SDL 3.2.0. */ #define SDL_REQUIRES_SHARED(x) \ SDL_THREAD_ANNOTATION_ATTRIBUTE__(requires_shared_capability(x)) /** * Wrapper around Clang thread safety analysis annotations. * * Please see https://clang.llvm.org/docs/ThreadSafetyAnalysis.html#mutex-h * * \since This macro is available since SDL 3.2.0. */ #define SDL_ACQUIRE(x) \ SDL_THREAD_ANNOTATION_ATTRIBUTE__(acquire_capability(x)) /** * Wrapper around Clang thread safety analysis annotations. * * Please see https://clang.llvm.org/docs/ThreadSafetyAnalysis.html#mutex-h * * \since This macro is available since SDL 3.2.0. */ #define SDL_ACQUIRE_SHARED(x) \ SDL_THREAD_ANNOTATION_ATTRIBUTE__(acquire_shared_capability(x)) /** * Wrapper around Clang thread safety analysis annotations. * * Please see https://clang.llvm.org/docs/ThreadSafetyAnalysis.html#mutex-h * * \since This macro is available since SDL 3.2.0. */ #define SDL_RELEASE(x) \ SDL_THREAD_ANNOTATION_ATTRIBUTE__(release_capability(x)) /** * Wrapper around Clang thread safety analysis annotations. * * Please see https://clang.llvm.org/docs/ThreadSafetyAnalysis.html#mutex-h * * \since This macro is available since SDL 3.2.0. */ #define SDL_RELEASE_SHARED(x) \ SDL_THREAD_ANNOTATION_ATTRIBUTE__(release_shared_capability(x)) /** * Wrapper around Clang thread safety analysis annotations. * * Please see https://clang.llvm.org/docs/ThreadSafetyAnalysis.html#mutex-h * * \since This macro is available since SDL 3.2.0. */ #define SDL_RELEASE_GENERIC(x) \ SDL_THREAD_ANNOTATION_ATTRIBUTE__(release_generic_capability(x)) /** * Wrapper around Clang thread safety analysis annotations. * * Please see https://clang.llvm.org/docs/ThreadSafetyAnalysis.html#mutex-h * * \since This macro is available since SDL 3.2.0. */ #define SDL_TRY_ACQUIRE(x, y) \ SDL_THREAD_ANNOTATION_ATTRIBUTE__(try_acquire_capability(x, y)) /** * Wrapper around Clang thread safety analysis annotations. * * Please see https://clang.llvm.org/docs/ThreadSafetyAnalysis.html#mutex-h * * \since This macro is available since SDL 3.2.0. */ #define SDL_TRY_ACQUIRE_SHARED(x, y) \ SDL_THREAD_ANNOTATION_ATTRIBUTE__(try_acquire_shared_capability(x, y)) /** * Wrapper around Clang thread safety analysis annotations. * * Please see https://clang.llvm.org/docs/ThreadSafetyAnalysis.html#mutex-h * * \since This macro is available since SDL 3.2.0. */ #define SDL_EXCLUDES(x) \ SDL_THREAD_ANNOTATION_ATTRIBUTE__(locks_excluded(x)) /** * Wrapper around Clang thread safety analysis annotations. * * Please see https://clang.llvm.org/docs/ThreadSafetyAnalysis.html#mutex-h * * \since This macro is available since SDL 3.2.0. */ #define SDL_ASSERT_CAPABILITY(x) \ SDL_THREAD_ANNOTATION_ATTRIBUTE__(assert_capability(x)) /** * Wrapper around Clang thread safety analysis annotations. * * Please see https://clang.llvm.org/docs/ThreadSafetyAnalysis.html#mutex-h * * \since This macro is available since SDL 3.2.0. */ #define SDL_ASSERT_SHARED_CAPABILITY(x) \ SDL_THREAD_ANNOTATION_ATTRIBUTE__(assert_shared_capability(x)) /** * Wrapper around Clang thread safety analysis annotations. * * Please see https://clang.llvm.org/docs/ThreadSafetyAnalysis.html#mutex-h * * \since This macro is available since SDL 3.2.0. */ #define SDL_RETURN_CAPABILITY(x) \ SDL_THREAD_ANNOTATION_ATTRIBUTE__(lock_returned(x)) /** * Wrapper around Clang thread safety analysis annotations. * * Please see https://clang.llvm.org/docs/ThreadSafetyAnalysis.html#mutex-h * * \since This macro is available since SDL 3.2.0. */ #define SDL_NO_THREAD_SAFETY_ANALYSIS \ SDL_THREAD_ANNOTATION_ATTRIBUTE__(no_thread_safety_analysis) /******************************************************************************/ #include /* Set up for C function definitions, even when using C++ */ #ifdef __cplusplus extern "C" { #endif /** * \name Mutex functions */ /* @{ */ /** * A means to serialize access to a resource between threads. * * Mutexes (short for "mutual exclusion") are a synchronization primitive that * allows exactly one thread to proceed at a time. * * Wikipedia has a thorough explanation of the concept: * * https://en.wikipedia.org/wiki/Mutex * * \since This struct is available since SDL 3.2.0. */ typedef struct SDL_Mutex SDL_Mutex; /** * Create a new mutex. * * All newly-created mutexes begin in the _unlocked_ state. * * Calls to SDL_LockMutex() will not return while the mutex is locked by * another thread. See SDL_TryLockMutex() to attempt to lock without blocking. * * SDL mutexes are reentrant. * * \returns the initialized and unlocked mutex or NULL on failure; call * SDL_GetError() for more information. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_DestroyMutex * \sa SDL_LockMutex * \sa SDL_TryLockMutex * \sa SDL_UnlockMutex */ extern SDL_DECLSPEC SDL_Mutex * SDLCALL SDL_CreateMutex(void); /** * Lock the mutex. * * This will block until the mutex is available, which is to say it is in the * unlocked state and the OS has chosen the caller as the next thread to lock * it. Of all threads waiting to lock the mutex, only one may do so at a time. * * It is legal for the owning thread to lock an already-locked mutex. It must * unlock it the same number of times before it is actually made available for * other threads in the system (this is known as a "recursive mutex"). * * This function does not fail; if mutex is NULL, it will return immediately * having locked nothing. If the mutex is valid, this function will always * block until it can lock the mutex, and return with it locked. * * \param mutex the mutex to lock. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_TryLockMutex * \sa SDL_UnlockMutex */ extern SDL_DECLSPEC void SDLCALL SDL_LockMutex(SDL_Mutex *mutex) SDL_ACQUIRE(mutex); /** * Try to lock a mutex without blocking. * * This works just like SDL_LockMutex(), but if the mutex is not available, * this function returns false immediately. * * This technique is useful if you need exclusive access to a resource but * don't want to wait for it, and will return to it to try again later. * * This function returns true if passed a NULL mutex. * * \param mutex the mutex to try to lock. * \returns true on success, false if the mutex would block. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_LockMutex * \sa SDL_UnlockMutex */ extern SDL_DECLSPEC bool SDLCALL SDL_TryLockMutex(SDL_Mutex *mutex) SDL_TRY_ACQUIRE(true, mutex); /** * Unlock the mutex. * * It is legal for the owning thread to lock an already-locked mutex. It must * unlock it the same number of times before it is actually made available for * other threads in the system (this is known as a "recursive mutex"). * * It is illegal to unlock a mutex that has not been locked by the current * thread, and doing so results in undefined behavior. * * \param mutex the mutex to unlock. * * \threadsafety This call must be paired with a previous locking call on the * same thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_LockMutex * \sa SDL_TryLockMutex */ extern SDL_DECLSPEC void SDLCALL SDL_UnlockMutex(SDL_Mutex *mutex) SDL_RELEASE(mutex); /** * Destroy a mutex created with SDL_CreateMutex(). * * This function must be called on any mutex that is no longer needed. Failure * to destroy a mutex will result in a system memory or resource leak. While * it is safe to destroy a mutex that is _unlocked_, it is not safe to attempt * to destroy a locked mutex, and may result in undefined behavior depending * on the platform. * * \param mutex the mutex to destroy. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_CreateMutex */ extern SDL_DECLSPEC void SDLCALL SDL_DestroyMutex(SDL_Mutex *mutex); /* @} *//* Mutex functions */ /** * \name Read/write lock functions */ /* @{ */ /** * A mutex that allows read-only threads to run in parallel. * * A rwlock is roughly the same concept as SDL_Mutex, but allows threads that * request read-only access to all hold the lock at the same time. If a thread * requests write access, it will block until all read-only threads have * released the lock, and no one else can hold the thread (for reading or * writing) at the same time as the writing thread. * * This can be more efficient in cases where several threads need to access * data frequently, but changes to that data are rare. * * There are other rules that apply to rwlocks that don't apply to mutexes, * about how threads are scheduled and when they can be recursively locked. * These are documented in the other rwlock functions. * * \since This struct is available since SDL 3.2.0. */ typedef struct SDL_RWLock SDL_RWLock; /** * Create a new read/write lock. * * A read/write lock is useful for situations where you have multiple threads * trying to access a resource that is rarely updated. All threads requesting * a read-only lock will be allowed to run in parallel; if a thread requests a * write lock, it will be provided exclusive access. This makes it safe for * multiple threads to use a resource at the same time if they promise not to * change it, and when it has to be changed, the rwlock will serve as a * gateway to make sure those changes can be made safely. * * In the right situation, a rwlock can be more efficient than a mutex, which * only lets a single thread proceed at a time, even if it won't be modifying * the data. * * All newly-created read/write locks begin in the _unlocked_ state. * * Calls to SDL_LockRWLockForReading() and SDL_LockRWLockForWriting will not * return while the rwlock is locked _for writing_ by another thread. See * SDL_TryLockRWLockForReading() and SDL_TryLockRWLockForWriting() to attempt * to lock without blocking. * * SDL read/write locks are only recursive for read-only locks! They are not * guaranteed to be fair, or provide access in a FIFO manner! They are not * guaranteed to favor writers. You may not lock a rwlock for both read-only * and write access at the same time from the same thread (so you can't * promote your read-only lock to a write lock without unlocking first). * * \returns the initialized and unlocked read/write lock or NULL on failure; * call SDL_GetError() for more information. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_DestroyRWLock * \sa SDL_LockRWLockForReading * \sa SDL_LockRWLockForWriting * \sa SDL_TryLockRWLockForReading * \sa SDL_TryLockRWLockForWriting * \sa SDL_UnlockRWLock */ extern SDL_DECLSPEC SDL_RWLock * SDLCALL SDL_CreateRWLock(void); /** * Lock the read/write lock for _read only_ operations. * * This will block until the rwlock is available, which is to say it is not * locked for writing by any other thread. Of all threads waiting to lock the * rwlock, all may do so at the same time as long as they are requesting * read-only access; if a thread wants to lock for writing, only one may do so * at a time, and no other threads, read-only or not, may hold the lock at the * same time. * * It is legal for the owning thread to lock an already-locked rwlock for * reading. It must unlock it the same number of times before it is actually * made available for other threads in the system (this is known as a * "recursive rwlock"). * * Note that locking for writing is not recursive (this is only available to * read-only locks). * * It is illegal to request a read-only lock from a thread that already holds * the write lock. Doing so results in undefined behavior. Unlock the write * lock before requesting a read-only lock. (But, of course, if you have the * write lock, you don't need further locks to read in any case.) * * This function does not fail; if rwlock is NULL, it will return immediately * having locked nothing. If the rwlock is valid, this function will always * block until it can lock the mutex, and return with it locked. * * \param rwlock the read/write lock to lock. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_LockRWLockForWriting * \sa SDL_TryLockRWLockForReading * \sa SDL_UnlockRWLock */ extern SDL_DECLSPEC void SDLCALL SDL_LockRWLockForReading(SDL_RWLock *rwlock) SDL_ACQUIRE_SHARED(rwlock); /** * Lock the read/write lock for _write_ operations. * * This will block until the rwlock is available, which is to say it is not * locked for reading or writing by any other thread. Only one thread may hold * the lock when it requests write access; all other threads, whether they * also want to write or only want read-only access, must wait until the * writer thread has released the lock. * * It is illegal for the owning thread to lock an already-locked rwlock for * writing (read-only may be locked recursively, writing can not). Doing so * results in undefined behavior. * * It is illegal to request a write lock from a thread that already holds a * read-only lock. Doing so results in undefined behavior. Unlock the * read-only lock before requesting a write lock. * * This function does not fail; if rwlock is NULL, it will return immediately * having locked nothing. If the rwlock is valid, this function will always * block until it can lock the mutex, and return with it locked. * * \param rwlock the read/write lock to lock. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_LockRWLockForReading * \sa SDL_TryLockRWLockForWriting * \sa SDL_UnlockRWLock */ extern SDL_DECLSPEC void SDLCALL SDL_LockRWLockForWriting(SDL_RWLock *rwlock) SDL_ACQUIRE(rwlock); /** * Try to lock a read/write lock _for reading_ without blocking. * * This works just like SDL_LockRWLockForReading(), but if the rwlock is not * available, then this function returns false immediately. * * This technique is useful if you need access to a resource but don't want to * wait for it, and will return to it to try again later. * * Trying to lock for read-only access can succeed if other threads are * holding read-only locks, as this won't prevent access. * * This function returns true if passed a NULL rwlock. * * \param rwlock the rwlock to try to lock. * \returns true on success, false if the lock would block. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_LockRWLockForReading * \sa SDL_TryLockRWLockForWriting * \sa SDL_UnlockRWLock */ extern SDL_DECLSPEC bool SDLCALL SDL_TryLockRWLockForReading(SDL_RWLock *rwlock) SDL_TRY_ACQUIRE_SHARED(true, rwlock); /** * Try to lock a read/write lock _for writing_ without blocking. * * This works just like SDL_LockRWLockForWriting(), but if the rwlock is not * available, then this function returns false immediately. * * This technique is useful if you need exclusive access to a resource but * don't want to wait for it, and will return to it to try again later. * * It is illegal for the owning thread to lock an already-locked rwlock for * writing (read-only may be locked recursively, writing can not). Doing so * results in undefined behavior. * * It is illegal to request a write lock from a thread that already holds a * read-only lock. Doing so results in undefined behavior. Unlock the * read-only lock before requesting a write lock. * * This function returns true if passed a NULL rwlock. * * \param rwlock the rwlock to try to lock. * \returns true on success, false if the lock would block. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_LockRWLockForWriting * \sa SDL_TryLockRWLockForReading * \sa SDL_UnlockRWLock */ extern SDL_DECLSPEC bool SDLCALL SDL_TryLockRWLockForWriting(SDL_RWLock *rwlock) SDL_TRY_ACQUIRE(true, rwlock); /** * Unlock the read/write lock. * * Use this function to unlock the rwlock, whether it was locked for read-only * or write operations. * * It is legal for the owning thread to lock an already-locked read-only lock. * It must unlock it the same number of times before it is actually made * available for other threads in the system (this is known as a "recursive * rwlock"). * * It is illegal to unlock a rwlock that has not been locked by the current * thread, and doing so results in undefined behavior. * * \param rwlock the rwlock to unlock. * * \threadsafety This call must be paired with a previous locking call on the * same thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_LockRWLockForReading * \sa SDL_LockRWLockForWriting * \sa SDL_TryLockRWLockForReading * \sa SDL_TryLockRWLockForWriting */ extern SDL_DECLSPEC void SDLCALL SDL_UnlockRWLock(SDL_RWLock *rwlock) SDL_RELEASE_GENERIC(rwlock); /** * Destroy a read/write lock created with SDL_CreateRWLock(). * * This function must be called on any read/write lock that is no longer * needed. Failure to destroy a rwlock will result in a system memory or * resource leak. While it is safe to destroy a rwlock that is _unlocked_, it * is not safe to attempt to destroy a locked rwlock, and may result in * undefined behavior depending on the platform. * * \param rwlock the rwlock to destroy. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_CreateRWLock */ extern SDL_DECLSPEC void SDLCALL SDL_DestroyRWLock(SDL_RWLock *rwlock); /* @} *//* Read/write lock functions */ /** * \name Semaphore functions */ /* @{ */ /** * A means to manage access to a resource, by count, between threads. * * Semaphores (specifically, "counting semaphores"), let X number of threads * request access at the same time, each thread granted access decrementing a * counter. When the counter reaches zero, future requests block until a prior * thread releases their request, incrementing the counter again. * * Wikipedia has a thorough explanation of the concept: * * https://en.wikipedia.org/wiki/Semaphore_(programming) * * \since This struct is available since SDL 3.2.0. */ typedef struct SDL_Semaphore SDL_Semaphore; /** * Create a semaphore. * * This function creates a new semaphore and initializes it with the value * `initial_value`. Each wait operation on the semaphore will atomically * decrement the semaphore value and potentially block if the semaphore value * is 0. Each post operation will atomically increment the semaphore value and * wake waiting threads and allow them to retry the wait operation. * * \param initial_value the starting value of the semaphore. * \returns a new semaphore or NULL on failure; call SDL_GetError() for more * information. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_DestroySemaphore * \sa SDL_SignalSemaphore * \sa SDL_TryWaitSemaphore * \sa SDL_GetSemaphoreValue * \sa SDL_WaitSemaphore * \sa SDL_WaitSemaphoreTimeout */ extern SDL_DECLSPEC SDL_Semaphore * SDLCALL SDL_CreateSemaphore(Uint32 initial_value); /** * Destroy a semaphore. * * It is not safe to destroy a semaphore if there are threads currently * waiting on it. * * \param sem the semaphore to destroy. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_CreateSemaphore */ extern SDL_DECLSPEC void SDLCALL SDL_DestroySemaphore(SDL_Semaphore *sem); /** * Wait until a semaphore has a positive value and then decrements it. * * This function suspends the calling thread until the semaphore pointed to by * `sem` has a positive value, and then atomically decrement the semaphore * value. * * This function is the equivalent of calling SDL_WaitSemaphoreTimeout() with * a time length of -1. * * \param sem the semaphore wait on. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_SignalSemaphore * \sa SDL_TryWaitSemaphore * \sa SDL_WaitSemaphoreTimeout */ extern SDL_DECLSPEC void SDLCALL SDL_WaitSemaphore(SDL_Semaphore *sem); /** * See if a semaphore has a positive value and decrement it if it does. * * This function checks to see if the semaphore pointed to by `sem` has a * positive value and atomically decrements the semaphore value if it does. If * the semaphore doesn't have a positive value, the function immediately * returns false. * * \param sem the semaphore to wait on. * \returns true if the wait succeeds, false if the wait would block. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_SignalSemaphore * \sa SDL_WaitSemaphore * \sa SDL_WaitSemaphoreTimeout */ extern SDL_DECLSPEC bool SDLCALL SDL_TryWaitSemaphore(SDL_Semaphore *sem); /** * Wait until a semaphore has a positive value and then decrements it. * * This function suspends the calling thread until either the semaphore * pointed to by `sem` has a positive value or the specified time has elapsed. * If the call is successful it will atomically decrement the semaphore value. * * \param sem the semaphore to wait on. * \param timeoutMS the length of the timeout, in milliseconds, or -1 to wait * indefinitely. * \returns true if the wait succeeds or false if the wait times out. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_SignalSemaphore * \sa SDL_TryWaitSemaphore * \sa SDL_WaitSemaphore */ extern SDL_DECLSPEC bool SDLCALL SDL_WaitSemaphoreTimeout(SDL_Semaphore *sem, Sint32 timeoutMS); /** * Atomically increment a semaphore's value and wake waiting threads. * * \param sem the semaphore to increment. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_TryWaitSemaphore * \sa SDL_WaitSemaphore * \sa SDL_WaitSemaphoreTimeout */ extern SDL_DECLSPEC void SDLCALL SDL_SignalSemaphore(SDL_Semaphore *sem); /** * Get the current value of a semaphore. * * \param sem the semaphore to query. * \returns the current value of the semaphore. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC Uint32 SDLCALL SDL_GetSemaphoreValue(SDL_Semaphore *sem); /* @} *//* Semaphore functions */ /** * \name Condition variable functions */ /* @{ */ /** * A means to block multiple threads until a condition is satisfied. * * Condition variables, paired with an SDL_Mutex, let an app halt multiple * threads until a condition has occurred, at which time the app can release * one or all waiting threads. * * Wikipedia has a thorough explanation of the concept: * * https://en.wikipedia.org/wiki/Condition_variable * * \since This struct is available since SDL 3.2.0. */ typedef struct SDL_Condition SDL_Condition; /** * Create a condition variable. * * \returns a new condition variable or NULL on failure; call SDL_GetError() * for more information. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_BroadcastCondition * \sa SDL_SignalCondition * \sa SDL_WaitCondition * \sa SDL_WaitConditionTimeout * \sa SDL_DestroyCondition */ extern SDL_DECLSPEC SDL_Condition * SDLCALL SDL_CreateCondition(void); /** * Destroy a condition variable. * * \param cond the condition variable to destroy. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_CreateCondition */ extern SDL_DECLSPEC void SDLCALL SDL_DestroyCondition(SDL_Condition *cond); /** * Restart one of the threads that are waiting on the condition variable. * * \param cond the condition variable to signal. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_BroadcastCondition * \sa SDL_WaitCondition * \sa SDL_WaitConditionTimeout */ extern SDL_DECLSPEC void SDLCALL SDL_SignalCondition(SDL_Condition *cond); /** * Restart all threads that are waiting on the condition variable. * * \param cond the condition variable to signal. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_SignalCondition * \sa SDL_WaitCondition * \sa SDL_WaitConditionTimeout */ extern SDL_DECLSPEC void SDLCALL SDL_BroadcastCondition(SDL_Condition *cond); /** * Wait until a condition variable is signaled. * * This function unlocks the specified `mutex` and waits for another thread to * call SDL_SignalCondition() or SDL_BroadcastCondition() on the condition * variable `cond`. Once the condition variable is signaled, the mutex is * re-locked and the function returns. * * The mutex must be locked before calling this function. Locking the mutex * recursively (more than once) is not supported and leads to undefined * behavior. * * This function is the equivalent of calling SDL_WaitConditionTimeout() with * a time length of -1. * * \param cond the condition variable to wait on. * \param mutex the mutex used to coordinate thread access. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_BroadcastCondition * \sa SDL_SignalCondition * \sa SDL_WaitConditionTimeout */ extern SDL_DECLSPEC void SDLCALL SDL_WaitCondition(SDL_Condition *cond, SDL_Mutex *mutex); /** * Wait until a condition variable is signaled or a certain time has passed. * * This function unlocks the specified `mutex` and waits for another thread to * call SDL_SignalCondition() or SDL_BroadcastCondition() on the condition * variable `cond`, or for the specified time to elapse. Once the condition * variable is signaled or the time elapsed, the mutex is re-locked and the * function returns. * * The mutex must be locked before calling this function. Locking the mutex * recursively (more than once) is not supported and leads to undefined * behavior. * * \param cond the condition variable to wait on. * \param mutex the mutex used to coordinate thread access. * \param timeoutMS the maximum time to wait, in milliseconds, or -1 to wait * indefinitely. * \returns true if the condition variable is signaled, false if the condition * is not signaled in the allotted time. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_BroadcastCondition * \sa SDL_SignalCondition * \sa SDL_WaitCondition */ extern SDL_DECLSPEC bool SDLCALL SDL_WaitConditionTimeout(SDL_Condition *cond, SDL_Mutex *mutex, Sint32 timeoutMS); /* @} *//* Condition variable functions */ /** * \name Thread-safe initialization state functions */ /* @{ */ /** * The current status of an SDL_InitState structure. * * \since This enum is available since SDL 3.2.0. */ typedef enum SDL_InitStatus { SDL_INIT_STATUS_UNINITIALIZED, SDL_INIT_STATUS_INITIALIZING, SDL_INIT_STATUS_INITIALIZED, SDL_INIT_STATUS_UNINITIALIZING } SDL_InitStatus; /** * A structure used for thread-safe initialization and shutdown. * * Here is an example of using this: * * ```c * static SDL_InitState init; * * bool InitSystem(void) * { * if (!SDL_ShouldInit(&init)) { * // The system is initialized * return true; * } * * // At this point, you should not leave this function without calling SDL_SetInitialized() * * bool initialized = DoInitTasks(); * SDL_SetInitialized(&init, initialized); * return initialized; * } * * bool UseSubsystem(void) * { * if (SDL_ShouldInit(&init)) { * // Error, the subsystem isn't initialized * SDL_SetInitialized(&init, false); * return false; * } * * // Do work using the initialized subsystem * * return true; * } * * void QuitSystem(void) * { * if (!SDL_ShouldQuit(&init)) { * // The system is not initialized * return; * } * * // At this point, you should not leave this function without calling SDL_SetInitialized() * * DoQuitTasks(); * SDL_SetInitialized(&init, false); * } * ``` * * Note that this doesn't protect any resources created during initialization, * or guarantee that nobody is using those resources during cleanup. You * should use other mechanisms to protect those, if that's a concern for your * code. * * \since This struct is available since SDL 3.2.0. */ typedef struct SDL_InitState { SDL_AtomicInt status; SDL_ThreadID thread; void *reserved; } SDL_InitState; /** * Return whether initialization should be done. * * This function checks the passed in state and if initialization should be * done, sets the status to `SDL_INIT_STATUS_INITIALIZING` and returns true. * If another thread is already modifying this state, it will wait until * that's done before returning. * * If this function returns true, the calling code must call * SDL_SetInitialized() to complete the initialization. * * \param state the initialization state to check. * \returns true if initialization needs to be done, false otherwise. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_SetInitialized * \sa SDL_ShouldQuit */ extern SDL_DECLSPEC bool SDLCALL SDL_ShouldInit(SDL_InitState *state); /** * Return whether cleanup should be done. * * This function checks the passed in state and if cleanup should be done, * sets the status to `SDL_INIT_STATUS_UNINITIALIZING` and returns true. * * If this function returns true, the calling code must call * SDL_SetInitialized() to complete the cleanup. * * \param state the initialization state to check. * \returns true if cleanup needs to be done, false otherwise. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_SetInitialized * \sa SDL_ShouldInit */ extern SDL_DECLSPEC bool SDLCALL SDL_ShouldQuit(SDL_InitState *state); /** * Finish an initialization state transition. * * This function sets the status of the passed in state to * `SDL_INIT_STATUS_INITIALIZED` or `SDL_INIT_STATUS_UNINITIALIZED` and allows * any threads waiting for the status to proceed. * * \param state the initialization state to check. * \param initialized the new initialization state. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_ShouldInit * \sa SDL_ShouldQuit */ extern SDL_DECLSPEC void SDLCALL SDL_SetInitialized(SDL_InitState *state, bool initialized); /* @} *//* Thread-safe initialization state functions */ /* Ends C function definitions when using C++ */ #ifdef __cplusplus } #endif #include #endif /* SDL_mutex_h_ */ ================================================ FILE: deps/include/SDL3/SDL_oldnames.h ================================================ /* Simple DirectMedia Layer Copyright (C) 1997-2026 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ /* * Definitions to ease transition from SDL2 code */ #ifndef SDL_oldnames_h_ #define SDL_oldnames_h_ #include /* The new function names are recommended, but if you want to have the * old names available while you are in the process of migrating code * to SDL3, you can define `SDL_ENABLE_OLD_NAMES` in your project. * * You can use https://github.com/libsdl-org/SDL/blob/main/build-scripts/rename_symbols.py to mass rename the symbols defined here in your codebase: * rename_symbols.py --all-symbols source_code_path */ #ifdef SDL_ENABLE_OLD_NAMES /* ##SDL_atomic.h */ #define SDL_AtomicAdd SDL_AddAtomicInt #define SDL_AtomicCAS SDL_CompareAndSwapAtomicInt #define SDL_AtomicCASPtr SDL_CompareAndSwapAtomicPointer #define SDL_AtomicGet SDL_GetAtomicInt #define SDL_AtomicGetPtr SDL_GetAtomicPointer #define SDL_AtomicLock SDL_LockSpinlock #define SDL_AtomicSet SDL_SetAtomicInt #define SDL_AtomicSetPtr SDL_SetAtomicPointer #define SDL_AtomicTryLock SDL_TryLockSpinlock #define SDL_AtomicUnlock SDL_UnlockSpinlock #define SDL_atomic_t SDL_AtomicInt /* ##SDL_audio.h */ #define AUDIO_F32 SDL_AUDIO_F32LE #define AUDIO_F32LSB SDL_AUDIO_F32LE #define AUDIO_F32MSB SDL_AUDIO_F32BE #define AUDIO_F32SYS SDL_AUDIO_F32 #define AUDIO_S16 SDL_AUDIO_S16LE #define AUDIO_S16LSB SDL_AUDIO_S16LE #define AUDIO_S16MSB SDL_AUDIO_S16BE #define AUDIO_S16SYS SDL_AUDIO_S16 #define AUDIO_S32 SDL_AUDIO_S32LE #define AUDIO_S32LSB SDL_AUDIO_S32LE #define AUDIO_S32MSB SDL_AUDIO_S32BE #define AUDIO_S32SYS SDL_AUDIO_S32 #define AUDIO_S8 SDL_AUDIO_S8 #define AUDIO_U8 SDL_AUDIO_U8 #define SDL_AudioStreamAvailable SDL_GetAudioStreamAvailable #define SDL_AudioStreamClear SDL_ClearAudioStream #define SDL_AudioStreamFlush SDL_FlushAudioStream #define SDL_AudioStreamGet SDL_GetAudioStreamData #define SDL_AudioStreamPut SDL_PutAudioStreamData #define SDL_FreeAudioStream SDL_DestroyAudioStream #define SDL_FreeWAV SDL_free #define SDL_LoadWAV_RW SDL_LoadWAV_IO #define SDL_MixAudioFormat SDL_MixAudio #define SDL_NewAudioStream SDL_CreateAudioStream /* ##SDL_cpuinfo.h */ #define SDL_GetCPUCount SDL_GetNumLogicalCPUCores #define SDL_SIMDGetAlignment SDL_GetSIMDAlignment /* ##SDL_endian.h */ #define SDL_SwapBE16 SDL_Swap16BE #define SDL_SwapBE32 SDL_Swap32BE #define SDL_SwapBE64 SDL_Swap64BE #define SDL_SwapLE16 SDL_Swap16LE #define SDL_SwapLE32 SDL_Swap32LE #define SDL_SwapLE64 SDL_Swap64LE /* ##SDL_events.h */ #define SDL_APP_DIDENTERBACKGROUND SDL_EVENT_DID_ENTER_BACKGROUND #define SDL_APP_DIDENTERFOREGROUND SDL_EVENT_DID_ENTER_FOREGROUND #define SDL_APP_LOWMEMORY SDL_EVENT_LOW_MEMORY #define SDL_APP_TERMINATING SDL_EVENT_TERMINATING #define SDL_APP_WILLENTERBACKGROUND SDL_EVENT_WILL_ENTER_BACKGROUND #define SDL_APP_WILLENTERFOREGROUND SDL_EVENT_WILL_ENTER_FOREGROUND #define SDL_AUDIODEVICEADDED SDL_EVENT_AUDIO_DEVICE_ADDED #define SDL_AUDIODEVICEREMOVED SDL_EVENT_AUDIO_DEVICE_REMOVED #define SDL_CLIPBOARDUPDATE SDL_EVENT_CLIPBOARD_UPDATE #define SDL_CONTROLLERAXISMOTION SDL_EVENT_GAMEPAD_AXIS_MOTION #define SDL_CONTROLLERBUTTONDOWN SDL_EVENT_GAMEPAD_BUTTON_DOWN #define SDL_CONTROLLERBUTTONUP SDL_EVENT_GAMEPAD_BUTTON_UP #define SDL_CONTROLLERDEVICEADDED SDL_EVENT_GAMEPAD_ADDED #define SDL_CONTROLLERDEVICEREMAPPED SDL_EVENT_GAMEPAD_REMAPPED #define SDL_CONTROLLERDEVICEREMOVED SDL_EVENT_GAMEPAD_REMOVED #define SDL_CONTROLLERSENSORUPDATE SDL_EVENT_GAMEPAD_SENSOR_UPDATE #define SDL_CONTROLLERSTEAMHANDLEUPDATED SDL_EVENT_GAMEPAD_STEAM_HANDLE_UPDATED #define SDL_CONTROLLERTOUCHPADDOWN SDL_EVENT_GAMEPAD_TOUCHPAD_DOWN #define SDL_CONTROLLERTOUCHPADMOTION SDL_EVENT_GAMEPAD_TOUCHPAD_MOTION #define SDL_CONTROLLERTOUCHPADUP SDL_EVENT_GAMEPAD_TOUCHPAD_UP #define SDL_ControllerAxisEvent SDL_GamepadAxisEvent #define SDL_ControllerButtonEvent SDL_GamepadButtonEvent #define SDL_ControllerDeviceEvent SDL_GamepadDeviceEvent #define SDL_ControllerSensorEvent SDL_GamepadSensorEvent #define SDL_ControllerTouchpadEvent SDL_GamepadTouchpadEvent #define SDL_DISPLAYEVENT_CONNECTED SDL_EVENT_DISPLAY_ADDED #define SDL_DISPLAYEVENT_DISCONNECTED SDL_EVENT_DISPLAY_REMOVED #define SDL_DISPLAYEVENT_MOVED SDL_EVENT_DISPLAY_MOVED #define SDL_DISPLAYEVENT_ORIENTATION SDL_EVENT_DISPLAY_ORIENTATION #define SDL_DROPBEGIN SDL_EVENT_DROP_BEGIN #define SDL_DROPCOMPLETE SDL_EVENT_DROP_COMPLETE #define SDL_DROPFILE SDL_EVENT_DROP_FILE #define SDL_DROPTEXT SDL_EVENT_DROP_TEXT #define SDL_DelEventWatch SDL_RemoveEventWatch #define SDL_FINGERDOWN SDL_EVENT_FINGER_DOWN #define SDL_FINGERMOTION SDL_EVENT_FINGER_MOTION #define SDL_FINGERUP SDL_EVENT_FINGER_UP #define SDL_FIRSTEVENT SDL_EVENT_FIRST #define SDL_JOYAXISMOTION SDL_EVENT_JOYSTICK_AXIS_MOTION #define SDL_JOYBATTERYUPDATED SDL_EVENT_JOYSTICK_BATTERY_UPDATED #define SDL_JOYBUTTONDOWN SDL_EVENT_JOYSTICK_BUTTON_DOWN #define SDL_JOYBUTTONUP SDL_EVENT_JOYSTICK_BUTTON_UP #define SDL_JOYDEVICEADDED SDL_EVENT_JOYSTICK_ADDED #define SDL_JOYDEVICEREMOVED SDL_EVENT_JOYSTICK_REMOVED #define SDL_JOYBALLMOTION SDL_EVENT_JOYSTICK_BALL_MOTION #define SDL_JOYHATMOTION SDL_EVENT_JOYSTICK_HAT_MOTION #define SDL_KEYDOWN SDL_EVENT_KEY_DOWN #define SDL_KEYMAPCHANGED SDL_EVENT_KEYMAP_CHANGED #define SDL_KEYUP SDL_EVENT_KEY_UP #define SDL_LASTEVENT SDL_EVENT_LAST #define SDL_LOCALECHANGED SDL_EVENT_LOCALE_CHANGED #define SDL_MOUSEBUTTONDOWN SDL_EVENT_MOUSE_BUTTON_DOWN #define SDL_MOUSEBUTTONUP SDL_EVENT_MOUSE_BUTTON_UP #define SDL_MOUSEMOTION SDL_EVENT_MOUSE_MOTION #define SDL_MOUSEWHEEL SDL_EVENT_MOUSE_WHEEL #define SDL_POLLSENTINEL SDL_EVENT_POLL_SENTINEL #define SDL_QUIT SDL_EVENT_QUIT #define SDL_RENDER_DEVICE_RESET SDL_EVENT_RENDER_DEVICE_RESET #define SDL_RENDER_TARGETS_RESET SDL_EVENT_RENDER_TARGETS_RESET #define SDL_SENSORUPDATE SDL_EVENT_SENSOR_UPDATE #define SDL_TEXTEDITING SDL_EVENT_TEXT_EDITING #define SDL_TEXTEDITING_EXT SDL_EVENT_TEXT_EDITING_EXT #define SDL_TEXTINPUT SDL_EVENT_TEXT_INPUT #define SDL_USEREVENT SDL_EVENT_USER #define SDL_WINDOWEVENT_CLOSE SDL_EVENT_WINDOW_CLOSE_REQUESTED #define SDL_WINDOWEVENT_DISPLAY_CHANGED SDL_EVENT_WINDOW_DISPLAY_CHANGED #define SDL_WINDOWEVENT_ENTER SDL_EVENT_WINDOW_MOUSE_ENTER #define SDL_WINDOWEVENT_EXPOSED SDL_EVENT_WINDOW_EXPOSED #define SDL_WINDOWEVENT_FOCUS_GAINED SDL_EVENT_WINDOW_FOCUS_GAINED #define SDL_WINDOWEVENT_FOCUS_LOST SDL_EVENT_WINDOW_FOCUS_LOST #define SDL_WINDOWEVENT_HIDDEN SDL_EVENT_WINDOW_HIDDEN #define SDL_WINDOWEVENT_HIT_TEST SDL_EVENT_WINDOW_HIT_TEST #define SDL_WINDOWEVENT_ICCPROF_CHANGED SDL_EVENT_WINDOW_ICCPROF_CHANGED #define SDL_WINDOWEVENT_LEAVE SDL_EVENT_WINDOW_MOUSE_LEAVE #define SDL_WINDOWEVENT_MAXIMIZED SDL_EVENT_WINDOW_MAXIMIZED #define SDL_WINDOWEVENT_MINIMIZED SDL_EVENT_WINDOW_MINIMIZED #define SDL_WINDOWEVENT_MOVED SDL_EVENT_WINDOW_MOVED #define SDL_WINDOWEVENT_RESIZED SDL_EVENT_WINDOW_RESIZED #define SDL_WINDOWEVENT_RESTORED SDL_EVENT_WINDOW_RESTORED #define SDL_WINDOWEVENT_SHOWN SDL_EVENT_WINDOW_SHOWN #define SDL_WINDOWEVENT_SIZE_CHANGED SDL_EVENT_WINDOW_PIXEL_SIZE_CHANGED #define SDL_eventaction SDL_EventAction /* ##SDL_gamecontroller.h */ #define SDL_CONTROLLER_AXIS_INVALID SDL_GAMEPAD_AXIS_INVALID #define SDL_CONTROLLER_AXIS_LEFTX SDL_GAMEPAD_AXIS_LEFTX #define SDL_CONTROLLER_AXIS_LEFTY SDL_GAMEPAD_AXIS_LEFTY #define SDL_CONTROLLER_AXIS_MAX SDL_GAMEPAD_AXIS_COUNT #define SDL_CONTROLLER_AXIS_RIGHTX SDL_GAMEPAD_AXIS_RIGHTX #define SDL_CONTROLLER_AXIS_RIGHTY SDL_GAMEPAD_AXIS_RIGHTY #define SDL_CONTROLLER_AXIS_TRIGGERLEFT SDL_GAMEPAD_AXIS_LEFT_TRIGGER #define SDL_CONTROLLER_AXIS_TRIGGERRIGHT SDL_GAMEPAD_AXIS_RIGHT_TRIGGER #define SDL_CONTROLLER_BINDTYPE_AXIS SDL_GAMEPAD_BINDTYPE_AXIS #define SDL_CONTROLLER_BINDTYPE_BUTTON SDL_GAMEPAD_BINDTYPE_BUTTON #define SDL_CONTROLLER_BINDTYPE_HAT SDL_GAMEPAD_BINDTYPE_HAT #define SDL_CONTROLLER_BINDTYPE_NONE SDL_GAMEPAD_BINDTYPE_NONE #define SDL_CONTROLLER_BUTTON_A SDL_GAMEPAD_BUTTON_SOUTH #define SDL_CONTROLLER_BUTTON_B SDL_GAMEPAD_BUTTON_EAST #define SDL_CONTROLLER_BUTTON_BACK SDL_GAMEPAD_BUTTON_BACK #define SDL_CONTROLLER_BUTTON_DPAD_DOWN SDL_GAMEPAD_BUTTON_DPAD_DOWN #define SDL_CONTROLLER_BUTTON_DPAD_LEFT SDL_GAMEPAD_BUTTON_DPAD_LEFT #define SDL_CONTROLLER_BUTTON_DPAD_RIGHT SDL_GAMEPAD_BUTTON_DPAD_RIGHT #define SDL_CONTROLLER_BUTTON_DPAD_UP SDL_GAMEPAD_BUTTON_DPAD_UP #define SDL_CONTROLLER_BUTTON_GUIDE SDL_GAMEPAD_BUTTON_GUIDE #define SDL_CONTROLLER_BUTTON_INVALID SDL_GAMEPAD_BUTTON_INVALID #define SDL_CONTROLLER_BUTTON_LEFTSHOULDER SDL_GAMEPAD_BUTTON_LEFT_SHOULDER #define SDL_CONTROLLER_BUTTON_LEFTSTICK SDL_GAMEPAD_BUTTON_LEFT_STICK #define SDL_CONTROLLER_BUTTON_MAX SDL_GAMEPAD_BUTTON_COUNT #define SDL_CONTROLLER_BUTTON_MISC1 SDL_GAMEPAD_BUTTON_MISC1 #define SDL_CONTROLLER_BUTTON_PADDLE1 SDL_GAMEPAD_BUTTON_RIGHT_PADDLE1 #define SDL_CONTROLLER_BUTTON_PADDLE2 SDL_GAMEPAD_BUTTON_LEFT_PADDLE1 #define SDL_CONTROLLER_BUTTON_PADDLE3 SDL_GAMEPAD_BUTTON_RIGHT_PADDLE2 #define SDL_CONTROLLER_BUTTON_PADDLE4 SDL_GAMEPAD_BUTTON_LEFT_PADDLE2 #define SDL_CONTROLLER_BUTTON_RIGHTSHOULDER SDL_GAMEPAD_BUTTON_RIGHT_SHOULDER #define SDL_CONTROLLER_BUTTON_RIGHTSTICK SDL_GAMEPAD_BUTTON_RIGHT_STICK #define SDL_CONTROLLER_BUTTON_START SDL_GAMEPAD_BUTTON_START #define SDL_CONTROLLER_BUTTON_TOUCHPAD SDL_GAMEPAD_BUTTON_TOUCHPAD #define SDL_CONTROLLER_BUTTON_X SDL_GAMEPAD_BUTTON_WEST #define SDL_CONTROLLER_BUTTON_Y SDL_GAMEPAD_BUTTON_NORTH #define SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_JOYCON_LEFT SDL_GAMEPAD_TYPE_NINTENDO_SWITCH_JOYCON_LEFT #define SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_JOYCON_PAIR SDL_GAMEPAD_TYPE_NINTENDO_SWITCH_JOYCON_PAIR #define SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_JOYCON_RIGHT SDL_GAMEPAD_TYPE_NINTENDO_SWITCH_JOYCON_RIGHT #define SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_PRO SDL_GAMEPAD_TYPE_NINTENDO_SWITCH_PRO #define SDL_CONTROLLER_TYPE_PS3 SDL_GAMEPAD_TYPE_PS3 #define SDL_CONTROLLER_TYPE_PS4 SDL_GAMEPAD_TYPE_PS4 #define SDL_CONTROLLER_TYPE_PS5 SDL_GAMEPAD_TYPE_PS5 #define SDL_CONTROLLER_TYPE_UNKNOWN SDL_GAMEPAD_TYPE_STANDARD #define SDL_CONTROLLER_TYPE_VIRTUAL SDL_GAMEPAD_TYPE_VIRTUAL #define SDL_CONTROLLER_TYPE_XBOX360 SDL_GAMEPAD_TYPE_XBOX360 #define SDL_CONTROLLER_TYPE_XBOXONE SDL_GAMEPAD_TYPE_XBOXONE #define SDL_GameController SDL_Gamepad #define SDL_GameControllerAddMapping SDL_AddGamepadMapping #define SDL_GameControllerAddMappingsFromFile SDL_AddGamepadMappingsFromFile #define SDL_GameControllerAddMappingsFromRW SDL_AddGamepadMappingsFromIO #define SDL_GameControllerAxis SDL_GamepadAxis #define SDL_GameControllerBindType SDL_GamepadBindingType #define SDL_GameControllerButton SDL_GamepadButton #define SDL_GameControllerClose SDL_CloseGamepad #define SDL_GameControllerFromInstanceID SDL_GetGamepadFromID #define SDL_GameControllerFromPlayerIndex SDL_GetGamepadFromPlayerIndex #define SDL_GameControllerGetAppleSFSymbolsNameForAxis SDL_GetGamepadAppleSFSymbolsNameForAxis #define SDL_GameControllerGetAppleSFSymbolsNameForButton SDL_GetGamepadAppleSFSymbolsNameForButton #define SDL_GameControllerGetAttached SDL_GamepadConnected #define SDL_GameControllerGetAxis SDL_GetGamepadAxis #define SDL_GameControllerGetAxisFromString SDL_GetGamepadAxisFromString #define SDL_GameControllerGetButton SDL_GetGamepadButton #define SDL_GameControllerGetButtonFromString SDL_GetGamepadButtonFromString #define SDL_GameControllerGetFirmwareVersion SDL_GetGamepadFirmwareVersion #define SDL_GameControllerGetJoystick SDL_GetGamepadJoystick #define SDL_GameControllerGetNumTouchpadFingers SDL_GetNumGamepadTouchpadFingers #define SDL_GameControllerGetNumTouchpads SDL_GetNumGamepadTouchpads #define SDL_GameControllerGetPlayerIndex SDL_GetGamepadPlayerIndex #define SDL_GameControllerGetProduct SDL_GetGamepadProduct #define SDL_GameControllerGetProductVersion SDL_GetGamepadProductVersion #define SDL_GameControllerGetSensorData SDL_GetGamepadSensorData #define SDL_GameControllerGetSensorDataRate SDL_GetGamepadSensorDataRate #define SDL_GameControllerGetSerial SDL_GetGamepadSerial #define SDL_GameControllerGetSteamHandle SDL_GetGamepadSteamHandle #define SDL_GameControllerGetStringForAxis SDL_GetGamepadStringForAxis #define SDL_GameControllerGetStringForButton SDL_GetGamepadStringForButton #define SDL_GameControllerGetTouchpadFinger SDL_GetGamepadTouchpadFinger #define SDL_GameControllerGetType SDL_GetGamepadType #define SDL_GameControllerGetVendor SDL_GetGamepadVendor #define SDL_GameControllerHasAxis SDL_GamepadHasAxis #define SDL_GameControllerHasButton SDL_GamepadHasButton #define SDL_GameControllerHasSensor SDL_GamepadHasSensor #define SDL_GameControllerIsSensorEnabled SDL_GamepadSensorEnabled #define SDL_GameControllerMapping SDL_GetGamepadMapping #define SDL_GameControllerMappingForGUID SDL_GetGamepadMappingForGUID #define SDL_GameControllerName SDL_GetGamepadName #define SDL_GameControllerOpen SDL_OpenGamepad #define SDL_GameControllerPath SDL_GetGamepadPath #define SDL_GameControllerRumble SDL_RumbleGamepad #define SDL_GameControllerRumbleTriggers SDL_RumbleGamepadTriggers #define SDL_GameControllerSendEffect SDL_SendGamepadEffect #define SDL_GameControllerSetLED SDL_SetGamepadLED #define SDL_GameControllerSetPlayerIndex SDL_SetGamepadPlayerIndex #define SDL_GameControllerSetSensorEnabled SDL_SetGamepadSensorEnabled #define SDL_GameControllerType SDL_GamepadType #define SDL_GameControllerUpdate SDL_UpdateGamepads #define SDL_INIT_GAMECONTROLLER SDL_INIT_GAMEPAD #define SDL_IsGameController SDL_IsGamepad /* ##SDL_guid.h */ #define SDL_GUIDFromString SDL_StringToGUID /* ##SDL_haptic.h */ #define SDL_HapticClose SDL_CloseHaptic #define SDL_HapticDestroyEffect SDL_DestroyHapticEffect #define SDL_HapticGetEffectStatus SDL_GetHapticEffectStatus #define SDL_HapticNewEffect SDL_CreateHapticEffect #define SDL_HapticNumAxes SDL_GetNumHapticAxes #define SDL_HapticNumEffects SDL_GetMaxHapticEffects #define SDL_HapticNumEffectsPlaying SDL_GetMaxHapticEffectsPlaying #define SDL_HapticOpen SDL_OpenHaptic #define SDL_HapticOpenFromJoystick SDL_OpenHapticFromJoystick #define SDL_HapticOpenFromMouse SDL_OpenHapticFromMouse #define SDL_HapticPause SDL_PauseHaptic #define SDL_HapticQuery SDL_GetHapticFeatures #define SDL_HapticRumbleInit SDL_InitHapticRumble #define SDL_HapticRumblePlay SDL_PlayHapticRumble #define SDL_HapticRumbleStop SDL_StopHapticRumble #define SDL_HapticRunEffect SDL_RunHapticEffect #define SDL_HapticSetAutocenter SDL_SetHapticAutocenter #define SDL_HapticSetGain SDL_SetHapticGain #define SDL_HapticStopAll SDL_StopHapticEffects #define SDL_HapticStopEffect SDL_StopHapticEffect #define SDL_HapticUnpause SDL_ResumeHaptic #define SDL_HapticUpdateEffect SDL_UpdateHapticEffect #define SDL_JoystickIsHaptic SDL_IsJoystickHaptic #define SDL_MouseIsHaptic SDL_IsMouseHaptic /* ##SDL_hints.h */ #define SDL_DelHintCallback SDL_RemoveHintCallback #define SDL_HINT_ALLOW_TOPMOST SDL_HINT_WINDOW_ALLOW_TOPMOST #define SDL_HINT_DIRECTINPUT_ENABLED SDL_HINT_JOYSTICK_DIRECTINPUT #define SDL_HINT_GDK_TEXTINPUT_DEFAULT SDL_HINT_GDK_TEXTINPUT_DEFAULT_TEXT #define SDL_HINT_JOYSTICK_GAMECUBE_RUMBLE_BRAKE SDL_HINT_JOYSTICK_HIDAPI_GAMECUBE_RUMBLE_BRAKE #define SDL_HINT_JOYSTICK_HIDAPI_PS4_RUMBLE SDL_HINT_JOYSTICK_ENHANCED_REPORTS #define SDL_HINT_JOYSTICK_HIDAPI_PS5_RUMBLE SDL_HINT_JOYSTICK_ENHANCED_REPORTS #define SDL_HINT_LINUX_DIGITAL_HATS SDL_HINT_JOYSTICK_LINUX_DIGITAL_HATS #define SDL_HINT_LINUX_HAT_DEADZONES SDL_HINT_JOYSTICK_LINUX_HAT_DEADZONES #define SDL_HINT_LINUX_JOYSTICK_CLASSIC SDL_HINT_JOYSTICK_LINUX_CLASSIC #define SDL_HINT_LINUX_JOYSTICK_DEADZONES SDL_HINT_JOYSTICK_LINUX_DEADZONES /* ##SDL_joystick.h */ #define SDL_JOYSTICK_TYPE_GAMECONTROLLER SDL_JOYSTICK_TYPE_GAMEPAD #define SDL_JoystickAttachVirtualEx SDL_AttachVirtualJoystick #define SDL_JoystickClose SDL_CloseJoystick #define SDL_JoystickDetachVirtual SDL_DetachVirtualJoystick #define SDL_JoystickFromInstanceID SDL_GetJoystickFromID #define SDL_JoystickFromPlayerIndex SDL_GetJoystickFromPlayerIndex #define SDL_JoystickGUID SDL_GUID #define SDL_JoystickGetAttached SDL_JoystickConnected #define SDL_JoystickGetAxis SDL_GetJoystickAxis #define SDL_JoystickGetAxisInitialState SDL_GetJoystickAxisInitialState #define SDL_JoystickGetBall SDL_GetJoystickBall #define SDL_JoystickGetButton SDL_GetJoystickButton #define SDL_JoystickGetFirmwareVersion SDL_GetJoystickFirmwareVersion #define SDL_JoystickGetGUID SDL_GetJoystickGUID #define SDL_JoystickGetGUIDFromString SDL_StringToGUID #define SDL_JoystickGetHat SDL_GetJoystickHat #define SDL_JoystickGetPlayerIndex SDL_GetJoystickPlayerIndex #define SDL_JoystickGetProduct SDL_GetJoystickProduct #define SDL_JoystickGetProductVersion SDL_GetJoystickProductVersion #define SDL_JoystickGetSerial SDL_GetJoystickSerial #define SDL_JoystickGetType SDL_GetJoystickType #define SDL_JoystickGetVendor SDL_GetJoystickVendor #define SDL_JoystickInstanceID SDL_GetJoystickID #define SDL_JoystickIsVirtual SDL_IsJoystickVirtual #define SDL_JoystickName SDL_GetJoystickName #define SDL_JoystickNumAxes SDL_GetNumJoystickAxes #define SDL_JoystickNumBalls SDL_GetNumJoystickBalls #define SDL_JoystickNumButtons SDL_GetNumJoystickButtons #define SDL_JoystickNumHats SDL_GetNumJoystickHats #define SDL_JoystickOpen SDL_OpenJoystick #define SDL_JoystickPath SDL_GetJoystickPath #define SDL_JoystickRumble SDL_RumbleJoystick #define SDL_JoystickRumbleTriggers SDL_RumbleJoystickTriggers #define SDL_JoystickSendEffect SDL_SendJoystickEffect #define SDL_JoystickSetLED SDL_SetJoystickLED #define SDL_JoystickSetPlayerIndex SDL_SetJoystickPlayerIndex #define SDL_JoystickSetVirtualAxis SDL_SetJoystickVirtualAxis #define SDL_JoystickSetVirtualButton SDL_SetJoystickVirtualButton #define SDL_JoystickSetVirtualHat SDL_SetJoystickVirtualHat #define SDL_JoystickUpdate SDL_UpdateJoysticks /* ##SDL_keyboard.h */ #define SDL_IsScreenKeyboardShown SDL_ScreenKeyboardShown #define SDL_IsTextInputActive SDL_TextInputActive /* ##SDL_keycode.h */ #define KMOD_ALT SDL_KMOD_ALT #define KMOD_CAPS SDL_KMOD_CAPS #define KMOD_CTRL SDL_KMOD_CTRL #define KMOD_GUI SDL_KMOD_GUI #define KMOD_LALT SDL_KMOD_LALT #define KMOD_LCTRL SDL_KMOD_LCTRL #define KMOD_LGUI SDL_KMOD_LGUI #define KMOD_LSHIFT SDL_KMOD_LSHIFT #define KMOD_MODE SDL_KMOD_MODE #define KMOD_NONE SDL_KMOD_NONE #define KMOD_NUM SDL_KMOD_NUM #define KMOD_RALT SDL_KMOD_RALT #define KMOD_RCTRL SDL_KMOD_RCTRL #define KMOD_RGUI SDL_KMOD_RGUI #define KMOD_RSHIFT SDL_KMOD_RSHIFT #define KMOD_SCROLL SDL_KMOD_SCROLL #define KMOD_SHIFT SDL_KMOD_SHIFT #define SDLK_AUDIOFASTFORWARD SDLK_MEDIA_FAST_FORWARD #define SDLK_AUDIOMUTE SDLK_MUTE #define SDLK_AUDIONEXT SDLK_MEDIA_NEXT_TRACK #define SDLK_AUDIOPLAY SDLK_MEDIA_PLAY #define SDLK_AUDIOPREV SDLK_MEDIA_PREVIOUS_TRACK #define SDLK_AUDIOREWIND SDLK_MEDIA_REWIND #define SDLK_AUDIOSTOP SDLK_MEDIA_STOP #define SDLK_BACKQUOTE SDLK_GRAVE #define SDLK_EJECT SDLK_MEDIA_EJECT #define SDLK_MEDIASELECT SDLK_MEDIA_SELECT #define SDLK_QUOTE SDLK_APOSTROPHE #define SDLK_QUOTEDBL SDLK_DBLAPOSTROPHE #define SDLK_a SDLK_A #define SDLK_b SDLK_B #define SDLK_c SDLK_C #define SDLK_d SDLK_D #define SDLK_e SDLK_E #define SDLK_f SDLK_F #define SDLK_g SDLK_G #define SDLK_h SDLK_H #define SDLK_i SDLK_I #define SDLK_j SDLK_J #define SDLK_k SDLK_K #define SDLK_l SDLK_L #define SDLK_m SDLK_M #define SDLK_n SDLK_N #define SDLK_o SDLK_O #define SDLK_p SDLK_P #define SDLK_q SDLK_Q #define SDLK_r SDLK_R #define SDLK_s SDLK_S #define SDLK_t SDLK_T #define SDLK_u SDLK_U #define SDLK_v SDLK_V #define SDLK_w SDLK_W #define SDLK_x SDLK_X #define SDLK_y SDLK_Y #define SDLK_z SDLK_Z /* ##SDL_log.h */ #define SDL_LogGetOutputFunction SDL_GetLogOutputFunction #define SDL_LogGetPriority SDL_GetLogPriority #define SDL_LogResetPriorities SDL_ResetLogPriorities #define SDL_LogSetAllPriority SDL_SetLogPriorities #define SDL_LogSetOutputFunction SDL_SetLogOutputFunction #define SDL_LogSetPriority SDL_SetLogPriority #define SDL_NUM_LOG_PRIORITIES SDL_LOG_PRIORITY_COUNT /* ##SDL_messagebox.h */ #define SDL_MESSAGEBOX_COLOR_MAX SDL_MESSAGEBOX_COLOR_COUNT /* ##SDL_mouse.h */ #define SDL_BUTTON SDL_BUTTON_MASK #define SDL_FreeCursor SDL_DestroyCursor #define SDL_NUM_SYSTEM_CURSORS SDL_SYSTEM_CURSOR_COUNT #define SDL_SYSTEM_CURSOR_ARROW SDL_SYSTEM_CURSOR_DEFAULT #define SDL_SYSTEM_CURSOR_HAND SDL_SYSTEM_CURSOR_POINTER #define SDL_SYSTEM_CURSOR_IBEAM SDL_SYSTEM_CURSOR_TEXT #define SDL_SYSTEM_CURSOR_NO SDL_SYSTEM_CURSOR_NOT_ALLOWED #define SDL_SYSTEM_CURSOR_SIZEALL SDL_SYSTEM_CURSOR_MOVE #define SDL_SYSTEM_CURSOR_SIZENESW SDL_SYSTEM_CURSOR_NESW_RESIZE #define SDL_SYSTEM_CURSOR_SIZENS SDL_SYSTEM_CURSOR_NS_RESIZE #define SDL_SYSTEM_CURSOR_SIZENWSE SDL_SYSTEM_CURSOR_NWSE_RESIZE #define SDL_SYSTEM_CURSOR_SIZEWE SDL_SYSTEM_CURSOR_EW_RESIZE #define SDL_SYSTEM_CURSOR_WAITARROW SDL_SYSTEM_CURSOR_PROGRESS #define SDL_SYSTEM_CURSOR_WINDOW_BOTTOM SDL_SYSTEM_CURSOR_S_RESIZE #define SDL_SYSTEM_CURSOR_WINDOW_BOTTOMLEFT SDL_SYSTEM_CURSOR_SW_RESIZE #define SDL_SYSTEM_CURSOR_WINDOW_BOTTOMRIGHT SDL_SYSTEM_CURSOR_SE_RESIZE #define SDL_SYSTEM_CURSOR_WINDOW_LEFT SDL_SYSTEM_CURSOR_W_RESIZE #define SDL_SYSTEM_CURSOR_WINDOW_RIGHT SDL_SYSTEM_CURSOR_E_RESIZE #define SDL_SYSTEM_CURSOR_WINDOW_TOP SDL_SYSTEM_CURSOR_N_RESIZE #define SDL_SYSTEM_CURSOR_WINDOW_TOPLEFT SDL_SYSTEM_CURSOR_NW_RESIZE #define SDL_SYSTEM_CURSOR_WINDOW_TOPRIGHT SDL_SYSTEM_CURSOR_NE_RESIZE /* ##SDL_mutex.h */ #define SDL_CondBroadcast SDL_BroadcastCondition #define SDL_CondSignal SDL_SignalCondition #define SDL_CondWait SDL_WaitCondition #define SDL_CondWaitTimeout SDL_WaitConditionTimeout #define SDL_CreateCond SDL_CreateCondition #define SDL_DestroyCond SDL_DestroyCondition #define SDL_SemPost SDL_SignalSemaphore #define SDL_SemTryWait SDL_TryWaitSemaphore #define SDL_SemValue SDL_GetSemaphoreValue #define SDL_SemWait SDL_WaitSemaphore #define SDL_SemWaitTimeout SDL_WaitSemaphoreTimeout /* ##SDL_mutex.h */ #define SDL_cond SDL_Condition #define SDL_mutex SDL_Mutex #define SDL_sem SDL_Semaphore /* ##SDL_pixels.h */ #define SDL_AllocFormat SDL_GetPixelFormatDetails #define SDL_AllocPalette SDL_CreatePalette #define SDL_Colour SDL_Color #define SDL_FreePalette SDL_DestroyPalette #define SDL_MasksToPixelFormatEnum SDL_GetPixelFormatForMasks #define SDL_PIXELFORMAT_BGR444 SDL_PIXELFORMAT_XBGR4444 #define SDL_PIXELFORMAT_BGR555 SDL_PIXELFORMAT_XBGR1555 #define SDL_PIXELFORMAT_BGR888 SDL_PIXELFORMAT_XBGR8888 #define SDL_PIXELFORMAT_RGB444 SDL_PIXELFORMAT_XRGB4444 #define SDL_PIXELFORMAT_RGB555 SDL_PIXELFORMAT_XRGB1555 #define SDL_PIXELFORMAT_RGB888 SDL_PIXELFORMAT_XRGB8888 #define SDL_PixelFormatEnumToMasks SDL_GetMasksForPixelFormat /* ##SDL_rect.h */ #define SDL_EncloseFPoints SDL_GetRectEnclosingPointsFloat #define SDL_EnclosePoints SDL_GetRectEnclosingPoints #define SDL_FRectEmpty SDL_RectEmptyFloat #define SDL_FRectEquals SDL_RectsEqualFloat #define SDL_FRectEqualsEpsilon SDL_RectsEqualEpsilon #define SDL_HasIntersection SDL_HasRectIntersection #define SDL_HasIntersectionF SDL_HasRectIntersectionFloat #define SDL_IntersectFRect SDL_GetRectIntersectionFloat #define SDL_IntersectFRectAndLine SDL_GetRectAndLineIntersectionFloat #define SDL_IntersectRect SDL_GetRectIntersection #define SDL_IntersectRectAndLine SDL_GetRectAndLineIntersection #define SDL_PointInFRect SDL_PointInRectFloat #define SDL_RectEquals SDL_RectsEqual #define SDL_UnionFRect SDL_GetRectUnionFloat #define SDL_UnionRect SDL_GetRectUnion /* ##SDL_render.h */ #define SDL_GetRendererOutputSize SDL_GetCurrentRenderOutputSize #define SDL_RenderCopy SDL_RenderTexture #define SDL_RenderCopyEx SDL_RenderTextureRotated #define SDL_RenderCopyExF SDL_RenderTextureRotated #define SDL_RenderCopyF SDL_RenderTexture #define SDL_RenderDrawLine SDL_RenderLine #define SDL_RenderDrawLineF SDL_RenderLine #define SDL_RenderDrawLines SDL_RenderLines #define SDL_RenderDrawLinesF SDL_RenderLines #define SDL_RenderDrawPoint SDL_RenderPoint #define SDL_RenderDrawPointF SDL_RenderPoint #define SDL_RenderDrawPoints SDL_RenderPoints #define SDL_RenderDrawPointsF SDL_RenderPoints #define SDL_RenderDrawRect SDL_RenderRect #define SDL_RenderDrawRectF SDL_RenderRect #define SDL_RenderDrawRects SDL_RenderRects #define SDL_RenderDrawRectsF SDL_RenderRects #define SDL_RenderFillRectF SDL_RenderFillRect #define SDL_RenderFillRectsF SDL_RenderFillRects #define SDL_RendererFlip SDL_FlipMode #define SDL_RenderFlush SDL_FlushRenderer #define SDL_RenderGetClipRect SDL_GetRenderClipRect #define SDL_RenderGetLogicalSize SDL_GetRenderLogicalPresentation #define SDL_RenderGetMetalCommandEncoder SDL_GetRenderMetalCommandEncoder #define SDL_RenderGetMetalLayer SDL_GetRenderMetalLayer #define SDL_RenderGetScale SDL_GetRenderScale #define SDL_RenderGetViewport SDL_GetRenderViewport #define SDL_RenderGetWindow SDL_GetRenderWindow #define SDL_RenderIsClipEnabled SDL_RenderClipEnabled #define SDL_RenderLogicalToWindow SDL_RenderCoordinatesToWindow #define SDL_RenderSetClipRect SDL_SetRenderClipRect #define SDL_RenderSetLogicalSize SDL_SetRenderLogicalPresentation #define SDL_RenderSetScale SDL_SetRenderScale #define SDL_RenderSetVSync SDL_SetRenderVSync #define SDL_RenderSetViewport SDL_SetRenderViewport #define SDL_RenderWindowToLogical SDL_RenderCoordinatesFromWindow #define SDL_ScaleModeLinear SDL_SCALEMODE_LINEAR #define SDL_ScaleModeNearest SDL_SCALEMODE_NEAREST /* ##SDL_rwops.h */ #define RW_SEEK_CUR SDL_IO_SEEK_CUR #define RW_SEEK_END SDL_IO_SEEK_END #define RW_SEEK_SET SDL_IO_SEEK_SET #define SDL_RWFromConstMem SDL_IOFromConstMem #define SDL_RWFromFile SDL_IOFromFile #define SDL_RWFromMem SDL_IOFromMem #define SDL_RWclose SDL_CloseIO #define SDL_RWops SDL_IOStream #define SDL_RWread SDL_ReadIO #define SDL_RWseek SDL_SeekIO #define SDL_RWsize SDL_GetIOSize #define SDL_RWtell SDL_TellIO #define SDL_RWwrite SDL_WriteIO #define SDL_ReadBE16 SDL_ReadU16BE #define SDL_ReadBE32 SDL_ReadU32BE #define SDL_ReadBE64 SDL_ReadU64BE #define SDL_ReadLE16 SDL_ReadU16LE #define SDL_ReadLE32 SDL_ReadU32LE #define SDL_ReadLE64 SDL_ReadU64LE #define SDL_WriteBE16 SDL_WriteU16BE #define SDL_WriteBE32 SDL_WriteU32BE #define SDL_WriteBE64 SDL_WriteU64BE #define SDL_WriteLE16 SDL_WriteU16LE #define SDL_WriteLE32 SDL_WriteU32LE #define SDL_WriteLE64 SDL_WriteU64LE /* ##SDL_scancode.h */ #define SDL_NUM_SCANCODES SDL_SCANCODE_COUNT #define SDL_SCANCODE_AUDIOFASTFORWARD SDL_SCANCODE_MEDIA_FAST_FORWARD #define SDL_SCANCODE_AUDIOMUTE SDL_SCANCODE_MUTE #define SDL_SCANCODE_AUDIONEXT SDL_SCANCODE_MEDIA_NEXT_TRACK #define SDL_SCANCODE_AUDIOPLAY SDL_SCANCODE_MEDIA_PLAY #define SDL_SCANCODE_AUDIOPREV SDL_SCANCODE_MEDIA_PREVIOUS_TRACK #define SDL_SCANCODE_AUDIOREWIND SDL_SCANCODE_MEDIA_REWIND #define SDL_SCANCODE_AUDIOSTOP SDL_SCANCODE_MEDIA_STOP #define SDL_SCANCODE_EJECT SDL_SCANCODE_MEDIA_EJECT #define SDL_SCANCODE_MEDIASELECT SDL_SCANCODE_MEDIA_SELECT /* ##SDL_sensor.h */ #define SDL_SensorClose SDL_CloseSensor #define SDL_SensorFromInstanceID SDL_GetSensorFromID #define SDL_SensorGetData SDL_GetSensorData #define SDL_SensorGetInstanceID SDL_GetSensorID #define SDL_SensorGetName SDL_GetSensorName #define SDL_SensorGetNonPortableType SDL_GetSensorNonPortableType #define SDL_SensorGetType SDL_GetSensorType #define SDL_SensorOpen SDL_OpenSensor #define SDL_SensorUpdate SDL_UpdateSensors /* ##SDL_stdinc.h */ #define SDL_FALSE false #define SDL_TABLESIZE SDL_arraysize #define SDL_TRUE true #define SDL_bool bool #define SDL_size_add_overflow SDL_size_add_check_overflow #define SDL_size_mul_overflow SDL_size_mul_check_overflow #define SDL_strtokr SDL_strtok_r /* ##SDL_surface.h */ #define SDL_BlitScaled SDL_BlitSurfaceScaled #define SDL_ConvertSurfaceFormat SDL_ConvertSurface #define SDL_FillRect SDL_FillSurfaceRect #define SDL_FillRects SDL_FillSurfaceRects #define SDL_FreeSurface SDL_DestroySurface #define SDL_GetClipRect SDL_GetSurfaceClipRect #define SDL_GetColorKey SDL_GetSurfaceColorKey #define SDL_HasColorKey SDL_SurfaceHasColorKey #define SDL_HasSurfaceRLE SDL_SurfaceHasRLE #define SDL_LoadBMP_RW SDL_LoadBMP_IO #define SDL_LowerBlit SDL_BlitSurfaceUnchecked #define SDL_LowerBlitScaled SDL_BlitSurfaceUncheckedScaled #define SDL_PREALLOC SDL_SURFACE_PREALLOCATED #define SDL_SIMD_ALIGNED SDL_SURFACE_SIMD_ALIGNED #define SDL_SaveBMP_RW SDL_SaveBMP_IO #define SDL_SetClipRect SDL_SetSurfaceClipRect #define SDL_SetColorKey SDL_SetSurfaceColorKey #define SDL_UpperBlit SDL_BlitSurface #define SDL_UpperBlitScaled SDL_BlitSurfaceScaled /* ##SDL_system.h */ #define SDL_AndroidBackButton SDL_SendAndroidBackButton #define SDL_AndroidGetActivity SDL_GetAndroidActivity #define SDL_AndroidGetExternalStoragePath SDL_GetAndroidExternalStoragePath #define SDL_AndroidGetExternalStorageState SDL_GetAndroidExternalStorageState #define SDL_AndroidGetInternalStoragePath SDL_GetAndroidInternalStoragePath #define SDL_AndroidGetJNIEnv SDL_GetAndroidJNIEnv #define SDL_AndroidRequestPermission SDL_RequestAndroidPermission #define SDL_AndroidRequestPermissionCallback SDL_RequestAndroidPermissionCallback #define SDL_AndroidSendMessage SDL_SendAndroidMessage #define SDL_AndroidShowToast SDL_ShowAndroidToast #define SDL_DXGIGetOutputInfo SDL_GetDXGIOutputInfo #define SDL_Direct3D9GetAdapterIndex SDL_GetDirect3D9AdapterIndex #define SDL_GDKGetDefaultUser SDL_GetGDKDefaultUser #define SDL_GDKGetTaskQueue SDL_GetGDKTaskQueue #define SDL_LinuxSetThreadPriority SDL_SetLinuxThreadPriority #define SDL_LinuxSetThreadPriorityAndPolicy SDL_SetLinuxThreadPriorityAndPolicy #define SDL_OnApplicationDidBecomeActive SDL_OnApplicationDidEnterForeground #define SDL_OnApplicationWillResignActive SDL_OnApplicationWillEnterBackground #define SDL_iOSSetAnimationCallback SDL_SetiOSAnimationCallback #define SDL_iOSSetEventPump SDL_SetiOSEventPump #define SDL_iPhoneSetAnimationCallback SDL_SetiOSAnimationCallback #define SDL_iPhoneSetEventPump SDL_SetiOSEventPump /* ##SDL_thread.h */ #define SDL_SetThreadPriority SDL_SetCurrentThreadPriority #define SDL_TLSCleanup SDL_CleanupTLS #define SDL_TLSGet SDL_GetTLS #define SDL_TLSSet SDL_SetTLS #define SDL_threadID SDL_ThreadID /* ##SDL_timer.h */ #define SDL_GetTicks64 SDL_GetTicks /* ##SDL_version.h */ #define SDL_COMPILEDVERSION SDL_VERSION #define SDL_PATCHLEVEL SDL_MICRO_VERSION /* ##SDL_video.h */ #define SDL_GL_DeleteContext SDL_GL_DestroyContext #define SDL_GLattr SDL_GLAttr #define SDL_GLcontextFlag SDL_GLContextFlag #define SDL_GLcontextReleaseFlag SDL_GLContextReleaseFlag #define SDL_GLprofile SDL_GLProfile #define SDL_GetClosestDisplayMode SDL_GetClosestFullscreenDisplayMode #define SDL_GetDisplayOrientation SDL_GetCurrentDisplayOrientation #define SDL_GetPointDisplayIndex SDL_GetDisplayForPoint #define SDL_GetRectDisplayIndex SDL_GetDisplayForRect #define SDL_GetWindowDisplayIndex SDL_GetDisplayForWindow #define SDL_GetWindowDisplayMode SDL_GetWindowFullscreenMode #define SDL_HasWindowSurface SDL_WindowHasSurface #define SDL_IsScreenSaverEnabled SDL_ScreenSaverEnabled #define SDL_SetWindowDisplayMode SDL_SetWindowFullscreenMode #define SDL_WINDOW_ALLOW_HIGHDPI SDL_WINDOW_HIGH_PIXEL_DENSITY #define SDL_WINDOW_INPUT_GRABBED SDL_WINDOW_MOUSE_GRABBED #define SDL_WINDOW_SKIP_TASKBAR SDL_WINDOW_UTILITY #elif !defined(SDL_DISABLE_OLD_NAMES) /* ##SDL_atomic.h */ #define SDL_AtomicAdd SDL_AtomicAdd_renamed_SDL_AddAtomicInt #define SDL_AtomicCAS SDL_AtomicCAS_renamed_SDL_CompareAndSwapAtomicInt #define SDL_AtomicCASPtr SDL_AtomicCASPtr_renamed_SDL_CompareAndSwapAtomicPointer #define SDL_AtomicGet SDL_AtomicGet_renamed_SDL_GetAtomicInt #define SDL_AtomicGetPtr SDL_AtomicGetPtr_renamed_SDL_GetAtomicPointer #define SDL_AtomicLock SDL_AtomicLock_renamed_SDL_LockSpinlock #define SDL_AtomicSet SDL_AtomicSet_renamed_SDL_SetAtomicInt #define SDL_AtomicSetPtr SDL_AtomicSetPtr_renamed_SDL_SetAtomicPointer #define SDL_AtomicTryLock SDL_AtomicTryLock_renamed_SDL_TryLockSpinlock #define SDL_AtomicUnlock SDL_AtomicUnlock_renamed_SDL_UnlockSpinlock #define SDL_atomic_t SDL_atomic_t_renamed_SDL_AtomicInt /* ##SDL_audio.h */ #define AUDIO_F32 AUDIO_F32_renamed_SDL_AUDIO_F32LE #define AUDIO_F32LSB AUDIO_F32LSB_renamed_SDL_AUDIO_F32LE #define AUDIO_F32MSB AUDIO_F32MSB_renamed_SDL_AUDIO_F32BE #define AUDIO_F32SYS AUDIO_F32SYS_renamed_SDL_AUDIO_F32 #define AUDIO_S16 AUDIO_S16_renamed_SDL_AUDIO_S16LE #define AUDIO_S16LSB AUDIO_S16LSB_renamed_SDL_AUDIO_S16LE #define AUDIO_S16MSB AUDIO_S16MSB_renamed_SDL_AUDIO_S16BE #define AUDIO_S16SYS AUDIO_S16SYS_renamed_SDL_AUDIO_S16 #define AUDIO_S32 AUDIO_S32_renamed_SDL_AUDIO_S32LE #define AUDIO_S32LSB AUDIO_S32LSB_renamed_SDL_AUDIO_S32LE #define AUDIO_S32MSB AUDIO_S32MSB_renamed_SDL_AUDIO_S32BE #define AUDIO_S32SYS AUDIO_S32SYS_renamed_SDL_AUDIO_S32 #define AUDIO_S8 AUDIO_S8_renamed_SDL_AUDIO_S8 #define AUDIO_U8 AUDIO_U8_renamed_SDL_AUDIO_U8 #define SDL_AudioStreamAvailable SDL_AudioStreamAvailable_renamed_SDL_GetAudioStreamAvailable #define SDL_AudioStreamClear SDL_AudioStreamClear_renamed_SDL_ClearAudioStream #define SDL_AudioStreamFlush SDL_AudioStreamFlush_renamed_SDL_FlushAudioStream #define SDL_AudioStreamGet SDL_AudioStreamGet_renamed_SDL_GetAudioStreamData #define SDL_AudioStreamPut SDL_AudioStreamPut_renamed_SDL_PutAudioStreamData #define SDL_FreeAudioStream SDL_FreeAudioStream_renamed_SDL_DestroyAudioStream #define SDL_FreeWAV SDL_FreeWAV_renamed_SDL_free #define SDL_LoadWAV_RW SDL_LoadWAV_RW_renamed_SDL_LoadWAV_IO #define SDL_MixAudioFormat SDL_MixAudioFormat_renamed_SDL_MixAudio #define SDL_NewAudioStream SDL_NewAudioStream_renamed_SDL_CreateAudioStream /* ##SDL_cpuinfo.h */ #define SDL_GetCPUCount SDL_GetCPUCount_renamed_SDL_GetNumLogicalCPUCores #define SDL_SIMDGetAlignment SDL_SIMDGetAlignment_renamed_SDL_GetSIMDAlignment /* ##SDL_endian.h */ #define SDL_SwapBE16 SDL_SwapBE16_renamed_SDL_Swap16BE #define SDL_SwapBE32 SDL_SwapBE32_renamed_SDL_Swap32BE #define SDL_SwapBE64 SDL_SwapBE64_renamed_SDL_Swap64BE #define SDL_SwapLE16 SDL_SwapLE16_renamed_SDL_Swap16LE #define SDL_SwapLE32 SDL_SwapLE32_renamed_SDL_Swap32LE #define SDL_SwapLE64 SDL_SwapLE64_renamed_SDL_Swap64LE /* ##SDL_events.h */ #define SDL_APP_DIDENTERBACKGROUND SDL_APP_DIDENTERBACKGROUND_renamed_SDL_EVENT_DID_ENTER_BACKGROUND #define SDL_APP_DIDENTERFOREGROUND SDL_APP_DIDENTERFOREGROUND_renamed_SDL_EVENT_DID_ENTER_FOREGROUND #define SDL_APP_LOWMEMORY SDL_APP_LOWMEMORY_renamed_SDL_EVENT_LOW_MEMORY #define SDL_APP_TERMINATING SDL_APP_TERMINATING_renamed_SDL_EVENT_TERMINATING #define SDL_APP_WILLENTERBACKGROUND SDL_APP_WILLENTERBACKGROUND_renamed_SDL_EVENT_WILL_ENTER_BACKGROUND #define SDL_APP_WILLENTERFOREGROUND SDL_APP_WILLENTERFOREGROUND_renamed_SDL_EVENT_WILL_ENTER_FOREGROUND #define SDL_AUDIODEVICEADDED SDL_AUDIODEVICEADDED_renamed_SDL_EVENT_AUDIO_DEVICE_ADDED #define SDL_AUDIODEVICEREMOVED SDL_AUDIODEVICEREMOVED_renamed_SDL_EVENT_AUDIO_DEVICE_REMOVED #define SDL_CLIPBOARDUPDATE SDL_CLIPBOARDUPDATE_renamed_SDL_EVENT_CLIPBOARD_UPDATE #define SDL_CONTROLLERAXISMOTION SDL_CONTROLLERAXISMOTION_renamed_SDL_EVENT_GAMEPAD_AXIS_MOTION #define SDL_CONTROLLERBUTTONDOWN SDL_CONTROLLERBUTTONDOWN_renamed_SDL_EVENT_GAMEPAD_BUTTON_DOWN #define SDL_CONTROLLERBUTTONUP SDL_CONTROLLERBUTTONUP_renamed_SDL_EVENT_GAMEPAD_BUTTON_UP #define SDL_CONTROLLERDEVICEADDED SDL_CONTROLLERDEVICEADDED_renamed_SDL_EVENT_GAMEPAD_ADDED #define SDL_CONTROLLERDEVICEREMAPPED SDL_CONTROLLERDEVICEREMAPPED_renamed_SDL_EVENT_GAMEPAD_REMAPPED #define SDL_CONTROLLERDEVICEREMOVED SDL_CONTROLLERDEVICEREMOVED_renamed_SDL_EVENT_GAMEPAD_REMOVED #define SDL_CONTROLLERSENSORUPDATE SDL_CONTROLLERSENSORUPDATE_renamed_SDL_EVENT_GAMEPAD_SENSOR_UPDATE #define SDL_CONTROLLERSTEAMHANDLEUPDATED SDL_CONTROLLERSTEAMHANDLEUPDATED_renamed_SDL_EVENT_GAMEPAD_STEAM_HANDLE_UPDATED #define SDL_CONTROLLERTOUCHPADDOWN SDL_CONTROLLERTOUCHPADDOWN_renamed_SDL_EVENT_GAMEPAD_TOUCHPAD_DOWN #define SDL_CONTROLLERTOUCHPADMOTION SDL_CONTROLLERTOUCHPADMOTION_renamed_SDL_EVENT_GAMEPAD_TOUCHPAD_MOTION #define SDL_CONTROLLERTOUCHPADUP SDL_CONTROLLERTOUCHPADUP_renamed_SDL_EVENT_GAMEPAD_TOUCHPAD_UP #define SDL_ControllerAxisEvent SDL_ControllerAxisEvent_renamed_SDL_GamepadAxisEvent #define SDL_ControllerButtonEvent SDL_ControllerButtonEvent_renamed_SDL_GamepadButtonEvent #define SDL_ControllerDeviceEvent SDL_ControllerDeviceEvent_renamed_SDL_GamepadDeviceEvent #define SDL_ControllerSensorEvent SDL_ControllerSensorEvent_renamed_SDL_GamepadSensorEvent #define SDL_ControllerTouchpadEvent SDL_ControllerTouchpadEvent_renamed_SDL_GamepadTouchpadEvent #define SDL_DISPLAYEVENT_CONNECTED SDL_DISPLAYEVENT_CONNECTED_renamed_SDL_EVENT_DISPLAY_ADDED #define SDL_DISPLAYEVENT_DISCONNECTED SDL_DISPLAYEVENT_DISCONNECTED_renamed_SDL_EVENT_DISPLAY_REMOVED #define SDL_DISPLAYEVENT_MOVED SDL_DISPLAYEVENT_MOVED_renamed_SDL_EVENT_DISPLAY_MOVED #define SDL_DISPLAYEVENT_ORIENTATION SDL_DISPLAYEVENT_ORIENTATION_renamed_SDL_EVENT_DISPLAY_ORIENTATION #define SDL_DROPBEGIN SDL_DROPBEGIN_renamed_SDL_EVENT_DROP_BEGIN #define SDL_DROPCOMPLETE SDL_DROPCOMPLETE_renamed_SDL_EVENT_DROP_COMPLETE #define SDL_DROPFILE SDL_DROPFILE_renamed_SDL_EVENT_DROP_FILE #define SDL_DROPTEXT SDL_DROPTEXT_renamed_SDL_EVENT_DROP_TEXT #define SDL_DelEventWatch SDL_DelEventWatch_renamed_SDL_RemoveEventWatch #define SDL_FINGERDOWN SDL_FINGERDOWN_renamed_SDL_EVENT_FINGER_DOWN #define SDL_FINGERMOTION SDL_FINGERMOTION_renamed_SDL_EVENT_FINGER_MOTION #define SDL_FINGERUP SDL_FINGERUP_renamed_SDL_EVENT_FINGER_UP #define SDL_FIRSTEVENT SDL_FIRSTEVENT_renamed_SDL_EVENT_FIRST #define SDL_JOYAXISMOTION SDL_JOYAXISMOTION_renamed_SDL_EVENT_JOYSTICK_AXIS_MOTION #define SDL_JOYBATTERYUPDATED SDL_JOYBATTERYUPDATED_renamed_SDL_EVENT_JOYSTICK_BATTERY_UPDATED #define SDL_JOYBUTTONDOWN SDL_JOYBUTTONDOWN_renamed_SDL_EVENT_JOYSTICK_BUTTON_DOWN #define SDL_JOYBUTTONUP SDL_JOYBUTTONUP_renamed_SDL_EVENT_JOYSTICK_BUTTON_UP #define SDL_JOYDEVICEADDED SDL_JOYDEVICEADDED_renamed_SDL_EVENT_JOYSTICK_ADDED #define SDL_JOYDEVICEREMOVED SDL_JOYDEVICEREMOVED_renamed_SDL_EVENT_JOYSTICK_REMOVED #define SDL_JOYBALLMOTION SDL_JOYBALLMOTION_renamed_SDL_EVENT_JOYSTICK_BALL_MOTION #define SDL_JOYHATMOTION SDL_JOYHATMOTION_renamed_SDL_EVENT_JOYSTICK_HAT_MOTION #define SDL_KEYDOWN SDL_KEYDOWN_renamed_SDL_EVENT_KEY_DOWN #define SDL_KEYMAPCHANGED SDL_KEYMAPCHANGED_renamed_SDL_EVENT_KEYMAP_CHANGED #define SDL_KEYUP SDL_KEYUP_renamed_SDL_EVENT_KEY_UP #define SDL_LASTEVENT SDL_LASTEVENT_renamed_SDL_EVENT_LAST #define SDL_LOCALECHANGED SDL_LOCALECHANGED_renamed_SDL_EVENT_LOCALE_CHANGED #define SDL_MOUSEBUTTONDOWN SDL_MOUSEBUTTONDOWN_renamed_SDL_EVENT_MOUSE_BUTTON_DOWN #define SDL_MOUSEBUTTONUP SDL_MOUSEBUTTONUP_renamed_SDL_EVENT_MOUSE_BUTTON_UP #define SDL_MOUSEMOTION SDL_MOUSEMOTION_renamed_SDL_EVENT_MOUSE_MOTION #define SDL_MOUSEWHEEL SDL_MOUSEWHEEL_renamed_SDL_EVENT_MOUSE_WHEEL #define SDL_POLLSENTINEL SDL_POLLSENTINEL_renamed_SDL_EVENT_POLL_SENTINEL #define SDL_QUIT SDL_QUIT_renamed_SDL_EVENT_QUIT #define SDL_RENDER_DEVICE_RESET SDL_RENDER_DEVICE_RESET_renamed_SDL_EVENT_RENDER_DEVICE_RESET #define SDL_RENDER_TARGETS_RESET SDL_RENDER_TARGETS_RESET_renamed_SDL_EVENT_RENDER_TARGETS_RESET #define SDL_SENSORUPDATE SDL_SENSORUPDATE_renamed_SDL_EVENT_SENSOR_UPDATE #define SDL_TEXTEDITING SDL_TEXTEDITING_renamed_SDL_EVENT_TEXT_EDITING #define SDL_TEXTEDITING_EXT SDL_TEXTEDITING_EXT_renamed_SDL_EVENT_TEXT_EDITING_EXT #define SDL_TEXTINPUT SDL_TEXTINPUT_renamed_SDL_EVENT_TEXT_INPUT #define SDL_USEREVENT SDL_USEREVENT_renamed_SDL_EVENT_USER #define SDL_WINDOWEVENT SDL_WINDOWEVENT_deprecated_use_SDL_EVENT_WINDOW_NAME #define SDL_WINDOWEVENT_CLOSE SDL_WINDOWEVENT_CLOSE_renamed_SDL_EVENT_WINDOW_CLOSE_REQUESTED #define SDL_WINDOWEVENT_DISPLAY_CHANGED SDL_WINDOWEVENT_DISPLAY_CHANGED_renamed_SDL_EVENT_WINDOW_DISPLAY_CHANGED #define SDL_WINDOWEVENT_ENTER SDL_WINDOWEVENT_ENTER_renamed_SDL_EVENT_WINDOW_MOUSE_ENTER #define SDL_WINDOWEVENT_EXPOSED SDL_WINDOWEVENT_EXPOSED_renamed_SDL_EVENT_WINDOW_EXPOSED #define SDL_WINDOWEVENT_FOCUS_GAINED SDL_WINDOWEVENT_FOCUS_GAINED_renamed_SDL_EVENT_WINDOW_FOCUS_GAINED #define SDL_WINDOWEVENT_FOCUS_LOST SDL_WINDOWEVENT_FOCUS_LOST_renamed_SDL_EVENT_WINDOW_FOCUS_LOST #define SDL_WINDOWEVENT_HIDDEN SDL_WINDOWEVENT_HIDDEN_renamed_SDL_EVENT_WINDOW_HIDDEN #define SDL_WINDOWEVENT_HIT_TEST SDL_WINDOWEVENT_HIT_TEST_renamed_SDL_EVENT_WINDOW_HIT_TEST #define SDL_WINDOWEVENT_ICCPROF_CHANGED SDL_WINDOWEVENT_ICCPROF_CHANGED_renamed_SDL_EVENT_WINDOW_ICCPROF_CHANGED #define SDL_WINDOWEVENT_LEAVE SDL_WINDOWEVENT_LEAVE_renamed_SDL_EVENT_WINDOW_MOUSE_LEAVE #define SDL_WINDOWEVENT_MAXIMIZED SDL_WINDOWEVENT_MAXIMIZED_renamed_SDL_EVENT_WINDOW_MAXIMIZED #define SDL_WINDOWEVENT_MINIMIZED SDL_WINDOWEVENT_MINIMIZED_renamed_SDL_EVENT_WINDOW_MINIMIZED #define SDL_WINDOWEVENT_MOVED SDL_WINDOWEVENT_MOVED_renamed_SDL_EVENT_WINDOW_MOVED #define SDL_WINDOWEVENT_RESIZED SDL_WINDOWEVENT_RESIZED_renamed_SDL_EVENT_WINDOW_RESIZED #define SDL_WINDOWEVENT_RESTORED SDL_WINDOWEVENT_RESTORED_renamed_SDL_EVENT_WINDOW_RESTORED #define SDL_WINDOWEVENT_SHOWN SDL_WINDOWEVENT_SHOWN_renamed_SDL_EVENT_WINDOW_SHOWN #define SDL_WINDOWEVENT_SIZE_CHANGED SDL_WINDOWEVENT_SIZE_CHANGED_renamed_SDL_EVENT_WINDOW_PIXEL_SIZE_CHANGED #define SDL_eventaction SDL_eventaction_renamed_SDL_EventAction /* ##SDL_gamecontroller.h */ #define SDL_CONTROLLER_AXIS_INVALID SDL_CONTROLLER_AXIS_INVALID_renamed_SDL_GAMEPAD_AXIS_INVALID #define SDL_CONTROLLER_AXIS_LEFTX SDL_CONTROLLER_AXIS_LEFTX_renamed_SDL_GAMEPAD_AXIS_LEFTX #define SDL_CONTROLLER_AXIS_LEFTY SDL_CONTROLLER_AXIS_LEFTY_renamed_SDL_GAMEPAD_AXIS_LEFTY #define SDL_CONTROLLER_AXIS_MAX SDL_CONTROLLER_AXIS_MAX_renamed_SDL_GAMEPAD_AXIS_COUNT #define SDL_CONTROLLER_AXIS_RIGHTX SDL_CONTROLLER_AXIS_RIGHTX_renamed_SDL_GAMEPAD_AXIS_RIGHTX #define SDL_CONTROLLER_AXIS_RIGHTY SDL_CONTROLLER_AXIS_RIGHTY_renamed_SDL_GAMEPAD_AXIS_RIGHTY #define SDL_CONTROLLER_AXIS_TRIGGERLEFT SDL_CONTROLLER_AXIS_TRIGGERLEFT_renamed_SDL_GAMEPAD_AXIS_LEFT_TRIGGER #define SDL_CONTROLLER_AXIS_TRIGGERRIGHT SDL_CONTROLLER_AXIS_TRIGGERRIGHT_renamed_SDL_GAMEPAD_AXIS_RIGHT_TRIGGER #define SDL_CONTROLLER_BINDTYPE_AXIS SDL_CONTROLLER_BINDTYPE_AXIS_renamed_SDL_GAMEPAD_BINDTYPE_AXIS #define SDL_CONTROLLER_BINDTYPE_BUTTON SDL_CONTROLLER_BINDTYPE_BUTTON_renamed_SDL_GAMEPAD_BINDTYPE_BUTTON #define SDL_CONTROLLER_BINDTYPE_HAT SDL_CONTROLLER_BINDTYPE_HAT_renamed_SDL_GAMEPAD_BINDTYPE_HAT #define SDL_CONTROLLER_BINDTYPE_NONE SDL_CONTROLLER_BINDTYPE_NONE_renamed_SDL_GAMEPAD_BINDTYPE_NONE #define SDL_CONTROLLER_BUTTON_A SDL_CONTROLLER_BUTTON_A_renamed_SDL_GAMEPAD_BUTTON_SOUTH #define SDL_CONTROLLER_BUTTON_B SDL_CONTROLLER_BUTTON_B_renamed_SDL_GAMEPAD_BUTTON_EAST #define SDL_CONTROLLER_BUTTON_BACK SDL_CONTROLLER_BUTTON_BACK_renamed_SDL_GAMEPAD_BUTTON_BACK #define SDL_CONTROLLER_BUTTON_DPAD_DOWN SDL_CONTROLLER_BUTTON_DPAD_DOWN_renamed_SDL_GAMEPAD_BUTTON_DPAD_DOWN #define SDL_CONTROLLER_BUTTON_DPAD_LEFT SDL_CONTROLLER_BUTTON_DPAD_LEFT_renamed_SDL_GAMEPAD_BUTTON_DPAD_LEFT #define SDL_CONTROLLER_BUTTON_DPAD_RIGHT SDL_CONTROLLER_BUTTON_DPAD_RIGHT_renamed_SDL_GAMEPAD_BUTTON_DPAD_RIGHT #define SDL_CONTROLLER_BUTTON_DPAD_UP SDL_CONTROLLER_BUTTON_DPAD_UP_renamed_SDL_GAMEPAD_BUTTON_DPAD_UP #define SDL_CONTROLLER_BUTTON_GUIDE SDL_CONTROLLER_BUTTON_GUIDE_renamed_SDL_GAMEPAD_BUTTON_GUIDE #define SDL_CONTROLLER_BUTTON_INVALID SDL_CONTROLLER_BUTTON_INVALID_renamed_SDL_GAMEPAD_BUTTON_INVALID #define SDL_CONTROLLER_BUTTON_LEFTSHOULDER SDL_CONTROLLER_BUTTON_LEFTSHOULDER_renamed_SDL_GAMEPAD_BUTTON_LEFT_SHOULDER #define SDL_CONTROLLER_BUTTON_LEFTSTICK SDL_CONTROLLER_BUTTON_LEFTSTICK_renamed_SDL_GAMEPAD_BUTTON_LEFT_STICK #define SDL_CONTROLLER_BUTTON_MAX SDL_CONTROLLER_BUTTON_MAX_renamed_SDL_GAMEPAD_BUTTON_COUNT #define SDL_CONTROLLER_BUTTON_MISC1 SDL_CONTROLLER_BUTTON_MISC1_renamed_SDL_GAMEPAD_BUTTON_MISC1 #define SDL_CONTROLLER_BUTTON_PADDLE1 SDL_CONTROLLER_BUTTON_PADDLE1_renamed_SDL_GAMEPAD_BUTTON_RIGHT_PADDLE1 #define SDL_CONTROLLER_BUTTON_PADDLE2 SDL_CONTROLLER_BUTTON_PADDLE2_renamed_SDL_GAMEPAD_BUTTON_LEFT_PADDLE1 #define SDL_CONTROLLER_BUTTON_PADDLE3 SDL_CONTROLLER_BUTTON_PADDLE3_renamed_SDL_GAMEPAD_BUTTON_RIGHT_PADDLE2 #define SDL_CONTROLLER_BUTTON_PADDLE4 SDL_CONTROLLER_BUTTON_PADDLE4_renamed_SDL_GAMEPAD_BUTTON_LEFT_PADDLE2 #define SDL_CONTROLLER_BUTTON_RIGHTSHOULDER SDL_CONTROLLER_BUTTON_RIGHTSHOULDER_renamed_SDL_GAMEPAD_BUTTON_RIGHT_SHOULDER #define SDL_CONTROLLER_BUTTON_RIGHTSTICK SDL_CONTROLLER_BUTTON_RIGHTSTICK_renamed_SDL_GAMEPAD_BUTTON_RIGHT_STICK #define SDL_CONTROLLER_BUTTON_START SDL_CONTROLLER_BUTTON_START_renamed_SDL_GAMEPAD_BUTTON_START #define SDL_CONTROLLER_BUTTON_TOUCHPAD SDL_CONTROLLER_BUTTON_TOUCHPAD_renamed_SDL_GAMEPAD_BUTTON_TOUCHPAD #define SDL_CONTROLLER_BUTTON_X SDL_CONTROLLER_BUTTON_X_renamed_SDL_GAMEPAD_BUTTON_WEST #define SDL_CONTROLLER_BUTTON_Y SDL_CONTROLLER_BUTTON_Y_renamed_SDL_GAMEPAD_BUTTON_NORTH #define SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_JOYCON_LEFT SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_JOYCON_LEFT_renamed_SDL_GAMEPAD_TYPE_NINTENDO_SWITCH_JOYCON_LEFT #define SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_JOYCON_PAIR SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_JOYCON_PAIR_renamed_SDL_GAMEPAD_TYPE_NINTENDO_SWITCH_JOYCON_PAIR #define SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_JOYCON_RIGHT SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_JOYCON_RIGHT_renamed_SDL_GAMEPAD_TYPE_NINTENDO_SWITCH_JOYCON_RIGHT #define SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_PRO SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_PRO_renamed_SDL_GAMEPAD_TYPE_NINTENDO_SWITCH_PRO #define SDL_CONTROLLER_TYPE_PS3 SDL_CONTROLLER_TYPE_PS3_renamed_SDL_GAMEPAD_TYPE_PS3 #define SDL_CONTROLLER_TYPE_PS4 SDL_CONTROLLER_TYPE_PS4_renamed_SDL_GAMEPAD_TYPE_PS4 #define SDL_CONTROLLER_TYPE_PS5 SDL_CONTROLLER_TYPE_PS5_renamed_SDL_GAMEPAD_TYPE_PS5 #define SDL_CONTROLLER_TYPE_UNKNOWN SDL_CONTROLLER_TYPE_UNKNOWN_renamed_SDL_GAMEPAD_TYPE_STANDARD #define SDL_CONTROLLER_TYPE_VIRTUAL SDL_CONTROLLER_TYPE_VIRTUAL_renamed_SDL_GAMEPAD_TYPE_VIRTUAL #define SDL_CONTROLLER_TYPE_XBOX360 SDL_CONTROLLER_TYPE_XBOX360_renamed_SDL_GAMEPAD_TYPE_XBOX360 #define SDL_CONTROLLER_TYPE_XBOXONE SDL_CONTROLLER_TYPE_XBOXONE_renamed_SDL_GAMEPAD_TYPE_XBOXONE #define SDL_GameController SDL_GameController_renamed_SDL_Gamepad #define SDL_GameControllerAddMapping SDL_GameControllerAddMapping_renamed_SDL_AddGamepadMapping #define SDL_GameControllerAddMappingsFromFile SDL_GameControllerAddMappingsFromFile_renamed_SDL_AddGamepadMappingsFromFile #define SDL_GameControllerAddMappingsFromRW SDL_GameControllerAddMappingsFromRW_renamed_SDL_AddGamepadMappingsFromIO #define SDL_GameControllerAxis SDL_GameControllerAxis_renamed_SDL_GamepadAxis #define SDL_GameControllerBindType SDL_GameControllerBindType_renamed_SDL_GamepadBindingType #define SDL_GameControllerButton SDL_GameControllerButton_renamed_SDL_GamepadButton #define SDL_GameControllerClose SDL_GameControllerClose_renamed_SDL_CloseGamepad #define SDL_GameControllerEventState SDL_GameControllerEventState_deprecated_use_SDL_SetGamepadEventsEnabled_true_false #define SDL_GameControllerFromInstanceID SDL_GameControllerFromInstanceID_renamed_SDL_GetGamepadFromID #define SDL_GameControllerFromPlayerIndex SDL_GameControllerFromPlayerIndex_renamed_SDL_GetGamepadFromPlayerIndex #define SDL_GameControllerGetAppleSFSymbolsNameForAxis SDL_GameControllerGetAppleSFSymbolsNameForAxis_renamed_SDL_GetGamepadAppleSFSymbolsNameForAxis #define SDL_GameControllerGetAppleSFSymbolsNameForButton SDL_GameControllerGetAppleSFSymbolsNameForButton_renamed_SDL_GetGamepadAppleSFSymbolsNameForButton #define SDL_GameControllerGetAttached SDL_GameControllerGetAttached_renamed_SDL_GamepadConnected #define SDL_GameControllerGetAxis SDL_GameControllerGetAxis_renamed_SDL_GetGamepadAxis #define SDL_GameControllerGetAxisFromString SDL_GameControllerGetAxisFromString_renamed_SDL_GetGamepadAxisFromString #define SDL_GameControllerGetButton SDL_GameControllerGetButton_renamed_SDL_GetGamepadButton #define SDL_GameControllerGetButtonFromString SDL_GameControllerGetButtonFromString_renamed_SDL_GetGamepadButtonFromString #define SDL_GameControllerGetFirmwareVersion SDL_GameControllerGetFirmwareVersion_renamed_SDL_GetGamepadFirmwareVersion #define SDL_GameControllerGetJoystick SDL_GameControllerGetJoystick_renamed_SDL_GetGamepadJoystick #define SDL_GameControllerGetNumTouchpadFingers SDL_GameControllerGetNumTouchpadFingers_renamed_SDL_GetNumGamepadTouchpadFingers #define SDL_GameControllerGetNumTouchpads SDL_GameControllerGetNumTouchpads_renamed_SDL_GetNumGamepadTouchpads #define SDL_GameControllerGetPlayerIndex SDL_GameControllerGetPlayerIndex_renamed_SDL_GetGamepadPlayerIndex #define SDL_GameControllerGetProduct SDL_GameControllerGetProduct_renamed_SDL_GetGamepadProduct #define SDL_GameControllerGetProductVersion SDL_GameControllerGetProductVersion_renamed_SDL_GetGamepadProductVersion #define SDL_GameControllerGetSensorData SDL_GameControllerGetSensorData_renamed_SDL_GetGamepadSensorData #define SDL_GameControllerGetSensorDataRate SDL_GameControllerGetSensorDataRate_renamed_SDL_GetGamepadSensorDataRate #define SDL_GameControllerGetSerial SDL_GameControllerGetSerial_renamed_SDL_GetGamepadSerial #define SDL_GameControllerGetSteamHandle SDL_GameControllerGetSteamHandle_renamed_SDL_GetGamepadSteamHandle #define SDL_GameControllerGetStringForAxis SDL_GameControllerGetStringForAxis_renamed_SDL_GetGamepadStringForAxis #define SDL_GameControllerGetStringForButton SDL_GameControllerGetStringForButton_renamed_SDL_GetGamepadStringForButton #define SDL_GameControllerGetTouchpadFinger SDL_GameControllerGetTouchpadFinger_renamed_SDL_GetGamepadTouchpadFinger #define SDL_GameControllerGetType SDL_GameControllerGetType_renamed_SDL_GetGamepadType #define SDL_GameControllerGetVendor SDL_GameControllerGetVendor_renamed_SDL_GetGamepadVendor #define SDL_GameControllerHasAxis SDL_GameControllerHasAxis_renamed_SDL_GamepadHasAxis #define SDL_GameControllerHasButton SDL_GameControllerHasButton_renamed_SDL_GamepadHasButton #define SDL_GameControllerHasSensor SDL_GameControllerHasSensor_renamed_SDL_GamepadHasSensor #define SDL_GameControllerIsSensorEnabled SDL_GameControllerIsSensorEnabled_renamed_SDL_GamepadSensorEnabled #define SDL_GameControllerMapping SDL_GameControllerMapping_renamed_SDL_GetGamepadMapping #define SDL_GameControllerMappingForDeviceIndex SDL_GameControllerMappingForDeviceIndex_renamed_SDL_GetGamepadMappingForDeviceIndex #define SDL_GameControllerMappingForGUID SDL_GameControllerMappingForGUID_renamed_SDL_GetGamepadMappingForGUID #define SDL_GameControllerName SDL_GameControllerName_renamed_SDL_GetGamepadName #define SDL_GameControllerOpen SDL_GameControllerOpen_renamed_SDL_OpenGamepad #define SDL_GameControllerPath SDL_GameControllerPath_renamed_SDL_GetGamepadPath #define SDL_GameControllerRumble SDL_GameControllerRumble_renamed_SDL_RumbleGamepad #define SDL_GameControllerRumbleTriggers SDL_GameControllerRumbleTriggers_renamed_SDL_RumbleGamepadTriggers #define SDL_GameControllerSendEffect SDL_GameControllerSendEffect_renamed_SDL_SendGamepadEffect #define SDL_GameControllerSetLED SDL_GameControllerSetLED_renamed_SDL_SetGamepadLED #define SDL_GameControllerSetPlayerIndex SDL_GameControllerSetPlayerIndex_renamed_SDL_SetGamepadPlayerIndex #define SDL_GameControllerSetSensorEnabled SDL_GameControllerSetSensorEnabled_renamed_SDL_SetGamepadSensorEnabled #define SDL_GameControllerType SDL_GameControllerType_renamed_SDL_GamepadType #define SDL_GameControllerUpdate SDL_GameControllerUpdate_renamed_SDL_UpdateGamepads #define SDL_INIT_GAMECONTROLLER SDL_INIT_GAMECONTROLLER_renamed_SDL_INIT_GAMEPAD #define SDL_IsGameController SDL_IsGameController_renamed_SDL_IsGamepad /* ##SDL_guid.h */ #define SDL_GUIDFromString SDL_GUIDFromString_renamed_SDL_StringToGUID /* ##SDL_haptic.h */ #define SDL_HapticClose SDL_HapticClose_renamed_SDL_CloseHaptic #define SDL_HapticDestroyEffect SDL_HapticDestroyEffect_renamed_SDL_DestroyHapticEffect #define SDL_HapticGetEffectStatus SDL_HapticGetEffectStatus_renamed_SDL_GetHapticEffectStatus #define SDL_HapticNewEffect SDL_HapticNewEffect_renamed_SDL_CreateHapticEffect #define SDL_HapticNumAxes SDL_HapticNumAxes_renamed_SDL_GetNumHapticAxes #define SDL_HapticNumEffects SDL_HapticNumEffects_renamed_SDL_GetMaxHapticEffects #define SDL_HapticNumEffectsPlaying SDL_HapticNumEffectsPlaying_renamed_SDL_GetMaxHapticEffectsPlaying #define SDL_HapticOpen SDL_HapticOpen_renamed_SDL_OpenHaptic #define SDL_HapticOpenFromJoystick SDL_HapticOpenFromJoystick_renamed_SDL_OpenHapticFromJoystick #define SDL_HapticOpenFromMouse SDL_HapticOpenFromMouse_renamed_SDL_OpenHapticFromMouse #define SDL_HapticPause SDL_HapticPause_renamed_SDL_PauseHaptic #define SDL_HapticQuery SDL_HapticQuery_renamed_SDL_GetHapticFeatures #define SDL_HapticRumbleInit SDL_HapticRumbleInit_renamed_SDL_InitHapticRumble #define SDL_HapticRumblePlay SDL_HapticRumblePlay_renamed_SDL_PlayHapticRumble #define SDL_HapticRumbleStop SDL_HapticRumbleStop_renamed_SDL_StopHapticRumble #define SDL_HapticRunEffect SDL_HapticRunEffect_renamed_SDL_RunHapticEffect #define SDL_HapticSetAutocenter SDL_HapticSetAutocenter_renamed_SDL_SetHapticAutocenter #define SDL_HapticSetGain SDL_HapticSetGain_renamed_SDL_SetHapticGain #define SDL_HapticStopAll SDL_HapticStopAll_renamed_SDL_StopHapticEffects #define SDL_HapticStopEffect SDL_HapticStopEffect_renamed_SDL_StopHapticEffect #define SDL_HapticUnpause SDL_HapticUnpause_renamed_SDL_ResumeHaptic #define SDL_HapticUpdateEffect SDL_HapticUpdateEffect_renamed_SDL_UpdateHapticEffect #define SDL_JoystickIsHaptic SDL_JoystickIsHaptic_renamed_SDL_IsJoystickHaptic #define SDL_MouseIsHaptic SDL_MouseIsHaptic_renamed_SDL_IsMouseHaptic /* ##SDL_hints.h */ #define SDL_DelHintCallback SDL_DelHintCallback_renamed_SDL_RemoveHintCallback #define SDL_HINT_ACCELEROMETER_AS_JOYSTICK SDL_HINT_ACCELEROMETER_AS_JOYSTICK_deprecated_use_SDL_GamepadHasSensor_and_SDL_SetGamepadSensorEnabled #define SDL_HINT_ALLOW_TOPMOST SDL_HINT_ALLOW_TOPMOST_renamed_SDL_HINT_WINDOW_ALLOW_TOPMOST #define SDL_HINT_DIRECTINPUT_ENABLED SDL_HINT_DIRECTINPUT_ENABLED_renamed_SDL_HINT_JOYSTICK_DIRECTINPUT #define SDL_HINT_GDK_TEXTINPUT_DEFAULT SDL_HINT_GDK_TEXTINPUT_DEFAULT_renamed_SDL_HINT_GDK_TEXTINPUT_DEFAULT_TEXT #define SDL_HINT_JOYSTICK_GAMECUBE_RUMBLE_BRAKE SDL_HINT_JOYSTICK_GAMECUBE_RUMBLE_BRAKE_renamed_SDL_HINT_JOYSTICK_HIDAPI_GAMECUBE_RUMBLE_BRAKE #define SDL_HINT_JOYSTICK_HIDAPI_PS4_RUMBLE SDL_HINT_JOYSTICK_HIDAPI_PS4_RUMBLE_renamed_SDL_HINT_JOYSTICK_ENHANCED_REPORTS #define SDL_HINT_JOYSTICK_HIDAPI_PS5_RUMBLE SDL_HINT_JOYSTICK_HIDAPI_PS5_RUMBLE_renamed_SDL_HINT_JOYSTICK_ENHANCED_REPORTS #define SDL_HINT_LINUX_DIGITAL_HATS SDL_HINT_LINUX_DIGITAL_HATS_renamed_SDL_HINT_JOYSTICK_LINUX_DIGITAL_HATS #define SDL_HINT_LINUX_HAT_DEADZONES SDL_HINT_LINUX_HAT_DEADZONES_renamed_SDL_HINT_JOYSTICK_LINUX_HAT_DEADZONES #define SDL_HINT_LINUX_JOYSTICK_CLASSIC SDL_HINT_LINUX_JOYSTICK_CLASSIC_renamed_SDL_HINT_JOYSTICK_LINUX_CLASSIC #define SDL_HINT_LINUX_JOYSTICK_DEADZONES SDL_HINT_LINUX_JOYSTICK_DEADZONES_renamed_SDL_HINT_JOYSTICK_LINUX_DEADZONES #define SDL_HINT_RENDER_SCALE_QUALITY SDL_HINT_RENDER_SCALE_QUALITY_deprecated_use_SDL_SetTextureScaleMode_with_SDL_SCALEMODE_NEAREST #define SDL_HINT_WINDOWS_FORCE_MUTEX_CRITICAL_SECTIONS SDL_HINT_WINDOWS_FORCE_MUTEX_CRITICAL_SECTIONS_deprecated_remove_this_line /* ##SDL_joystick.h */ #define SDL_JOYSTICK_TYPE_GAMECONTROLLER SDL_JOYSTICK_TYPE_GAMECONTROLLER_renamed_SDL_JOYSTICK_TYPE_GAMEPAD #define SDL_JoystickAttachVirtualEx SDL_JoystickAttachVirtualEx_renamed_SDL_AttachVirtualJoystick #define SDL_JoystickClose SDL_JoystickClose_renamed_SDL_CloseJoystick #define SDL_JoystickDetachVirtual SDL_JoystickDetachVirtual_renamed_SDL_DetachVirtualJoystick #define SDL_JoystickFromInstanceID SDL_JoystickFromInstanceID_renamed_SDL_GetJoystickFromID #define SDL_JoystickFromPlayerIndex SDL_JoystickFromPlayerIndex_renamed_SDL_GetJoystickFromPlayerIndex #define SDL_JoystickGUID SDL_JoystickGUID_renamed_SDL_GUID #define SDL_JoystickGetAttached SDL_JoystickGetAttached_renamed_SDL_JoystickConnected #define SDL_JoystickGetAxis SDL_JoystickGetAxis_renamed_SDL_GetJoystickAxis #define SDL_JoystickGetAxisInitialState SDL_JoystickGetAxisInitialState_renamed_SDL_GetJoystickAxisInitialState #define SDL_JoystickGetBall SDL_JoystickGetBall_renamed_SDL_GetJoystickBall #define SDL_JoystickGetButton SDL_JoystickGetButton_renamed_SDL_GetJoystickButton #define SDL_JoystickGetFirmwareVersion SDL_JoystickGetFirmwareVersion_renamed_SDL_GetJoystickFirmwareVersion #define SDL_JoystickGetGUID SDL_JoystickGetGUID_renamed_SDL_GetJoystickGUID #define SDL_JoystickGetGUIDFromString SDL_JoystickGetGUIDFromString_renamed_SDL_GUIDFromString #define SDL_JoystickGetHat SDL_JoystickGetHat_renamed_SDL_GetJoystickHat #define SDL_JoystickGetPlayerIndex SDL_JoystickGetPlayerIndex_renamed_SDL_GetJoystickPlayerIndex #define SDL_JoystickGetProduct SDL_JoystickGetProduct_renamed_SDL_GetJoystickProduct #define SDL_JoystickGetProductVersion SDL_JoystickGetProductVersion_renamed_SDL_GetJoystickProductVersion #define SDL_JoystickGetSerial SDL_JoystickGetSerial_renamed_SDL_GetJoystickSerial #define SDL_JoystickGetType SDL_JoystickGetType_renamed_SDL_GetJoystickType #define SDL_JoystickGetVendor SDL_JoystickGetVendor_renamed_SDL_GetJoystickVendor #define SDL_JoystickInstanceID SDL_JoystickInstanceID_renamed_SDL_GetJoystickID #define SDL_JoystickIsVirtual SDL_JoystickIsVirtual_renamed_SDL_IsJoystickVirtual #define SDL_JoystickName SDL_JoystickName_renamed_SDL_GetJoystickName #define SDL_JoystickNumAxes SDL_JoystickNumAxes_renamed_SDL_GetNumJoystickAxes #define SDL_JoystickNumBalls SDL_JoystickNumBalls_renamed_SDL_GetNumJoystickBalls #define SDL_JoystickNumButtons SDL_JoystickNumButtons_renamed_SDL_GetNumJoystickButtons #define SDL_JoystickNumHats SDL_JoystickNumHats_renamed_SDL_GetNumJoystickHats #define SDL_JoystickOpen SDL_JoystickOpen_renamed_SDL_OpenJoystick #define SDL_JoystickPath SDL_JoystickPath_renamed_SDL_GetJoystickPath #define SDL_JoystickRumble SDL_JoystickRumble_renamed_SDL_RumbleJoystick #define SDL_JoystickRumbleTriggers SDL_JoystickRumbleTriggers_renamed_SDL_RumbleJoystickTriggers #define SDL_JoystickSendEffect SDL_JoystickSendEffect_renamed_SDL_SendJoystickEffect #define SDL_JoystickSetLED SDL_JoystickSetLED_renamed_SDL_SetJoystickLED #define SDL_JoystickSetPlayerIndex SDL_JoystickSetPlayerIndex_renamed_SDL_SetJoystickPlayerIndex #define SDL_JoystickSetVirtualAxis SDL_JoystickSetVirtualAxis_renamed_SDL_SetJoystickVirtualAxis #define SDL_JoystickSetVirtualButton SDL_JoystickSetVirtualButton_renamed_SDL_SetJoystickVirtualButton #define SDL_JoystickSetVirtualHat SDL_JoystickSetVirtualHat_renamed_SDL_SetJoystickVirtualHat #define SDL_JoystickUpdate SDL_JoystickUpdate_renamed_SDL_UpdateJoysticks #define SDL_NumJoysticks SDL_NumJoysticks_deprecated_use_SDL_GetJoysticks /* ##SDL_keyboard.h */ #define SDL_IsScreenKeyboardShown SDL_IsScreenKeyboardShown_renamed_SDL_ScreenKeyboardShown #define SDL_IsTextInputActive SDL_IsTextInputActive_renamed_SDL_TextInputActive /* ##SDL_keycode.h */ #define KMOD_ALT KMOD_ALT_renamed_SDL_KMOD_ALT #define KMOD_CAPS KMOD_CAPS_renamed_SDL_KMOD_CAPS #define KMOD_CTRL KMOD_CTRL_renamed_SDL_KMOD_CTRL #define KMOD_GUI KMOD_GUI_renamed_SDL_KMOD_GUI #define KMOD_LALT KMOD_LALT_renamed_SDL_KMOD_LALT #define KMOD_LCTRL KMOD_LCTRL_renamed_SDL_KMOD_LCTRL #define KMOD_LGUI KMOD_LGUI_renamed_SDL_KMOD_LGUI #define KMOD_LSHIFT KMOD_LSHIFT_renamed_SDL_KMOD_LSHIFT #define KMOD_MODE KMOD_MODE_renamed_SDL_KMOD_MODE #define KMOD_NONE KMOD_NONE_renamed_SDL_KMOD_NONE #define KMOD_NUM KMOD_NUM_renamed_SDL_KMOD_NUM #define KMOD_RALT KMOD_RALT_renamed_SDL_KMOD_RALT #define KMOD_RCTRL KMOD_RCTRL_renamed_SDL_KMOD_RCTRL #define KMOD_RGUI KMOD_RGUI_renamed_SDL_KMOD_RGUI #define KMOD_RSHIFT KMOD_RSHIFT_renamed_SDL_KMOD_RSHIFT #define KMOD_SCROLL KMOD_SCROLL_renamed_SDL_KMOD_SCROLL #define KMOD_SHIFT KMOD_SHIFT_renamed_SDL_KMOD_SHIFT #define SDLK_AUDIOFASTFORWARD SDLK_AUDIOFASTFORWARD_renamed_SDLK_MEDIA_FAST_FORWARD #define SDLK_AUDIOMUTE SDLK_AUDIOMUTE_renamed_SDLK_MUTE #define SDLK_AUDIONEXT SDLK_AUDIONEXT_renamed_SDLK_MEDIA_NEXT_TRACK #define SDLK_AUDIOPLAY SDLK_AUDIOPLAY_renamed_SDLK_MEDIA_PLAY #define SDLK_AUDIOPREV SDLK_AUDIOPREV_renamed_SDLK_MEDIA_PREVIOUS_TRACK #define SDLK_AUDIOREWIND SDLK_AUDIOREWIND_renamed_SDLK_MEDIA_REWIND #define SDLK_AUDIOSTOP SDLK_AUDIOSTOP_renamed_SDLK_MEDIA_STOP #define SDLK_BACKQUOTE SDLK_BACKQUOTE_renamed_SDLK_GRAVE #define SDLK_EJECT SDLK_EJECT_renamed_SDLK_MEDIA_EJECT #define SDLK_MEDIASELECT SDLK_MEDIASELECT_renamed_SDLK_MEDIA_SELECT #define SDLK_QUOTE SDLK_QUOTE_renamed_SDLK_APOSTROPHE #define SDLK_QUOTEDBL SDLK_QUOTEDBL_renamed_SDLK_DBLAPOSTROPHE #define SDLK_a SDLK_a_renamed_SDLK_A #define SDLK_b SDLK_b_renamed_SDLK_B #define SDLK_c SDLK_c_renamed_SDLK_C #define SDLK_d SDLK_d_renamed_SDLK_D #define SDLK_e SDLK_e_renamed_SDLK_E #define SDLK_f SDLK_f_renamed_SDLK_F #define SDLK_g SDLK_g_renamed_SDLK_G #define SDLK_h SDLK_h_renamed_SDLK_H #define SDLK_i SDLK_i_renamed_SDLK_I #define SDLK_j SDLK_j_renamed_SDLK_J #define SDLK_k SDLK_k_renamed_SDLK_K #define SDLK_l SDLK_l_renamed_SDLK_L #define SDLK_m SDLK_m_renamed_SDLK_M #define SDLK_n SDLK_n_renamed_SDLK_N #define SDLK_o SDLK_o_renamed_SDLK_O #define SDLK_p SDLK_p_renamed_SDLK_P #define SDLK_q SDLK_q_renamed_SDLK_Q #define SDLK_r SDLK_r_renamed_SDLK_R #define SDLK_s SDLK_s_renamed_SDLK_S #define SDLK_t SDLK_t_renamed_SDLK_T #define SDLK_u SDLK_u_renamed_SDLK_U #define SDLK_v SDLK_v_renamed_SDLK_V #define SDLK_w SDLK_w_renamed_SDLK_W #define SDLK_x SDLK_x_renamed_SDLK_X #define SDLK_y SDLK_y_renamed_SDLK_Y #define SDLK_z SDLK_z_renamed_SDLK_Z /* ##SDL_log.h */ #define SDL_LogGetOutputFunction SDL_LogGetOutputFunction_renamed_SDL_GetLogOutputFunction #define SDL_LogGetPriority SDL_LogGetPriority_renamed_SDL_GetLogPriority #define SDL_LogResetPriorities SDL_LogResetPriorities_renamed_SDL_ResetLogPriorities #define SDL_LogSetAllPriority SDL_LogSetAllPriority_renamed_SDL_SetLogPriorities #define SDL_LogSetOutputFunction SDL_LogSetOutputFunction_renamed_SDL_SetLogOutputFunction #define SDL_LogSetPriority SDL_LogSetPriority_renamed_SDL_SetLogPriority #define SDL_NUM_LOG_PRIORITIES SDL_NUM_LOG_PRIORITIES_renamed_SDL_LOG_PRIORITY_COUNT /* ##SDL_messagebox.h */ #define SDL_MESSAGEBOX_COLOR_MAX SDL_MESSAGEBOX_COLOR_MAX_renamed_SDL_MESSAGEBOX_COLOR_COUNT /* ##SDL_mouse.h */ #define SDL_BUTTON SDL_BUTTON_renamed_SDL_BUTTON_MASK #define SDL_FreeCursor SDL_FreeCursor_renamed_SDL_DestroyCursor #define SDL_NUM_SYSTEM_CURSORS SDL_NUM_SYSTEM_CURSORS_renamed_SDL_SYSTEM_CURSOR_COUNT #define SDL_SYSTEM_CURSOR_ARROW SDL_SYSTEM_CURSOR_ARROW_renamed_SDL_SYSTEM_CURSOR_DEFAULT #define SDL_SYSTEM_CURSOR_HAND SDL_SYSTEM_CURSOR_HAND_renamed_SDL_SYSTEM_CURSOR_POINTER #define SDL_SYSTEM_CURSOR_IBEAM SDL_SYSTEM_CURSOR_IBEAM_renamed_SDL_SYSTEM_CURSOR_TEXT #define SDL_SYSTEM_CURSOR_NO SDL_SYSTEM_CURSOR_NO_renamed_SDL_SYSTEM_CURSOR_NOT_ALLOWED #define SDL_SYSTEM_CURSOR_SIZEALL SDL_SYSTEM_CURSOR_SIZEALL_renamed_SDL_SYSTEM_CURSOR_MOVE #define SDL_SYSTEM_CURSOR_SIZENESW SDL_SYSTEM_CURSOR_SIZENESW_renamed_SDL_SYSTEM_CURSOR_NESW_RESIZE #define SDL_SYSTEM_CURSOR_SIZENS SDL_SYSTEM_CURSOR_SIZENS_renamed_SDL_SYSTEM_CURSOR_NS_RESIZE #define SDL_SYSTEM_CURSOR_SIZENWSE SDL_SYSTEM_CURSOR_SIZENWSE_renamed_SDL_SYSTEM_CURSOR_NWSE_RESIZE #define SDL_SYSTEM_CURSOR_SIZEWE SDL_SYSTEM_CURSOR_SIZEWE_renamed_SDL_SYSTEM_CURSOR_EW_RESIZE #define SDL_SYSTEM_CURSOR_WAITARROW SDL_SYSTEM_CURSOR_WAITARROW_renamed_SDL_SYSTEM_CURSOR_PROGRESS #define SDL_SYSTEM_CURSOR_WINDOW_BOTTOM SDL_SYSTEM_CURSOR_WINDOW_BOTTOM_renamed_SDL_SYSTEM_CURSOR_S_RESIZE #define SDL_SYSTEM_CURSOR_WINDOW_BOTTOMLEFT SDL_SYSTEM_CURSOR_WINDOW_BOTTOMLEFT_renamed_SDL_SYSTEM_CURSOR_SW_RESIZE #define SDL_SYSTEM_CURSOR_WINDOW_BOTTOMRIGHT SDL_SYSTEM_CURSOR_WINDOW_BOTTOMRIGHT_renamed_SDL_SYSTEM_CURSOR_SE_RESIZE #define SDL_SYSTEM_CURSOR_WINDOW_LEFT SDL_SYSTEM_CURSOR_WINDOW_LEFT_renamed_SDL_SYSTEM_CURSOR_W_RESIZE #define SDL_SYSTEM_CURSOR_WINDOW_RIGHT SDL_SYSTEM_CURSOR_WINDOW_RIGHT_renamed_SDL_SYSTEM_CURSOR_E_RESIZE #define SDL_SYSTEM_CURSOR_WINDOW_TOP SDL_SYSTEM_CURSOR_WINDOW_TOP_renamed_SDL_SYSTEM_CURSOR_N_RESIZE #define SDL_SYSTEM_CURSOR_WINDOW_TOPLEFT SDL_SYSTEM_CURSOR_WINDOW_TOPLEFT_renamed_SDL_SYSTEM_CURSOR_NW_RESIZE #define SDL_SYSTEM_CURSOR_WINDOW_TOPRIGHT SDL_SYSTEM_CURSOR_WINDOW_TOPRIGHT_renamed_SDL_SYSTEM_CURSOR_NE_RESIZE /* ##SDL_mutex.h */ #define SDL_CondBroadcast SDL_CondBroadcast_renamed_SDL_BroadcastCondition #define SDL_CondSignal SDL_CondSignal_renamed_SDL_SignalCondition #define SDL_CondWait SDL_CondWait_renamed_SDL_WaitCondition #define SDL_CondWaitTimeout SDL_CondWaitTimeout_renamed_SDL_WaitConditionTimeout #define SDL_CreateCond SDL_CreateCond_renamed_SDL_CreateCondition #define SDL_DestroyCond SDL_DestroyCond_renamed_SDL_DestroyCondition #define SDL_SemPost SDL_SemPost_renamed_SDL_SignalSemaphore #define SDL_SemTryWait SDL_SemTryWait_renamed_SDL_TryWaitSemaphore #define SDL_SemValue SDL_SemValue_renamed_SDL_GetSemaphoreValue #define SDL_SemWait SDL_SemWait_renamed_SDL_WaitSemaphore #define SDL_SemWaitTimeout SDL_SemWaitTimeout_renamed_SDL_WaitSemaphoreTimeout /* ##SDL_mutex.h */ #define SDL_cond SDL_cond_renamed_SDL_Condition #define SDL_mutex SDL_mutex_renamed_SDL_Mutex #define SDL_sem SDL_sem_renamed_SDL_Semaphore /* ##SDL_pixels.h */ #define SDL_AllocFormat SDL_AllocFormat_renamed_SDL_GetPixelFormatDetails #define SDL_AllocPalette SDL_AllocPalette_renamed_SDL_CreatePalette #define SDL_Colour SDL_Colour_renamed_SDL_Color #define SDL_FreePalette SDL_FreePalette_renamed_SDL_DestroyPalette #define SDL_MasksToPixelFormatEnum SDL_MasksToPixelFormatEnum_renamed_SDL_GetPixelFormatForMasks #define SDL_PIXELFORMAT_BGR444 SDL_PIXELFORMAT_BGR444_renamed_SDL_PIXELFORMAT_XBGR4444 #define SDL_PIXELFORMAT_BGR555 SDL_PIXELFORMAT_BGR555_renamed_SDL_PIXELFORMAT_XBGR1555 #define SDL_PIXELFORMAT_BGR888 SDL_PIXELFORMAT_BGR888_renamed_SDL_PIXELFORMAT_XBGR8888 #define SDL_PIXELFORMAT_RGB444 SDL_PIXELFORMAT_RGB444_renamed_SDL_PIXELFORMAT_XRGB4444 #define SDL_PIXELFORMAT_RGB555 SDL_PIXELFORMAT_RGB555_renamed_SDL_PIXELFORMAT_XRGB1555 #define SDL_PIXELFORMAT_RGB888 SDL_PIXELFORMAT_RGB888_renamed_SDL_PIXELFORMAT_XRGB8888 #define SDL_PixelFormatEnumToMasks SDL_PixelFormatEnumToMasks_renamed_SDL_GetMasksForPixelFormat /* ##SDL_rect.h */ #define SDL_EncloseFPoints SDL_EncloseFPoints_renamed_SDL_GetRectEnclosingPointsFloat #define SDL_EnclosePoints SDL_EnclosePoints_renamed_SDL_GetRectEnclosingPoints #define SDL_FRectEmpty SDL_FRectEmpty_renamed_SDL_RectEmptyFloat #define SDL_FRectEquals SDL_FRectEquals_renamed_SDL_RectsEqualFloat #define SDL_FRectEqualsEpsilon SDL_FRectEqualsEpsilon_renamed_SDL_RectsEqualEpsilon #define SDL_HasIntersection SDL_HasIntersection_renamed_SDL_HasRectIntersection #define SDL_HasIntersectionF SDL_HasIntersectionF_renamed_SDL_HasRectIntersectionFloat #define SDL_IntersectFRect SDL_IntersectFRect_renamed_SDL_GetRectIntersectionFloat #define SDL_IntersectFRectAndLine SDL_IntersectFRectAndLine_renamed_SDL_GetRectAndLineIntersectionFloat #define SDL_IntersectRect SDL_IntersectRect_renamed_SDL_GetRectIntersection #define SDL_IntersectRectAndLine SDL_IntersectRectAndLine_renamed_SDL_GetRectAndLineIntersection #define SDL_PointInFRect SDL_PointInFRect_renamed_SDL_PointInRectFloat #define SDL_RectEquals SDL_RectEquals_renamed_SDL_RectsEqual #define SDL_UnionFRect SDL_UnionFRect_renamed_SDL_GetRectUnionFloat #define SDL_UnionRect SDL_UnionRect_renamed_SDL_GetRectUnion /* ##SDL_render.h */ #define SDL_GetRendererOutputSize SDL_GetRendererOutputSize_renamed_SDL_GetCurrentRenderOutputSize #define SDL_RENDERER_ACCELERATED SDL_RENDERER_ACCELERATED_deprecated_remove_this_line #define SDL_RENDERER_PRESENTVSYNC SDL_RENDERER_PRESENTVSYNC_deprecated_use_SDL_SetRenderVSync #define SDL_RenderCopy SDL_RenderCopy_renamed_SDL_RenderTexture #define SDL_RenderCopyEx SDL_RenderCopyEx_renamed_SDL_RenderTextureRotated #define SDL_RenderCopyExF SDL_RenderCopyExF_renamed_SDL_RenderTextureRotated #define SDL_RenderCopyF SDL_RenderCopyF_renamed_SDL_RenderTexture #define SDL_RenderDrawLine SDL_RenderDrawLine_renamed_SDL_RenderLine #define SDL_RenderDrawLineF SDL_RenderDrawLineF_renamed_SDL_RenderLine #define SDL_RenderDrawLines SDL_RenderDrawLines_renamed_SDL_RenderLines #define SDL_RenderDrawLinesF SDL_RenderDrawLinesF_renamed_SDL_RenderLines #define SDL_RenderDrawPoint SDL_RenderDrawPoint_renamed_SDL_RenderPoint #define SDL_RenderDrawPointF SDL_RenderDrawPointF_renamed_SDL_RenderPoint #define SDL_RenderDrawPoints SDL_RenderDrawPoints_renamed_SDL_RenderPoints #define SDL_RenderDrawPointsF SDL_RenderDrawPointsF_renamed_SDL_RenderPoints #define SDL_RenderDrawRect SDL_RenderDrawRect_renamed_SDL_RenderRect #define SDL_RenderDrawRectF SDL_RenderDrawRectF_renamed_SDL_RenderRect #define SDL_RenderDrawRects SDL_RenderDrawRects_renamed_SDL_RenderRects #define SDL_RenderDrawRectsF SDL_RenderDrawRectsF_renamed_SDL_RenderRects #define SDL_RenderFillRectF SDL_RenderFillRectF_renamed_SDL_RenderFillRect #define SDL_RenderFillRectsF SDL_RenderFillRectsF_renamed_SDL_RenderFillRects #define SDL_RendererFlip SDL_RendererFlip_renamed_SDL_FlipMode #define SDL_RenderFlush SDL_RenderFlush_renamed_SDL_FlushRenderer #define SDL_RenderGetClipRect SDL_RenderGetClipRect_renamed_SDL_GetRenderClipRect #define SDL_RenderGetLogicalSize SDL_RenderGetLogicalSize_renamed_SDL_GetRenderLogicalPresentation #define SDL_RenderGetMetalCommandEncoder SDL_RenderGetMetalCommandEncoder_renamed_SDL_GetRenderMetalCommandEncoder #define SDL_RenderGetMetalLayer SDL_RenderGetMetalLayer_renamed_SDL_GetRenderMetalLayer #define SDL_RenderGetScale SDL_RenderGetScale_renamed_SDL_GetRenderScale #define SDL_RenderGetViewport SDL_RenderGetViewport_renamed_SDL_GetRenderViewport #define SDL_RenderGetWindow SDL_RenderGetWindow_renamed_SDL_GetRenderWindow #define SDL_RenderIsClipEnabled SDL_RenderIsClipEnabled_renamed_SDL_RenderClipEnabled #define SDL_RenderLogicalToWindow SDL_RenderLogicalToWindow_renamed_SDL_RenderCoordinatesToWindow #define SDL_RenderSetClipRect SDL_RenderSetClipRect_renamed_SDL_SetRenderClipRect #define SDL_RenderSetLogicalSize SDL_RenderSetLogicalSize_renamed_SDL_SetRenderLogicalPresentation #define SDL_RenderSetScale SDL_RenderSetScale_renamed_SDL_SetRenderScale #define SDL_RenderSetVSync SDL_RenderSetVSync_renamed_SDL_SetRenderVSync #define SDL_RenderSetViewport SDL_RenderSetViewport_renamed_SDL_SetRenderViewport #define SDL_RenderWindowToLogical SDL_RenderWindowToLogical_renamed_SDL_RenderCoordinatesFromWindow #define SDL_ScaleModeLinear SDL_ScaleModeLinear_renamed_SDL_SCALEMODE_LINEAR #define SDL_ScaleModeNearest SDL_ScaleModeNearest_renamed_SDL_SCALEMODE_NEAREST /* ##SDL_rwops.h */ #define RW_SEEK_CUR RW_SEEK_CUR_renamed_SDL_IO_SEEK_CUR #define RW_SEEK_END RW_SEEK_END_renamed_SDL_IO_SEEK_END #define RW_SEEK_SET RW_SEEK_SET_renamed_SDL_IO_SEEK_SET #define SDL_RWFromConstMem SDL_RWFromConstMem_renamed_SDL_IOFromConstMem #define SDL_RWFromFile SDL_RWFromFile_renamed_SDL_IOFromFile #define SDL_RWFromMem SDL_RWFromMem_renamed_SDL_IOFromMem #define SDL_RWclose SDL_RWclose_renamed_SDL_CloseIO #define SDL_RWops SDL_RWops_renamed_SDL_IOStream #define SDL_RWread SDL_RWread_renamed_SDL_ReadIO #define SDL_RWseek SDL_RWseek_renamed_SDL_SeekIO #define SDL_RWsize SDL_RWsize_renamed_SDL_GetIOSize #define SDL_RWtell SDL_RWtell_renamed_SDL_TellIO #define SDL_RWwrite SDL_RWwrite_renamed_SDL_WriteIO #define SDL_ReadBE16 SDL_ReadBE16_renamed_SDL_ReadU16BE #define SDL_ReadBE32 SDL_ReadBE32_renamed_SDL_ReadU32BE #define SDL_ReadBE64 SDL_ReadBE64_renamed_SDL_ReadU64BE #define SDL_ReadLE16 SDL_ReadLE16_renamed_SDL_ReadU16LE #define SDL_ReadLE32 SDL_ReadLE32_renamed_SDL_ReadU32LE #define SDL_ReadLE64 SDL_ReadLE64_renamed_SDL_ReadU64LE #define SDL_WriteBE16 SDL_WriteBE16_renamed_SDL_WriteU16BE #define SDL_WriteBE32 SDL_WriteBE32_renamed_SDL_WriteU32BE #define SDL_WriteBE64 SDL_WriteBE64_renamed_SDL_WriteU64BE #define SDL_WriteLE16 SDL_WriteLE16_renamed_SDL_WriteU16LE #define SDL_WriteLE32 SDL_WriteLE32_renamed_SDL_WriteU32LE #define SDL_WriteLE64 SDL_WriteLE64_renamed_SDL_WriteU64LE /* ##SDL_scancode.h */ #define SDL_NUM_SCANCODES SDL_NUM_SCANCODES_renamed_SDL_SCANCODE_COUNT #define SDL_SCANCODE_AUDIOFASTFORWARD SDL_SCANCODE_AUDIOFASTFORWARD_renamed_SDL_SCANCODE_MEDIA_FAST_FORWARD #define SDL_SCANCODE_AUDIOMUTE SDL_SCANCODE_AUDIOMUTE_renamed_SDL_SCANCODE_MUTE #define SDL_SCANCODE_AUDIONEXT SDL_SCANCODE_AUDIONEXT_renamed_SDL_SCANCODE_MEDIA_NEXT_TRACK #define SDL_SCANCODE_AUDIOPLAY SDL_SCANCODE_AUDIOPLAY_renamed_SDL_SCANCODE_MEDIA_PLAY #define SDL_SCANCODE_AUDIOPREV SDL_SCANCODE_AUDIOPREV_renamed_SDL_SCANCODE_MEDIA_PREVIOUS_TRACK #define SDL_SCANCODE_AUDIOREWIND SDL_SCANCODE_AUDIOREWIND_renamed_SDL_SCANCODE_MEDIA_REWIND #define SDL_SCANCODE_AUDIOSTOP SDL_SCANCODE_AUDIOSTOP_renamed_SDL_SCANCODE_MEDIA_STOP #define SDL_SCANCODE_EJECT SDL_SCANCODE_EJECT_renamed_SDL_SCANCODE_MEDIA_EJECT #define SDL_SCANCODE_MEDIASELECT SDL_SCANCODE_MEDIASELECT_renamed_SDL_SCANCODE_MEDIA_SELECT /* ##SDL_sensor.h */ #define SDL_SensorClose SDL_SensorClose_renamed_SDL_CloseSensor #define SDL_SensorFromInstanceID SDL_SensorFromInstanceID_renamed_SDL_GetSensorFromID #define SDL_SensorGetData SDL_SensorGetData_renamed_SDL_GetSensorData #define SDL_SensorGetInstanceID SDL_SensorGetInstanceID_renamed_SDL_GetSensorID #define SDL_SensorGetName SDL_SensorGetName_renamed_SDL_GetSensorName #define SDL_SensorGetNonPortableType SDL_SensorGetNonPortableType_renamed_SDL_GetSensorNonPortableType #define SDL_SensorGetType SDL_SensorGetType_renamed_SDL_GetSensorType #define SDL_SensorOpen SDL_SensorOpen_renamed_SDL_OpenSensor #define SDL_SensorUpdate SDL_SensorUpdate_renamed_SDL_UpdateSensors /* ##SDL_stdinc.h */ #define SDL_FALSE SDL_FALSE_renamed_false #define SDL_TABLESIZE SDL_TABLESIZE_renamed_SDL_arraysize #define SDL_TRUE SDL_TRUE_renamed_true #define SDL_bool SDL_bool_renamed_bool #define SDL_size_add_overflow SDL_size_add_overflow_renamed_SDL_size_add_check_overflow #define SDL_size_mul_overflow SDL_size_mul_overflow_renamed_SDL_size_mul_check_overflow #define SDL_strtokr SDL_strtokr_renamed_SDL_strtok_r /* ##SDL_surface.h */ #define SDL_BlitScaled SDL_BlitScaled_renamed_SDL_BlitSurfaceScaled #define SDL_ConvertSurfaceFormat SDL_ConvertSurfaceFormat_renamed_SDL_ConvertSurface #define SDL_FillRect SDL_FillRect_renamed_SDL_FillSurfaceRect #define SDL_FillRects SDL_FillRects_renamed_SDL_FillSurfaceRects #define SDL_FreeSurface SDL_FreeSurface_renamed_SDL_DestroySurface #define SDL_GetClipRect SDL_GetClipRect_renamed_SDL_GetSurfaceClipRect #define SDL_GetColorKey SDL_GetColorKey_renamed_SDL_GetSurfaceColorKey #define SDL_HasColorKey SDL_HasColorKey_renamed_SDL_SurfaceHasColorKey #define SDL_HasSurfaceRLE SDL_HasSurfaceRLE_renamed_SDL_SurfaceHasRLE #define SDL_LoadBMP_RW SDL_LoadBMP_RW_renamed_SDL_LoadBMP_IO #define SDL_LowerBlit SDL_LowerBlit_renamed_SDL_BlitSurfaceUnchecked #define SDL_LowerBlitScaled SDL_LowerBlitScaled_renamed_SDL_BlitSurfaceUncheckedScaled #define SDL_PREALLOC SDL_PREALLOC_renamed_SDL_SURFACE_PREALLOCATED #define SDL_SIMD_ALIGNED SDL_SIMD_ALIGNED_renamed_SDL_SURFACE_SIMD_ALIGNED #define SDL_SaveBMP_RW SDL_SaveBMP_RW_renamed_SDL_SaveBMP_IO #define SDL_SetClipRect SDL_SetClipRect_renamed_SDL_SetSurfaceClipRect #define SDL_SetColorKey SDL_SetColorKey_renamed_SDL_SetSurfaceColorKey #define SDL_UpperBlit SDL_UpperBlit_renamed_SDL_BlitSurface #define SDL_UpperBlitScaled SDL_UpperBlitScaled_renamed_SDL_BlitSurfaceScaled /* ##SDL_system.h */ #define SDL_AndroidBackButton SDL_AndroidBackButton_renamed_SDL_SendAndroidBackButton #define SDL_AndroidGetActivity SDL_AndroidGetActivity_renamed_SDL_GetAndroidActivity #define SDL_AndroidGetExternalStoragePath SDL_AndroidGetExternalStoragePath_renamed_SDL_GetAndroidExternalStoragePath #define SDL_AndroidGetExternalStorageState SDL_AndroidGetExternalStorageState_renamed_SDL_GetAndroidExternalStorageState #define SDL_AndroidGetInternalStoragePath SDL_AndroidGetInternalStoragePath_renamed_SDL_GetAndroidInternalStoragePath #define SDL_AndroidGetJNIEnv SDL_AndroidGetJNIEnv_renamed_SDL_GetAndroidJNIEnv #define SDL_AndroidRequestPermission SDL_AndroidRequestPermission_renamed_SDL_RequestAndroidPermission #define SDL_AndroidRequestPermissionCallback SDL_AndroidRequestPermissionCallback_renamed_SDL_RequestAndroidPermissionCallback #define SDL_AndroidSendMessage SDL_AndroidSendMessage_renamed_SDL_SendAndroidMessage #define SDL_AndroidShowToast SDL_AndroidShowToast_renamed_SDL_ShowAndroidToast #define SDL_DXGIGetOutputInfo SDL_DXGIGetOutputInfo_renamed_SDL_GetDXGIOutputInfo #define SDL_Direct3D9GetAdapterIndex SDL_Direct3D9GetAdapterIndex_renamed_SDL_GetDirect3D9AdapterIndex #define SDL_GDKGetDefaultUser SDL_GDKGetDefaultUser_renamed_SDL_GetGDKDefaultUser #define SDL_GDKGetTaskQueue SDL_GDKGetTaskQueue_renamed_SDL_GetGDKTaskQueue #define SDL_LinuxSetThreadPriority SDL_LinuxSetThreadPriority_renamed_SDL_SetLinuxThreadPriority #define SDL_LinuxSetThreadPriorityAndPolicy SDL_LinuxSetThreadPriorityAndPolicy_renamed_SDL_SetLinuxThreadPriorityAndPolicy #define SDL_OnApplicationDidBecomeActive SDL_OnApplicationDidBecomeActive_renamed_SDL_OnApplicationDidEnterForeground #define SDL_OnApplicationWillResignActive SDL_OnApplicationWillResignActive_renamed_SDL_OnApplicationWillEnterBackground #define SDL_iOSSetAnimationCallback SDL_iOSSetAnimationCallback_renamed_SDL_SetiOSAnimationCallback #define SDL_iOSSetEventPump SDL_iOSSetEventPump_renamed_SDL_SetiOSEventPump #define SDL_iPhoneSetAnimationCallback SDL_iPhoneSetAnimationCallback_renamed_SDL_iOSSetAnimationCallback #define SDL_iPhoneSetEventPump SDL_iPhoneSetEventPump_renamed_SDL_iOSSetEventPump /* ##SDL_thread.h */ #define SDL_SetThreadPriority SDL_SetThreadPriority_renamed_SDL_SetCurrentThreadPriority #define SDL_SetWindowInputFocus SDL_SetWindowInputFocus_deprecated_use_SDL_RaiseWindow #define SDL_TLSCleanup SDL_TLSCleanup_renamed_SDL_CleanupTLS #define SDL_TLSGet SDL_TLSGet_renamed_SDL_GetTLS #define SDL_TLSSet SDL_TLSSet_renamed_SDL_SetTLS #define SDL_threadID SDL_threadID_renamed_SDL_ThreadID /* ##SDL_timer.h */ #define SDL_GetTicks64 SDL_GetTicks64_renamed_SDL_GetTicks /* ##SDL_version.h */ #define SDL_COMPILEDVERSION SDL_COMPILEDVERSION_renamed_SDL_VERSION #define SDL_PATCHLEVEL SDL_PATCHLEVEL_renamed_SDL_MICRO_VERSION /* ##SDL_video.h */ #define SDL_GL_DeleteContext SDL_GL_DeleteContext_renamed_SDL_GL_DestroyContext #define SDL_GLattr SDL_GLattr_renamed_SDL_GLAttr #define SDL_GLcontextFlag SDL_GLcontextFlag_renamed_SDL_GLContextFlag #define SDL_GLcontextReleaseFlag SDL_GLcontextReleaseFlag_renamed_SDL_GLContextReleaseFlag #define SDL_GLprofile SDL_GLprofile_renamed_SDL_GLProfile #define SDL_GetClosestDisplayMode SDL_GetClosestDisplayMode_renamed_SDL_GetClosestFullscreenDisplayMode #define SDL_GetDisplayOrientation SDL_GetDisplayOrientation_renamed_SDL_GetCurrentDisplayOrientation #define SDL_GetPointDisplayIndex SDL_GetPointDisplayIndex_renamed_SDL_GetDisplayForPoint #define SDL_GetRectDisplayIndex SDL_GetRectDisplayIndex_renamed_SDL_GetDisplayForRect #define SDL_GetWindowDisplayIndex SDL_GetWindowDisplayIndex_renamed_SDL_GetDisplayForWindow #define SDL_GetWindowDisplayMode SDL_GetWindowDisplayMode_renamed_SDL_GetWindowFullscreenMode #define SDL_HasWindowSurface SDL_HasWindowSurface_renamed_SDL_WindowHasSurface #define SDL_INIT_EVERYTHING SDL_INIT_EVERYTHING_deprecated_list_flags_explicitly #define SDL_IsScreenSaverEnabled SDL_IsScreenSaverEnabled_renamed_SDL_ScreenSaverEnabled #define SDL_SetWindowDisplayMode SDL_SetWindowDisplayMode_renamed_SDL_SetWindowFullscreenMode #define SDL_WINDOW_ALLOW_HIGHDPI SDL_WINDOW_ALLOW_HIGHDPI_renamed_SDL_WINDOW_HIGH_PIXEL_DENSITY #define SDL_WINDOW_FULLSCREEN_DESKTOP SDL_WINDOW_FULLSCREEN_DESKTOP_deprecated_use_SDL_SetWindowFullscreen_with_bool #define SDL_WINDOW_INPUT_GRABBED SDL_WINDOW_INPUT_GRABBED_renamed_SDL_WINDOW_MOUSE_GRABBED #define SDL_WINDOW_SHOWN SDL_WINDOW_SHOWN_deprecated_windows_are_shown_by_default #define SDL_WINDOW_SKIP_TASKBAR SDL_WINDOW_SKIP_TASKBAR_renamed_SDL_WINDOW_UTILITY #endif /* SDL_ENABLE_OLD_NAMES */ #endif /* SDL_oldnames_h_ */ ================================================ FILE: deps/include/SDL3/SDL_opengl.h ================================================ /* Simple DirectMedia Layer Copyright (C) 1997-2026 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ /* * This is a simple file to encapsulate the OpenGL API headers. * * Define NO_SDL_GLEXT if you have your own version of glext.h and want * to disable the version included in SDL_opengl.h. */ #ifndef SDL_opengl_h_ #define SDL_opengl_h_ #include #ifndef SDL_PLATFORM_IOS /* No OpenGL on iOS. */ /* * Mesa 3-D graphics library * * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. * Copyright (C) 2009 VMware, Inc. All Rights Reserved. * * 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. */ #ifndef __gl_h_ #define __gl_h_ #ifdef USE_MGL_NAMESPACE #include #endif /********************************************************************** * Begin system-specific stuff. */ #if defined(_WIN32) && !defined(__CYGWIN__) # if (defined(_MSC_VER) || defined(__MINGW32__)) && defined(BUILD_GL32) /* tag specify we're building mesa as a DLL */ # define GLAPI __declspec(dllexport) # elif (defined(_MSC_VER) || defined(__MINGW32__)) && defined(_DLL) /* tag specifying we're building for DLL runtime support */ # define GLAPI __declspec(dllimport) # else /* for use with static link lib build of Win32 edition only */ # define GLAPI extern # endif /* _STATIC_MESA support */ # if defined(__MINGW32__) && defined(GL_NO_STDCALL) || defined(UNDER_CE) /* The generated DLLs by MingW with STDCALL are not compatible with the ones done by Microsoft's compilers */ # define GLAPIENTRY # else # define GLAPIENTRY __stdcall # endif #elif defined(__CYGWIN__) && defined(USE_OPENGL32) /* use native windows opengl32 */ # define GLAPI extern # define GLAPIENTRY __stdcall #elif (defined(__GNUC__) && __GNUC__ >= 4) || (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590)) # define GLAPI __attribute__((visibility("default"))) # define GLAPIENTRY #endif /* WIN32 && !CYGWIN */ /* * WINDOWS: Include windows.h here to define APIENTRY. * It is also useful when applications include this file by * including only glut.h, since glut.h depends on windows.h. * Applications needing to include windows.h with parms other * than "WIN32_LEAN_AND_MEAN" may include windows.h before * glut.h or gl.h. */ #if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__) #ifndef WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN 1 #endif #ifndef NOMINMAX /* don't define min() and max(). */ #define NOMINMAX #endif #include #endif #ifndef GLAPI #define GLAPI extern #endif #ifndef GLAPIENTRY #define GLAPIENTRY #endif #ifndef APIENTRY #define APIENTRY GLAPIENTRY #endif /* "P" suffix to be used for a pointer to a function */ #ifndef APIENTRYP #define APIENTRYP APIENTRY * #endif #ifndef GLAPIENTRYP #define GLAPIENTRYP GLAPIENTRY * #endif #if defined(PRAGMA_EXPORT_SUPPORTED) #pragma export on #endif /* * End system-specific stuff. **********************************************************************/ #ifdef __cplusplus extern "C" { #endif #define GL_VERSION_1_1 1 #define GL_VERSION_1_2 1 #define GL_VERSION_1_3 1 #define GL_ARB_imaging 1 /* * Datatypes */ typedef unsigned int GLenum; typedef unsigned char GLboolean; typedef unsigned int GLbitfield; typedef void GLvoid; typedef signed char GLbyte; /* 1-byte signed */ typedef short GLshort; /* 2-byte signed */ typedef int GLint; /* 4-byte signed */ typedef unsigned char GLubyte; /* 1-byte unsigned */ typedef unsigned short GLushort; /* 2-byte unsigned */ typedef unsigned int GLuint; /* 4-byte unsigned */ typedef int GLsizei; /* 4-byte signed */ typedef float GLfloat; /* single precision float */ typedef float GLclampf; /* single precision float in [0,1] */ typedef double GLdouble; /* double precision float */ typedef double GLclampd; /* double precision float in [0,1] */ /* * Constants */ /* Boolean values */ #define GL_FALSE 0 #define GL_TRUE 1 /* Data types */ #define GL_BYTE 0x1400 #define GL_UNSIGNED_BYTE 0x1401 #define GL_SHORT 0x1402 #define GL_UNSIGNED_SHORT 0x1403 #define GL_INT 0x1404 #define GL_UNSIGNED_INT 0x1405 #define GL_FLOAT 0x1406 #define GL_2_BYTES 0x1407 #define GL_3_BYTES 0x1408 #define GL_4_BYTES 0x1409 #define GL_DOUBLE 0x140A /* Primitives */ #define GL_POINTS 0x0000 #define GL_LINES 0x0001 #define GL_LINE_LOOP 0x0002 #define GL_LINE_STRIP 0x0003 #define GL_TRIANGLES 0x0004 #define GL_TRIANGLE_STRIP 0x0005 #define GL_TRIANGLE_FAN 0x0006 #define GL_QUADS 0x0007 #define GL_QUAD_STRIP 0x0008 #define GL_POLYGON 0x0009 /* Vertex Arrays */ #define GL_VERTEX_ARRAY 0x8074 #define GL_NORMAL_ARRAY 0x8075 #define GL_COLOR_ARRAY 0x8076 #define GL_INDEX_ARRAY 0x8077 #define GL_TEXTURE_COORD_ARRAY 0x8078 #define GL_EDGE_FLAG_ARRAY 0x8079 #define GL_VERTEX_ARRAY_SIZE 0x807A #define GL_VERTEX_ARRAY_TYPE 0x807B #define GL_VERTEX_ARRAY_STRIDE 0x807C #define GL_NORMAL_ARRAY_TYPE 0x807E #define GL_NORMAL_ARRAY_STRIDE 0x807F #define GL_COLOR_ARRAY_SIZE 0x8081 #define GL_COLOR_ARRAY_TYPE 0x8082 #define GL_COLOR_ARRAY_STRIDE 0x8083 #define GL_INDEX_ARRAY_TYPE 0x8085 #define GL_INDEX_ARRAY_STRIDE 0x8086 #define GL_TEXTURE_COORD_ARRAY_SIZE 0x8088 #define GL_TEXTURE_COORD_ARRAY_TYPE 0x8089 #define GL_TEXTURE_COORD_ARRAY_STRIDE 0x808A #define GL_EDGE_FLAG_ARRAY_STRIDE 0x808C #define GL_VERTEX_ARRAY_POINTER 0x808E #define GL_NORMAL_ARRAY_POINTER 0x808F #define GL_COLOR_ARRAY_POINTER 0x8090 #define GL_INDEX_ARRAY_POINTER 0x8091 #define GL_TEXTURE_COORD_ARRAY_POINTER 0x8092 #define GL_EDGE_FLAG_ARRAY_POINTER 0x8093 #define GL_V2F 0x2A20 #define GL_V3F 0x2A21 #define GL_C4UB_V2F 0x2A22 #define GL_C4UB_V3F 0x2A23 #define GL_C3F_V3F 0x2A24 #define GL_N3F_V3F 0x2A25 #define GL_C4F_N3F_V3F 0x2A26 #define GL_T2F_V3F 0x2A27 #define GL_T4F_V4F 0x2A28 #define GL_T2F_C4UB_V3F 0x2A29 #define GL_T2F_C3F_V3F 0x2A2A #define GL_T2F_N3F_V3F 0x2A2B #define GL_T2F_C4F_N3F_V3F 0x2A2C #define GL_T4F_C4F_N3F_V4F 0x2A2D /* Matrix Mode */ #define GL_MATRIX_MODE 0x0BA0 #define GL_MODELVIEW 0x1700 #define GL_PROJECTION 0x1701 #define GL_TEXTURE 0x1702 /* Points */ #define GL_POINT_SMOOTH 0x0B10 #define GL_POINT_SIZE 0x0B11 #define GL_POINT_SIZE_GRANULARITY 0x0B13 #define GL_POINT_SIZE_RANGE 0x0B12 /* Lines */ #define GL_LINE_SMOOTH 0x0B20 #define GL_LINE_STIPPLE 0x0B24 #define GL_LINE_STIPPLE_PATTERN 0x0B25 #define GL_LINE_STIPPLE_REPEAT 0x0B26 #define GL_LINE_WIDTH 0x0B21 #define GL_LINE_WIDTH_GRANULARITY 0x0B23 #define GL_LINE_WIDTH_RANGE 0x0B22 /* Polygons */ #define GL_POINT 0x1B00 #define GL_LINE 0x1B01 #define GL_FILL 0x1B02 #define GL_CW 0x0900 #define GL_CCW 0x0901 #define GL_FRONT 0x0404 #define GL_BACK 0x0405 #define GL_POLYGON_MODE 0x0B40 #define GL_POLYGON_SMOOTH 0x0B41 #define GL_POLYGON_STIPPLE 0x0B42 #define GL_EDGE_FLAG 0x0B43 #define GL_CULL_FACE 0x0B44 #define GL_CULL_FACE_MODE 0x0B45 #define GL_FRONT_FACE 0x0B46 #define GL_POLYGON_OFFSET_FACTOR 0x8038 #define GL_POLYGON_OFFSET_UNITS 0x2A00 #define GL_POLYGON_OFFSET_POINT 0x2A01 #define GL_POLYGON_OFFSET_LINE 0x2A02 #define GL_POLYGON_OFFSET_FILL 0x8037 /* Display Lists */ #define GL_COMPILE 0x1300 #define GL_COMPILE_AND_EXECUTE 0x1301 #define GL_LIST_BASE 0x0B32 #define GL_LIST_INDEX 0x0B33 #define GL_LIST_MODE 0x0B30 /* Depth buffer */ #define GL_NEVER 0x0200 #define GL_LESS 0x0201 #define GL_EQUAL 0x0202 #define GL_LEQUAL 0x0203 #define GL_GREATER 0x0204 #define GL_NOTEQUAL 0x0205 #define GL_GEQUAL 0x0206 #define GL_ALWAYS 0x0207 #define GL_DEPTH_TEST 0x0B71 #define GL_DEPTH_BITS 0x0D56 #define GL_DEPTH_CLEAR_VALUE 0x0B73 #define GL_DEPTH_FUNC 0x0B74 #define GL_DEPTH_RANGE 0x0B70 #define GL_DEPTH_WRITEMASK 0x0B72 #define GL_DEPTH_COMPONENT 0x1902 /* Lighting */ #define GL_LIGHTING 0x0B50 #define GL_LIGHT0 0x4000 #define GL_LIGHT1 0x4001 #define GL_LIGHT2 0x4002 #define GL_LIGHT3 0x4003 #define GL_LIGHT4 0x4004 #define GL_LIGHT5 0x4005 #define GL_LIGHT6 0x4006 #define GL_LIGHT7 0x4007 #define GL_SPOT_EXPONENT 0x1205 #define GL_SPOT_CUTOFF 0x1206 #define GL_CONSTANT_ATTENUATION 0x1207 #define GL_LINEAR_ATTENUATION 0x1208 #define GL_QUADRATIC_ATTENUATION 0x1209 #define GL_AMBIENT 0x1200 #define GL_DIFFUSE 0x1201 #define GL_SPECULAR 0x1202 #define GL_SHININESS 0x1601 #define GL_EMISSION 0x1600 #define GL_POSITION 0x1203 #define GL_SPOT_DIRECTION 0x1204 #define GL_AMBIENT_AND_DIFFUSE 0x1602 #define GL_COLOR_INDEXES 0x1603 #define GL_LIGHT_MODEL_TWO_SIDE 0x0B52 #define GL_LIGHT_MODEL_LOCAL_VIEWER 0x0B51 #define GL_LIGHT_MODEL_AMBIENT 0x0B53 #define GL_FRONT_AND_BACK 0x0408 #define GL_SHADE_MODEL 0x0B54 #define GL_FLAT 0x1D00 #define GL_SMOOTH 0x1D01 #define GL_COLOR_MATERIAL 0x0B57 #define GL_COLOR_MATERIAL_FACE 0x0B55 #define GL_COLOR_MATERIAL_PARAMETER 0x0B56 #define GL_NORMALIZE 0x0BA1 /* User clipping planes */ #define GL_CLIP_PLANE0 0x3000 #define GL_CLIP_PLANE1 0x3001 #define GL_CLIP_PLANE2 0x3002 #define GL_CLIP_PLANE3 0x3003 #define GL_CLIP_PLANE4 0x3004 #define GL_CLIP_PLANE5 0x3005 /* Accumulation buffer */ #define GL_ACCUM_RED_BITS 0x0D58 #define GL_ACCUM_GREEN_BITS 0x0D59 #define GL_ACCUM_BLUE_BITS 0x0D5A #define GL_ACCUM_ALPHA_BITS 0x0D5B #define GL_ACCUM_CLEAR_VALUE 0x0B80 #define GL_ACCUM 0x0100 #define GL_ADD 0x0104 #define GL_LOAD 0x0101 #define GL_MULT 0x0103 #define GL_RETURN 0x0102 /* Alpha testing */ #define GL_ALPHA_TEST 0x0BC0 #define GL_ALPHA_TEST_REF 0x0BC2 #define GL_ALPHA_TEST_FUNC 0x0BC1 /* Blending */ #define GL_BLEND 0x0BE2 #define GL_BLEND_SRC 0x0BE1 #define GL_BLEND_DST 0x0BE0 #define GL_ZERO 0 #define GL_ONE 1 #define GL_SRC_COLOR 0x0300 #define GL_ONE_MINUS_SRC_COLOR 0x0301 #define GL_SRC_ALPHA 0x0302 #define GL_ONE_MINUS_SRC_ALPHA 0x0303 #define GL_DST_ALPHA 0x0304 #define GL_ONE_MINUS_DST_ALPHA 0x0305 #define GL_DST_COLOR 0x0306 #define GL_ONE_MINUS_DST_COLOR 0x0307 #define GL_SRC_ALPHA_SATURATE 0x0308 /* Render Mode */ #define GL_FEEDBACK 0x1C01 #define GL_RENDER 0x1C00 #define GL_SELECT 0x1C02 /* Feedback */ #define GL_2D 0x0600 #define GL_3D 0x0601 #define GL_3D_COLOR 0x0602 #define GL_3D_COLOR_TEXTURE 0x0603 #define GL_4D_COLOR_TEXTURE 0x0604 #define GL_POINT_TOKEN 0x0701 #define GL_LINE_TOKEN 0x0702 #define GL_LINE_RESET_TOKEN 0x0707 #define GL_POLYGON_TOKEN 0x0703 #define GL_BITMAP_TOKEN 0x0704 #define GL_DRAW_PIXEL_TOKEN 0x0705 #define GL_COPY_PIXEL_TOKEN 0x0706 #define GL_PASS_THROUGH_TOKEN 0x0700 #define GL_FEEDBACK_BUFFER_POINTER 0x0DF0 #define GL_FEEDBACK_BUFFER_SIZE 0x0DF1 #define GL_FEEDBACK_BUFFER_TYPE 0x0DF2 /* Selection */ #define GL_SELECTION_BUFFER_POINTER 0x0DF3 #define GL_SELECTION_BUFFER_SIZE 0x0DF4 /* Fog */ #define GL_FOG 0x0B60 #define GL_FOG_MODE 0x0B65 #define GL_FOG_DENSITY 0x0B62 #define GL_FOG_COLOR 0x0B66 #define GL_FOG_INDEX 0x0B61 #define GL_FOG_START 0x0B63 #define GL_FOG_END 0x0B64 #define GL_LINEAR 0x2601 #define GL_EXP 0x0800 #define GL_EXP2 0x0801 /* Logic Ops */ #define GL_LOGIC_OP 0x0BF1 #define GL_INDEX_LOGIC_OP 0x0BF1 #define GL_COLOR_LOGIC_OP 0x0BF2 #define GL_LOGIC_OP_MODE 0x0BF0 #define GL_CLEAR 0x1500 #define GL_SET 0x150F #define GL_COPY 0x1503 #define GL_COPY_INVERTED 0x150C #define GL_NOOP 0x1505 #define GL_INVERT 0x150A #define GL_AND 0x1501 #define GL_NAND 0x150E #define GL_OR 0x1507 #define GL_NOR 0x1508 #define GL_XOR 0x1506 #define GL_EQUIV 0x1509 #define GL_AND_REVERSE 0x1502 #define GL_AND_INVERTED 0x1504 #define GL_OR_REVERSE 0x150B #define GL_OR_INVERTED 0x150D /* Stencil */ #define GL_STENCIL_BITS 0x0D57 #define GL_STENCIL_TEST 0x0B90 #define GL_STENCIL_CLEAR_VALUE 0x0B91 #define GL_STENCIL_FUNC 0x0B92 #define GL_STENCIL_VALUE_MASK 0x0B93 #define GL_STENCIL_FAIL 0x0B94 #define GL_STENCIL_PASS_DEPTH_FAIL 0x0B95 #define GL_STENCIL_PASS_DEPTH_PASS 0x0B96 #define GL_STENCIL_REF 0x0B97 #define GL_STENCIL_WRITEMASK 0x0B98 #define GL_STENCIL_INDEX 0x1901 #define GL_KEEP 0x1E00 #define GL_REPLACE 0x1E01 #define GL_INCR 0x1E02 #define GL_DECR 0x1E03 /* Buffers, Pixel Drawing/Reading */ #define GL_NONE 0 #define GL_LEFT 0x0406 #define GL_RIGHT 0x0407 /*GL_FRONT 0x0404 */ /*GL_BACK 0x0405 */ /*GL_FRONT_AND_BACK 0x0408 */ #define GL_FRONT_LEFT 0x0400 #define GL_FRONT_RIGHT 0x0401 #define GL_BACK_LEFT 0x0402 #define GL_BACK_RIGHT 0x0403 #define GL_AUX0 0x0409 #define GL_AUX1 0x040A #define GL_AUX2 0x040B #define GL_AUX3 0x040C #define GL_COLOR_INDEX 0x1900 #define GL_RED 0x1903 #define GL_GREEN 0x1904 #define GL_BLUE 0x1905 #define GL_ALPHA 0x1906 #define GL_LUMINANCE 0x1909 #define GL_LUMINANCE_ALPHA 0x190A #define GL_ALPHA_BITS 0x0D55 #define GL_RED_BITS 0x0D52 #define GL_GREEN_BITS 0x0D53 #define GL_BLUE_BITS 0x0D54 #define GL_INDEX_BITS 0x0D51 #define GL_SUBPIXEL_BITS 0x0D50 #define GL_AUX_BUFFERS 0x0C00 #define GL_READ_BUFFER 0x0C02 #define GL_DRAW_BUFFER 0x0C01 #define GL_DOUBLEBUFFER 0x0C32 #define GL_STEREO 0x0C33 #define GL_BITMAP 0x1A00 #define GL_COLOR 0x1800 #define GL_DEPTH 0x1801 #define GL_STENCIL 0x1802 #define GL_DITHER 0x0BD0 #define GL_RGB 0x1907 #define GL_RGBA 0x1908 /* Implementation limits */ #define GL_MAX_LIST_NESTING 0x0B31 #define GL_MAX_EVAL_ORDER 0x0D30 #define GL_MAX_LIGHTS 0x0D31 #define GL_MAX_CLIP_PLANES 0x0D32 #define GL_MAX_TEXTURE_SIZE 0x0D33 #define GL_MAX_PIXEL_MAP_TABLE 0x0D34 #define GL_MAX_ATTRIB_STACK_DEPTH 0x0D35 #define GL_MAX_MODELVIEW_STACK_DEPTH 0x0D36 #define GL_MAX_NAME_STACK_DEPTH 0x0D37 #define GL_MAX_PROJECTION_STACK_DEPTH 0x0D38 #define GL_MAX_TEXTURE_STACK_DEPTH 0x0D39 #define GL_MAX_VIEWPORT_DIMS 0x0D3A #define GL_MAX_CLIENT_ATTRIB_STACK_DEPTH 0x0D3B /* Gets */ #define GL_ATTRIB_STACK_DEPTH 0x0BB0 #define GL_CLIENT_ATTRIB_STACK_DEPTH 0x0BB1 #define GL_COLOR_CLEAR_VALUE 0x0C22 #define GL_COLOR_WRITEMASK 0x0C23 #define GL_CURRENT_INDEX 0x0B01 #define GL_CURRENT_COLOR 0x0B00 #define GL_CURRENT_NORMAL 0x0B02 #define GL_CURRENT_RASTER_COLOR 0x0B04 #define GL_CURRENT_RASTER_DISTANCE 0x0B09 #define GL_CURRENT_RASTER_INDEX 0x0B05 #define GL_CURRENT_RASTER_POSITION 0x0B07 #define GL_CURRENT_RASTER_TEXTURE_COORDS 0x0B06 #define GL_CURRENT_RASTER_POSITION_VALID 0x0B08 #define GL_CURRENT_TEXTURE_COORDS 0x0B03 #define GL_INDEX_CLEAR_VALUE 0x0C20 #define GL_INDEX_MODE 0x0C30 #define GL_INDEX_WRITEMASK 0x0C21 #define GL_MODELVIEW_MATRIX 0x0BA6 #define GL_MODELVIEW_STACK_DEPTH 0x0BA3 #define GL_NAME_STACK_DEPTH 0x0D70 #define GL_PROJECTION_MATRIX 0x0BA7 #define GL_PROJECTION_STACK_DEPTH 0x0BA4 #define GL_RENDER_MODE 0x0C40 #define GL_RGBA_MODE 0x0C31 #define GL_TEXTURE_MATRIX 0x0BA8 #define GL_TEXTURE_STACK_DEPTH 0x0BA5 #define GL_VIEWPORT 0x0BA2 /* Evaluators */ #define GL_AUTO_NORMAL 0x0D80 #define GL_MAP1_COLOR_4 0x0D90 #define GL_MAP1_INDEX 0x0D91 #define GL_MAP1_NORMAL 0x0D92 #define GL_MAP1_TEXTURE_COORD_1 0x0D93 #define GL_MAP1_TEXTURE_COORD_2 0x0D94 #define GL_MAP1_TEXTURE_COORD_3 0x0D95 #define GL_MAP1_TEXTURE_COORD_4 0x0D96 #define GL_MAP1_VERTEX_3 0x0D97 #define GL_MAP1_VERTEX_4 0x0D98 #define GL_MAP2_COLOR_4 0x0DB0 #define GL_MAP2_INDEX 0x0DB1 #define GL_MAP2_NORMAL 0x0DB2 #define GL_MAP2_TEXTURE_COORD_1 0x0DB3 #define GL_MAP2_TEXTURE_COORD_2 0x0DB4 #define GL_MAP2_TEXTURE_COORD_3 0x0DB5 #define GL_MAP2_TEXTURE_COORD_4 0x0DB6 #define GL_MAP2_VERTEX_3 0x0DB7 #define GL_MAP2_VERTEX_4 0x0DB8 #define GL_MAP1_GRID_DOMAIN 0x0DD0 #define GL_MAP1_GRID_SEGMENTS 0x0DD1 #define GL_MAP2_GRID_DOMAIN 0x0DD2 #define GL_MAP2_GRID_SEGMENTS 0x0DD3 #define GL_COEFF 0x0A00 #define GL_ORDER 0x0A01 #define GL_DOMAIN 0x0A02 /* Hints */ #define GL_PERSPECTIVE_CORRECTION_HINT 0x0C50 #define GL_POINT_SMOOTH_HINT 0x0C51 #define GL_LINE_SMOOTH_HINT 0x0C52 #define GL_POLYGON_SMOOTH_HINT 0x0C53 #define GL_FOG_HINT 0x0C54 #define GL_DONT_CARE 0x1100 #define GL_FASTEST 0x1101 #define GL_NICEST 0x1102 /* Scissor box */ #define GL_SCISSOR_BOX 0x0C10 #define GL_SCISSOR_TEST 0x0C11 /* Pixel Mode / Transfer */ #define GL_MAP_COLOR 0x0D10 #define GL_MAP_STENCIL 0x0D11 #define GL_INDEX_SHIFT 0x0D12 #define GL_INDEX_OFFSET 0x0D13 #define GL_RED_SCALE 0x0D14 #define GL_RED_BIAS 0x0D15 #define GL_GREEN_SCALE 0x0D18 #define GL_GREEN_BIAS 0x0D19 #define GL_BLUE_SCALE 0x0D1A #define GL_BLUE_BIAS 0x0D1B #define GL_ALPHA_SCALE 0x0D1C #define GL_ALPHA_BIAS 0x0D1D #define GL_DEPTH_SCALE 0x0D1E #define GL_DEPTH_BIAS 0x0D1F #define GL_PIXEL_MAP_S_TO_S_SIZE 0x0CB1 #define GL_PIXEL_MAP_I_TO_I_SIZE 0x0CB0 #define GL_PIXEL_MAP_I_TO_R_SIZE 0x0CB2 #define GL_PIXEL_MAP_I_TO_G_SIZE 0x0CB3 #define GL_PIXEL_MAP_I_TO_B_SIZE 0x0CB4 #define GL_PIXEL_MAP_I_TO_A_SIZE 0x0CB5 #define GL_PIXEL_MAP_R_TO_R_SIZE 0x0CB6 #define GL_PIXEL_MAP_G_TO_G_SIZE 0x0CB7 #define GL_PIXEL_MAP_B_TO_B_SIZE 0x0CB8 #define GL_PIXEL_MAP_A_TO_A_SIZE 0x0CB9 #define GL_PIXEL_MAP_S_TO_S 0x0C71 #define GL_PIXEL_MAP_I_TO_I 0x0C70 #define GL_PIXEL_MAP_I_TO_R 0x0C72 #define GL_PIXEL_MAP_I_TO_G 0x0C73 #define GL_PIXEL_MAP_I_TO_B 0x0C74 #define GL_PIXEL_MAP_I_TO_A 0x0C75 #define GL_PIXEL_MAP_R_TO_R 0x0C76 #define GL_PIXEL_MAP_G_TO_G 0x0C77 #define GL_PIXEL_MAP_B_TO_B 0x0C78 #define GL_PIXEL_MAP_A_TO_A 0x0C79 #define GL_PACK_ALIGNMENT 0x0D05 #define GL_PACK_LSB_FIRST 0x0D01 #define GL_PACK_ROW_LENGTH 0x0D02 #define GL_PACK_SKIP_PIXELS 0x0D04 #define GL_PACK_SKIP_ROWS 0x0D03 #define GL_PACK_SWAP_BYTES 0x0D00 #define GL_UNPACK_ALIGNMENT 0x0CF5 #define GL_UNPACK_LSB_FIRST 0x0CF1 #define GL_UNPACK_ROW_LENGTH 0x0CF2 #define GL_UNPACK_SKIP_PIXELS 0x0CF4 #define GL_UNPACK_SKIP_ROWS 0x0CF3 #define GL_UNPACK_SWAP_BYTES 0x0CF0 #define GL_ZOOM_X 0x0D16 #define GL_ZOOM_Y 0x0D17 /* Texture mapping */ #define GL_TEXTURE_ENV 0x2300 #define GL_TEXTURE_ENV_MODE 0x2200 #define GL_TEXTURE_1D 0x0DE0 #define GL_TEXTURE_2D 0x0DE1 #define GL_TEXTURE_WRAP_S 0x2802 #define GL_TEXTURE_WRAP_T 0x2803 #define GL_TEXTURE_MAG_FILTER 0x2800 #define GL_TEXTURE_MIN_FILTER 0x2801 #define GL_TEXTURE_ENV_COLOR 0x2201 #define GL_TEXTURE_GEN_S 0x0C60 #define GL_TEXTURE_GEN_T 0x0C61 #define GL_TEXTURE_GEN_R 0x0C62 #define GL_TEXTURE_GEN_Q 0x0C63 #define GL_TEXTURE_GEN_MODE 0x2500 #define GL_TEXTURE_BORDER_COLOR 0x1004 #define GL_TEXTURE_WIDTH 0x1000 #define GL_TEXTURE_HEIGHT 0x1001 #define GL_TEXTURE_BORDER 0x1005 #define GL_TEXTURE_COMPONENTS 0x1003 #define GL_TEXTURE_RED_SIZE 0x805C #define GL_TEXTURE_GREEN_SIZE 0x805D #define GL_TEXTURE_BLUE_SIZE 0x805E #define GL_TEXTURE_ALPHA_SIZE 0x805F #define GL_TEXTURE_LUMINANCE_SIZE 0x8060 #define GL_TEXTURE_INTENSITY_SIZE 0x8061 #define GL_NEAREST_MIPMAP_NEAREST 0x2700 #define GL_NEAREST_MIPMAP_LINEAR 0x2702 #define GL_LINEAR_MIPMAP_NEAREST 0x2701 #define GL_LINEAR_MIPMAP_LINEAR 0x2703 #define GL_OBJECT_LINEAR 0x2401 #define GL_OBJECT_PLANE 0x2501 #define GL_EYE_LINEAR 0x2400 #define GL_EYE_PLANE 0x2502 #define GL_SPHERE_MAP 0x2402 #define GL_DECAL 0x2101 #define GL_MODULATE 0x2100 #define GL_NEAREST 0x2600 #define GL_REPEAT 0x2901 #define GL_CLAMP 0x2900 #define GL_S 0x2000 #define GL_T 0x2001 #define GL_R 0x2002 #define GL_Q 0x2003 /* Utility */ #define GL_VENDOR 0x1F00 #define GL_RENDERER 0x1F01 #define GL_VERSION 0x1F02 #define GL_EXTENSIONS 0x1F03 /* Errors */ #define GL_NO_ERROR 0 #define GL_INVALID_ENUM 0x0500 #define GL_INVALID_VALUE 0x0501 #define GL_INVALID_OPERATION 0x0502 #define GL_STACK_OVERFLOW 0x0503 #define GL_STACK_UNDERFLOW 0x0504 #define GL_OUT_OF_MEMORY 0x0505 /* glPush/PopAttrib bits */ #define GL_CURRENT_BIT 0x00000001 #define GL_POINT_BIT 0x00000002 #define GL_LINE_BIT 0x00000004 #define GL_POLYGON_BIT 0x00000008 #define GL_POLYGON_STIPPLE_BIT 0x00000010 #define GL_PIXEL_MODE_BIT 0x00000020 #define GL_LIGHTING_BIT 0x00000040 #define GL_FOG_BIT 0x00000080 #define GL_DEPTH_BUFFER_BIT 0x00000100 #define GL_ACCUM_BUFFER_BIT 0x00000200 #define GL_STENCIL_BUFFER_BIT 0x00000400 #define GL_VIEWPORT_BIT 0x00000800 #define GL_TRANSFORM_BIT 0x00001000 #define GL_ENABLE_BIT 0x00002000 #define GL_COLOR_BUFFER_BIT 0x00004000 #define GL_HINT_BIT 0x00008000 #define GL_EVAL_BIT 0x00010000 #define GL_LIST_BIT 0x00020000 #define GL_TEXTURE_BIT 0x00040000 #define GL_SCISSOR_BIT 0x00080000 #define GL_ALL_ATTRIB_BITS 0x000FFFFF /* OpenGL 1.1 */ #define GL_PROXY_TEXTURE_1D 0x8063 #define GL_PROXY_TEXTURE_2D 0x8064 #define GL_TEXTURE_PRIORITY 0x8066 #define GL_TEXTURE_RESIDENT 0x8067 #define GL_TEXTURE_BINDING_1D 0x8068 #define GL_TEXTURE_BINDING_2D 0x8069 #define GL_TEXTURE_INTERNAL_FORMAT 0x1003 #define GL_ALPHA4 0x803B #define GL_ALPHA8 0x803C #define GL_ALPHA12 0x803D #define GL_ALPHA16 0x803E #define GL_LUMINANCE4 0x803F #define GL_LUMINANCE8 0x8040 #define GL_LUMINANCE12 0x8041 #define GL_LUMINANCE16 0x8042 #define GL_LUMINANCE4_ALPHA4 0x8043 #define GL_LUMINANCE6_ALPHA2 0x8044 #define GL_LUMINANCE8_ALPHA8 0x8045 #define GL_LUMINANCE12_ALPHA4 0x8046 #define GL_LUMINANCE12_ALPHA12 0x8047 #define GL_LUMINANCE16_ALPHA16 0x8048 #define GL_INTENSITY 0x8049 #define GL_INTENSITY4 0x804A #define GL_INTENSITY8 0x804B #define GL_INTENSITY12 0x804C #define GL_INTENSITY16 0x804D #define GL_R3_G3_B2 0x2A10 #define GL_RGB4 0x804F #define GL_RGB5 0x8050 #define GL_RGB8 0x8051 #define GL_RGB10 0x8052 #define GL_RGB12 0x8053 #define GL_RGB16 0x8054 #define GL_RGBA2 0x8055 #define GL_RGBA4 0x8056 #define GL_RGB5_A1 0x8057 #define GL_RGBA8 0x8058 #define GL_RGB10_A2 0x8059 #define GL_RGBA12 0x805A #define GL_RGBA16 0x805B #define GL_CLIENT_PIXEL_STORE_BIT 0x00000001 #define GL_CLIENT_VERTEX_ARRAY_BIT 0x00000002 #define GL_ALL_CLIENT_ATTRIB_BITS 0xFFFFFFFF #define GL_CLIENT_ALL_ATTRIB_BITS 0xFFFFFFFF /* * Miscellaneous */ #ifndef SDL_OPENGL_1_NO_PROTOTYPES GLAPI void GLAPIENTRY glClearIndex( GLfloat c ); GLAPI void GLAPIENTRY glClearColor( GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha ); GLAPI void GLAPIENTRY glClear( GLbitfield mask ); GLAPI void GLAPIENTRY glIndexMask( GLuint mask ); GLAPI void GLAPIENTRY glColorMask( GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha ); GLAPI void GLAPIENTRY glAlphaFunc( GLenum func, GLclampf ref ); GLAPI void GLAPIENTRY glBlendFunc( GLenum sfactor, GLenum dfactor ); GLAPI void GLAPIENTRY glLogicOp( GLenum opcode ); GLAPI void GLAPIENTRY glCullFace( GLenum mode ); GLAPI void GLAPIENTRY glFrontFace( GLenum mode ); GLAPI void GLAPIENTRY glPointSize( GLfloat size ); GLAPI void GLAPIENTRY glLineWidth( GLfloat width ); GLAPI void GLAPIENTRY glLineStipple( GLint factor, GLushort pattern ); GLAPI void GLAPIENTRY glPolygonMode( GLenum face, GLenum mode ); GLAPI void GLAPIENTRY glPolygonOffset( GLfloat factor, GLfloat units ); GLAPI void GLAPIENTRY glPolygonStipple( const GLubyte *mask ); GLAPI void GLAPIENTRY glGetPolygonStipple( GLubyte *mask ); GLAPI void GLAPIENTRY glEdgeFlag( GLboolean flag ); GLAPI void GLAPIENTRY glEdgeFlagv( const GLboolean *flag ); GLAPI void GLAPIENTRY glScissor( GLint x, GLint y, GLsizei width, GLsizei height); GLAPI void GLAPIENTRY glClipPlane( GLenum plane, const GLdouble *equation ); GLAPI void GLAPIENTRY glGetClipPlane( GLenum plane, GLdouble *equation ); GLAPI void GLAPIENTRY glDrawBuffer( GLenum mode ); GLAPI void GLAPIENTRY glReadBuffer( GLenum mode ); GLAPI void GLAPIENTRY glEnable( GLenum cap ); GLAPI void GLAPIENTRY glDisable( GLenum cap ); GLAPI GLboolean GLAPIENTRY glIsEnabled( GLenum cap ); GLAPI void GLAPIENTRY glEnableClientState( GLenum cap ); /* 1.1 */ GLAPI void GLAPIENTRY glDisableClientState( GLenum cap ); /* 1.1 */ GLAPI void GLAPIENTRY glGetBooleanv( GLenum pname, GLboolean *params ); GLAPI void GLAPIENTRY glGetDoublev( GLenum pname, GLdouble *params ); GLAPI void GLAPIENTRY glGetFloatv( GLenum pname, GLfloat *params ); GLAPI void GLAPIENTRY glGetIntegerv( GLenum pname, GLint *params ); GLAPI void GLAPIENTRY glPushAttrib( GLbitfield mask ); GLAPI void GLAPIENTRY glPopAttrib( void ); GLAPI void GLAPIENTRY glPushClientAttrib( GLbitfield mask ); /* 1.1 */ GLAPI void GLAPIENTRY glPopClientAttrib( void ); /* 1.1 */ GLAPI GLint GLAPIENTRY glRenderMode( GLenum mode ); GLAPI GLenum GLAPIENTRY glGetError( void ); GLAPI const GLubyte * GLAPIENTRY glGetString( GLenum name ); GLAPI void GLAPIENTRY glFinish( void ); GLAPI void GLAPIENTRY glFlush( void ); GLAPI void GLAPIENTRY glHint( GLenum target, GLenum mode ); /* * Depth Buffer */ GLAPI void GLAPIENTRY glClearDepth( GLclampd depth ); GLAPI void GLAPIENTRY glDepthFunc( GLenum func ); GLAPI void GLAPIENTRY glDepthMask( GLboolean flag ); GLAPI void GLAPIENTRY glDepthRange( GLclampd near_val, GLclampd far_val ); /* * Accumulation Buffer */ GLAPI void GLAPIENTRY glClearAccum( GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha ); GLAPI void GLAPIENTRY glAccum( GLenum op, GLfloat value ); /* * Transformation */ GLAPI void GLAPIENTRY glMatrixMode( GLenum mode ); GLAPI void GLAPIENTRY glOrtho( GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble near_val, GLdouble far_val ); GLAPI void GLAPIENTRY glFrustum( GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble near_val, GLdouble far_val ); GLAPI void GLAPIENTRY glViewport( GLint x, GLint y, GLsizei width, GLsizei height ); GLAPI void GLAPIENTRY glPushMatrix( void ); GLAPI void GLAPIENTRY glPopMatrix( void ); GLAPI void GLAPIENTRY glLoadIdentity( void ); GLAPI void GLAPIENTRY glLoadMatrixd( const GLdouble *m ); GLAPI void GLAPIENTRY glLoadMatrixf( const GLfloat *m ); GLAPI void GLAPIENTRY glMultMatrixd( const GLdouble *m ); GLAPI void GLAPIENTRY glMultMatrixf( const GLfloat *m ); GLAPI void GLAPIENTRY glRotated( GLdouble angle, GLdouble x, GLdouble y, GLdouble z ); GLAPI void GLAPIENTRY glRotatef( GLfloat angle, GLfloat x, GLfloat y, GLfloat z ); GLAPI void GLAPIENTRY glScaled( GLdouble x, GLdouble y, GLdouble z ); GLAPI void GLAPIENTRY glScalef( GLfloat x, GLfloat y, GLfloat z ); GLAPI void GLAPIENTRY glTranslated( GLdouble x, GLdouble y, GLdouble z ); GLAPI void GLAPIENTRY glTranslatef( GLfloat x, GLfloat y, GLfloat z ); /* * Display Lists */ GLAPI GLboolean GLAPIENTRY glIsList( GLuint list ); GLAPI void GLAPIENTRY glDeleteLists( GLuint list, GLsizei range ); GLAPI GLuint GLAPIENTRY glGenLists( GLsizei range ); GLAPI void GLAPIENTRY glNewList( GLuint list, GLenum mode ); GLAPI void GLAPIENTRY glEndList( void ); GLAPI void GLAPIENTRY glCallList( GLuint list ); GLAPI void GLAPIENTRY glCallLists( GLsizei n, GLenum type, const GLvoid *lists ); GLAPI void GLAPIENTRY glListBase( GLuint base ); /* * Drawing Functions */ GLAPI void GLAPIENTRY glBegin( GLenum mode ); GLAPI void GLAPIENTRY glEnd( void ); GLAPI void GLAPIENTRY glVertex2d( GLdouble x, GLdouble y ); GLAPI void GLAPIENTRY glVertex2f( GLfloat x, GLfloat y ); GLAPI void GLAPIENTRY glVertex2i( GLint x, GLint y ); GLAPI void GLAPIENTRY glVertex2s( GLshort x, GLshort y ); GLAPI void GLAPIENTRY glVertex3d( GLdouble x, GLdouble y, GLdouble z ); GLAPI void GLAPIENTRY glVertex3f( GLfloat x, GLfloat y, GLfloat z ); GLAPI void GLAPIENTRY glVertex3i( GLint x, GLint y, GLint z ); GLAPI void GLAPIENTRY glVertex3s( GLshort x, GLshort y, GLshort z ); GLAPI void GLAPIENTRY glVertex4d( GLdouble x, GLdouble y, GLdouble z, GLdouble w ); GLAPI void GLAPIENTRY glVertex4f( GLfloat x, GLfloat y, GLfloat z, GLfloat w ); GLAPI void GLAPIENTRY glVertex4i( GLint x, GLint y, GLint z, GLint w ); GLAPI void GLAPIENTRY glVertex4s( GLshort x, GLshort y, GLshort z, GLshort w ); GLAPI void GLAPIENTRY glVertex2dv( const GLdouble *v ); GLAPI void GLAPIENTRY glVertex2fv( const GLfloat *v ); GLAPI void GLAPIENTRY glVertex2iv( const GLint *v ); GLAPI void GLAPIENTRY glVertex2sv( const GLshort *v ); GLAPI void GLAPIENTRY glVertex3dv( const GLdouble *v ); GLAPI void GLAPIENTRY glVertex3fv( const GLfloat *v ); GLAPI void GLAPIENTRY glVertex3iv( const GLint *v ); GLAPI void GLAPIENTRY glVertex3sv( const GLshort *v ); GLAPI void GLAPIENTRY glVertex4dv( const GLdouble *v ); GLAPI void GLAPIENTRY glVertex4fv( const GLfloat *v ); GLAPI void GLAPIENTRY glVertex4iv( const GLint *v ); GLAPI void GLAPIENTRY glVertex4sv( const GLshort *v ); GLAPI void GLAPIENTRY glNormal3b( GLbyte nx, GLbyte ny, GLbyte nz ); GLAPI void GLAPIENTRY glNormal3d( GLdouble nx, GLdouble ny, GLdouble nz ); GLAPI void GLAPIENTRY glNormal3f( GLfloat nx, GLfloat ny, GLfloat nz ); GLAPI void GLAPIENTRY glNormal3i( GLint nx, GLint ny, GLint nz ); GLAPI void GLAPIENTRY glNormal3s( GLshort nx, GLshort ny, GLshort nz ); GLAPI void GLAPIENTRY glNormal3bv( const GLbyte *v ); GLAPI void GLAPIENTRY glNormal3dv( const GLdouble *v ); GLAPI void GLAPIENTRY glNormal3fv( const GLfloat *v ); GLAPI void GLAPIENTRY glNormal3iv( const GLint *v ); GLAPI void GLAPIENTRY glNormal3sv( const GLshort *v ); GLAPI void GLAPIENTRY glIndexd( GLdouble c ); GLAPI void GLAPIENTRY glIndexf( GLfloat c ); GLAPI void GLAPIENTRY glIndexi( GLint c ); GLAPI void GLAPIENTRY glIndexs( GLshort c ); GLAPI void GLAPIENTRY glIndexub( GLubyte c ); /* 1.1 */ GLAPI void GLAPIENTRY glIndexdv( const GLdouble *c ); GLAPI void GLAPIENTRY glIndexfv( const GLfloat *c ); GLAPI void GLAPIENTRY glIndexiv( const GLint *c ); GLAPI void GLAPIENTRY glIndexsv( const GLshort *c ); GLAPI void GLAPIENTRY glIndexubv( const GLubyte *c ); /* 1.1 */ GLAPI void GLAPIENTRY glColor3b( GLbyte red, GLbyte green, GLbyte blue ); GLAPI void GLAPIENTRY glColor3d( GLdouble red, GLdouble green, GLdouble blue ); GLAPI void GLAPIENTRY glColor3f( GLfloat red, GLfloat green, GLfloat blue ); GLAPI void GLAPIENTRY glColor3i( GLint red, GLint green, GLint blue ); GLAPI void GLAPIENTRY glColor3s( GLshort red, GLshort green, GLshort blue ); GLAPI void GLAPIENTRY glColor3ub( GLubyte red, GLubyte green, GLubyte blue ); GLAPI void GLAPIENTRY glColor3ui( GLuint red, GLuint green, GLuint blue ); GLAPI void GLAPIENTRY glColor3us( GLushort red, GLushort green, GLushort blue ); GLAPI void GLAPIENTRY glColor4b( GLbyte red, GLbyte green, GLbyte blue, GLbyte alpha ); GLAPI void GLAPIENTRY glColor4d( GLdouble red, GLdouble green, GLdouble blue, GLdouble alpha ); GLAPI void GLAPIENTRY glColor4f( GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha ); GLAPI void GLAPIENTRY glColor4i( GLint red, GLint green, GLint blue, GLint alpha ); GLAPI void GLAPIENTRY glColor4s( GLshort red, GLshort green, GLshort blue, GLshort alpha ); GLAPI void GLAPIENTRY glColor4ub( GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha ); GLAPI void GLAPIENTRY glColor4ui( GLuint red, GLuint green, GLuint blue, GLuint alpha ); GLAPI void GLAPIENTRY glColor4us( GLushort red, GLushort green, GLushort blue, GLushort alpha ); GLAPI void GLAPIENTRY glColor3bv( const GLbyte *v ); GLAPI void GLAPIENTRY glColor3dv( const GLdouble *v ); GLAPI void GLAPIENTRY glColor3fv( const GLfloat *v ); GLAPI void GLAPIENTRY glColor3iv( const GLint *v ); GLAPI void GLAPIENTRY glColor3sv( const GLshort *v ); GLAPI void GLAPIENTRY glColor3ubv( const GLubyte *v ); GLAPI void GLAPIENTRY glColor3uiv( const GLuint *v ); GLAPI void GLAPIENTRY glColor3usv( const GLushort *v ); GLAPI void GLAPIENTRY glColor4bv( const GLbyte *v ); GLAPI void GLAPIENTRY glColor4dv( const GLdouble *v ); GLAPI void GLAPIENTRY glColor4fv( const GLfloat *v ); GLAPI void GLAPIENTRY glColor4iv( const GLint *v ); GLAPI void GLAPIENTRY glColor4sv( const GLshort *v ); GLAPI void GLAPIENTRY glColor4ubv( const GLubyte *v ); GLAPI void GLAPIENTRY glColor4uiv( const GLuint *v ); GLAPI void GLAPIENTRY glColor4usv( const GLushort *v ); GLAPI void GLAPIENTRY glTexCoord1d( GLdouble s ); GLAPI void GLAPIENTRY glTexCoord1f( GLfloat s ); GLAPI void GLAPIENTRY glTexCoord1i( GLint s ); GLAPI void GLAPIENTRY glTexCoord1s( GLshort s ); GLAPI void GLAPIENTRY glTexCoord2d( GLdouble s, GLdouble t ); GLAPI void GLAPIENTRY glTexCoord2f( GLfloat s, GLfloat t ); GLAPI void GLAPIENTRY glTexCoord2i( GLint s, GLint t ); GLAPI void GLAPIENTRY glTexCoord2s( GLshort s, GLshort t ); GLAPI void GLAPIENTRY glTexCoord3d( GLdouble s, GLdouble t, GLdouble r ); GLAPI void GLAPIENTRY glTexCoord3f( GLfloat s, GLfloat t, GLfloat r ); GLAPI void GLAPIENTRY glTexCoord3i( GLint s, GLint t, GLint r ); GLAPI void GLAPIENTRY glTexCoord3s( GLshort s, GLshort t, GLshort r ); GLAPI void GLAPIENTRY glTexCoord4d( GLdouble s, GLdouble t, GLdouble r, GLdouble q ); GLAPI void GLAPIENTRY glTexCoord4f( GLfloat s, GLfloat t, GLfloat r, GLfloat q ); GLAPI void GLAPIENTRY glTexCoord4i( GLint s, GLint t, GLint r, GLint q ); GLAPI void GLAPIENTRY glTexCoord4s( GLshort s, GLshort t, GLshort r, GLshort q ); GLAPI void GLAPIENTRY glTexCoord1dv( const GLdouble *v ); GLAPI void GLAPIENTRY glTexCoord1fv( const GLfloat *v ); GLAPI void GLAPIENTRY glTexCoord1iv( const GLint *v ); GLAPI void GLAPIENTRY glTexCoord1sv( const GLshort *v ); GLAPI void GLAPIENTRY glTexCoord2dv( const GLdouble *v ); GLAPI void GLAPIENTRY glTexCoord2fv( const GLfloat *v ); GLAPI void GLAPIENTRY glTexCoord2iv( const GLint *v ); GLAPI void GLAPIENTRY glTexCoord2sv( const GLshort *v ); GLAPI void GLAPIENTRY glTexCoord3dv( const GLdouble *v ); GLAPI void GLAPIENTRY glTexCoord3fv( const GLfloat *v ); GLAPI void GLAPIENTRY glTexCoord3iv( const GLint *v ); GLAPI void GLAPIENTRY glTexCoord3sv( const GLshort *v ); GLAPI void GLAPIENTRY glTexCoord4dv( const GLdouble *v ); GLAPI void GLAPIENTRY glTexCoord4fv( const GLfloat *v ); GLAPI void GLAPIENTRY glTexCoord4iv( const GLint *v ); GLAPI void GLAPIENTRY glTexCoord4sv( const GLshort *v ); GLAPI void GLAPIENTRY glRasterPos2d( GLdouble x, GLdouble y ); GLAPI void GLAPIENTRY glRasterPos2f( GLfloat x, GLfloat y ); GLAPI void GLAPIENTRY glRasterPos2i( GLint x, GLint y ); GLAPI void GLAPIENTRY glRasterPos2s( GLshort x, GLshort y ); GLAPI void GLAPIENTRY glRasterPos3d( GLdouble x, GLdouble y, GLdouble z ); GLAPI void GLAPIENTRY glRasterPos3f( GLfloat x, GLfloat y, GLfloat z ); GLAPI void GLAPIENTRY glRasterPos3i( GLint x, GLint y, GLint z ); GLAPI void GLAPIENTRY glRasterPos3s( GLshort x, GLshort y, GLshort z ); GLAPI void GLAPIENTRY glRasterPos4d( GLdouble x, GLdouble y, GLdouble z, GLdouble w ); GLAPI void GLAPIENTRY glRasterPos4f( GLfloat x, GLfloat y, GLfloat z, GLfloat w ); GLAPI void GLAPIENTRY glRasterPos4i( GLint x, GLint y, GLint z, GLint w ); GLAPI void GLAPIENTRY glRasterPos4s( GLshort x, GLshort y, GLshort z, GLshort w ); GLAPI void GLAPIENTRY glRasterPos2dv( const GLdouble *v ); GLAPI void GLAPIENTRY glRasterPos2fv( const GLfloat *v ); GLAPI void GLAPIENTRY glRasterPos2iv( const GLint *v ); GLAPI void GLAPIENTRY glRasterPos2sv( const GLshort *v ); GLAPI void GLAPIENTRY glRasterPos3dv( const GLdouble *v ); GLAPI void GLAPIENTRY glRasterPos3fv( const GLfloat *v ); GLAPI void GLAPIENTRY glRasterPos3iv( const GLint *v ); GLAPI void GLAPIENTRY glRasterPos3sv( const GLshort *v ); GLAPI void GLAPIENTRY glRasterPos4dv( const GLdouble *v ); GLAPI void GLAPIENTRY glRasterPos4fv( const GLfloat *v ); GLAPI void GLAPIENTRY glRasterPos4iv( const GLint *v ); GLAPI void GLAPIENTRY glRasterPos4sv( const GLshort *v ); GLAPI void GLAPIENTRY glRectd( GLdouble x1, GLdouble y1, GLdouble x2, GLdouble y2 ); GLAPI void GLAPIENTRY glRectf( GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2 ); GLAPI void GLAPIENTRY glRecti( GLint x1, GLint y1, GLint x2, GLint y2 ); GLAPI void GLAPIENTRY glRects( GLshort x1, GLshort y1, GLshort x2, GLshort y2 ); GLAPI void GLAPIENTRY glRectdv( const GLdouble *v1, const GLdouble *v2 ); GLAPI void GLAPIENTRY glRectfv( const GLfloat *v1, const GLfloat *v2 ); GLAPI void GLAPIENTRY glRectiv( const GLint *v1, const GLint *v2 ); GLAPI void GLAPIENTRY glRectsv( const GLshort *v1, const GLshort *v2 ); /* * Vertex Arrays (1.1) */ GLAPI void GLAPIENTRY glVertexPointer( GLint size, GLenum type, GLsizei stride, const GLvoid *ptr ); GLAPI void GLAPIENTRY glNormalPointer( GLenum type, GLsizei stride, const GLvoid *ptr ); GLAPI void GLAPIENTRY glColorPointer( GLint size, GLenum type, GLsizei stride, const GLvoid *ptr ); GLAPI void GLAPIENTRY glIndexPointer( GLenum type, GLsizei stride, const GLvoid *ptr ); GLAPI void GLAPIENTRY glTexCoordPointer( GLint size, GLenum type, GLsizei stride, const GLvoid *ptr ); GLAPI void GLAPIENTRY glEdgeFlagPointer( GLsizei stride, const GLvoid *ptr ); GLAPI void GLAPIENTRY glGetPointerv( GLenum pname, GLvoid **params ); GLAPI void GLAPIENTRY glArrayElement( GLint i ); GLAPI void GLAPIENTRY glDrawArrays( GLenum mode, GLint first, GLsizei count ); GLAPI void GLAPIENTRY glDrawElements( GLenum mode, GLsizei count, GLenum type, const GLvoid *indices ); GLAPI void GLAPIENTRY glInterleavedArrays( GLenum format, GLsizei stride, const GLvoid *pointer ); /* * Lighting */ GLAPI void GLAPIENTRY glShadeModel( GLenum mode ); GLAPI void GLAPIENTRY glLightf( GLenum light, GLenum pname, GLfloat param ); GLAPI void GLAPIENTRY glLighti( GLenum light, GLenum pname, GLint param ); GLAPI void GLAPIENTRY glLightfv( GLenum light, GLenum pname, const GLfloat *params ); GLAPI void GLAPIENTRY glLightiv( GLenum light, GLenum pname, const GLint *params ); GLAPI void GLAPIENTRY glGetLightfv( GLenum light, GLenum pname, GLfloat *params ); GLAPI void GLAPIENTRY glGetLightiv( GLenum light, GLenum pname, GLint *params ); GLAPI void GLAPIENTRY glLightModelf( GLenum pname, GLfloat param ); GLAPI void GLAPIENTRY glLightModeli( GLenum pname, GLint param ); GLAPI void GLAPIENTRY glLightModelfv( GLenum pname, const GLfloat *params ); GLAPI void GLAPIENTRY glLightModeliv( GLenum pname, const GLint *params ); GLAPI void GLAPIENTRY glMaterialf( GLenum face, GLenum pname, GLfloat param ); GLAPI void GLAPIENTRY glMateriali( GLenum face, GLenum pname, GLint param ); GLAPI void GLAPIENTRY glMaterialfv( GLenum face, GLenum pname, const GLfloat *params ); GLAPI void GLAPIENTRY glMaterialiv( GLenum face, GLenum pname, const GLint *params ); GLAPI void GLAPIENTRY glGetMaterialfv( GLenum face, GLenum pname, GLfloat *params ); GLAPI void GLAPIENTRY glGetMaterialiv( GLenum face, GLenum pname, GLint *params ); GLAPI void GLAPIENTRY glColorMaterial( GLenum face, GLenum mode ); /* * Raster functions */ GLAPI void GLAPIENTRY glPixelZoom( GLfloat xfactor, GLfloat yfactor ); GLAPI void GLAPIENTRY glPixelStoref( GLenum pname, GLfloat param ); GLAPI void GLAPIENTRY glPixelStorei( GLenum pname, GLint param ); GLAPI void GLAPIENTRY glPixelTransferf( GLenum pname, GLfloat param ); GLAPI void GLAPIENTRY glPixelTransferi( GLenum pname, GLint param ); GLAPI void GLAPIENTRY glPixelMapfv( GLenum map, GLsizei mapsize, const GLfloat *values ); GLAPI void GLAPIENTRY glPixelMapuiv( GLenum map, GLsizei mapsize, const GLuint *values ); GLAPI void GLAPIENTRY glPixelMapusv( GLenum map, GLsizei mapsize, const GLushort *values ); GLAPI void GLAPIENTRY glGetPixelMapfv( GLenum map, GLfloat *values ); GLAPI void GLAPIENTRY glGetPixelMapuiv( GLenum map, GLuint *values ); GLAPI void GLAPIENTRY glGetPixelMapusv( GLenum map, GLushort *values ); GLAPI void GLAPIENTRY glBitmap( GLsizei width, GLsizei height, GLfloat xorig, GLfloat yorig, GLfloat xmove, GLfloat ymove, const GLubyte *bitmap ); GLAPI void GLAPIENTRY glReadPixels( GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels ); GLAPI void GLAPIENTRY glDrawPixels( GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels ); GLAPI void GLAPIENTRY glCopyPixels( GLint x, GLint y, GLsizei width, GLsizei height, GLenum type ); /* * Stenciling */ GLAPI void GLAPIENTRY glStencilFunc( GLenum func, GLint ref, GLuint mask ); GLAPI void GLAPIENTRY glStencilMask( GLuint mask ); GLAPI void GLAPIENTRY glStencilOp( GLenum fail, GLenum zfail, GLenum zpass ); GLAPI void GLAPIENTRY glClearStencil( GLint s ); /* * Texture mapping */ GLAPI void GLAPIENTRY glTexGend( GLenum coord, GLenum pname, GLdouble param ); GLAPI void GLAPIENTRY glTexGenf( GLenum coord, GLenum pname, GLfloat param ); GLAPI void GLAPIENTRY glTexGeni( GLenum coord, GLenum pname, GLint param ); GLAPI void GLAPIENTRY glTexGendv( GLenum coord, GLenum pname, const GLdouble *params ); GLAPI void GLAPIENTRY glTexGenfv( GLenum coord, GLenum pname, const GLfloat *params ); GLAPI void GLAPIENTRY glTexGeniv( GLenum coord, GLenum pname, const GLint *params ); GLAPI void GLAPIENTRY glGetTexGendv( GLenum coord, GLenum pname, GLdouble *params ); GLAPI void GLAPIENTRY glGetTexGenfv( GLenum coord, GLenum pname, GLfloat *params ); GLAPI void GLAPIENTRY glGetTexGeniv( GLenum coord, GLenum pname, GLint *params ); GLAPI void GLAPIENTRY glTexEnvf( GLenum target, GLenum pname, GLfloat param ); GLAPI void GLAPIENTRY glTexEnvi( GLenum target, GLenum pname, GLint param ); GLAPI void GLAPIENTRY glTexEnvfv( GLenum target, GLenum pname, const GLfloat *params ); GLAPI void GLAPIENTRY glTexEnviv( GLenum target, GLenum pname, const GLint *params ); GLAPI void GLAPIENTRY glGetTexEnvfv( GLenum target, GLenum pname, GLfloat *params ); GLAPI void GLAPIENTRY glGetTexEnviv( GLenum target, GLenum pname, GLint *params ); GLAPI void GLAPIENTRY glTexParameterf( GLenum target, GLenum pname, GLfloat param ); GLAPI void GLAPIENTRY glTexParameteri( GLenum target, GLenum pname, GLint param ); GLAPI void GLAPIENTRY glTexParameterfv( GLenum target, GLenum pname, const GLfloat *params ); GLAPI void GLAPIENTRY glTexParameteriv( GLenum target, GLenum pname, const GLint *params ); GLAPI void GLAPIENTRY glGetTexParameterfv( GLenum target, GLenum pname, GLfloat *params); GLAPI void GLAPIENTRY glGetTexParameteriv( GLenum target, GLenum pname, GLint *params ); GLAPI void GLAPIENTRY glGetTexLevelParameterfv( GLenum target, GLint level, GLenum pname, GLfloat *params ); GLAPI void GLAPIENTRY glGetTexLevelParameteriv( GLenum target, GLint level, GLenum pname, GLint *params ); GLAPI void GLAPIENTRY glTexImage1D( GLenum target, GLint level, GLint internalFormat, GLsizei width, GLint border, GLenum format, GLenum type, const GLvoid *pixels ); GLAPI void GLAPIENTRY glTexImage2D( GLenum target, GLint level, GLint internalFormat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels ); GLAPI void GLAPIENTRY glGetTexImage( GLenum target, GLint level, GLenum format, GLenum type, GLvoid *pixels ); /* 1.1 functions */ GLAPI void GLAPIENTRY glGenTextures( GLsizei n, GLuint *textures ); GLAPI void GLAPIENTRY glDeleteTextures( GLsizei n, const GLuint *textures); GLAPI void GLAPIENTRY glBindTexture( GLenum target, GLuint texture ); GLAPI void GLAPIENTRY glPrioritizeTextures( GLsizei n, const GLuint *textures, const GLclampf *priorities ); GLAPI GLboolean GLAPIENTRY glAreTexturesResident( GLsizei n, const GLuint *textures, GLboolean *residences ); GLAPI GLboolean GLAPIENTRY glIsTexture( GLuint texture ); GLAPI void GLAPIENTRY glTexSubImage1D( GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels ); GLAPI void GLAPIENTRY glTexSubImage2D( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels ); GLAPI void GLAPIENTRY glCopyTexImage1D( GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border ); GLAPI void GLAPIENTRY glCopyTexImage2D( GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border ); GLAPI void GLAPIENTRY glCopyTexSubImage1D( GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width ); GLAPI void GLAPIENTRY glCopyTexSubImage2D( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height ); /* * Evaluators */ GLAPI void GLAPIENTRY glMap1d( GLenum target, GLdouble u1, GLdouble u2, GLint stride, GLint order, const GLdouble *points ); GLAPI void GLAPIENTRY glMap1f( GLenum target, GLfloat u1, GLfloat u2, GLint stride, GLint order, const GLfloat *points ); GLAPI void GLAPIENTRY glMap2d( GLenum target, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, const GLdouble *points ); GLAPI void GLAPIENTRY glMap2f( GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, const GLfloat *points ); GLAPI void GLAPIENTRY glGetMapdv( GLenum target, GLenum query, GLdouble *v ); GLAPI void GLAPIENTRY glGetMapfv( GLenum target, GLenum query, GLfloat *v ); GLAPI void GLAPIENTRY glGetMapiv( GLenum target, GLenum query, GLint *v ); GLAPI void GLAPIENTRY glEvalCoord1d( GLdouble u ); GLAPI void GLAPIENTRY glEvalCoord1f( GLfloat u ); GLAPI void GLAPIENTRY glEvalCoord1dv( const GLdouble *u ); GLAPI void GLAPIENTRY glEvalCoord1fv( const GLfloat *u ); GLAPI void GLAPIENTRY glEvalCoord2d( GLdouble u, GLdouble v ); GLAPI void GLAPIENTRY glEvalCoord2f( GLfloat u, GLfloat v ); GLAPI void GLAPIENTRY glEvalCoord2dv( const GLdouble *u ); GLAPI void GLAPIENTRY glEvalCoord2fv( const GLfloat *u ); GLAPI void GLAPIENTRY glMapGrid1d( GLint un, GLdouble u1, GLdouble u2 ); GLAPI void GLAPIENTRY glMapGrid1f( GLint un, GLfloat u1, GLfloat u2 ); GLAPI void GLAPIENTRY glMapGrid2d( GLint un, GLdouble u1, GLdouble u2, GLint vn, GLdouble v1, GLdouble v2 ); GLAPI void GLAPIENTRY glMapGrid2f( GLint un, GLfloat u1, GLfloat u2, GLint vn, GLfloat v1, GLfloat v2 ); GLAPI void GLAPIENTRY glEvalPoint1( GLint i ); GLAPI void GLAPIENTRY glEvalPoint2( GLint i, GLint j ); GLAPI void GLAPIENTRY glEvalMesh1( GLenum mode, GLint i1, GLint i2 ); GLAPI void GLAPIENTRY glEvalMesh2( GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2 ); /* * Fog */ GLAPI void GLAPIENTRY glFogf( GLenum pname, GLfloat param ); GLAPI void GLAPIENTRY glFogi( GLenum pname, GLint param ); GLAPI void GLAPIENTRY glFogfv( GLenum pname, const GLfloat *params ); GLAPI void GLAPIENTRY glFogiv( GLenum pname, const GLint *params ); /* * Selection and Feedback */ GLAPI void GLAPIENTRY glFeedbackBuffer( GLsizei size, GLenum type, GLfloat *buffer ); GLAPI void GLAPIENTRY glPassThrough( GLfloat token ); GLAPI void GLAPIENTRY glSelectBuffer( GLsizei size, GLuint *buffer ); GLAPI void GLAPIENTRY glInitNames( void ); GLAPI void GLAPIENTRY glLoadName( GLuint name ); GLAPI void GLAPIENTRY glPushName( GLuint name ); GLAPI void GLAPIENTRY glPopName( void ); #endif #ifdef SDL_OPENGL_1_FUNCTION_TYPEDEFS typedef void (APIENTRYP PFNGLCLEARINDEXPROC) ( GLfloat c ); typedef void (APIENTRYP PFNGLCLEARCOLORPROC) ( GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha ); typedef void (APIENTRYP PFNGLCLEARPROC) ( GLbitfield mask ); typedef void (APIENTRYP PFNGLINDEXMASKPROC) ( GLuint mask ); typedef void (APIENTRYP PFNGLCOLORMASKPROC) ( GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha ); typedef void (APIENTRYP PFNGLALPHAFUNCPROC) ( GLenum func, GLclampf ref ); typedef void (APIENTRYP PFNGLBLENDFUNCPROC) ( GLenum sfactor, GLenum dfactor ); typedef void (APIENTRYP PFNGLLOGICOPPROC) ( GLenum opcode ); typedef void (APIENTRYP PFNGLCULLFACEPROC) ( GLenum mode ); typedef void (APIENTRYP PFNGLFRONTFACEPROC) ( GLenum mode ); typedef void (APIENTRYP PFNGLPOINTSIZEPROC) ( GLfloat size ); typedef void (APIENTRYP PFNGLLINEWIDTHPROC) ( GLfloat width ); typedef void (APIENTRYP PFNGLLINESTIPPLEPROC) ( GLint factor, GLushort pattern ); typedef void (APIENTRYP PFNGLPOLYGONMODEPROC) ( GLenum face, GLenum mode ); typedef void (APIENTRYP PFNGLPOLYGONOFFSETPROC) ( GLfloat factor, GLfloat units ); typedef void (APIENTRYP PFNGLPOLYGONSTIPPLEPROC) ( const GLubyte *mask ); typedef void (APIENTRYP PFNGLGETPOLYGONSTIPPLEPROC) ( GLubyte *mask ); typedef void (APIENTRYP PFNGLEDGEFLAGPROC) ( GLboolean flag ); typedef void (APIENTRYP PFNGLEDGEFLAGVPROC) ( const GLboolean *flag ); typedef void (APIENTRYP PFNGLSCISSORPROC) ( GLint x, GLint y, GLsizei width, GLsizei height); typedef void (APIENTRYP PFNGLCLIPPLANEPROC) ( GLenum plane, const GLdouble *equation ); typedef void (APIENTRYP PFNGLGETCLIPPLANEPROC) ( GLenum plane, GLdouble *equation ); typedef void (APIENTRYP PFNGLDRAWBUFFERPROC) ( GLenum mode ); typedef void (APIENTRYP PFNGLREADBUFFERPROC) ( GLenum mode ); typedef void (APIENTRYP PFNGLENABLEPROC) ( GLenum cap ); typedef void (APIENTRYP PFNGLDISABLEPROC) ( GLenum cap ); typedef GLboolean (APIENTRYP PFNGLISENABLEDPROC) ( GLenum cap ); typedef void (APIENTRYP PFNGLENABLECLIENTSTATEPROC) ( GLenum cap ); /* 1.1 */ typedef void (APIENTRYP PFNGLDISABLECLIENTSTATEPROC) ( GLenum cap ); /* 1.1 */ typedef void (APIENTRYP PFNGLGETBOOLEANVPROC) ( GLenum pname, GLboolean *params ); typedef void (APIENTRYP PFNGLGETDOUBLEVPROC) ( GLenum pname, GLdouble *params ); typedef void (APIENTRYP PFNGLGETFLOATVPROC) ( GLenum pname, GLfloat *params ); typedef void (APIENTRYP PFNGLGETINTEGERVPROC) ( GLenum pname, GLint *params ); typedef void (APIENTRYP PFNGLPUSHATTRIBPROC) ( GLbitfield mask ); typedef void (APIENTRYP PFNGLPOPATTRIBPROC) ( void ); typedef void (APIENTRYP PFNGLPUSHCLIENTATTRIBPROC) ( GLbitfield mask ); /* 1.1 */ typedef void (APIENTRYP PFNGLPOPCLIENTATTRIBPROC) ( void ); /* 1.1 */ typedef GLint (APIENTRYP PFNGLRENDERMODEPROC) ( GLenum mode ); typedef GLenum (APIENTRYP PFNGLGETERRORPROC) ( void ); typedef const GLubyte * (APIENTRYP PFNGLGETSTRINGPROC) ( GLenum name ); typedef void (APIENTRYP PFNGLFINISHPROC) ( void ); typedef void (APIENTRYP PFNGLFLUSHPROC) ( void ); typedef void (APIENTRYP PFNGLHINTPROC) ( GLenum target, GLenum mode ); /* * Depth Buffer */ typedef void (APIENTRYP PFNGLCLEARDEPTHPROC) ( GLclampd depth ); typedef void (APIENTRYP PFNGLDEPTHFUNCPROC) ( GLenum func ); typedef void (APIENTRYP PFNGLDEPTHMASKPROC) ( GLboolean flag ); typedef void (APIENTRYP PFNGLDEPTHRANGEPROC) ( GLclampd near_val, GLclampd far_val ); /* * Accumulation Buffer */ typedef void (APIENTRYP PFNGLCLEARACCUMPROC) ( GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha ); typedef void (APIENTRYP PFNGLACCUMPROC) ( GLenum op, GLfloat value ); /* * Transformation */ typedef void (APIENTRYP PFNGLMATRIXMODEPROC) ( GLenum mode ); typedef void (APIENTRYP PFNGLORTHOPROC) ( GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble near_val, GLdouble far_val ); typedef void (APIENTRYP PFNGLFRUSTUMPROC) ( GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble near_val, GLdouble far_val ); typedef void (APIENTRYP PFNGLVIEWPORTPROC) ( GLint x, GLint y, GLsizei width, GLsizei height ); typedef void (APIENTRYP PFNGLPUSHMATRIXPROC) ( void ); typedef void (APIENTRYP PFNGLPOPMATRIXPROC) ( void ); typedef void (APIENTRYP PFNGLLOADIDENTITYPROC) ( void ); typedef void (APIENTRYP PFNGLLOADMATRIXDPROC) ( const GLdouble *m ); typedef void (APIENTRYP PFNGLLOADMATRIXFPROC) ( const GLfloat *m ); typedef void (APIENTRYP PFNGLMULTMATRIXDPROC) ( const GLdouble *m ); typedef void (APIENTRYP PFNGLMULTMATRIXFPROC) ( const GLfloat *m ); typedef void (APIENTRYP PFNGLROTATEDPROC) ( GLdouble angle, GLdouble x, GLdouble y, GLdouble z ); typedef void (APIENTRYP PFNGLROTATEFPROC) ( GLfloat angle, GLfloat x, GLfloat y, GLfloat z ); typedef void (APIENTRYP PFNGLSCALEDPROC) ( GLdouble x, GLdouble y, GLdouble z ); typedef void (APIENTRYP PFNGLSCALEFPROC) ( GLfloat x, GLfloat y, GLfloat z ); typedef void (APIENTRYP PFNGLTRANSLATEDPROC) ( GLdouble x, GLdouble y, GLdouble z ); typedef void (APIENTRYP PFNGLTRANSLATEFPROC) ( GLfloat x, GLfloat y, GLfloat z ); /* * Display Lists */ typedef GLboolean (APIENTRYP PFNGLISLISTPROC) ( GLuint list ); typedef void (APIENTRYP PFNGLDELETELISTSPROC) ( GLuint list, GLsizei range ); typedef GLuint (APIENTRYP PFNGLGENLISTSPROC) ( GLsizei range ); typedef void (APIENTRYP PFNGLNEWLISTPROC) ( GLuint list, GLenum mode ); typedef void (APIENTRYP PFNGLENDLISTPROC) ( void ); typedef void (APIENTRYP PFNGLCALLLISTPROC) ( GLuint list ); typedef void (APIENTRYP PFNGLCALLLISTSPROC) ( GLsizei n, GLenum type, const GLvoid *lists ); typedef void (APIENTRYP PFNGLLISTBASEPROC) ( GLuint base ); /* * Drawing Functions */ typedef void (APIENTRYP PFNGLBEGINPROC) ( GLenum mode ); typedef void (APIENTRYP PFNGLENDPROC) ( void ); typedef void (APIENTRYP PFNGLVERTEX2DPROC) ( GLdouble x, GLdouble y ); typedef void (APIENTRYP PFNGLVERTEX2FPROC) ( GLfloat x, GLfloat y ); typedef void (APIENTRYP PFNGLVERTEX2IPROC) ( GLint x, GLint y ); typedef void (APIENTRYP PFNGLVERTEX2SPROC) ( GLshort x, GLshort y ); typedef void (APIENTRYP PFNGLVERTEX3DPROC) ( GLdouble x, GLdouble y, GLdouble z ); typedef void (APIENTRYP PFNGLVERTEX3FPROC) ( GLfloat x, GLfloat y, GLfloat z ); typedef void (APIENTRYP PFNGLVERTEX3IPROC) ( GLint x, GLint y, GLint z ); typedef void (APIENTRYP PFNGLVERTEX3SPROC) ( GLshort x, GLshort y, GLshort z ); typedef void (APIENTRYP PFNGLVERTEX4DPROC) ( GLdouble x, GLdouble y, GLdouble z, GLdouble w ); typedef void (APIENTRYP PFNGLVERTEX4FPROC) ( GLfloat x, GLfloat y, GLfloat z, GLfloat w ); typedef void (APIENTRYP PFNGLVERTEX4IPROC) ( GLint x, GLint y, GLint z, GLint w ); typedef void (APIENTRYP PFNGLVERTEX4SPROC) ( GLshort x, GLshort y, GLshort z, GLshort w ); typedef void (APIENTRYP PFNGLVERTEX2DVPROC) ( const GLdouble *v ); typedef void (APIENTRYP PFNGLVERTEX2FVPROC) ( const GLfloat *v ); typedef void (APIENTRYP PFNGLVERTEX2IVPROC) ( const GLint *v ); typedef void (APIENTRYP PFNGLVERTEX2SVPROC) ( const GLshort *v ); typedef void (APIENTRYP PFNGLVERTEX3DVPROC) ( const GLdouble *v ); typedef void (APIENTRYP PFNGLVERTEX3FVPROC) ( const GLfloat *v ); typedef void (APIENTRYP PFNGLVERTEX3IVPROC) ( const GLint *v ); typedef void (APIENTRYP PFNGLVERTEX3SVPROC) ( const GLshort *v ); typedef void (APIENTRYP PFNGLVERTEX4DVPROC) ( const GLdouble *v ); typedef void (APIENTRYP PFNGLVERTEX4FVPROC) ( const GLfloat *v ); typedef void (APIENTRYP PFNGLVERTEX4IVPROC) ( const GLint *v ); typedef void (APIENTRYP PFNGLVERTEX4SVPROC) ( const GLshort *v ); typedef void (APIENTRYP PFNGLNORMAL3BPROC) ( GLbyte nx, GLbyte ny, GLbyte nz ); typedef void (APIENTRYP PFNGLNORMAL3DPROC) ( GLdouble nx, GLdouble ny, GLdouble nz ); typedef void (APIENTRYP PFNGLNORMAL3FPROC) ( GLfloat nx, GLfloat ny, GLfloat nz ); typedef void (APIENTRYP PFNGLNORMAL3IPROC) ( GLint nx, GLint ny, GLint nz ); typedef void (APIENTRYP PFNGLNORMAL3SPROC) ( GLshort nx, GLshort ny, GLshort nz ); typedef void (APIENTRYP PFNGLNORMAL3BVPROC) ( const GLbyte *v ); typedef void (APIENTRYP PFNGLNORMAL3DVPROC) ( const GLdouble *v ); typedef void (APIENTRYP PFNGLNORMAL3FVPROC) ( const GLfloat *v ); typedef void (APIENTRYP PFNGLNORMAL3IVPROC) ( const GLint *v ); typedef void (APIENTRYP PFNGLNORMAL3SVPROC) ( const GLshort *v ); typedef void (APIENTRYP PFNGLINDEXDPROC) ( GLdouble c ); typedef void (APIENTRYP PFNGLINDEXFPROC) ( GLfloat c ); typedef void (APIENTRYP PFNGLINDEXIPROC) ( GLint c ); typedef void (APIENTRYP PFNGLINDEXSPROC) ( GLshort c ); typedef void (APIENTRYP PFNGLINDEXUBPROC) ( GLubyte c ); /* 1.1 */ typedef void (APIENTRYP PFNGLINDEXDVPROC) ( const GLdouble *c ); typedef void (APIENTRYP PFNGLINDEXFVPROC) ( const GLfloat *c ); typedef void (APIENTRYP PFNGLINDEXIVPROC) ( const GLint *c ); typedef void (APIENTRYP PFNGLINDEXSVPROC) ( const GLshort *c ); typedef void (APIENTRYP PFNGLINDEXUBVPROC) ( const GLubyte *c ); /* 1.1 */ typedef void (APIENTRYP PFNGLCOLOR3BPROC) ( GLbyte red, GLbyte green, GLbyte blue ); typedef void (APIENTRYP PFNGLCOLOR3DPROC) ( GLdouble red, GLdouble green, GLdouble blue ); typedef void (APIENTRYP PFNGLCOLOR3FPROC) ( GLfloat red, GLfloat green, GLfloat blue ); typedef void (APIENTRYP PFNGLCOLOR3IPROC) ( GLint red, GLint green, GLint blue ); typedef void (APIENTRYP PFNGLCOLOR3SPROC) ( GLshort red, GLshort green, GLshort blue ); typedef void (APIENTRYP PFNGLCOLOR3UBPROC) ( GLubyte red, GLubyte green, GLubyte blue ); typedef void (APIENTRYP PFNGLCOLOR3UIPROC) ( GLuint red, GLuint green, GLuint blue ); typedef void (APIENTRYP PFNGLCOLOR3USPROC) ( GLushort red, GLushort green, GLushort blue ); typedef void (APIENTRYP PFNGLCOLOR4BPROC) ( GLbyte red, GLbyte green, GLbyte blue, GLbyte alpha ); typedef void (APIENTRYP PFNGLCOLOR4DPROC) ( GLdouble red, GLdouble green, GLdouble blue, GLdouble alpha ); typedef void (APIENTRYP PFNGLCOLOR4FPROC) ( GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha ); typedef void (APIENTRYP PFNGLCOLOR4IPROC) ( GLint red, GLint green, GLint blue, GLint alpha ); typedef void (APIENTRYP PFNGLCOLOR4SPROC) ( GLshort red, GLshort green, GLshort blue, GLshort alpha ); typedef void (APIENTRYP PFNGLCOLOR4UBPROC) ( GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha ); typedef void (APIENTRYP PFNGLCOLOR4UIPROC) ( GLuint red, GLuint green, GLuint blue, GLuint alpha ); typedef void (APIENTRYP PFNGLCOLOR4USPROC) ( GLushort red, GLushort green, GLushort blue, GLushort alpha ); typedef void (APIENTRYP PFNGLCOLOR3BVPROC) ( const GLbyte *v ); typedef void (APIENTRYP PFNGLCOLOR3DVPROC) ( const GLdouble *v ); typedef void (APIENTRYP PFNGLCOLOR3FVPROC) ( const GLfloat *v ); typedef void (APIENTRYP PFNGLCOLOR3IVPROC) ( const GLint *v ); typedef void (APIENTRYP PFNGLCOLOR3SVPROC) ( const GLshort *v ); typedef void (APIENTRYP PFNGLCOLOR3UBVPROC) ( const GLubyte *v ); typedef void (APIENTRYP PFNGLCOLOR3UIVPROC) ( const GLuint *v ); typedef void (APIENTRYP PFNGLCOLOR3USVPROC) ( const GLushort *v ); typedef void (APIENTRYP PFNGLCOLOR4BVPROC) ( const GLbyte *v ); typedef void (APIENTRYP PFNGLCOLOR4DVPROC) ( const GLdouble *v ); typedef void (APIENTRYP PFNGLCOLOR4FVPROC) ( const GLfloat *v ); typedef void (APIENTRYP PFNGLCOLOR4IVPROC) ( const GLint *v ); typedef void (APIENTRYP PFNGLCOLOR4SVPROC) ( const GLshort *v ); typedef void (APIENTRYP PFNGLCOLOR4UBVPROC) ( const GLubyte *v ); typedef void (APIENTRYP PFNGLCOLOR4UIVPROC) ( const GLuint *v ); typedef void (APIENTRYP PFNGLCOLOR4USVPROC) ( const GLushort *v ); typedef void (APIENTRYP PFNGLTEXCOORD1DPROC) ( GLdouble s ); typedef void (APIENTRYP PFNGLTEXCOORD1FPROC) ( GLfloat s ); typedef void (APIENTRYP PFNGLTEXCOORD1IPROC) ( GLint s ); typedef void (APIENTRYP PFNGLTEXCOORD1SPROC) ( GLshort s ); typedef void (APIENTRYP PFNGLTEXCOORD2DPROC) ( GLdouble s, GLdouble t ); typedef void (APIENTRYP PFNGLTEXCOORD2FPROC) ( GLfloat s, GLfloat t ); typedef void (APIENTRYP PFNGLTEXCOORD2IPROC) ( GLint s, GLint t ); typedef void (APIENTRYP PFNGLTEXCOORD2SPROC) ( GLshort s, GLshort t ); typedef void (APIENTRYP PFNGLTEXCOORD3DPROC) ( GLdouble s, GLdouble t, GLdouble r ); typedef void (APIENTRYP PFNGLTEXCOORD3FPROC) ( GLfloat s, GLfloat t, GLfloat r ); typedef void (APIENTRYP PFNGLTEXCOORD3IPROC) ( GLint s, GLint t, GLint r ); typedef void (APIENTRYP PFNGLTEXCOORD3SPROC) ( GLshort s, GLshort t, GLshort r ); typedef void (APIENTRYP PFNGLTEXCOORD4DPROC) ( GLdouble s, GLdouble t, GLdouble r, GLdouble q ); typedef void (APIENTRYP PFNGLTEXCOORD4FPROC) ( GLfloat s, GLfloat t, GLfloat r, GLfloat q ); typedef void (APIENTRYP PFNGLTEXCOORD4IPROC) ( GLint s, GLint t, GLint r, GLint q ); typedef void (APIENTRYP PFNGLTEXCOORD4SPROC) ( GLshort s, GLshort t, GLshort r, GLshort q ); typedef void (APIENTRYP PFNGLTEXCOORD1DVPROC) ( const GLdouble *v ); typedef void (APIENTRYP PFNGLTEXCOORD1FVPROC) ( const GLfloat *v ); typedef void (APIENTRYP PFNGLTEXCOORD1IVPROC) ( const GLint *v ); typedef void (APIENTRYP PFNGLTEXCOORD1SVPROC) ( const GLshort *v ); typedef void (APIENTRYP PFNGLTEXCOORD2DVPROC) ( const GLdouble *v ); typedef void (APIENTRYP PFNGLTEXCOORD2FVPROC) ( const GLfloat *v ); typedef void (APIENTRYP PFNGLTEXCOORD2IVPROC) ( const GLint *v ); typedef void (APIENTRYP PFNGLTEXCOORD2SVPROC) ( const GLshort *v ); typedef void (APIENTRYP PFNGLTEXCOORD3DVPROC) ( const GLdouble *v ); typedef void (APIENTRYP PFNGLTEXCOORD3FVPROC) ( const GLfloat *v ); typedef void (APIENTRYP PFNGLTEXCOORD3IVPROC) ( const GLint *v ); typedef void (APIENTRYP PFNGLTEXCOORD3SVPROC) ( const GLshort *v ); typedef void (APIENTRYP PFNGLTEXCOORD4DVPROC) ( const GLdouble *v ); typedef void (APIENTRYP PFNGLTEXCOORD4FVPROC) ( const GLfloat *v ); typedef void (APIENTRYP PFNGLTEXCOORD4IVPROC) ( const GLint *v ); typedef void (APIENTRYP PFNGLTEXCOORD4SVPROC) ( const GLshort *v ); typedef void (APIENTRYP PFNGLRASTERPOS2DPROC) ( GLdouble x, GLdouble y ); typedef void (APIENTRYP PFNGLRASTERPOS2FPROC) ( GLfloat x, GLfloat y ); typedef void (APIENTRYP PFNGLRASTERPOS2IPROC) ( GLint x, GLint y ); typedef void (APIENTRYP PFNGLRASTERPOS2SPROC) ( GLshort x, GLshort y ); typedef void (APIENTRYP PFNGLRASTERPOS3DPROC) ( GLdouble x, GLdouble y, GLdouble z ); typedef void (APIENTRYP PFNGLRASTERPOS3FPROC) ( GLfloat x, GLfloat y, GLfloat z ); typedef void (APIENTRYP PFNGLRASTERPOS3IPROC) ( GLint x, GLint y, GLint z ); typedef void (APIENTRYP PFNGLRASTERPOS3SPROC) ( GLshort x, GLshort y, GLshort z ); typedef void (APIENTRYP PFNGLRASTERPOS4DPROC) ( GLdouble x, GLdouble y, GLdouble z, GLdouble w ); typedef void (APIENTRYP PFNGLRASTERPOS4FPROC) ( GLfloat x, GLfloat y, GLfloat z, GLfloat w ); typedef void (APIENTRYP PFNGLRASTERPOS4IPROC) ( GLint x, GLint y, GLint z, GLint w ); typedef void (APIENTRYP PFNGLRASTERPOS4SPROC) ( GLshort x, GLshort y, GLshort z, GLshort w ); typedef void (APIENTRYP PFNGLRASTERPOS2DVPROC) ( const GLdouble *v ); typedef void (APIENTRYP PFNGLRASTERPOS2FVPROC) ( const GLfloat *v ); typedef void (APIENTRYP PFNGLRASTERPOS2IVPROC) ( const GLint *v ); typedef void (APIENTRYP PFNGLRASTERPOS2SVPROC) ( const GLshort *v ); typedef void (APIENTRYP PFNGLRASTERPOS3DVPROC) ( const GLdouble *v ); typedef void (APIENTRYP PFNGLRASTERPOS3FVPROC) ( const GLfloat *v ); typedef void (APIENTRYP PFNGLRASTERPOS3IVPROC) ( const GLint *v ); typedef void (APIENTRYP PFNGLRASTERPOS3SVPROC) ( const GLshort *v ); typedef void (APIENTRYP PFNGLRASTERPOS4DVPROC) ( const GLdouble *v ); typedef void (APIENTRYP PFNGLRASTERPOS4FVPROC) ( const GLfloat *v ); typedef void (APIENTRYP PFNGLRASTERPOS4IVPROC) ( const GLint *v ); typedef void (APIENTRYP PFNGLRASTERPOS4SVPROC) ( const GLshort *v ); typedef void (APIENTRYP PFNGLRECTDPROC) ( GLdouble x1, GLdouble y1, GLdouble x2, GLdouble y2 ); typedef void (APIENTRYP PFNGLRECTFPROC) ( GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2 ); typedef void (APIENTRYP PFNGLRECTIPROC) ( GLint x1, GLint y1, GLint x2, GLint y2 ); typedef void (APIENTRYP PFNGLRECTSPROC) ( GLshort x1, GLshort y1, GLshort x2, GLshort y2 ); typedef void (APIENTRYP PFNGLRECTDVPROC) ( const GLdouble *v1, const GLdouble *v2 ); typedef void (APIENTRYP PFNGLRECTFVPROC) ( const GLfloat *v1, const GLfloat *v2 ); typedef void (APIENTRYP PFNGLRECTIVPROC) ( const GLint *v1, const GLint *v2 ); typedef void (APIENTRYP PFNGLRECTSVPROC) ( const GLshort *v1, const GLshort *v2 ); /* * Vertex Arrays (1.1) */ typedef void (APIENTRYP PFNGLVERTEXPOINTERPROC) ( GLint size, GLenum type, GLsizei stride, const GLvoid *ptr ); typedef void (APIENTRYP PFNGLNORMALPOINTERPROC) ( GLenum type, GLsizei stride, const GLvoid *ptr ); typedef void (APIENTRYP PFNGLCOLORPOINTERPROC) ( GLint size, GLenum type, GLsizei stride, const GLvoid *ptr ); typedef void (APIENTRYP PFNGLINDEXPOINTERPROC) ( GLenum type, GLsizei stride, const GLvoid *ptr ); typedef void (APIENTRYP PFNGLTEXCOORDPOINTERPROC) ( GLint size, GLenum type, GLsizei stride, const GLvoid *ptr ); typedef void (APIENTRYP PFNGLEDGEFLAGPOINTERPROC) ( GLsizei stride, const GLvoid *ptr ); typedef void (APIENTRYP PFNGLGETPOINTERVPROC) ( GLenum pname, GLvoid **params ); typedef void (APIENTRYP PFNGLARRAYELEMENTPROC) ( GLint i ); typedef void (APIENTRYP PFNGLDRAWARRAYSPROC) ( GLenum mode, GLint first, GLsizei count ); typedef void (APIENTRYP PFNGLDRAWELEMENTSPROC) ( GLenum mode, GLsizei count, GLenum type, const GLvoid *indices ); typedef void (APIENTRYP PFNGLINTERLEAVEDARRAYSPROC) ( GLenum format, GLsizei stride, const GLvoid *pointer ); /* * Lighting */ typedef void (APIENTRYP PFNGLSHADEMODELPROC) ( GLenum mode ); typedef void (APIENTRYP PFNGLLIGHTFPROC) ( GLenum light, GLenum pname, GLfloat param ); typedef void (APIENTRYP PFNGLLIGHTIPROC) ( GLenum light, GLenum pname, GLint param ); typedef void (APIENTRYP PFNGLLIGHTFVPROC) ( GLenum light, GLenum pname, const GLfloat *params ); typedef void (APIENTRYP PFNGLLIGHTIVPROC) ( GLenum light, GLenum pname, const GLint *params ); typedef void (APIENTRYP PFNGLGETLIGHTFVPROC) ( GLenum light, GLenum pname, GLfloat *params ); typedef void (APIENTRYP PFNGLGETLIGHTIVPROC) ( GLenum light, GLenum pname, GLint *params ); typedef void (APIENTRYP PFNGLLIGHTMODELFPROC) ( GLenum pname, GLfloat param ); typedef void (APIENTRYP PFNGLLIGHTMODELIPROC) ( GLenum pname, GLint param ); typedef void (APIENTRYP PFNGLLIGHTMODELFVPROC) ( GLenum pname, const GLfloat *params ); typedef void (APIENTRYP PFNGLLIGHTMODELIVPROC) ( GLenum pname, const GLint *params ); typedef void (APIENTRYP PFNGLMATERIALFPROC) ( GLenum face, GLenum pname, GLfloat param ); typedef void (APIENTRYP PFNGLMATERIALIPROC) ( GLenum face, GLenum pname, GLint param ); typedef void (APIENTRYP PFNGLMATERIALFVPROC) ( GLenum face, GLenum pname, const GLfloat *params ); typedef void (APIENTRYP PFNGLMATERIALIVPROC) ( GLenum face, GLenum pname, const GLint *params ); typedef void (APIENTRYP PFNGLGETMATERIALFVPROC) ( GLenum face, GLenum pname, GLfloat *params ); typedef void (APIENTRYP PFNGLGETMATERIALIVPROC) ( GLenum face, GLenum pname, GLint *params ); typedef void (APIENTRYP PFNGLCOLORMATERIALPROC) ( GLenum face, GLenum mode ); /* * Raster functions */ typedef void (APIENTRYP PFNGLPIXELZOOMPROC) ( GLfloat xfactor, GLfloat yfactor ); typedef void (APIENTRYP PFNGLPIXELSTOREFPROC) ( GLenum pname, GLfloat param ); typedef void (APIENTRYP PFNGLPIXELSTOREIPROC) ( GLenum pname, GLint param ); typedef void (APIENTRYP PFNGLPIXELTRANSFERFPROC) ( GLenum pname, GLfloat param ); typedef void (APIENTRYP PFNGLPIXELTRANSFERIPROC) ( GLenum pname, GLint param ); typedef void (APIENTRYP PFNGLPIXELMAPFVPROC) ( GLenum map, GLsizei mapsize, const GLfloat *values ); typedef void (APIENTRYP PFNGLPIXELMAPUIVPROC) ( GLenum map, GLsizei mapsize, const GLuint *values ); typedef void (APIENTRYP PFNGLPIXELMAPUSVPROC) ( GLenum map, GLsizei mapsize, const GLushort *values ); typedef void (APIENTRYP PFNGLGETPIXELMAPFVPROC) ( GLenum map, GLfloat *values ); typedef void (APIENTRYP PFNGLGETPIXELMAPUIVPROC) ( GLenum map, GLuint *values ); typedef void (APIENTRYP PFNGLGETPIXELMAPUSVPROC) ( GLenum map, GLushort *values ); typedef void (APIENTRYP PFNGLBITMAPPROC) ( GLsizei width, GLsizei height, GLfloat xorig, GLfloat yorig, GLfloat xmove, GLfloat ymove, const GLubyte *bitmap ); typedef void (APIENTRYP PFNGLREADPIXELSPROC) ( GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels ); typedef void (APIENTRYP PFNGLDRAWPIXELSPROC) ( GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels ); typedef void (APIENTRYP PFNGLCOPYPIXELSPROC) ( GLint x, GLint y, GLsizei width, GLsizei height, GLenum type ); /* * Stenciling */ typedef void (APIENTRYP PFNGLSTENCILFUNCPROC) ( GLenum func, GLint ref, GLuint mask ); typedef void (APIENTRYP PFNGLSTENCILMASKPROC) ( GLuint mask ); typedef void (APIENTRYP PFNGLSTENCILOPPROC) ( GLenum fail, GLenum zfail, GLenum zpass ); typedef void (APIENTRYP PFNGLCLEARSTENCILPROC) ( GLint s ); /* * Texture mapping */ typedef void (APIENTRYP PFNGLTEXGENDPROC) ( GLenum coord, GLenum pname, GLdouble param ); typedef void (APIENTRYP PFNGLTEXGENFPROC) ( GLenum coord, GLenum pname, GLfloat param ); typedef void (APIENTRYP PFNGLTEXGENIPROC) ( GLenum coord, GLenum pname, GLint param ); typedef void (APIENTRYP PFNGLTEXGENDVPROC) ( GLenum coord, GLenum pname, const GLdouble *params ); typedef void (APIENTRYP PFNGLTEXGENFVPROC) ( GLenum coord, GLenum pname, const GLfloat *params ); typedef void (APIENTRYP PFNGLTEXGENIVPROC) ( GLenum coord, GLenum pname, const GLint *params ); typedef void (APIENTRYP PFNGLGETTEXGENDVPROC) ( GLenum coord, GLenum pname, GLdouble *params ); typedef void (APIENTRYP PFNGLGETTEXGENFVPROC) ( GLenum coord, GLenum pname, GLfloat *params ); typedef void (APIENTRYP PFNGLGETTEXGENIVPROC) ( GLenum coord, GLenum pname, GLint *params ); typedef void (APIENTRYP PFNGLTEXENVFPROC) ( GLenum target, GLenum pname, GLfloat param ); typedef void (APIENTRYP PFNGLTEXENVIPROC) ( GLenum target, GLenum pname, GLint param ); typedef void (APIENTRYP PFNGLTEXENVFVPROC) ( GLenum target, GLenum pname, const GLfloat *params ); typedef void (APIENTRYP PFNGLTEXENVIVPROC) ( GLenum target, GLenum pname, const GLint *params ); typedef void (APIENTRYP PFNGLGETTEXENVFVPROC) ( GLenum target, GLenum pname, GLfloat *params ); typedef void (APIENTRYP PFNGLGETTEXENVIVPROC) ( GLenum target, GLenum pname, GLint *params ); typedef void (APIENTRYP PFNGLTEXPARAMETERFPROC) ( GLenum target, GLenum pname, GLfloat param ); typedef void (APIENTRYP PFNGLTEXPARAMETERIPROC) ( GLenum target, GLenum pname, GLint param ); typedef void (APIENTRYP PFNGLTEXPARAMETERFVPROC) ( GLenum target, GLenum pname, const GLfloat *params ); typedef void (APIENTRYP PFNGLTEXPARAMETERIVPROC) ( GLenum target, GLenum pname, const GLint *params ); typedef void (APIENTRYP PFNGLGETTEXPARAMETERFVPROC) ( GLenum target, GLenum pname, GLfloat *params); typedef void (APIENTRYP PFNGLGETTEXPARAMETERIVPROC) ( GLenum target, GLenum pname, GLint *params ); typedef void (APIENTRYP PFNGLGETTEXLEVELPARAMETERFVPROC) ( GLenum target, GLint level, GLenum pname, GLfloat *params ); typedef void (APIENTRYP PFNGLGETTEXLEVELPARAMETERIVPROC) ( GLenum target, GLint level, GLenum pname, GLint *params ); typedef void (APIENTRYP PFNGLTEXIMAGE1DPROC) ( GLenum target, GLint level, GLint internalFormat, GLsizei width, GLint border, GLenum format, GLenum type, const GLvoid *pixels ); typedef void (APIENTRYP PFNGLTEXIMAGE2DPROC) ( GLenum target, GLint level, GLint internalFormat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels ); typedef void (APIENTRYP PFNGLGETTEXIMAGEPROC) ( GLenum target, GLint level, GLenum format, GLenum type, GLvoid *pixels ); /* 1.1 functions */ typedef void (APIENTRYP PFNGLGENTEXTURESPROC) ( GLsizei n, GLuint *textures ); typedef void (APIENTRYP PFNGLDELETETEXTURESPROC) ( GLsizei n, const GLuint *textures); typedef void (APIENTRYP PFNGLBINDTEXTUREPROC) ( GLenum target, GLuint texture ); typedef void (APIENTRYP PFNGLPRIORITIZETEXTURESPROC) ( GLsizei n, const GLuint *textures, const GLclampf *priorities ); typedef GLboolean (APIENTRYP PFNGLARETEXTURESRESIDENTPROC) ( GLsizei n, const GLuint *textures, GLboolean *residences ); typedef GLboolean (APIENTRYP PFNGLISTEXTUREPROC) ( GLuint texture ); typedef void (APIENTRYP PFNGLTEXSUBIMAGE1DPROC) ( GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels ); typedef void (APIENTRYP PFNGLTEXSUBIMAGE2DPROC) ( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels ); typedef void (APIENTRYP PFNGLCOPYTEXIMAGE1DPROC) ( GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border ); typedef void (APIENTRYP PFNGLCOPYTEXIMAGE2DPROC) ( GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border ); typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE1DPROC) ( GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width ); typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE2DPROC) ( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height ); /* * Evaluators */ typedef void (APIENTRYP PFNGLMAP1DPROC) ( GLenum target, GLdouble u1, GLdouble u2, GLint stride, GLint order, const GLdouble *points ); typedef void (APIENTRYP PFNGLMAP1FPROC) ( GLenum target, GLfloat u1, GLfloat u2, GLint stride, GLint order, const GLfloat *points ); typedef void (APIENTRYP PFNGLMAP2DPROC) ( GLenum target, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, const GLdouble *points ); typedef void (APIENTRYP PFNGLMAP2FPROC) ( GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, const GLfloat *points ); typedef void (APIENTRYP PFNGLGETMAPDVPROC) ( GLenum target, GLenum query, GLdouble *v ); typedef void (APIENTRYP PFNGLGETMAPFVPROC) ( GLenum target, GLenum query, GLfloat *v ); typedef void (APIENTRYP PFNGLGETMAPIVPROC) ( GLenum target, GLenum query, GLint *v ); typedef void (APIENTRYP PFNGLEVALCOORD1DPROC) ( GLdouble u ); typedef void (APIENTRYP PFNGLEVALCOORD1FPROC) ( GLfloat u ); typedef void (APIENTRYP PFNGLEVALCOORD1DVPROC) ( const GLdouble *u ); typedef void (APIENTRYP PFNGLEVALCOORD1FVPROC) ( const GLfloat *u ); typedef void (APIENTRYP PFNGLEVALCOORD2DPROC) ( GLdouble u, GLdouble v ); typedef void (APIENTRYP PFNGLEVALCOORD2FPROC) ( GLfloat u, GLfloat v ); typedef void (APIENTRYP PFNGLEVALCOORD2DVPROC) ( const GLdouble *u ); typedef void (APIENTRYP PFNGLEVALCOORD2FVPROC) ( const GLfloat *u ); typedef void (APIENTRYP PFNGLMAPGRID1DPROC) ( GLint un, GLdouble u1, GLdouble u2 ); typedef void (APIENTRYP PFNGLMAPGRID1FPROC) ( GLint un, GLfloat u1, GLfloat u2 ); typedef void (APIENTRYP PFNGLMAPGRID2DPROC) ( GLint un, GLdouble u1, GLdouble u2, GLint vn, GLdouble v1, GLdouble v2 ); typedef void (APIENTRYP PFNGLMAPGRID2FPROC) ( GLint un, GLfloat u1, GLfloat u2, GLint vn, GLfloat v1, GLfloat v2 ); typedef void (APIENTRYP PFNGLEVALPOINT1PROC) ( GLint i ); typedef void (APIENTRYP PFNGLEVALPOINT2PROC) ( GLint i, GLint j ); typedef void (APIENTRYP PFNGLEVALMESH1PROC) ( GLenum mode, GLint i1, GLint i2 ); typedef void (APIENTRYP PFNGLEVALMESH2PROC) ( GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2 ); /* * Fog */ typedef void (APIENTRYP PFNGLFOGFPROC) ( GLenum pname, GLfloat param ); typedef void (APIENTRYP PFNGLFOGIPROC) ( GLenum pname, GLint param ); typedef void (APIENTRYP PFNGLFOGFVPROC) ( GLenum pname, const GLfloat *params ); typedef void (APIENTRYP PFNGLFOGIVPROC) ( GLenum pname, const GLint *params ); /* * Selection and Feedback */ typedef void (APIENTRYP PFNGLFEEDBACKBUFFERPROC) ( GLsizei size, GLenum type, GLfloat *buffer ); typedef void (APIENTRYP PFNGLPASSTHROUGHPROC) ( GLfloat token ); typedef void (APIENTRYP PFNGLSELECTBUFFERPROC) ( GLsizei size, GLuint *buffer ); typedef void (APIENTRYP PFNGLINITNAMESPROC) ( void ); typedef void (APIENTRYP PFNGLLOADNAMEPROC) ( GLuint name ); typedef void (APIENTRYP PFNGLPUSHNAMEPROC) ( GLuint name ); typedef void (APIENTRYP PFNGLPOPNAMEPROC) ( void ); #endif /* * OpenGL 1.2 */ #define GL_RESCALE_NORMAL 0x803A #define GL_CLAMP_TO_EDGE 0x812F #define GL_MAX_ELEMENTS_VERTICES 0x80E8 #define GL_MAX_ELEMENTS_INDICES 0x80E9 #define GL_BGR 0x80E0 #define GL_BGRA 0x80E1 #define GL_UNSIGNED_BYTE_3_3_2 0x8032 #define GL_UNSIGNED_BYTE_2_3_3_REV 0x8362 #define GL_UNSIGNED_SHORT_5_6_5 0x8363 #define GL_UNSIGNED_SHORT_5_6_5_REV 0x8364 #define GL_UNSIGNED_SHORT_4_4_4_4 0x8033 #define GL_UNSIGNED_SHORT_4_4_4_4_REV 0x8365 #define GL_UNSIGNED_SHORT_5_5_5_1 0x8034 #define GL_UNSIGNED_SHORT_1_5_5_5_REV 0x8366 #define GL_UNSIGNED_INT_8_8_8_8 0x8035 #define GL_UNSIGNED_INT_8_8_8_8_REV 0x8367 #define GL_UNSIGNED_INT_10_10_10_2 0x8036 #define GL_UNSIGNED_INT_2_10_10_10_REV 0x8368 #define GL_LIGHT_MODEL_COLOR_CONTROL 0x81F8 #define GL_SINGLE_COLOR 0x81F9 #define GL_SEPARATE_SPECULAR_COLOR 0x81FA #define GL_TEXTURE_MIN_LOD 0x813A #define GL_TEXTURE_MAX_LOD 0x813B #define GL_TEXTURE_BASE_LEVEL 0x813C #define GL_TEXTURE_MAX_LEVEL 0x813D #define GL_SMOOTH_POINT_SIZE_RANGE 0x0B12 #define GL_SMOOTH_POINT_SIZE_GRANULARITY 0x0B13 #define GL_SMOOTH_LINE_WIDTH_RANGE 0x0B22 #define GL_SMOOTH_LINE_WIDTH_GRANULARITY 0x0B23 #define GL_ALIASED_POINT_SIZE_RANGE 0x846D #define GL_ALIASED_LINE_WIDTH_RANGE 0x846E #define GL_PACK_SKIP_IMAGES 0x806B #define GL_PACK_IMAGE_HEIGHT 0x806C #define GL_UNPACK_SKIP_IMAGES 0x806D #define GL_UNPACK_IMAGE_HEIGHT 0x806E #define GL_TEXTURE_3D 0x806F #define GL_PROXY_TEXTURE_3D 0x8070 #define GL_TEXTURE_DEPTH 0x8071 #define GL_TEXTURE_WRAP_R 0x8072 #define GL_MAX_3D_TEXTURE_SIZE 0x8073 #define GL_TEXTURE_BINDING_3D 0x806A #ifndef SDL_OPENGL_1_NO_PROTOTYPES GLAPI void GLAPIENTRY glDrawRangeElements( GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices ); GLAPI void GLAPIENTRY glTexImage3D( GLenum target, GLint level, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels ); GLAPI void GLAPIENTRY glTexSubImage3D( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels); GLAPI void GLAPIENTRY glCopyTexSubImage3D( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height ); #endif #ifdef SDL_OPENGL_1_FUNCTION_TYPEDEFS typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTSPROC) ( GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices ); typedef void (APIENTRYP PFNGLTEXIMAGE3DPROC) ( GLenum target, GLint level, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels ); typedef void (APIENTRYP PFNGLTEXSUBIMAGE3DPROC) ( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels); typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE3DPROC) ( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height ); #endif typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTSPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices); typedef void (APIENTRYP PFNGLTEXIMAGE3DPROC) (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels); typedef void (APIENTRYP PFNGLTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels); typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); /* * GL_ARB_imaging */ #define GL_CONSTANT_COLOR 0x8001 #define GL_ONE_MINUS_CONSTANT_COLOR 0x8002 #define GL_CONSTANT_ALPHA 0x8003 #define GL_ONE_MINUS_CONSTANT_ALPHA 0x8004 #define GL_COLOR_TABLE 0x80D0 #define GL_POST_CONVOLUTION_COLOR_TABLE 0x80D1 #define GL_POST_COLOR_MATRIX_COLOR_TABLE 0x80D2 #define GL_PROXY_COLOR_TABLE 0x80D3 #define GL_PROXY_POST_CONVOLUTION_COLOR_TABLE 0x80D4 #define GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE 0x80D5 #define GL_COLOR_TABLE_SCALE 0x80D6 #define GL_COLOR_TABLE_BIAS 0x80D7 #define GL_COLOR_TABLE_FORMAT 0x80D8 #define GL_COLOR_TABLE_WIDTH 0x80D9 #define GL_COLOR_TABLE_RED_SIZE 0x80DA #define GL_COLOR_TABLE_GREEN_SIZE 0x80DB #define GL_COLOR_TABLE_BLUE_SIZE 0x80DC #define GL_COLOR_TABLE_ALPHA_SIZE 0x80DD #define GL_COLOR_TABLE_LUMINANCE_SIZE 0x80DE #define GL_COLOR_TABLE_INTENSITY_SIZE 0x80DF #define GL_CONVOLUTION_1D 0x8010 #define GL_CONVOLUTION_2D 0x8011 #define GL_SEPARABLE_2D 0x8012 #define GL_CONVOLUTION_BORDER_MODE 0x8013 #define GL_CONVOLUTION_FILTER_SCALE 0x8014 #define GL_CONVOLUTION_FILTER_BIAS 0x8015 #define GL_REDUCE 0x8016 #define GL_CONVOLUTION_FORMAT 0x8017 #define GL_CONVOLUTION_WIDTH 0x8018 #define GL_CONVOLUTION_HEIGHT 0x8019 #define GL_MAX_CONVOLUTION_WIDTH 0x801A #define GL_MAX_CONVOLUTION_HEIGHT 0x801B #define GL_POST_CONVOLUTION_RED_SCALE 0x801C #define GL_POST_CONVOLUTION_GREEN_SCALE 0x801D #define GL_POST_CONVOLUTION_BLUE_SCALE 0x801E #define GL_POST_CONVOLUTION_ALPHA_SCALE 0x801F #define GL_POST_CONVOLUTION_RED_BIAS 0x8020 #define GL_POST_CONVOLUTION_GREEN_BIAS 0x8021 #define GL_POST_CONVOLUTION_BLUE_BIAS 0x8022 #define GL_POST_CONVOLUTION_ALPHA_BIAS 0x8023 #define GL_CONSTANT_BORDER 0x8151 #define GL_REPLICATE_BORDER 0x8153 #define GL_CONVOLUTION_BORDER_COLOR 0x8154 #define GL_COLOR_MATRIX 0x80B1 #define GL_COLOR_MATRIX_STACK_DEPTH 0x80B2 #define GL_MAX_COLOR_MATRIX_STACK_DEPTH 0x80B3 #define GL_POST_COLOR_MATRIX_RED_SCALE 0x80B4 #define GL_POST_COLOR_MATRIX_GREEN_SCALE 0x80B5 #define GL_POST_COLOR_MATRIX_BLUE_SCALE 0x80B6 #define GL_POST_COLOR_MATRIX_ALPHA_SCALE 0x80B7 #define GL_POST_COLOR_MATRIX_RED_BIAS 0x80B8 #define GL_POST_COLOR_MATRIX_GREEN_BIAS 0x80B9 #define GL_POST_COLOR_MATRIX_BLUE_BIAS 0x80BA #define GL_POST_COLOR_MATRIX_ALPHA_BIAS 0x80BB #define GL_HISTOGRAM 0x8024 #define GL_PROXY_HISTOGRAM 0x8025 #define GL_HISTOGRAM_WIDTH 0x8026 #define GL_HISTOGRAM_FORMAT 0x8027 #define GL_HISTOGRAM_RED_SIZE 0x8028 #define GL_HISTOGRAM_GREEN_SIZE 0x8029 #define GL_HISTOGRAM_BLUE_SIZE 0x802A #define GL_HISTOGRAM_ALPHA_SIZE 0x802B #define GL_HISTOGRAM_LUMINANCE_SIZE 0x802C #define GL_HISTOGRAM_SINK 0x802D #define GL_MINMAX 0x802E #define GL_MINMAX_FORMAT 0x802F #define GL_MINMAX_SINK 0x8030 #define GL_TABLE_TOO_LARGE 0x8031 #define GL_BLEND_EQUATION 0x8009 #define GL_MIN 0x8007 #define GL_MAX 0x8008 #define GL_FUNC_ADD 0x8006 #define GL_FUNC_SUBTRACT 0x800A #define GL_FUNC_REVERSE_SUBTRACT 0x800B #define GL_BLEND_COLOR 0x8005 #ifndef SDL_OPENGL_1_NO_PROTOTYPES GLAPI void GLAPIENTRY glColorTable( GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *table ); GLAPI void GLAPIENTRY glColorSubTable( GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const GLvoid *data ); GLAPI void GLAPIENTRY glColorTableParameteriv(GLenum target, GLenum pname, const GLint *params); GLAPI void GLAPIENTRY glColorTableParameterfv(GLenum target, GLenum pname, const GLfloat *params); GLAPI void GLAPIENTRY glCopyColorSubTable( GLenum target, GLsizei start, GLint x, GLint y, GLsizei width ); GLAPI void GLAPIENTRY glCopyColorTable( GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width ); GLAPI void GLAPIENTRY glGetColorTable( GLenum target, GLenum format, GLenum type, GLvoid *table ); GLAPI void GLAPIENTRY glGetColorTableParameterfv( GLenum target, GLenum pname, GLfloat *params ); GLAPI void GLAPIENTRY glGetColorTableParameteriv( GLenum target, GLenum pname, GLint *params ); GLAPI void GLAPIENTRY glBlendEquation( GLenum mode ); GLAPI void GLAPIENTRY glBlendColor( GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha ); GLAPI void GLAPIENTRY glHistogram( GLenum target, GLsizei width, GLenum internalformat, GLboolean sink ); GLAPI void GLAPIENTRY glResetHistogram( GLenum target ); GLAPI void GLAPIENTRY glGetHistogram( GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values ); GLAPI void GLAPIENTRY glGetHistogramParameterfv( GLenum target, GLenum pname, GLfloat *params ); GLAPI void GLAPIENTRY glGetHistogramParameteriv( GLenum target, GLenum pname, GLint *params ); GLAPI void GLAPIENTRY glMinmax( GLenum target, GLenum internalformat, GLboolean sink ); GLAPI void GLAPIENTRY glResetMinmax( GLenum target ); GLAPI void GLAPIENTRY glGetMinmax( GLenum target, GLboolean reset, GLenum format, GLenum types, GLvoid *values ); GLAPI void GLAPIENTRY glGetMinmaxParameterfv( GLenum target, GLenum pname, GLfloat *params ); GLAPI void GLAPIENTRY glGetMinmaxParameteriv( GLenum target, GLenum pname, GLint *params ); GLAPI void GLAPIENTRY glConvolutionFilter1D( GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *image ); GLAPI void GLAPIENTRY glConvolutionFilter2D( GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *image ); GLAPI void GLAPIENTRY glConvolutionParameterf( GLenum target, GLenum pname, GLfloat params ); GLAPI void GLAPIENTRY glConvolutionParameterfv( GLenum target, GLenum pname, const GLfloat *params ); GLAPI void GLAPIENTRY glConvolutionParameteri( GLenum target, GLenum pname, GLint params ); GLAPI void GLAPIENTRY glConvolutionParameteriv( GLenum target, GLenum pname, const GLint *params ); GLAPI void GLAPIENTRY glCopyConvolutionFilter1D( GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width ); GLAPI void GLAPIENTRY glCopyConvolutionFilter2D( GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height); GLAPI void GLAPIENTRY glGetConvolutionFilter( GLenum target, GLenum format, GLenum type, GLvoid *image ); GLAPI void GLAPIENTRY glGetConvolutionParameterfv( GLenum target, GLenum pname, GLfloat *params ); GLAPI void GLAPIENTRY glGetConvolutionParameteriv( GLenum target, GLenum pname, GLint *params ); GLAPI void GLAPIENTRY glSeparableFilter2D( GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *row, const GLvoid *column ); GLAPI void GLAPIENTRY glGetSeparableFilter( GLenum target, GLenum format, GLenum type, GLvoid *row, GLvoid *column, GLvoid *span ); #endif #ifdef SDL_OPENGL_1_FUNCTION_TYPEDEFS typedef void (APIENTRYP PFNGLCOLORTABLEPROC) ( GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *table ); typedef void (APIENTRYP PFNGLCOLORSUBTABLEPROC) ( GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const GLvoid *data ); typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERIVPROC) (GLenum target, GLenum pname, const GLint *params); typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERFVPROC) (GLenum target, GLenum pname, const GLfloat *params); typedef void (APIENTRYP PFNGLCOPYCOLORSUBTABLEPROC) ( GLenum target, GLsizei start, GLint x, GLint y, GLsizei width ); typedef void (APIENTRYP PFNGLCOPYCOLORTABLEPROC) ( GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width ); typedef void (APIENTRYP PFNGLGETCOLORTABLEPROC) ( GLenum target, GLenum format, GLenum type, GLvoid *table ); typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERFVPROC) ( GLenum target, GLenum pname, GLfloat *params ); typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERIVPROC) ( GLenum target, GLenum pname, GLint *params ); typedef void (APIENTRYP PFNGLBLENDEQUATIONPROC) ( GLenum mode ); typedef void (APIENTRYP PFNGLBLENDCOLORPROC) ( GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha ); typedef void (APIENTRYP PFNGLHISTOGRAMPROC) ( GLenum target, GLsizei width, GLenum internalformat, GLboolean sink ); typedef void (APIENTRYP PFNGLRESETHISTOGRAMPROC) ( GLenum target ); typedef void (APIENTRYP PFNGLGETHISTOGRAMPROC) ( GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values ); typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERFVPROC) ( GLenum target, GLenum pname, GLfloat *params ); typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERIVPROC) ( GLenum target, GLenum pname, GLint *params ); typedef void (APIENTRYP PFNGLMINMAXPROC) ( GLenum target, GLenum internalformat, GLboolean sink ); typedef void (APIENTRYP PFNGLRESETMINMAXPROC) ( GLenum target ); typedef void (APIENTRYP PFNGLGETMINMAXPROC) ( GLenum target, GLboolean reset, GLenum format, GLenum types, GLvoid *values ); typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERFVPROC) ( GLenum target, GLenum pname, GLfloat *params ); typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERIVPROC) ( GLenum target, GLenum pname, GLint *params ); typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER1DPROC) ( GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *image ); typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER2DPROC) ( GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *image ); typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFPROC) ( GLenum target, GLenum pname, GLfloat params ); typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFVPROC) ( GLenum target, GLenum pname, const GLfloat *params ); typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIPROC) ( GLenum target, GLenum pname, GLint params ); typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIVPROC) ( GLenum target, GLenum pname, const GLint *params ); typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER1DPROC) ( GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width ); typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER2DPROC) ( GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height); typedef void (APIENTRYP PFNGLGETCONVOLUTIONFILTERPROC) ( GLenum target, GLenum format, GLenum type, GLvoid *image ); typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERFVPROC) ( GLenum target, GLenum pname, GLfloat *params ); typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERIVPROC) ( GLenum target, GLenum pname, GLint *params ); typedef void (APIENTRYP PFNGLSEPARABLEFILTER2DPROC) ( GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *row, const GLvoid *column ); typedef void (APIENTRYP PFNGLGETSEPARABLEFILTERPROC) ( GLenum target, GLenum format, GLenum type, GLvoid *row, GLvoid *column, GLvoid *span ); #endif /* * OpenGL 1.3 */ /* multitexture */ #define GL_TEXTURE0 0x84C0 #define GL_TEXTURE1 0x84C1 #define GL_TEXTURE2 0x84C2 #define GL_TEXTURE3 0x84C3 #define GL_TEXTURE4 0x84C4 #define GL_TEXTURE5 0x84C5 #define GL_TEXTURE6 0x84C6 #define GL_TEXTURE7 0x84C7 #define GL_TEXTURE8 0x84C8 #define GL_TEXTURE9 0x84C9 #define GL_TEXTURE10 0x84CA #define GL_TEXTURE11 0x84CB #define GL_TEXTURE12 0x84CC #define GL_TEXTURE13 0x84CD #define GL_TEXTURE14 0x84CE #define GL_TEXTURE15 0x84CF #define GL_TEXTURE16 0x84D0 #define GL_TEXTURE17 0x84D1 #define GL_TEXTURE18 0x84D2 #define GL_TEXTURE19 0x84D3 #define GL_TEXTURE20 0x84D4 #define GL_TEXTURE21 0x84D5 #define GL_TEXTURE22 0x84D6 #define GL_TEXTURE23 0x84D7 #define GL_TEXTURE24 0x84D8 #define GL_TEXTURE25 0x84D9 #define GL_TEXTURE26 0x84DA #define GL_TEXTURE27 0x84DB #define GL_TEXTURE28 0x84DC #define GL_TEXTURE29 0x84DD #define GL_TEXTURE30 0x84DE #define GL_TEXTURE31 0x84DF #define GL_ACTIVE_TEXTURE 0x84E0 #define GL_CLIENT_ACTIVE_TEXTURE 0x84E1 #define GL_MAX_TEXTURE_UNITS 0x84E2 /* texture_cube_map */ #define GL_NORMAL_MAP 0x8511 #define GL_REFLECTION_MAP 0x8512 #define GL_TEXTURE_CUBE_MAP 0x8513 #define GL_TEXTURE_BINDING_CUBE_MAP 0x8514 #define GL_TEXTURE_CUBE_MAP_POSITIVE_X 0x8515 #define GL_TEXTURE_CUBE_MAP_NEGATIVE_X 0x8516 #define GL_TEXTURE_CUBE_MAP_POSITIVE_Y 0x8517 #define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y 0x8518 #define GL_TEXTURE_CUBE_MAP_POSITIVE_Z 0x8519 #define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z 0x851A #define GL_PROXY_TEXTURE_CUBE_MAP 0x851B #define GL_MAX_CUBE_MAP_TEXTURE_SIZE 0x851C /* texture_compression */ #define GL_COMPRESSED_ALPHA 0x84E9 #define GL_COMPRESSED_LUMINANCE 0x84EA #define GL_COMPRESSED_LUMINANCE_ALPHA 0x84EB #define GL_COMPRESSED_INTENSITY 0x84EC #define GL_COMPRESSED_RGB 0x84ED #define GL_COMPRESSED_RGBA 0x84EE #define GL_TEXTURE_COMPRESSION_HINT 0x84EF #define GL_TEXTURE_COMPRESSED_IMAGE_SIZE 0x86A0 #define GL_TEXTURE_COMPRESSED 0x86A1 #define GL_NUM_COMPRESSED_TEXTURE_FORMATS 0x86A2 #define GL_COMPRESSED_TEXTURE_FORMATS 0x86A3 /* multisample */ #define GL_MULTISAMPLE 0x809D #define GL_SAMPLE_ALPHA_TO_COVERAGE 0x809E #define GL_SAMPLE_ALPHA_TO_ONE 0x809F #define GL_SAMPLE_COVERAGE 0x80A0 #define GL_SAMPLE_BUFFERS 0x80A8 #define GL_SAMPLES 0x80A9 #define GL_SAMPLE_COVERAGE_VALUE 0x80AA #define GL_SAMPLE_COVERAGE_INVERT 0x80AB #define GL_MULTISAMPLE_BIT 0x20000000 /* transpose_matrix */ #define GL_TRANSPOSE_MODELVIEW_MATRIX 0x84E3 #define GL_TRANSPOSE_PROJECTION_MATRIX 0x84E4 #define GL_TRANSPOSE_TEXTURE_MATRIX 0x84E5 #define GL_TRANSPOSE_COLOR_MATRIX 0x84E6 /* texture_env_combine */ #define GL_COMBINE 0x8570 #define GL_COMBINE_RGB 0x8571 #define GL_COMBINE_ALPHA 0x8572 #define GL_SOURCE0_RGB 0x8580 #define GL_SOURCE1_RGB 0x8581 #define GL_SOURCE2_RGB 0x8582 #define GL_SOURCE0_ALPHA 0x8588 #define GL_SOURCE1_ALPHA 0x8589 #define GL_SOURCE2_ALPHA 0x858A #define GL_OPERAND0_RGB 0x8590 #define GL_OPERAND1_RGB 0x8591 #define GL_OPERAND2_RGB 0x8592 #define GL_OPERAND0_ALPHA 0x8598 #define GL_OPERAND1_ALPHA 0x8599 #define GL_OPERAND2_ALPHA 0x859A #define GL_RGB_SCALE 0x8573 #define GL_ADD_SIGNED 0x8574 #define GL_INTERPOLATE 0x8575 #define GL_SUBTRACT 0x84E7 #define GL_CONSTANT 0x8576 #define GL_PRIMARY_COLOR 0x8577 #define GL_PREVIOUS 0x8578 /* texture_env_dot3 */ #define GL_DOT3_RGB 0x86AE #define GL_DOT3_RGBA 0x86AF /* texture_border_clamp */ #define GL_CLAMP_TO_BORDER 0x812D #ifndef SDL_OPENGL_1_NO_PROTOTYPES GLAPI void GLAPIENTRY glActiveTexture( GLenum texture ); GLAPI void GLAPIENTRY glClientActiveTexture( GLenum texture ); GLAPI void GLAPIENTRY glCompressedTexImage1D( GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *data ); GLAPI void GLAPIENTRY glCompressedTexImage2D( GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data ); GLAPI void GLAPIENTRY glCompressedTexImage3D( GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data ); GLAPI void GLAPIENTRY glCompressedTexSubImage1D( GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *data ); GLAPI void GLAPIENTRY glCompressedTexSubImage2D( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data ); GLAPI void GLAPIENTRY glCompressedTexSubImage3D( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *data ); GLAPI void GLAPIENTRY glGetCompressedTexImage( GLenum target, GLint lod, GLvoid *img ); GLAPI void GLAPIENTRY glMultiTexCoord1d( GLenum target, GLdouble s ); GLAPI void GLAPIENTRY glMultiTexCoord1dv( GLenum target, const GLdouble *v ); GLAPI void GLAPIENTRY glMultiTexCoord1f( GLenum target, GLfloat s ); GLAPI void GLAPIENTRY glMultiTexCoord1fv( GLenum target, const GLfloat *v ); GLAPI void GLAPIENTRY glMultiTexCoord1i( GLenum target, GLint s ); GLAPI void GLAPIENTRY glMultiTexCoord1iv( GLenum target, const GLint *v ); GLAPI void GLAPIENTRY glMultiTexCoord1s( GLenum target, GLshort s ); GLAPI void GLAPIENTRY glMultiTexCoord1sv( GLenum target, const GLshort *v ); GLAPI void GLAPIENTRY glMultiTexCoord2d( GLenum target, GLdouble s, GLdouble t ); GLAPI void GLAPIENTRY glMultiTexCoord2dv( GLenum target, const GLdouble *v ); GLAPI void GLAPIENTRY glMultiTexCoord2f( GLenum target, GLfloat s, GLfloat t ); GLAPI void GLAPIENTRY glMultiTexCoord2fv( GLenum target, const GLfloat *v ); GLAPI void GLAPIENTRY glMultiTexCoord2i( GLenum target, GLint s, GLint t ); GLAPI void GLAPIENTRY glMultiTexCoord2iv( GLenum target, const GLint *v ); GLAPI void GLAPIENTRY glMultiTexCoord2s( GLenum target, GLshort s, GLshort t ); GLAPI void GLAPIENTRY glMultiTexCoord2sv( GLenum target, const GLshort *v ); GLAPI void GLAPIENTRY glMultiTexCoord3d( GLenum target, GLdouble s, GLdouble t, GLdouble r ); GLAPI void GLAPIENTRY glMultiTexCoord3dv( GLenum target, const GLdouble *v ); GLAPI void GLAPIENTRY glMultiTexCoord3f( GLenum target, GLfloat s, GLfloat t, GLfloat r ); GLAPI void GLAPIENTRY glMultiTexCoord3fv( GLenum target, const GLfloat *v ); GLAPI void GLAPIENTRY glMultiTexCoord3i( GLenum target, GLint s, GLint t, GLint r ); GLAPI void GLAPIENTRY glMultiTexCoord3iv( GLenum target, const GLint *v ); GLAPI void GLAPIENTRY glMultiTexCoord3s( GLenum target, GLshort s, GLshort t, GLshort r ); GLAPI void GLAPIENTRY glMultiTexCoord3sv( GLenum target, const GLshort *v ); GLAPI void GLAPIENTRY glMultiTexCoord4d( GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q ); GLAPI void GLAPIENTRY glMultiTexCoord4dv( GLenum target, const GLdouble *v ); GLAPI void GLAPIENTRY glMultiTexCoord4f( GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q ); GLAPI void GLAPIENTRY glMultiTexCoord4fv( GLenum target, const GLfloat *v ); GLAPI void GLAPIENTRY glMultiTexCoord4i( GLenum target, GLint s, GLint t, GLint r, GLint q ); GLAPI void GLAPIENTRY glMultiTexCoord4iv( GLenum target, const GLint *v ); GLAPI void GLAPIENTRY glMultiTexCoord4s( GLenum target, GLshort s, GLshort t, GLshort r, GLshort q ); GLAPI void GLAPIENTRY glMultiTexCoord4sv( GLenum target, const GLshort *v ); GLAPI void GLAPIENTRY glLoadTransposeMatrixd( const GLdouble m[16] ); GLAPI void GLAPIENTRY glLoadTransposeMatrixf( const GLfloat m[16] ); GLAPI void GLAPIENTRY glMultTransposeMatrixd( const GLdouble m[16] ); GLAPI void GLAPIENTRY glMultTransposeMatrixf( const GLfloat m[16] ); GLAPI void GLAPIENTRY glSampleCoverage( GLclampf value, GLboolean invert ); #endif #ifdef SDL_OPENGL_1_FUNCTION_TYPEDEFS typedef void (APIENTRYP PFNGLACTIVETEXTUREPROC) ( GLenum texture ); typedef void (APIENTRYP PFNGLCLIENTACTIVETEXTUREPROC) ( GLenum texture ); typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE1DPROC) ( GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *data ); typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE2DPROC) ( GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data ); typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE3DPROC) ( GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data ); typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC) ( GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *data ); typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC) ( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data ); typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC) ( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *data ); typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXIMAGEPROC) ( GLenum target, GLint lod, GLvoid *img ); typedef void (APIENTRYP PFNGLMULTITEXCOORD1DPROC) ( GLenum target, GLdouble s ); typedef void (APIENTRYP PFNGLMULTITEXCOORD1DVPROC) ( GLenum target, const GLdouble *v ); typedef void (APIENTRYP PFNGLMULTITEXCOORD1FPROC) ( GLenum target, GLfloat s ); typedef void (APIENTRYP PFNGLMULTITEXCOORD1FVPROC) ( GLenum target, const GLfloat *v ); typedef void (APIENTRYP PFNGLMULTITEXCOORD1IPROC) ( GLenum target, GLint s ); typedef void (APIENTRYP PFNGLMULTITEXCOORD1IVPROC) ( GLenum target, const GLint *v ); typedef void (APIENTRYP PFNGLMULTITEXCOORD1SPROC) ( GLenum target, GLshort s ); typedef void (APIENTRYP PFNGLMULTITEXCOORD1SVPROC) ( GLenum target, const GLshort *v ); typedef void (APIENTRYP PFNGLMULTITEXCOORD2DPROC) ( GLenum target, GLdouble s, GLdouble t ); typedef void (APIENTRYP PFNGLMULTITEXCOORD2DVPROC) ( GLenum target, const GLdouble *v ); typedef void (APIENTRYP PFNGLMULTITEXCOORD2FPROC) ( GLenum target, GLfloat s, GLfloat t ); typedef void (APIENTRYP PFNGLMULTITEXCOORD2FVPROC) ( GLenum target, const GLfloat *v ); typedef void (APIENTRYP PFNGLMULTITEXCOORD2IPROC) ( GLenum target, GLint s, GLint t ); typedef void (APIENTRYP PFNGLMULTITEXCOORD2IVPROC) ( GLenum target, const GLint *v ); typedef void (APIENTRYP PFNGLMULTITEXCOORD2SPROC) ( GLenum target, GLshort s, GLshort t ); typedef void (APIENTRYP PFNGLMULTITEXCOORD2SVPROC) ( GLenum target, const GLshort *v ); typedef void (APIENTRYP PFNGLMULTITEXCOORD3DPROC) ( GLenum target, GLdouble s, GLdouble t, GLdouble r ); typedef void (APIENTRYP PFNGLMULTITEXCOORD3DVPROC) ( GLenum target, const GLdouble *v ); typedef void (APIENTRYP PFNGLMULTITEXCOORD3FPROC) ( GLenum target, GLfloat s, GLfloat t, GLfloat r ); typedef void (APIENTRYP PFNGLMULTITEXCOORD3FVPROC) ( GLenum target, const GLfloat *v ); typedef void (APIENTRYP PFNGLMULTITEXCOORD3IPROC) ( GLenum target, GLint s, GLint t, GLint r ); typedef void (APIENTRYP PFNGLMULTITEXCOORD3IVPROC) ( GLenum target, const GLint *v ); typedef void (APIENTRYP PFNGLMULTITEXCOORD3SPROC) ( GLenum target, GLshort s, GLshort t, GLshort r ); typedef void (APIENTRYP PFNGLMULTITEXCOORD3SVPROC) ( GLenum target, const GLshort *v ); typedef void (APIENTRYP PFNGLMULTITEXCOORD4DPROC) ( GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q ); typedef void (APIENTRYP PFNGLMULTITEXCOORD4DVPROC) ( GLenum target, const GLdouble *v ); typedef void (APIENTRYP PFNGLMULTITEXCOORD4FPROC) ( GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q ); typedef void (APIENTRYP PFNGLMULTITEXCOORD4FVPROC) ( GLenum target, const GLfloat *v ); typedef void (APIENTRYP PFNGLMULTITEXCOORD4IPROC) ( GLenum target, GLint s, GLint t, GLint r, GLint q ); typedef void (APIENTRYP PFNGLMULTITEXCOORD4IVPROC) ( GLenum target, const GLint *v ); typedef void (APIENTRYP PFNGLMULTITEXCOORD4SPROC) ( GLenum target, GLshort s, GLshort t, GLshort r, GLshort q ); typedef void (APIENTRYP PFNGLMULTITEXCOORD4SVPROC) ( GLenum target, const GLshort *v ); typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXDPROC) ( const GLdouble m[16] ); typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXFPROC) ( const GLfloat m[16] ); typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXDPROC) ( const GLdouble m[16] ); typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXFPROC) ( const GLfloat m[16] ); typedef void (APIENTRYP PFNGLSAMPLECOVERAGEPROC) ( GLclampf value, GLboolean invert ); #endif typedef void (APIENTRYP PFNGLACTIVETEXTUREPROC) (GLenum texture); typedef void (APIENTRYP PFNGLSAMPLECOVERAGEPROC) (GLclampf value, GLboolean invert); typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE3DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data); typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE2DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data); typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE1DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *data); typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *data); typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data); typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *data); typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXIMAGEPROC) (GLenum target, GLint level, GLvoid *img); /* * GL_ARB_multitexture (ARB extension 1 and OpenGL 1.2.1) */ #ifndef GL_ARB_multitexture #define GL_ARB_multitexture 1 #define GL_TEXTURE0_ARB 0x84C0 #define GL_TEXTURE1_ARB 0x84C1 #define GL_TEXTURE2_ARB 0x84C2 #define GL_TEXTURE3_ARB 0x84C3 #define GL_TEXTURE4_ARB 0x84C4 #define GL_TEXTURE5_ARB 0x84C5 #define GL_TEXTURE6_ARB 0x84C6 #define GL_TEXTURE7_ARB 0x84C7 #define GL_TEXTURE8_ARB 0x84C8 #define GL_TEXTURE9_ARB 0x84C9 #define GL_TEXTURE10_ARB 0x84CA #define GL_TEXTURE11_ARB 0x84CB #define GL_TEXTURE12_ARB 0x84CC #define GL_TEXTURE13_ARB 0x84CD #define GL_TEXTURE14_ARB 0x84CE #define GL_TEXTURE15_ARB 0x84CF #define GL_TEXTURE16_ARB 0x84D0 #define GL_TEXTURE17_ARB 0x84D1 #define GL_TEXTURE18_ARB 0x84D2 #define GL_TEXTURE19_ARB 0x84D3 #define GL_TEXTURE20_ARB 0x84D4 #define GL_TEXTURE21_ARB 0x84D5 #define GL_TEXTURE22_ARB 0x84D6 #define GL_TEXTURE23_ARB 0x84D7 #define GL_TEXTURE24_ARB 0x84D8 #define GL_TEXTURE25_ARB 0x84D9 #define GL_TEXTURE26_ARB 0x84DA #define GL_TEXTURE27_ARB 0x84DB #define GL_TEXTURE28_ARB 0x84DC #define GL_TEXTURE29_ARB 0x84DD #define GL_TEXTURE30_ARB 0x84DE #define GL_TEXTURE31_ARB 0x84DF #define GL_ACTIVE_TEXTURE_ARB 0x84E0 #define GL_CLIENT_ACTIVE_TEXTURE_ARB 0x84E1 #define GL_MAX_TEXTURE_UNITS_ARB 0x84E2 #ifndef SDL_OPENGL_1_NO_PROTOTYPES GLAPI void GLAPIENTRY glActiveTextureARB(GLenum texture); GLAPI void GLAPIENTRY glClientActiveTextureARB(GLenum texture); GLAPI void GLAPIENTRY glMultiTexCoord1dARB(GLenum target, GLdouble s); GLAPI void GLAPIENTRY glMultiTexCoord1dvARB(GLenum target, const GLdouble *v); GLAPI void GLAPIENTRY glMultiTexCoord1fARB(GLenum target, GLfloat s); GLAPI void GLAPIENTRY glMultiTexCoord1fvARB(GLenum target, const GLfloat *v); GLAPI void GLAPIENTRY glMultiTexCoord1iARB(GLenum target, GLint s); GLAPI void GLAPIENTRY glMultiTexCoord1ivARB(GLenum target, const GLint *v); GLAPI void GLAPIENTRY glMultiTexCoord1sARB(GLenum target, GLshort s); GLAPI void GLAPIENTRY glMultiTexCoord1svARB(GLenum target, const GLshort *v); GLAPI void GLAPIENTRY glMultiTexCoord2dARB(GLenum target, GLdouble s, GLdouble t); GLAPI void GLAPIENTRY glMultiTexCoord2dvARB(GLenum target, const GLdouble *v); GLAPI void GLAPIENTRY glMultiTexCoord2fARB(GLenum target, GLfloat s, GLfloat t); GLAPI void GLAPIENTRY glMultiTexCoord2fvARB(GLenum target, const GLfloat *v); GLAPI void GLAPIENTRY glMultiTexCoord2iARB(GLenum target, GLint s, GLint t); GLAPI void GLAPIENTRY glMultiTexCoord2ivARB(GLenum target, const GLint *v); GLAPI void GLAPIENTRY glMultiTexCoord2sARB(GLenum target, GLshort s, GLshort t); GLAPI void GLAPIENTRY glMultiTexCoord2svARB(GLenum target, const GLshort *v); GLAPI void GLAPIENTRY glMultiTexCoord3dARB(GLenum target, GLdouble s, GLdouble t, GLdouble r); GLAPI void GLAPIENTRY glMultiTexCoord3dvARB(GLenum target, const GLdouble *v); GLAPI void GLAPIENTRY glMultiTexCoord3fARB(GLenum target, GLfloat s, GLfloat t, GLfloat r); GLAPI void GLAPIENTRY glMultiTexCoord3fvARB(GLenum target, const GLfloat *v); GLAPI void GLAPIENTRY glMultiTexCoord3iARB(GLenum target, GLint s, GLint t, GLint r); GLAPI void GLAPIENTRY glMultiTexCoord3ivARB(GLenum target, const GLint *v); GLAPI void GLAPIENTRY glMultiTexCoord3sARB(GLenum target, GLshort s, GLshort t, GLshort r); GLAPI void GLAPIENTRY glMultiTexCoord3svARB(GLenum target, const GLshort *v); GLAPI void GLAPIENTRY glMultiTexCoord4dARB(GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q); GLAPI void GLAPIENTRY glMultiTexCoord4dvARB(GLenum target, const GLdouble *v); GLAPI void GLAPIENTRY glMultiTexCoord4fARB(GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); GLAPI void GLAPIENTRY glMultiTexCoord4fvARB(GLenum target, const GLfloat *v); GLAPI void GLAPIENTRY glMultiTexCoord4iARB(GLenum target, GLint s, GLint t, GLint r, GLint q); GLAPI void GLAPIENTRY glMultiTexCoord4ivARB(GLenum target, const GLint *v); GLAPI void GLAPIENTRY glMultiTexCoord4sARB(GLenum target, GLshort s, GLshort t, GLshort r, GLshort q); GLAPI void GLAPIENTRY glMultiTexCoord4svARB(GLenum target, const GLshort *v); #endif #ifdef SDL_OPENGL_1_FUNCTION_TYPEDEFS typedef void (APIENTRYP PFNGLACTIVETEXTUREARBPROC) (GLenum texture); typedef void (APIENTRYP PFNGLCLIENTACTIVETEXTUREARBPROC) (GLenum texture); typedef void (APIENTRYP PFNGLMULTITEXCOORD1DARBPROC) (GLenum target, GLdouble s); typedef void (APIENTRYP PFNGLMULTITEXCOORD1DVARBPROC) (GLenum target, const GLdouble *v); typedef void (APIENTRYP PFNGLMULTITEXCOORD1FARBPROC) (GLenum target, GLfloat s); typedef void (APIENTRYP PFNGLMULTITEXCOORD1FVARBPROC) (GLenum target, const GLfloat *v); typedef void (APIENTRYP PFNGLMULTITEXCOORD1IARBPROC) (GLenum target, GLint s); typedef void (APIENTRYP PFNGLMULTITEXCOORD1IVARBPROC) (GLenum target, const GLint *v); typedef void (APIENTRYP PFNGLMULTITEXCOORD1SARBPROC) (GLenum target, GLshort s); typedef void (APIENTRYP PFNGLMULTITEXCOORD1SVARBPROC) (GLenum target, const GLshort *v); typedef void (APIENTRYP PFNGLMULTITEXCOORD2DARBPROC) (GLenum target, GLdouble s, GLdouble t); typedef void (APIENTRYP PFNGLMULTITEXCOORD2DVARBPROC) (GLenum target, const GLdouble *v); typedef void (APIENTRYP PFNGLMULTITEXCOORD2FARBPROC) (GLenum target, GLfloat s, GLfloat t); typedef void (APIENTRYP PFNGLMULTITEXCOORD2FVARBPROC) (GLenum target, const GLfloat *v); typedef void (APIENTRYP PFNGLMULTITEXCOORD2IARBPROC) (GLenum target, GLint s, GLint t); typedef void (APIENTRYP PFNGLMULTITEXCOORD2IVARBPROC) (GLenum target, const GLint *v); typedef void (APIENTRYP PFNGLMULTITEXCOORD2SARBPROC) (GLenum target, GLshort s, GLshort t); typedef void (APIENTRYP PFNGLMULTITEXCOORD2SVARBPROC) (GLenum target, const GLshort *v); typedef void (APIENTRYP PFNGLMULTITEXCOORD3DARBPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r); typedef void (APIENTRYP PFNGLMULTITEXCOORD3DVARBPROC) (GLenum target, const GLdouble *v); typedef void (APIENTRYP PFNGLMULTITEXCOORD3FARBPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r); typedef void (APIENTRYP PFNGLMULTITEXCOORD3FVARBPROC) (GLenum target, const GLfloat *v); typedef void (APIENTRYP PFNGLMULTITEXCOORD3IARBPROC) (GLenum target, GLint s, GLint t, GLint r); typedef void (APIENTRYP PFNGLMULTITEXCOORD3IVARBPROC) (GLenum target, const GLint *v); typedef void (APIENTRYP PFNGLMULTITEXCOORD3SARBPROC) (GLenum target, GLshort s, GLshort t, GLshort r); typedef void (APIENTRYP PFNGLMULTITEXCOORD3SVARBPROC) (GLenum target, const GLshort *v); typedef void (APIENTRYP PFNGLMULTITEXCOORD4DARBPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q); typedef void (APIENTRYP PFNGLMULTITEXCOORD4DVARBPROC) (GLenum target, const GLdouble *v); typedef void (APIENTRYP PFNGLMULTITEXCOORD4FARBPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); typedef void (APIENTRYP PFNGLMULTITEXCOORD4FVARBPROC) (GLenum target, const GLfloat *v); typedef void (APIENTRYP PFNGLMULTITEXCOORD4IARBPROC) (GLenum target, GLint s, GLint t, GLint r, GLint q); typedef void (APIENTRYP PFNGLMULTITEXCOORD4IVARBPROC) (GLenum target, const GLint *v); typedef void (APIENTRYP PFNGLMULTITEXCOORD4SARBPROC) (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q); typedef void (APIENTRYP PFNGLMULTITEXCOORD4SVARBPROC) (GLenum target, const GLshort *v); #endif typedef void (APIENTRYP PFNGLACTIVETEXTUREARBPROC) (GLenum texture); typedef void (APIENTRYP PFNGLCLIENTACTIVETEXTUREARBPROC) (GLenum texture); typedef void (APIENTRYP PFNGLMULTITEXCOORD1DARBPROC) (GLenum target, GLdouble s); typedef void (APIENTRYP PFNGLMULTITEXCOORD1DVARBPROC) (GLenum target, const GLdouble *v); typedef void (APIENTRYP PFNGLMULTITEXCOORD1FARBPROC) (GLenum target, GLfloat s); typedef void (APIENTRYP PFNGLMULTITEXCOORD1FVARBPROC) (GLenum target, const GLfloat *v); typedef void (APIENTRYP PFNGLMULTITEXCOORD1IARBPROC) (GLenum target, GLint s); typedef void (APIENTRYP PFNGLMULTITEXCOORD1IVARBPROC) (GLenum target, const GLint *v); typedef void (APIENTRYP PFNGLMULTITEXCOORD1SARBPROC) (GLenum target, GLshort s); typedef void (APIENTRYP PFNGLMULTITEXCOORD1SVARBPROC) (GLenum target, const GLshort *v); typedef void (APIENTRYP PFNGLMULTITEXCOORD2DARBPROC) (GLenum target, GLdouble s, GLdouble t); typedef void (APIENTRYP PFNGLMULTITEXCOORD2DVARBPROC) (GLenum target, const GLdouble *v); typedef void (APIENTRYP PFNGLMULTITEXCOORD2FARBPROC) (GLenum target, GLfloat s, GLfloat t); typedef void (APIENTRYP PFNGLMULTITEXCOORD2FVARBPROC) (GLenum target, const GLfloat *v); typedef void (APIENTRYP PFNGLMULTITEXCOORD2IARBPROC) (GLenum target, GLint s, GLint t); typedef void (APIENTRYP PFNGLMULTITEXCOORD2IVARBPROC) (GLenum target, const GLint *v); typedef void (APIENTRYP PFNGLMULTITEXCOORD2SARBPROC) (GLenum target, GLshort s, GLshort t); typedef void (APIENTRYP PFNGLMULTITEXCOORD2SVARBPROC) (GLenum target, const GLshort *v); typedef void (APIENTRYP PFNGLMULTITEXCOORD3DARBPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r); typedef void (APIENTRYP PFNGLMULTITEXCOORD3DVARBPROC) (GLenum target, const GLdouble *v); typedef void (APIENTRYP PFNGLMULTITEXCOORD3FARBPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r); typedef void (APIENTRYP PFNGLMULTITEXCOORD3FVARBPROC) (GLenum target, const GLfloat *v); typedef void (APIENTRYP PFNGLMULTITEXCOORD3IARBPROC) (GLenum target, GLint s, GLint t, GLint r); typedef void (APIENTRYP PFNGLMULTITEXCOORD3IVARBPROC) (GLenum target, const GLint *v); typedef void (APIENTRYP PFNGLMULTITEXCOORD3SARBPROC) (GLenum target, GLshort s, GLshort t, GLshort r); typedef void (APIENTRYP PFNGLMULTITEXCOORD3SVARBPROC) (GLenum target, const GLshort *v); typedef void (APIENTRYP PFNGLMULTITEXCOORD4DARBPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q); typedef void (APIENTRYP PFNGLMULTITEXCOORD4DVARBPROC) (GLenum target, const GLdouble *v); typedef void (APIENTRYP PFNGLMULTITEXCOORD4FARBPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); typedef void (APIENTRYP PFNGLMULTITEXCOORD4FVARBPROC) (GLenum target, const GLfloat *v); typedef void (APIENTRYP PFNGLMULTITEXCOORD4IARBPROC) (GLenum target, GLint s, GLint t, GLint r, GLint q); typedef void (APIENTRYP PFNGLMULTITEXCOORD4IVARBPROC) (GLenum target, const GLint *v); typedef void (APIENTRYP PFNGLMULTITEXCOORD4SARBPROC) (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q); typedef void (APIENTRYP PFNGLMULTITEXCOORD4SVARBPROC) (GLenum target, const GLshort *v); #endif /* GL_ARB_multitexture */ /* * Define this token if you want "old-style" header file behaviour (extensions * defined in gl.h). Otherwise, extensions will be included from glext.h. */ #if !defined(NO_SDL_GLEXT) && !defined(GL_GLEXT_LEGACY) #include #endif /* GL_GLEXT_LEGACY */ /********************************************************************** * Begin system-specific stuff */ #if defined(PRAGMA_EXPORT_SUPPORTED) #pragma export off #endif /* * End system-specific stuff **********************************************************************/ #ifdef __cplusplus } #endif #endif /* __gl_h_ */ #endif /* !SDL_PLATFORM_IOS */ #endif /* SDL_opengl_h_ */ ================================================ FILE: deps/include/SDL3/SDL_opengl_glext.h ================================================ /* SDL modified the include guard to be compatible with Mesa and Apple include guards: * - Mesa uses: __gl_glext_h_ * - Apple uses: __glext_h_ */ #if !defined(__glext_h_) && !defined(__gl_glext_h_) #define __glext_h_ 1 #define __gl_glext_h_ 1 #ifdef __cplusplus extern "C" { #endif /* ** Copyright 2013-2020 The Khronos Group Inc. ** SPDX-License-Identifier: MIT ** ** This header is generated from the Khronos OpenGL / OpenGL ES XML ** API Registry. The current version of the Registry, generator scripts ** used to make the header, and the header can be found at ** https://github.com/KhronosGroup/OpenGL-Registry */ #if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__) #ifndef WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN 1 #endif #include #endif #ifndef APIENTRY #define APIENTRY #endif #ifndef APIENTRYP #define APIENTRYP APIENTRY * #endif #ifndef GLAPI #define GLAPI extern #endif #define GL_GLEXT_VERSION 20220530 /*#include */ #ifndef __khrplatform_h_ #define __khrplatform_h_ /* ** Copyright (c) 2008-2018 The Khronos Group Inc. ** ** Permission is hereby granted, free of charge, to any person obtaining a ** copy of this software and/or associated documentation files (the ** "Materials"), to deal in the Materials without restriction, including ** without limitation the rights to use, copy, modify, merge, publish, ** distribute, sublicense, and/or sell copies of the Materials, and to ** permit persons to whom the Materials are 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 Materials. ** ** THE MATERIALS ARE 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 ** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. */ /* Khronos platform-specific types and definitions. * * The master copy of khrplatform.h is maintained in the Khronos EGL * Registry repository at https://github.com/KhronosGroup/EGL-Registry * The last semantic modification to khrplatform.h was at commit ID: * 67a3e0864c2d75ea5287b9f3d2eb74a745936692 * * Adopters may modify this file to suit their platform. Adopters are * encouraged to submit platform specific modifications to the Khronos * group so that they can be included in future versions of this file. * Please submit changes by filing pull requests or issues on * the EGL Registry repository linked above. * * * See the Implementer's Guidelines for information about where this file * should be located on your system and for more details of its use: * http://www.khronos.org/registry/implementers_guide.pdf * * This file should be included as * #include * by Khronos client API header files that use its types and defines. * * The types in khrplatform.h should only be used to define API-specific types. * * Types defined in khrplatform.h: * khronos_int8_t signed 8 bit * khronos_uint8_t unsigned 8 bit * khronos_int16_t signed 16 bit * khronos_uint16_t unsigned 16 bit * khronos_int32_t signed 32 bit * khronos_uint32_t unsigned 32 bit * khronos_int64_t signed 64 bit * khronos_uint64_t unsigned 64 bit * khronos_intptr_t signed same number of bits as a pointer * khronos_uintptr_t unsigned same number of bits as a pointer * khronos_ssize_t signed size * khronos_usize_t unsigned size * khronos_float_t signed 32 bit floating point * khronos_time_ns_t unsigned 64 bit time in nanoseconds * khronos_utime_nanoseconds_t unsigned time interval or absolute time in * nanoseconds * khronos_stime_nanoseconds_t signed time interval in nanoseconds * khronos_boolean_enum_t enumerated boolean type. This should * only be used as a base type when a client API's boolean type is * an enum. Client APIs which use an integer or other type for * booleans cannot use this as the base type for their boolean. * * Tokens defined in khrplatform.h: * * KHRONOS_FALSE, KHRONOS_TRUE Enumerated boolean false/true values. * * KHRONOS_SUPPORT_INT64 is 1 if 64 bit integers are supported; otherwise 0. * KHRONOS_SUPPORT_FLOAT is 1 if floats are supported; otherwise 0. * * Calling convention macros defined in this file: * KHRONOS_APICALL * KHRONOS_APIENTRY * KHRONOS_APIATTRIBUTES * * These may be used in function prototypes as: * * KHRONOS_APICALL void KHRONOS_APIENTRY funcname( * int arg1, * int arg2) KHRONOS_APIATTRIBUTES; */ #if defined(__SCITECH_SNAP__) && !defined(KHRONOS_STATIC) # define KHRONOS_STATIC 1 #endif /*------------------------------------------------------------------------- * Definition of KHRONOS_APICALL *------------------------------------------------------------------------- * This precedes the return type of the function in the function prototype. */ #if defined(KHRONOS_STATIC) /* If the preprocessor constant KHRONOS_STATIC is defined, make the * header compatible with static linking. */ # define KHRONOS_APICALL #elif defined(_WIN32) # define KHRONOS_APICALL __declspec(dllimport) #elif defined (__SYMBIAN32__) # define KHRONOS_APICALL IMPORT_C #elif defined(__ANDROID__) # define KHRONOS_APICALL __attribute__((visibility("default"))) #else # define KHRONOS_APICALL #endif /*------------------------------------------------------------------------- * Definition of KHRONOS_APIENTRY *------------------------------------------------------------------------- * This follows the return type of the function and precedes the function * name in the function prototype. */ #if defined(_WIN32) && !defined(_WIN32_WCE) && !defined(__SCITECH_SNAP__) /* Win32 but not WinCE */ # define KHRONOS_APIENTRY __stdcall #else # define KHRONOS_APIENTRY #endif /*------------------------------------------------------------------------- * Definition of KHRONOS_APIATTRIBUTES *------------------------------------------------------------------------- * This follows the closing parenthesis of the function prototype arguments. */ #if defined (__ARMCC_2__) #define KHRONOS_APIATTRIBUTES __softfp #else #define KHRONOS_APIATTRIBUTES #endif /*------------------------------------------------------------------------- * basic type definitions *-----------------------------------------------------------------------*/ #if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || defined(__GNUC__) || defined(__SCO__) || defined(__USLC__) /* * Using */ #include typedef int32_t khronos_int32_t; typedef uint32_t khronos_uint32_t; typedef int64_t khronos_int64_t; typedef uint64_t khronos_uint64_t; #define KHRONOS_SUPPORT_INT64 1 #define KHRONOS_SUPPORT_FLOAT 1 /* * To support platform where unsigned long cannot be used interchangeably with * inptr_t (e.g. CHERI-extended ISAs), we can use the stdint.h intptr_t. * Ideally, we could just use (u)intptr_t everywhere, but this could result in * ABI breakage if khronos_uintptr_t is changed from unsigned long to * unsigned long long or similar (this results in different C++ name mangling). * To avoid changes for existing platforms, we restrict usage of intptr_t to * platforms where the size of a pointer is larger than the size of long. */ #if defined(__SIZEOF_LONG__) && defined(__SIZEOF_POINTER__) #if __SIZEOF_POINTER__ > __SIZEOF_LONG__ #define KHRONOS_USE_INTPTR_T #endif #endif #elif defined(__VMS ) || defined(__sgi) /* * Using */ #include typedef int32_t khronos_int32_t; typedef uint32_t khronos_uint32_t; typedef int64_t khronos_int64_t; typedef uint64_t khronos_uint64_t; #define KHRONOS_SUPPORT_INT64 1 #define KHRONOS_SUPPORT_FLOAT 1 #elif defined(_WIN32) && !defined(__SCITECH_SNAP__) /* * Win32 */ typedef __int32 khronos_int32_t; typedef unsigned __int32 khronos_uint32_t; typedef __int64 khronos_int64_t; typedef unsigned __int64 khronos_uint64_t; #define KHRONOS_SUPPORT_INT64 1 #define KHRONOS_SUPPORT_FLOAT 1 #elif defined(__sun__) || defined(__digital__) /* * Sun or Digital */ typedef int khronos_int32_t; typedef unsigned int khronos_uint32_t; #if defined(__arch64__) || defined(_LP64) typedef long int khronos_int64_t; typedef unsigned long int khronos_uint64_t; #else typedef long long int khronos_int64_t; typedef unsigned long long int khronos_uint64_t; #endif /* __arch64__ */ #define KHRONOS_SUPPORT_INT64 1 #define KHRONOS_SUPPORT_FLOAT 1 #elif 0 /* * Hypothetical platform with no float or int64 support */ typedef int khronos_int32_t; typedef unsigned int khronos_uint32_t; #define KHRONOS_SUPPORT_INT64 0 #define KHRONOS_SUPPORT_FLOAT 0 #else /* * Generic fallback */ #include typedef int32_t khronos_int32_t; typedef uint32_t khronos_uint32_t; typedef int64_t khronos_int64_t; typedef uint64_t khronos_uint64_t; #define KHRONOS_SUPPORT_INT64 1 #define KHRONOS_SUPPORT_FLOAT 1 #endif /* * Types that are (so far) the same on all platforms */ typedef signed char khronos_int8_t; typedef unsigned char khronos_uint8_t; typedef signed short int khronos_int16_t; typedef unsigned short int khronos_uint16_t; /* * Types that differ between LLP64 and LP64 architectures - in LLP64, * pointers are 64 bits, but 'long' is still 32 bits. Win64 appears * to be the only LLP64 architecture in current use. */ #ifdef KHRONOS_USE_INTPTR_T typedef intptr_t khronos_intptr_t; typedef uintptr_t khronos_uintptr_t; #elif defined(_WIN64) typedef signed long long int khronos_intptr_t; typedef unsigned long long int khronos_uintptr_t; #else typedef signed long int khronos_intptr_t; typedef unsigned long int khronos_uintptr_t; #endif #if defined(_WIN64) typedef signed long long int khronos_ssize_t; typedef unsigned long long int khronos_usize_t; #else typedef signed long int khronos_ssize_t; typedef unsigned long int khronos_usize_t; #endif #if KHRONOS_SUPPORT_FLOAT /* * Float type */ typedef float khronos_float_t; #endif #if KHRONOS_SUPPORT_INT64 /* Time types * * These types can be used to represent a time interval in nanoseconds or * an absolute Unadjusted System Time. Unadjusted System Time is the number * of nanoseconds since some arbitrary system event (e.g. since the last * time the system booted). The Unadjusted System Time is an unsigned * 64 bit value that wraps back to 0 every 584 years. Time intervals * may be either signed or unsigned. */ typedef khronos_uint64_t khronos_utime_nanoseconds_t; typedef khronos_int64_t khronos_stime_nanoseconds_t; #endif /* * Dummy value used to pad enum types to 32 bits. */ #ifndef KHRONOS_MAX_ENUM #define KHRONOS_MAX_ENUM 0x7FFFFFFF #endif /* * Enumerated boolean type * * Values other than zero should be considered to be true. Therefore * comparisons should not be made against KHRONOS_TRUE. */ typedef enum { KHRONOS_FALSE = 0, KHRONOS_TRUE = 1, KHRONOS_BOOLEAN_ENUM_FORCE_SIZE = KHRONOS_MAX_ENUM } khronos_boolean_enum_t; #endif /* __khrplatform_h_ */ /* Generated C header for: * API: gl * Profile: compatibility * Versions considered: .* * Versions emitted: 1\.[2-9]|[234]\.[0-9] * Default extensions included: gl * Additional extensions included: _nomatch_^ * Extensions removed: _nomatch_^ */ #ifndef GL_VERSION_1_2 #define GL_VERSION_1_2 1 #define GL_UNSIGNED_BYTE_3_3_2 0x8032 #define GL_UNSIGNED_SHORT_4_4_4_4 0x8033 #define GL_UNSIGNED_SHORT_5_5_5_1 0x8034 #define GL_UNSIGNED_INT_8_8_8_8 0x8035 #define GL_UNSIGNED_INT_10_10_10_2 0x8036 #define GL_TEXTURE_BINDING_3D 0x806A #define GL_PACK_SKIP_IMAGES 0x806B #define GL_PACK_IMAGE_HEIGHT 0x806C #define GL_UNPACK_SKIP_IMAGES 0x806D #define GL_UNPACK_IMAGE_HEIGHT 0x806E #define GL_TEXTURE_3D 0x806F #define GL_PROXY_TEXTURE_3D 0x8070 #define GL_TEXTURE_DEPTH 0x8071 #define GL_TEXTURE_WRAP_R 0x8072 #define GL_MAX_3D_TEXTURE_SIZE 0x8073 #define GL_UNSIGNED_BYTE_2_3_3_REV 0x8362 #define GL_UNSIGNED_SHORT_5_6_5 0x8363 #define GL_UNSIGNED_SHORT_5_6_5_REV 0x8364 #define GL_UNSIGNED_SHORT_4_4_4_4_REV 0x8365 #define GL_UNSIGNED_SHORT_1_5_5_5_REV 0x8366 #define GL_UNSIGNED_INT_8_8_8_8_REV 0x8367 #define GL_UNSIGNED_INT_2_10_10_10_REV 0x8368 #define GL_BGR 0x80E0 #define GL_BGRA 0x80E1 #define GL_MAX_ELEMENTS_VERTICES 0x80E8 #define GL_MAX_ELEMENTS_INDICES 0x80E9 #define GL_CLAMP_TO_EDGE 0x812F #define GL_TEXTURE_MIN_LOD 0x813A #define GL_TEXTURE_MAX_LOD 0x813B #define GL_TEXTURE_BASE_LEVEL 0x813C #define GL_TEXTURE_MAX_LEVEL 0x813D #define GL_SMOOTH_POINT_SIZE_RANGE 0x0B12 #define GL_SMOOTH_POINT_SIZE_GRANULARITY 0x0B13 #define GL_SMOOTH_LINE_WIDTH_RANGE 0x0B22 #define GL_SMOOTH_LINE_WIDTH_GRANULARITY 0x0B23 #define GL_ALIASED_LINE_WIDTH_RANGE 0x846E #define GL_RESCALE_NORMAL 0x803A #define GL_LIGHT_MODEL_COLOR_CONTROL 0x81F8 #define GL_SINGLE_COLOR 0x81F9 #define GL_SEPARATE_SPECULAR_COLOR 0x81FA #define GL_ALIASED_POINT_SIZE_RANGE 0x846D typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTSPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void *indices); typedef void (APIENTRYP PFNGLTEXIMAGE3DPROC) (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void *pixels); typedef void (APIENTRYP PFNGLTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels); typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glDrawRangeElements (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void *indices); GLAPI void APIENTRY glTexImage3D (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void *pixels); GLAPI void APIENTRY glTexSubImage3D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels); GLAPI void APIENTRY glCopyTexSubImage3D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); #endif #endif /* GL_VERSION_1_2 */ #ifndef GL_VERSION_1_3 #define GL_VERSION_1_3 1 #define GL_TEXTURE0 0x84C0 #define GL_TEXTURE1 0x84C1 #define GL_TEXTURE2 0x84C2 #define GL_TEXTURE3 0x84C3 #define GL_TEXTURE4 0x84C4 #define GL_TEXTURE5 0x84C5 #define GL_TEXTURE6 0x84C6 #define GL_TEXTURE7 0x84C7 #define GL_TEXTURE8 0x84C8 #define GL_TEXTURE9 0x84C9 #define GL_TEXTURE10 0x84CA #define GL_TEXTURE11 0x84CB #define GL_TEXTURE12 0x84CC #define GL_TEXTURE13 0x84CD #define GL_TEXTURE14 0x84CE #define GL_TEXTURE15 0x84CF #define GL_TEXTURE16 0x84D0 #define GL_TEXTURE17 0x84D1 #define GL_TEXTURE18 0x84D2 #define GL_TEXTURE19 0x84D3 #define GL_TEXTURE20 0x84D4 #define GL_TEXTURE21 0x84D5 #define GL_TEXTURE22 0x84D6 #define GL_TEXTURE23 0x84D7 #define GL_TEXTURE24 0x84D8 #define GL_TEXTURE25 0x84D9 #define GL_TEXTURE26 0x84DA #define GL_TEXTURE27 0x84DB #define GL_TEXTURE28 0x84DC #define GL_TEXTURE29 0x84DD #define GL_TEXTURE30 0x84DE #define GL_TEXTURE31 0x84DF #define GL_ACTIVE_TEXTURE 0x84E0 #define GL_MULTISAMPLE 0x809D #define GL_SAMPLE_ALPHA_TO_COVERAGE 0x809E #define GL_SAMPLE_ALPHA_TO_ONE 0x809F #define GL_SAMPLE_COVERAGE 0x80A0 #define GL_SAMPLE_BUFFERS 0x80A8 #define GL_SAMPLES 0x80A9 #define GL_SAMPLE_COVERAGE_VALUE 0x80AA #define GL_SAMPLE_COVERAGE_INVERT 0x80AB #define GL_TEXTURE_CUBE_MAP 0x8513 #define GL_TEXTURE_BINDING_CUBE_MAP 0x8514 #define GL_TEXTURE_CUBE_MAP_POSITIVE_X 0x8515 #define GL_TEXTURE_CUBE_MAP_NEGATIVE_X 0x8516 #define GL_TEXTURE_CUBE_MAP_POSITIVE_Y 0x8517 #define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y 0x8518 #define GL_TEXTURE_CUBE_MAP_POSITIVE_Z 0x8519 #define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z 0x851A #define GL_PROXY_TEXTURE_CUBE_MAP 0x851B #define GL_MAX_CUBE_MAP_TEXTURE_SIZE 0x851C #define GL_COMPRESSED_RGB 0x84ED #define GL_COMPRESSED_RGBA 0x84EE #define GL_TEXTURE_COMPRESSION_HINT 0x84EF #define GL_TEXTURE_COMPRESSED_IMAGE_SIZE 0x86A0 #define GL_TEXTURE_COMPRESSED 0x86A1 #define GL_NUM_COMPRESSED_TEXTURE_FORMATS 0x86A2 #define GL_COMPRESSED_TEXTURE_FORMATS 0x86A3 #define GL_CLAMP_TO_BORDER 0x812D #define GL_CLIENT_ACTIVE_TEXTURE 0x84E1 #define GL_MAX_TEXTURE_UNITS 0x84E2 #define GL_TRANSPOSE_MODELVIEW_MATRIX 0x84E3 #define GL_TRANSPOSE_PROJECTION_MATRIX 0x84E4 #define GL_TRANSPOSE_TEXTURE_MATRIX 0x84E5 #define GL_TRANSPOSE_COLOR_MATRIX 0x84E6 #define GL_MULTISAMPLE_BIT 0x20000000 #define GL_NORMAL_MAP 0x8511 #define GL_REFLECTION_MAP 0x8512 #define GL_COMPRESSED_ALPHA 0x84E9 #define GL_COMPRESSED_LUMINANCE 0x84EA #define GL_COMPRESSED_LUMINANCE_ALPHA 0x84EB #define GL_COMPRESSED_INTENSITY 0x84EC #define GL_COMBINE 0x8570 #define GL_COMBINE_RGB 0x8571 #define GL_COMBINE_ALPHA 0x8572 #define GL_SOURCE0_RGB 0x8580 #define GL_SOURCE1_RGB 0x8581 #define GL_SOURCE2_RGB 0x8582 #define GL_SOURCE0_ALPHA 0x8588 #define GL_SOURCE1_ALPHA 0x8589 #define GL_SOURCE2_ALPHA 0x858A #define GL_OPERAND0_RGB 0x8590 #define GL_OPERAND1_RGB 0x8591 #define GL_OPERAND2_RGB 0x8592 #define GL_OPERAND0_ALPHA 0x8598 #define GL_OPERAND1_ALPHA 0x8599 #define GL_OPERAND2_ALPHA 0x859A #define GL_RGB_SCALE 0x8573 #define GL_ADD_SIGNED 0x8574 #define GL_INTERPOLATE 0x8575 #define GL_SUBTRACT 0x84E7 #define GL_CONSTANT 0x8576 #define GL_PRIMARY_COLOR 0x8577 #define GL_PREVIOUS 0x8578 #define GL_DOT3_RGB 0x86AE #define GL_DOT3_RGBA 0x86AF typedef void (APIENTRYP PFNGLACTIVETEXTUREPROC) (GLenum texture); typedef void (APIENTRYP PFNGLSAMPLECOVERAGEPROC) (GLfloat value, GLboolean invert); typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE3DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void *data); typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE2DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void *data); typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE1DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const void *data); typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *data); typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *data); typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void *data); typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXIMAGEPROC) (GLenum target, GLint level, void *img); typedef void (APIENTRYP PFNGLCLIENTACTIVETEXTUREPROC) (GLenum texture); typedef void (APIENTRYP PFNGLMULTITEXCOORD1DPROC) (GLenum target, GLdouble s); typedef void (APIENTRYP PFNGLMULTITEXCOORD1DVPROC) (GLenum target, const GLdouble *v); typedef void (APIENTRYP PFNGLMULTITEXCOORD1FPROC) (GLenum target, GLfloat s); typedef void (APIENTRYP PFNGLMULTITEXCOORD1FVPROC) (GLenum target, const GLfloat *v); typedef void (APIENTRYP PFNGLMULTITEXCOORD1IPROC) (GLenum target, GLint s); typedef void (APIENTRYP PFNGLMULTITEXCOORD1IVPROC) (GLenum target, const GLint *v); typedef void (APIENTRYP PFNGLMULTITEXCOORD1SPROC) (GLenum target, GLshort s); typedef void (APIENTRYP PFNGLMULTITEXCOORD1SVPROC) (GLenum target, const GLshort *v); typedef void (APIENTRYP PFNGLMULTITEXCOORD2DPROC) (GLenum target, GLdouble s, GLdouble t); typedef void (APIENTRYP PFNGLMULTITEXCOORD2DVPROC) (GLenum target, const GLdouble *v); typedef void (APIENTRYP PFNGLMULTITEXCOORD2FPROC) (GLenum target, GLfloat s, GLfloat t); typedef void (APIENTRYP PFNGLMULTITEXCOORD2FVPROC) (GLenum target, const GLfloat *v); typedef void (APIENTRYP PFNGLMULTITEXCOORD2IPROC) (GLenum target, GLint s, GLint t); typedef void (APIENTRYP PFNGLMULTITEXCOORD2IVPROC) (GLenum target, const GLint *v); typedef void (APIENTRYP PFNGLMULTITEXCOORD2SPROC) (GLenum target, GLshort s, GLshort t); typedef void (APIENTRYP PFNGLMULTITEXCOORD2SVPROC) (GLenum target, const GLshort *v); typedef void (APIENTRYP PFNGLMULTITEXCOORD3DPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r); typedef void (APIENTRYP PFNGLMULTITEXCOORD3DVPROC) (GLenum target, const GLdouble *v); typedef void (APIENTRYP PFNGLMULTITEXCOORD3FPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r); typedef void (APIENTRYP PFNGLMULTITEXCOORD3FVPROC) (GLenum target, const GLfloat *v); typedef void (APIENTRYP PFNGLMULTITEXCOORD3IPROC) (GLenum target, GLint s, GLint t, GLint r); typedef void (APIENTRYP PFNGLMULTITEXCOORD3IVPROC) (GLenum target, const GLint *v); typedef void (APIENTRYP PFNGLMULTITEXCOORD3SPROC) (GLenum target, GLshort s, GLshort t, GLshort r); typedef void (APIENTRYP PFNGLMULTITEXCOORD3SVPROC) (GLenum target, const GLshort *v); typedef void (APIENTRYP PFNGLMULTITEXCOORD4DPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q); typedef void (APIENTRYP PFNGLMULTITEXCOORD4DVPROC) (GLenum target, const GLdouble *v); typedef void (APIENTRYP PFNGLMULTITEXCOORD4FPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); typedef void (APIENTRYP PFNGLMULTITEXCOORD4FVPROC) (GLenum target, const GLfloat *v); typedef void (APIENTRYP PFNGLMULTITEXCOORD4IPROC) (GLenum target, GLint s, GLint t, GLint r, GLint q); typedef void (APIENTRYP PFNGLMULTITEXCOORD4IVPROC) (GLenum target, const GLint *v); typedef void (APIENTRYP PFNGLMULTITEXCOORD4SPROC) (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q); typedef void (APIENTRYP PFNGLMULTITEXCOORD4SVPROC) (GLenum target, const GLshort *v); typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXFPROC) (const GLfloat *m); typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXDPROC) (const GLdouble *m); typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXFPROC) (const GLfloat *m); typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXDPROC) (const GLdouble *m); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glActiveTexture (GLenum texture); GLAPI void APIENTRY glSampleCoverage (GLfloat value, GLboolean invert); GLAPI void APIENTRY glCompressedTexImage3D (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void *data); GLAPI void APIENTRY glCompressedTexImage2D (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void *data); GLAPI void APIENTRY glCompressedTexImage1D (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const void *data); GLAPI void APIENTRY glCompressedTexSubImage3D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *data); GLAPI void APIENTRY glCompressedTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *data); GLAPI void APIENTRY glCompressedTexSubImage1D (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void *data); GLAPI void APIENTRY glGetCompressedTexImage (GLenum target, GLint level, void *img); GLAPI void APIENTRY glClientActiveTexture (GLenum texture); GLAPI void APIENTRY glMultiTexCoord1d (GLenum target, GLdouble s); GLAPI void APIENTRY glMultiTexCoord1dv (GLenum target, const GLdouble *v); GLAPI void APIENTRY glMultiTexCoord1f (GLenum target, GLfloat s); GLAPI void APIENTRY glMultiTexCoord1fv (GLenum target, const GLfloat *v); GLAPI void APIENTRY glMultiTexCoord1i (GLenum target, GLint s); GLAPI void APIENTRY glMultiTexCoord1iv (GLenum target, const GLint *v); GLAPI void APIENTRY glMultiTexCoord1s (GLenum target, GLshort s); GLAPI void APIENTRY glMultiTexCoord1sv (GLenum target, const GLshort *v); GLAPI void APIENTRY glMultiTexCoord2d (GLenum target, GLdouble s, GLdouble t); GLAPI void APIENTRY glMultiTexCoord2dv (GLenum target, const GLdouble *v); GLAPI void APIENTRY glMultiTexCoord2f (GLenum target, GLfloat s, GLfloat t); GLAPI void APIENTRY glMultiTexCoord2fv (GLenum target, const GLfloat *v); GLAPI void APIENTRY glMultiTexCoord2i (GLenum target, GLint s, GLint t); GLAPI void APIENTRY glMultiTexCoord2iv (GLenum target, const GLint *v); GLAPI void APIENTRY glMultiTexCoord2s (GLenum target, GLshort s, GLshort t); GLAPI void APIENTRY glMultiTexCoord2sv (GLenum target, const GLshort *v); GLAPI void APIENTRY glMultiTexCoord3d (GLenum target, GLdouble s, GLdouble t, GLdouble r); GLAPI void APIENTRY glMultiTexCoord3dv (GLenum target, const GLdouble *v); GLAPI void APIENTRY glMultiTexCoord3f (GLenum target, GLfloat s, GLfloat t, GLfloat r); GLAPI void APIENTRY glMultiTexCoord3fv (GLenum target, const GLfloat *v); GLAPI void APIENTRY glMultiTexCoord3i (GLenum target, GLint s, GLint t, GLint r); GLAPI void APIENTRY glMultiTexCoord3iv (GLenum target, const GLint *v); GLAPI void APIENTRY glMultiTexCoord3s (GLenum target, GLshort s, GLshort t, GLshort r); GLAPI void APIENTRY glMultiTexCoord3sv (GLenum target, const GLshort *v); GLAPI void APIENTRY glMultiTexCoord4d (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q); GLAPI void APIENTRY glMultiTexCoord4dv (GLenum target, const GLdouble *v); GLAPI void APIENTRY glMultiTexCoord4f (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); GLAPI void APIENTRY glMultiTexCoord4fv (GLenum target, const GLfloat *v); GLAPI void APIENTRY glMultiTexCoord4i (GLenum target, GLint s, GLint t, GLint r, GLint q); GLAPI void APIENTRY glMultiTexCoord4iv (GLenum target, const GLint *v); GLAPI void APIENTRY glMultiTexCoord4s (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q); GLAPI void APIENTRY glMultiTexCoord4sv (GLenum target, const GLshort *v); GLAPI void APIENTRY glLoadTransposeMatrixf (const GLfloat *m); GLAPI void APIENTRY glLoadTransposeMatrixd (const GLdouble *m); GLAPI void APIENTRY glMultTransposeMatrixf (const GLfloat *m); GLAPI void APIENTRY glMultTransposeMatrixd (const GLdouble *m); #endif #endif /* GL_VERSION_1_3 */ #ifndef GL_VERSION_1_4 #define GL_VERSION_1_4 1 #define GL_BLEND_DST_RGB 0x80C8 #define GL_BLEND_SRC_RGB 0x80C9 #define GL_BLEND_DST_ALPHA 0x80CA #define GL_BLEND_SRC_ALPHA 0x80CB #define GL_POINT_FADE_THRESHOLD_SIZE 0x8128 #define GL_DEPTH_COMPONENT16 0x81A5 #define GL_DEPTH_COMPONENT24 0x81A6 #define GL_DEPTH_COMPONENT32 0x81A7 #define GL_MIRRORED_REPEAT 0x8370 #define GL_MAX_TEXTURE_LOD_BIAS 0x84FD #define GL_TEXTURE_LOD_BIAS 0x8501 #define GL_INCR_WRAP 0x8507 #define GL_DECR_WRAP 0x8508 #define GL_TEXTURE_DEPTH_SIZE 0x884A #define GL_TEXTURE_COMPARE_MODE 0x884C #define GL_TEXTURE_COMPARE_FUNC 0x884D #define GL_POINT_SIZE_MIN 0x8126 #define GL_POINT_SIZE_MAX 0x8127 #define GL_POINT_DISTANCE_ATTENUATION 0x8129 #define GL_GENERATE_MIPMAP 0x8191 #define GL_GENERATE_MIPMAP_HINT 0x8192 #define GL_FOG_COORDINATE_SOURCE 0x8450 #define GL_FOG_COORDINATE 0x8451 #define GL_FRAGMENT_DEPTH 0x8452 #define GL_CURRENT_FOG_COORDINATE 0x8453 #define GL_FOG_COORDINATE_ARRAY_TYPE 0x8454 #define GL_FOG_COORDINATE_ARRAY_STRIDE 0x8455 #define GL_FOG_COORDINATE_ARRAY_POINTER 0x8456 #define GL_FOG_COORDINATE_ARRAY 0x8457 #define GL_COLOR_SUM 0x8458 #define GL_CURRENT_SECONDARY_COLOR 0x8459 #define GL_SECONDARY_COLOR_ARRAY_SIZE 0x845A #define GL_SECONDARY_COLOR_ARRAY_TYPE 0x845B #define GL_SECONDARY_COLOR_ARRAY_STRIDE 0x845C #define GL_SECONDARY_COLOR_ARRAY_POINTER 0x845D #define GL_SECONDARY_COLOR_ARRAY 0x845E #define GL_TEXTURE_FILTER_CONTROL 0x8500 #define GL_DEPTH_TEXTURE_MODE 0x884B #define GL_COMPARE_R_TO_TEXTURE 0x884E #define GL_BLEND_COLOR 0x8005 #define GL_BLEND_EQUATION 0x8009 #define GL_CONSTANT_COLOR 0x8001 #define GL_ONE_MINUS_CONSTANT_COLOR 0x8002 #define GL_CONSTANT_ALPHA 0x8003 #define GL_ONE_MINUS_CONSTANT_ALPHA 0x8004 #define GL_FUNC_ADD 0x8006 #define GL_FUNC_REVERSE_SUBTRACT 0x800B #define GL_FUNC_SUBTRACT 0x800A #define GL_MIN 0x8007 #define GL_MAX 0x8008 typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSPROC) (GLenum mode, const GLint *first, const GLsizei *count, GLsizei drawcount); typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSPROC) (GLenum mode, const GLsizei *count, GLenum type, const void *const*indices, GLsizei drawcount); typedef void (APIENTRYP PFNGLPOINTPARAMETERFPROC) (GLenum pname, GLfloat param); typedef void (APIENTRYP PFNGLPOINTPARAMETERFVPROC) (GLenum pname, const GLfloat *params); typedef void (APIENTRYP PFNGLPOINTPARAMETERIPROC) (GLenum pname, GLint param); typedef void (APIENTRYP PFNGLPOINTPARAMETERIVPROC) (GLenum pname, const GLint *params); typedef void (APIENTRYP PFNGLFOGCOORDFPROC) (GLfloat coord); typedef void (APIENTRYP PFNGLFOGCOORDFVPROC) (const GLfloat *coord); typedef void (APIENTRYP PFNGLFOGCOORDDPROC) (GLdouble coord); typedef void (APIENTRYP PFNGLFOGCOORDDVPROC) (const GLdouble *coord); typedef void (APIENTRYP PFNGLFOGCOORDPOINTERPROC) (GLenum type, GLsizei stride, const void *pointer); typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BPROC) (GLbyte red, GLbyte green, GLbyte blue); typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BVPROC) (const GLbyte *v); typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DPROC) (GLdouble red, GLdouble green, GLdouble blue); typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DVPROC) (const GLdouble *v); typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FPROC) (GLfloat red, GLfloat green, GLfloat blue); typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FVPROC) (const GLfloat *v); typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IPROC) (GLint red, GLint green, GLint blue); typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IVPROC) (const GLint *v); typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SPROC) (GLshort red, GLshort green, GLshort blue); typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SVPROC) (const GLshort *v); typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBPROC) (GLubyte red, GLubyte green, GLubyte blue); typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBVPROC) (const GLubyte *v); typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIPROC) (GLuint red, GLuint green, GLuint blue); typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIVPROC) (const GLuint *v); typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USPROC) (GLushort red, GLushort green, GLushort blue); typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USVPROC) (const GLushort *v); typedef void (APIENTRYP PFNGLSECONDARYCOLORPOINTERPROC) (GLint size, GLenum type, GLsizei stride, const void *pointer); typedef void (APIENTRYP PFNGLWINDOWPOS2DPROC) (GLdouble x, GLdouble y); typedef void (APIENTRYP PFNGLWINDOWPOS2DVPROC) (const GLdouble *v); typedef void (APIENTRYP PFNGLWINDOWPOS2FPROC) (GLfloat x, GLfloat y); typedef void (APIENTRYP PFNGLWINDOWPOS2FVPROC) (const GLfloat *v); typedef void (APIENTRYP PFNGLWINDOWPOS2IPROC) (GLint x, GLint y); typedef void (APIENTRYP PFNGLWINDOWPOS2IVPROC) (const GLint *v); typedef void (APIENTRYP PFNGLWINDOWPOS2SPROC) (GLshort x, GLshort y); typedef void (APIENTRYP PFNGLWINDOWPOS2SVPROC) (const GLshort *v); typedef void (APIENTRYP PFNGLWINDOWPOS3DPROC) (GLdouble x, GLdouble y, GLdouble z); typedef void (APIENTRYP PFNGLWINDOWPOS3DVPROC) (const GLdouble *v); typedef void (APIENTRYP PFNGLWINDOWPOS3FPROC) (GLfloat x, GLfloat y, GLfloat z); typedef void (APIENTRYP PFNGLWINDOWPOS3FVPROC) (const GLfloat *v); typedef void (APIENTRYP PFNGLWINDOWPOS3IPROC) (GLint x, GLint y, GLint z); typedef void (APIENTRYP PFNGLWINDOWPOS3IVPROC) (const GLint *v); typedef void (APIENTRYP PFNGLWINDOWPOS3SPROC) (GLshort x, GLshort y, GLshort z); typedef void (APIENTRYP PFNGLWINDOWPOS3SVPROC) (const GLshort *v); typedef void (APIENTRYP PFNGLBLENDCOLORPROC) (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); typedef void (APIENTRYP PFNGLBLENDEQUATIONPROC) (GLenum mode); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glBlendFuncSeparate (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); GLAPI void APIENTRY glMultiDrawArrays (GLenum mode, const GLint *first, const GLsizei *count, GLsizei drawcount); GLAPI void APIENTRY glMultiDrawElements (GLenum mode, const GLsizei *count, GLenum type, const void *const*indices, GLsizei drawcount); GLAPI void APIENTRY glPointParameterf (GLenum pname, GLfloat param); GLAPI void APIENTRY glPointParameterfv (GLenum pname, const GLfloat *params); GLAPI void APIENTRY glPointParameteri (GLenum pname, GLint param); GLAPI void APIENTRY glPointParameteriv (GLenum pname, const GLint *params); GLAPI void APIENTRY glFogCoordf (GLfloat coord); GLAPI void APIENTRY glFogCoordfv (const GLfloat *coord); GLAPI void APIENTRY glFogCoordd (GLdouble coord); GLAPI void APIENTRY glFogCoorddv (const GLdouble *coord); GLAPI void APIENTRY glFogCoordPointer (GLenum type, GLsizei stride, const void *pointer); GLAPI void APIENTRY glSecondaryColor3b (GLbyte red, GLbyte green, GLbyte blue); GLAPI void APIENTRY glSecondaryColor3bv (const GLbyte *v); GLAPI void APIENTRY glSecondaryColor3d (GLdouble red, GLdouble green, GLdouble blue); GLAPI void APIENTRY glSecondaryColor3dv (const GLdouble *v); GLAPI void APIENTRY glSecondaryColor3f (GLfloat red, GLfloat green, GLfloat blue); GLAPI void APIENTRY glSecondaryColor3fv (const GLfloat *v); GLAPI void APIENTRY glSecondaryColor3i (GLint red, GLint green, GLint blue); GLAPI void APIENTRY glSecondaryColor3iv (const GLint *v); GLAPI void APIENTRY glSecondaryColor3s (GLshort red, GLshort green, GLshort blue); GLAPI void APIENTRY glSecondaryColor3sv (const GLshort *v); GLAPI void APIENTRY glSecondaryColor3ub (GLubyte red, GLubyte green, GLubyte blue); GLAPI void APIENTRY glSecondaryColor3ubv (const GLubyte *v); GLAPI void APIENTRY glSecondaryColor3ui (GLuint red, GLuint green, GLuint blue); GLAPI void APIENTRY glSecondaryColor3uiv (const GLuint *v); GLAPI void APIENTRY glSecondaryColor3us (GLushort red, GLushort green, GLushort blue); GLAPI void APIENTRY glSecondaryColor3usv (const GLushort *v); GLAPI void APIENTRY glSecondaryColorPointer (GLint size, GLenum type, GLsizei stride, const void *pointer); GLAPI void APIENTRY glWindowPos2d (GLdouble x, GLdouble y); GLAPI void APIENTRY glWindowPos2dv (const GLdouble *v); GLAPI void APIENTRY glWindowPos2f (GLfloat x, GLfloat y); GLAPI void APIENTRY glWindowPos2fv (const GLfloat *v); GLAPI void APIENTRY glWindowPos2i (GLint x, GLint y); GLAPI void APIENTRY glWindowPos2iv (const GLint *v); GLAPI void APIENTRY glWindowPos2s (GLshort x, GLshort y); GLAPI void APIENTRY glWindowPos2sv (const GLshort *v); GLAPI void APIENTRY glWindowPos3d (GLdouble x, GLdouble y, GLdouble z); GLAPI void APIENTRY glWindowPos3dv (const GLdouble *v); GLAPI void APIENTRY glWindowPos3f (GLfloat x, GLfloat y, GLfloat z); GLAPI void APIENTRY glWindowPos3fv (const GLfloat *v); GLAPI void APIENTRY glWindowPos3i (GLint x, GLint y, GLint z); GLAPI void APIENTRY glWindowPos3iv (const GLint *v); GLAPI void APIENTRY glWindowPos3s (GLshort x, GLshort y, GLshort z); GLAPI void APIENTRY glWindowPos3sv (const GLshort *v); GLAPI void APIENTRY glBlendColor (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); GLAPI void APIENTRY glBlendEquation (GLenum mode); #endif #endif /* GL_VERSION_1_4 */ #ifndef GL_VERSION_1_5 #define GL_VERSION_1_5 1 typedef khronos_ssize_t GLsizeiptr; typedef khronos_intptr_t GLintptr; #define GL_BUFFER_SIZE 0x8764 #define GL_BUFFER_USAGE 0x8765 #define GL_QUERY_COUNTER_BITS 0x8864 #define GL_CURRENT_QUERY 0x8865 #define GL_QUERY_RESULT 0x8866 #define GL_QUERY_RESULT_AVAILABLE 0x8867 #define GL_ARRAY_BUFFER 0x8892 #define GL_ELEMENT_ARRAY_BUFFER 0x8893 #define GL_ARRAY_BUFFER_BINDING 0x8894 #define GL_ELEMENT_ARRAY_BUFFER_BINDING 0x8895 #define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING 0x889F #define GL_READ_ONLY 0x88B8 #define GL_WRITE_ONLY 0x88B9 #define GL_READ_WRITE 0x88BA #define GL_BUFFER_ACCESS 0x88BB #define GL_BUFFER_MAPPED 0x88BC #define GL_BUFFER_MAP_POINTER 0x88BD #define GL_STREAM_DRAW 0x88E0 #define GL_STREAM_READ 0x88E1 #define GL_STREAM_COPY 0x88E2 #define GL_STATIC_DRAW 0x88E4 #define GL_STATIC_READ 0x88E5 #define GL_STATIC_COPY 0x88E6 #define GL_DYNAMIC_DRAW 0x88E8 #define GL_DYNAMIC_READ 0x88E9 #define GL_DYNAMIC_COPY 0x88EA #define GL_SAMPLES_PASSED 0x8914 #define GL_SRC1_ALPHA 0x8589 #define GL_VERTEX_ARRAY_BUFFER_BINDING 0x8896 #define GL_NORMAL_ARRAY_BUFFER_BINDING 0x8897 #define GL_COLOR_ARRAY_BUFFER_BINDING 0x8898 #define GL_INDEX_ARRAY_BUFFER_BINDING 0x8899 #define GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING 0x889A #define GL_EDGE_FLAG_ARRAY_BUFFER_BINDING 0x889B #define GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING 0x889C #define GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING 0x889D #define GL_WEIGHT_ARRAY_BUFFER_BINDING 0x889E #define GL_FOG_COORD_SRC 0x8450 #define GL_FOG_COORD 0x8451 #define GL_CURRENT_FOG_COORD 0x8453 #define GL_FOG_COORD_ARRAY_TYPE 0x8454 #define GL_FOG_COORD_ARRAY_STRIDE 0x8455 #define GL_FOG_COORD_ARRAY_POINTER 0x8456 #define GL_FOG_COORD_ARRAY 0x8457 #define GL_FOG_COORD_ARRAY_BUFFER_BINDING 0x889D #define GL_SRC0_RGB 0x8580 #define GL_SRC1_RGB 0x8581 #define GL_SRC2_RGB 0x8582 #define GL_SRC0_ALPHA 0x8588 #define GL_SRC2_ALPHA 0x858A typedef void (APIENTRYP PFNGLGENQUERIESPROC) (GLsizei n, GLuint *ids); typedef void (APIENTRYP PFNGLDELETEQUERIESPROC) (GLsizei n, const GLuint *ids); typedef GLboolean (APIENTRYP PFNGLISQUERYPROC) (GLuint id); typedef void (APIENTRYP PFNGLBEGINQUERYPROC) (GLenum target, GLuint id); typedef void (APIENTRYP PFNGLENDQUERYPROC) (GLenum target); typedef void (APIENTRYP PFNGLGETQUERYIVPROC) (GLenum target, GLenum pname, GLint *params); typedef void (APIENTRYP PFNGLGETQUERYOBJECTIVPROC) (GLuint id, GLenum pname, GLint *params); typedef void (APIENTRYP PFNGLGETQUERYOBJECTUIVPROC) (GLuint id, GLenum pname, GLuint *params); typedef void (APIENTRYP PFNGLBINDBUFFERPROC) (GLenum target, GLuint buffer); typedef void (APIENTRYP PFNGLDELETEBUFFERSPROC) (GLsizei n, const GLuint *buffers); typedef void (APIENTRYP PFNGLGENBUFFERSPROC) (GLsizei n, GLuint *buffers); typedef GLboolean (APIENTRYP PFNGLISBUFFERPROC) (GLuint buffer); typedef void (APIENTRYP PFNGLBUFFERDATAPROC) (GLenum target, GLsizeiptr size, const void *data, GLenum usage); typedef void (APIENTRYP PFNGLBUFFERSUBDATAPROC) (GLenum target, GLintptr offset, GLsizeiptr size, const void *data); typedef void (APIENTRYP PFNGLGETBUFFERSUBDATAPROC) (GLenum target, GLintptr offset, GLsizeiptr size, void *data); typedef void *(APIENTRYP PFNGLMAPBUFFERPROC) (GLenum target, GLenum access); typedef GLboolean (APIENTRYP PFNGLUNMAPBUFFERPROC) (GLenum target); typedef void (APIENTRYP PFNGLGETBUFFERPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); typedef void (APIENTRYP PFNGLGETBUFFERPOINTERVPROC) (GLenum target, GLenum pname, void **params); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glGenQueries (GLsizei n, GLuint *ids); GLAPI void APIENTRY glDeleteQueries (GLsizei n, const GLuint *ids); GLAPI GLboolean APIENTRY glIsQuery (GLuint id); GLAPI void APIENTRY glBeginQuery (GLenum target, GLuint id); GLAPI void APIENTRY glEndQuery (GLenum target); GLAPI void APIENTRY glGetQueryiv (GLenum target, GLenum pname, GLint *params); GLAPI void APIENTRY glGetQueryObjectiv (GLuint id, GLenum pname, GLint *params); GLAPI void APIENTRY glGetQueryObjectuiv (GLuint id, GLenum pname, GLuint *params); GLAPI void APIENTRY glBindBuffer (GLenum target, GLuint buffer); GLAPI void APIENTRY glDeleteBuffers (GLsizei n, const GLuint *buffers); GLAPI void APIENTRY glGenBuffers (GLsizei n, GLuint *buffers); GLAPI GLboolean APIENTRY glIsBuffer (GLuint buffer); GLAPI void APIENTRY glBufferData (GLenum target, GLsizeiptr size, const void *data, GLenum usage); GLAPI void APIENTRY glBufferSubData (GLenum target, GLintptr offset, GLsizeiptr size, const void *data); GLAPI void APIENTRY glGetBufferSubData (GLenum target, GLintptr offset, GLsizeiptr size, void *data); GLAPI void *APIENTRY glMapBuffer (GLenum target, GLenum access); GLAPI GLboolean APIENTRY glUnmapBuffer (GLenum target); GLAPI void APIENTRY glGetBufferParameteriv (GLenum target, GLenum pname, GLint *params); GLAPI void APIENTRY glGetBufferPointerv (GLenum target, GLenum pname, void **params); #endif #endif /* GL_VERSION_1_5 */ #ifndef GL_VERSION_2_0 #define GL_VERSION_2_0 1 typedef char GLchar; #define GL_BLEND_EQUATION_RGB 0x8009 #define GL_VERTEX_ATTRIB_ARRAY_ENABLED 0x8622 #define GL_VERTEX_ATTRIB_ARRAY_SIZE 0x8623 #define GL_VERTEX_ATTRIB_ARRAY_STRIDE 0x8624 #define GL_VERTEX_ATTRIB_ARRAY_TYPE 0x8625 #define GL_CURRENT_VERTEX_ATTRIB 0x8626 #define GL_VERTEX_PROGRAM_POINT_SIZE 0x8642 #define GL_VERTEX_ATTRIB_ARRAY_POINTER 0x8645 #define GL_STENCIL_BACK_FUNC 0x8800 #define GL_STENCIL_BACK_FAIL 0x8801 #define GL_STENCIL_BACK_PASS_DEPTH_FAIL 0x8802 #define GL_STENCIL_BACK_PASS_DEPTH_PASS 0x8803 #define GL_MAX_DRAW_BUFFERS 0x8824 #define GL_DRAW_BUFFER0 0x8825 #define GL_DRAW_BUFFER1 0x8826 #define GL_DRAW_BUFFER2 0x8827 #define GL_DRAW_BUFFER3 0x8828 #define GL_DRAW_BUFFER4 0x8829 #define GL_DRAW_BUFFER5 0x882A #define GL_DRAW_BUFFER6 0x882B #define GL_DRAW_BUFFER7 0x882C #define GL_DRAW_BUFFER8 0x882D #define GL_DRAW_BUFFER9 0x882E #define GL_DRAW_BUFFER10 0x882F #define GL_DRAW_BUFFER11 0x8830 #define GL_DRAW_BUFFER12 0x8831 #define GL_DRAW_BUFFER13 0x8832 #define GL_DRAW_BUFFER14 0x8833 #define GL_DRAW_BUFFER15 0x8834 #define GL_BLEND_EQUATION_ALPHA 0x883D #define GL_MAX_VERTEX_ATTRIBS 0x8869 #define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED 0x886A #define GL_MAX_TEXTURE_IMAGE_UNITS 0x8872 #define GL_FRAGMENT_SHADER 0x8B30 #define GL_VERTEX_SHADER 0x8B31 #define GL_MAX_FRAGMENT_UNIFORM_COMPONENTS 0x8B49 #define GL_MAX_VERTEX_UNIFORM_COMPONENTS 0x8B4A #define GL_MAX_VARYING_FLOATS 0x8B4B #define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS 0x8B4C #define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS 0x8B4D #define GL_SHADER_TYPE 0x8B4F #define GL_FLOAT_VEC2 0x8B50 #define GL_FLOAT_VEC3 0x8B51 #define GL_FLOAT_VEC4 0x8B52 #define GL_INT_VEC2 0x8B53 #define GL_INT_VEC3 0x8B54 #define GL_INT_VEC4 0x8B55 #define GL_BOOL 0x8B56 #define GL_BOOL_VEC2 0x8B57 #define GL_BOOL_VEC3 0x8B58 #define GL_BOOL_VEC4 0x8B59 #define GL_FLOAT_MAT2 0x8B5A #define GL_FLOAT_MAT3 0x8B5B #define GL_FLOAT_MAT4 0x8B5C #define GL_SAMPLER_1D 0x8B5D #define GL_SAMPLER_2D 0x8B5E #define GL_SAMPLER_3D 0x8B5F #define GL_SAMPLER_CUBE 0x8B60 #define GL_SAMPLER_1D_SHADOW 0x8B61 #define GL_SAMPLER_2D_SHADOW 0x8B62 #define GL_DELETE_STATUS 0x8B80 #define GL_COMPILE_STATUS 0x8B81 #define GL_LINK_STATUS 0x8B82 #define GL_VALIDATE_STATUS 0x8B83 #define GL_INFO_LOG_LENGTH 0x8B84 #define GL_ATTACHED_SHADERS 0x8B85 #define GL_ACTIVE_UNIFORMS 0x8B86 #define GL_ACTIVE_UNIFORM_MAX_LENGTH 0x8B87 #define GL_SHADER_SOURCE_LENGTH 0x8B88 #define GL_ACTIVE_ATTRIBUTES 0x8B89 #define GL_ACTIVE_ATTRIBUTE_MAX_LENGTH 0x8B8A #define GL_FRAGMENT_SHADER_DERIVATIVE_HINT 0x8B8B #define GL_SHADING_LANGUAGE_VERSION 0x8B8C #define GL_CURRENT_PROGRAM 0x8B8D #define GL_POINT_SPRITE_COORD_ORIGIN 0x8CA0 #define GL_LOWER_LEFT 0x8CA1 #define GL_UPPER_LEFT 0x8CA2 #define GL_STENCIL_BACK_REF 0x8CA3 #define GL_STENCIL_BACK_VALUE_MASK 0x8CA4 #define GL_STENCIL_BACK_WRITEMASK 0x8CA5 #define GL_VERTEX_PROGRAM_TWO_SIDE 0x8643 #define GL_POINT_SPRITE 0x8861 #define GL_COORD_REPLACE 0x8862 #define GL_MAX_TEXTURE_COORDS 0x8871 typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEPROC) (GLenum modeRGB, GLenum modeAlpha); typedef void (APIENTRYP PFNGLDRAWBUFFERSPROC) (GLsizei n, const GLenum *bufs); typedef void (APIENTRYP PFNGLSTENCILOPSEPARATEPROC) (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); typedef void (APIENTRYP PFNGLSTENCILFUNCSEPARATEPROC) (GLenum face, GLenum func, GLint ref, GLuint mask); typedef void (APIENTRYP PFNGLSTENCILMASKSEPARATEPROC) (GLenum face, GLuint mask); typedef void (APIENTRYP PFNGLATTACHSHADERPROC) (GLuint program, GLuint shader); typedef void (APIENTRYP PFNGLBINDATTRIBLOCATIONPROC) (GLuint program, GLuint index, const GLchar *name); typedef void (APIENTRYP PFNGLCOMPILESHADERPROC) (GLuint shader); typedef GLuint (APIENTRYP PFNGLCREATEPROGRAMPROC) (void); typedef GLuint (APIENTRYP PFNGLCREATESHADERPROC) (GLenum type); typedef void (APIENTRYP PFNGLDELETEPROGRAMPROC) (GLuint program); typedef void (APIENTRYP PFNGLDELETESHADERPROC) (GLuint shader); typedef void (APIENTRYP PFNGLDETACHSHADERPROC) (GLuint program, GLuint shader); typedef void (APIENTRYP PFNGLDISABLEVERTEXATTRIBARRAYPROC) (GLuint index); typedef void (APIENTRYP PFNGLENABLEVERTEXATTRIBARRAYPROC) (GLuint index); typedef void (APIENTRYP PFNGLGETACTIVEATTRIBPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); typedef void (APIENTRYP PFNGLGETATTACHEDSHADERSPROC) (GLuint program, GLsizei maxCount, GLsizei *count, GLuint *shaders); typedef GLint (APIENTRYP PFNGLGETATTRIBLOCATIONPROC) (GLuint program, const GLchar *name); typedef void (APIENTRYP PFNGLGETPROGRAMIVPROC) (GLuint program, GLenum pname, GLint *params); typedef void (APIENTRYP PFNGLGETPROGRAMINFOLOGPROC) (GLuint program, GLsizei bufSize, GLsizei *length, GLchar *infoLog); typedef void (APIENTRYP PFNGLGETSHADERIVPROC) (GLuint shader, GLenum pname, GLint *params); typedef void (APIENTRYP PFNGLGETSHADERINFOLOGPROC) (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog); typedef void (APIENTRYP PFNGLGETSHADERSOURCEPROC) (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *source); typedef GLint (APIENTRYP PFNGLGETUNIFORMLOCATIONPROC) (GLuint program, const GLchar *name); typedef void (APIENTRYP PFNGLGETUNIFORMFVPROC) (GLuint program, GLint location, GLfloat *params); typedef void (APIENTRYP PFNGLGETUNIFORMIVPROC) (GLuint program, GLint location, GLint *params); typedef void (APIENTRYP PFNGLGETVERTEXATTRIBDVPROC) (GLuint index, GLenum pname, GLdouble *params); typedef void (APIENTRYP PFNGLGETVERTEXATTRIBFVPROC) (GLuint index, GLenum pname, GLfloat *params); typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIVPROC) (GLuint index, GLenum pname, GLint *params); typedef void (APIENTRYP PFNGLGETVERTEXATTRIBPOINTERVPROC) (GLuint index, GLenum pname, void **pointer); typedef GLboolean (APIENTRYP PFNGLISPROGRAMPROC) (GLuint program); typedef GLboolean (APIENTRYP PFNGLISSHADERPROC) (GLuint shader); typedef void (APIENTRYP PFNGLLINKPROGRAMPROC) (GLuint program); typedef void (APIENTRYP PFNGLSHADERSOURCEPROC) (GLuint shader, GLsizei count, const GLchar *const*string, const GLint *length); typedef void (APIENTRYP PFNGLUSEPROGRAMPROC) (GLuint program); typedef void (APIENTRYP PFNGLUNIFORM1FPROC) (GLint location, GLfloat v0); typedef void (APIENTRYP PFNGLUNIFORM2FPROC) (GLint location, GLfloat v0, GLfloat v1); typedef void (APIENTRYP PFNGLUNIFORM3FPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2); typedef void (APIENTRYP PFNGLUNIFORM4FPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); typedef void (APIENTRYP PFNGLUNIFORM1IPROC) (GLint location, GLint v0); typedef void (APIENTRYP PFNGLUNIFORM2IPROC) (GLint location, GLint v0, GLint v1); typedef void (APIENTRYP PFNGLUNIFORM3IPROC) (GLint location, GLint v0, GLint v1, GLint v2); typedef void (APIENTRYP PFNGLUNIFORM4IPROC) (GLint location, GLint v0, GLint v1, GLint v2, GLint v3); typedef void (APIENTRYP PFNGLUNIFORM1FVPROC) (GLint location, GLsizei count, const GLfloat *value); typedef void (APIENTRYP PFNGLUNIFORM2FVPROC) (GLint location, GLsizei count, const GLfloat *value); typedef void (APIENTRYP PFNGLUNIFORM3FVPROC) (GLint location, GLsizei count, const GLfloat *value); typedef void (APIENTRYP PFNGLUNIFORM4FVPROC) (GLint location, GLsizei count, const GLfloat *value); typedef void (APIENTRYP PFNGLUNIFORM1IVPROC) (GLint location, GLsizei count, const GLint *value); typedef void (APIENTRYP PFNGLUNIFORM2IVPROC) (GLint location, GLsizei count, const GLint *value); typedef void (APIENTRYP PFNGLUNIFORM3IVPROC) (GLint location, GLsizei count, const GLint *value); typedef void (APIENTRYP PFNGLUNIFORM4IVPROC) (GLint location, GLsizei count, const GLint *value); typedef void (APIENTRYP PFNGLUNIFORMMATRIX2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); typedef void (APIENTRYP PFNGLUNIFORMMATRIX3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); typedef void (APIENTRYP PFNGLUNIFORMMATRIX4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); typedef void (APIENTRYP PFNGLVALIDATEPROGRAMPROC) (GLuint program); typedef void (APIENTRYP PFNGLVERTEXATTRIB1DPROC) (GLuint index, GLdouble x); typedef void (APIENTRYP PFNGLVERTEXATTRIB1DVPROC) (GLuint index, const GLdouble *v); typedef void (APIENTRYP PFNGLVERTEXATTRIB1FPROC) (GLuint index, GLfloat x); typedef void (APIENTRYP PFNGLVERTEXATTRIB1FVPROC) (GLuint index, const GLfloat *v); typedef void (APIENTRYP PFNGLVERTEXATTRIB1SPROC) (GLuint index, GLshort x); typedef void (APIENTRYP PFNGLVERTEXATTRIB1SVPROC) (GLuint index, const GLshort *v); typedef void (APIENTRYP PFNGLVERTEXATTRIB2DPROC) (GLuint index, GLdouble x, GLdouble y); typedef void (APIENTRYP PFNGLVERTEXATTRIB2DVPROC) (GLuint index, const GLdouble *v); typedef void (APIENTRYP PFNGLVERTEXATTRIB2FPROC) (GLuint index, GLfloat x, GLfloat y); typedef void (APIENTRYP PFNGLVERTEXATTRIB2FVPROC) (GLuint index, const GLfloat *v); typedef void (APIENTRYP PFNGLVERTEXATTRIB2SPROC) (GLuint index, GLshort x, GLshort y); typedef void (APIENTRYP PFNGLVERTEXATTRIB2SVPROC) (GLuint index, const GLshort *v); typedef void (APIENTRYP PFNGLVERTEXATTRIB3DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); typedef void (APIENTRYP PFNGLVERTEXATTRIB3DVPROC) (GLuint index, const GLdouble *v); typedef void (APIENTRYP PFNGLVERTEXATTRIB3FPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z); typedef void (APIENTRYP PFNGLVERTEXATTRIB3FVPROC) (GLuint index, const GLfloat *v); typedef void (APIENTRYP PFNGLVERTEXATTRIB3SPROC) (GLuint index, GLshort x, GLshort y, GLshort z); typedef void (APIENTRYP PFNGLVERTEXATTRIB3SVPROC) (GLuint index, const GLshort *v); typedef void (APIENTRYP PFNGLVERTEXATTRIB4NBVPROC) (GLuint index, const GLbyte *v); typedef void (APIENTRYP PFNGLVERTEXATTRIB4NIVPROC) (GLuint index, const GLint *v); typedef void (APIENTRYP PFNGLVERTEXATTRIB4NSVPROC) (GLuint index, const GLshort *v); typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBPROC) (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBVPROC) (GLuint index, const GLubyte *v); typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUIVPROC) (GLuint index, const GLuint *v); typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUSVPROC) (GLuint index, const GLushort *v); typedef void (APIENTRYP PFNGLVERTEXATTRIB4BVPROC) (GLuint index, const GLbyte *v); typedef void (APIENTRYP PFNGLVERTEXATTRIB4DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); typedef void (APIENTRYP PFNGLVERTEXATTRIB4DVPROC) (GLuint index, const GLdouble *v); typedef void (APIENTRYP PFNGLVERTEXATTRIB4FPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); typedef void (APIENTRYP PFNGLVERTEXATTRIB4FVPROC) (GLuint index, const GLfloat *v); typedef void (APIENTRYP PFNGLVERTEXATTRIB4IVPROC) (GLuint index, const GLint *v); typedef void (APIENTRYP PFNGLVERTEXATTRIB4SPROC) (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); typedef void (APIENTRYP PFNGLVERTEXATTRIB4SVPROC) (GLuint index, const GLshort *v); typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBVPROC) (GLuint index, const GLubyte *v); typedef void (APIENTRYP PFNGLVERTEXATTRIB4UIVPROC) (GLuint index, const GLuint *v); typedef void (APIENTRYP PFNGLVERTEXATTRIB4USVPROC) (GLuint index, const GLushort *v); typedef void (APIENTRYP PFNGLVERTEXATTRIBPOINTERPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void *pointer); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glBlendEquationSeparate (GLenum modeRGB, GLenum modeAlpha); GLAPI void APIENTRY glDrawBuffers (GLsizei n, const GLenum *bufs); GLAPI void APIENTRY glStencilOpSeparate (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); GLAPI void APIENTRY glStencilFuncSeparate (GLenum face, GLenum func, GLint ref, GLuint mask); GLAPI void APIENTRY glStencilMaskSeparate (GLenum face, GLuint mask); GLAPI void APIENTRY glAttachShader (GLuint program, GLuint shader); GLAPI void APIENTRY glBindAttribLocation (GLuint program, GLuint index, const GLchar *name); GLAPI void APIENTRY glCompileShader (GLuint shader); GLAPI GLuint APIENTRY glCreateProgram (void); GLAPI GLuint APIENTRY glCreateShader (GLenum type); GLAPI void APIENTRY glDeleteProgram (GLuint program); GLAPI void APIENTRY glDeleteShader (GLuint shader); GLAPI void APIENTRY glDetachShader (GLuint program, GLuint shader); GLAPI void APIENTRY glDisableVertexAttribArray (GLuint index); GLAPI void APIENTRY glEnableVertexAttribArray (GLuint index); GLAPI void APIENTRY glGetActiveAttrib (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); GLAPI void APIENTRY glGetActiveUniform (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); GLAPI void APIENTRY glGetAttachedShaders (GLuint program, GLsizei maxCount, GLsizei *count, GLuint *shaders); GLAPI GLint APIENTRY glGetAttribLocation (GLuint program, const GLchar *name); GLAPI void APIENTRY glGetProgramiv (GLuint program, GLenum pname, GLint *params); GLAPI void APIENTRY glGetProgramInfoLog (GLuint program, GLsizei bufSize, GLsizei *length, GLchar *infoLog); GLAPI void APIENTRY glGetShaderiv (GLuint shader, GLenum pname, GLint *params); GLAPI void APIENTRY glGetShaderInfoLog (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog); GLAPI void APIENTRY glGetShaderSource (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *source); GLAPI GLint APIENTRY glGetUniformLocation (GLuint program, const GLchar *name); GLAPI void APIENTRY glGetUniformfv (GLuint program, GLint location, GLfloat *params); GLAPI void APIENTRY glGetUniformiv (GLuint program, GLint location, GLint *params); GLAPI void APIENTRY glGetVertexAttribdv (GLuint index, GLenum pname, GLdouble *params); GLAPI void APIENTRY glGetVertexAttribfv (GLuint index, GLenum pname, GLfloat *params); GLAPI void APIENTRY glGetVertexAttribiv (GLuint index, GLenum pname, GLint *params); GLAPI void APIENTRY glGetVertexAttribPointerv (GLuint index, GLenum pname, void **pointer); GLAPI GLboolean APIENTRY glIsProgram (GLuint program); GLAPI GLboolean APIENTRY glIsShader (GLuint shader); GLAPI void APIENTRY glLinkProgram (GLuint program); GLAPI void APIENTRY glShaderSource (GLuint shader, GLsizei count, const GLchar *const*string, const GLint *length); GLAPI void APIENTRY glUseProgram (GLuint program); GLAPI void APIENTRY glUniform1f (GLint location, GLfloat v0); GLAPI void APIENTRY glUniform2f (GLint location, GLfloat v0, GLfloat v1); GLAPI void APIENTRY glUniform3f (GLint location, GLfloat v0, GLfloat v1, GLfloat v2); GLAPI void APIENTRY glUniform4f (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); GLAPI void APIENTRY glUniform1i (GLint location, GLint v0); GLAPI void APIENTRY glUniform2i (GLint location, GLint v0, GLint v1); GLAPI void APIENTRY glUniform3i (GLint location, GLint v0, GLint v1, GLint v2); GLAPI void APIENTRY glUniform4i (GLint location, GLint v0, GLint v1, GLint v2, GLint v3); GLAPI void APIENTRY glUniform1fv (GLint location, GLsizei count, const GLfloat *value); GLAPI void APIENTRY glUniform2fv (GLint location, GLsizei count, const GLfloat *value); GLAPI void APIENTRY glUniform3fv (GLint location, GLsizei count, const GLfloat *value); GLAPI void APIENTRY glUniform4fv (GLint location, GLsizei count, const GLfloat *value); GLAPI void APIENTRY glUniform1iv (GLint location, GLsizei count, const GLint *value); GLAPI void APIENTRY glUniform2iv (GLint location, GLsizei count, const GLint *value); GLAPI void APIENTRY glUniform3iv (GLint location, GLsizei count, const GLint *value); GLAPI void APIENTRY glUniform4iv (GLint location, GLsizei count, const GLint *value); GLAPI void APIENTRY glUniformMatrix2fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); GLAPI void APIENTRY glUniformMatrix3fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); GLAPI void APIENTRY glUniformMatrix4fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); GLAPI void APIENTRY glValidateProgram (GLuint program); GLAPI void APIENTRY glVertexAttrib1d (GLuint index, GLdouble x); GLAPI void APIENTRY glVertexAttrib1dv (GLuint index, const GLdouble *v); GLAPI void APIENTRY glVertexAttrib1f (GLuint index, GLfloat x); GLAPI void APIENTRY glVertexAttrib1fv (GLuint index, const GLfloat *v); GLAPI void APIENTRY glVertexAttrib1s (GLuint index, GLshort x); GLAPI void APIENTRY glVertexAttrib1sv (GLuint index, const GLshort *v); GLAPI void APIENTRY glVertexAttrib2d (GLuint index, GLdouble x, GLdouble y); GLAPI void APIENTRY glVertexAttrib2dv (GLuint index, const GLdouble *v); GLAPI void APIENTRY glVertexAttrib2f (GLuint index, GLfloat x, GLfloat y); GLAPI void APIENTRY glVertexAttrib2fv (GLuint index, const GLfloat *v); GLAPI void APIENTRY glVertexAttrib2s (GLuint index, GLshort x, GLshort y); GLAPI void APIENTRY glVertexAttrib2sv (GLuint index, const GLshort *v); GLAPI void APIENTRY glVertexAttrib3d (GLuint index, GLdouble x, GLdouble y, GLdouble z); GLAPI void APIENTRY glVertexAttrib3dv (GLuint index, const GLdouble *v); GLAPI void APIENTRY glVertexAttrib3f (GLuint index, GLfloat x, GLfloat y, GLfloat z); GLAPI void APIENTRY glVertexAttrib3fv (GLuint index, const GLfloat *v); GLAPI void APIENTRY glVertexAttrib3s (GLuint index, GLshort x, GLshort y, GLshort z); GLAPI void APIENTRY glVertexAttrib3sv (GLuint index, const GLshort *v); GLAPI void APIENTRY glVertexAttrib4Nbv (GLuint index, const GLbyte *v); GLAPI void APIENTRY glVertexAttrib4Niv (GLuint index, const GLint *v); GLAPI void APIENTRY glVertexAttrib4Nsv (GLuint index, const GLshort *v); GLAPI void APIENTRY glVertexAttrib4Nub (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); GLAPI void APIENTRY glVertexAttrib4Nubv (GLuint index, const GLubyte *v); GLAPI void APIENTRY glVertexAttrib4Nuiv (GLuint index, const GLuint *v); GLAPI void APIENTRY glVertexAttrib4Nusv (GLuint index, const GLushort *v); GLAPI void APIENTRY glVertexAttrib4bv (GLuint index, const GLbyte *v); GLAPI void APIENTRY glVertexAttrib4d (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); GLAPI void APIENTRY glVertexAttrib4dv (GLuint index, const GLdouble *v); GLAPI void APIENTRY glVertexAttrib4f (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); GLAPI void APIENTRY glVertexAttrib4fv (GLuint index, const GLfloat *v); GLAPI void APIENTRY glVertexAttrib4iv (GLuint index, const GLint *v); GLAPI void APIENTRY glVertexAttrib4s (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); GLAPI void APIENTRY glVertexAttrib4sv (GLuint index, const GLshort *v); GLAPI void APIENTRY glVertexAttrib4ubv (GLuint index, const GLubyte *v); GLAPI void APIENTRY glVertexAttrib4uiv (GLuint index, const GLuint *v); GLAPI void APIENTRY glVertexAttrib4usv (GLuint index, const GLushort *v); GLAPI void APIENTRY glVertexAttribPointer (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void *pointer); #endif #endif /* GL_VERSION_2_0 */ #ifndef GL_VERSION_2_1 #define GL_VERSION_2_1 1 #define GL_PIXEL_PACK_BUFFER 0x88EB #define GL_PIXEL_UNPACK_BUFFER 0x88EC #define GL_PIXEL_PACK_BUFFER_BINDING 0x88ED #define GL_PIXEL_UNPACK_BUFFER_BINDING 0x88EF #define GL_FLOAT_MAT2x3 0x8B65 #define GL_FLOAT_MAT2x4 0x8B66 #define GL_FLOAT_MAT3x2 0x8B67 #define GL_FLOAT_MAT3x4 0x8B68 #define GL_FLOAT_MAT4x2 0x8B69 #define GL_FLOAT_MAT4x3 0x8B6A #define GL_SRGB 0x8C40 #define GL_SRGB8 0x8C41 #define GL_SRGB_ALPHA 0x8C42 #define GL_SRGB8_ALPHA8 0x8C43 #define GL_COMPRESSED_SRGB 0x8C48 #define GL_COMPRESSED_SRGB_ALPHA 0x8C49 #define GL_CURRENT_RASTER_SECONDARY_COLOR 0x845F #define GL_SLUMINANCE_ALPHA 0x8C44 #define GL_SLUMINANCE8_ALPHA8 0x8C45 #define GL_SLUMINANCE 0x8C46 #define GL_SLUMINANCE8 0x8C47 #define GL_COMPRESSED_SLUMINANCE 0x8C4A #define GL_COMPRESSED_SLUMINANCE_ALPHA 0x8C4B typedef void (APIENTRYP PFNGLUNIFORMMATRIX2X3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); typedef void (APIENTRYP PFNGLUNIFORMMATRIX3X2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); typedef void (APIENTRYP PFNGLUNIFORMMATRIX2X4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); typedef void (APIENTRYP PFNGLUNIFORMMATRIX4X2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); typedef void (APIENTRYP PFNGLUNIFORMMATRIX3X4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); typedef void (APIENTRYP PFNGLUNIFORMMATRIX4X3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glUniformMatrix2x3fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); GLAPI void APIENTRY glUniformMatrix3x2fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); GLAPI void APIENTRY glUniformMatrix2x4fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); GLAPI void APIENTRY glUniformMatrix4x2fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); GLAPI void APIENTRY glUniformMatrix3x4fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); GLAPI void APIENTRY glUniformMatrix4x3fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); #endif #endif /* GL_VERSION_2_1 */ #ifndef GL_VERSION_3_0 #define GL_VERSION_3_0 1 typedef khronos_uint16_t GLhalf; #define GL_COMPARE_REF_TO_TEXTURE 0x884E #define GL_CLIP_DISTANCE0 0x3000 #define GL_CLIP_DISTANCE1 0x3001 #define GL_CLIP_DISTANCE2 0x3002 #define GL_CLIP_DISTANCE3 0x3003 #define GL_CLIP_DISTANCE4 0x3004 #define GL_CLIP_DISTANCE5 0x3005 #define GL_CLIP_DISTANCE6 0x3006 #define GL_CLIP_DISTANCE7 0x3007 #define GL_MAX_CLIP_DISTANCES 0x0D32 #define GL_MAJOR_VERSION 0x821B #define GL_MINOR_VERSION 0x821C #define GL_NUM_EXTENSIONS 0x821D #define GL_CONTEXT_FLAGS 0x821E #define GL_COMPRESSED_RED 0x8225 #define GL_COMPRESSED_RG 0x8226 #define GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT 0x00000001 #define GL_RGBA32F 0x8814 #define GL_RGB32F 0x8815 #define GL_RGBA16F 0x881A #define GL_RGB16F 0x881B #define GL_VERTEX_ATTRIB_ARRAY_INTEGER 0x88FD #define GL_MAX_ARRAY_TEXTURE_LAYERS 0x88FF #define GL_MIN_PROGRAM_TEXEL_OFFSET 0x8904 #define GL_MAX_PROGRAM_TEXEL_OFFSET 0x8905 #define GL_CLAMP_READ_COLOR 0x891C #define GL_FIXED_ONLY 0x891D #define GL_MAX_VARYING_COMPONENTS 0x8B4B #define GL_TEXTURE_1D_ARRAY 0x8C18 #define GL_PROXY_TEXTURE_1D_ARRAY 0x8C19 #define GL_TEXTURE_2D_ARRAY 0x8C1A #define GL_PROXY_TEXTURE_2D_ARRAY 0x8C1B #define GL_TEXTURE_BINDING_1D_ARRAY 0x8C1C #define GL_TEXTURE_BINDING_2D_ARRAY 0x8C1D #define GL_R11F_G11F_B10F 0x8C3A #define GL_UNSIGNED_INT_10F_11F_11F_REV 0x8C3B #define GL_RGB9_E5 0x8C3D #define GL_UNSIGNED_INT_5_9_9_9_REV 0x8C3E #define GL_TEXTURE_SHARED_SIZE 0x8C3F #define GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH 0x8C76 #define GL_TRANSFORM_FEEDBACK_BUFFER_MODE 0x8C7F #define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS 0x8C80 #define GL_TRANSFORM_FEEDBACK_VARYINGS 0x8C83 #define GL_TRANSFORM_FEEDBACK_BUFFER_START 0x8C84 #define GL_TRANSFORM_FEEDBACK_BUFFER_SIZE 0x8C85 #define GL_PRIMITIVES_GENERATED 0x8C87 #define GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN 0x8C88 #define GL_RASTERIZER_DISCARD 0x8C89 #define GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS 0x8C8A #define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS 0x8C8B #define GL_INTERLEAVED_ATTRIBS 0x8C8C #define GL_SEPARATE_ATTRIBS 0x8C8D #define GL_TRANSFORM_FEEDBACK_BUFFER 0x8C8E #define GL_TRANSFORM_FEEDBACK_BUFFER_BINDING 0x8C8F #define GL_RGBA32UI 0x8D70 #define GL_RGB32UI 0x8D71 #define GL_RGBA16UI 0x8D76 #define GL_RGB16UI 0x8D77 #define GL_RGBA8UI 0x8D7C #define GL_RGB8UI 0x8D7D #define GL_RGBA32I 0x8D82 #define GL_RGB32I 0x8D83 #define GL_RGBA16I 0x8D88 #define GL_RGB16I 0x8D89 #define GL_RGBA8I 0x8D8E #define GL_RGB8I 0x8D8F #define GL_RED_INTEGER 0x8D94 #define GL_GREEN_INTEGER 0x8D95 #define GL_BLUE_INTEGER 0x8D96 #define GL_RGB_INTEGER 0x8D98 #define GL_RGBA_INTEGER 0x8D99 #define GL_BGR_INTEGER 0x8D9A #define GL_BGRA_INTEGER 0x8D9B #define GL_SAMPLER_1D_ARRAY 0x8DC0 #define GL_SAMPLER_2D_ARRAY 0x8DC1 #define GL_SAMPLER_1D_ARRAY_SHADOW 0x8DC3 #define GL_SAMPLER_2D_ARRAY_SHADOW 0x8DC4 #define GL_SAMPLER_CUBE_SHADOW 0x8DC5 #define GL_UNSIGNED_INT_VEC2 0x8DC6 #define GL_UNSIGNED_INT_VEC3 0x8DC7 #define GL_UNSIGNED_INT_VEC4 0x8DC8 #define GL_INT_SAMPLER_1D 0x8DC9 #define GL_INT_SAMPLER_2D 0x8DCA #define GL_INT_SAMPLER_3D 0x8DCB #define GL_INT_SAMPLER_CUBE 0x8DCC #define GL_INT_SAMPLER_1D_ARRAY 0x8DCE #define GL_INT_SAMPLER_2D_ARRAY 0x8DCF #define GL_UNSIGNED_INT_SAMPLER_1D 0x8DD1 #define GL_UNSIGNED_INT_SAMPLER_2D 0x8DD2 #define GL_UNSIGNED_INT_SAMPLER_3D 0x8DD3 #define GL_UNSIGNED_INT_SAMPLER_CUBE 0x8DD4 #define GL_UNSIGNED_INT_SAMPLER_1D_ARRAY 0x8DD6 #define GL_UNSIGNED_INT_SAMPLER_2D_ARRAY 0x8DD7 #define GL_QUERY_WAIT 0x8E13 #define GL_QUERY_NO_WAIT 0x8E14 #define GL_QUERY_BY_REGION_WAIT 0x8E15 #define GL_QUERY_BY_REGION_NO_WAIT 0x8E16 #define GL_BUFFER_ACCESS_FLAGS 0x911F #define GL_BUFFER_MAP_LENGTH 0x9120 #define GL_BUFFER_MAP_OFFSET 0x9121 #define GL_DEPTH_COMPONENT32F 0x8CAC #define GL_DEPTH32F_STENCIL8 0x8CAD #define GL_FLOAT_32_UNSIGNED_INT_24_8_REV 0x8DAD #define GL_INVALID_FRAMEBUFFER_OPERATION 0x0506 #define GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING 0x8210 #define GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE 0x8211 #define GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE 0x8212 #define GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE 0x8213 #define GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE 0x8214 #define GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE 0x8215 #define GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE 0x8216 #define GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE 0x8217 #define GL_FRAMEBUFFER_DEFAULT 0x8218 #define GL_FRAMEBUFFER_UNDEFINED 0x8219 #define GL_DEPTH_STENCIL_ATTACHMENT 0x821A #define GL_MAX_RENDERBUFFER_SIZE 0x84E8 #define GL_DEPTH_STENCIL 0x84F9 #define GL_UNSIGNED_INT_24_8 0x84FA #define GL_DEPTH24_STENCIL8 0x88F0 #define GL_TEXTURE_STENCIL_SIZE 0x88F1 #define GL_TEXTURE_RED_TYPE 0x8C10 #define GL_TEXTURE_GREEN_TYPE 0x8C11 #define GL_TEXTURE_BLUE_TYPE 0x8C12 #define GL_TEXTURE_ALPHA_TYPE 0x8C13 #define GL_TEXTURE_DEPTH_TYPE 0x8C16 #define GL_UNSIGNED_NORMALIZED 0x8C17 #define GL_FRAMEBUFFER_BINDING 0x8CA6 #define GL_DRAW_FRAMEBUFFER_BINDING 0x8CA6 #define GL_RENDERBUFFER_BINDING 0x8CA7 #define GL_READ_FRAMEBUFFER 0x8CA8 #define GL_DRAW_FRAMEBUFFER 0x8CA9 #define GL_READ_FRAMEBUFFER_BINDING 0x8CAA #define GL_RENDERBUFFER_SAMPLES 0x8CAB #define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE 0x8CD0 #define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME 0x8CD1 #define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL 0x8CD2 #define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE 0x8CD3 #define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER 0x8CD4 #define GL_FRAMEBUFFER_COMPLETE 0x8CD5 #define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT 0x8CD6 #define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT 0x8CD7 #define GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER 0x8CDB #define GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER 0x8CDC #define GL_FRAMEBUFFER_UNSUPPORTED 0x8CDD #define GL_MAX_COLOR_ATTACHMENTS 0x8CDF #define GL_COLOR_ATTACHMENT0 0x8CE0 #define GL_COLOR_ATTACHMENT1 0x8CE1 #define GL_COLOR_ATTACHMENT2 0x8CE2 #define GL_COLOR_ATTACHMENT3 0x8CE3 #define GL_COLOR_ATTACHMENT4 0x8CE4 #define GL_COLOR_ATTACHMENT5 0x8CE5 #define GL_COLOR_ATTACHMENT6 0x8CE6 #define GL_COLOR_ATTACHMENT7 0x8CE7 #define GL_COLOR_ATTACHMENT8 0x8CE8 #define GL_COLOR_ATTACHMENT9 0x8CE9 #define GL_COLOR_ATTACHMENT10 0x8CEA #define GL_COLOR_ATTACHMENT11 0x8CEB #define GL_COLOR_ATTACHMENT12 0x8CEC #define GL_COLOR_ATTACHMENT13 0x8CED #define GL_COLOR_ATTACHMENT14 0x8CEE #define GL_COLOR_ATTACHMENT15 0x8CEF #define GL_COLOR_ATTACHMENT16 0x8CF0 #define GL_COLOR_ATTACHMENT17 0x8CF1 #define GL_COLOR_ATTACHMENT18 0x8CF2 #define GL_COLOR_ATTACHMENT19 0x8CF3 #define GL_COLOR_ATTACHMENT20 0x8CF4 #define GL_COLOR_ATTACHMENT21 0x8CF5 #define GL_COLOR_ATTACHMENT22 0x8CF6 #define GL_COLOR_ATTACHMENT23 0x8CF7 #define GL_COLOR_ATTACHMENT24 0x8CF8 #define GL_COLOR_ATTACHMENT25 0x8CF9 #define GL_COLOR_ATTACHMENT26 0x8CFA #define GL_COLOR_ATTACHMENT27 0x8CFB #define GL_COLOR_ATTACHMENT28 0x8CFC #define GL_COLOR_ATTACHMENT29 0x8CFD #define GL_COLOR_ATTACHMENT30 0x8CFE #define GL_COLOR_ATTACHMENT31 0x8CFF #define GL_DEPTH_ATTACHMENT 0x8D00 #define GL_STENCIL_ATTACHMENT 0x8D20 #define GL_FRAMEBUFFER 0x8D40 #define GL_RENDERBUFFER 0x8D41 #define GL_RENDERBUFFER_WIDTH 0x8D42 #define GL_RENDERBUFFER_HEIGHT 0x8D43 #define GL_RENDERBUFFER_INTERNAL_FORMAT 0x8D44 #define GL_STENCIL_INDEX1 0x8D46 #define GL_STENCIL_INDEX4 0x8D47 #define GL_STENCIL_INDEX8 0x8D48 #define GL_STENCIL_INDEX16 0x8D49 #define GL_RENDERBUFFER_RED_SIZE 0x8D50 #define GL_RENDERBUFFER_GREEN_SIZE 0x8D51 #define GL_RENDERBUFFER_BLUE_SIZE 0x8D52 #define GL_RENDERBUFFER_ALPHA_SIZE 0x8D53 #define GL_RENDERBUFFER_DEPTH_SIZE 0x8D54 #define GL_RENDERBUFFER_STENCIL_SIZE 0x8D55 #define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE 0x8D56 #define GL_MAX_SAMPLES 0x8D57 #define GL_INDEX 0x8222 #define GL_TEXTURE_LUMINANCE_TYPE 0x8C14 #define GL_TEXTURE_INTENSITY_TYPE 0x8C15 #define GL_FRAMEBUFFER_SRGB 0x8DB9 #define GL_HALF_FLOAT 0x140B #define GL_MAP_READ_BIT 0x0001 #define GL_MAP_WRITE_BIT 0x0002 #define GL_MAP_INVALIDATE_RANGE_BIT 0x0004 #define GL_MAP_INVALIDATE_BUFFER_BIT 0x0008 #define GL_MAP_FLUSH_EXPLICIT_BIT 0x0010 #define GL_MAP_UNSYNCHRONIZED_BIT 0x0020 #define GL_COMPRESSED_RED_RGTC1 0x8DBB #define GL_COMPRESSED_SIGNED_RED_RGTC1 0x8DBC #define GL_COMPRESSED_RG_RGTC2 0x8DBD #define GL_COMPRESSED_SIGNED_RG_RGTC2 0x8DBE #define GL_RG 0x8227 #define GL_RG_INTEGER 0x8228 #define GL_R8 0x8229 #define GL_R16 0x822A #define GL_RG8 0x822B #define GL_RG16 0x822C #define GL_R16F 0x822D #define GL_R32F 0x822E #define GL_RG16F 0x822F #define GL_RG32F 0x8230 #define GL_R8I 0x8231 #define GL_R8UI 0x8232 #define GL_R16I 0x8233 #define GL_R16UI 0x8234 #define GL_R32I 0x8235 #define GL_R32UI 0x8236 #define GL_RG8I 0x8237 #define GL_RG8UI 0x8238 #define GL_RG16I 0x8239 #define GL_RG16UI 0x823A #define GL_RG32I 0x823B #define GL_RG32UI 0x823C #define GL_VERTEX_ARRAY_BINDING 0x85B5 #define GL_CLAMP_VERTEX_COLOR 0x891A #define GL_CLAMP_FRAGMENT_COLOR 0x891B #define GL_ALPHA_INTEGER 0x8D97 typedef void (APIENTRYP PFNGLCOLORMASKIPROC) (GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a); typedef void (APIENTRYP PFNGLGETBOOLEANI_VPROC) (GLenum target, GLuint index, GLboolean *data); typedef void (APIENTRYP PFNGLGETINTEGERI_VPROC) (GLenum target, GLuint index, GLint *data); typedef void (APIENTRYP PFNGLENABLEIPROC) (GLenum target, GLuint index); typedef void (APIENTRYP PFNGLDISABLEIPROC) (GLenum target, GLuint index); typedef GLboolean (APIENTRYP PFNGLISENABLEDIPROC) (GLenum target, GLuint index); typedef void (APIENTRYP PFNGLBEGINTRANSFORMFEEDBACKPROC) (GLenum primitiveMode); typedef void (APIENTRYP PFNGLENDTRANSFORMFEEDBACKPROC) (void); typedef void (APIENTRYP PFNGLBINDBUFFERRANGEPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); typedef void (APIENTRYP PFNGLBINDBUFFERBASEPROC) (GLenum target, GLuint index, GLuint buffer); typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKVARYINGSPROC) (GLuint program, GLsizei count, const GLchar *const*varyings, GLenum bufferMode); typedef void (APIENTRYP PFNGLGETTRANSFORMFEEDBACKVARYINGPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); typedef void (APIENTRYP PFNGLCLAMPCOLORPROC) (GLenum target, GLenum clamp); typedef void (APIENTRYP PFNGLBEGINCONDITIONALRENDERPROC) (GLuint id, GLenum mode); typedef void (APIENTRYP PFNGLENDCONDITIONALRENDERPROC) (void); typedef void (APIENTRYP PFNGLVERTEXATTRIBIPOINTERPROC) (GLuint index, GLint size, GLenum type, GLsizei stride, const void *pointer); typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIIVPROC) (GLuint index, GLenum pname, GLint *params); typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIUIVPROC) (GLuint index, GLenum pname, GLuint *params); typedef void (APIENTRYP PFNGLVERTEXATTRIBI1IPROC) (GLuint index, GLint x); typedef void (APIENTRYP PFNGLVERTEXATTRIBI2IPROC) (GLuint index, GLint x, GLint y); typedef void (APIENTRYP PFNGLVERTEXATTRIBI3IPROC) (GLuint index, GLint x, GLint y, GLint z); typedef void (APIENTRYP PFNGLVERTEXATTRIBI4IPROC) (GLuint index, GLint x, GLint y, GLint z, GLint w); typedef void (APIENTRYP PFNGLVERTEXATTRIBI1UIPROC) (GLuint index, GLuint x); typedef void (APIENTRYP PFNGLVERTEXATTRIBI2UIPROC) (GLuint index, GLuint x, GLuint y); typedef void (APIENTRYP PFNGLVERTEXATTRIBI3UIPROC) (GLuint index, GLuint x, GLuint y, GLuint z); typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UIPROC) (GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); typedef void (APIENTRYP PFNGLVERTEXATTRIBI1IVPROC) (GLuint index, const GLint *v); typedef void (APIENTRYP PFNGLVERTEXATTRIBI2IVPROC) (GLuint index, const GLint *v); typedef void (APIENTRYP PFNGLVERTEXATTRIBI3IVPROC) (GLuint index, const GLint *v); typedef void (APIENTRYP PFNGLVERTEXATTRIBI4IVPROC) (GLuint index, const GLint *v); typedef void (APIENTRYP PFNGLVERTEXATTRIBI1UIVPROC) (GLuint index, const GLuint *v); typedef void (APIENTRYP PFNGLVERTEXATTRIBI2UIVPROC) (GLuint index, const GLuint *v); typedef void (APIENTRYP PFNGLVERTEXATTRIBI3UIVPROC) (GLuint index, const GLuint *v); typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UIVPROC) (GLuint index, const GLuint *v); typedef void (APIENTRYP PFNGLVERTEXATTRIBI4BVPROC) (GLuint index, const GLbyte *v); typedef void (APIENTRYP PFNGLVERTEXATTRIBI4SVPROC) (GLuint index, const GLshort *v); typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UBVPROC) (GLuint index, const GLubyte *v); typedef void (APIENTRYP PFNGLVERTEXATTRIBI4USVPROC) (GLuint index, const GLushort *v); typedef void (APIENTRYP PFNGLGETUNIFORMUIVPROC) (GLuint program, GLint location, GLuint *params); typedef void (APIENTRYP PFNGLBINDFRAGDATALOCATIONPROC) (GLuint program, GLuint color, const GLchar *name); typedef GLint (APIENTRYP PFNGLGETFRAGDATALOCATIONPROC) (GLuint program, const GLchar *name); typedef void (APIENTRYP PFNGLUNIFORM1UIPROC) (GLint location, GLuint v0); typedef void (APIENTRYP PFNGLUNIFORM2UIPROC) (GLint location, GLuint v0, GLuint v1); typedef void (APIENTRYP PFNGLUNIFORM3UIPROC) (GLint location, GLuint v0, GLuint v1, GLuint v2); typedef void (APIENTRYP PFNGLUNIFORM4UIPROC) (GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); typedef void (APIENTRYP PFNGLUNIFORM1UIVPROC) (GLint location, GLsizei count, const GLuint *value); typedef void (APIENTRYP PFNGLUNIFORM2UIVPROC) (GLint location, GLsizei count, const GLuint *value); typedef void (APIENTRYP PFNGLUNIFORM3UIVPROC) (GLint location, GLsizei count, const GLuint *value); typedef void (APIENTRYP PFNGLUNIFORM4UIVPROC) (GLint location, GLsizei count, const GLuint *value); typedef void (APIENTRYP PFNGLTEXPARAMETERIIVPROC) (GLenum target, GLenum pname, const GLint *params); typedef void (APIENTRYP PFNGLTEXPARAMETERIUIVPROC) (GLenum target, GLenum pname, const GLuint *params); typedef void (APIENTRYP PFNGLGETTEXPARAMETERIIVPROC) (GLenum target, GLenum pname, GLint *params); typedef void (APIENTRYP PFNGLGETTEXPARAMETERIUIVPROC) (GLenum target, GLenum pname, GLuint *params); typedef void (APIENTRYP PFNGLCLEARBUFFERIVPROC) (GLenum buffer, GLint drawbuffer, const GLint *value); typedef void (APIENTRYP PFNGLCLEARBUFFERUIVPROC) (GLenum buffer, GLint drawbuffer, const GLuint *value); typedef void (APIENTRYP PFNGLCLEARBUFFERFVPROC) (GLenum buffer, GLint drawbuffer, const GLfloat *value); typedef void (APIENTRYP PFNGLCLEARBUFFERFIPROC) (GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil); typedef const GLubyte *(APIENTRYP PFNGLGETSTRINGIPROC) (GLenum name, GLuint index); typedef GLboolean (APIENTRYP PFNGLISRENDERBUFFERPROC) (GLuint renderbuffer); typedef void (APIENTRYP PFNGLBINDRENDERBUFFERPROC) (GLenum target, GLuint renderbuffer); typedef void (APIENTRYP PFNGLDELETERENDERBUFFERSPROC) (GLsizei n, const GLuint *renderbuffers); typedef void (APIENTRYP PFNGLGENRENDERBUFFERSPROC) (GLsizei n, GLuint *renderbuffers); typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height); typedef void (APIENTRYP PFNGLGETRENDERBUFFERPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); typedef GLboolean (APIENTRYP PFNGLISFRAMEBUFFERPROC) (GLuint framebuffer); typedef void (APIENTRYP PFNGLBINDFRAMEBUFFERPROC) (GLenum target, GLuint framebuffer); typedef void (APIENTRYP PFNGLDELETEFRAMEBUFFERSPROC) (GLsizei n, const GLuint *framebuffers); typedef void (APIENTRYP PFNGLGENFRAMEBUFFERSPROC) (GLsizei n, GLuint *framebuffers); typedef GLenum (APIENTRYP PFNGLCHECKFRAMEBUFFERSTATUSPROC) (GLenum target); typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE1DPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE3DPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); typedef void (APIENTRYP PFNGLFRAMEBUFFERRENDERBUFFERPROC) (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); typedef void (APIENTRYP PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC) (GLenum target, GLenum attachment, GLenum pname, GLint *params); typedef void (APIENTRYP PFNGLGENERATEMIPMAPPROC) (GLenum target); typedef void (APIENTRYP PFNGLBLITFRAMEBUFFERPROC) (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURELAYERPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); typedef void *(APIENTRYP PFNGLMAPBUFFERRANGEPROC) (GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access); typedef void (APIENTRYP PFNGLFLUSHMAPPEDBUFFERRANGEPROC) (GLenum target, GLintptr offset, GLsizeiptr length); typedef void (APIENTRYP PFNGLBINDVERTEXARRAYPROC) (GLuint array); typedef void (APIENTRYP PFNGLDELETEVERTEXARRAYSPROC) (GLsizei n, const GLuint *arrays); typedef void (APIENTRYP PFNGLGENVERTEXARRAYSPROC) (GLsizei n, GLuint *arrays); typedef GLboolean (APIENTRYP PFNGLISVERTEXARRAYPROC) (GLuint array); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glColorMaski (GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a); GLAPI void APIENTRY glGetBooleani_v (GLenum target, GLuint index, GLboolean *data); GLAPI void APIENTRY glGetIntegeri_v (GLenum target, GLuint index, GLint *data); GLAPI void APIENTRY glEnablei (GLenum target, GLuint index); GLAPI void APIENTRY glDisablei (GLenum target, GLuint index); GLAPI GLboolean APIENTRY glIsEnabledi (GLenum target, GLuint index); GLAPI void APIENTRY glBeginTransformFeedback (GLenum primitiveMode); GLAPI void APIENTRY glEndTransformFeedback (void); GLAPI void APIENTRY glBindBufferRange (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); GLAPI void APIENTRY glBindBufferBase (GLenum target, GLuint index, GLuint buffer); GLAPI void APIENTRY glTransformFeedbackVaryings (GLuint program, GLsizei count, const GLchar *const*varyings, GLenum bufferMode); GLAPI void APIENTRY glGetTransformFeedbackVarying (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); GLAPI void APIENTRY glClampColor (GLenum target, GLenum clamp); GLAPI void APIENTRY glBeginConditionalRender (GLuint id, GLenum mode); GLAPI void APIENTRY glEndConditionalRender (void); GLAPI void APIENTRY glVertexAttribIPointer (GLuint index, GLint size, GLenum type, GLsizei stride, const void *pointer); GLAPI void APIENTRY glGetVertexAttribIiv (GLuint index, GLenum pname, GLint *params); GLAPI void APIENTRY glGetVertexAttribIuiv (GLuint index, GLenum pname, GLuint *params); GLAPI void APIENTRY glVertexAttribI1i (GLuint index, GLint x); GLAPI void APIENTRY glVertexAttribI2i (GLuint index, GLint x, GLint y); GLAPI void APIENTRY glVertexAttribI3i (GLuint index, GLint x, GLint y, GLint z); GLAPI void APIENTRY glVertexAttribI4i (GLuint index, GLint x, GLint y, GLint z, GLint w); GLAPI void APIENTRY glVertexAttribI1ui (GLuint index, GLuint x); GLAPI void APIENTRY glVertexAttribI2ui (GLuint index, GLuint x, GLuint y); GLAPI void APIENTRY glVertexAttribI3ui (GLuint index, GLuint x, GLuint y, GLuint z); GLAPI void APIENTRY glVertexAttribI4ui (GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); GLAPI void APIENTRY glVertexAttribI1iv (GLuint index, const GLint *v); GLAPI void APIENTRY glVertexAttribI2iv (GLuint index, const GLint *v); GLAPI void APIENTRY glVertexAttribI3iv (GLuint index, const GLint *v); GLAPI void APIENTRY glVertexAttribI4iv (GLuint index, const GLint *v); GLAPI void APIENTRY glVertexAttribI1uiv (GLuint index, const GLuint *v); GLAPI void APIENTRY glVertexAttribI2uiv (GLuint index, const GLuint *v); GLAPI void APIENTRY glVertexAttribI3uiv (GLuint index, const GLuint *v); GLAPI void APIENTRY glVertexAttribI4uiv (GLuint index, const GLuint *v); GLAPI void APIENTRY glVertexAttribI4bv (GLuint index, const GLbyte *v); GLAPI void APIENTRY glVertexAttribI4sv (GLuint index, const GLshort *v); GLAPI void APIENTRY glVertexAttribI4ubv (GLuint index, const GLubyte *v); GLAPI void APIENTRY glVertexAttribI4usv (GLuint index, const GLushort *v); GLAPI void APIENTRY glGetUniformuiv (GLuint program, GLint location, GLuint *params); GLAPI void APIENTRY glBindFragDataLocation (GLuint program, GLuint color, const GLchar *name); GLAPI GLint APIENTRY glGetFragDataLocation (GLuint program, const GLchar *name); GLAPI void APIENTRY glUniform1ui (GLint location, GLuint v0); GLAPI void APIENTRY glUniform2ui (GLint location, GLuint v0, GLuint v1); GLAPI void APIENTRY glUniform3ui (GLint location, GLuint v0, GLuint v1, GLuint v2); GLAPI void APIENTRY glUniform4ui (GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); GLAPI void APIENTRY glUniform1uiv (GLint location, GLsizei count, const GLuint *value); GLAPI void APIENTRY glUniform2uiv (GLint location, GLsizei count, const GLuint *value); GLAPI void APIENTRY glUniform3uiv (GLint location, GLsizei count, const GLuint *value); GLAPI void APIENTRY glUniform4uiv (GLint location, GLsizei count, const GLuint *value); GLAPI void APIENTRY glTexParameterIiv (GLenum target, GLenum pname, const GLint *params); GLAPI void APIENTRY glTexParameterIuiv (GLenum target, GLenum pname, const GLuint *params); GLAPI void APIENTRY glGetTexParameterIiv (GLenum target, GLenum pname, GLint *params); GLAPI void APIENTRY glGetTexParameterIuiv (GLenum target, GLenum pname, GLuint *params); GLAPI void APIENTRY glClearBufferiv (GLenum buffer, GLint drawbuffer, const GLint *value); GLAPI void APIENTRY glClearBufferuiv (GLenum buffer, GLint drawbuffer, const GLuint *value); GLAPI void APIENTRY glClearBufferfv (GLenum buffer, GLint drawbuffer, const GLfloat *value); GLAPI void APIENTRY glClearBufferfi (GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil); GLAPI const GLubyte *APIENTRY glGetStringi (GLenum name, GLuint index); GLAPI GLboolean APIENTRY glIsRenderbuffer (GLuint renderbuffer); GLAPI void APIENTRY glBindRenderbuffer (GLenum target, GLuint renderbuffer); GLAPI void APIENTRY glDeleteRenderbuffers (GLsizei n, const GLuint *renderbuffers); GLAPI void APIENTRY glGenRenderbuffers (GLsizei n, GLuint *renderbuffers); GLAPI void APIENTRY glRenderbufferStorage (GLenum target, GLenum internalformat, GLsizei width, GLsizei height); GLAPI void APIENTRY glGetRenderbufferParameteriv (GLenum target, GLenum pname, GLint *params); GLAPI GLboolean APIENTRY glIsFramebuffer (GLuint framebuffer); GLAPI void APIENTRY glBindFramebuffer (GLenum target, GLuint framebuffer); GLAPI void APIENTRY glDeleteFramebuffers (GLsizei n, const GLuint *framebuffers); GLAPI void APIENTRY glGenFramebuffers (GLsizei n, GLuint *framebuffers); GLAPI GLenum APIENTRY glCheckFramebufferStatus (GLenum target); GLAPI void APIENTRY glFramebufferTexture1D (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); GLAPI void APIENTRY glFramebufferTexture2D (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); GLAPI void APIENTRY glFramebufferTexture3D (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); GLAPI void APIENTRY glFramebufferRenderbuffer (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); GLAPI void APIENTRY glGetFramebufferAttachmentParameteriv (GLenum target, GLenum attachment, GLenum pname, GLint *params); GLAPI void APIENTRY glGenerateMipmap (GLenum target); GLAPI void APIENTRY glBlitFramebuffer (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); GLAPI void APIENTRY glRenderbufferStorageMultisample (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); GLAPI void APIENTRY glFramebufferTextureLayer (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); GLAPI void *APIENTRY glMapBufferRange (GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access); GLAPI void APIENTRY glFlushMappedBufferRange (GLenum target, GLintptr offset, GLsizeiptr length); GLAPI void APIENTRY glBindVertexArray (GLuint array); GLAPI void APIENTRY glDeleteVertexArrays (GLsizei n, const GLuint *arrays); GLAPI void APIENTRY glGenVertexArrays (GLsizei n, GLuint *arrays); GLAPI GLboolean APIENTRY glIsVertexArray (GLuint array); #endif #endif /* GL_VERSION_3_0 */ #ifndef GL_VERSION_3_1 #define GL_VERSION_3_1 1 #define GL_SAMPLER_2D_RECT 0x8B63 #define GL_SAMPLER_2D_RECT_SHADOW 0x8B64 #define GL_SAMPLER_BUFFER 0x8DC2 #define GL_INT_SAMPLER_2D_RECT 0x8DCD #define GL_INT_SAMPLER_BUFFER 0x8DD0 #define GL_UNSIGNED_INT_SAMPLER_2D_RECT 0x8DD5 #define GL_UNSIGNED_INT_SAMPLER_BUFFER 0x8DD8 #define GL_TEXTURE_BUFFER 0x8C2A #define GL_MAX_TEXTURE_BUFFER_SIZE 0x8C2B #define GL_TEXTURE_BINDING_BUFFER 0x8C2C #define GL_TEXTURE_BUFFER_DATA_STORE_BINDING 0x8C2D #define GL_TEXTURE_RECTANGLE 0x84F5 #define GL_TEXTURE_BINDING_RECTANGLE 0x84F6 #define GL_PROXY_TEXTURE_RECTANGLE 0x84F7 #define GL_MAX_RECTANGLE_TEXTURE_SIZE 0x84F8 #define GL_R8_SNORM 0x8F94 #define GL_RG8_SNORM 0x8F95 #define GL_RGB8_SNORM 0x8F96 #define GL_RGBA8_SNORM 0x8F97 #define GL_R16_SNORM 0x8F98 #define GL_RG16_SNORM 0x8F99 #define GL_RGB16_SNORM 0x8F9A #define GL_RGBA16_SNORM 0x8F9B #define GL_SIGNED_NORMALIZED 0x8F9C #define GL_PRIMITIVE_RESTART 0x8F9D #define GL_PRIMITIVE_RESTART_INDEX 0x8F9E #define GL_COPY_READ_BUFFER 0x8F36 #define GL_COPY_WRITE_BUFFER 0x8F37 #define GL_UNIFORM_BUFFER 0x8A11 #define GL_UNIFORM_BUFFER_BINDING 0x8A28 #define GL_UNIFORM_BUFFER_START 0x8A29 #define GL_UNIFORM_BUFFER_SIZE 0x8A2A #define GL_MAX_VERTEX_UNIFORM_BLOCKS 0x8A2B #define GL_MAX_GEOMETRY_UNIFORM_BLOCKS 0x8A2C #define GL_MAX_FRAGMENT_UNIFORM_BLOCKS 0x8A2D #define GL_MAX_COMBINED_UNIFORM_BLOCKS 0x8A2E #define GL_MAX_UNIFORM_BUFFER_BINDINGS 0x8A2F #define GL_MAX_UNIFORM_BLOCK_SIZE 0x8A30 #define GL_MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS 0x8A31 #define GL_MAX_COMBINED_GEOMETRY_UNIFORM_COMPONENTS 0x8A32 #define GL_MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS 0x8A33 #define GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT 0x8A34 #define GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH 0x8A35 #define GL_ACTIVE_UNIFORM_BLOCKS 0x8A36 #define GL_UNIFORM_TYPE 0x8A37 #define GL_UNIFORM_SIZE 0x8A38 #define GL_UNIFORM_NAME_LENGTH 0x8A39 #define GL_UNIFORM_BLOCK_INDEX 0x8A3A #define GL_UNIFORM_OFFSET 0x8A3B #define GL_UNIFORM_ARRAY_STRIDE 0x8A3C #define GL_UNIFORM_MATRIX_STRIDE 0x8A3D #define GL_UNIFORM_IS_ROW_MAJOR 0x8A3E #define GL_UNIFORM_BLOCK_BINDING 0x8A3F #define GL_UNIFORM_BLOCK_DATA_SIZE 0x8A40 #define GL_UNIFORM_BLOCK_NAME_LENGTH 0x8A41 #define GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS 0x8A42 #define GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES 0x8A43 #define GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER 0x8A44 #define GL_UNIFORM_BLOCK_REFERENCED_BY_GEOMETRY_SHADER 0x8A45 #define GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER 0x8A46 #define GL_INVALID_INDEX 0xFFFFFFFFu typedef void (APIENTRYP PFNGLDRAWARRAYSINSTANCEDPROC) (GLenum mode, GLint first, GLsizei count, GLsizei instancecount); typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount); typedef void (APIENTRYP PFNGLTEXBUFFERPROC) (GLenum target, GLenum internalformat, GLuint buffer); typedef void (APIENTRYP PFNGLPRIMITIVERESTARTINDEXPROC) (GLuint index); typedef void (APIENTRYP PFNGLCOPYBUFFERSUBDATAPROC) (GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); typedef void (APIENTRYP PFNGLGETUNIFORMINDICESPROC) (GLuint program, GLsizei uniformCount, const GLchar *const*uniformNames, GLuint *uniformIndices); typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMSIVPROC) (GLuint program, GLsizei uniformCount, const GLuint *uniformIndices, GLenum pname, GLint *params); typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMNAMEPROC) (GLuint program, GLuint uniformIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformName); typedef GLuint (APIENTRYP PFNGLGETUNIFORMBLOCKINDEXPROC) (GLuint program, const GLchar *uniformBlockName); typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMBLOCKIVPROC) (GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint *params); typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMBLOCKNAMEPROC) (GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformBlockName); typedef void (APIENTRYP PFNGLUNIFORMBLOCKBINDINGPROC) (GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glDrawArraysInstanced (GLenum mode, GLint first, GLsizei count, GLsizei instancecount); GLAPI void APIENTRY glDrawElementsInstanced (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount); GLAPI void APIENTRY glTexBuffer (GLenum target, GLenum internalformat, GLuint buffer); GLAPI void APIENTRY glPrimitiveRestartIndex (GLuint index); GLAPI void APIENTRY glCopyBufferSubData (GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); GLAPI void APIENTRY glGetUniformIndices (GLuint program, GLsizei uniformCount, const GLchar *const*uniformNames, GLuint *uniformIndices); GLAPI void APIENTRY glGetActiveUniformsiv (GLuint program, GLsizei uniformCount, const GLuint *uniformIndices, GLenum pname, GLint *params); GLAPI void APIENTRY glGetActiveUniformName (GLuint program, GLuint uniformIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformName); GLAPI GLuint APIENTRY glGetUniformBlockIndex (GLuint program, const GLchar *uniformBlockName); GLAPI void APIENTRY glGetActiveUniformBlockiv (GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint *params); GLAPI void APIENTRY glGetActiveUniformBlockName (GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformBlockName); GLAPI void APIENTRY glUniformBlockBinding (GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding); #endif #endif /* GL_VERSION_3_1 */ #ifndef GL_VERSION_3_2 #define GL_VERSION_3_2 1 typedef struct __GLsync *GLsync; typedef khronos_uint64_t GLuint64; typedef khronos_int64_t GLint64; #define GL_CONTEXT_CORE_PROFILE_BIT 0x00000001 #define GL_CONTEXT_COMPATIBILITY_PROFILE_BIT 0x00000002 #define GL_LINES_ADJACENCY 0x000A #define GL_LINE_STRIP_ADJACENCY 0x000B #define GL_TRIANGLES_ADJACENCY 0x000C #define GL_TRIANGLE_STRIP_ADJACENCY 0x000D #define GL_PROGRAM_POINT_SIZE 0x8642 #define GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS 0x8C29 #define GL_FRAMEBUFFER_ATTACHMENT_LAYERED 0x8DA7 #define GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS 0x8DA8 #define GL_GEOMETRY_SHADER 0x8DD9 #define GL_GEOMETRY_VERTICES_OUT 0x8916 #define GL_GEOMETRY_INPUT_TYPE 0x8917 #define GL_GEOMETRY_OUTPUT_TYPE 0x8918 #define GL_MAX_GEOMETRY_UNIFORM_COMPONENTS 0x8DDF #define GL_MAX_GEOMETRY_OUTPUT_VERTICES 0x8DE0 #define GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS 0x8DE1 #define GL_MAX_VERTEX_OUTPUT_COMPONENTS 0x9122 #define GL_MAX_GEOMETRY_INPUT_COMPONENTS 0x9123 #define GL_MAX_GEOMETRY_OUTPUT_COMPONENTS 0x9124 #define GL_MAX_FRAGMENT_INPUT_COMPONENTS 0x9125 #define GL_CONTEXT_PROFILE_MASK 0x9126 #define GL_DEPTH_CLAMP 0x864F #define GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION 0x8E4C #define GL_FIRST_VERTEX_CONVENTION 0x8E4D #define GL_LAST_VERTEX_CONVENTION 0x8E4E #define GL_PROVOKING_VERTEX 0x8E4F #define GL_TEXTURE_CUBE_MAP_SEAMLESS 0x884F #define GL_MAX_SERVER_WAIT_TIMEOUT 0x9111 #define GL_OBJECT_TYPE 0x9112 #define GL_SYNC_CONDITION 0x9113 #define GL_SYNC_STATUS 0x9114 #define GL_SYNC_FLAGS 0x9115 #define GL_SYNC_FENCE 0x9116 #define GL_SYNC_GPU_COMMANDS_COMPLETE 0x9117 #define GL_UNSIGNALED 0x9118 #define GL_SIGNALED 0x9119 #define GL_ALREADY_SIGNALED 0x911A #define GL_TIMEOUT_EXPIRED 0x911B #define GL_CONDITION_SATISFIED 0x911C #define GL_WAIT_FAILED 0x911D #define GL_TIMEOUT_IGNORED 0xFFFFFFFFFFFFFFFFull #define GL_SYNC_FLUSH_COMMANDS_BIT 0x00000001 #define GL_SAMPLE_POSITION 0x8E50 #define GL_SAMPLE_MASK 0x8E51 #define GL_SAMPLE_MASK_VALUE 0x8E52 #define GL_MAX_SAMPLE_MASK_WORDS 0x8E59 #define GL_TEXTURE_2D_MULTISAMPLE 0x9100 #define GL_PROXY_TEXTURE_2D_MULTISAMPLE 0x9101 #define GL_TEXTURE_2D_MULTISAMPLE_ARRAY 0x9102 #define GL_PROXY_TEXTURE_2D_MULTISAMPLE_ARRAY 0x9103 #define GL_TEXTURE_BINDING_2D_MULTISAMPLE 0x9104 #define GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY 0x9105 #define GL_TEXTURE_SAMPLES 0x9106 #define GL_TEXTURE_FIXED_SAMPLE_LOCATIONS 0x9107 #define GL_SAMPLER_2D_MULTISAMPLE 0x9108 #define GL_INT_SAMPLER_2D_MULTISAMPLE 0x9109 #define GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE 0x910A #define GL_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910B #define GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910C #define GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910D #define GL_MAX_COLOR_TEXTURE_SAMPLES 0x910E #define GL_MAX_DEPTH_TEXTURE_SAMPLES 0x910F #define GL_MAX_INTEGER_SAMPLES 0x9110 typedef void (APIENTRYP PFNGLDRAWELEMENTSBASEVERTEXPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLint basevertex); typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTSBASEVERTEXPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void *indices, GLint basevertex); typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLint basevertex); typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSBASEVERTEXPROC) (GLenum mode, const GLsizei *count, GLenum type, const void *const*indices, GLsizei drawcount, const GLint *basevertex); typedef void (APIENTRYP PFNGLPROVOKINGVERTEXPROC) (GLenum mode); typedef GLsync (APIENTRYP PFNGLFENCESYNCPROC) (GLenum condition, GLbitfield flags); typedef GLboolean (APIENTRYP PFNGLISSYNCPROC) (GLsync sync); typedef void (APIENTRYP PFNGLDELETESYNCPROC) (GLsync sync); typedef GLenum (APIENTRYP PFNGLCLIENTWAITSYNCPROC) (GLsync sync, GLbitfield flags, GLuint64 timeout); typedef void (APIENTRYP PFNGLWAITSYNCPROC) (GLsync sync, GLbitfield flags, GLuint64 timeout); typedef void (APIENTRYP PFNGLGETINTEGER64VPROC) (GLenum pname, GLint64 *data); typedef void (APIENTRYP PFNGLGETSYNCIVPROC) (GLsync sync, GLenum pname, GLsizei count, GLsizei *length, GLint *values); typedef void (APIENTRYP PFNGLGETINTEGER64I_VPROC) (GLenum target, GLuint index, GLint64 *data); typedef void (APIENTRYP PFNGLGETBUFFERPARAMETERI64VPROC) (GLenum target, GLenum pname, GLint64 *params); typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level); typedef void (APIENTRYP PFNGLTEXIMAGE2DMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); typedef void (APIENTRYP PFNGLTEXIMAGE3DMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); typedef void (APIENTRYP PFNGLGETMULTISAMPLEFVPROC) (GLenum pname, GLuint index, GLfloat *val); typedef void (APIENTRYP PFNGLSAMPLEMASKIPROC) (GLuint maskNumber, GLbitfield mask); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glDrawElementsBaseVertex (GLenum mode, GLsizei count, GLenum type, const void *indices, GLint basevertex); GLAPI void APIENTRY glDrawRangeElementsBaseVertex (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void *indices, GLint basevertex); GLAPI void APIENTRY glDrawElementsInstancedBaseVertex (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLint basevertex); GLAPI void APIENTRY glMultiDrawElementsBaseVertex (GLenum mode, const GLsizei *count, GLenum type, const void *const*indices, GLsizei drawcount, const GLint *basevertex); GLAPI void APIENTRY glProvokingVertex (GLenum mode); GLAPI GLsync APIENTRY glFenceSync (GLenum condition, GLbitfield flags); GLAPI GLboolean APIENTRY glIsSync (GLsync sync); GLAPI void APIENTRY glDeleteSync (GLsync sync); GLAPI GLenum APIENTRY glClientWaitSync (GLsync sync, GLbitfield flags, GLuint64 timeout); GLAPI void APIENTRY glWaitSync (GLsync sync, GLbitfield flags, GLuint64 timeout); GLAPI void APIENTRY glGetInteger64v (GLenum pname, GLint64 *data); GLAPI void APIENTRY glGetSynciv (GLsync sync, GLenum pname, GLsizei count, GLsizei *length, GLint *values); GLAPI void APIENTRY glGetInteger64i_v (GLenum target, GLuint index, GLint64 *data); GLAPI void APIENTRY glGetBufferParameteri64v (GLenum target, GLenum pname, GLint64 *params); GLAPI void APIENTRY glFramebufferTexture (GLenum target, GLenum attachment, GLuint texture, GLint level); GLAPI void APIENTRY glTexImage2DMultisample (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); GLAPI void APIENTRY glTexImage3DMultisample (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); GLAPI void APIENTRY glGetMultisamplefv (GLenum pname, GLuint index, GLfloat *val); GLAPI void APIENTRY glSampleMaski (GLuint maskNumber, GLbitfield mask); #endif #endif /* GL_VERSION_3_2 */ #ifndef GL_VERSION_3_3 #define GL_VERSION_3_3 1 #define GL_VERTEX_ATTRIB_ARRAY_DIVISOR 0x88FE #define GL_SRC1_COLOR 0x88F9 #define GL_ONE_MINUS_SRC1_COLOR 0x88FA #define GL_ONE_MINUS_SRC1_ALPHA 0x88FB #define GL_MAX_DUAL_SOURCE_DRAW_BUFFERS 0x88FC #define GL_ANY_SAMPLES_PASSED 0x8C2F #define GL_SAMPLER_BINDING 0x8919 #define GL_RGB10_A2UI 0x906F #define GL_TEXTURE_SWIZZLE_R 0x8E42 #define GL_TEXTURE_SWIZZLE_G 0x8E43 #define GL_TEXTURE_SWIZZLE_B 0x8E44 #define GL_TEXTURE_SWIZZLE_A 0x8E45 #define GL_TEXTURE_SWIZZLE_RGBA 0x8E46 #define GL_TIME_ELAPSED 0x88BF #define GL_TIMESTAMP 0x8E28 #define GL_INT_2_10_10_10_REV 0x8D9F typedef void (APIENTRYP PFNGLBINDFRAGDATALOCATIONINDEXEDPROC) (GLuint program, GLuint colorNumber, GLuint index, const GLchar *name); typedef GLint (APIENTRYP PFNGLGETFRAGDATAINDEXPROC) (GLuint program, const GLchar *name); typedef void (APIENTRYP PFNGLGENSAMPLERSPROC) (GLsizei count, GLuint *samplers); typedef void (APIENTRYP PFNGLDELETESAMPLERSPROC) (GLsizei count, const GLuint *samplers); typedef GLboolean (APIENTRYP PFNGLISSAMPLERPROC) (GLuint sampler); typedef void (APIENTRYP PFNGLBINDSAMPLERPROC) (GLuint unit, GLuint sampler); typedef void (APIENTRYP PFNGLSAMPLERPARAMETERIPROC) (GLuint sampler, GLenum pname, GLint param); typedef void (APIENTRYP PFNGLSAMPLERPARAMETERIVPROC) (GLuint sampler, GLenum pname, const GLint *param); typedef void (APIENTRYP PFNGLSAMPLERPARAMETERFPROC) (GLuint sampler, GLenum pname, GLfloat param); typedef void (APIENTRYP PFNGLSAMPLERPARAMETERFVPROC) (GLuint sampler, GLenum pname, const GLfloat *param); typedef void (APIENTRYP PFNGLSAMPLERPARAMETERIIVPROC) (GLuint sampler, GLenum pname, const GLint *param); typedef void (APIENTRYP PFNGLSAMPLERPARAMETERIUIVPROC) (GLuint sampler, GLenum pname, const GLuint *param); typedef void (APIENTRYP PFNGLGETSAMPLERPARAMETERIVPROC) (GLuint sampler, GLenum pname, GLint *params); typedef void (APIENTRYP PFNGLGETSAMPLERPARAMETERIIVPROC) (GLuint sampler, GLenum pname, GLint *params); typedef void (APIENTRYP PFNGLGETSAMPLERPARAMETERFVPROC) (GLuint sampler, GLenum pname, GLfloat *params); typedef void (APIENTRYP PFNGLGETSAMPLERPARAMETERIUIVPROC) (GLuint sampler, GLenum pname, GLuint *params); typedef void (APIENTRYP PFNGLQUERYCOUNTERPROC) (GLuint id, GLenum target); typedef void (APIENTRYP PFNGLGETQUERYOBJECTI64VPROC) (GLuint id, GLenum pname, GLint64 *params); typedef void (APIENTRYP PFNGLGETQUERYOBJECTUI64VPROC) (GLuint id, GLenum pname, GLuint64 *params); typedef void (APIENTRYP PFNGLVERTEXATTRIBDIVISORPROC) (GLuint index, GLuint divisor); typedef void (APIENTRYP PFNGLVERTEXATTRIBP1UIPROC) (GLuint index, GLenum type, GLboolean normalized, GLuint value); typedef void (APIENTRYP PFNGLVERTEXATTRIBP1UIVPROC) (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); typedef void (APIENTRYP PFNGLVERTEXATTRIBP2UIPROC) (GLuint index, GLenum type, GLboolean normalized, GLuint value); typedef void (APIENTRYP PFNGLVERTEXATTRIBP2UIVPROC) (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); typedef void (APIENTRYP PFNGLVERTEXATTRIBP3UIPROC) (GLuint index, GLenum type, GLboolean normalized, GLuint value); typedef void (APIENTRYP PFNGLVERTEXATTRIBP3UIVPROC) (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); typedef void (APIENTRYP PFNGLVERTEXATTRIBP4UIPROC) (GLuint index, GLenum type, GLboolean normalized, GLuint value); typedef void (APIENTRYP PFNGLVERTEXATTRIBP4UIVPROC) (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); typedef void (APIENTRYP PFNGLVERTEXP2UIPROC) (GLenum type, GLuint value); typedef void (APIENTRYP PFNGLVERTEXP2UIVPROC) (GLenum type, const GLuint *value); typedef void (APIENTRYP PFNGLVERTEXP3UIPROC) (GLenum type, GLuint value); typedef void (APIENTRYP PFNGLVERTEXP3UIVPROC) (GLenum type, const GLuint *value); typedef void (APIENTRYP PFNGLVERTEXP4UIPROC) (GLenum type, GLuint value); typedef void (APIENTRYP PFNGLVERTEXP4UIVPROC) (GLenum type, const GLuint *value); typedef void (APIENTRYP PFNGLTEXCOORDP1UIPROC) (GLenum type, GLuint coords); typedef void (APIENTRYP PFNGLTEXCOORDP1UIVPROC) (GLenum type, const GLuint *coords); typedef void (APIENTRYP PFNGLTEXCOORDP2UIPROC) (GLenum type, GLuint coords); typedef void (APIENTRYP PFNGLTEXCOORDP2UIVPROC) (GLenum type, const GLuint *coords); typedef void (APIENTRYP PFNGLTEXCOORDP3UIPROC) (GLenum type, GLuint coords); typedef void (APIENTRYP PFNGLTEXCOORDP3UIVPROC) (GLenum type, const GLuint *coords); typedef void (APIENTRYP PFNGLTEXCOORDP4UIPROC) (GLenum type, GLuint coords); typedef void (APIENTRYP PFNGLTEXCOORDP4UIVPROC) (GLenum type, const GLuint *coords); typedef void (APIENTRYP PFNGLMULTITEXCOORDP1UIPROC) (GLenum texture, GLenum type, GLuint coords); typedef void (APIENTRYP PFNGLMULTITEXCOORDP1UIVPROC) (GLenum texture, GLenum type, const GLuint *coords); typedef void (APIENTRYP PFNGLMULTITEXCOORDP2UIPROC) (GLenum texture, GLenum type, GLuint coords); typedef void (APIENTRYP PFNGLMULTITEXCOORDP2UIVPROC) (GLenum texture, GLenum type, const GLuint *coords); typedef void (APIENTRYP PFNGLMULTITEXCOORDP3UIPROC) (GLenum texture, GLenum type, GLuint coords); typedef void (APIENTRYP PFNGLMULTITEXCOORDP3UIVPROC) (GLenum texture, GLenum type, const GLuint *coords); typedef void (APIENTRYP PFNGLMULTITEXCOORDP4UIPROC) (GLenum texture, GLenum type, GLuint coords); typedef void (APIENTRYP PFNGLMULTITEXCOORDP4UIVPROC) (GLenum texture, GLenum type, const GLuint *coords); typedef void (APIENTRYP PFNGLNORMALP3UIPROC) (GLenum type, GLuint coords); typedef void (APIENTRYP PFNGLNORMALP3UIVPROC) (GLenum type, const GLuint *coords); typedef void (APIENTRYP PFNGLCOLORP3UIPROC) (GLenum type, GLuint color); typedef void (APIENTRYP PFNGLCOLORP3UIVPROC) (GLenum type, const GLuint *color); typedef void (APIENTRYP PFNGLCOLORP4UIPROC) (GLenum type, GLuint color); typedef void (APIENTRYP PFNGLCOLORP4UIVPROC) (GLenum type, const GLuint *color); typedef void (APIENTRYP PFNGLSECONDARYCOLORP3UIPROC) (GLenum type, GLuint color); typedef void (APIENTRYP PFNGLSECONDARYCOLORP3UIVPROC) (GLenum type, const GLuint *color); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glBindFragDataLocationIndexed (GLuint program, GLuint colorNumber, GLuint index, const GLchar *name); GLAPI GLint APIENTRY glGetFragDataIndex (GLuint program, const GLchar *name); GLAPI void APIENTRY glGenSamplers (GLsizei count, GLuint *samplers); GLAPI void APIENTRY glDeleteSamplers (GLsizei count, const GLuint *samplers); GLAPI GLboolean APIENTRY glIsSampler (GLuint sampler); GLAPI void APIENTRY glBindSampler (GLuint unit, GLuint sampler); GLAPI void APIENTRY glSamplerParameteri (GLuint sampler, GLenum pname, GLint param); GLAPI void APIENTRY glSamplerParameteriv (GLuint sampler, GLenum pname, const GLint *param); GLAPI void APIENTRY glSamplerParameterf (GLuint sampler, GLenum pname, GLfloat param); GLAPI void APIENTRY glSamplerParameterfv (GLuint sampler, GLenum pname, const GLfloat *param); GLAPI void APIENTRY glSamplerParameterIiv (GLuint sampler, GLenum pname, const GLint *param); GLAPI void APIENTRY glSamplerParameterIuiv (GLuint sampler, GLenum pname, const GLuint *param); GLAPI void APIENTRY glGetSamplerParameteriv (GLuint sampler, GLenum pname, GLint *params); GLAPI void APIENTRY glGetSamplerParameterIiv (GLuint sampler, GLenum pname, GLint *params); GLAPI void APIENTRY glGetSamplerParameterfv (GLuint sampler, GLenum pname, GLfloat *params); GLAPI void APIENTRY glGetSamplerParameterIuiv (GLuint sampler, GLenum pname, GLuint *params); GLAPI void APIENTRY glQueryCounter (GLuint id, GLenum target); GLAPI void APIENTRY glGetQueryObjecti64v (GLuint id, GLenum pname, GLint64 *params); GLAPI void APIENTRY glGetQueryObjectui64v (GLuint id, GLenum pname, GLuint64 *params); GLAPI void APIENTRY glVertexAttribDivisor (GLuint index, GLuint divisor); GLAPI void APIENTRY glVertexAttribP1ui (GLuint index, GLenum type, GLboolean normalized, GLuint value); GLAPI void APIENTRY glVertexAttribP1uiv (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); GLAPI void APIENTRY glVertexAttribP2ui (GLuint index, GLenum type, GLboolean normalized, GLuint value); GLAPI void APIENTRY glVertexAttribP2uiv (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); GLAPI void APIENTRY glVertexAttribP3ui (GLuint index, GLenum type, GLboolean normalized, GLuint value); GLAPI void APIENTRY glVertexAttribP3uiv (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); GLAPI void APIENTRY glVertexAttribP4ui (GLuint index, GLenum type, GLboolean normalized, GLuint value); GLAPI void APIENTRY glVertexAttribP4uiv (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); GLAPI void APIENTRY glVertexP2ui (GLenum type, GLuint value); GLAPI void APIENTRY glVertexP2uiv (GLenum type, const GLuint *value); GLAPI void APIENTRY glVertexP3ui (GLenum type, GLuint value); GLAPI void APIENTRY glVertexP3uiv (GLenum type, const GLuint *value); GLAPI void APIENTRY glVertexP4ui (GLenum type, GLuint value); GLAPI void APIENTRY glVertexP4uiv (GLenum type, const GLuint *value); GLAPI void APIENTRY glTexCoordP1ui (GLenum type, GLuint coords); GLAPI void APIENTRY glTexCoordP1uiv (GLenum type, const GLuint *coords); GLAPI void APIENTRY glTexCoordP2ui (GLenum type, GLuint coords); GLAPI void APIENTRY glTexCoordP2uiv (GLenum type, const GLuint *coords); GLAPI void APIENTRY glTexCoordP3ui (GLenum type, GLuint coords); GLAPI void APIENTRY glTexCoordP3uiv (GLenum type, const GLuint *coords); GLAPI void APIENTRY glTexCoordP4ui (GLenum type, GLuint coords); GLAPI void APIENTRY glTexCoordP4uiv (GLenum type, const GLuint *coords); GLAPI void APIENTRY glMultiTexCoordP1ui (GLenum texture, GLenum type, GLuint coords); GLAPI void APIENTRY glMultiTexCoordP1uiv (GLenum texture, GLenum type, const GLuint *coords); GLAPI void APIENTRY glMultiTexCoordP2ui (GLenum texture, GLenum type, GLuint coords); GLAPI void APIENTRY glMultiTexCoordP2uiv (GLenum texture, GLenum type, const GLuint *coords); GLAPI void APIENTRY glMultiTexCoordP3ui (GLenum texture, GLenum type, GLuint coords); GLAPI void APIENTRY glMultiTexCoordP3uiv (GLenum texture, GLenum type, const GLuint *coords); GLAPI void APIENTRY glMultiTexCoordP4ui (GLenum texture, GLenum type, GLuint coords); GLAPI void APIENTRY glMultiTexCoordP4uiv (GLenum texture, GLenum type, const GLuint *coords); GLAPI void APIENTRY glNormalP3ui (GLenum type, GLuint coords); GLAPI void APIENTRY glNormalP3uiv (GLenum type, const GLuint *coords); GLAPI void APIENTRY glColorP3ui (GLenum type, GLuint color); GLAPI void APIENTRY glColorP3uiv (GLenum type, const GLuint *color); GLAPI void APIENTRY glColorP4ui (GLenum type, GLuint color); GLAPI void APIENTRY glColorP4uiv (GLenum type, const GLuint *color); GLAPI void APIENTRY glSecondaryColorP3ui (GLenum type, GLuint color); GLAPI void APIENTRY glSecondaryColorP3uiv (GLenum type, const GLuint *color); #endif #endif /* GL_VERSION_3_3 */ #ifndef GL_VERSION_4_0 #define GL_VERSION_4_0 1 #define GL_SAMPLE_SHADING 0x8C36 #define GL_MIN_SAMPLE_SHADING_VALUE 0x8C37 #define GL_MIN_PROGRAM_TEXTURE_GATHER_OFFSET 0x8E5E #define GL_MAX_PROGRAM_TEXTURE_GATHER_OFFSET 0x8E5F #define GL_TEXTURE_CUBE_MAP_ARRAY 0x9009 #define GL_TEXTURE_BINDING_CUBE_MAP_ARRAY 0x900A #define GL_PROXY_TEXTURE_CUBE_MAP_ARRAY 0x900B #define GL_SAMPLER_CUBE_MAP_ARRAY 0x900C #define GL_SAMPLER_CUBE_MAP_ARRAY_SHADOW 0x900D #define GL_INT_SAMPLER_CUBE_MAP_ARRAY 0x900E #define GL_UNSIGNED_INT_SAMPLER_CUBE_MAP_ARRAY 0x900F #define GL_DRAW_INDIRECT_BUFFER 0x8F3F #define GL_DRAW_INDIRECT_BUFFER_BINDING 0x8F43 #define GL_GEOMETRY_SHADER_INVOCATIONS 0x887F #define GL_MAX_GEOMETRY_SHADER_INVOCATIONS 0x8E5A #define GL_MIN_FRAGMENT_INTERPOLATION_OFFSET 0x8E5B #define GL_MAX_FRAGMENT_INTERPOLATION_OFFSET 0x8E5C #define GL_FRAGMENT_INTERPOLATION_OFFSET_BITS 0x8E5D #define GL_MAX_VERTEX_STREAMS 0x8E71 #define GL_DOUBLE_VEC2 0x8FFC #define GL_DOUBLE_VEC3 0x8FFD #define GL_DOUBLE_VEC4 0x8FFE #define GL_DOUBLE_MAT2 0x8F46 #define GL_DOUBLE_MAT3 0x8F47 #define GL_DOUBLE_MAT4 0x8F48 #define GL_DOUBLE_MAT2x3 0x8F49 #define GL_DOUBLE_MAT2x4 0x8F4A #define GL_DOUBLE_MAT3x2 0x8F4B #define GL_DOUBLE_MAT3x4 0x8F4C #define GL_DOUBLE_MAT4x2 0x8F4D #define GL_DOUBLE_MAT4x3 0x8F4E #define GL_ACTIVE_SUBROUTINES 0x8DE5 #define GL_ACTIVE_SUBROUTINE_UNIFORMS 0x8DE6 #define GL_ACTIVE_SUBROUTINE_UNIFORM_LOCATIONS 0x8E47 #define GL_ACTIVE_SUBROUTINE_MAX_LENGTH 0x8E48 #define GL_ACTIVE_SUBROUTINE_UNIFORM_MAX_LENGTH 0x8E49 #define GL_MAX_SUBROUTINES 0x8DE7 #define GL_MAX_SUBROUTINE_UNIFORM_LOCATIONS 0x8DE8 #define GL_NUM_COMPATIBLE_SUBROUTINES 0x8E4A #define GL_COMPATIBLE_SUBROUTINES 0x8E4B #define GL_PATCHES 0x000E #define GL_PATCH_VERTICES 0x8E72 #define GL_PATCH_DEFAULT_INNER_LEVEL 0x8E73 #define GL_PATCH_DEFAULT_OUTER_LEVEL 0x8E74 #define GL_TESS_CONTROL_OUTPUT_VERTICES 0x8E75 #define GL_TESS_GEN_MODE 0x8E76 #define GL_TESS_GEN_SPACING 0x8E77 #define GL_TESS_GEN_VERTEX_ORDER 0x8E78 #define GL_TESS_GEN_POINT_MODE 0x8E79 #define GL_ISOLINES 0x8E7A #define GL_FRACTIONAL_ODD 0x8E7B #define GL_FRACTIONAL_EVEN 0x8E7C #define GL_MAX_PATCH_VERTICES 0x8E7D #define GL_MAX_TESS_GEN_LEVEL 0x8E7E #define GL_MAX_TESS_CONTROL_UNIFORM_COMPONENTS 0x8E7F #define GL_MAX_TESS_EVALUATION_UNIFORM_COMPONENTS 0x8E80 #define GL_MAX_TESS_CONTROL_TEXTURE_IMAGE_UNITS 0x8E81 #define GL_MAX_TESS_EVALUATION_TEXTURE_IMAGE_UNITS 0x8E82 #define GL_MAX_TESS_CONTROL_OUTPUT_COMPONENTS 0x8E83 #define GL_MAX_TESS_PATCH_COMPONENTS 0x8E84 #define GL_MAX_TESS_CONTROL_TOTAL_OUTPUT_COMPONENTS 0x8E85 #define GL_MAX_TESS_EVALUATION_OUTPUT_COMPONENTS 0x8E86 #define GL_MAX_TESS_CONTROL_UNIFORM_BLOCKS 0x8E89 #define GL_MAX_TESS_EVALUATION_UNIFORM_BLOCKS 0x8E8A #define GL_MAX_TESS_CONTROL_INPUT_COMPONENTS 0x886C #define GL_MAX_TESS_EVALUATION_INPUT_COMPONENTS 0x886D #define GL_MAX_COMBINED_TESS_CONTROL_UNIFORM_COMPONENTS 0x8E1E #define GL_MAX_COMBINED_TESS_EVALUATION_UNIFORM_COMPONENTS 0x8E1F #define GL_UNIFORM_BLOCK_REFERENCED_BY_TESS_CONTROL_SHADER 0x84F0 #define GL_UNIFORM_BLOCK_REFERENCED_BY_TESS_EVALUATION_SHADER 0x84F1 #define GL_TESS_EVALUATION_SHADER 0x8E87 #define GL_TESS_CONTROL_SHADER 0x8E88 #define GL_TRANSFORM_FEEDBACK 0x8E22 #define GL_TRANSFORM_FEEDBACK_BUFFER_PAUSED 0x8E23 #define GL_TRANSFORM_FEEDBACK_BUFFER_ACTIVE 0x8E24 #define GL_TRANSFORM_FEEDBACK_BINDING 0x8E25 #define GL_MAX_TRANSFORM_FEEDBACK_BUFFERS 0x8E70 typedef void (APIENTRYP PFNGLMINSAMPLESHADINGPROC) (GLfloat value); typedef void (APIENTRYP PFNGLBLENDEQUATIONIPROC) (GLuint buf, GLenum mode); typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEIPROC) (GLuint buf, GLenum modeRGB, GLenum modeAlpha); typedef void (APIENTRYP PFNGLBLENDFUNCIPROC) (GLuint buf, GLenum src, GLenum dst); typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEIPROC) (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); typedef void (APIENTRYP PFNGLDRAWARRAYSINDIRECTPROC) (GLenum mode, const void *indirect); typedef void (APIENTRYP PFNGLDRAWELEMENTSINDIRECTPROC) (GLenum mode, GLenum type, const void *indirect); typedef void (APIENTRYP PFNGLUNIFORM1DPROC) (GLint location, GLdouble x); typedef void (APIENTRYP PFNGLUNIFORM2DPROC) (GLint location, GLdouble x, GLdouble y); typedef void (APIENTRYP PFNGLUNIFORM3DPROC) (GLint location, GLdouble x, GLdouble y, GLdouble z); typedef void (APIENTRYP PFNGLUNIFORM4DPROC) (GLint location, GLdouble x, GLdouble y, GLdouble z, GLdouble w); typedef void (APIENTRYP PFNGLUNIFORM1DVPROC) (GLint location, GLsizei count, const GLdouble *value); typedef void (APIENTRYP PFNGLUNIFORM2DVPROC) (GLint location, GLsizei count, const GLdouble *value); typedef void (APIENTRYP PFNGLUNIFORM3DVPROC) (GLint location, GLsizei count, const GLdouble *value); typedef void (APIENTRYP PFNGLUNIFORM4DVPROC) (GLint location, GLsizei count, const GLdouble *value); typedef void (APIENTRYP PFNGLUNIFORMMATRIX2DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); typedef void (APIENTRYP PFNGLUNIFORMMATRIX3DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); typedef void (APIENTRYP PFNGLUNIFORMMATRIX4DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); typedef void (APIENTRYP PFNGLUNIFORMMATRIX2X3DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); typedef void (APIENTRYP PFNGLUNIFORMMATRIX2X4DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); typedef void (APIENTRYP PFNGLUNIFORMMATRIX3X2DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); typedef void (APIENTRYP PFNGLUNIFORMMATRIX3X4DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); typedef void (APIENTRYP PFNGLUNIFORMMATRIX4X2DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); typedef void (APIENTRYP PFNGLUNIFORMMATRIX4X3DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); typedef void (APIENTRYP PFNGLGETUNIFORMDVPROC) (GLuint program, GLint location, GLdouble *params); typedef GLint (APIENTRYP PFNGLGETSUBROUTINEUNIFORMLOCATIONPROC) (GLuint program, GLenum shadertype, const GLchar *name); typedef GLuint (APIENTRYP PFNGLGETSUBROUTINEINDEXPROC) (GLuint program, GLenum shadertype, const GLchar *name); typedef void (APIENTRYP PFNGLGETACTIVESUBROUTINEUNIFORMIVPROC) (GLuint program, GLenum shadertype, GLuint index, GLenum pname, GLint *values); typedef void (APIENTRYP PFNGLGETACTIVESUBROUTINEUNIFORMNAMEPROC) (GLuint program, GLenum shadertype, GLuint index, GLsizei bufSize, GLsizei *length, GLchar *name); typedef void (APIENTRYP PFNGLGETACTIVESUBROUTINENAMEPROC) (GLuint program, GLenum shadertype, GLuint index, GLsizei bufSize, GLsizei *length, GLchar *name); typedef void (APIENTRYP PFNGLUNIFORMSUBROUTINESUIVPROC) (GLenum shadertype, GLsizei count, const GLuint *indices); typedef void (APIENTRYP PFNGLGETUNIFORMSUBROUTINEUIVPROC) (GLenum shadertype, GLint location, GLuint *params); typedef void (APIENTRYP PFNGLGETPROGRAMSTAGEIVPROC) (GLuint program, GLenum shadertype, GLenum pname, GLint *values); typedef void (APIENTRYP PFNGLPATCHPARAMETERIPROC) (GLenum pname, GLint value); typedef void (APIENTRYP PFNGLPATCHPARAMETERFVPROC) (GLenum pname, const GLfloat *values); typedef void (APIENTRYP PFNGLBINDTRANSFORMFEEDBACKPROC) (GLenum target, GLuint id); typedef void (APIENTRYP PFNGLDELETETRANSFORMFEEDBACKSPROC) (GLsizei n, const GLuint *ids); typedef void (APIENTRYP PFNGLGENTRANSFORMFEEDBACKSPROC) (GLsizei n, GLuint *ids); typedef GLboolean (APIENTRYP PFNGLISTRANSFORMFEEDBACKPROC) (GLuint id); typedef void (APIENTRYP PFNGLPAUSETRANSFORMFEEDBACKPROC) (void); typedef void (APIENTRYP PFNGLRESUMETRANSFORMFEEDBACKPROC) (void); typedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKPROC) (GLenum mode, GLuint id); typedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKSTREAMPROC) (GLenum mode, GLuint id, GLuint stream); typedef void (APIENTRYP PFNGLBEGINQUERYINDEXEDPROC) (GLenum target, GLuint index, GLuint id); typedef void (APIENTRYP PFNGLENDQUERYINDEXEDPROC) (GLenum target, GLuint index); typedef void (APIENTRYP PFNGLGETQUERYINDEXEDIVPROC) (GLenum target, GLuint index, GLenum pname, GLint *params); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glMinSampleShading (GLfloat value); GLAPI void APIENTRY glBlendEquationi (GLuint buf, GLenum mode); GLAPI void APIENTRY glBlendEquationSeparatei (GLuint buf, GLenum modeRGB, GLenum modeAlpha); GLAPI void APIENTRY glBlendFunci (GLuint buf, GLenum src, GLenum dst); GLAPI void APIENTRY glBlendFuncSeparatei (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); GLAPI void APIENTRY glDrawArraysIndirect (GLenum mode, const void *indirect); GLAPI void APIENTRY glDrawElementsIndirect (GLenum mode, GLenum type, const void *indirect); GLAPI void APIENTRY glUniform1d (GLint location, GLdouble x); GLAPI void APIENTRY glUniform2d (GLint location, GLdouble x, GLdouble y); GLAPI void APIENTRY glUniform3d (GLint location, GLdouble x, GLdouble y, GLdouble z); GLAPI void APIENTRY glUniform4d (GLint location, GLdouble x, GLdouble y, GLdouble z, GLdouble w); GLAPI void APIENTRY glUniform1dv (GLint location, GLsizei count, const GLdouble *value); GLAPI void APIENTRY glUniform2dv (GLint location, GLsizei count, const GLdouble *value); GLAPI void APIENTRY glUniform3dv (GLint location, GLsizei count, const GLdouble *value); GLAPI void APIENTRY glUniform4dv (GLint location, GLsizei count, const GLdouble *value); GLAPI void APIENTRY glUniformMatrix2dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); GLAPI void APIENTRY glUniformMatrix3dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); GLAPI void APIENTRY glUniformMatrix4dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); GLAPI void APIENTRY glUniformMatrix2x3dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); GLAPI void APIENTRY glUniformMatrix2x4dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); GLAPI void APIENTRY glUniformMatrix3x2dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); GLAPI void APIENTRY glUniformMatrix3x4dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); GLAPI void APIENTRY glUniformMatrix4x2dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); GLAPI void APIENTRY glUniformMatrix4x3dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); GLAPI void APIENTRY glGetUniformdv (GLuint program, GLint location, GLdouble *params); GLAPI GLint APIENTRY glGetSubroutineUniformLocation (GLuint program, GLenum shadertype, const GLchar *name); GLAPI GLuint APIENTRY glGetSubroutineIndex (GLuint program, GLenum shadertype, const GLchar *name); GLAPI void APIENTRY glGetActiveSubroutineUniformiv (GLuint program, GLenum shadertype, GLuint index, GLenum pname, GLint *values); GLAPI void APIENTRY glGetActiveSubroutineUniformName (GLuint program, GLenum shadertype, GLuint index, GLsizei bufSize, GLsizei *length, GLchar *name); GLAPI void APIENTRY glGetActiveSubroutineName (GLuint program, GLenum shadertype, GLuint index, GLsizei bufSize, GLsizei *length, GLchar *name); GLAPI void APIENTRY glUniformSubroutinesuiv (GLenum shadertype, GLsizei count, const GLuint *indices); GLAPI void APIENTRY glGetUniformSubroutineuiv (GLenum shadertype, GLint location, GLuint *params); GLAPI void APIENTRY glGetProgramStageiv (GLuint program, GLenum shadertype, GLenum pname, GLint *values); GLAPI void APIENTRY glPatchParameteri (GLenum pname, GLint value); GLAPI void APIENTRY glPatchParameterfv (GLenum pname, const GLfloat *values); GLAPI void APIENTRY glBindTransformFeedback (GLenum target, GLuint id); GLAPI void APIENTRY glDeleteTransformFeedbacks (GLsizei n, const GLuint *ids); GLAPI void APIENTRY glGenTransformFeedbacks (GLsizei n, GLuint *ids); GLAPI GLboolean APIENTRY glIsTransformFeedback (GLuint id); GLAPI void APIENTRY glPauseTransformFeedback (void); GLAPI void APIENTRY glResumeTransformFeedback (void); GLAPI void APIENTRY glDrawTransformFeedback (GLenum mode, GLuint id); GLAPI void APIENTRY glDrawTransformFeedbackStream (GLenum mode, GLuint id, GLuint stream); GLAPI void APIENTRY glBeginQueryIndexed (GLenum target, GLuint index, GLuint id); GLAPI void APIENTRY glEndQueryIndexed (GLenum target, GLuint index); GLAPI void APIENTRY glGetQueryIndexediv (GLenum target, GLuint index, GLenum pname, GLint *params); #endif #endif /* GL_VERSION_4_0 */ #ifndef GL_VERSION_4_1 #define GL_VERSION_4_1 1 #define GL_FIXED 0x140C #define GL_IMPLEMENTATION_COLOR_READ_TYPE 0x8B9A #define GL_IMPLEMENTATION_COLOR_READ_FORMAT 0x8B9B #define GL_LOW_FLOAT 0x8DF0 #define GL_MEDIUM_FLOAT 0x8DF1 #define GL_HIGH_FLOAT 0x8DF2 #define GL_LOW_INT 0x8DF3 #define GL_MEDIUM_INT 0x8DF4 #define GL_HIGH_INT 0x8DF5 #define GL_SHADER_COMPILER 0x8DFA #define GL_SHADER_BINARY_FORMATS 0x8DF8 #define GL_NUM_SHADER_BINARY_FORMATS 0x8DF9 #define GL_MAX_VERTEX_UNIFORM_VECTORS 0x8DFB #define GL_MAX_VARYING_VECTORS 0x8DFC #define GL_MAX_FRAGMENT_UNIFORM_VECTORS 0x8DFD #define GL_RGB565 0x8D62 #define GL_PROGRAM_BINARY_RETRIEVABLE_HINT 0x8257 #define GL_PROGRAM_BINARY_LENGTH 0x8741 #define GL_NUM_PROGRAM_BINARY_FORMATS 0x87FE #define GL_PROGRAM_BINARY_FORMATS 0x87FF #define GL_VERTEX_SHADER_BIT 0x00000001 #define GL_FRAGMENT_SHADER_BIT 0x00000002 #define GL_GEOMETRY_SHADER_BIT 0x00000004 #define GL_TESS_CONTROL_SHADER_BIT 0x00000008 #define GL_TESS_EVALUATION_SHADER_BIT 0x00000010 #define GL_ALL_SHADER_BITS 0xFFFFFFFF #define GL_PROGRAM_SEPARABLE 0x8258 #define GL_ACTIVE_PROGRAM 0x8259 #define GL_PROGRAM_PIPELINE_BINDING 0x825A #define GL_MAX_VIEWPORTS 0x825B #define GL_VIEWPORT_SUBPIXEL_BITS 0x825C #define GL_VIEWPORT_BOUNDS_RANGE 0x825D #define GL_LAYER_PROVOKING_VERTEX 0x825E #define GL_VIEWPORT_INDEX_PROVOKING_VERTEX 0x825F #define GL_UNDEFINED_VERTEX 0x8260 typedef void (APIENTRYP PFNGLRELEASESHADERCOMPILERPROC) (void); typedef void (APIENTRYP PFNGLSHADERBINARYPROC) (GLsizei count, const GLuint *shaders, GLenum binaryFormat, const void *binary, GLsizei length); typedef void (APIENTRYP PFNGLGETSHADERPRECISIONFORMATPROC) (GLenum shadertype, GLenum precisiontype, GLint *range, GLint *precision); typedef void (APIENTRYP PFNGLDEPTHRANGEFPROC) (GLfloat n, GLfloat f); typedef void (APIENTRYP PFNGLCLEARDEPTHFPROC) (GLfloat d); typedef void (APIENTRYP PFNGLGETPROGRAMBINARYPROC) (GLuint program, GLsizei bufSize, GLsizei *length, GLenum *binaryFormat, void *binary); typedef void (APIENTRYP PFNGLPROGRAMBINARYPROC) (GLuint program, GLenum binaryFormat, const void *binary, GLsizei length); typedef void (APIENTRYP PFNGLPROGRAMPARAMETERIPROC) (GLuint program, GLenum pname, GLint value); typedef void (APIENTRYP PFNGLUSEPROGRAMSTAGESPROC) (GLuint pipeline, GLbitfield stages, GLuint program); typedef void (APIENTRYP PFNGLACTIVESHADERPROGRAMPROC) (GLuint pipeline, GLuint program); typedef GLuint (APIENTRYP PFNGLCREATESHADERPROGRAMVPROC) (GLenum type, GLsizei count, const GLchar *const*strings); typedef void (APIENTRYP PFNGLBINDPROGRAMPIPELINEPROC) (GLuint pipeline); typedef void (APIENTRYP PFNGLDELETEPROGRAMPIPELINESPROC) (GLsizei n, const GLuint *pipelines); typedef void (APIENTRYP PFNGLGENPROGRAMPIPELINESPROC) (GLsizei n, GLuint *pipelines); typedef GLboolean (APIENTRYP PFNGLISPROGRAMPIPELINEPROC) (GLuint pipeline); typedef void (APIENTRYP PFNGLGETPROGRAMPIPELINEIVPROC) (GLuint pipeline, GLenum pname, GLint *params); typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1IPROC) (GLuint program, GLint location, GLint v0); typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1IVPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1FPROC) (GLuint program, GLint location, GLfloat v0); typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1FVPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1DPROC) (GLuint program, GLint location, GLdouble v0); typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1DVPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UIPROC) (GLuint program, GLint location, GLuint v0); typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UIVPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2IPROC) (GLuint program, GLint location, GLint v0, GLint v1); typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2IVPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2FPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1); typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2FVPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2DPROC) (GLuint program, GLint location, GLdouble v0, GLdouble v1); typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2DVPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UIPROC) (GLuint program, GLint location, GLuint v0, GLuint v1); typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UIVPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3IPROC) (GLuint program, GLint location, GLint v0, GLint v1, GLint v2); typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3IVPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3FPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2); typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3FVPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3DPROC) (GLuint program, GLint location, GLdouble v0, GLdouble v1, GLdouble v2); typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3DVPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UIPROC) (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2); typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UIVPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4IPROC) (GLuint program, GLint location, GLint v0, GLint v1, GLint v2, GLint v3); typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4IVPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4FPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4FVPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4DPROC) (GLuint program, GLint location, GLdouble v0, GLdouble v1, GLdouble v2, GLdouble v3); typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4DVPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UIPROC) (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UIVPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X3FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X2FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X4FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X2FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X4FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X3FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X3DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X2DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X4DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X2DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X4DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X3DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); typedef void (APIENTRYP PFNGLVALIDATEPROGRAMPIPELINEPROC) (GLuint pipeline); typedef void (APIENTRYP PFNGLGETPROGRAMPIPELINEINFOLOGPROC) (GLuint pipeline, GLsizei bufSize, GLsizei *length, GLchar *infoLog); typedef void (APIENTRYP PFNGLVERTEXATTRIBL1DPROC) (GLuint index, GLdouble x); typedef void (APIENTRYP PFNGLVERTEXATTRIBL2DPROC) (GLuint index, GLdouble x, GLdouble y); typedef void (APIENTRYP PFNGLVERTEXATTRIBL3DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); typedef void (APIENTRYP PFNGLVERTEXATTRIBL4DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); typedef void (APIENTRYP PFNGLVERTEXATTRIBL1DVPROC) (GLuint index, const GLdouble *v); typedef void (APIENTRYP PFNGLVERTEXATTRIBL2DVPROC) (GLuint index, const GLdouble *v); typedef void (APIENTRYP PFNGLVERTEXATTRIBL3DVPROC) (GLuint index, const GLdouble *v); typedef void (APIENTRYP PFNGLVERTEXATTRIBL4DVPROC) (GLuint index, const GLdouble *v); typedef void (APIENTRYP PFNGLVERTEXATTRIBLPOINTERPROC) (GLuint index, GLint size, GLenum type, GLsizei stride, const void *pointer); typedef void (APIENTRYP PFNGLGETVERTEXATTRIBLDVPROC) (GLuint index, GLenum pname, GLdouble *params); typedef void (APIENTRYP PFNGLVIEWPORTARRAYVPROC) (GLuint first, GLsizei count, const GLfloat *v); typedef void (APIENTRYP PFNGLVIEWPORTINDEXEDFPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat w, GLfloat h); typedef void (APIENTRYP PFNGLVIEWPORTINDEXEDFVPROC) (GLuint index, const GLfloat *v); typedef void (APIENTRYP PFNGLSCISSORARRAYVPROC) (GLuint first, GLsizei count, const GLint *v); typedef void (APIENTRYP PFNGLSCISSORINDEXEDPROC) (GLuint index, GLint left, GLint bottom, GLsizei width, GLsizei height); typedef void (APIENTRYP PFNGLSCISSORINDEXEDVPROC) (GLuint index, const GLint *v); typedef void (APIENTRYP PFNGLDEPTHRANGEARRAYVPROC) (GLuint first, GLsizei count, const GLdouble *v); typedef void (APIENTRYP PFNGLDEPTHRANGEINDEXEDPROC) (GLuint index, GLdouble n, GLdouble f); typedef void (APIENTRYP PFNGLGETFLOATI_VPROC) (GLenum target, GLuint index, GLfloat *data); typedef void (APIENTRYP PFNGLGETDOUBLEI_VPROC) (GLenum target, GLuint index, GLdouble *data); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glReleaseShaderCompiler (void); GLAPI void APIENTRY glShaderBinary (GLsizei count, const GLuint *shaders, GLenum binaryFormat, const void *binary, GLsizei length); GLAPI void APIENTRY glGetShaderPrecisionFormat (GLenum shadertype, GLenum precisiontype, GLint *range, GLint *precision); GLAPI void APIENTRY glDepthRangef (GLfloat n, GLfloat f); GLAPI void APIENTRY glClearDepthf (GLfloat d); GLAPI void APIENTRY glGetProgramBinary (GLuint program, GLsizei bufSize, GLsizei *length, GLenum *binaryFormat, void *binary); GLAPI void APIENTRY glProgramBinary (GLuint program, GLenum binaryFormat, const void *binary, GLsizei length); GLAPI void APIENTRY glProgramParameteri (GLuint program, GLenum pname, GLint value); GLAPI void APIENTRY glUseProgramStages (GLuint pipeline, GLbitfield stages, GLuint program); GLAPI void APIENTRY glActiveShaderProgram (GLuint pipeline, GLuint program); GLAPI GLuint APIENTRY glCreateShaderProgramv (GLenum type, GLsizei count, const GLchar *const*strings); GLAPI void APIENTRY glBindProgramPipeline (GLuint pipeline); GLAPI void APIENTRY glDeleteProgramPipelines (GLsizei n, const GLuint *pipelines); GLAPI void APIENTRY glGenProgramPipelines (GLsizei n, GLuint *pipelines); GLAPI GLboolean APIENTRY glIsProgramPipeline (GLuint pipeline); GLAPI void APIENTRY glGetProgramPipelineiv (GLuint pipeline, GLenum pname, GLint *params); GLAPI void APIENTRY glProgramUniform1i (GLuint program, GLint location, GLint v0); GLAPI void APIENTRY glProgramUniform1iv (GLuint program, GLint location, GLsizei count, const GLint *value); GLAPI void APIENTRY glProgramUniform1f (GLuint program, GLint location, GLfloat v0); GLAPI void APIENTRY glProgramUniform1fv (GLuint program, GLint location, GLsizei count, const GLfloat *value); GLAPI void APIENTRY glProgramUniform1d (GLuint program, GLint location, GLdouble v0); GLAPI void APIENTRY glProgramUniform1dv (GLuint program, GLint location, GLsizei count, const GLdouble *value); GLAPI void APIENTRY glProgramUniform1ui (GLuint program, GLint location, GLuint v0); GLAPI void APIENTRY glProgramUniform1uiv (GLuint program, GLint location, GLsizei count, const GLuint *value); GLAPI void APIENTRY glProgramUniform2i (GLuint program, GLint location, GLint v0, GLint v1); GLAPI void APIENTRY glProgramUniform2iv (GLuint program, GLint location, GLsizei count, const GLint *value); GLAPI void APIENTRY glProgramUniform2f (GLuint program, GLint location, GLfloat v0, GLfloat v1); GLAPI void APIENTRY glProgramUniform2fv (GLuint program, GLint location, GLsizei count, const GLfloat *value); GLAPI void APIENTRY glProgramUniform2d (GLuint program, GLint location, GLdouble v0, GLdouble v1); GLAPI void APIENTRY glProgramUniform2dv (GLuint program, GLint location, GLsizei count, const GLdouble *value); GLAPI void APIENTRY glProgramUniform2ui (GLuint program, GLint location, GLuint v0, GLuint v1); GLAPI void APIENTRY glProgramUniform2uiv (GLuint program, GLint location, GLsizei count, const GLuint *value); GLAPI void APIENTRY glProgramUniform3i (GLuint program, GLint location, GLint v0, GLint v1, GLint v2); GLAPI void APIENTRY glProgramUniform3iv (GLuint program, GLint location, GLsizei count, const GLint *value); GLAPI void APIENTRY glProgramUniform3f (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2); GLAPI void APIENTRY glProgramUniform3fv (GLuint program, GLint location, GLsizei count, const GLfloat *value); GLAPI void APIENTRY glProgramUniform3d (GLuint program, GLint location, GLdouble v0, GLdouble v1, GLdouble v2); GLAPI void APIENTRY glProgramUniform3dv (GLuint program, GLint location, GLsizei count, const GLdouble *value); GLAPI void APIENTRY glProgramUniform3ui (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2); GLAPI void APIENTRY glProgramUniform3uiv (GLuint program, GLint location, GLsizei count, const GLuint *value); GLAPI void APIENTRY glProgramUniform4i (GLuint program, GLint location, GLint v0, GLint v1, GLint v2, GLint v3); GLAPI void APIENTRY glProgramUniform4iv (GLuint program, GLint location, GLsizei count, const GLint *value); GLAPI void APIENTRY glProgramUniform4f (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); GLAPI void APIENTRY glProgramUniform4fv (GLuint program, GLint location, GLsizei count, const GLfloat *value); GLAPI void APIENTRY glProgramUniform4d (GLuint program, GLint location, GLdouble v0, GLdouble v1, GLdouble v2, GLdouble v3); GLAPI void APIENTRY glProgramUniform4dv (GLuint program, GLint location, GLsizei count, const GLdouble *value); GLAPI void APIENTRY glProgramUniform4ui (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); GLAPI void APIENTRY glProgramUniform4uiv (GLuint program, GLint location, GLsizei count, const GLuint *value); GLAPI void APIENTRY glProgramUniformMatrix2fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); GLAPI void APIENTRY glProgramUniformMatrix3fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); GLAPI void APIENTRY glProgramUniformMatrix4fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); GLAPI void APIENTRY glProgramUniformMatrix2dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); GLAPI void APIENTRY glProgramUniformMatrix3dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); GLAPI void APIENTRY glProgramUniformMatrix4dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); GLAPI void APIENTRY glProgramUniformMatrix2x3fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); GLAPI void APIENTRY glProgramUniformMatrix3x2fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); GLAPI void APIENTRY glProgramUniformMatrix2x4fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); GLAPI void APIENTRY glProgramUniformMatrix4x2fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); GLAPI void APIENTRY glProgramUniformMatrix3x4fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); GLAPI void APIENTRY glProgramUniformMatrix4x3fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); GLAPI void APIENTRY glProgramUniformMatrix2x3dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); GLAPI void APIENTRY glProgramUniformMatrix3x2dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); GLAPI void APIENTRY glProgramUniformMatrix2x4dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); GLAPI void APIENTRY glProgramUniformMatrix4x2dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); GLAPI void APIENTRY glProgramUniformMatrix3x4dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); GLAPI void APIENTRY glProgramUniformMatrix4x3dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); GLAPI void APIENTRY glValidateProgramPipeline (GLuint pipeline); GLAPI void APIENTRY glGetProgramPipelineInfoLog (GLuint pipeline, GLsizei bufSize, GLsizei *length, GLchar *infoLog); GLAPI void APIENTRY glVertexAttribL1d (GLuint index, GLdouble x); GLAPI void APIENTRY glVertexAttribL2d (GLuint index, GLdouble x, GLdouble y); GLAPI void APIENTRY glVertexAttribL3d (GLuint index, GLdouble x, GLdouble y, GLdouble z); GLAPI void APIENTRY glVertexAttribL4d (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); GLAPI void APIENTRY glVertexAttribL1dv (GLuint index, const GLdouble *v); GLAPI void APIENTRY glVertexAttribL2dv (GLuint index, const GLdouble *v); GLAPI void APIENTRY glVertexAttribL3dv (GLuint index, const GLdouble *v); GLAPI void APIENTRY glVertexAttribL4dv (GLuint index, const GLdouble *v); GLAPI void APIENTRY glVertexAttribLPointer (GLuint index, GLint size, GLenum type, GLsizei stride, const void *pointer); GLAPI void APIENTRY glGetVertexAttribLdv (GLuint index, GLenum pname, GLdouble *params); GLAPI void APIENTRY glViewportArrayv (GLuint first, GLsizei count, const GLfloat *v); GLAPI void APIENTRY glViewportIndexedf (GLuint index, GLfloat x, GLfloat y, GLfloat w, GLfloat h); GLAPI void APIENTRY glViewportIndexedfv (GLuint index, const GLfloat *v); GLAPI void APIENTRY glScissorArrayv (GLuint first, GLsizei count, const GLint *v); GLAPI void APIENTRY glScissorIndexed (GLuint index, GLint left, GLint bottom, GLsizei width, GLsizei height); GLAPI void APIENTRY glScissorIndexedv (GLuint index, const GLint *v); GLAPI void APIENTRY glDepthRangeArrayv (GLuint first, GLsizei count, const GLdouble *v); GLAPI void APIENTRY glDepthRangeIndexed (GLuint index, GLdouble n, GLdouble f); GLAPI void APIENTRY glGetFloati_v (GLenum target, GLuint index, GLfloat *data); GLAPI void APIENTRY glGetDoublei_v (GLenum target, GLuint index, GLdouble *data); #endif #endif /* GL_VERSION_4_1 */ #ifndef GL_VERSION_4_2 #define GL_VERSION_4_2 1 #define GL_COPY_READ_BUFFER_BINDING 0x8F36 #define GL_COPY_WRITE_BUFFER_BINDING 0x8F37 #define GL_TRANSFORM_FEEDBACK_ACTIVE 0x8E24 #define GL_TRANSFORM_FEEDBACK_PAUSED 0x8E23 #define GL_UNPACK_COMPRESSED_BLOCK_WIDTH 0x9127 #define GL_UNPACK_COMPRESSED_BLOCK_HEIGHT 0x9128 #define GL_UNPACK_COMPRESSED_BLOCK_DEPTH 0x9129 #define GL_UNPACK_COMPRESSED_BLOCK_SIZE 0x912A #define GL_PACK_COMPRESSED_BLOCK_WIDTH 0x912B #define GL_PACK_COMPRESSED_BLOCK_HEIGHT 0x912C #define GL_PACK_COMPRESSED_BLOCK_DEPTH 0x912D #define GL_PACK_COMPRESSED_BLOCK_SIZE 0x912E #define GL_NUM_SAMPLE_COUNTS 0x9380 #define GL_MIN_MAP_BUFFER_ALIGNMENT 0x90BC #define GL_ATOMIC_COUNTER_BUFFER 0x92C0 #define GL_ATOMIC_COUNTER_BUFFER_BINDING 0x92C1 #define GL_ATOMIC_COUNTER_BUFFER_START 0x92C2 #define GL_ATOMIC_COUNTER_BUFFER_SIZE 0x92C3 #define GL_ATOMIC_COUNTER_BUFFER_DATA_SIZE 0x92C4 #define GL_ATOMIC_COUNTER_BUFFER_ACTIVE_ATOMIC_COUNTERS 0x92C5 #define GL_ATOMIC_COUNTER_BUFFER_ACTIVE_ATOMIC_COUNTER_INDICES 0x92C6 #define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_VERTEX_SHADER 0x92C7 #define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_TESS_CONTROL_SHADER 0x92C8 #define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_TESS_EVALUATION_SHADER 0x92C9 #define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_GEOMETRY_SHADER 0x92CA #define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_FRAGMENT_SHADER 0x92CB #define GL_MAX_VERTEX_ATOMIC_COUNTER_BUFFERS 0x92CC #define GL_MAX_TESS_CONTROL_ATOMIC_COUNTER_BUFFERS 0x92CD #define GL_MAX_TESS_EVALUATION_ATOMIC_COUNTER_BUFFERS 0x92CE #define GL_MAX_GEOMETRY_ATOMIC_COUNTER_BUFFERS 0x92CF #define GL_MAX_FRAGMENT_ATOMIC_COUNTER_BUFFERS 0x92D0 #define GL_MAX_COMBINED_ATOMIC_COUNTER_BUFFERS 0x92D1 #define GL_MAX_VERTEX_ATOMIC_COUNTERS 0x92D2 #define GL_MAX_TESS_CONTROL_ATOMIC_COUNTERS 0x92D3 #define GL_MAX_TESS_EVALUATION_ATOMIC_COUNTERS 0x92D4 #define GL_MAX_GEOMETRY_ATOMIC_COUNTERS 0x92D5 #define GL_MAX_FRAGMENT_ATOMIC_COUNTERS 0x92D6 #define GL_MAX_COMBINED_ATOMIC_COUNTERS 0x92D7 #define GL_MAX_ATOMIC_COUNTER_BUFFER_SIZE 0x92D8 #define GL_MAX_ATOMIC_COUNTER_BUFFER_BINDINGS 0x92DC #define GL_ACTIVE_ATOMIC_COUNTER_BUFFERS 0x92D9 #define GL_UNIFORM_ATOMIC_COUNTER_BUFFER_INDEX 0x92DA #define GL_UNSIGNED_INT_ATOMIC_COUNTER 0x92DB #define GL_VERTEX_ATTRIB_ARRAY_BARRIER_BIT 0x00000001 #define GL_ELEMENT_ARRAY_BARRIER_BIT 0x00000002 #define GL_UNIFORM_BARRIER_BIT 0x00000004 #define GL_TEXTURE_FETCH_BARRIER_BIT 0x00000008 #define GL_SHADER_IMAGE_ACCESS_BARRIER_BIT 0x00000020 #define GL_COMMAND_BARRIER_BIT 0x00000040 #define GL_PIXEL_BUFFER_BARRIER_BIT 0x00000080 #define GL_TEXTURE_UPDATE_BARRIER_BIT 0x00000100 #define GL_BUFFER_UPDATE_BARRIER_BIT 0x00000200 #define GL_FRAMEBUFFER_BARRIER_BIT 0x00000400 #define GL_TRANSFORM_FEEDBACK_BARRIER_BIT 0x00000800 #define GL_ATOMIC_COUNTER_BARRIER_BIT 0x00001000 #define GL_ALL_BARRIER_BITS 0xFFFFFFFF #define GL_MAX_IMAGE_UNITS 0x8F38 #define GL_MAX_COMBINED_IMAGE_UNITS_AND_FRAGMENT_OUTPUTS 0x8F39 #define GL_IMAGE_BINDING_NAME 0x8F3A #define GL_IMAGE_BINDING_LEVEL 0x8F3B #define GL_IMAGE_BINDING_LAYERED 0x8F3C #define GL_IMAGE_BINDING_LAYER 0x8F3D #define GL_IMAGE_BINDING_ACCESS 0x8F3E #define GL_IMAGE_1D 0x904C #define GL_IMAGE_2D 0x904D #define GL_IMAGE_3D 0x904E #define GL_IMAGE_2D_RECT 0x904F #define GL_IMAGE_CUBE 0x9050 #define GL_IMAGE_BUFFER 0x9051 #define GL_IMAGE_1D_ARRAY 0x9052 #define GL_IMAGE_2D_ARRAY 0x9053 #define GL_IMAGE_CUBE_MAP_ARRAY 0x9054 #define GL_IMAGE_2D_MULTISAMPLE 0x9055 #define GL_IMAGE_2D_MULTISAMPLE_ARRAY 0x9056 #define GL_INT_IMAGE_1D 0x9057 #define GL_INT_IMAGE_2D 0x9058 #define GL_INT_IMAGE_3D 0x9059 #define GL_INT_IMAGE_2D_RECT 0x905A #define GL_INT_IMAGE_CUBE 0x905B #define GL_INT_IMAGE_BUFFER 0x905C #define GL_INT_IMAGE_1D_ARRAY 0x905D #define GL_INT_IMAGE_2D_ARRAY 0x905E #define GL_INT_IMAGE_CUBE_MAP_ARRAY 0x905F #define GL_INT_IMAGE_2D_MULTISAMPLE 0x9060 #define GL_INT_IMAGE_2D_MULTISAMPLE_ARRAY 0x9061 #define GL_UNSIGNED_INT_IMAGE_1D 0x9062 #define GL_UNSIGNED_INT_IMAGE_2D 0x9063 #define GL_UNSIGNED_INT_IMAGE_3D 0x9064 #define GL_UNSIGNED_INT_IMAGE_2D_RECT 0x9065 #define GL_UNSIGNED_INT_IMAGE_CUBE 0x9066 #define GL_UNSIGNED_INT_IMAGE_BUFFER 0x9067 #define GL_UNSIGNED_INT_IMAGE_1D_ARRAY 0x9068 #define GL_UNSIGNED_INT_IMAGE_2D_ARRAY 0x9069 #define GL_UNSIGNED_INT_IMAGE_CUBE_MAP_ARRAY 0x906A #define GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE 0x906B #define GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE_ARRAY 0x906C #define GL_MAX_IMAGE_SAMPLES 0x906D #define GL_IMAGE_BINDING_FORMAT 0x906E #define GL_IMAGE_FORMAT_COMPATIBILITY_TYPE 0x90C7 #define GL_IMAGE_FORMAT_COMPATIBILITY_BY_SIZE 0x90C8 #define GL_IMAGE_FORMAT_COMPATIBILITY_BY_CLASS 0x90C9 #define GL_MAX_VERTEX_IMAGE_UNIFORMS 0x90CA #define GL_MAX_TESS_CONTROL_IMAGE_UNIFORMS 0x90CB #define GL_MAX_TESS_EVALUATION_IMAGE_UNIFORMS 0x90CC #define GL_MAX_GEOMETRY_IMAGE_UNIFORMS 0x90CD #define GL_MAX_FRAGMENT_IMAGE_UNIFORMS 0x90CE #define GL_MAX_COMBINED_IMAGE_UNIFORMS 0x90CF #define GL_COMPRESSED_RGBA_BPTC_UNORM 0x8E8C #define GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM 0x8E8D #define GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT 0x8E8E #define GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT 0x8E8F #define GL_TEXTURE_IMMUTABLE_FORMAT 0x912F typedef void (APIENTRYP PFNGLDRAWARRAYSINSTANCEDBASEINSTANCEPROC) (GLenum mode, GLint first, GLsizei count, GLsizei instancecount, GLuint baseinstance); typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDBASEINSTANCEPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLuint baseinstance); typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXBASEINSTANCEPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLint basevertex, GLuint baseinstance); typedef void (APIENTRYP PFNGLGETINTERNALFORMATIVPROC) (GLenum target, GLenum internalformat, GLenum pname, GLsizei count, GLint *params); typedef void (APIENTRYP PFNGLGETACTIVEATOMICCOUNTERBUFFERIVPROC) (GLuint program, GLuint bufferIndex, GLenum pname, GLint *params); typedef void (APIENTRYP PFNGLBINDIMAGETEXTUREPROC) (GLuint unit, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLenum format); typedef void (APIENTRYP PFNGLMEMORYBARRIERPROC) (GLbitfield barriers); typedef void (APIENTRYP PFNGLTEXSTORAGE1DPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width); typedef void (APIENTRYP PFNGLTEXSTORAGE2DPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); typedef void (APIENTRYP PFNGLTEXSTORAGE3DPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); typedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKINSTANCEDPROC) (GLenum mode, GLuint id, GLsizei instancecount); typedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKSTREAMINSTANCEDPROC) (GLenum mode, GLuint id, GLuint stream, GLsizei instancecount); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glDrawArraysInstancedBaseInstance (GLenum mode, GLint first, GLsizei count, GLsizei instancecount, GLuint baseinstance); GLAPI void APIENTRY glDrawElementsInstancedBaseInstance (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLuint baseinstance); GLAPI void APIENTRY glDrawElementsInstancedBaseVertexBaseInstance (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLint basevertex, GLuint baseinstance); GLAPI void APIENTRY glGetInternalformativ (GLenum target, GLenum internalformat, GLenum pname, GLsizei count, GLint *params); GLAPI void APIENTRY glGetActiveAtomicCounterBufferiv (GLuint program, GLuint bufferIndex, GLenum pname, GLint *params); GLAPI void APIENTRY glBindImageTexture (GLuint unit, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLenum format); GLAPI void APIENTRY glMemoryBarrier (GLbitfield barriers); GLAPI void APIENTRY glTexStorage1D (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width); GLAPI void APIENTRY glTexStorage2D (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); GLAPI void APIENTRY glTexStorage3D (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); GLAPI void APIENTRY glDrawTransformFeedbackInstanced (GLenum mode, GLuint id, GLsizei instancecount); GLAPI void APIENTRY glDrawTransformFeedbackStreamInstanced (GLenum mode, GLuint id, GLuint stream, GLsizei instancecount); #endif #endif /* GL_VERSION_4_2 */ #ifndef GL_VERSION_4_3 #define GL_VERSION_4_3 1 typedef void (APIENTRY *GLDEBUGPROC)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,const void *userParam); #define GL_NUM_SHADING_LANGUAGE_VERSIONS 0x82E9 #define GL_VERTEX_ATTRIB_ARRAY_LONG 0x874E #define GL_COMPRESSED_RGB8_ETC2 0x9274 #define GL_COMPRESSED_SRGB8_ETC2 0x9275 #define GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2 0x9276 #define GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2 0x9277 #define GL_COMPRESSED_RGBA8_ETC2_EAC 0x9278 #define GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC 0x9279 #define GL_COMPRESSED_R11_EAC 0x9270 #define GL_COMPRESSED_SIGNED_R11_EAC 0x9271 #define GL_COMPRESSED_RG11_EAC 0x9272 #define GL_COMPRESSED_SIGNED_RG11_EAC 0x9273 #define GL_PRIMITIVE_RESTART_FIXED_INDEX 0x8D69 #define GL_ANY_SAMPLES_PASSED_CONSERVATIVE 0x8D6A #define GL_MAX_ELEMENT_INDEX 0x8D6B #define GL_COMPUTE_SHADER 0x91B9 #define GL_MAX_COMPUTE_UNIFORM_BLOCKS 0x91BB #define GL_MAX_COMPUTE_TEXTURE_IMAGE_UNITS 0x91BC #define GL_MAX_COMPUTE_IMAGE_UNIFORMS 0x91BD #define GL_MAX_COMPUTE_SHARED_MEMORY_SIZE 0x8262 #define GL_MAX_COMPUTE_UNIFORM_COMPONENTS 0x8263 #define GL_MAX_COMPUTE_ATOMIC_COUNTER_BUFFERS 0x8264 #define GL_MAX_COMPUTE_ATOMIC_COUNTERS 0x8265 #define GL_MAX_COMBINED_COMPUTE_UNIFORM_COMPONENTS 0x8266 #define GL_MAX_COMPUTE_WORK_GROUP_INVOCATIONS 0x90EB #define GL_MAX_COMPUTE_WORK_GROUP_COUNT 0x91BE #define GL_MAX_COMPUTE_WORK_GROUP_SIZE 0x91BF #define GL_COMPUTE_WORK_GROUP_SIZE 0x8267 #define GL_UNIFORM_BLOCK_REFERENCED_BY_COMPUTE_SHADER 0x90EC #define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_COMPUTE_SHADER 0x90ED #define GL_DISPATCH_INDIRECT_BUFFER 0x90EE #define GL_DISPATCH_INDIRECT_BUFFER_BINDING 0x90EF #define GL_COMPUTE_SHADER_BIT 0x00000020 #define GL_DEBUG_OUTPUT_SYNCHRONOUS 0x8242 #define GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH 0x8243 #define GL_DEBUG_CALLBACK_FUNCTION 0x8244 #define GL_DEBUG_CALLBACK_USER_PARAM 0x8245 #define GL_DEBUG_SOURCE_API 0x8246 #define GL_DEBUG_SOURCE_WINDOW_SYSTEM 0x8247 #define GL_DEBUG_SOURCE_SHADER_COMPILER 0x8248 #define GL_DEBUG_SOURCE_THIRD_PARTY 0x8249 #define GL_DEBUG_SOURCE_APPLICATION 0x824A #define GL_DEBUG_SOURCE_OTHER 0x824B #define GL_DEBUG_TYPE_ERROR 0x824C #define GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR 0x824D #define GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR 0x824E #define GL_DEBUG_TYPE_PORTABILITY 0x824F #define GL_DEBUG_TYPE_PERFORMANCE 0x8250 #define GL_DEBUG_TYPE_OTHER 0x8251 #define GL_MAX_DEBUG_MESSAGE_LENGTH 0x9143 #define GL_MAX_DEBUG_LOGGED_MESSAGES 0x9144 #define GL_DEBUG_LOGGED_MESSAGES 0x9145 #define GL_DEBUG_SEVERITY_HIGH 0x9146 #define GL_DEBUG_SEVERITY_MEDIUM 0x9147 #define GL_DEBUG_SEVERITY_LOW 0x9148 #define GL_DEBUG_TYPE_MARKER 0x8268 #define GL_DEBUG_TYPE_PUSH_GROUP 0x8269 #define GL_DEBUG_TYPE_POP_GROUP 0x826A #define GL_DEBUG_SEVERITY_NOTIFICATION 0x826B #define GL_MAX_DEBUG_GROUP_STACK_DEPTH 0x826C #define GL_DEBUG_GROUP_STACK_DEPTH 0x826D #define GL_BUFFER 0x82E0 #define GL_SHADER 0x82E1 #define GL_PROGRAM 0x82E2 #define GL_QUERY 0x82E3 #define GL_PROGRAM_PIPELINE 0x82E4 #define GL_SAMPLER 0x82E6 #define GL_MAX_LABEL_LENGTH 0x82E8 #define GL_DEBUG_OUTPUT 0x92E0 #define GL_CONTEXT_FLAG_DEBUG_BIT 0x00000002 #define GL_MAX_UNIFORM_LOCATIONS 0x826E #define GL_FRAMEBUFFER_DEFAULT_WIDTH 0x9310 #define GL_FRAMEBUFFER_DEFAULT_HEIGHT 0x9311 #define GL_FRAMEBUFFER_DEFAULT_LAYERS 0x9312 #define GL_FRAMEBUFFER_DEFAULT_SAMPLES 0x9313 #define GL_FRAMEBUFFER_DEFAULT_FIXED_SAMPLE_LOCATIONS 0x9314 #define GL_MAX_FRAMEBUFFER_WIDTH 0x9315 #define GL_MAX_FRAMEBUFFER_HEIGHT 0x9316 #define GL_MAX_FRAMEBUFFER_LAYERS 0x9317 #define GL_MAX_FRAMEBUFFER_SAMPLES 0x9318 #define GL_INTERNALFORMAT_SUPPORTED 0x826F #define GL_INTERNALFORMAT_PREFERRED 0x8270 #define GL_INTERNALFORMAT_RED_SIZE 0x8271 #define GL_INTERNALFORMAT_GREEN_SIZE 0x8272 #define GL_INTERNALFORMAT_BLUE_SIZE 0x8273 #define GL_INTERNALFORMAT_ALPHA_SIZE 0x8274 #define GL_INTERNALFORMAT_DEPTH_SIZE 0x8275 #define GL_INTERNALFORMAT_STENCIL_SIZE 0x8276 #define GL_INTERNALFORMAT_SHARED_SIZE 0x8277 #define GL_INTERNALFORMAT_RED_TYPE 0x8278 #define GL_INTERNALFORMAT_GREEN_TYPE 0x8279 #define GL_INTERNALFORMAT_BLUE_TYPE 0x827A #define GL_INTERNALFORMAT_ALPHA_TYPE 0x827B #define GL_INTERNALFORMAT_DEPTH_TYPE 0x827C #define GL_INTERNALFORMAT_STENCIL_TYPE 0x827D #define GL_MAX_WIDTH 0x827E #define GL_MAX_HEIGHT 0x827F #define GL_MAX_DEPTH 0x8280 #define GL_MAX_LAYERS 0x8281 #define GL_MAX_COMBINED_DIMENSIONS 0x8282 #define GL_COLOR_COMPONENTS 0x8283 #define GL_DEPTH_COMPONENTS 0x8284 #define GL_STENCIL_COMPONENTS 0x8285 #define GL_COLOR_RENDERABLE 0x8286 #define GL_DEPTH_RENDERABLE 0x8287 #define GL_STENCIL_RENDERABLE 0x8288 #define GL_FRAMEBUFFER_RENDERABLE 0x8289 #define GL_FRAMEBUFFER_RENDERABLE_LAYERED 0x828A #define GL_FRAMEBUFFER_BLEND 0x828B #define GL_READ_PIXELS 0x828C #define GL_READ_PIXELS_FORMAT 0x828D #define GL_READ_PIXELS_TYPE 0x828E #define GL_TEXTURE_IMAGE_FORMAT 0x828F #define GL_TEXTURE_IMAGE_TYPE 0x8290 #define GL_GET_TEXTURE_IMAGE_FORMAT 0x8291 #define GL_GET_TEXTURE_IMAGE_TYPE 0x8292 #define GL_MIPMAP 0x8293 #define GL_MANUAL_GENERATE_MIPMAP 0x8294 #define GL_AUTO_GENERATE_MIPMAP 0x8295 #define GL_COLOR_ENCODING 0x8296 #define GL_SRGB_READ 0x8297 #define GL_SRGB_WRITE 0x8298 #define GL_FILTER 0x829A #define GL_VERTEX_TEXTURE 0x829B #define GL_TESS_CONTROL_TEXTURE 0x829C #define GL_TESS_EVALUATION_TEXTURE 0x829D #define GL_GEOMETRY_TEXTURE 0x829E #define GL_FRAGMENT_TEXTURE 0x829F #define GL_COMPUTE_TEXTURE 0x82A0 #define GL_TEXTURE_SHADOW 0x82A1 #define GL_TEXTURE_GATHER 0x82A2 #define GL_TEXTURE_GATHER_SHADOW 0x82A3 #define GL_SHADER_IMAGE_LOAD 0x82A4 #define GL_SHADER_IMAGE_STORE 0x82A5 #define GL_SHADER_IMAGE_ATOMIC 0x82A6 #define GL_IMAGE_TEXEL_SIZE 0x82A7 #define GL_IMAGE_COMPATIBILITY_CLASS 0x82A8 #define GL_IMAGE_PIXEL_FORMAT 0x82A9 #define GL_IMAGE_PIXEL_TYPE 0x82AA #define GL_SIMULTANEOUS_TEXTURE_AND_DEPTH_TEST 0x82AC #define GL_SIMULTANEOUS_TEXTURE_AND_STENCIL_TEST 0x82AD #define GL_SIMULTANEOUS_TEXTURE_AND_DEPTH_WRITE 0x82AE #define GL_SIMULTANEOUS_TEXTURE_AND_STENCIL_WRITE 0x82AF #define GL_TEXTURE_COMPRESSED_BLOCK_WIDTH 0x82B1 #define GL_TEXTURE_COMPRESSED_BLOCK_HEIGHT 0x82B2 #define GL_TEXTURE_COMPRESSED_BLOCK_SIZE 0x82B3 #define GL_CLEAR_BUFFER 0x82B4 #define GL_TEXTURE_VIEW 0x82B5 #define GL_VIEW_COMPATIBILITY_CLASS 0x82B6 #define GL_FULL_SUPPORT 0x82B7 #define GL_CAVEAT_SUPPORT 0x82B8 #define GL_IMAGE_CLASS_4_X_32 0x82B9 #define GL_IMAGE_CLASS_2_X_32 0x82BA #define GL_IMAGE_CLASS_1_X_32 0x82BB #define GL_IMAGE_CLASS_4_X_16 0x82BC #define GL_IMAGE_CLASS_2_X_16 0x82BD #define GL_IMAGE_CLASS_1_X_16 0x82BE #define GL_IMAGE_CLASS_4_X_8 0x82BF #define GL_IMAGE_CLASS_2_X_8 0x82C0 #define GL_IMAGE_CLASS_1_X_8 0x82C1 #define GL_IMAGE_CLASS_11_11_10 0x82C2 #define GL_IMAGE_CLASS_10_10_10_2 0x82C3 #define GL_VIEW_CLASS_128_BITS 0x82C4 #define GL_VIEW_CLASS_96_BITS 0x82C5 #define GL_VIEW_CLASS_64_BITS 0x82C6 #define GL_VIEW_CLASS_48_BITS 0x82C7 #define GL_VIEW_CLASS_32_BITS 0x82C8 #define GL_VIEW_CLASS_24_BITS 0x82C9 #define GL_VIEW_CLASS_16_BITS 0x82CA #define GL_VIEW_CLASS_8_BITS 0x82CB #define GL_VIEW_CLASS_S3TC_DXT1_RGB 0x82CC #define GL_VIEW_CLASS_S3TC_DXT1_RGBA 0x82CD #define GL_VIEW_CLASS_S3TC_DXT3_RGBA 0x82CE #define GL_VIEW_CLASS_S3TC_DXT5_RGBA 0x82CF #define GL_VIEW_CLASS_RGTC1_RED 0x82D0 #define GL_VIEW_CLASS_RGTC2_RG 0x82D1 #define GL_VIEW_CLASS_BPTC_UNORM 0x82D2 #define GL_VIEW_CLASS_BPTC_FLOAT 0x82D3 #define GL_UNIFORM 0x92E1 #define GL_UNIFORM_BLOCK 0x92E2 #define GL_PROGRAM_INPUT 0x92E3 #define GL_PROGRAM_OUTPUT 0x92E4 #define GL_BUFFER_VARIABLE 0x92E5 #define GL_SHADER_STORAGE_BLOCK 0x92E6 #define GL_VERTEX_SUBROUTINE 0x92E8 #define GL_TESS_CONTROL_SUBROUTINE 0x92E9 #define GL_TESS_EVALUATION_SUBROUTINE 0x92EA #define GL_GEOMETRY_SUBROUTINE 0x92EB #define GL_FRAGMENT_SUBROUTINE 0x92EC #define GL_COMPUTE_SUBROUTINE 0x92ED #define GL_VERTEX_SUBROUTINE_UNIFORM 0x92EE #define GL_TESS_CONTROL_SUBROUTINE_UNIFORM 0x92EF #define GL_TESS_EVALUATION_SUBROUTINE_UNIFORM 0x92F0 #define GL_GEOMETRY_SUBROUTINE_UNIFORM 0x92F1 #define GL_FRAGMENT_SUBROUTINE_UNIFORM 0x92F2 #define GL_COMPUTE_SUBROUTINE_UNIFORM 0x92F3 #define GL_TRANSFORM_FEEDBACK_VARYING 0x92F4 #define GL_ACTIVE_RESOURCES 0x92F5 #define GL_MAX_NAME_LENGTH 0x92F6 #define GL_MAX_NUM_ACTIVE_VARIABLES 0x92F7 #define GL_MAX_NUM_COMPATIBLE_SUBROUTINES 0x92F8 #define GL_NAME_LENGTH 0x92F9 #define GL_TYPE 0x92FA #define GL_ARRAY_SIZE 0x92FB #define GL_OFFSET 0x92FC #define GL_BLOCK_INDEX 0x92FD #define GL_ARRAY_STRIDE 0x92FE #define GL_MATRIX_STRIDE 0x92FF #define GL_IS_ROW_MAJOR 0x9300 #define GL_ATOMIC_COUNTER_BUFFER_INDEX 0x9301 #define GL_BUFFER_BINDING 0x9302 #define GL_BUFFER_DATA_SIZE 0x9303 #define GL_NUM_ACTIVE_VARIABLES 0x9304 #define GL_ACTIVE_VARIABLES 0x9305 #define GL_REFERENCED_BY_VERTEX_SHADER 0x9306 #define GL_REFERENCED_BY_TESS_CONTROL_SHADER 0x9307 #define GL_REFERENCED_BY_TESS_EVALUATION_SHADER 0x9308 #define GL_REFERENCED_BY_GEOMETRY_SHADER 0x9309 #define GL_REFERENCED_BY_FRAGMENT_SHADER 0x930A #define GL_REFERENCED_BY_COMPUTE_SHADER 0x930B #define GL_TOP_LEVEL_ARRAY_SIZE 0x930C #define GL_TOP_LEVEL_ARRAY_STRIDE 0x930D #define GL_LOCATION 0x930E #define GL_LOCATION_INDEX 0x930F #define GL_IS_PER_PATCH 0x92E7 #define GL_SHADER_STORAGE_BUFFER 0x90D2 #define GL_SHADER_STORAGE_BUFFER_BINDING 0x90D3 #define GL_SHADER_STORAGE_BUFFER_START 0x90D4 #define GL_SHADER_STORAGE_BUFFER_SIZE 0x90D5 #define GL_MAX_VERTEX_SHADER_STORAGE_BLOCKS 0x90D6 #define GL_MAX_GEOMETRY_SHADER_STORAGE_BLOCKS 0x90D7 #define GL_MAX_TESS_CONTROL_SHADER_STORAGE_BLOCKS 0x90D8 #define GL_MAX_TESS_EVALUATION_SHADER_STORAGE_BLOCKS 0x90D9 #define GL_MAX_FRAGMENT_SHADER_STORAGE_BLOCKS 0x90DA #define GL_MAX_COMPUTE_SHADER_STORAGE_BLOCKS 0x90DB #define GL_MAX_COMBINED_SHADER_STORAGE_BLOCKS 0x90DC #define GL_MAX_SHADER_STORAGE_BUFFER_BINDINGS 0x90DD #define GL_MAX_SHADER_STORAGE_BLOCK_SIZE 0x90DE #define GL_SHADER_STORAGE_BUFFER_OFFSET_ALIGNMENT 0x90DF #define GL_SHADER_STORAGE_BARRIER_BIT 0x00002000 #define GL_MAX_COMBINED_SHADER_OUTPUT_RESOURCES 0x8F39 #define GL_DEPTH_STENCIL_TEXTURE_MODE 0x90EA #define GL_TEXTURE_BUFFER_OFFSET 0x919D #define GL_TEXTURE_BUFFER_SIZE 0x919E #define GL_TEXTURE_BUFFER_OFFSET_ALIGNMENT 0x919F #define GL_TEXTURE_VIEW_MIN_LEVEL 0x82DB #define GL_TEXTURE_VIEW_NUM_LEVELS 0x82DC #define GL_TEXTURE_VIEW_MIN_LAYER 0x82DD #define GL_TEXTURE_VIEW_NUM_LAYERS 0x82DE #define GL_TEXTURE_IMMUTABLE_LEVELS 0x82DF #define GL_VERTEX_ATTRIB_BINDING 0x82D4 #define GL_VERTEX_ATTRIB_RELATIVE_OFFSET 0x82D5 #define GL_VERTEX_BINDING_DIVISOR 0x82D6 #define GL_VERTEX_BINDING_OFFSET 0x82D7 #define GL_VERTEX_BINDING_STRIDE 0x82D8 #define GL_MAX_VERTEX_ATTRIB_RELATIVE_OFFSET 0x82D9 #define GL_MAX_VERTEX_ATTRIB_BINDINGS 0x82DA #define GL_VERTEX_BINDING_BUFFER 0x8F4F #define GL_DISPLAY_LIST 0x82E7 typedef void (APIENTRYP PFNGLCLEARBUFFERDATAPROC) (GLenum target, GLenum internalformat, GLenum format, GLenum type, const void *data); typedef void (APIENTRYP PFNGLCLEARBUFFERSUBDATAPROC) (GLenum target, GLenum internalformat, GLintptr offset, GLsizeiptr size, GLenum format, GLenum type, const void *data); typedef void (APIENTRYP PFNGLDISPATCHCOMPUTEPROC) (GLuint num_groups_x, GLuint num_groups_y, GLuint num_groups_z); typedef void (APIENTRYP PFNGLDISPATCHCOMPUTEINDIRECTPROC) (GLintptr indirect); typedef void (APIENTRYP PFNGLCOPYIMAGESUBDATAPROC) (GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei srcWidth, GLsizei srcHeight, GLsizei srcDepth); typedef void (APIENTRYP PFNGLFRAMEBUFFERPARAMETERIPROC) (GLenum target, GLenum pname, GLint param); typedef void (APIENTRYP PFNGLGETFRAMEBUFFERPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); typedef void (APIENTRYP PFNGLGETINTERNALFORMATI64VPROC) (GLenum target, GLenum internalformat, GLenum pname, GLsizei count, GLint64 *params); typedef void (APIENTRYP PFNGLINVALIDATETEXSUBIMAGEPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth); typedef void (APIENTRYP PFNGLINVALIDATETEXIMAGEPROC) (GLuint texture, GLint level); typedef void (APIENTRYP PFNGLINVALIDATEBUFFERSUBDATAPROC) (GLuint buffer, GLintptr offset, GLsizeiptr length); typedef void (APIENTRYP PFNGLINVALIDATEBUFFERDATAPROC) (GLuint buffer); typedef void (APIENTRYP PFNGLINVALIDATEFRAMEBUFFERPROC) (GLenum target, GLsizei numAttachments, const GLenum *attachments); typedef void (APIENTRYP PFNGLINVALIDATESUBFRAMEBUFFERPROC) (GLenum target, GLsizei numAttachments, const GLenum *attachments, GLint x, GLint y, GLsizei width, GLsizei height); typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSINDIRECTPROC) (GLenum mode, const void *indirect, GLsizei drawcount, GLsizei stride); typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSINDIRECTPROC) (GLenum mode, GLenum type, const void *indirect, GLsizei drawcount, GLsizei stride); typedef void (APIENTRYP PFNGLGETPROGRAMINTERFACEIVPROC) (GLuint program, GLenum programInterface, GLenum pname, GLint *params); typedef GLuint (APIENTRYP PFNGLGETPROGRAMRESOURCEINDEXPROC) (GLuint program, GLenum programInterface, const GLchar *name); typedef void (APIENTRYP PFNGLGETPROGRAMRESOURCENAMEPROC) (GLuint program, GLenum programInterface, GLuint index, GLsizei bufSize, GLsizei *length, GLchar *name); typedef void (APIENTRYP PFNGLGETPROGRAMRESOURCEIVPROC) (GLuint program, GLenum programInterface, GLuint index, GLsizei propCount, const GLenum *props, GLsizei count, GLsizei *length, GLint *params); typedef GLint (APIENTRYP PFNGLGETPROGRAMRESOURCELOCATIONPROC) (GLuint program, GLenum programInterface, const GLchar *name); typedef GLint (APIENTRYP PFNGLGETPROGRAMRESOURCELOCATIONINDEXPROC) (GLuint program, GLenum programInterface, const GLchar *name); typedef void (APIENTRYP PFNGLSHADERSTORAGEBLOCKBINDINGPROC) (GLuint program, GLuint storageBlockIndex, GLuint storageBlockBinding); typedef void (APIENTRYP PFNGLTEXBUFFERRANGEPROC) (GLenum target, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size); typedef void (APIENTRYP PFNGLTEXSTORAGE2DMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); typedef void (APIENTRYP PFNGLTEXSTORAGE3DMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); typedef void (APIENTRYP PFNGLTEXTUREVIEWPROC) (GLuint texture, GLenum target, GLuint origtexture, GLenum internalformat, GLuint minlevel, GLuint numlevels, GLuint minlayer, GLuint numlayers); typedef void (APIENTRYP PFNGLBINDVERTEXBUFFERPROC) (GLuint bindingindex, GLuint buffer, GLintptr offset, GLsizei stride); typedef void (APIENTRYP PFNGLVERTEXATTRIBFORMATPROC) (GLuint attribindex, GLint size, GLenum type, GLboolean normalized, GLuint relativeoffset); typedef void (APIENTRYP PFNGLVERTEXATTRIBIFORMATPROC) (GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); typedef void (APIENTRYP PFNGLVERTEXATTRIBLFORMATPROC) (GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); typedef void (APIENTRYP PFNGLVERTEXATTRIBBINDINGPROC) (GLuint attribindex, GLuint bindingindex); typedef void (APIENTRYP PFNGLVERTEXBINDINGDIVISORPROC) (GLuint bindingindex, GLuint divisor); typedef void (APIENTRYP PFNGLDEBUGMESSAGECONTROLPROC) (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); typedef void (APIENTRYP PFNGLDEBUGMESSAGEINSERTPROC) (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf); typedef void (APIENTRYP PFNGLDEBUGMESSAGECALLBACKPROC) (GLDEBUGPROC callback, const void *userParam); typedef GLuint (APIENTRYP PFNGLGETDEBUGMESSAGELOGPROC) (GLuint count, GLsizei bufSize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog); typedef void (APIENTRYP PFNGLPUSHDEBUGGROUPPROC) (GLenum source, GLuint id, GLsizei length, const GLchar *message); typedef void (APIENTRYP PFNGLPOPDEBUGGROUPPROC) (void); typedef void (APIENTRYP PFNGLOBJECTLABELPROC) (GLenum identifier, GLuint name, GLsizei length, const GLchar *label); typedef void (APIENTRYP PFNGLGETOBJECTLABELPROC) (GLenum identifier, GLuint name, GLsizei bufSize, GLsizei *length, GLchar *label); typedef void (APIENTRYP PFNGLOBJECTPTRLABELPROC) (const void *ptr, GLsizei length, const GLchar *label); typedef void (APIENTRYP PFNGLGETOBJECTPTRLABELPROC) (const void *ptr, GLsizei bufSize, GLsizei *length, GLchar *label); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glClearBufferData (GLenum target, GLenum internalformat, GLenum format, GLenum type, const void *data); GLAPI void APIENTRY glClearBufferSubData (GLenum target, GLenum internalformat, GLintptr offset, GLsizeiptr size, GLenum format, GLenum type, const void *data); GLAPI void APIENTRY glDispatchCompute (GLuint num_groups_x, GLuint num_groups_y, GLuint num_groups_z); GLAPI void APIENTRY glDispatchComputeIndirect (GLintptr indirect); GLAPI void APIENTRY glCopyImageSubData (GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei srcWidth, GLsizei srcHeight, GLsizei srcDepth); GLAPI void APIENTRY glFramebufferParameteri (GLenum target, GLenum pname, GLint param); GLAPI void APIENTRY glGetFramebufferParameteriv (GLenum target, GLenum pname, GLint *params); GLAPI void APIENTRY glGetInternalformati64v (GLenum target, GLenum internalformat, GLenum pname, GLsizei count, GLint64 *params); GLAPI void APIENTRY glInvalidateTexSubImage (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth); GLAPI void APIENTRY glInvalidateTexImage (GLuint texture, GLint level); GLAPI void APIENTRY glInvalidateBufferSubData (GLuint buffer, GLintptr offset, GLsizeiptr length); GLAPI void APIENTRY glInvalidateBufferData (GLuint buffer); GLAPI void APIENTRY glInvalidateFramebuffer (GLenum target, GLsizei numAttachments, const GLenum *attachments); GLAPI void APIENTRY glInvalidateSubFramebuffer (GLenum target, GLsizei numAttachments, const GLenum *attachments, GLint x, GLint y, GLsizei width, GLsizei height); GLAPI void APIENTRY glMultiDrawArraysIndirect (GLenum mode, const void *indirect, GLsizei drawcount, GLsizei stride); GLAPI void APIENTRY glMultiDrawElementsIndirect (GLenum mode, GLenum type, const void *indirect, GLsizei drawcount, GLsizei stride); GLAPI void APIENTRY glGetProgramInterfaceiv (GLuint program, GLenum programInterface, GLenum pname, GLint *params); GLAPI GLuint APIENTRY glGetProgramResourceIndex (GLuint program, GLenum programInterface, const GLchar *name); GLAPI void APIENTRY glGetProgramResourceName (GLuint program, GLenum programInterface, GLuint index, GLsizei bufSize, GLsizei *length, GLchar *name); GLAPI void APIENTRY glGetProgramResourceiv (GLuint program, GLenum programInterface, GLuint index, GLsizei propCount, const GLenum *props, GLsizei count, GLsizei *length, GLint *params); GLAPI GLint APIENTRY glGetProgramResourceLocation (GLuint program, GLenum programInterface, const GLchar *name); GLAPI GLint APIENTRY glGetProgramResourceLocationIndex (GLuint program, GLenum programInterface, const GLchar *name); GLAPI void APIENTRY glShaderStorageBlockBinding (GLuint program, GLuint storageBlockIndex, GLuint storageBlockBinding); GLAPI void APIENTRY glTexBufferRange (GLenum target, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size); GLAPI void APIENTRY glTexStorage2DMultisample (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); GLAPI void APIENTRY glTexStorage3DMultisample (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); GLAPI void APIENTRY glTextureView (GLuint texture, GLenum target, GLuint origtexture, GLenum internalformat, GLuint minlevel, GLuint numlevels, GLuint minlayer, GLuint numlayers); GLAPI void APIENTRY glBindVertexBuffer (GLuint bindingindex, GLuint buffer, GLintptr offset, GLsizei stride); GLAPI void APIENTRY glVertexAttribFormat (GLuint attribindex, GLint size, GLenum type, GLboolean normalized, GLuint relativeoffset); GLAPI void APIENTRY glVertexAttribIFormat (GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); GLAPI void APIENTRY glVertexAttribLFormat (GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); GLAPI void APIENTRY glVertexAttribBinding (GLuint attribindex, GLuint bindingindex); GLAPI void APIENTRY glVertexBindingDivisor (GLuint bindingindex, GLuint divisor); GLAPI void APIENTRY glDebugMessageControl (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); GLAPI void APIENTRY glDebugMessageInsert (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf); GLAPI void APIENTRY glDebugMessageCallback (GLDEBUGPROC callback, const void *userParam); GLAPI GLuint APIENTRY glGetDebugMessageLog (GLuint count, GLsizei bufSize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog); GLAPI void APIENTRY glPushDebugGroup (GLenum source, GLuint id, GLsizei length, const GLchar *message); GLAPI void APIENTRY glPopDebugGroup (void); GLAPI void APIENTRY glObjectLabel (GLenum identifier, GLuint name, GLsizei length, const GLchar *label); GLAPI void APIENTRY glGetObjectLabel (GLenum identifier, GLuint name, GLsizei bufSize, GLsizei *length, GLchar *label); GLAPI void APIENTRY glObjectPtrLabel (const void *ptr, GLsizei length, const GLchar *label); GLAPI void APIENTRY glGetObjectPtrLabel (const void *ptr, GLsizei bufSize, GLsizei *length, GLchar *label); #endif #endif /* GL_VERSION_4_3 */ #ifndef GL_VERSION_4_4 #define GL_VERSION_4_4 1 #define GL_MAX_VERTEX_ATTRIB_STRIDE 0x82E5 #define GL_PRIMITIVE_RESTART_FOR_PATCHES_SUPPORTED 0x8221 #define GL_TEXTURE_BUFFER_BINDING 0x8C2A #define GL_MAP_PERSISTENT_BIT 0x0040 #define GL_MAP_COHERENT_BIT 0x0080 #define GL_DYNAMIC_STORAGE_BIT 0x0100 #define GL_CLIENT_STORAGE_BIT 0x0200 #define GL_CLIENT_MAPPED_BUFFER_BARRIER_BIT 0x00004000 #define GL_BUFFER_IMMUTABLE_STORAGE 0x821F #define GL_BUFFER_STORAGE_FLAGS 0x8220 #define GL_CLEAR_TEXTURE 0x9365 #define GL_LOCATION_COMPONENT 0x934A #define GL_TRANSFORM_FEEDBACK_BUFFER_INDEX 0x934B #define GL_TRANSFORM_FEEDBACK_BUFFER_STRIDE 0x934C #define GL_QUERY_BUFFER 0x9192 #define GL_QUERY_BUFFER_BARRIER_BIT 0x00008000 #define GL_QUERY_BUFFER_BINDING 0x9193 #define GL_QUERY_RESULT_NO_WAIT 0x9194 #define GL_MIRROR_CLAMP_TO_EDGE 0x8743 typedef void (APIENTRYP PFNGLBUFFERSTORAGEPROC) (GLenum target, GLsizeiptr size, const void *data, GLbitfield flags); typedef void (APIENTRYP PFNGLCLEARTEXIMAGEPROC) (GLuint texture, GLint level, GLenum format, GLenum type, const void *data); typedef void (APIENTRYP PFNGLCLEARTEXSUBIMAGEPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *data); typedef void (APIENTRYP PFNGLBINDBUFFERSBASEPROC) (GLenum target, GLuint first, GLsizei count, const GLuint *buffers); typedef void (APIENTRYP PFNGLBINDBUFFERSRANGEPROC) (GLenum target, GLuint first, GLsizei count, const GLuint *buffers, const GLintptr *offsets, const GLsizeiptr *sizes); typedef void (APIENTRYP PFNGLBINDTEXTURESPROC) (GLuint first, GLsizei count, const GLuint *textures); typedef void (APIENTRYP PFNGLBINDSAMPLERSPROC) (GLuint first, GLsizei count, const GLuint *samplers); typedef void (APIENTRYP PFNGLBINDIMAGETEXTURESPROC) (GLuint first, GLsizei count, const GLuint *textures); typedef void (APIENTRYP PFNGLBINDVERTEXBUFFERSPROC) (GLuint first, GLsizei count, const GLuint *buffers, const GLintptr *offsets, const GLsizei *strides); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glBufferStorage (GLenum target, GLsizeiptr size, const void *data, GLbitfield flags); GLAPI void APIENTRY glClearTexImage (GLuint texture, GLint level, GLenum format, GLenum type, const void *data); GLAPI void APIENTRY glClearTexSubImage (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *data); GLAPI void APIENTRY glBindBuffersBase (GLenum target, GLuint first, GLsizei count, const GLuint *buffers); GLAPI void APIENTRY glBindBuffersRange (GLenum target, GLuint first, GLsizei count, const GLuint *buffers, const GLintptr *offsets, const GLsizeiptr *sizes); GLAPI void APIENTRY glBindTextures (GLuint first, GLsizei count, const GLuint *textures); GLAPI void APIENTRY glBindSamplers (GLuint first, GLsizei count, const GLuint *samplers); GLAPI void APIENTRY glBindImageTextures (GLuint first, GLsizei count, const GLuint *textures); GLAPI void APIENTRY glBindVertexBuffers (GLuint first, GLsizei count, const GLuint *buffers, const GLintptr *offsets, const GLsizei *strides); #endif #endif /* GL_VERSION_4_4 */ #ifndef GL_VERSION_4_5 #define GL_VERSION_4_5 1 #define GL_CONTEXT_LOST 0x0507 #define GL_NEGATIVE_ONE_TO_ONE 0x935E #define GL_ZERO_TO_ONE 0x935F #define GL_CLIP_ORIGIN 0x935C #define GL_CLIP_DEPTH_MODE 0x935D #define GL_QUERY_WAIT_INVERTED 0x8E17 #define GL_QUERY_NO_WAIT_INVERTED 0x8E18 #define GL_QUERY_BY_REGION_WAIT_INVERTED 0x8E19 #define GL_QUERY_BY_REGION_NO_WAIT_INVERTED 0x8E1A #define GL_MAX_CULL_DISTANCES 0x82F9 #define GL_MAX_COMBINED_CLIP_AND_CULL_DISTANCES 0x82FA #define GL_TEXTURE_TARGET 0x1006 #define GL_QUERY_TARGET 0x82EA #define GL_GUILTY_CONTEXT_RESET 0x8253 #define GL_INNOCENT_CONTEXT_RESET 0x8254 #define GL_UNKNOWN_CONTEXT_RESET 0x8255 #define GL_RESET_NOTIFICATION_STRATEGY 0x8256 #define GL_LOSE_CONTEXT_ON_RESET 0x8252 #define GL_NO_RESET_NOTIFICATION 0x8261 #define GL_CONTEXT_FLAG_ROBUST_ACCESS_BIT 0x00000004 #define GL_COLOR_TABLE 0x80D0 #define GL_POST_CONVOLUTION_COLOR_TABLE 0x80D1 #define GL_POST_COLOR_MATRIX_COLOR_TABLE 0x80D2 #define GL_PROXY_COLOR_TABLE 0x80D3 #define GL_PROXY_POST_CONVOLUTION_COLOR_TABLE 0x80D4 #define GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE 0x80D5 #define GL_CONVOLUTION_1D 0x8010 #define GL_CONVOLUTION_2D 0x8011 #define GL_SEPARABLE_2D 0x8012 #define GL_HISTOGRAM 0x8024 #define GL_PROXY_HISTOGRAM 0x8025 #define GL_MINMAX 0x802E #define GL_CONTEXT_RELEASE_BEHAVIOR 0x82FB #define GL_CONTEXT_RELEASE_BEHAVIOR_FLUSH 0x82FC typedef void (APIENTRYP PFNGLCLIPCONTROLPROC) (GLenum origin, GLenum depth); typedef void (APIENTRYP PFNGLCREATETRANSFORMFEEDBACKSPROC) (GLsizei n, GLuint *ids); typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKBUFFERBASEPROC) (GLuint xfb, GLuint index, GLuint buffer); typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKBUFFERRANGEPROC) (GLuint xfb, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); typedef void (APIENTRYP PFNGLGETTRANSFORMFEEDBACKIVPROC) (GLuint xfb, GLenum pname, GLint *param); typedef void (APIENTRYP PFNGLGETTRANSFORMFEEDBACKI_VPROC) (GLuint xfb, GLenum pname, GLuint index, GLint *param); typedef void (APIENTRYP PFNGLGETTRANSFORMFEEDBACKI64_VPROC) (GLuint xfb, GLenum pname, GLuint index, GLint64 *param); typedef void (APIENTRYP PFNGLCREATEBUFFERSPROC) (GLsizei n, GLuint *buffers); typedef void (APIENTRYP PFNGLNAMEDBUFFERSTORAGEPROC) (GLuint buffer, GLsizeiptr size, const void *data, GLbitfield flags); typedef void (APIENTRYP PFNGLNAMEDBUFFERDATAPROC) (GLuint buffer, GLsizeiptr size, const void *data, GLenum usage); typedef void (APIENTRYP PFNGLNAMEDBUFFERSUBDATAPROC) (GLuint buffer, GLintptr offset, GLsizeiptr size, const void *data); typedef void (APIENTRYP PFNGLCOPYNAMEDBUFFERSUBDATAPROC) (GLuint readBuffer, GLuint writeBuffer, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); typedef void (APIENTRYP PFNGLCLEARNAMEDBUFFERDATAPROC) (GLuint buffer, GLenum internalformat, GLenum format, GLenum type, const void *data); typedef void (APIENTRYP PFNGLCLEARNAMEDBUFFERSUBDATAPROC) (GLuint buffer, GLenum internalformat, GLintptr offset, GLsizeiptr size, GLenum format, GLenum type, const void *data); typedef void *(APIENTRYP PFNGLMAPNAMEDBUFFERPROC) (GLuint buffer, GLenum access); typedef void *(APIENTRYP PFNGLMAPNAMEDBUFFERRANGEPROC) (GLuint buffer, GLintptr offset, GLsizeiptr length, GLbitfield access); typedef GLboolean (APIENTRYP PFNGLUNMAPNAMEDBUFFERPROC) (GLuint buffer); typedef void (APIENTRYP PFNGLFLUSHMAPPEDNAMEDBUFFERRANGEPROC) (GLuint buffer, GLintptr offset, GLsizeiptr length); typedef void (APIENTRYP PFNGLGETNAMEDBUFFERPARAMETERIVPROC) (GLuint buffer, GLenum pname, GLint *params); typedef void (APIENTRYP PFNGLGETNAMEDBUFFERPARAMETERI64VPROC) (GLuint buffer, GLenum pname, GLint64 *params); typedef void (APIENTRYP PFNGLGETNAMEDBUFFERPOINTERVPROC) (GLuint buffer, GLenum pname, void **params); typedef void (APIENTRYP PFNGLGETNAMEDBUFFERSUBDATAPROC) (GLuint buffer, GLintptr offset, GLsizeiptr size, void *data); typedef void (APIENTRYP PFNGLCREATEFRAMEBUFFERSPROC) (GLsizei n, GLuint *framebuffers); typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERRENDERBUFFERPROC) (GLuint framebuffer, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERPARAMETERIPROC) (GLuint framebuffer, GLenum pname, GLint param); typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTUREPROC) (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level); typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTURELAYERPROC) (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level, GLint layer); typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERDRAWBUFFERPROC) (GLuint framebuffer, GLenum buf); typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERDRAWBUFFERSPROC) (GLuint framebuffer, GLsizei n, const GLenum *bufs); typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERREADBUFFERPROC) (GLuint framebuffer, GLenum src); typedef void (APIENTRYP PFNGLINVALIDATENAMEDFRAMEBUFFERDATAPROC) (GLuint framebuffer, GLsizei numAttachments, const GLenum *attachments); typedef void (APIENTRYP PFNGLINVALIDATENAMEDFRAMEBUFFERSUBDATAPROC) (GLuint framebuffer, GLsizei numAttachments, const GLenum *attachments, GLint x, GLint y, GLsizei width, GLsizei height); typedef void (APIENTRYP PFNGLCLEARNAMEDFRAMEBUFFERIVPROC) (GLuint framebuffer, GLenum buffer, GLint drawbuffer, const GLint *value); typedef void (APIENTRYP PFNGLCLEARNAMEDFRAMEBUFFERUIVPROC) (GLuint framebuffer, GLenum buffer, GLint drawbuffer, const GLuint *value); typedef void (APIENTRYP PFNGLCLEARNAMEDFRAMEBUFFERFVPROC) (GLuint framebuffer, GLenum buffer, GLint drawbuffer, const GLfloat *value); typedef void (APIENTRYP PFNGLCLEARNAMEDFRAMEBUFFERFIPROC) (GLuint framebuffer, GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil); typedef void (APIENTRYP PFNGLBLITNAMEDFRAMEBUFFERPROC) (GLuint readFramebuffer, GLuint drawFramebuffer, GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); typedef GLenum (APIENTRYP PFNGLCHECKNAMEDFRAMEBUFFERSTATUSPROC) (GLuint framebuffer, GLenum target); typedef void (APIENTRYP PFNGLGETNAMEDFRAMEBUFFERPARAMETERIVPROC) (GLuint framebuffer, GLenum pname, GLint *param); typedef void (APIENTRYP PFNGLGETNAMEDFRAMEBUFFERATTACHMENTPARAMETERIVPROC) (GLuint framebuffer, GLenum attachment, GLenum pname, GLint *params); typedef void (APIENTRYP PFNGLCREATERENDERBUFFERSPROC) (GLsizei n, GLuint *renderbuffers); typedef void (APIENTRYP PFNGLNAMEDRENDERBUFFERSTORAGEPROC) (GLuint renderbuffer, GLenum internalformat, GLsizei width, GLsizei height); typedef void (APIENTRYP PFNGLNAMEDRENDERBUFFERSTORAGEMULTISAMPLEPROC) (GLuint renderbuffer, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); typedef void (APIENTRYP PFNGLGETNAMEDRENDERBUFFERPARAMETERIVPROC) (GLuint renderbuffer, GLenum pname, GLint *params); typedef void (APIENTRYP PFNGLCREATETEXTURESPROC) (GLenum target, GLsizei n, GLuint *textures); typedef void (APIENTRYP PFNGLTEXTUREBUFFERPROC) (GLuint texture, GLenum internalformat, GLuint buffer); typedef void (APIENTRYP PFNGLTEXTUREBUFFERRANGEPROC) (GLuint texture, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size); typedef void (APIENTRYP PFNGLTEXTURESTORAGE1DPROC) (GLuint texture, GLsizei levels, GLenum internalformat, GLsizei width); typedef void (APIENTRYP PFNGLTEXTURESTORAGE2DPROC) (GLuint texture, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); typedef void (APIENTRYP PFNGLTEXTURESTORAGE3DPROC) (GLuint texture, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); typedef void (APIENTRYP PFNGLTEXTURESTORAGE2DMULTISAMPLEPROC) (GLuint texture, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); typedef void (APIENTRYP PFNGLTEXTURESTORAGE3DMULTISAMPLEPROC) (GLuint texture, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); typedef void (APIENTRYP PFNGLTEXTURESUBIMAGE1DPROC) (GLuint texture, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const void *pixels); typedef void (APIENTRYP PFNGLTEXTURESUBIMAGE2DPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels); typedef void (APIENTRYP PFNGLTEXTURESUBIMAGE3DPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels); typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTURESUBIMAGE1DPROC) (GLuint texture, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void *data); typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTURESUBIMAGE2DPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *data); typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTURESUBIMAGE3DPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *data); typedef void (APIENTRYP PFNGLCOPYTEXTURESUBIMAGE1DPROC) (GLuint texture, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); typedef void (APIENTRYP PFNGLCOPYTEXTURESUBIMAGE2DPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); typedef void (APIENTRYP PFNGLCOPYTEXTURESUBIMAGE3DPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); typedef void (APIENTRYP PFNGLTEXTUREPARAMETERFPROC) (GLuint texture, GLenum pname, GLfloat param); typedef void (APIENTRYP PFNGLTEXTUREPARAMETERFVPROC) (GLuint texture, GLenum pname, const GLfloat *param); typedef void (APIENTRYP PFNGLTEXTUREPARAMETERIPROC) (GLuint texture, GLenum pname, GLint param); typedef void (APIENTRYP PFNGLTEXTUREPARAMETERIIVPROC) (GLuint texture, GLenum pname, const GLint *params); typedef void (APIENTRYP PFNGLTEXTUREPARAMETERIUIVPROC) (GLuint texture, GLenum pname, const GLuint *params); typedef void (APIENTRYP PFNGLTEXTUREPARAMETERIVPROC) (GLuint texture, GLenum pname, const GLint *param); typedef void (APIENTRYP PFNGLGENERATETEXTUREMIPMAPPROC) (GLuint texture); typedef void (APIENTRYP PFNGLBINDTEXTUREUNITPROC) (GLuint unit, GLuint texture); typedef void (APIENTRYP PFNGLGETTEXTUREIMAGEPROC) (GLuint texture, GLint level, GLenum format, GLenum type, GLsizei bufSize, void *pixels); typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXTUREIMAGEPROC) (GLuint texture, GLint level, GLsizei bufSize, void *pixels); typedef void (APIENTRYP PFNGLGETTEXTURELEVELPARAMETERFVPROC) (GLuint texture, GLint level, GLenum pname, GLfloat *params); typedef void (APIENTRYP PFNGLGETTEXTURELEVELPARAMETERIVPROC) (GLuint texture, GLint level, GLenum pname, GLint *params); typedef void (APIENTRYP PFNGLGETTEXTUREPARAMETERFVPROC) (GLuint texture, GLenum pname, GLfloat *params); typedef void (APIENTRYP PFNGLGETTEXTUREPARAMETERIIVPROC) (GLuint texture, GLenum pname, GLint *params); typedef void (APIENTRYP PFNGLGETTEXTUREPARAMETERIUIVPROC) (GLuint texture, GLenum pname, GLuint *params); typedef void (APIENTRYP PFNGLGETTEXTUREPARAMETERIVPROC) (GLuint texture, GLenum pname, GLint *params); typedef void (APIENTRYP PFNGLCREATEVERTEXARRAYSPROC) (GLsizei n, GLuint *arrays); typedef void (APIENTRYP PFNGLDISABLEVERTEXARRAYATTRIBPROC) (GLuint vaobj, GLuint index); typedef void (APIENTRYP PFNGLENABLEVERTEXARRAYATTRIBPROC) (GLuint vaobj, GLuint index); typedef void (APIENTRYP PFNGLVERTEXARRAYELEMENTBUFFERPROC) (GLuint vaobj, GLuint buffer); typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXBUFFERPROC) (GLuint vaobj, GLuint bindingindex, GLuint buffer, GLintptr offset, GLsizei stride); typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXBUFFERSPROC) (GLuint vaobj, GLuint first, GLsizei count, const GLuint *buffers, const GLintptr *offsets, const GLsizei *strides); typedef void (APIENTRYP PFNGLVERTEXARRAYATTRIBBINDINGPROC) (GLuint vaobj, GLuint attribindex, GLuint bindingindex); typedef void (APIENTRYP PFNGLVERTEXARRAYATTRIBFORMATPROC) (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLboolean normalized, GLuint relativeoffset); typedef void (APIENTRYP PFNGLVERTEXARRAYATTRIBIFORMATPROC) (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); typedef void (APIENTRYP PFNGLVERTEXARRAYATTRIBLFORMATPROC) (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); typedef void (APIENTRYP PFNGLVERTEXARRAYBINDINGDIVISORPROC) (GLuint vaobj, GLuint bindingindex, GLuint divisor); typedef void (APIENTRYP PFNGLGETVERTEXARRAYIVPROC) (GLuint vaobj, GLenum pname, GLint *param); typedef void (APIENTRYP PFNGLGETVERTEXARRAYINDEXEDIVPROC) (GLuint vaobj, GLuint index, GLenum pname, GLint *param); typedef void (APIENTRYP PFNGLGETVERTEXARRAYINDEXED64IVPROC) (GLuint vaobj, GLuint index, GLenum pname, GLint64 *param); typedef void (APIENTRYP PFNGLCREATESAMPLERSPROC) (GLsizei n, GLuint *samplers); typedef void (APIENTRYP PFNGLCREATEPROGRAMPIPELINESPROC) (GLsizei n, GLuint *pipelines); typedef void (APIENTRYP PFNGLCREATEQUERIESPROC) (GLenum target, GLsizei n, GLuint *ids); typedef void (APIENTRYP PFNGLGETQUERYBUFFEROBJECTI64VPROC) (GLuint id, GLuint buffer, GLenum pname, GLintptr offset); typedef void (APIENTRYP PFNGLGETQUERYBUFFEROBJECTIVPROC) (GLuint id, GLuint buffer, GLenum pname, GLintptr offset); typedef void (APIENTRYP PFNGLGETQUERYBUFFEROBJECTUI64VPROC) (GLuint id, GLuint buffer, GLenum pname, GLintptr offset); typedef void (APIENTRYP PFNGLGETQUERYBUFFEROBJECTUIVPROC) (GLuint id, GLuint buffer, GLenum pname, GLintptr offset); typedef void (APIENTRYP PFNGLMEMORYBARRIERBYREGIONPROC) (GLbitfield barriers); typedef void (APIENTRYP PFNGLGETTEXTURESUBIMAGEPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, GLsizei bufSize, void *pixels); typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXTURESUBIMAGEPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLsizei bufSize, void *pixels); typedef GLenum (APIENTRYP PFNGLGETGRAPHICSRESETSTATUSPROC) (void); typedef void (APIENTRYP PFNGLGETNCOMPRESSEDTEXIMAGEPROC) (GLenum target, GLint lod, GLsizei bufSize, void *pixels); typedef void (APIENTRYP PFNGLGETNTEXIMAGEPROC) (GLenum target, GLint level, GLenum format, GLenum type, GLsizei bufSize, void *pixels); typedef void (APIENTRYP PFNGLGETNUNIFORMDVPROC) (GLuint program, GLint location, GLsizei bufSize, GLdouble *params); typedef void (APIENTRYP PFNGLGETNUNIFORMFVPROC) (GLuint program, GLint location, GLsizei bufSize, GLfloat *params); typedef void (APIENTRYP PFNGLGETNUNIFORMIVPROC) (GLuint program, GLint location, GLsizei bufSize, GLint *params); typedef void (APIENTRYP PFNGLGETNUNIFORMUIVPROC) (GLuint program, GLint location, GLsizei bufSize, GLuint *params); typedef void (APIENTRYP PFNGLREADNPIXELSPROC) (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei bufSize, void *data); typedef void (APIENTRYP PFNGLGETNMAPDVPROC) (GLenum target, GLenum query, GLsizei bufSize, GLdouble *v); typedef void (APIENTRYP PFNGLGETNMAPFVPROC) (GLenum target, GLenum query, GLsizei bufSize, GLfloat *v); typedef void (APIENTRYP PFNGLGETNMAPIVPROC) (GLenum target, GLenum query, GLsizei bufSize, GLint *v); typedef void (APIENTRYP PFNGLGETNPIXELMAPFVPROC) (GLenum map, GLsizei bufSize, GLfloat *values); typedef void (APIENTRYP PFNGLGETNPIXELMAPUIVPROC) (GLenum map, GLsizei bufSize, GLuint *values); typedef void (APIENTRYP PFNGLGETNPIXELMAPUSVPROC) (GLenum map, GLsizei bufSize, GLushort *values); typedef void (APIENTRYP PFNGLGETNPOLYGONSTIPPLEPROC) (GLsizei bufSize, GLubyte *pattern); typedef void (APIENTRYP PFNGLGETNCOLORTABLEPROC) (GLenum target, GLenum format, GLenum type, GLsizei bufSize, void *table); typedef void (APIENTRYP PFNGLGETNCONVOLUTIONFILTERPROC) (GLenum target, GLenum format, GLenum type, GLsizei bufSize, void *image); typedef void (APIENTRYP PFNGLGETNSEPARABLEFILTERPROC) (GLenum target, GLenum format, GLenum type, GLsizei rowBufSize, void *row, GLsizei columnBufSize, void *column, void *span); typedef void (APIENTRYP PFNGLGETNHISTOGRAMPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLsizei bufSize, void *values); typedef void (APIENTRYP PFNGLGETNMINMAXPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLsizei bufSize, void *values); typedef void (APIENTRYP PFNGLTEXTUREBARRIERPROC) (void); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glClipControl (GLenum origin, GLenum depth); GLAPI void APIENTRY glCreateTransformFeedbacks (GLsizei n, GLuint *ids); GLAPI void APIENTRY glTransformFeedbackBufferBase (GLuint xfb, GLuint index, GLuint buffer); GLAPI void APIENTRY glTransformFeedbackBufferRange (GLuint xfb, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); GLAPI void APIENTRY glGetTransformFeedbackiv (GLuint xfb, GLenum pname, GLint *param); GLAPI void APIENTRY glGetTransformFeedbacki_v (GLuint xfb, GLenum pname, GLuint index, GLint *param); GLAPI void APIENTRY glGetTransformFeedbacki64_v (GLuint xfb, GLenum pname, GLuint index, GLint64 *param); GLAPI void APIENTRY glCreateBuffers (GLsizei n, GLuint *buffers); GLAPI void APIENTRY glNamedBufferStorage (GLuint buffer, GLsizeiptr size, const void *data, GLbitfield flags); GLAPI void APIENTRY glNamedBufferData (GLuint buffer, GLsizeiptr size, const void *data, GLenum usage); GLAPI void APIENTRY glNamedBufferSubData (GLuint buffer, GLintptr offset, GLsizeiptr size, const void *data); GLAPI void APIENTRY glCopyNamedBufferSubData (GLuint readBuffer, GLuint writeBuffer, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); GLAPI void APIENTRY glClearNamedBufferData (GLuint buffer, GLenum internalformat, GLenum format, GLenum type, const void *data); GLAPI void APIENTRY glClearNamedBufferSubData (GLuint buffer, GLenum internalformat, GLintptr offset, GLsizeiptr size, GLenum format, GLenum type, const void *data); GLAPI void *APIENTRY glMapNamedBuffer (GLuint buffer, GLenum access); GLAPI void *APIENTRY glMapNamedBufferRange (GLuint buffer, GLintptr offset, GLsizeiptr length, GLbitfield access); GLAPI GLboolean APIENTRY glUnmapNamedBuffer (GLuint buffer); GLAPI void APIENTRY glFlushMappedNamedBufferRange (GLuint buffer, GLintptr offset, GLsizeiptr length); GLAPI void APIENTRY glGetNamedBufferParameteriv (GLuint buffer, GLenum pname, GLint *params); GLAPI void APIENTRY glGetNamedBufferParameteri64v (GLuint buffer, GLenum pname, GLint64 *params); GLAPI void APIENTRY glGetNamedBufferPointerv (GLuint buffer, GLenum pname, void **params); GLAPI void APIENTRY glGetNamedBufferSubData (GLuint buffer, GLintptr offset, GLsizeiptr size, void *data); GLAPI void APIENTRY glCreateFramebuffers (GLsizei n, GLuint *framebuffers); GLAPI void APIENTRY glNamedFramebufferRenderbuffer (GLuint framebuffer, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); GLAPI void APIENTRY glNamedFramebufferParameteri (GLuint framebuffer, GLenum pname, GLint param); GLAPI void APIENTRY glNamedFramebufferTexture (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level); GLAPI void APIENTRY glNamedFramebufferTextureLayer (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level, GLint layer); GLAPI void APIENTRY glNamedFramebufferDrawBuffer (GLuint framebuffer, GLenum buf); GLAPI void APIENTRY glNamedFramebufferDrawBuffers (GLuint framebuffer, GLsizei n, const GLenum *bufs); GLAPI void APIENTRY glNamedFramebufferReadBuffer (GLuint framebuffer, GLenum src); GLAPI void APIENTRY glInvalidateNamedFramebufferData (GLuint framebuffer, GLsizei numAttachments, const GLenum *attachments); GLAPI void APIENTRY glInvalidateNamedFramebufferSubData (GLuint framebuffer, GLsizei numAttachments, const GLenum *attachments, GLint x, GLint y, GLsizei width, GLsizei height); GLAPI void APIENTRY glClearNamedFramebufferiv (GLuint framebuffer, GLenum buffer, GLint drawbuffer, const GLint *value); GLAPI void APIENTRY glClearNamedFramebufferuiv (GLuint framebuffer, GLenum buffer, GLint drawbuffer, const GLuint *value); GLAPI void APIENTRY glClearNamedFramebufferfv (GLuint framebuffer, GLenum buffer, GLint drawbuffer, const GLfloat *value); GLAPI void APIENTRY glClearNamedFramebufferfi (GLuint framebuffer, GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil); GLAPI void APIENTRY glBlitNamedFramebuffer (GLuint readFramebuffer, GLuint drawFramebuffer, GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); GLAPI GLenum APIENTRY glCheckNamedFramebufferStatus (GLuint framebuffer, GLenum target); GLAPI void APIENTRY glGetNamedFramebufferParameteriv (GLuint framebuffer, GLenum pname, GLint *param); GLAPI void APIENTRY glGetNamedFramebufferAttachmentParameteriv (GLuint framebuffer, GLenum attachment, GLenum pname, GLint *params); GLAPI void APIENTRY glCreateRenderbuffers (GLsizei n, GLuint *renderbuffers); GLAPI void APIENTRY glNamedRenderbufferStorage (GLuint renderbuffer, GLenum internalformat, GLsizei width, GLsizei height); GLAPI void APIENTRY glNamedRenderbufferStorageMultisample (GLuint renderbuffer, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); GLAPI void APIENTRY glGetNamedRenderbufferParameteriv (GLuint renderbuffer, GLenum pname, GLint *params); GLAPI void APIENTRY glCreateTextures (GLenum target, GLsizei n, GLuint *textures); GLAPI void APIENTRY glTextureBuffer (GLuint texture, GLenum internalformat, GLuint buffer); GLAPI void APIENTRY glTextureBufferRange (GLuint texture, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size); GLAPI void APIENTRY glTextureStorage1D (GLuint texture, GLsizei levels, GLenum internalformat, GLsizei width); GLAPI void APIENTRY glTextureStorage2D (GLuint texture, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); GLAPI void APIENTRY glTextureStorage3D (GLuint texture, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); GLAPI void APIENTRY glTextureStorage2DMultisample (GLuint texture, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); GLAPI void APIENTRY glTextureStorage3DMultisample (GLuint texture, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); GLAPI void APIENTRY glTextureSubImage1D (GLuint texture, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const void *pixels); GLAPI void APIENTRY glTextureSubImage2D (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels); GLAPI void APIENTRY glTextureSubImage3D (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels); GLAPI void APIENTRY glCompressedTextureSubImage1D (GLuint texture, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void *data); GLAPI void APIENTRY glCompressedTextureSubImage2D (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *data); GLAPI void APIENTRY glCompressedTextureSubImage3D (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *data); GLAPI void APIENTRY glCopyTextureSubImage1D (GLuint texture, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); GLAPI void APIENTRY glCopyTextureSubImage2D (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); GLAPI void APIENTRY glCopyTextureSubImage3D (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); GLAPI void APIENTRY glTextureParameterf (GLuint texture, GLenum pname, GLfloat param); GLAPI void APIENTRY glTextureParameterfv (GLuint texture, GLenum pname, const GLfloat *param); GLAPI void APIENTRY glTextureParameteri (GLuint texture, GLenum pname, GLint param); GLAPI void APIENTRY glTextureParameterIiv (GLuint texture, GLenum pname, const GLint *params); GLAPI void APIENTRY glTextureParameterIuiv (GLuint texture, GLenum pname, const GLuint *params); GLAPI void APIENTRY glTextureParameteriv (GLuint texture, GLenum pname, const GLint *param); GLAPI void APIENTRY glGenerateTextureMipmap (GLuint texture); GLAPI void APIENTRY glBindTextureUnit (GLuint unit, GLuint texture); GLAPI void APIENTRY glGetTextureImage (GLuint texture, GLint level, GLenum format, GLenum type, GLsizei bufSize, void *pixels); GLAPI void APIENTRY glGetCompressedTextureImage (GLuint texture, GLint level, GLsizei bufSize, void *pixels); GLAPI void APIENTRY glGetTextureLevelParameterfv (GLuint texture, GLint level, GLenum pname, GLfloat *params); GLAPI void APIENTRY glGetTextureLevelParameteriv (GLuint texture, GLint level, GLenum pname, GLint *params); GLAPI void APIENTRY glGetTextureParameterfv (GLuint texture, GLenum pname, GLfloat *params); GLAPI void APIENTRY glGetTextureParameterIiv (GLuint texture, GLenum pname, GLint *params); GLAPI void APIENTRY glGetTextureParameterIuiv (GLuint texture, GLenum pname, GLuint *params); GLAPI void APIENTRY glGetTextureParameteriv (GLuint texture, GLenum pname, GLint *params); GLAPI void APIENTRY glCreateVertexArrays (GLsizei n, GLuint *arrays); GLAPI void APIENTRY glDisableVertexArrayAttrib (GLuint vaobj, GLuint index); GLAPI void APIENTRY glEnableVertexArrayAttrib (GLuint vaobj, GLuint index); GLAPI void APIENTRY glVertexArrayElementBuffer (GLuint vaobj, GLuint buffer); GLAPI void APIENTRY glVertexArrayVertexBuffer (GLuint vaobj, GLuint bindingindex, GLuint buffer, GLintptr offset, GLsizei stride); GLAPI void APIENTRY glVertexArrayVertexBuffers (GLuint vaobj, GLuint first, GLsizei count, const GLuint *buffers, const GLintptr *offsets, const GLsizei *strides); GLAPI void APIENTRY glVertexArrayAttribBinding (GLuint vaobj, GLuint attribindex, GLuint bindingindex); GLAPI void APIENTRY glVertexArrayAttribFormat (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLboolean normalized, GLuint relativeoffset); GLAPI void APIENTRY glVertexArrayAttribIFormat (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); GLAPI void APIENTRY glVertexArrayAttribLFormat (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); GLAPI void APIENTRY glVertexArrayBindingDivisor (GLuint vaobj, GLuint bindingindex, GLuint divisor); GLAPI void APIENTRY glGetVertexArrayiv (GLuint vaobj, GLenum pname, GLint *param); GLAPI void APIENTRY glGetVertexArrayIndexediv (GLuint vaobj, GLuint index, GLenum pname, GLint *param); GLAPI void APIENTRY glGetVertexArrayIndexed64iv (GLuint vaobj, GLuint index, GLenum pname, GLint64 *param); GLAPI void APIENTRY glCreateSamplers (GLsizei n, GLuint *samplers); GLAPI void APIENTRY glCreateProgramPipelines (GLsizei n, GLuint *pipelines); GLAPI void APIENTRY glCreateQueries (GLenum target, GLsizei n, GLuint *ids); GLAPI void APIENTRY glGetQueryBufferObjecti64v (GLuint id, GLuint buffer, GLenum pname, GLintptr offset); GLAPI void APIENTRY glGetQueryBufferObjectiv (GLuint id, GLuint buffer, GLenum pname, GLintptr offset); GLAPI void APIENTRY glGetQueryBufferObjectui64v (GLuint id, GLuint buffer, GLenum pname, GLintptr offset); GLAPI void APIENTRY glGetQueryBufferObjectuiv (GLuint id, GLuint buffer, GLenum pname, GLintptr offset); GLAPI void APIENTRY glMemoryBarrierByRegion (GLbitfield barriers); GLAPI void APIENTRY glGetTextureSubImage (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, GLsizei bufSize, void *pixels); GLAPI void APIENTRY glGetCompressedTextureSubImage (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLsizei bufSize, void *pixels); GLAPI GLenum APIENTRY glGetGraphicsResetStatus (void); GLAPI void APIENTRY glGetnCompressedTexImage (GLenum target, GLint lod, GLsizei bufSize, void *pixels); GLAPI void APIENTRY glGetnTexImage (GLenum target, GLint level, GLenum format, GLenum type, GLsizei bufSize, void *pixels); GLAPI void APIENTRY glGetnUniformdv (GLuint program, GLint location, GLsizei bufSize, GLdouble *params); GLAPI void APIENTRY glGetnUniformfv (GLuint program, GLint location, GLsizei bufSize, GLfloat *params); GLAPI void APIENTRY glGetnUniformiv (GLuint program, GLint location, GLsizei bufSize, GLint *params); GLAPI void APIENTRY glGetnUniformuiv (GLuint program, GLint location, GLsizei bufSize, GLuint *params); GLAPI void APIENTRY glReadnPixels (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei bufSize, void *data); GLAPI void APIENTRY glGetnMapdv (GLenum target, GLenum query, GLsizei bufSize, GLdouble *v); GLAPI void APIENTRY glGetnMapfv (GLenum target, GLenum query, GLsizei bufSize, GLfloat *v); GLAPI void APIENTRY glGetnMapiv (GLenum target, GLenum query, GLsizei bufSize, GLint *v); GLAPI void APIENTRY glGetnPixelMapfv (GLenum map, GLsizei bufSize, GLfloat *values); GLAPI void APIENTRY glGetnPixelMapuiv (GLenum map, GLsizei bufSize, GLuint *values); GLAPI void APIENTRY glGetnPixelMapusv (GLenum map, GLsizei bufSize, GLushort *values); GLAPI void APIENTRY glGetnPolygonStipple (GLsizei bufSize, GLubyte *pattern); GLAPI void APIENTRY glGetnColorTable (GLenum target, GLenum format, GLenum type, GLsizei bufSize, void *table); GLAPI void APIENTRY glGetnConvolutionFilter (GLenum target, GLenum format, GLenum type, GLsizei bufSize, void *image); GLAPI void APIENTRY glGetnSeparableFilter (GLenum target, GLenum format, GLenum type, GLsizei rowBufSize, void *row, GLsizei columnBufSize, void *column, void *span); GLAPI void APIENTRY glGetnHistogram (GLenum target, GLboolean reset, GLenum format, GLenum type, GLsizei bufSize, void *values); GLAPI void APIENTRY glGetnMinmax (GLenum target, GLboolean reset, GLenum format, GLenum type, GLsizei bufSize, void *values); GLAPI void APIENTRY glTextureBarrier (void); #endif #endif /* GL_VERSION_4_5 */ #ifndef GL_VERSION_4_6 #define GL_VERSION_4_6 1 #define GL_SHADER_BINARY_FORMAT_SPIR_V 0x9551 #define GL_SPIR_V_BINARY 0x9552 #define GL_PARAMETER_BUFFER 0x80EE #define GL_PARAMETER_BUFFER_BINDING 0x80EF #define GL_CONTEXT_FLAG_NO_ERROR_BIT 0x00000008 #define GL_VERTICES_SUBMITTED 0x82EE #define GL_PRIMITIVES_SUBMITTED 0x82EF #define GL_VERTEX_SHADER_INVOCATIONS 0x82F0 #define GL_TESS_CONTROL_SHADER_PATCHES 0x82F1 #define GL_TESS_EVALUATION_SHADER_INVOCATIONS 0x82F2 #define GL_GEOMETRY_SHADER_PRIMITIVES_EMITTED 0x82F3 #define GL_FRAGMENT_SHADER_INVOCATIONS 0x82F4 #define GL_COMPUTE_SHADER_INVOCATIONS 0x82F5 #define GL_CLIPPING_INPUT_PRIMITIVES 0x82F6 #define GL_CLIPPING_OUTPUT_PRIMITIVES 0x82F7 #define GL_POLYGON_OFFSET_CLAMP 0x8E1B #define GL_SPIR_V_EXTENSIONS 0x9553 #define GL_NUM_SPIR_V_EXTENSIONS 0x9554 #define GL_TEXTURE_MAX_ANISOTROPY 0x84FE #define GL_MAX_TEXTURE_MAX_ANISOTROPY 0x84FF #define GL_TRANSFORM_FEEDBACK_OVERFLOW 0x82EC #define GL_TRANSFORM_FEEDBACK_STREAM_OVERFLOW 0x82ED typedef void (APIENTRYP PFNGLSPECIALIZESHADERPROC) (GLuint shader, const GLchar *pEntryPoint, GLuint numSpecializationConstants, const GLuint *pConstantIndex, const GLuint *pConstantValue); typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSINDIRECTCOUNTPROC) (GLenum mode, const void *indirect, GLintptr drawcount, GLsizei maxdrawcount, GLsizei stride); typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSINDIRECTCOUNTPROC) (GLenum mode, GLenum type, const void *indirect, GLintptr drawcount, GLsizei maxdrawcount, GLsizei stride); typedef void (APIENTRYP PFNGLPOLYGONOFFSETCLAMPPROC) (GLfloat factor, GLfloat units, GLfloat clamp); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glSpecializeShader (GLuint shader, const GLchar *pEntryPoint, GLuint numSpecializationConstants, const GLuint *pConstantIndex, const GLuint *pConstantValue); GLAPI void APIENTRY glMultiDrawArraysIndirectCount (GLenum mode, const void *indirect, GLintptr drawcount, GLsizei maxdrawcount, GLsizei stride); GLAPI void APIENTRY glMultiDrawElementsIndirectCount (GLenum mode, GLenum type, const void *indirect, GLintptr drawcount, GLsizei maxdrawcount, GLsizei stride); GLAPI void APIENTRY glPolygonOffsetClamp (GLfloat factor, GLfloat units, GLfloat clamp); #endif #endif /* GL_VERSION_4_6 */ #ifndef GL_ARB_ES2_compatibility #define GL_ARB_ES2_compatibility 1 #endif /* GL_ARB_ES2_compatibility */ #ifndef GL_ARB_ES3_1_compatibility #define GL_ARB_ES3_1_compatibility 1 #endif /* GL_ARB_ES3_1_compatibility */ #ifndef GL_ARB_ES3_2_compatibility #define GL_ARB_ES3_2_compatibility 1 #define GL_PRIMITIVE_BOUNDING_BOX_ARB 0x92BE #define GL_MULTISAMPLE_LINE_WIDTH_RANGE_ARB 0x9381 #define GL_MULTISAMPLE_LINE_WIDTH_GRANULARITY_ARB 0x9382 typedef void (APIENTRYP PFNGLPRIMITIVEBOUNDINGBOXARBPROC) (GLfloat minX, GLfloat minY, GLfloat minZ, GLfloat minW, GLfloat maxX, GLfloat maxY, GLfloat maxZ, GLfloat maxW); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glPrimitiveBoundingBoxARB (GLfloat minX, GLfloat minY, GLfloat minZ, GLfloat minW, GLfloat maxX, GLfloat maxY, GLfloat maxZ, GLfloat maxW); #endif #endif /* GL_ARB_ES3_2_compatibility */ #ifndef GL_ARB_ES3_compatibility #define GL_ARB_ES3_compatibility 1 #endif /* GL_ARB_ES3_compatibility */ #ifndef GL_ARB_arrays_of_arrays #define GL_ARB_arrays_of_arrays 1 #endif /* GL_ARB_arrays_of_arrays */ #ifndef GL_ARB_base_instance #define GL_ARB_base_instance 1 #endif /* GL_ARB_base_instance */ #ifndef GL_ARB_bindless_texture #define GL_ARB_bindless_texture 1 typedef khronos_uint64_t GLuint64EXT; #define GL_UNSIGNED_INT64_ARB 0x140F typedef GLuint64 (APIENTRYP PFNGLGETTEXTUREHANDLEARBPROC) (GLuint texture); typedef GLuint64 (APIENTRYP PFNGLGETTEXTURESAMPLERHANDLEARBPROC) (GLuint texture, GLuint sampler); typedef void (APIENTRYP PFNGLMAKETEXTUREHANDLERESIDENTARBPROC) (GLuint64 handle); typedef void (APIENTRYP PFNGLMAKETEXTUREHANDLENONRESIDENTARBPROC) (GLuint64 handle); typedef GLuint64 (APIENTRYP PFNGLGETIMAGEHANDLEARBPROC) (GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum format); typedef void (APIENTRYP PFNGLMAKEIMAGEHANDLERESIDENTARBPROC) (GLuint64 handle, GLenum access); typedef void (APIENTRYP PFNGLMAKEIMAGEHANDLENONRESIDENTARBPROC) (GLuint64 handle); typedef void (APIENTRYP PFNGLUNIFORMHANDLEUI64ARBPROC) (GLint location, GLuint64 value); typedef void (APIENTRYP PFNGLUNIFORMHANDLEUI64VARBPROC) (GLint location, GLsizei count, const GLuint64 *value); typedef void (APIENTRYP PFNGLPROGRAMUNIFORMHANDLEUI64ARBPROC) (GLuint program, GLint location, GLuint64 value); typedef void (APIENTRYP PFNGLPROGRAMUNIFORMHANDLEUI64VARBPROC) (GLuint program, GLint location, GLsizei count, const GLuint64 *values); typedef GLboolean (APIENTRYP PFNGLISTEXTUREHANDLERESIDENTARBPROC) (GLuint64 handle); typedef GLboolean (APIENTRYP PFNGLISIMAGEHANDLERESIDENTARBPROC) (GLuint64 handle); typedef void (APIENTRYP PFNGLVERTEXATTRIBL1UI64ARBPROC) (GLuint index, GLuint64EXT x); typedef void (APIENTRYP PFNGLVERTEXATTRIBL1UI64VARBPROC) (GLuint index, const GLuint64EXT *v); typedef void (APIENTRYP PFNGLGETVERTEXATTRIBLUI64VARBPROC) (GLuint index, GLenum pname, GLuint64EXT *params); #ifdef GL_GLEXT_PROTOTYPES GLAPI GLuint64 APIENTRY glGetTextureHandleARB (GLuint texture); GLAPI GLuint64 APIENTRY glGetTextureSamplerHandleARB (GLuint texture, GLuint sampler); GLAPI void APIENTRY glMakeTextureHandleResidentARB (GLuint64 handle); GLAPI void APIENTRY glMakeTextureHandleNonResidentARB (GLuint64 handle); GLAPI GLuint64 APIENTRY glGetImageHandleARB (GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum format); GLAPI void APIENTRY glMakeImageHandleResidentARB (GLuint64 handle, GLenum access); GLAPI void APIENTRY glMakeImageHandleNonResidentARB (GLuint64 handle); GLAPI void APIENTRY glUniformHandleui64ARB (GLint location, GLuint64 value); GLAPI void APIENTRY glUniformHandleui64vARB (GLint location, GLsizei count, const GLuint64 *value); GLAPI void APIENTRY glProgramUniformHandleui64ARB (GLuint program, GLint location, GLuint64 value); GLAPI void APIENTRY glProgramUniformHandleui64vARB (GLuint program, GLint location, GLsizei count, const GLuint64 *values); GLAPI GLboolean APIENTRY glIsTextureHandleResidentARB (GLuint64 handle); GLAPI GLboolean APIENTRY glIsImageHandleResidentARB (GLuint64 handle); GLAPI void APIENTRY glVertexAttribL1ui64ARB (GLuint index, GLuint64EXT x); GLAPI void APIENTRY glVertexAttribL1ui64vARB (GLuint index, const GLuint64EXT *v); GLAPI void APIENTRY glGetVertexAttribLui64vARB (GLuint index, GLenum pname, GLuint64EXT *params); #endif #endif /* GL_ARB_bindless_texture */ #ifndef GL_ARB_blend_func_extended #define GL_ARB_blend_func_extended 1 #endif /* GL_ARB_blend_func_extended */ #ifndef GL_ARB_buffer_storage #define GL_ARB_buffer_storage 1 #endif /* GL_ARB_buffer_storage */ #ifndef GL_ARB_cl_event #define GL_ARB_cl_event 1 struct _cl_context; struct _cl_event; #define GL_SYNC_CL_EVENT_ARB 0x8240 #define GL_SYNC_CL_EVENT_COMPLETE_ARB 0x8241 typedef GLsync (APIENTRYP PFNGLCREATESYNCFROMCLEVENTARBPROC) (struct _cl_context *context, struct _cl_event *event, GLbitfield flags); #ifdef GL_GLEXT_PROTOTYPES GLAPI GLsync APIENTRY glCreateSyncFromCLeventARB (struct _cl_context *context, struct _cl_event *event, GLbitfield flags); #endif #endif /* GL_ARB_cl_event */ #ifndef GL_ARB_clear_buffer_object #define GL_ARB_clear_buffer_object 1 #endif /* GL_ARB_clear_buffer_object */ #ifndef GL_ARB_clear_texture #define GL_ARB_clear_texture 1 #endif /* GL_ARB_clear_texture */ #ifndef GL_ARB_clip_control #define GL_ARB_clip_control 1 #endif /* GL_ARB_clip_control */ #ifndef GL_ARB_color_buffer_float #define GL_ARB_color_buffer_float 1 #define GL_RGBA_FLOAT_MODE_ARB 0x8820 #define GL_CLAMP_VERTEX_COLOR_ARB 0x891A #define GL_CLAMP_FRAGMENT_COLOR_ARB 0x891B #define GL_CLAMP_READ_COLOR_ARB 0x891C #define GL_FIXED_ONLY_ARB 0x891D typedef void (APIENTRYP PFNGLCLAMPCOLORARBPROC) (GLenum target, GLenum clamp); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glClampColorARB (GLenum target, GLenum clamp); #endif #endif /* GL_ARB_color_buffer_float */ #ifndef GL_ARB_compatibility #define GL_ARB_compatibility 1 #endif /* GL_ARB_compatibility */ #ifndef GL_ARB_compressed_texture_pixel_storage #define GL_ARB_compressed_texture_pixel_storage 1 #endif /* GL_ARB_compressed_texture_pixel_storage */ #ifndef GL_ARB_compute_shader #define GL_ARB_compute_shader 1 #endif /* GL_ARB_compute_shader */ #ifndef GL_ARB_compute_variable_group_size #define GL_ARB_compute_variable_group_size 1 #define GL_MAX_COMPUTE_VARIABLE_GROUP_INVOCATIONS_ARB 0x9344 #define GL_MAX_COMPUTE_FIXED_GROUP_INVOCATIONS_ARB 0x90EB #define GL_MAX_COMPUTE_VARIABLE_GROUP_SIZE_ARB 0x9345 #define GL_MAX_COMPUTE_FIXED_GROUP_SIZE_ARB 0x91BF typedef void (APIENTRYP PFNGLDISPATCHCOMPUTEGROUPSIZEARBPROC) (GLuint num_groups_x, GLuint num_groups_y, GLuint num_groups_z, GLuint group_size_x, GLuint group_size_y, GLuint group_size_z); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glDispatchComputeGroupSizeARB (GLuint num_groups_x, GLuint num_groups_y, GLuint num_groups_z, GLuint group_size_x, GLuint group_size_y, GLuint group_size_z); #endif #endif /* GL_ARB_compute_variable_group_size */ #ifndef GL_ARB_conditional_render_inverted #define GL_ARB_conditional_render_inverted 1 #endif /* GL_ARB_conditional_render_inverted */ #ifndef GL_ARB_conservative_depth #define GL_ARB_conservative_depth 1 #endif /* GL_ARB_conservative_depth */ #ifndef GL_ARB_copy_buffer #define GL_ARB_copy_buffer 1 #endif /* GL_ARB_copy_buffer */ #ifndef GL_ARB_copy_image #define GL_ARB_copy_image 1 #endif /* GL_ARB_copy_image */ #ifndef GL_ARB_cull_distance #define GL_ARB_cull_distance 1 #endif /* GL_ARB_cull_distance */ #ifndef GL_ARB_debug_output #define GL_ARB_debug_output 1 typedef void (APIENTRY *GLDEBUGPROCARB)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,const void *userParam); #define GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB 0x8242 #define GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH_ARB 0x8243 #define GL_DEBUG_CALLBACK_FUNCTION_ARB 0x8244 #define GL_DEBUG_CALLBACK_USER_PARAM_ARB 0x8245 #define GL_DEBUG_SOURCE_API_ARB 0x8246 #define GL_DEBUG_SOURCE_WINDOW_SYSTEM_ARB 0x8247 #define GL_DEBUG_SOURCE_SHADER_COMPILER_ARB 0x8248 #define GL_DEBUG_SOURCE_THIRD_PARTY_ARB 0x8249 #define GL_DEBUG_SOURCE_APPLICATION_ARB 0x824A #define GL_DEBUG_SOURCE_OTHER_ARB 0x824B #define GL_DEBUG_TYPE_ERROR_ARB 0x824C #define GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR_ARB 0x824D #define GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR_ARB 0x824E #define GL_DEBUG_TYPE_PORTABILITY_ARB 0x824F #define GL_DEBUG_TYPE_PERFORMANCE_ARB 0x8250 #define GL_DEBUG_TYPE_OTHER_ARB 0x8251 #define GL_MAX_DEBUG_MESSAGE_LENGTH_ARB 0x9143 #define GL_MAX_DEBUG_LOGGED_MESSAGES_ARB 0x9144 #define GL_DEBUG_LOGGED_MESSAGES_ARB 0x9145 #define GL_DEBUG_SEVERITY_HIGH_ARB 0x9146 #define GL_DEBUG_SEVERITY_MEDIUM_ARB 0x9147 #define GL_DEBUG_SEVERITY_LOW_ARB 0x9148 typedef void (APIENTRYP PFNGLDEBUGMESSAGECONTROLARBPROC) (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); typedef void (APIENTRYP PFNGLDEBUGMESSAGEINSERTARBPROC) (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf); typedef void (APIENTRYP PFNGLDEBUGMESSAGECALLBACKARBPROC) (GLDEBUGPROCARB callback, const void *userParam); typedef GLuint (APIENTRYP PFNGLGETDEBUGMESSAGELOGARBPROC) (GLuint count, GLsizei bufSize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glDebugMessageControlARB (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); GLAPI void APIENTRY glDebugMessageInsertARB (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf); GLAPI void APIENTRY glDebugMessageCallbackARB (GLDEBUGPROCARB callback, const void *userParam); GLAPI GLuint APIENTRY glGetDebugMessageLogARB (GLuint count, GLsizei bufSize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog); #endif #endif /* GL_ARB_debug_output */ #ifndef GL_ARB_depth_buffer_float #define GL_ARB_depth_buffer_float 1 #endif /* GL_ARB_depth_buffer_float */ #ifndef GL_ARB_depth_clamp #define GL_ARB_depth_clamp 1 #endif /* GL_ARB_depth_clamp */ #ifndef GL_ARB_depth_texture #define GL_ARB_depth_texture 1 #define GL_DEPTH_COMPONENT16_ARB 0x81A5 #define GL_DEPTH_COMPONENT24_ARB 0x81A6 #define GL_DEPTH_COMPONENT32_ARB 0x81A7 #define GL_TEXTURE_DEPTH_SIZE_ARB 0x884A #define GL_DEPTH_TEXTURE_MODE_ARB 0x884B #endif /* GL_ARB_depth_texture */ #ifndef GL_ARB_derivative_control #define GL_ARB_derivative_control 1 #endif /* GL_ARB_derivative_control */ #ifndef GL_ARB_direct_state_access #define GL_ARB_direct_state_access 1 #endif /* GL_ARB_direct_state_access */ #ifndef GL_ARB_draw_buffers #define GL_ARB_draw_buffers 1 #define GL_MAX_DRAW_BUFFERS_ARB 0x8824 #define GL_DRAW_BUFFER0_ARB 0x8825 #define GL_DRAW_BUFFER1_ARB 0x8826 #define GL_DRAW_BUFFER2_ARB 0x8827 #define GL_DRAW_BUFFER3_ARB 0x8828 #define GL_DRAW_BUFFER4_ARB 0x8829 #define GL_DRAW_BUFFER5_ARB 0x882A #define GL_DRAW_BUFFER6_ARB 0x882B #define GL_DRAW_BUFFER7_ARB 0x882C #define GL_DRAW_BUFFER8_ARB 0x882D #define GL_DRAW_BUFFER9_ARB 0x882E #define GL_DRAW_BUFFER10_ARB 0x882F #define GL_DRAW_BUFFER11_ARB 0x8830 #define GL_DRAW_BUFFER12_ARB 0x8831 #define GL_DRAW_BUFFER13_ARB 0x8832 #define GL_DRAW_BUFFER14_ARB 0x8833 #define GL_DRAW_BUFFER15_ARB 0x8834 typedef void (APIENTRYP PFNGLDRAWBUFFERSARBPROC) (GLsizei n, const GLenum *bufs); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glDrawBuffersARB (GLsizei n, const GLenum *bufs); #endif #endif /* GL_ARB_draw_buffers */ #ifndef GL_ARB_draw_buffers_blend #define GL_ARB_draw_buffers_blend 1 typedef void (APIENTRYP PFNGLBLENDEQUATIONIARBPROC) (GLuint buf, GLenum mode); typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEIARBPROC) (GLuint buf, GLenum modeRGB, GLenum modeAlpha); typedef void (APIENTRYP PFNGLBLENDFUNCIARBPROC) (GLuint buf, GLenum src, GLenum dst); typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEIARBPROC) (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glBlendEquationiARB (GLuint buf, GLenum mode); GLAPI void APIENTRY glBlendEquationSeparateiARB (GLuint buf, GLenum modeRGB, GLenum modeAlpha); GLAPI void APIENTRY glBlendFunciARB (GLuint buf, GLenum src, GLenum dst); GLAPI void APIENTRY glBlendFuncSeparateiARB (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); #endif #endif /* GL_ARB_draw_buffers_blend */ #ifndef GL_ARB_draw_elements_base_vertex #define GL_ARB_draw_elements_base_vertex 1 #endif /* GL_ARB_draw_elements_base_vertex */ #ifndef GL_ARB_draw_indirect #define GL_ARB_draw_indirect 1 #endif /* GL_ARB_draw_indirect */ #ifndef GL_ARB_draw_instanced #define GL_ARB_draw_instanced 1 typedef void (APIENTRYP PFNGLDRAWARRAYSINSTANCEDARBPROC) (GLenum mode, GLint first, GLsizei count, GLsizei primcount); typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDARBPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glDrawArraysInstancedARB (GLenum mode, GLint first, GLsizei count, GLsizei primcount); GLAPI void APIENTRY glDrawElementsInstancedARB (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount); #endif #endif /* GL_ARB_draw_instanced */ #ifndef GL_ARB_enhanced_layouts #define GL_ARB_enhanced_layouts 1 #endif /* GL_ARB_enhanced_layouts */ #ifndef GL_ARB_explicit_attrib_location #define GL_ARB_explicit_attrib_location 1 #endif /* GL_ARB_explicit_attrib_location */ #ifndef GL_ARB_explicit_uniform_location #define GL_ARB_explicit_uniform_location 1 #endif /* GL_ARB_explicit_uniform_location */ #ifndef GL_ARB_fragment_coord_conventions #define GL_ARB_fragment_coord_conventions 1 #endif /* GL_ARB_fragment_coord_conventions */ #ifndef GL_ARB_fragment_layer_viewport #define GL_ARB_fragment_layer_viewport 1 #endif /* GL_ARB_fragment_layer_viewport */ #ifndef GL_ARB_fragment_program #define GL_ARB_fragment_program 1 #define GL_FRAGMENT_PROGRAM_ARB 0x8804 #define GL_PROGRAM_FORMAT_ASCII_ARB 0x8875 #define GL_PROGRAM_LENGTH_ARB 0x8627 #define GL_PROGRAM_FORMAT_ARB 0x8876 #define GL_PROGRAM_BINDING_ARB 0x8677 #define GL_PROGRAM_INSTRUCTIONS_ARB 0x88A0 #define GL_MAX_PROGRAM_INSTRUCTIONS_ARB 0x88A1 #define GL_PROGRAM_NATIVE_INSTRUCTIONS_ARB 0x88A2 #define GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB 0x88A3 #define GL_PROGRAM_TEMPORARIES_ARB 0x88A4 #define GL_MAX_PROGRAM_TEMPORARIES_ARB 0x88A5 #define GL_PROGRAM_NATIVE_TEMPORARIES_ARB 0x88A6 #define GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB 0x88A7 #define GL_PROGRAM_PARAMETERS_ARB 0x88A8 #define GL_MAX_PROGRAM_PARAMETERS_ARB 0x88A9 #define GL_PROGRAM_NATIVE_PARAMETERS_ARB 0x88AA #define GL_MAX_PROGRAM_NATIVE_PARAMETERS_ARB 0x88AB #define GL_PROGRAM_ATTRIBS_ARB 0x88AC #define GL_MAX_PROGRAM_ATTRIBS_ARB 0x88AD #define GL_PROGRAM_NATIVE_ATTRIBS_ARB 0x88AE #define GL_MAX_PROGRAM_NATIVE_ATTRIBS_ARB 0x88AF #define GL_MAX_PROGRAM_LOCAL_PARAMETERS_ARB 0x88B4 #define GL_MAX_PROGRAM_ENV_PARAMETERS_ARB 0x88B5 #define GL_PROGRAM_UNDER_NATIVE_LIMITS_ARB 0x88B6 #define GL_PROGRAM_ALU_INSTRUCTIONS_ARB 0x8805 #define GL_PROGRAM_TEX_INSTRUCTIONS_ARB 0x8806 #define GL_PROGRAM_TEX_INDIRECTIONS_ARB 0x8807 #define GL_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB 0x8808 #define GL_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB 0x8809 #define GL_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB 0x880A #define GL_MAX_PROGRAM_ALU_INSTRUCTIONS_ARB 0x880B #define GL_MAX_PROGRAM_TEX_INSTRUCTIONS_ARB 0x880C #define GL_MAX_PROGRAM_TEX_INDIRECTIONS_ARB 0x880D #define GL_MAX_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB 0x880E #define GL_MAX_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB 0x880F #define GL_MAX_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB 0x8810 #define GL_PROGRAM_STRING_ARB 0x8628 #define GL_PROGRAM_ERROR_POSITION_ARB 0x864B #define GL_CURRENT_MATRIX_ARB 0x8641 #define GL_TRANSPOSE_CURRENT_MATRIX_ARB 0x88B7 #define GL_CURRENT_MATRIX_STACK_DEPTH_ARB 0x8640 #define GL_MAX_PROGRAM_MATRICES_ARB 0x862F #define GL_MAX_PROGRAM_MATRIX_STACK_DEPTH_ARB 0x862E #define GL_MAX_TEXTURE_COORDS_ARB 0x8871 #define GL_MAX_TEXTURE_IMAGE_UNITS_ARB 0x8872 #define GL_PROGRAM_ERROR_STRING_ARB 0x8874 #define GL_MATRIX0_ARB 0x88C0 #define GL_MATRIX1_ARB 0x88C1 #define GL_MATRIX2_ARB 0x88C2 #define GL_MATRIX3_ARB 0x88C3 #define GL_MATRIX4_ARB 0x88C4 #define GL_MATRIX5_ARB 0x88C5 #define GL_MATRIX6_ARB 0x88C6 #define GL_MATRIX7_ARB 0x88C7 #define GL_MATRIX8_ARB 0x88C8 #define GL_MATRIX9_ARB 0x88C9 #define GL_MATRIX10_ARB 0x88CA #define GL_MATRIX11_ARB 0x88CB #define GL_MATRIX12_ARB 0x88CC #define GL_MATRIX13_ARB 0x88CD #define GL_MATRIX14_ARB 0x88CE #define GL_MATRIX15_ARB 0x88CF #define GL_MATRIX16_ARB 0x88D0 #define GL_MATRIX17_ARB 0x88D1 #define GL_MATRIX18_ARB 0x88D2 #define GL_MATRIX19_ARB 0x88D3 #define GL_MATRIX20_ARB 0x88D4 #define GL_MATRIX21_ARB 0x88D5 #define GL_MATRIX22_ARB 0x88D6 #define GL_MATRIX23_ARB 0x88D7 #define GL_MATRIX24_ARB 0x88D8 #define GL_MATRIX25_ARB 0x88D9 #define GL_MATRIX26_ARB 0x88DA #define GL_MATRIX27_ARB 0x88DB #define GL_MATRIX28_ARB 0x88DC #define GL_MATRIX29_ARB 0x88DD #define GL_MATRIX30_ARB 0x88DE #define GL_MATRIX31_ARB 0x88DF typedef void (APIENTRYP PFNGLPROGRAMSTRINGARBPROC) (GLenum target, GLenum format, GLsizei len, const void *string); typedef void (APIENTRYP PFNGLBINDPROGRAMARBPROC) (GLenum target, GLuint program); typedef void (APIENTRYP PFNGLDELETEPROGRAMSARBPROC) (GLsizei n, const GLuint *programs); typedef void (APIENTRYP PFNGLGENPROGRAMSARBPROC) (GLsizei n, GLuint *programs); typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4DARBPROC) (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4DVARBPROC) (GLenum target, GLuint index, const GLdouble *params); typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4FARBPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4FVARBPROC) (GLenum target, GLuint index, const GLfloat *params); typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4DARBPROC) (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4DVARBPROC) (GLenum target, GLuint index, const GLdouble *params); typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4FARBPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4FVARBPROC) (GLenum target, GLuint index, const GLfloat *params); typedef void (APIENTRYP PFNGLGETPROGRAMENVPARAMETERDVARBPROC) (GLenum target, GLuint index, GLdouble *params); typedef void (APIENTRYP PFNGLGETPROGRAMENVPARAMETERFVARBPROC) (GLenum target, GLuint index, GLfloat *params); typedef void (APIENTRYP PFNGLGETPROGRAMLOCALPARAMETERDVARBPROC) (GLenum target, GLuint index, GLdouble *params); typedef void (APIENTRYP PFNGLGETPROGRAMLOCALPARAMETERFVARBPROC) (GLenum target, GLuint index, GLfloat *params); typedef void (APIENTRYP PFNGLGETPROGRAMIVARBPROC) (GLenum target, GLenum pname, GLint *params); typedef void (APIENTRYP PFNGLGETPROGRAMSTRINGARBPROC) (GLenum target, GLenum pname, void *string); typedef GLboolean (APIENTRYP PFNGLISPROGRAMARBPROC) (GLuint program); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glProgramStringARB (GLenum target, GLenum format, GLsizei len, const void *string); GLAPI void APIENTRY glBindProgramARB (GLenum target, GLuint program); GLAPI void APIENTRY glDeleteProgramsARB (GLsizei n, const GLuint *programs); GLAPI void APIENTRY glGenProgramsARB (GLsizei n, GLuint *programs); GLAPI void APIENTRY glProgramEnvParameter4dARB (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); GLAPI void APIENTRY glProgramEnvParameter4dvARB (GLenum target, GLuint index, const GLdouble *params); GLAPI void APIENTRY glProgramEnvParameter4fARB (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); GLAPI void APIENTRY glProgramEnvParameter4fvARB (GLenum target, GLuint index, const GLfloat *params); GLAPI void APIENTRY glProgramLocalParameter4dARB (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); GLAPI void APIENTRY glProgramLocalParameter4dvARB (GLenum target, GLuint index, const GLdouble *params); GLAPI void APIENTRY glProgramLocalParameter4fARB (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); GLAPI void APIENTRY glProgramLocalParameter4fvARB (GLenum target, GLuint index, const GLfloat *params); GLAPI void APIENTRY glGetProgramEnvParameterdvARB (GLenum target, GLuint index, GLdouble *params); GLAPI void APIENTRY glGetProgramEnvParameterfvARB (GLenum target, GLuint index, GLfloat *params); GLAPI void APIENTRY glGetProgramLocalParameterdvARB (GLenum target, GLuint index, GLdouble *params); GLAPI void APIENTRY glGetProgramLocalParameterfvARB (GLenum target, GLuint index, GLfloat *params); GLAPI void APIENTRY glGetProgramivARB (GLenum target, GLenum pname, GLint *params); GLAPI void APIENTRY glGetProgramStringARB (GLenum target, GLenum pname, void *string); GLAPI GLboolean APIENTRY glIsProgramARB (GLuint program); #endif #endif /* GL_ARB_fragment_program */ #ifndef GL_ARB_fragment_program_shadow #define GL_ARB_fragment_program_shadow 1 #endif /* GL_ARB_fragment_program_shadow */ #ifndef GL_ARB_fragment_shader #define GL_ARB_fragment_shader 1 #define GL_FRAGMENT_SHADER_ARB 0x8B30 #define GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB 0x8B49 #define GL_FRAGMENT_SHADER_DERIVATIVE_HINT_ARB 0x8B8B #endif /* GL_ARB_fragment_shader */ #ifndef GL_ARB_fragment_shader_interlock #define GL_ARB_fragment_shader_interlock 1 #endif /* GL_ARB_fragment_shader_interlock */ #ifndef GL_ARB_framebuffer_no_attachments #define GL_ARB_framebuffer_no_attachments 1 #endif /* GL_ARB_framebuffer_no_attachments */ #ifndef GL_ARB_framebuffer_object #define GL_ARB_framebuffer_object 1 #endif /* GL_ARB_framebuffer_object */ #ifndef GL_ARB_framebuffer_sRGB #define GL_ARB_framebuffer_sRGB 1 #endif /* GL_ARB_framebuffer_sRGB */ #ifndef GL_ARB_geometry_shader4 #define GL_ARB_geometry_shader4 1 #define GL_LINES_ADJACENCY_ARB 0x000A #define GL_LINE_STRIP_ADJACENCY_ARB 0x000B #define GL_TRIANGLES_ADJACENCY_ARB 0x000C #define GL_TRIANGLE_STRIP_ADJACENCY_ARB 0x000D #define GL_PROGRAM_POINT_SIZE_ARB 0x8642 #define GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_ARB 0x8C29 #define GL_FRAMEBUFFER_ATTACHMENT_LAYERED_ARB 0x8DA7 #define GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS_ARB 0x8DA8 #define GL_FRAMEBUFFER_INCOMPLETE_LAYER_COUNT_ARB 0x8DA9 #define GL_GEOMETRY_SHADER_ARB 0x8DD9 #define GL_GEOMETRY_VERTICES_OUT_ARB 0x8DDA #define GL_GEOMETRY_INPUT_TYPE_ARB 0x8DDB #define GL_GEOMETRY_OUTPUT_TYPE_ARB 0x8DDC #define GL_MAX_GEOMETRY_VARYING_COMPONENTS_ARB 0x8DDD #define GL_MAX_VERTEX_VARYING_COMPONENTS_ARB 0x8DDE #define GL_MAX_GEOMETRY_UNIFORM_COMPONENTS_ARB 0x8DDF #define GL_MAX_GEOMETRY_OUTPUT_VERTICES_ARB 0x8DE0 #define GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS_ARB 0x8DE1 typedef void (APIENTRYP PFNGLPROGRAMPARAMETERIARBPROC) (GLuint program, GLenum pname, GLint value); typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREARBPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level); typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURELAYERARBPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREFACEARBPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLenum face); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glProgramParameteriARB (GLuint program, GLenum pname, GLint value); GLAPI void APIENTRY glFramebufferTextureARB (GLenum target, GLenum attachment, GLuint texture, GLint level); GLAPI void APIENTRY glFramebufferTextureLayerARB (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); GLAPI void APIENTRY glFramebufferTextureFaceARB (GLenum target, GLenum attachment, GLuint texture, GLint level, GLenum face); #endif #endif /* GL_ARB_geometry_shader4 */ #ifndef GL_ARB_get_program_binary #define GL_ARB_get_program_binary 1 #endif /* GL_ARB_get_program_binary */ #ifndef GL_ARB_get_texture_sub_image #define GL_ARB_get_texture_sub_image 1 #endif /* GL_ARB_get_texture_sub_image */ #ifndef GL_ARB_gl_spirv #define GL_ARB_gl_spirv 1 #define GL_SHADER_BINARY_FORMAT_SPIR_V_ARB 0x9551 #define GL_SPIR_V_BINARY_ARB 0x9552 typedef void (APIENTRYP PFNGLSPECIALIZESHADERARBPROC) (GLuint shader, const GLchar *pEntryPoint, GLuint numSpecializationConstants, const GLuint *pConstantIndex, const GLuint *pConstantValue); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glSpecializeShaderARB (GLuint shader, const GLchar *pEntryPoint, GLuint numSpecializationConstants, const GLuint *pConstantIndex, const GLuint *pConstantValue); #endif #endif /* GL_ARB_gl_spirv */ #ifndef GL_ARB_gpu_shader5 #define GL_ARB_gpu_shader5 1 #endif /* GL_ARB_gpu_shader5 */ #ifndef GL_ARB_gpu_shader_fp64 #define GL_ARB_gpu_shader_fp64 1 #endif /* GL_ARB_gpu_shader_fp64 */ #ifndef GL_ARB_gpu_shader_int64 #define GL_ARB_gpu_shader_int64 1 #define GL_INT64_ARB 0x140E #define GL_INT64_VEC2_ARB 0x8FE9 #define GL_INT64_VEC3_ARB 0x8FEA #define GL_INT64_VEC4_ARB 0x8FEB #define GL_UNSIGNED_INT64_VEC2_ARB 0x8FF5 #define GL_UNSIGNED_INT64_VEC3_ARB 0x8FF6 #define GL_UNSIGNED_INT64_VEC4_ARB 0x8FF7 typedef void (APIENTRYP PFNGLUNIFORM1I64ARBPROC) (GLint location, GLint64 x); typedef void (APIENTRYP PFNGLUNIFORM2I64ARBPROC) (GLint location, GLint64 x, GLint64 y); typedef void (APIENTRYP PFNGLUNIFORM3I64ARBPROC) (GLint location, GLint64 x, GLint64 y, GLint64 z); typedef void (APIENTRYP PFNGLUNIFORM4I64ARBPROC) (GLint location, GLint64 x, GLint64 y, GLint64 z, GLint64 w); typedef void (APIENTRYP PFNGLUNIFORM1I64VARBPROC) (GLint location, GLsizei count, const GLint64 *value); typedef void (APIENTRYP PFNGLUNIFORM2I64VARBPROC) (GLint location, GLsizei count, const GLint64 *value); typedef void (APIENTRYP PFNGLUNIFORM3I64VARBPROC) (GLint location, GLsizei count, const GLint64 *value); typedef void (APIENTRYP PFNGLUNIFORM4I64VARBPROC) (GLint location, GLsizei count, const GLint64 *value); typedef void (APIENTRYP PFNGLUNIFORM1UI64ARBPROC) (GLint location, GLuint64 x); typedef void (APIENTRYP PFNGLUNIFORM2UI64ARBPROC) (GLint location, GLuint64 x, GLuint64 y); typedef void (APIENTRYP PFNGLUNIFORM3UI64ARBPROC) (GLint location, GLuint64 x, GLuint64 y, GLuint64 z); typedef void (APIENTRYP PFNGLUNIFORM4UI64ARBPROC) (GLint location, GLuint64 x, GLuint64 y, GLuint64 z, GLuint64 w); typedef void (APIENTRYP PFNGLUNIFORM1UI64VARBPROC) (GLint location, GLsizei count, const GLuint64 *value); typedef void (APIENTRYP PFNGLUNIFORM2UI64VARBPROC) (GLint location, GLsizei count, const GLuint64 *value); typedef void (APIENTRYP PFNGLUNIFORM3UI64VARBPROC) (GLint location, GLsizei count, const GLuint64 *value); typedef void (APIENTRYP PFNGLUNIFORM4UI64VARBPROC) (GLint location, GLsizei count, const GLuint64 *value); typedef void (APIENTRYP PFNGLGETUNIFORMI64VARBPROC) (GLuint program, GLint location, GLint64 *params); typedef void (APIENTRYP PFNGLGETUNIFORMUI64VARBPROC) (GLuint program, GLint location, GLuint64 *params); typedef void (APIENTRYP PFNGLGETNUNIFORMI64VARBPROC) (GLuint program, GLint location, GLsizei bufSize, GLint64 *params); typedef void (APIENTRYP PFNGLGETNUNIFORMUI64VARBPROC) (GLuint program, GLint location, GLsizei bufSize, GLuint64 *params); typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1I64ARBPROC) (GLuint program, GLint location, GLint64 x); typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2I64ARBPROC) (GLuint program, GLint location, GLint64 x, GLint64 y); typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3I64ARBPROC) (GLuint program, GLint location, GLint64 x, GLint64 y, GLint64 z); typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4I64ARBPROC) (GLuint program, GLint location, GLint64 x, GLint64 y, GLint64 z, GLint64 w); typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1I64VARBPROC) (GLuint program, GLint location, GLsizei count, const GLint64 *value); typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2I64VARBPROC) (GLuint program, GLint location, GLsizei count, const GLint64 *value); typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3I64VARBPROC) (GLuint program, GLint location, GLsizei count, const GLint64 *value); typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4I64VARBPROC) (GLuint program, GLint location, GLsizei count, const GLint64 *value); typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UI64ARBPROC) (GLuint program, GLint location, GLuint64 x); typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UI64ARBPROC) (GLuint program, GLint location, GLuint64 x, GLuint64 y); typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UI64ARBPROC) (GLuint program, GLint location, GLuint64 x, GLuint64 y, GLuint64 z); typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UI64ARBPROC) (GLuint program, GLint location, GLuint64 x, GLuint64 y, GLuint64 z, GLuint64 w); typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UI64VARBPROC) (GLuint program, GLint location, GLsizei count, const GLuint64 *value); typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UI64VARBPROC) (GLuint program, GLint location, GLsizei count, const GLuint64 *value); typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UI64VARBPROC) (GLuint program, GLint location, GLsizei count, const GLuint64 *value); typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UI64VARBPROC) (GLuint program, GLint location, GLsizei count, const GLuint64 *value); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glUniform1i64ARB (GLint location, GLint64 x); GLAPI void APIENTRY glUniform2i64ARB (GLint location, GLint64 x, GLint64 y); GLAPI void APIENTRY glUniform3i64ARB (GLint location, GLint64 x, GLint64 y, GLint64 z); GLAPI void APIENTRY glUniform4i64ARB (GLint location, GLint64 x, GLint64 y, GLint64 z, GLint64 w); GLAPI void APIENTRY glUniform1i64vARB (GLint location, GLsizei count, const GLint64 *value); GLAPI void APIENTRY glUniform2i64vARB (GLint location, GLsizei count, const GLint64 *value); GLAPI void APIENTRY glUniform3i64vARB (GLint location, GLsizei count, const GLint64 *value); GLAPI void APIENTRY glUniform4i64vARB (GLint location, GLsizei count, const GLint64 *value); GLAPI void APIENTRY glUniform1ui64ARB (GLint location, GLuint64 x); GLAPI void APIENTRY glUniform2ui64ARB (GLint location, GLuint64 x, GLuint64 y); GLAPI void APIENTRY glUniform3ui64ARB (GLint location, GLuint64 x, GLuint64 y, GLuint64 z); GLAPI void APIENTRY glUniform4ui64ARB (GLint location, GLuint64 x, GLuint64 y, GLuint64 z, GLuint64 w); GLAPI void APIENTRY glUniform1ui64vARB (GLint location, GLsizei count, const GLuint64 *value); GLAPI void APIENTRY glUniform2ui64vARB (GLint location, GLsizei count, const GLuint64 *value); GLAPI void APIENTRY glUniform3ui64vARB (GLint location, GLsizei count, const GLuint64 *value); GLAPI void APIENTRY glUniform4ui64vARB (GLint location, GLsizei count, const GLuint64 *value); GLAPI void APIENTRY glGetUniformi64vARB (GLuint program, GLint location, GLint64 *params); GLAPI void APIENTRY glGetUniformui64vARB (GLuint program, GLint location, GLuint64 *params); GLAPI void APIENTRY glGetnUniformi64vARB (GLuint program, GLint location, GLsizei bufSize, GLint64 *params); GLAPI void APIENTRY glGetnUniformui64vARB (GLuint program, GLint location, GLsizei bufSize, GLuint64 *params); GLAPI void APIENTRY glProgramUniform1i64ARB (GLuint program, GLint location, GLint64 x); GLAPI void APIENTRY glProgramUniform2i64ARB (GLuint program, GLint location, GLint64 x, GLint64 y); GLAPI void APIENTRY glProgramUniform3i64ARB (GLuint program, GLint location, GLint64 x, GLint64 y, GLint64 z); GLAPI void APIENTRY glProgramUniform4i64ARB (GLuint program, GLint location, GLint64 x, GLint64 y, GLint64 z, GLint64 w); GLAPI void APIENTRY glProgramUniform1i64vARB (GLuint program, GLint location, GLsizei count, const GLint64 *value); GLAPI void APIENTRY glProgramUniform2i64vARB (GLuint program, GLint location, GLsizei count, const GLint64 *value); GLAPI void APIENTRY glProgramUniform3i64vARB (GLuint program, GLint location, GLsizei count, const GLint64 *value); GLAPI void APIENTRY glProgramUniform4i64vARB (GLuint program, GLint location, GLsizei count, const GLint64 *value); GLAPI void APIENTRY glProgramUniform1ui64ARB (GLuint program, GLint location, GLuint64 x); GLAPI void APIENTRY glProgramUniform2ui64ARB (GLuint program, GLint location, GLuint64 x, GLuint64 y); GLAPI void APIENTRY glProgramUniform3ui64ARB (GLuint program, GLint location, GLuint64 x, GLuint64 y, GLuint64 z); GLAPI void APIENTRY glProgramUniform4ui64ARB (GLuint program, GLint location, GLuint64 x, GLuint64 y, GLuint64 z, GLuint64 w); GLAPI void APIENTRY glProgramUniform1ui64vARB (GLuint program, GLint location, GLsizei count, const GLuint64 *value); GLAPI void APIENTRY glProgramUniform2ui64vARB (GLuint program, GLint location, GLsizei count, const GLuint64 *value); GLAPI void APIENTRY glProgramUniform3ui64vARB (GLuint program, GLint location, GLsizei count, const GLuint64 *value); GLAPI void APIENTRY glProgramUniform4ui64vARB (GLuint program, GLint location, GLsizei count, const GLuint64 *value); #endif #endif /* GL_ARB_gpu_shader_int64 */ #ifndef GL_ARB_half_float_pixel #define GL_ARB_half_float_pixel 1 typedef khronos_uint16_t GLhalfARB; #define GL_HALF_FLOAT_ARB 0x140B #endif /* GL_ARB_half_float_pixel */ #ifndef GL_ARB_half_float_vertex #define GL_ARB_half_float_vertex 1 #endif /* GL_ARB_half_float_vertex */ #ifndef GL_ARB_imaging #define GL_ARB_imaging 1 #define GL_CONVOLUTION_BORDER_MODE 0x8013 #define GL_CONVOLUTION_FILTER_SCALE 0x8014 #define GL_CONVOLUTION_FILTER_BIAS 0x8015 #define GL_REDUCE 0x8016 #define GL_CONVOLUTION_FORMAT 0x8017 #define GL_CONVOLUTION_WIDTH 0x8018 #define GL_CONVOLUTION_HEIGHT 0x8019 #define GL_MAX_CONVOLUTION_WIDTH 0x801A #define GL_MAX_CONVOLUTION_HEIGHT 0x801B #define GL_POST_CONVOLUTION_RED_SCALE 0x801C #define GL_POST_CONVOLUTION_GREEN_SCALE 0x801D #define GL_POST_CONVOLUTION_BLUE_SCALE 0x801E #define GL_POST_CONVOLUTION_ALPHA_SCALE 0x801F #define GL_POST_CONVOLUTION_RED_BIAS 0x8020 #define GL_POST_CONVOLUTION_GREEN_BIAS 0x8021 #define GL_POST_CONVOLUTION_BLUE_BIAS 0x8022 #define GL_POST_CONVOLUTION_ALPHA_BIAS 0x8023 #define GL_HISTOGRAM_WIDTH 0x8026 #define GL_HISTOGRAM_FORMAT 0x8027 #define GL_HISTOGRAM_RED_SIZE 0x8028 #define GL_HISTOGRAM_GREEN_SIZE 0x8029 #define GL_HISTOGRAM_BLUE_SIZE 0x802A #define GL_HISTOGRAM_ALPHA_SIZE 0x802B #define GL_HISTOGRAM_LUMINANCE_SIZE 0x802C #define GL_HISTOGRAM_SINK 0x802D #define GL_MINMAX_FORMAT 0x802F #define GL_MINMAX_SINK 0x8030 #define GL_TABLE_TOO_LARGE 0x8031 #define GL_COLOR_MATRIX 0x80B1 #define GL_COLOR_MATRIX_STACK_DEPTH 0x80B2 #define GL_MAX_COLOR_MATRIX_STACK_DEPTH 0x80B3 #define GL_POST_COLOR_MATRIX_RED_SCALE 0x80B4 #define GL_POST_COLOR_MATRIX_GREEN_SCALE 0x80B5 #define GL_POST_COLOR_MATRIX_BLUE_SCALE 0x80B6 #define GL_POST_COLOR_MATRIX_ALPHA_SCALE 0x80B7 #define GL_POST_COLOR_MATRIX_RED_BIAS 0x80B8 #define GL_POST_COLOR_MATRIX_GREEN_BIAS 0x80B9 #define GL_POST_COLOR_MATRIX_BLUE_BIAS 0x80BA #define GL_POST_COLOR_MATRIX_ALPHA_BIAS 0x80BB #define GL_COLOR_TABLE_SCALE 0x80D6 #define GL_COLOR_TABLE_BIAS 0x80D7 #define GL_COLOR_TABLE_FORMAT 0x80D8 #define GL_COLOR_TABLE_WIDTH 0x80D9 #define GL_COLOR_TABLE_RED_SIZE 0x80DA #define GL_COLOR_TABLE_GREEN_SIZE 0x80DB #define GL_COLOR_TABLE_BLUE_SIZE 0x80DC #define GL_COLOR_TABLE_ALPHA_SIZE 0x80DD #define GL_COLOR_TABLE_LUMINANCE_SIZE 0x80DE #define GL_COLOR_TABLE_INTENSITY_SIZE 0x80DF #define GL_CONSTANT_BORDER 0x8151 #define GL_REPLICATE_BORDER 0x8153 #define GL_CONVOLUTION_BORDER_COLOR 0x8154 typedef void (APIENTRYP PFNGLCOLORTABLEPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const void *table); typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERFVPROC) (GLenum target, GLenum pname, const GLfloat *params); typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERIVPROC) (GLenum target, GLenum pname, const GLint *params); typedef void (APIENTRYP PFNGLCOPYCOLORTABLEPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); typedef void (APIENTRYP PFNGLGETCOLORTABLEPROC) (GLenum target, GLenum format, GLenum type, void *table); typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); typedef void (APIENTRYP PFNGLCOLORSUBTABLEPROC) (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const void *data); typedef void (APIENTRYP PFNGLCOPYCOLORSUBTABLEPROC) (GLenum target, GLsizei start, GLint x, GLint y, GLsizei width); typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER1DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const void *image); typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER2DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *image); typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFPROC) (GLenum target, GLenum pname, GLfloat params); typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFVPROC) (GLenum target, GLenum pname, const GLfloat *params); typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIPROC) (GLenum target, GLenum pname, GLint params); typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIVPROC) (GLenum target, GLenum pname, const GLint *params); typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER1DPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER2DPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height); typedef void (APIENTRYP PFNGLGETCONVOLUTIONFILTERPROC) (GLenum target, GLenum format, GLenum type, void *image); typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); typedef void (APIENTRYP PFNGLGETSEPARABLEFILTERPROC) (GLenum target, GLenum format, GLenum type, void *row, void *column, void *span); typedef void (APIENTRYP PFNGLSEPARABLEFILTER2DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *row, const void *column); typedef void (APIENTRYP PFNGLGETHISTOGRAMPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, void *values); typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); typedef void (APIENTRYP PFNGLGETMINMAXPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, void *values); typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); typedef void (APIENTRYP PFNGLHISTOGRAMPROC) (GLenum target, GLsizei width, GLenum internalformat, GLboolean sink); typedef void (APIENTRYP PFNGLMINMAXPROC) (GLenum target, GLenum internalformat, GLboolean sink); typedef void (APIENTRYP PFNGLRESETHISTOGRAMPROC) (GLenum target); typedef void (APIENTRYP PFNGLRESETMINMAXPROC) (GLenum target); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glColorTable (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const void *table); GLAPI void APIENTRY glColorTableParameterfv (GLenum target, GLenum pname, const GLfloat *params); GLAPI void APIENTRY glColorTableParameteriv (GLenum target, GLenum pname, const GLint *params); GLAPI void APIENTRY glCopyColorTable (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); GLAPI void APIENTRY glGetColorTable (GLenum target, GLenum format, GLenum type, void *table); GLAPI void APIENTRY glGetColorTableParameterfv (GLenum target, GLenum pname, GLfloat *params); GLAPI void APIENTRY glGetColorTableParameteriv (GLenum target, GLenum pname, GLint *params); GLAPI void APIENTRY glColorSubTable (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const void *data); GLAPI void APIENTRY glCopyColorSubTable (GLenum target, GLsizei start, GLint x, GLint y, GLsizei width); GLAPI void APIENTRY glConvolutionFilter1D (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const void *image); GLAPI void APIENTRY glConvolutionFilter2D (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *image); GLAPI void APIENTRY glConvolutionParameterf (GLenum target, GLenum pname, GLfloat params); GLAPI void APIENTRY glConvolutionParameterfv (GLenum target, GLenum pname, const GLfloat *params); GLAPI void APIENTRY glConvolutionParameteri (GLenum target, GLenum pname, GLint params); GLAPI void APIENTRY glConvolutionParameteriv (GLenum target, GLenum pname, const GLint *params); GLAPI void APIENTRY glCopyConvolutionFilter1D (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); GLAPI void APIENTRY glCopyConvolutionFilter2D (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height); GLAPI void APIENTRY glGetConvolutionFilter (GLenum target, GLenum format, GLenum type, void *image); GLAPI void APIENTRY glGetConvolutionParameterfv (GLenum target, GLenum pname, GLfloat *params); GLAPI void APIENTRY glGetConvolutionParameteriv (GLenum target, GLenum pname, GLint *params); GLAPI void APIENTRY glGetSeparableFilter (GLenum target, GLenum format, GLenum type, void *row, void *column, void *span); GLAPI void APIENTRY glSeparableFilter2D (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *row, const void *column); GLAPI void APIENTRY glGetHistogram (GLenum target, GLboolean reset, GLenum format, GLenum type, void *values); GLAPI void APIENTRY glGetHistogramParameterfv (GLenum target, GLenum pname, GLfloat *params); GLAPI void APIENTRY glGetHistogramParameteriv (GLenum target, GLenum pname, GLint *params); GLAPI void APIENTRY glGetMinmax (GLenum target, GLboolean reset, GLenum format, GLenum type, void *values); GLAPI void APIENTRY glGetMinmaxParameterfv (GLenum target, GLenum pname, GLfloat *params); GLAPI void APIENTRY glGetMinmaxParameteriv (GLenum target, GLenum pname, GLint *params); GLAPI void APIENTRY glHistogram (GLenum target, GLsizei width, GLenum internalformat, GLboolean sink); GLAPI void APIENTRY glMinmax (GLenum target, GLenum internalformat, GLboolean sink); GLAPI void APIENTRY glResetHistogram (GLenum target); GLAPI void APIENTRY glResetMinmax (GLenum target); #endif #endif /* GL_ARB_imaging */ #ifndef GL_ARB_indirect_parameters #define GL_ARB_indirect_parameters 1 #define GL_PARAMETER_BUFFER_ARB 0x80EE #define GL_PARAMETER_BUFFER_BINDING_ARB 0x80EF typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSINDIRECTCOUNTARBPROC) (GLenum mode, const void *indirect, GLintptr drawcount, GLsizei maxdrawcount, GLsizei stride); typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSINDIRECTCOUNTARBPROC) (GLenum mode, GLenum type, const void *indirect, GLintptr drawcount, GLsizei maxdrawcount, GLsizei stride); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glMultiDrawArraysIndirectCountARB (GLenum mode, const void *indirect, GLintptr drawcount, GLsizei maxdrawcount, GLsizei stride); GLAPI void APIENTRY glMultiDrawElementsIndirectCountARB (GLenum mode, GLenum type, const void *indirect, GLintptr drawcount, GLsizei maxdrawcount, GLsizei stride); #endif #endif /* GL_ARB_indirect_parameters */ #ifndef GL_ARB_instanced_arrays #define GL_ARB_instanced_arrays 1 #define GL_VERTEX_ATTRIB_ARRAY_DIVISOR_ARB 0x88FE typedef void (APIENTRYP PFNGLVERTEXATTRIBDIVISORARBPROC) (GLuint index, GLuint divisor); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glVertexAttribDivisorARB (GLuint index, GLuint divisor); #endif #endif /* GL_ARB_instanced_arrays */ #ifndef GL_ARB_internalformat_query #define GL_ARB_internalformat_query 1 #endif /* GL_ARB_internalformat_query */ #ifndef GL_ARB_internalformat_query2 #define GL_ARB_internalformat_query2 1 #define GL_SRGB_DECODE_ARB 0x8299 #define GL_VIEW_CLASS_EAC_R11 0x9383 #define GL_VIEW_CLASS_EAC_RG11 0x9384 #define GL_VIEW_CLASS_ETC2_RGB 0x9385 #define GL_VIEW_CLASS_ETC2_RGBA 0x9386 #define GL_VIEW_CLASS_ETC2_EAC_RGBA 0x9387 #define GL_VIEW_CLASS_ASTC_4x4_RGBA 0x9388 #define GL_VIEW_CLASS_ASTC_5x4_RGBA 0x9389 #define GL_VIEW_CLASS_ASTC_5x5_RGBA 0x938A #define GL_VIEW_CLASS_ASTC_6x5_RGBA 0x938B #define GL_VIEW_CLASS_ASTC_6x6_RGBA 0x938C #define GL_VIEW_CLASS_ASTC_8x5_RGBA 0x938D #define GL_VIEW_CLASS_ASTC_8x6_RGBA 0x938E #define GL_VIEW_CLASS_ASTC_8x8_RGBA 0x938F #define GL_VIEW_CLASS_ASTC_10x5_RGBA 0x9390 #define GL_VIEW_CLASS_ASTC_10x6_RGBA 0x9391 #define GL_VIEW_CLASS_ASTC_10x8_RGBA 0x9392 #define GL_VIEW_CLASS_ASTC_10x10_RGBA 0x9393 #define GL_VIEW_CLASS_ASTC_12x10_RGBA 0x9394 #define GL_VIEW_CLASS_ASTC_12x12_RGBA 0x9395 #endif /* GL_ARB_internalformat_query2 */ #ifndef GL_ARB_invalidate_subdata #define GL_ARB_invalidate_subdata 1 #endif /* GL_ARB_invalidate_subdata */ #ifndef GL_ARB_map_buffer_alignment #define GL_ARB_map_buffer_alignment 1 #endif /* GL_ARB_map_buffer_alignment */ #ifndef GL_ARB_map_buffer_range #define GL_ARB_map_buffer_range 1 #endif /* GL_ARB_map_buffer_range */ #ifndef GL_ARB_matrix_palette #define GL_ARB_matrix_palette 1 #define GL_MATRIX_PALETTE_ARB 0x8840 #define GL_MAX_MATRIX_PALETTE_STACK_DEPTH_ARB 0x8841 #define GL_MAX_PALETTE_MATRICES_ARB 0x8842 #define GL_CURRENT_PALETTE_MATRIX_ARB 0x8843 #define GL_MATRIX_INDEX_ARRAY_ARB 0x8844 #define GL_CURRENT_MATRIX_INDEX_ARB 0x8845 #define GL_MATRIX_INDEX_ARRAY_SIZE_ARB 0x8846 #define GL_MATRIX_INDEX_ARRAY_TYPE_ARB 0x8847 #define GL_MATRIX_INDEX_ARRAY_STRIDE_ARB 0x8848 #define GL_MATRIX_INDEX_ARRAY_POINTER_ARB 0x8849 typedef void (APIENTRYP PFNGLCURRENTPALETTEMATRIXARBPROC) (GLint index); typedef void (APIENTRYP PFNGLMATRIXINDEXUBVARBPROC) (GLint size, const GLubyte *indices); typedef void (APIENTRYP PFNGLMATRIXINDEXUSVARBPROC) (GLint size, const GLushort *indices); typedef void (APIENTRYP PFNGLMATRIXINDEXUIVARBPROC) (GLint size, const GLuint *indices); typedef void (APIENTRYP PFNGLMATRIXINDEXPOINTERARBPROC) (GLint size, GLenum type, GLsizei stride, const void *pointer); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glCurrentPaletteMatrixARB (GLint index); GLAPI void APIENTRY glMatrixIndexubvARB (GLint size, const GLubyte *indices); GLAPI void APIENTRY glMatrixIndexusvARB (GLint size, const GLushort *indices); GLAPI void APIENTRY glMatrixIndexuivARB (GLint size, const GLuint *indices); GLAPI void APIENTRY glMatrixIndexPointerARB (GLint size, GLenum type, GLsizei stride, const void *pointer); #endif #endif /* GL_ARB_matrix_palette */ #ifndef GL_ARB_multi_bind #define GL_ARB_multi_bind 1 #endif /* GL_ARB_multi_bind */ #ifndef GL_ARB_multi_draw_indirect #define GL_ARB_multi_draw_indirect 1 #endif /* GL_ARB_multi_draw_indirect */ #ifndef GL_ARB_multisample #define GL_ARB_multisample 1 #define GL_MULTISAMPLE_ARB 0x809D #define GL_SAMPLE_ALPHA_TO_COVERAGE_ARB 0x809E #define GL_SAMPLE_ALPHA_TO_ONE_ARB 0x809F #define GL_SAMPLE_COVERAGE_ARB 0x80A0 #define GL_SAMPLE_BUFFERS_ARB 0x80A8 #define GL_SAMPLES_ARB 0x80A9 #define GL_SAMPLE_COVERAGE_VALUE_ARB 0x80AA #define GL_SAMPLE_COVERAGE_INVERT_ARB 0x80AB #define GL_MULTISAMPLE_BIT_ARB 0x20000000 typedef void (APIENTRYP PFNGLSAMPLECOVERAGEARBPROC) (GLfloat value, GLboolean invert); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glSampleCoverageARB (GLfloat value, GLboolean invert); #endif #endif /* GL_ARB_multisample */ #ifndef GL_ARB_multitexture #define GL_ARB_multitexture 1 #define GL_TEXTURE0_ARB 0x84C0 #define GL_TEXTURE1_ARB 0x84C1 #define GL_TEXTURE2_ARB 0x84C2 #define GL_TEXTURE3_ARB 0x84C3 #define GL_TEXTURE4_ARB 0x84C4 #define GL_TEXTURE5_ARB 0x84C5 #define GL_TEXTURE6_ARB 0x84C6 #define GL_TEXTURE7_ARB 0x84C7 #define GL_TEXTURE8_ARB 0x84C8 #define GL_TEXTURE9_ARB 0x84C9 #define GL_TEXTURE10_ARB 0x84CA #define GL_TEXTURE11_ARB 0x84CB #define GL_TEXTURE12_ARB 0x84CC #define GL_TEXTURE13_ARB 0x84CD #define GL_TEXTURE14_ARB 0x84CE #define GL_TEXTURE15_ARB 0x84CF #define GL_TEXTURE16_ARB 0x84D0 #define GL_TEXTURE17_ARB 0x84D1 #define GL_TEXTURE18_ARB 0x84D2 #define GL_TEXTURE19_ARB 0x84D3 #define GL_TEXTURE20_ARB 0x84D4 #define GL_TEXTURE21_ARB 0x84D5 #define GL_TEXTURE22_ARB 0x84D6 #define GL_TEXTURE23_ARB 0x84D7 #define GL_TEXTURE24_ARB 0x84D8 #define GL_TEXTURE25_ARB 0x84D9 #define GL_TEXTURE26_ARB 0x84DA #define GL_TEXTURE27_ARB 0x84DB #define GL_TEXTURE28_ARB 0x84DC #define GL_TEXTURE29_ARB 0x84DD #define GL_TEXTURE30_ARB 0x84DE #define GL_TEXTURE31_ARB 0x84DF #define GL_ACTIVE_TEXTURE_ARB 0x84E0 #define GL_CLIENT_ACTIVE_TEXTURE_ARB 0x84E1 #define GL_MAX_TEXTURE_UNITS_ARB 0x84E2 typedef void (APIENTRYP PFNGLACTIVETEXTUREARBPROC) (GLenum texture); typedef void (APIENTRYP PFNGLCLIENTACTIVETEXTUREARBPROC) (GLenum texture); typedef void (APIENTRYP PFNGLMULTITEXCOORD1DARBPROC) (GLenum target, GLdouble s); typedef void (APIENTRYP PFNGLMULTITEXCOORD1DVARBPROC) (GLenum target, const GLdouble *v); typedef void (APIENTRYP PFNGLMULTITEXCOORD1FARBPROC) (GLenum target, GLfloat s); typedef void (APIENTRYP PFNGLMULTITEXCOORD1FVARBPROC) (GLenum target, const GLfloat *v); typedef void (APIENTRYP PFNGLMULTITEXCOORD1IARBPROC) (GLenum target, GLint s); typedef void (APIENTRYP PFNGLMULTITEXCOORD1IVARBPROC) (GLenum target, const GLint *v); typedef void (APIENTRYP PFNGLMULTITEXCOORD1SARBPROC) (GLenum target, GLshort s); typedef void (APIENTRYP PFNGLMULTITEXCOORD1SVARBPROC) (GLenum target, const GLshort *v); typedef void (APIENTRYP PFNGLMULTITEXCOORD2DARBPROC) (GLenum target, GLdouble s, GLdouble t); typedef void (APIENTRYP PFNGLMULTITEXCOORD2DVARBPROC) (GLenum target, const GLdouble *v); typedef void (APIENTRYP PFNGLMULTITEXCOORD2FARBPROC) (GLenum target, GLfloat s, GLfloat t); typedef void (APIENTRYP PFNGLMULTITEXCOORD2FVARBPROC) (GLenum target, const GLfloat *v); typedef void (APIENTRYP PFNGLMULTITEXCOORD2IARBPROC) (GLenum target, GLint s, GLint t); typedef void (APIENTRYP PFNGLMULTITEXCOORD2IVARBPROC) (GLenum target, const GLint *v); typedef void (APIENTRYP PFNGLMULTITEXCOORD2SARBPROC) (GLenum target, GLshort s, GLshort t); typedef void (APIENTRYP PFNGLMULTITEXCOORD2SVARBPROC) (GLenum target, const GLshort *v); typedef void (APIENTRYP PFNGLMULTITEXCOORD3DARBPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r); typedef void (APIENTRYP PFNGLMULTITEXCOORD3DVARBPROC) (GLenum target, const GLdouble *v); typedef void (APIENTRYP PFNGLMULTITEXCOORD3FARBPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r); typedef void (APIENTRYP PFNGLMULTITEXCOORD3FVARBPROC) (GLenum target, const GLfloat *v); typedef void (APIENTRYP PFNGLMULTITEXCOORD3IARBPROC) (GLenum target, GLint s, GLint t, GLint r); typedef void (APIENTRYP PFNGLMULTITEXCOORD3IVARBPROC) (GLenum target, const GLint *v); typedef void (APIENTRYP PFNGLMULTITEXCOORD3SARBPROC) (GLenum target, GLshort s, GLshort t, GLshort r); typedef void (APIENTRYP PFNGLMULTITEXCOORD3SVARBPROC) (GLenum target, const GLshort *v); typedef void (APIENTRYP PFNGLMULTITEXCOORD4DARBPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q); typedef void (APIENTRYP PFNGLMULTITEXCOORD4DVARBPROC) (GLenum target, const GLdouble *v); typedef void (APIENTRYP PFNGLMULTITEXCOORD4FARBPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); typedef void (APIENTRYP PFNGLMULTITEXCOORD4FVARBPROC) (GLenum target, const GLfloat *v); typedef void (APIENTRYP PFNGLMULTITEXCOORD4IARBPROC) (GLenum target, GLint s, GLint t, GLint r, GLint q); typedef void (APIENTRYP PFNGLMULTITEXCOORD4IVARBPROC) (GLenum target, const GLint *v); typedef void (APIENTRYP PFNGLMULTITEXCOORD4SARBPROC) (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q); typedef void (APIENTRYP PFNGLMULTITEXCOORD4SVARBPROC) (GLenum target, const GLshort *v); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glActiveTextureARB (GLenum texture); GLAPI void APIENTRY glClientActiveTextureARB (GLenum texture); GLAPI void APIENTRY glMultiTexCoord1dARB (GLenum target, GLdouble s); GLAPI void APIENTRY glMultiTexCoord1dvARB (GLenum target, const GLdouble *v); GLAPI void APIENTRY glMultiTexCoord1fARB (GLenum target, GLfloat s); GLAPI void APIENTRY glMultiTexCoord1fvARB (GLenum target, const GLfloat *v); GLAPI void APIENTRY glMultiTexCoord1iARB (GLenum target, GLint s); GLAPI void APIENTRY glMultiTexCoord1ivARB (GLenum target, const GLint *v); GLAPI void APIENTRY glMultiTexCoord1sARB (GLenum target, GLshort s); GLAPI void APIENTRY glMultiTexCoord1svARB (GLenum target, const GLshort *v); GLAPI void APIENTRY glMultiTexCoord2dARB (GLenum target, GLdouble s, GLdouble t); GLAPI void APIENTRY glMultiTexCoord2dvARB (GLenum target, const GLdouble *v); GLAPI void APIENTRY glMultiTexCoord2fARB (GLenum target, GLfloat s, GLfloat t); GLAPI void APIENTRY glMultiTexCoord2fvARB (GLenum target, const GLfloat *v); GLAPI void APIENTRY glMultiTexCoord2iARB (GLenum target, GLint s, GLint t); GLAPI void APIENTRY glMultiTexCoord2ivARB (GLenum target, const GLint *v); GLAPI void APIENTRY glMultiTexCoord2sARB (GLenum target, GLshort s, GLshort t); GLAPI void APIENTRY glMultiTexCoord2svARB (GLenum target, const GLshort *v); GLAPI void APIENTRY glMultiTexCoord3dARB (GLenum target, GLdouble s, GLdouble t, GLdouble r); GLAPI void APIENTRY glMultiTexCoord3dvARB (GLenum target, const GLdouble *v); GLAPI void APIENTRY glMultiTexCoord3fARB (GLenum target, GLfloat s, GLfloat t, GLfloat r); GLAPI void APIENTRY glMultiTexCoord3fvARB (GLenum target, const GLfloat *v); GLAPI void APIENTRY glMultiTexCoord3iARB (GLenum target, GLint s, GLint t, GLint r); GLAPI void APIENTRY glMultiTexCoord3ivARB (GLenum target, const GLint *v); GLAPI void APIENTRY glMultiTexCoord3sARB (GLenum target, GLshort s, GLshort t, GLshort r); GLAPI void APIENTRY glMultiTexCoord3svARB (GLenum target, const GLshort *v); GLAPI void APIENTRY glMultiTexCoord4dARB (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q); GLAPI void APIENTRY glMultiTexCoord4dvARB (GLenum target, const GLdouble *v); GLAPI void APIENTRY glMultiTexCoord4fARB (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); GLAPI void APIENTRY glMultiTexCoord4fvARB (GLenum target, const GLfloat *v); GLAPI void APIENTRY glMultiTexCoord4iARB (GLenum target, GLint s, GLint t, GLint r, GLint q); GLAPI void APIENTRY glMultiTexCoord4ivARB (GLenum target, const GLint *v); GLAPI void APIENTRY glMultiTexCoord4sARB (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q); GLAPI void APIENTRY glMultiTexCoord4svARB (GLenum target, const GLshort *v); #endif #endif /* GL_ARB_multitexture */ #ifndef GL_ARB_occlusion_query #define GL_ARB_occlusion_query 1 #define GL_QUERY_COUNTER_BITS_ARB 0x8864 #define GL_CURRENT_QUERY_ARB 0x8865 #define GL_QUERY_RESULT_ARB 0x8866 #define GL_QUERY_RESULT_AVAILABLE_ARB 0x8867 #define GL_SAMPLES_PASSED_ARB 0x8914 typedef void (APIENTRYP PFNGLGENQUERIESARBPROC) (GLsizei n, GLuint *ids); typedef void (APIENTRYP PFNGLDELETEQUERIESARBPROC) (GLsizei n, const GLuint *ids); typedef GLboolean (APIENTRYP PFNGLISQUERYARBPROC) (GLuint id); typedef void (APIENTRYP PFNGLBEGINQUERYARBPROC) (GLenum target, GLuint id); typedef void (APIENTRYP PFNGLENDQUERYARBPROC) (GLenum target); typedef void (APIENTRYP PFNGLGETQUERYIVARBPROC) (GLenum target, GLenum pname, GLint *params); typedef void (APIENTRYP PFNGLGETQUERYOBJECTIVARBPROC) (GLuint id, GLenum pname, GLint *params); typedef void (APIENTRYP PFNGLGETQUERYOBJECTUIVARBPROC) (GLuint id, GLenum pname, GLuint *params); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glGenQueriesARB (GLsizei n, GLuint *ids); GLAPI void APIENTRY glDeleteQueriesARB (GLsizei n, const GLuint *ids); GLAPI GLboolean APIENTRY glIsQueryARB (GLuint id); GLAPI void APIENTRY glBeginQueryARB (GLenum target, GLuint id); GLAPI void APIENTRY glEndQueryARB (GLenum target); GLAPI void APIENTRY glGetQueryivARB (GLenum target, GLenum pname, GLint *params); GLAPI void APIENTRY glGetQueryObjectivARB (GLuint id, GLenum pname, GLint *params); GLAPI void APIENTRY glGetQueryObjectuivARB (GLuint id, GLenum pname, GLuint *params); #endif #endif /* GL_ARB_occlusion_query */ #ifndef GL_ARB_occlusion_query2 #define GL_ARB_occlusion_query2 1 #endif /* GL_ARB_occlusion_query2 */ #ifndef GL_ARB_parallel_shader_compile #define GL_ARB_parallel_shader_compile 1 #define GL_MAX_SHADER_COMPILER_THREADS_ARB 0x91B0 #define GL_COMPLETION_STATUS_ARB 0x91B1 typedef void (APIENTRYP PFNGLMAXSHADERCOMPILERTHREADSARBPROC) (GLuint count); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glMaxShaderCompilerThreadsARB (GLuint count); #endif #endif /* GL_ARB_parallel_shader_compile */ #ifndef GL_ARB_pipeline_statistics_query #define GL_ARB_pipeline_statistics_query 1 #define GL_VERTICES_SUBMITTED_ARB 0x82EE #define GL_PRIMITIVES_SUBMITTED_ARB 0x82EF #define GL_VERTEX_SHADER_INVOCATIONS_ARB 0x82F0 #define GL_TESS_CONTROL_SHADER_PATCHES_ARB 0x82F1 #define GL_TESS_EVALUATION_SHADER_INVOCATIONS_ARB 0x82F2 #define GL_GEOMETRY_SHADER_PRIMITIVES_EMITTED_ARB 0x82F3 #define GL_FRAGMENT_SHADER_INVOCATIONS_ARB 0x82F4 #define GL_COMPUTE_SHADER_INVOCATIONS_ARB 0x82F5 #define GL_CLIPPING_INPUT_PRIMITIVES_ARB 0x82F6 #define GL_CLIPPING_OUTPUT_PRIMITIVES_ARB 0x82F7 #endif /* GL_ARB_pipeline_statistics_query */ #ifndef GL_ARB_pixel_buffer_object #define GL_ARB_pixel_buffer_object 1 #define GL_PIXEL_PACK_BUFFER_ARB 0x88EB #define GL_PIXEL_UNPACK_BUFFER_ARB 0x88EC #define GL_PIXEL_PACK_BUFFER_BINDING_ARB 0x88ED #define GL_PIXEL_UNPACK_BUFFER_BINDING_ARB 0x88EF #endif /* GL_ARB_pixel_buffer_object */ #ifndef GL_ARB_point_parameters #define GL_ARB_point_parameters 1 #define GL_POINT_SIZE_MIN_ARB 0x8126 #define GL_POINT_SIZE_MAX_ARB 0x8127 #define GL_POINT_FADE_THRESHOLD_SIZE_ARB 0x8128 #define GL_POINT_DISTANCE_ATTENUATION_ARB 0x8129 typedef void (APIENTRYP PFNGLPOINTPARAMETERFARBPROC) (GLenum pname, GLfloat param); typedef void (APIENTRYP PFNGLPOINTPARAMETERFVARBPROC) (GLenum pname, const GLfloat *params); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glPointParameterfARB (GLenum pname, GLfloat param); GLAPI void APIENTRY glPointParameterfvARB (GLenum pname, const GLfloat *params); #endif #endif /* GL_ARB_point_parameters */ #ifndef GL_ARB_point_sprite #define GL_ARB_point_sprite 1 #define GL_POINT_SPRITE_ARB 0x8861 #define GL_COORD_REPLACE_ARB 0x8862 #endif /* GL_ARB_point_sprite */ #ifndef GL_ARB_polygon_offset_clamp #define GL_ARB_polygon_offset_clamp 1 #endif /* GL_ARB_polygon_offset_clamp */ #ifndef GL_ARB_post_depth_coverage #define GL_ARB_post_depth_coverage 1 #endif /* GL_ARB_post_depth_coverage */ #ifndef GL_ARB_program_interface_query #define GL_ARB_program_interface_query 1 #endif /* GL_ARB_program_interface_query */ #ifndef GL_ARB_provoking_vertex #define GL_ARB_provoking_vertex 1 #endif /* GL_ARB_provoking_vertex */ #ifndef GL_ARB_query_buffer_object #define GL_ARB_query_buffer_object 1 #endif /* GL_ARB_query_buffer_object */ #ifndef GL_ARB_robust_buffer_access_behavior #define GL_ARB_robust_buffer_access_behavior 1 #endif /* GL_ARB_robust_buffer_access_behavior */ #ifndef GL_ARB_robustness #define GL_ARB_robustness 1 #define GL_CONTEXT_FLAG_ROBUST_ACCESS_BIT_ARB 0x00000004 #define GL_LOSE_CONTEXT_ON_RESET_ARB 0x8252 #define GL_GUILTY_CONTEXT_RESET_ARB 0x8253 #define GL_INNOCENT_CONTEXT_RESET_ARB 0x8254 #define GL_UNKNOWN_CONTEXT_RESET_ARB 0x8255 #define GL_RESET_NOTIFICATION_STRATEGY_ARB 0x8256 #define GL_NO_RESET_NOTIFICATION_ARB 0x8261 typedef GLenum (APIENTRYP PFNGLGETGRAPHICSRESETSTATUSARBPROC) (void); typedef void (APIENTRYP PFNGLGETNTEXIMAGEARBPROC) (GLenum target, GLint level, GLenum format, GLenum type, GLsizei bufSize, void *img); typedef void (APIENTRYP PFNGLREADNPIXELSARBPROC) (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei bufSize, void *data); typedef void (APIENTRYP PFNGLGETNCOMPRESSEDTEXIMAGEARBPROC) (GLenum target, GLint lod, GLsizei bufSize, void *img); typedef void (APIENTRYP PFNGLGETNUNIFORMFVARBPROC) (GLuint program, GLint location, GLsizei bufSize, GLfloat *params); typedef void (APIENTRYP PFNGLGETNUNIFORMIVARBPROC) (GLuint program, GLint location, GLsizei bufSize, GLint *params); typedef void (APIENTRYP PFNGLGETNUNIFORMUIVARBPROC) (GLuint program, GLint location, GLsizei bufSize, GLuint *params); typedef void (APIENTRYP PFNGLGETNUNIFORMDVARBPROC) (GLuint program, GLint location, GLsizei bufSize, GLdouble *params); typedef void (APIENTRYP PFNGLGETNMAPDVARBPROC) (GLenum target, GLenum query, GLsizei bufSize, GLdouble *v); typedef void (APIENTRYP PFNGLGETNMAPFVARBPROC) (GLenum target, GLenum query, GLsizei bufSize, GLfloat *v); typedef void (APIENTRYP PFNGLGETNMAPIVARBPROC) (GLenum target, GLenum query, GLsizei bufSize, GLint *v); typedef void (APIENTRYP PFNGLGETNPIXELMAPFVARBPROC) (GLenum map, GLsizei bufSize, GLfloat *values); typedef void (APIENTRYP PFNGLGETNPIXELMAPUIVARBPROC) (GLenum map, GLsizei bufSize, GLuint *values); typedef void (APIENTRYP PFNGLGETNPIXELMAPUSVARBPROC) (GLenum map, GLsizei bufSize, GLushort *values); typedef void (APIENTRYP PFNGLGETNPOLYGONSTIPPLEARBPROC) (GLsizei bufSize, GLubyte *pattern); typedef void (APIENTRYP PFNGLGETNCOLORTABLEARBPROC) (GLenum target, GLenum format, GLenum type, GLsizei bufSize, void *table); typedef void (APIENTRYP PFNGLGETNCONVOLUTIONFILTERARBPROC) (GLenum target, GLenum format, GLenum type, GLsizei bufSize, void *image); typedef void (APIENTRYP PFNGLGETNSEPARABLEFILTERARBPROC) (GLenum target, GLenum format, GLenum type, GLsizei rowBufSize, void *row, GLsizei columnBufSize, void *column, void *span); typedef void (APIENTRYP PFNGLGETNHISTOGRAMARBPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLsizei bufSize, void *values); typedef void (APIENTRYP PFNGLGETNMINMAXARBPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLsizei bufSize, void *values); #ifdef GL_GLEXT_PROTOTYPES GLAPI GLenum APIENTRY glGetGraphicsResetStatusARB (void); GLAPI void APIENTRY glGetnTexImageARB (GLenum target, GLint level, GLenum format, GLenum type, GLsizei bufSize, void *img); GLAPI void APIENTRY glReadnPixelsARB (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei bufSize, void *data); GLAPI void APIENTRY glGetnCompressedTexImageARB (GLenum target, GLint lod, GLsizei bufSize, void *img); GLAPI void APIENTRY glGetnUniformfvARB (GLuint program, GLint location, GLsizei bufSize, GLfloat *params); GLAPI void APIENTRY glGetnUniformivARB (GLuint program, GLint location, GLsizei bufSize, GLint *params); GLAPI void APIENTRY glGetnUniformuivARB (GLuint program, GLint location, GLsizei bufSize, GLuint *params); GLAPI void APIENTRY glGetnUniformdvARB (GLuint program, GLint location, GLsizei bufSize, GLdouble *params); GLAPI void APIENTRY glGetnMapdvARB (GLenum target, GLenum query, GLsizei bufSize, GLdouble *v); GLAPI void APIENTRY glGetnMapfvARB (GLenum target, GLenum query, GLsizei bufSize, GLfloat *v); GLAPI void APIENTRY glGetnMapivARB (GLenum target, GLenum query, GLsizei bufSize, GLint *v); GLAPI void APIENTRY glGetnPixelMapfvARB (GLenum map, GLsizei bufSize, GLfloat *values); GLAPI void APIENTRY glGetnPixelMapuivARB (GLenum map, GLsizei bufSize, GLuint *values); GLAPI void APIENTRY glGetnPixelMapusvARB (GLenum map, GLsizei bufSize, GLushort *values); GLAPI void APIENTRY glGetnPolygonStippleARB (GLsizei bufSize, GLubyte *pattern); GLAPI void APIENTRY glGetnColorTableARB (GLenum target, GLenum format, GLenum type, GLsizei bufSize, void *table); GLAPI void APIENTRY glGetnConvolutionFilterARB (GLenum target, GLenum format, GLenum type, GLsizei bufSize, void *image); GLAPI void APIENTRY glGetnSeparableFilterARB (GLenum target, GLenum format, GLenum type, GLsizei rowBufSize, void *row, GLsizei columnBufSize, void *column, void *span); GLAPI void APIENTRY glGetnHistogramARB (GLenum target, GLboolean reset, GLenum format, GLenum type, GLsizei bufSize, void *values); GLAPI void APIENTRY glGetnMinmaxARB (GLenum target, GLboolean reset, GLenum format, GLenum type, GLsizei bufSize, void *values); #endif #endif /* GL_ARB_robustness */ #ifndef GL_ARB_robustness_isolation #define GL_ARB_robustness_isolation 1 #endif /* GL_ARB_robustness_isolation */ #ifndef GL_ARB_sample_locations #define GL_ARB_sample_locations 1 #define GL_SAMPLE_LOCATION_SUBPIXEL_BITS_ARB 0x933D #define GL_SAMPLE_LOCATION_PIXEL_GRID_WIDTH_ARB 0x933E #define GL_SAMPLE_LOCATION_PIXEL_GRID_HEIGHT_ARB 0x933F #define GL_PROGRAMMABLE_SAMPLE_LOCATION_TABLE_SIZE_ARB 0x9340 #define GL_SAMPLE_LOCATION_ARB 0x8E50 #define GL_PROGRAMMABLE_SAMPLE_LOCATION_ARB 0x9341 #define GL_FRAMEBUFFER_PROGRAMMABLE_SAMPLE_LOCATIONS_ARB 0x9342 #define GL_FRAMEBUFFER_SAMPLE_LOCATION_PIXEL_GRID_ARB 0x9343 typedef void (APIENTRYP PFNGLFRAMEBUFFERSAMPLELOCATIONSFVARBPROC) (GLenum target, GLuint start, GLsizei count, const GLfloat *v); typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERSAMPLELOCATIONSFVARBPROC) (GLuint framebuffer, GLuint start, GLsizei count, const GLfloat *v); typedef void (APIENTRYP PFNGLEVALUATEDEPTHVALUESARBPROC) (void); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glFramebufferSampleLocationsfvARB (GLenum target, GLuint start, GLsizei count, const GLfloat *v); GLAPI void APIENTRY glNamedFramebufferSampleLocationsfvARB (GLuint framebuffer, GLuint start, GLsizei count, const GLfloat *v); GLAPI void APIENTRY glEvaluateDepthValuesARB (void); #endif #endif /* GL_ARB_sample_locations */ #ifndef GL_ARB_sample_shading #define GL_ARB_sample_shading 1 #define GL_SAMPLE_SHADING_ARB 0x8C36 #define GL_MIN_SAMPLE_SHADING_VALUE_ARB 0x8C37 typedef void (APIENTRYP PFNGLMINSAMPLESHADINGARBPROC) (GLfloat value); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glMinSampleShadingARB (GLfloat value); #endif #endif /* GL_ARB_sample_shading */ #ifndef GL_ARB_sampler_objects #define GL_ARB_sampler_objects 1 #endif /* GL_ARB_sampler_objects */ #ifndef GL_ARB_seamless_cube_map #define GL_ARB_seamless_cube_map 1 #endif /* GL_ARB_seamless_cube_map */ #ifndef GL_ARB_seamless_cubemap_per_texture #define GL_ARB_seamless_cubemap_per_texture 1 #endif /* GL_ARB_seamless_cubemap_per_texture */ #ifndef GL_ARB_separate_shader_objects #define GL_ARB_separate_shader_objects 1 #endif /* GL_ARB_separate_shader_objects */ #ifndef GL_ARB_shader_atomic_counter_ops #define GL_ARB_shader_atomic_counter_ops 1 #endif /* GL_ARB_shader_atomic_counter_ops */ #ifndef GL_ARB_shader_atomic_counters #define GL_ARB_shader_atomic_counters 1 #endif /* GL_ARB_shader_atomic_counters */ #ifndef GL_ARB_shader_ballot #define GL_ARB_shader_ballot 1 #endif /* GL_ARB_shader_ballot */ #ifndef GL_ARB_shader_bit_encoding #define GL_ARB_shader_bit_encoding 1 #endif /* GL_ARB_shader_bit_encoding */ #ifndef GL_ARB_shader_clock #define GL_ARB_shader_clock 1 #endif /* GL_ARB_shader_clock */ #ifndef GL_ARB_shader_draw_parameters #define GL_ARB_shader_draw_parameters 1 #endif /* GL_ARB_shader_draw_parameters */ #ifndef GL_ARB_shader_group_vote #define GL_ARB_shader_group_vote 1 #endif /* GL_ARB_shader_group_vote */ #ifndef GL_ARB_shader_image_load_store #define GL_ARB_shader_image_load_store 1 #endif /* GL_ARB_shader_image_load_store */ #ifndef GL_ARB_shader_image_size #define GL_ARB_shader_image_size 1 #endif /* GL_ARB_shader_image_size */ #ifndef GL_ARB_shader_objects #define GL_ARB_shader_objects 1 #ifdef __APPLE__ typedef void *GLhandleARB; #else typedef unsigned int GLhandleARB; #endif typedef char GLcharARB; #define GL_PROGRAM_OBJECT_ARB 0x8B40 #define GL_SHADER_OBJECT_ARB 0x8B48 #define GL_OBJECT_TYPE_ARB 0x8B4E #define GL_OBJECT_SUBTYPE_ARB 0x8B4F #define GL_FLOAT_VEC2_ARB 0x8B50 #define GL_FLOAT_VEC3_ARB 0x8B51 #define GL_FLOAT_VEC4_ARB 0x8B52 #define GL_INT_VEC2_ARB 0x8B53 #define GL_INT_VEC3_ARB 0x8B54 #define GL_INT_VEC4_ARB 0x8B55 #define GL_BOOL_ARB 0x8B56 #define GL_BOOL_VEC2_ARB 0x8B57 #define GL_BOOL_VEC3_ARB 0x8B58 #define GL_BOOL_VEC4_ARB 0x8B59 #define GL_FLOAT_MAT2_ARB 0x8B5A #define GL_FLOAT_MAT3_ARB 0x8B5B #define GL_FLOAT_MAT4_ARB 0x8B5C #define GL_SAMPLER_1D_ARB 0x8B5D #define GL_SAMPLER_2D_ARB 0x8B5E #define GL_SAMPLER_3D_ARB 0x8B5F #define GL_SAMPLER_CUBE_ARB 0x8B60 #define GL_SAMPLER_1D_SHADOW_ARB 0x8B61 #define GL_SAMPLER_2D_SHADOW_ARB 0x8B62 #define GL_SAMPLER_2D_RECT_ARB 0x8B63 #define GL_SAMPLER_2D_RECT_SHADOW_ARB 0x8B64 #define GL_OBJECT_DELETE_STATUS_ARB 0x8B80 #define GL_OBJECT_COMPILE_STATUS_ARB 0x8B81 #define GL_OBJECT_LINK_STATUS_ARB 0x8B82 #define GL_OBJECT_VALIDATE_STATUS_ARB 0x8B83 #define GL_OBJECT_INFO_LOG_LENGTH_ARB 0x8B84 #define GL_OBJECT_ATTACHED_OBJECTS_ARB 0x8B85 #define GL_OBJECT_ACTIVE_UNIFORMS_ARB 0x8B86 #define GL_OBJECT_ACTIVE_UNIFORM_MAX_LENGTH_ARB 0x8B87 #define GL_OBJECT_SHADER_SOURCE_LENGTH_ARB 0x8B88 typedef void (APIENTRYP PFNGLDELETEOBJECTARBPROC) (GLhandleARB obj); typedef GLhandleARB (APIENTRYP PFNGLGETHANDLEARBPROC) (GLenum pname); typedef void (APIENTRYP PFNGLDETACHOBJECTARBPROC) (GLhandleARB containerObj, GLhandleARB attachedObj); typedef GLhandleARB (APIENTRYP PFNGLCREATESHADEROBJECTARBPROC) (GLenum shaderType); typedef void (APIENTRYP PFNGLSHADERSOURCEARBPROC) (GLhandleARB shaderObj, GLsizei count, const GLcharARB **string, const GLint *length); typedef void (APIENTRYP PFNGLCOMPILESHADERARBPROC) (GLhandleARB shaderObj); typedef GLhandleARB (APIENTRYP PFNGLCREATEPROGRAMOBJECTARBPROC) (void); typedef void (APIENTRYP PFNGLATTACHOBJECTARBPROC) (GLhandleARB containerObj, GLhandleARB obj); typedef void (APIENTRYP PFNGLLINKPROGRAMARBPROC) (GLhandleARB programObj); typedef void (APIENTRYP PFNGLUSEPROGRAMOBJECTARBPROC) (GLhandleARB programObj); typedef void (APIENTRYP PFNGLVALIDATEPROGRAMARBPROC) (GLhandleARB programObj); typedef void (APIENTRYP PFNGLUNIFORM1FARBPROC) (GLint location, GLfloat v0); typedef void (APIENTRYP PFNGLUNIFORM2FARBPROC) (GLint location, GLfloat v0, GLfloat v1); typedef void (APIENTRYP PFNGLUNIFORM3FARBPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2); typedef void (APIENTRYP PFNGLUNIFORM4FARBPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); typedef void (APIENTRYP PFNGLUNIFORM1IARBPROC) (GLint location, GLint v0); typedef void (APIENTRYP PFNGLUNIFORM2IARBPROC) (GLint location, GLint v0, GLint v1); typedef void (APIENTRYP PFNGLUNIFORM3IARBPROC) (GLint location, GLint v0, GLint v1, GLint v2); typedef void (APIENTRYP PFNGLUNIFORM4IARBPROC) (GLint location, GLint v0, GLint v1, GLint v2, GLint v3); typedef void (APIENTRYP PFNGLUNIFORM1FVARBPROC) (GLint location, GLsizei count, const GLfloat *value); typedef void (APIENTRYP PFNGLUNIFORM2FVARBPROC) (GLint location, GLsizei count, const GLfloat *value); typedef void (APIENTRYP PFNGLUNIFORM3FVARBPROC) (GLint location, GLsizei count, const GLfloat *value); typedef void (APIENTRYP PFNGLUNIFORM4FVARBPROC) (GLint location, GLsizei count, const GLfloat *value); typedef void (APIENTRYP PFNGLUNIFORM1IVARBPROC) (GLint location, GLsizei count, const GLint *value); typedef void (APIENTRYP PFNGLUNIFORM2IVARBPROC) (GLint location, GLsizei count, const GLint *value); typedef void (APIENTRYP PFNGLUNIFORM3IVARBPROC) (GLint location, GLsizei count, const GLint *value); typedef void (APIENTRYP PFNGLUNIFORM4IVARBPROC) (GLint location, GLsizei count, const GLint *value); typedef void (APIENTRYP PFNGLUNIFORMMATRIX2FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); typedef void (APIENTRYP PFNGLUNIFORMMATRIX3FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); typedef void (APIENTRYP PFNGLUNIFORMMATRIX4FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); typedef void (APIENTRYP PFNGLGETOBJECTPARAMETERFVARBPROC) (GLhandleARB obj, GLenum pname, GLfloat *params); typedef void (APIENTRYP PFNGLGETOBJECTPARAMETERIVARBPROC) (GLhandleARB obj, GLenum pname, GLint *params); typedef void (APIENTRYP PFNGLGETINFOLOGARBPROC) (GLhandleARB obj, GLsizei maxLength, GLsizei *length, GLcharARB *infoLog); typedef void (APIENTRYP PFNGLGETATTACHEDOBJECTSARBPROC) (GLhandleARB containerObj, GLsizei maxCount, GLsizei *count, GLhandleARB *obj); typedef GLint (APIENTRYP PFNGLGETUNIFORMLOCATIONARBPROC) (GLhandleARB programObj, const GLcharARB *name); typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMARBPROC) (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei *length, GLint *size, GLenum *type, GLcharARB *name); typedef void (APIENTRYP PFNGLGETUNIFORMFVARBPROC) (GLhandleARB programObj, GLint location, GLfloat *params); typedef void (APIENTRYP PFNGLGETUNIFORMIVARBPROC) (GLhandleARB programObj, GLint location, GLint *params); typedef void (APIENTRYP PFNGLGETSHADERSOURCEARBPROC) (GLhandleARB obj, GLsizei maxLength, GLsizei *length, GLcharARB *source); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glDeleteObjectARB (GLhandleARB obj); GLAPI GLhandleARB APIENTRY glGetHandleARB (GLenum pname); GLAPI void APIENTRY glDetachObjectARB (GLhandleARB containerObj, GLhandleARB attachedObj); GLAPI GLhandleARB APIENTRY glCreateShaderObjectARB (GLenum shaderType); GLAPI void APIENTRY glShaderSourceARB (GLhandleARB shaderObj, GLsizei count, const GLcharARB **string, const GLint *length); GLAPI void APIENTRY glCompileShaderARB (GLhandleARB shaderObj); GLAPI GLhandleARB APIENTRY glCreateProgramObjectARB (void); GLAPI void APIENTRY glAttachObjectARB (GLhandleARB containerObj, GLhandleARB obj); GLAPI void APIENTRY glLinkProgramARB (GLhandleARB programObj); GLAPI void APIENTRY glUseProgramObjectARB (GLhandleARB programObj); GLAPI void APIENTRY glValidateProgramARB (GLhandleARB programObj); GLAPI void APIENTRY glUniform1fARB (GLint location, GLfloat v0); GLAPI void APIENTRY glUniform2fARB (GLint location, GLfloat v0, GLfloat v1); GLAPI void APIENTRY glUniform3fARB (GLint location, GLfloat v0, GLfloat v1, GLfloat v2); GLAPI void APIENTRY glUniform4fARB (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); GLAPI void APIENTRY glUniform1iARB (GLint location, GLint v0); GLAPI void APIENTRY glUniform2iARB (GLint location, GLint v0, GLint v1); GLAPI void APIENTRY glUniform3iARB (GLint location, GLint v0, GLint v1, GLint v2); GLAPI void APIENTRY glUniform4iARB (GLint location, GLint v0, GLint v1, GLint v2, GLint v3); GLAPI void APIENTRY glUniform1fvARB (GLint location, GLsizei count, const GLfloat *value); GLAPI void APIENTRY glUniform2fvARB (GLint location, GLsizei count, const GLfloat *value); GLAPI void APIENTRY glUniform3fvARB (GLint location, GLsizei count, const GLfloat *value); GLAPI void APIENTRY glUniform4fvARB (GLint location, GLsizei count, const GLfloat *value); GLAPI void APIENTRY glUniform1ivARB (GLint location, GLsizei count, const GLint *value); GLAPI void APIENTRY glUniform2ivARB (GLint location, GLsizei count, const GLint *value); GLAPI void APIENTRY glUniform3ivARB (GLint location, GLsizei count, const GLint *value); GLAPI void APIENTRY glUniform4ivARB (GLint location, GLsizei count, const GLint *value); GLAPI void APIENTRY glUniformMatrix2fvARB (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); GLAPI void APIENTRY glUniformMatrix3fvARB (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); GLAPI void APIENTRY glUniformMatrix4fvARB (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); GLAPI void APIENTRY glGetObjectParameterfvARB (GLhandleARB obj, GLenum pname, GLfloat *params); GLAPI void APIENTRY glGetObjectParameterivARB (GLhandleARB obj, GLenum pname, GLint *params); GLAPI void APIENTRY glGetInfoLogARB (GLhandleARB obj, GLsizei maxLength, GLsizei *length, GLcharARB *infoLog); GLAPI void APIENTRY glGetAttachedObjectsARB (GLhandleARB containerObj, GLsizei maxCount, GLsizei *count, GLhandleARB *obj); GLAPI GLint APIENTRY glGetUniformLocationARB (GLhandleARB programObj, const GLcharARB *name); GLAPI void APIENTRY glGetActiveUniformARB (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei *length, GLint *size, GLenum *type, GLcharARB *name); GLAPI void APIENTRY glGetUniformfvARB (GLhandleARB programObj, GLint location, GLfloat *params); GLAPI void APIENTRY glGetUniformivARB (GLhandleARB programObj, GLint location, GLint *params); GLAPI void APIENTRY glGetShaderSourceARB (GLhandleARB obj, GLsizei maxLength, GLsizei *length, GLcharARB *source); #endif #endif /* GL_ARB_shader_objects */ #ifndef GL_ARB_shader_precision #define GL_ARB_shader_precision 1 #endif /* GL_ARB_shader_precision */ #ifndef GL_ARB_shader_stencil_export #define GL_ARB_shader_stencil_export 1 #endif /* GL_ARB_shader_stencil_export */ #ifndef GL_ARB_shader_storage_buffer_object #define GL_ARB_shader_storage_buffer_object 1 #endif /* GL_ARB_shader_storage_buffer_object */ #ifndef GL_ARB_shader_subroutine #define GL_ARB_shader_subroutine 1 #endif /* GL_ARB_shader_subroutine */ #ifndef GL_ARB_shader_texture_image_samples #define GL_ARB_shader_texture_image_samples 1 #endif /* GL_ARB_shader_texture_image_samples */ #ifndef GL_ARB_shader_texture_lod #define GL_ARB_shader_texture_lod 1 #endif /* GL_ARB_shader_texture_lod */ #ifndef GL_ARB_shader_viewport_layer_array #define GL_ARB_shader_viewport_layer_array 1 #endif /* GL_ARB_shader_viewport_layer_array */ #ifndef GL_ARB_shading_language_100 #define GL_ARB_shading_language_100 1 #define GL_SHADING_LANGUAGE_VERSION_ARB 0x8B8C #endif /* GL_ARB_shading_language_100 */ #ifndef GL_ARB_shading_language_420pack #define GL_ARB_shading_language_420pack 1 #endif /* GL_ARB_shading_language_420pack */ #ifndef GL_ARB_shading_language_include #define GL_ARB_shading_language_include 1 #define GL_SHADER_INCLUDE_ARB 0x8DAE #define GL_NAMED_STRING_LENGTH_ARB 0x8DE9 #define GL_NAMED_STRING_TYPE_ARB 0x8DEA typedef void (APIENTRYP PFNGLNAMEDSTRINGARBPROC) (GLenum type, GLint namelen, const GLchar *name, GLint stringlen, const GLchar *string); typedef void (APIENTRYP PFNGLDELETENAMEDSTRINGARBPROC) (GLint namelen, const GLchar *name); typedef void (APIENTRYP PFNGLCOMPILESHADERINCLUDEARBPROC) (GLuint shader, GLsizei count, const GLchar *const*path, const GLint *length); typedef GLboolean (APIENTRYP PFNGLISNAMEDSTRINGARBPROC) (GLint namelen, const GLchar *name); typedef void (APIENTRYP PFNGLGETNAMEDSTRINGARBPROC) (GLint namelen, const GLchar *name, GLsizei bufSize, GLint *stringlen, GLchar *string); typedef void (APIENTRYP PFNGLGETNAMEDSTRINGIVARBPROC) (GLint namelen, const GLchar *name, GLenum pname, GLint *params); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glNamedStringARB (GLenum type, GLint namelen, const GLchar *name, GLint stringlen, const GLchar *string); GLAPI void APIENTRY glDeleteNamedStringARB (GLint namelen, const GLchar *name); GLAPI void APIENTRY glCompileShaderIncludeARB (GLuint shader, GLsizei count, const GLchar *const*path, const GLint *length); GLAPI GLboolean APIENTRY glIsNamedStringARB (GLint namelen, const GLchar *name); GLAPI void APIENTRY glGetNamedStringARB (GLint namelen, const GLchar *name, GLsizei bufSize, GLint *stringlen, GLchar *string); GLAPI void APIENTRY glGetNamedStringivARB (GLint namelen, const GLchar *name, GLenum pname, GLint *params); #endif #endif /* GL_ARB_shading_language_include */ #ifndef GL_ARB_shading_language_packing #define GL_ARB_shading_language_packing 1 #endif /* GL_ARB_shading_language_packing */ #ifndef GL_ARB_shadow #define GL_ARB_shadow 1 #define GL_TEXTURE_COMPARE_MODE_ARB 0x884C #define GL_TEXTURE_COMPARE_FUNC_ARB 0x884D #define GL_COMPARE_R_TO_TEXTURE_ARB 0x884E #endif /* GL_ARB_shadow */ #ifndef GL_ARB_shadow_ambient #define GL_ARB_shadow_ambient 1 #define GL_TEXTURE_COMPARE_FAIL_VALUE_ARB 0x80BF #endif /* GL_ARB_shadow_ambient */ #ifndef GL_ARB_sparse_buffer #define GL_ARB_sparse_buffer 1 #define GL_SPARSE_STORAGE_BIT_ARB 0x0400 #define GL_SPARSE_BUFFER_PAGE_SIZE_ARB 0x82F8 typedef void (APIENTRYP PFNGLBUFFERPAGECOMMITMENTARBPROC) (GLenum target, GLintptr offset, GLsizeiptr size, GLboolean commit); typedef void (APIENTRYP PFNGLNAMEDBUFFERPAGECOMMITMENTEXTPROC) (GLuint buffer, GLintptr offset, GLsizeiptr size, GLboolean commit); typedef void (APIENTRYP PFNGLNAMEDBUFFERPAGECOMMITMENTARBPROC) (GLuint buffer, GLintptr offset, GLsizeiptr size, GLboolean commit); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glBufferPageCommitmentARB (GLenum target, GLintptr offset, GLsizeiptr size, GLboolean commit); GLAPI void APIENTRY glNamedBufferPageCommitmentEXT (GLuint buffer, GLintptr offset, GLsizeiptr size, GLboolean commit); GLAPI void APIENTRY glNamedBufferPageCommitmentARB (GLuint buffer, GLintptr offset, GLsizeiptr size, GLboolean commit); #endif #endif /* GL_ARB_sparse_buffer */ #ifndef GL_ARB_sparse_texture #define GL_ARB_sparse_texture 1 #define GL_TEXTURE_SPARSE_ARB 0x91A6 #define GL_VIRTUAL_PAGE_SIZE_INDEX_ARB 0x91A7 #define GL_NUM_SPARSE_LEVELS_ARB 0x91AA #define GL_NUM_VIRTUAL_PAGE_SIZES_ARB 0x91A8 #define GL_VIRTUAL_PAGE_SIZE_X_ARB 0x9195 #define GL_VIRTUAL_PAGE_SIZE_Y_ARB 0x9196 #define GL_VIRTUAL_PAGE_SIZE_Z_ARB 0x9197 #define GL_MAX_SPARSE_TEXTURE_SIZE_ARB 0x9198 #define GL_MAX_SPARSE_3D_TEXTURE_SIZE_ARB 0x9199 #define GL_MAX_SPARSE_ARRAY_TEXTURE_LAYERS_ARB 0x919A #define GL_SPARSE_TEXTURE_FULL_ARRAY_CUBE_MIPMAPS_ARB 0x91A9 typedef void (APIENTRYP PFNGLTEXPAGECOMMITMENTARBPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLboolean commit); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glTexPageCommitmentARB (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLboolean commit); #endif #endif /* GL_ARB_sparse_texture */ #ifndef GL_ARB_sparse_texture2 #define GL_ARB_sparse_texture2 1 #endif /* GL_ARB_sparse_texture2 */ #ifndef GL_ARB_sparse_texture_clamp #define GL_ARB_sparse_texture_clamp 1 #endif /* GL_ARB_sparse_texture_clamp */ #ifndef GL_ARB_spirv_extensions #define GL_ARB_spirv_extensions 1 #endif /* GL_ARB_spirv_extensions */ #ifndef GL_ARB_stencil_texturing #define GL_ARB_stencil_texturing 1 #endif /* GL_ARB_stencil_texturing */ #ifndef GL_ARB_sync #define GL_ARB_sync 1 #endif /* GL_ARB_sync */ #ifndef GL_ARB_tessellation_shader #define GL_ARB_tessellation_shader 1 #endif /* GL_ARB_tessellation_shader */ #ifndef GL_ARB_texture_barrier #define GL_ARB_texture_barrier 1 #endif /* GL_ARB_texture_barrier */ #ifndef GL_ARB_texture_border_clamp #define GL_ARB_texture_border_clamp 1 #define GL_CLAMP_TO_BORDER_ARB 0x812D #endif /* GL_ARB_texture_border_clamp */ #ifndef GL_ARB_texture_buffer_object #define GL_ARB_texture_buffer_object 1 #define GL_TEXTURE_BUFFER_ARB 0x8C2A #define GL_MAX_TEXTURE_BUFFER_SIZE_ARB 0x8C2B #define GL_TEXTURE_BINDING_BUFFER_ARB 0x8C2C #define GL_TEXTURE_BUFFER_DATA_STORE_BINDING_ARB 0x8C2D #define GL_TEXTURE_BUFFER_FORMAT_ARB 0x8C2E typedef void (APIENTRYP PFNGLTEXBUFFERARBPROC) (GLenum target, GLenum internalformat, GLuint buffer); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glTexBufferARB (GLenum target, GLenum internalformat, GLuint buffer); #endif #endif /* GL_ARB_texture_buffer_object */ #ifndef GL_ARB_texture_buffer_object_rgb32 #define GL_ARB_texture_buffer_object_rgb32 1 #endif /* GL_ARB_texture_buffer_object_rgb32 */ #ifndef GL_ARB_texture_buffer_range #define GL_ARB_texture_buffer_range 1 #endif /* GL_ARB_texture_buffer_range */ #ifndef GL_ARB_texture_compression #define GL_ARB_texture_compression 1 #define GL_COMPRESSED_ALPHA_ARB 0x84E9 #define GL_COMPRESSED_LUMINANCE_ARB 0x84EA #define GL_COMPRESSED_LUMINANCE_ALPHA_ARB 0x84EB #define GL_COMPRESSED_INTENSITY_ARB 0x84EC #define GL_COMPRESSED_RGB_ARB 0x84ED #define GL_COMPRESSED_RGBA_ARB 0x84EE #define GL_TEXTURE_COMPRESSION_HINT_ARB 0x84EF #define GL_TEXTURE_COMPRESSED_IMAGE_SIZE_ARB 0x86A0 #define GL_TEXTURE_COMPRESSED_ARB 0x86A1 #define GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB 0x86A2 #define GL_COMPRESSED_TEXTURE_FORMATS_ARB 0x86A3 typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE3DARBPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void *data); typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE2DARBPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void *data); typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE1DARBPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const void *data); typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE3DARBPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *data); typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE2DARBPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *data); typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE1DARBPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void *data); typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXIMAGEARBPROC) (GLenum target, GLint level, void *img); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glCompressedTexImage3DARB (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void *data); GLAPI void APIENTRY glCompressedTexImage2DARB (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void *data); GLAPI void APIENTRY glCompressedTexImage1DARB (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const void *data); GLAPI void APIENTRY glCompressedTexSubImage3DARB (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *data); GLAPI void APIENTRY glCompressedTexSubImage2DARB (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *data); GLAPI void APIENTRY glCompressedTexSubImage1DARB (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void *data); GLAPI void APIENTRY glGetCompressedTexImageARB (GLenum target, GLint level, void *img); #endif #endif /* GL_ARB_texture_compression */ #ifndef GL_ARB_texture_compression_bptc #define GL_ARB_texture_compression_bptc 1 #define GL_COMPRESSED_RGBA_BPTC_UNORM_ARB 0x8E8C #define GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM_ARB 0x8E8D #define GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT_ARB 0x8E8E #define GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_ARB 0x8E8F #endif /* GL_ARB_texture_compression_bptc */ #ifndef GL_ARB_texture_compression_rgtc #define GL_ARB_texture_compression_rgtc 1 #endif /* GL_ARB_texture_compression_rgtc */ #ifndef GL_ARB_texture_cube_map #define GL_ARB_texture_cube_map 1 #define GL_NORMAL_MAP_ARB 0x8511 #define GL_REFLECTION_MAP_ARB 0x8512 #define GL_TEXTURE_CUBE_MAP_ARB 0x8513 #define GL_TEXTURE_BINDING_CUBE_MAP_ARB 0x8514 #define GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB 0x8515 #define GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB 0x8516 #define GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB 0x8517 #define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB 0x8518 #define GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB 0x8519 #define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB 0x851A #define GL_PROXY_TEXTURE_CUBE_MAP_ARB 0x851B #define GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB 0x851C #endif /* GL_ARB_texture_cube_map */ #ifndef GL_ARB_texture_cube_map_array #define GL_ARB_texture_cube_map_array 1 #define GL_TEXTURE_CUBE_MAP_ARRAY_ARB 0x9009 #define GL_TEXTURE_BINDING_CUBE_MAP_ARRAY_ARB 0x900A #define GL_PROXY_TEXTURE_CUBE_MAP_ARRAY_ARB 0x900B #define GL_SAMPLER_CUBE_MAP_ARRAY_ARB 0x900C #define GL_SAMPLER_CUBE_MAP_ARRAY_SHADOW_ARB 0x900D #define GL_INT_SAMPLER_CUBE_MAP_ARRAY_ARB 0x900E #define GL_UNSIGNED_INT_SAMPLER_CUBE_MAP_ARRAY_ARB 0x900F #endif /* GL_ARB_texture_cube_map_array */ #ifndef GL_ARB_texture_env_add #define GL_ARB_texture_env_add 1 #endif /* GL_ARB_texture_env_add */ #ifndef GL_ARB_texture_env_combine #define GL_ARB_texture_env_combine 1 #define GL_COMBINE_ARB 0x8570 #define GL_COMBINE_RGB_ARB 0x8571 #define GL_COMBINE_ALPHA_ARB 0x8572 #define GL_SOURCE0_RGB_ARB 0x8580 #define GL_SOURCE1_RGB_ARB 0x8581 #define GL_SOURCE2_RGB_ARB 0x8582 #define GL_SOURCE0_ALPHA_ARB 0x8588 #define GL_SOURCE1_ALPHA_ARB 0x8589 #define GL_SOURCE2_ALPHA_ARB 0x858A #define GL_OPERAND0_RGB_ARB 0x8590 #define GL_OPERAND1_RGB_ARB 0x8591 #define GL_OPERAND2_RGB_ARB 0x8592 #define GL_OPERAND0_ALPHA_ARB 0x8598 #define GL_OPERAND1_ALPHA_ARB 0x8599 #define GL_OPERAND2_ALPHA_ARB 0x859A #define GL_RGB_SCALE_ARB 0x8573 #define GL_ADD_SIGNED_ARB 0x8574 #define GL_INTERPOLATE_ARB 0x8575 #define GL_SUBTRACT_ARB 0x84E7 #define GL_CONSTANT_ARB 0x8576 #define GL_PRIMARY_COLOR_ARB 0x8577 #define GL_PREVIOUS_ARB 0x8578 #endif /* GL_ARB_texture_env_combine */ #ifndef GL_ARB_texture_env_crossbar #define GL_ARB_texture_env_crossbar 1 #endif /* GL_ARB_texture_env_crossbar */ #ifndef GL_ARB_texture_env_dot3 #define GL_ARB_texture_env_dot3 1 #define GL_DOT3_RGB_ARB 0x86AE #define GL_DOT3_RGBA_ARB 0x86AF #endif /* GL_ARB_texture_env_dot3 */ #ifndef GL_ARB_texture_filter_anisotropic #define GL_ARB_texture_filter_anisotropic 1 #endif /* GL_ARB_texture_filter_anisotropic */ #ifndef GL_ARB_texture_filter_minmax #define GL_ARB_texture_filter_minmax 1 #define GL_TEXTURE_REDUCTION_MODE_ARB 0x9366 #define GL_WEIGHTED_AVERAGE_ARB 0x9367 #endif /* GL_ARB_texture_filter_minmax */ #ifndef GL_ARB_texture_float #define GL_ARB_texture_float 1 #define GL_TEXTURE_RED_TYPE_ARB 0x8C10 #define GL_TEXTURE_GREEN_TYPE_ARB 0x8C11 #define GL_TEXTURE_BLUE_TYPE_ARB 0x8C12 #define GL_TEXTURE_ALPHA_TYPE_ARB 0x8C13 #define GL_TEXTURE_LUMINANCE_TYPE_ARB 0x8C14 #define GL_TEXTURE_INTENSITY_TYPE_ARB 0x8C15 #define GL_TEXTURE_DEPTH_TYPE_ARB 0x8C16 #define GL_UNSIGNED_NORMALIZED_ARB 0x8C17 #define GL_RGBA32F_ARB 0x8814 #define GL_RGB32F_ARB 0x8815 #define GL_ALPHA32F_ARB 0x8816 #define GL_INTENSITY32F_ARB 0x8817 #define GL_LUMINANCE32F_ARB 0x8818 #define GL_LUMINANCE_ALPHA32F_ARB 0x8819 #define GL_RGBA16F_ARB 0x881A #define GL_RGB16F_ARB 0x881B #define GL_ALPHA16F_ARB 0x881C #define GL_INTENSITY16F_ARB 0x881D #define GL_LUMINANCE16F_ARB 0x881E #define GL_LUMINANCE_ALPHA16F_ARB 0x881F #endif /* GL_ARB_texture_float */ #ifndef GL_ARB_texture_gather #define GL_ARB_texture_gather 1 #define GL_MIN_PROGRAM_TEXTURE_GATHER_OFFSET_ARB 0x8E5E #define GL_MAX_PROGRAM_TEXTURE_GATHER_OFFSET_ARB 0x8E5F #define GL_MAX_PROGRAM_TEXTURE_GATHER_COMPONENTS_ARB 0x8F9F #endif /* GL_ARB_texture_gather */ #ifndef GL_ARB_texture_mirror_clamp_to_edge #define GL_ARB_texture_mirror_clamp_to_edge 1 #endif /* GL_ARB_texture_mirror_clamp_to_edge */ #ifndef GL_ARB_texture_mirrored_repeat #define GL_ARB_texture_mirrored_repeat 1 #define GL_MIRRORED_REPEAT_ARB 0x8370 #endif /* GL_ARB_texture_mirrored_repeat */ #ifndef GL_ARB_texture_multisample #define GL_ARB_texture_multisample 1 #endif /* GL_ARB_texture_multisample */ #ifndef GL_ARB_texture_non_power_of_two #define GL_ARB_texture_non_power_of_two 1 #endif /* GL_ARB_texture_non_power_of_two */ #ifndef GL_ARB_texture_query_levels #define GL_ARB_texture_query_levels 1 #endif /* GL_ARB_texture_query_levels */ #ifndef GL_ARB_texture_query_lod #define GL_ARB_texture_query_lod 1 #endif /* GL_ARB_texture_query_lod */ #ifndef GL_ARB_texture_rectangle #define GL_ARB_texture_rectangle 1 #define GL_TEXTURE_RECTANGLE_ARB 0x84F5 #define GL_TEXTURE_BINDING_RECTANGLE_ARB 0x84F6 #define GL_PROXY_TEXTURE_RECTANGLE_ARB 0x84F7 #define GL_MAX_RECTANGLE_TEXTURE_SIZE_ARB 0x84F8 #endif /* GL_ARB_texture_rectangle */ #ifndef GL_ARB_texture_rg #define GL_ARB_texture_rg 1 #endif /* GL_ARB_texture_rg */ #ifndef GL_ARB_texture_rgb10_a2ui #define GL_ARB_texture_rgb10_a2ui 1 #endif /* GL_ARB_texture_rgb10_a2ui */ #ifndef GL_ARB_texture_stencil8 #define GL_ARB_texture_stencil8 1 #endif /* GL_ARB_texture_stencil8 */ #ifndef GL_ARB_texture_storage #define GL_ARB_texture_storage 1 #endif /* GL_ARB_texture_storage */ #ifndef GL_ARB_texture_storage_multisample #define GL_ARB_texture_storage_multisample 1 #endif /* GL_ARB_texture_storage_multisample */ #ifndef GL_ARB_texture_swizzle #define GL_ARB_texture_swizzle 1 #endif /* GL_ARB_texture_swizzle */ #ifndef GL_ARB_texture_view #define GL_ARB_texture_view 1 #endif /* GL_ARB_texture_view */ #ifndef GL_ARB_timer_query #define GL_ARB_timer_query 1 #endif /* GL_ARB_timer_query */ #ifndef GL_ARB_transform_feedback2 #define GL_ARB_transform_feedback2 1 #endif /* GL_ARB_transform_feedback2 */ #ifndef GL_ARB_transform_feedback3 #define GL_ARB_transform_feedback3 1 #endif /* GL_ARB_transform_feedback3 */ #ifndef GL_ARB_transform_feedback_instanced #define GL_ARB_transform_feedback_instanced 1 #endif /* GL_ARB_transform_feedback_instanced */ #ifndef GL_ARB_transform_feedback_overflow_query #define GL_ARB_transform_feedback_overflow_query 1 #define GL_TRANSFORM_FEEDBACK_OVERFLOW_ARB 0x82EC #define GL_TRANSFORM_FEEDBACK_STREAM_OVERFLOW_ARB 0x82ED #endif /* GL_ARB_transform_feedback_overflow_query */ #ifndef GL_ARB_transpose_matrix #define GL_ARB_transpose_matrix 1 #define GL_TRANSPOSE_MODELVIEW_MATRIX_ARB 0x84E3 #define GL_TRANSPOSE_PROJECTION_MATRIX_ARB 0x84E4 #define GL_TRANSPOSE_TEXTURE_MATRIX_ARB 0x84E5 #define GL_TRANSPOSE_COLOR_MATRIX_ARB 0x84E6 typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXFARBPROC) (const GLfloat *m); typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXDARBPROC) (const GLdouble *m); typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXFARBPROC) (const GLfloat *m); typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXDARBPROC) (const GLdouble *m); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glLoadTransposeMatrixfARB (const GLfloat *m); GLAPI void APIENTRY glLoadTransposeMatrixdARB (const GLdouble *m); GLAPI void APIENTRY glMultTransposeMatrixfARB (const GLfloat *m); GLAPI void APIENTRY glMultTransposeMatrixdARB (const GLdouble *m); #endif #endif /* GL_ARB_transpose_matrix */ #ifndef GL_ARB_uniform_buffer_object #define GL_ARB_uniform_buffer_object 1 #endif /* GL_ARB_uniform_buffer_object */ #ifndef GL_ARB_vertex_array_bgra #define GL_ARB_vertex_array_bgra 1 #endif /* GL_ARB_vertex_array_bgra */ #ifndef GL_ARB_vertex_array_object #define GL_ARB_vertex_array_object 1 #endif /* GL_ARB_vertex_array_object */ #ifndef GL_ARB_vertex_attrib_64bit #define GL_ARB_vertex_attrib_64bit 1 #endif /* GL_ARB_vertex_attrib_64bit */ #ifndef GL_ARB_vertex_attrib_binding #define GL_ARB_vertex_attrib_binding 1 #endif /* GL_ARB_vertex_attrib_binding */ #ifndef GL_ARB_vertex_blend #define GL_ARB_vertex_blend 1 #define GL_MAX_VERTEX_UNITS_ARB 0x86A4 #define GL_ACTIVE_VERTEX_UNITS_ARB 0x86A5 #define GL_WEIGHT_SUM_UNITY_ARB 0x86A6 #define GL_VERTEX_BLEND_ARB 0x86A7 #define GL_CURRENT_WEIGHT_ARB 0x86A8 #define GL_WEIGHT_ARRAY_TYPE_ARB 0x86A9 #define GL_WEIGHT_ARRAY_STRIDE_ARB 0x86AA #define GL_WEIGHT_ARRAY_SIZE_ARB 0x86AB #define GL_WEIGHT_ARRAY_POINTER_ARB 0x86AC #define GL_WEIGHT_ARRAY_ARB 0x86AD #define GL_MODELVIEW0_ARB 0x1700 #define GL_MODELVIEW1_ARB 0x850A #define GL_MODELVIEW2_ARB 0x8722 #define GL_MODELVIEW3_ARB 0x8723 #define GL_MODELVIEW4_ARB 0x8724 #define GL_MODELVIEW5_ARB 0x8725 #define GL_MODELVIEW6_ARB 0x8726 #define GL_MODELVIEW7_ARB 0x8727 #define GL_MODELVIEW8_ARB 0x8728 #define GL_MODELVIEW9_ARB 0x8729 #define GL_MODELVIEW10_ARB 0x872A #define GL_MODELVIEW11_ARB 0x872B #define GL_MODELVIEW12_ARB 0x872C #define GL_MODELVIEW13_ARB 0x872D #define GL_MODELVIEW14_ARB 0x872E #define GL_MODELVIEW15_ARB 0x872F #define GL_MODELVIEW16_ARB 0x8730 #define GL_MODELVIEW17_ARB 0x8731 #define GL_MODELVIEW18_ARB 0x8732 #define GL_MODELVIEW19_ARB 0x8733 #define GL_MODELVIEW20_ARB 0x8734 #define GL_MODELVIEW21_ARB 0x8735 #define GL_MODELVIEW22_ARB 0x8736 #define GL_MODELVIEW23_ARB 0x8737 #define GL_MODELVIEW24_ARB 0x8738 #define GL_MODELVIEW25_ARB 0x8739 #define GL_MODELVIEW26_ARB 0x873A #define GL_MODELVIEW27_ARB 0x873B #define GL_MODELVIEW28_ARB 0x873C #define GL_MODELVIEW29_ARB 0x873D #define GL_MODELVIEW30_ARB 0x873E #define GL_MODELVIEW31_ARB 0x873F typedef void (APIENTRYP PFNGLWEIGHTBVARBPROC) (GLint size, const GLbyte *weights); typedef void (APIENTRYP PFNGLWEIGHTSVARBPROC) (GLint size, const GLshort *weights); typedef void (APIENTRYP PFNGLWEIGHTIVARBPROC) (GLint size, const GLint *weights); typedef void (APIENTRYP PFNGLWEIGHTFVARBPROC) (GLint size, const GLfloat *weights); typedef void (APIENTRYP PFNGLWEIGHTDVARBPROC) (GLint size, const GLdouble *weights); typedef void (APIENTRYP PFNGLWEIGHTUBVARBPROC) (GLint size, const GLubyte *weights); typedef void (APIENTRYP PFNGLWEIGHTUSVARBPROC) (GLint size, const GLushort *weights); typedef void (APIENTRYP PFNGLWEIGHTUIVARBPROC) (GLint size, const GLuint *weights); typedef void (APIENTRYP PFNGLWEIGHTPOINTERARBPROC) (GLint size, GLenum type, GLsizei stride, const void *pointer); typedef void (APIENTRYP PFNGLVERTEXBLENDARBPROC) (GLint count); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glWeightbvARB (GLint size, const GLbyte *weights); GLAPI void APIENTRY glWeightsvARB (GLint size, const GLshort *weights); GLAPI void APIENTRY glWeightivARB (GLint size, const GLint *weights); GLAPI void APIENTRY glWeightfvARB (GLint size, const GLfloat *weights); GLAPI void APIENTRY glWeightdvARB (GLint size, const GLdouble *weights); GLAPI void APIENTRY glWeightubvARB (GLint size, const GLubyte *weights); GLAPI void APIENTRY glWeightusvARB (GLint size, const GLushort *weights); GLAPI void APIENTRY glWeightuivARB (GLint size, const GLuint *weights); GLAPI void APIENTRY glWeightPointerARB (GLint size, GLenum type, GLsizei stride, const void *pointer); GLAPI void APIENTRY glVertexBlendARB (GLint count); #endif #endif /* GL_ARB_vertex_blend */ #ifndef GL_ARB_vertex_buffer_object #define GL_ARB_vertex_buffer_object 1 typedef khronos_ssize_t GLsizeiptrARB; typedef khronos_intptr_t GLintptrARB; #define GL_BUFFER_SIZE_ARB 0x8764 #define GL_BUFFER_USAGE_ARB 0x8765 #define GL_ARRAY_BUFFER_ARB 0x8892 #define GL_ELEMENT_ARRAY_BUFFER_ARB 0x8893 #define GL_ARRAY_BUFFER_BINDING_ARB 0x8894 #define GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB 0x8895 #define GL_VERTEX_ARRAY_BUFFER_BINDING_ARB 0x8896 #define GL_NORMAL_ARRAY_BUFFER_BINDING_ARB 0x8897 #define GL_COLOR_ARRAY_BUFFER_BINDING_ARB 0x8898 #define GL_INDEX_ARRAY_BUFFER_BINDING_ARB 0x8899 #define GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB 0x889A #define GL_EDGE_FLAG_ARRAY_BUFFER_BINDING_ARB 0x889B #define GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING_ARB 0x889C #define GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING_ARB 0x889D #define GL_WEIGHT_ARRAY_BUFFER_BINDING_ARB 0x889E #define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING_ARB 0x889F #define GL_READ_ONLY_ARB 0x88B8 #define GL_WRITE_ONLY_ARB 0x88B9 #define GL_READ_WRITE_ARB 0x88BA #define GL_BUFFER_ACCESS_ARB 0x88BB #define GL_BUFFER_MAPPED_ARB 0x88BC #define GL_BUFFER_MAP_POINTER_ARB 0x88BD #define GL_STREAM_DRAW_ARB 0x88E0 #define GL_STREAM_READ_ARB 0x88E1 #define GL_STREAM_COPY_ARB 0x88E2 #define GL_STATIC_DRAW_ARB 0x88E4 #define GL_STATIC_READ_ARB 0x88E5 #define GL_STATIC_COPY_ARB 0x88E6 #define GL_DYNAMIC_DRAW_ARB 0x88E8 #define GL_DYNAMIC_READ_ARB 0x88E9 #define GL_DYNAMIC_COPY_ARB 0x88EA typedef void (APIENTRYP PFNGLBINDBUFFERARBPROC) (GLenum target, GLuint buffer); typedef void (APIENTRYP PFNGLDELETEBUFFERSARBPROC) (GLsizei n, const GLuint *buffers); typedef void (APIENTRYP PFNGLGENBUFFERSARBPROC) (GLsizei n, GLuint *buffers); typedef GLboolean (APIENTRYP PFNGLISBUFFERARBPROC) (GLuint buffer); typedef void (APIENTRYP PFNGLBUFFERDATAARBPROC) (GLenum target, GLsizeiptrARB size, const void *data, GLenum usage); typedef void (APIENTRYP PFNGLBUFFERSUBDATAARBPROC) (GLenum target, GLintptrARB offset, GLsizeiptrARB size, const void *data); typedef void (APIENTRYP PFNGLGETBUFFERSUBDATAARBPROC) (GLenum target, GLintptrARB offset, GLsizeiptrARB size, void *data); typedef void *(APIENTRYP PFNGLMAPBUFFERARBPROC) (GLenum target, GLenum access); typedef GLboolean (APIENTRYP PFNGLUNMAPBUFFERARBPROC) (GLenum target); typedef void (APIENTRYP PFNGLGETBUFFERPARAMETERIVARBPROC) (GLenum target, GLenum pname, GLint *params); typedef void (APIENTRYP PFNGLGETBUFFERPOINTERVARBPROC) (GLenum target, GLenum pname, void **params); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glBindBufferARB (GLenum target, GLuint buffer); GLAPI void APIENTRY glDeleteBuffersARB (GLsizei n, const GLuint *buffers); GLAPI void APIENTRY glGenBuffersARB (GLsizei n, GLuint *buffers); GLAPI GLboolean APIENTRY glIsBufferARB (GLuint buffer); GLAPI void APIENTRY glBufferDataARB (GLenum target, GLsizeiptrARB size, const void *data, GLenum usage); GLAPI void APIENTRY glBufferSubDataARB (GLenum target, GLintptrARB offset, GLsizeiptrARB size, const void *data); GLAPI void APIENTRY glGetBufferSubDataARB (GLenum target, GLintptrARB offset, GLsizeiptrARB size, void *data); GLAPI void *APIENTRY glMapBufferARB (GLenum target, GLenum access); GLAPI GLboolean APIENTRY glUnmapBufferARB (GLenum target); GLAPI void APIENTRY glGetBufferParameterivARB (GLenum target, GLenum pname, GLint *params); GLAPI void APIENTRY glGetBufferPointervARB (GLenum target, GLenum pname, void **params); #endif #endif /* GL_ARB_vertex_buffer_object */ #ifndef GL_ARB_vertex_program #define GL_ARB_vertex_program 1 #define GL_COLOR_SUM_ARB 0x8458 #define GL_VERTEX_PROGRAM_ARB 0x8620 #define GL_VERTEX_ATTRIB_ARRAY_ENABLED_ARB 0x8622 #define GL_VERTEX_ATTRIB_ARRAY_SIZE_ARB 0x8623 #define GL_VERTEX_ATTRIB_ARRAY_STRIDE_ARB 0x8624 #define GL_VERTEX_ATTRIB_ARRAY_TYPE_ARB 0x8625 #define GL_CURRENT_VERTEX_ATTRIB_ARB 0x8626 #define GL_VERTEX_PROGRAM_POINT_SIZE_ARB 0x8642 #define GL_VERTEX_PROGRAM_TWO_SIDE_ARB 0x8643 #define GL_VERTEX_ATTRIB_ARRAY_POINTER_ARB 0x8645 #define GL_MAX_VERTEX_ATTRIBS_ARB 0x8869 #define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED_ARB 0x886A #define GL_PROGRAM_ADDRESS_REGISTERS_ARB 0x88B0 #define GL_MAX_PROGRAM_ADDRESS_REGISTERS_ARB 0x88B1 #define GL_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB 0x88B2 #define GL_MAX_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB 0x88B3 typedef void (APIENTRYP PFNGLVERTEXATTRIB1DARBPROC) (GLuint index, GLdouble x); typedef void (APIENTRYP PFNGLVERTEXATTRIB1DVARBPROC) (GLuint index, const GLdouble *v); typedef void (APIENTRYP PFNGLVERTEXATTRIB1FARBPROC) (GLuint index, GLfloat x); typedef void (APIENTRYP PFNGLVERTEXATTRIB1FVARBPROC) (GLuint index, const GLfloat *v); typedef void (APIENTRYP PFNGLVERTEXATTRIB1SARBPROC) (GLuint index, GLshort x); typedef void (APIENTRYP PFNGLVERTEXATTRIB1SVARBPROC) (GLuint index, const GLshort *v); typedef void (APIENTRYP PFNGLVERTEXATTRIB2DARBPROC) (GLuint index, GLdouble x, GLdouble y); typedef void (APIENTRYP PFNGLVERTEXATTRIB2DVARBPROC) (GLuint index, const GLdouble *v); typedef void (APIENTRYP PFNGLVERTEXATTRIB2FARBPROC) (GLuint index, GLfloat x, GLfloat y); typedef void (APIENTRYP PFNGLVERTEXATTRIB2FVARBPROC) (GLuint index, const GLfloat *v); typedef void (APIENTRYP PFNGLVERTEXATTRIB2SARBPROC) (GLuint index, GLshort x, GLshort y); typedef void (APIENTRYP PFNGLVERTEXATTRIB2SVARBPROC) (GLuint index, const GLshort *v); typedef void (APIENTRYP PFNGLVERTEXATTRIB3DARBPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); typedef void (APIENTRYP PFNGLVERTEXATTRIB3DVARBPROC) (GLuint index, const GLdouble *v); typedef void (APIENTRYP PFNGLVERTEXATTRIB3FARBPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z); typedef void (APIENTRYP PFNGLVERTEXATTRIB3FVARBPROC) (GLuint index, const GLfloat *v); typedef void (APIENTRYP PFNGLVERTEXATTRIB3SARBPROC) (GLuint index, GLshort x, GLshort y, GLshort z); typedef void (APIENTRYP PFNGLVERTEXATTRIB3SVARBPROC) (GLuint index, const GLshort *v); typedef void (APIENTRYP PFNGLVERTEXATTRIB4NBVARBPROC) (GLuint index, const GLbyte *v); typedef void (APIENTRYP PFNGLVERTEXATTRIB4NIVARBPROC) (GLuint index, const GLint *v); typedef void (APIENTRYP PFNGLVERTEXATTRIB4NSVARBPROC) (GLuint index, const GLshort *v); typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBARBPROC) (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBVARBPROC) (GLuint index, const GLubyte *v); typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUIVARBPROC) (GLuint index, const GLuint *v); typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUSVARBPROC) (GLuint index, const GLushort *v); typedef void (APIENTRYP PFNGLVERTEXATTRIB4BVARBPROC) (GLuint index, const GLbyte *v); typedef void (APIENTRYP PFNGLVERTEXATTRIB4DARBPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); typedef void (APIENTRYP PFNGLVERTEXATTRIB4DVARBPROC) (GLuint index, const GLdouble *v); typedef void (APIENTRYP PFNGLVERTEXATTRIB4FARBPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); typedef void (APIENTRYP PFNGLVERTEXATTRIB4FVARBPROC) (GLuint index, const GLfloat *v); typedef void (APIENTRYP PFNGLVERTEXATTRIB4IVARBPROC) (GLuint index, const GLint *v); typedef void (APIENTRYP PFNGLVERTEXATTRIB4SARBPROC) (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); typedef void (APIENTRYP PFNGLVERTEXATTRIB4SVARBPROC) (GLuint index, const GLshort *v); typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBVARBPROC) (GLuint index, const GLubyte *v); typedef void (APIENTRYP PFNGLVERTEXATTRIB4UIVARBPROC) (GLuint index, const GLuint *v); typedef void (APIENTRYP PFNGLVERTEXATTRIB4USVARBPROC) (GLuint index, const GLushort *v); typedef void (APIENTRYP PFNGLVERTEXATTRIBPOINTERARBPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void *pointer); typedef void (APIENTRYP PFNGLENABLEVERTEXATTRIBARRAYARBPROC) (GLuint index); typedef void (APIENTRYP PFNGLDISABLEVERTEXATTRIBARRAYARBPROC) (GLuint index); typedef void (APIENTRYP PFNGLGETVERTEXATTRIBDVARBPROC) (GLuint index, GLenum pname, GLdouble *params); typedef void (APIENTRYP PFNGLGETVERTEXATTRIBFVARBPROC) (GLuint index, GLenum pname, GLfloat *params); typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIVARBPROC) (GLuint index, GLenum pname, GLint *params); typedef void (APIENTRYP PFNGLGETVERTEXATTRIBPOINTERVARBPROC) (GLuint index, GLenum pname, void **pointer); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glVertexAttrib1dARB (GLuint index, GLdouble x); GLAPI void APIENTRY glVertexAttrib1dvARB (GLuint index, const GLdouble *v); GLAPI void APIENTRY glVertexAttrib1fARB (GLuint index, GLfloat x); GLAPI void APIENTRY glVertexAttrib1fvARB (GLuint index, const GLfloat *v); GLAPI void APIENTRY glVertexAttrib1sARB (GLuint index, GLshort x); GLAPI void APIENTRY glVertexAttrib1svARB (GLuint index, const GLshort *v); GLAPI void APIENTRY glVertexAttrib2dARB (GLuint index, GLdouble x, GLdouble y); GLAPI void APIENTRY glVertexAttrib2dvARB (GLuint index, const GLdouble *v); GLAPI void APIENTRY glVertexAttrib2fARB (GLuint index, GLfloat x, GLfloat y); GLAPI void APIENTRY glVertexAttrib2fvARB (GLuint index, const GLfloat *v); GLAPI void APIENTRY glVertexAttrib2sARB (GLuint index, GLshort x, GLshort y); GLAPI void APIENTRY glVertexAttrib2svARB (GLuint index, const GLshort *v); GLAPI void APIENTRY glVertexAttrib3dARB (GLuint index, GLdouble x, GLdouble y, GLdouble z); GLAPI void APIENTRY glVertexAttrib3dvARB (GLuint index, const GLdouble *v); GLAPI void APIENTRY glVertexAttrib3fARB (GLuint index, GLfloat x, GLfloat y, GLfloat z); GLAPI void APIENTRY glVertexAttrib3fvARB (GLuint index, const GLfloat *v); GLAPI void APIENTRY glVertexAttrib3sARB (GLuint index, GLshort x, GLshort y, GLshort z); GLAPI void APIENTRY glVertexAttrib3svARB (GLuint index, const GLshort *v); GLAPI void APIENTRY glVertexAttrib4NbvARB (GLuint index, const GLbyte *v); GLAPI void APIENTRY glVertexAttrib4NivARB (GLuint index, const GLint *v); GLAPI void APIENTRY glVertexAttrib4NsvARB (GLuint index, const GLshort *v); GLAPI void APIENTRY glVertexAttrib4NubARB (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); GLAPI void APIENTRY glVertexAttrib4NubvARB (GLuint index, const GLubyte *v); GLAPI void APIENTRY glVertexAttrib4NuivARB (GLuint index, const GLuint *v); GLAPI void APIENTRY glVertexAttrib4NusvARB (GLuint index, const GLushort *v); GLAPI void APIENTRY glVertexAttrib4bvARB (GLuint index, const GLbyte *v); GLAPI void APIENTRY glVertexAttrib4dARB (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); GLAPI void APIENTRY glVertexAttrib4dvARB (GLuint index, const GLdouble *v); GLAPI void APIENTRY glVertexAttrib4fARB (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); GLAPI void APIENTRY glVertexAttrib4fvARB (GLuint index, const GLfloat *v); GLAPI void APIENTRY glVertexAttrib4ivARB (GLuint index, const GLint *v); GLAPI void APIENTRY glVertexAttrib4sARB (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); GLAPI void APIENTRY glVertexAttrib4svARB (GLuint index, const GLshort *v); GLAPI void APIENTRY glVertexAttrib4ubvARB (GLuint index, const GLubyte *v); GLAPI void APIENTRY glVertexAttrib4uivARB (GLuint index, const GLuint *v); GLAPI void APIENTRY glVertexAttrib4usvARB (GLuint index, const GLushort *v); GLAPI void APIENTRY glVertexAttribPointerARB (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void *pointer); GLAPI void APIENTRY glEnableVertexAttribArrayARB (GLuint index); GLAPI void APIENTRY glDisableVertexAttribArrayARB (GLuint index); GLAPI void APIENTRY glGetVertexAttribdvARB (GLuint index, GLenum pname, GLdouble *params); GLAPI void APIENTRY glGetVertexAttribfvARB (GLuint index, GLenum pname, GLfloat *params); GLAPI void APIENTRY glGetVertexAttribivARB (GLuint index, GLenum pname, GLint *params); GLAPI void APIENTRY glGetVertexAttribPointervARB (GLuint index, GLenum pname, void **pointer); #endif #endif /* GL_ARB_vertex_program */ #ifndef GL_ARB_vertex_shader #define GL_ARB_vertex_shader 1 #define GL_VERTEX_SHADER_ARB 0x8B31 #define GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB 0x8B4A #define GL_MAX_VARYING_FLOATS_ARB 0x8B4B #define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB 0x8B4C #define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB 0x8B4D #define GL_OBJECT_ACTIVE_ATTRIBUTES_ARB 0x8B89 #define GL_OBJECT_ACTIVE_ATTRIBUTE_MAX_LENGTH_ARB 0x8B8A typedef void (APIENTRYP PFNGLBINDATTRIBLOCATIONARBPROC) (GLhandleARB programObj, GLuint index, const GLcharARB *name); typedef void (APIENTRYP PFNGLGETACTIVEATTRIBARBPROC) (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei *length, GLint *size, GLenum *type, GLcharARB *name); typedef GLint (APIENTRYP PFNGLGETATTRIBLOCATIONARBPROC) (GLhandleARB programObj, const GLcharARB *name); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glBindAttribLocationARB (GLhandleARB programObj, GLuint index, const GLcharARB *name); GLAPI void APIENTRY glGetActiveAttribARB (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei *length, GLint *size, GLenum *type, GLcharARB *name); GLAPI GLint APIENTRY glGetAttribLocationARB (GLhandleARB programObj, const GLcharARB *name); #endif #endif /* GL_ARB_vertex_shader */ #ifndef GL_ARB_vertex_type_10f_11f_11f_rev #define GL_ARB_vertex_type_10f_11f_11f_rev 1 #endif /* GL_ARB_vertex_type_10f_11f_11f_rev */ #ifndef GL_ARB_vertex_type_2_10_10_10_rev #define GL_ARB_vertex_type_2_10_10_10_rev 1 #endif /* GL_ARB_vertex_type_2_10_10_10_rev */ #ifndef GL_ARB_viewport_array #define GL_ARB_viewport_array 1 typedef void (APIENTRYP PFNGLDEPTHRANGEARRAYDVNVPROC) (GLuint first, GLsizei count, const GLdouble *v); typedef void (APIENTRYP PFNGLDEPTHRANGEINDEXEDDNVPROC) (GLuint index, GLdouble n, GLdouble f); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glDepthRangeArraydvNV (GLuint first, GLsizei count, const GLdouble *v); GLAPI void APIENTRY glDepthRangeIndexeddNV (GLuint index, GLdouble n, GLdouble f); #endif #endif /* GL_ARB_viewport_array */ #ifndef GL_ARB_window_pos #define GL_ARB_window_pos 1 typedef void (APIENTRYP PFNGLWINDOWPOS2DARBPROC) (GLdouble x, GLdouble y); typedef void (APIENTRYP PFNGLWINDOWPOS2DVARBPROC) (const GLdouble *v); typedef void (APIENTRYP PFNGLWINDOWPOS2FARBPROC) (GLfloat x, GLfloat y); typedef void (APIENTRYP PFNGLWINDOWPOS2FVARBPROC) (const GLfloat *v); typedef void (APIENTRYP PFNGLWINDOWPOS2IARBPROC) (GLint x, GLint y); typedef void (APIENTRYP PFNGLWINDOWPOS2IVARBPROC) (const GLint *v); typedef void (APIENTRYP PFNGLWINDOWPOS2SARBPROC) (GLshort x, GLshort y); typedef void (APIENTRYP PFNGLWINDOWPOS2SVARBPROC) (const GLshort *v); typedef void (APIENTRYP PFNGLWINDOWPOS3DARBPROC) (GLdouble x, GLdouble y, GLdouble z); typedef void (APIENTRYP PFNGLWINDOWPOS3DVARBPROC) (const GLdouble *v); typedef void (APIENTRYP PFNGLWINDOWPOS3FARBPROC) (GLfloat x, GLfloat y, GLfloat z); typedef void (APIENTRYP PFNGLWINDOWPOS3FVARBPROC) (const GLfloat *v); typedef void (APIENTRYP PFNGLWINDOWPOS3IARBPROC) (GLint x, GLint y, GLint z); typedef void (APIENTRYP PFNGLWINDOWPOS3IVARBPROC) (const GLint *v); typedef void (APIENTRYP PFNGLWINDOWPOS3SARBPROC) (GLshort x, GLshort y, GLshort z); typedef void (APIENTRYP PFNGLWINDOWPOS3SVARBPROC) (const GLshort *v); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glWindowPos2dARB (GLdouble x, GLdouble y); GLAPI void APIENTRY glWindowPos2dvARB (const GLdouble *v); GLAPI void APIENTRY glWindowPos2fARB (GLfloat x, GLfloat y); GLAPI void APIENTRY glWindowPos2fvARB (const GLfloat *v); GLAPI void APIENTRY glWindowPos2iARB (GLint x, GLint y); GLAPI void APIENTRY glWindowPos2ivARB (const GLint *v); GLAPI void APIENTRY glWindowPos2sARB (GLshort x, GLshort y); GLAPI void APIENTRY glWindowPos2svARB (const GLshort *v); GLAPI void APIENTRY glWindowPos3dARB (GLdouble x, GLdouble y, GLdouble z); GLAPI void APIENTRY glWindowPos3dvARB (const GLdouble *v); GLAPI void APIENTRY glWindowPos3fARB (GLfloat x, GLfloat y, GLfloat z); GLAPI void APIENTRY glWindowPos3fvARB (const GLfloat *v); GLAPI void APIENTRY glWindowPos3iARB (GLint x, GLint y, GLint z); GLAPI void APIENTRY glWindowPos3ivARB (const GLint *v); GLAPI void APIENTRY glWindowPos3sARB (GLshort x, GLshort y, GLshort z); GLAPI void APIENTRY glWindowPos3svARB (const GLshort *v); #endif #endif /* GL_ARB_window_pos */ #ifndef GL_KHR_blend_equation_advanced #define GL_KHR_blend_equation_advanced 1 #define GL_MULTIPLY_KHR 0x9294 #define GL_SCREEN_KHR 0x9295 #define GL_OVERLAY_KHR 0x9296 #define GL_DARKEN_KHR 0x9297 #define GL_LIGHTEN_KHR 0x9298 #define GL_COLORDODGE_KHR 0x9299 #define GL_COLORBURN_KHR 0x929A #define GL_HARDLIGHT_KHR 0x929B #define GL_SOFTLIGHT_KHR 0x929C #define GL_DIFFERENCE_KHR 0x929E #define GL_EXCLUSION_KHR 0x92A0 #define GL_HSL_HUE_KHR 0x92AD #define GL_HSL_SATURATION_KHR 0x92AE #define GL_HSL_COLOR_KHR 0x92AF #define GL_HSL_LUMINOSITY_KHR 0x92B0 typedef void (APIENTRYP PFNGLBLENDBARRIERKHRPROC) (void); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glBlendBarrierKHR (void); #endif #endif /* GL_KHR_blend_equation_advanced */ #ifndef GL_KHR_blend_equation_advanced_coherent #define GL_KHR_blend_equation_advanced_coherent 1 #define GL_BLEND_ADVANCED_COHERENT_KHR 0x9285 #endif /* GL_KHR_blend_equation_advanced_coherent */ #ifndef GL_KHR_context_flush_control #define GL_KHR_context_flush_control 1 #endif /* GL_KHR_context_flush_control */ #ifndef GL_KHR_debug #define GL_KHR_debug 1 #endif /* GL_KHR_debug */ #ifndef GL_KHR_no_error #define GL_KHR_no_error 1 #define GL_CONTEXT_FLAG_NO_ERROR_BIT_KHR 0x00000008 #endif /* GL_KHR_no_error */ #ifndef GL_KHR_parallel_shader_compile #define GL_KHR_parallel_shader_compile 1 #define GL_MAX_SHADER_COMPILER_THREADS_KHR 0x91B0 #define GL_COMPLETION_STATUS_KHR 0x91B1 typedef void (APIENTRYP PFNGLMAXSHADERCOMPILERTHREADSKHRPROC) (GLuint count); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glMaxShaderCompilerThreadsKHR (GLuint count); #endif #endif /* GL_KHR_parallel_shader_compile */ #ifndef GL_KHR_robust_buffer_access_behavior #define GL_KHR_robust_buffer_access_behavior 1 #endif /* GL_KHR_robust_buffer_access_behavior */ #ifndef GL_KHR_robustness #define GL_KHR_robustness 1 #define GL_CONTEXT_ROBUST_ACCESS 0x90F3 #endif /* GL_KHR_robustness */ #ifndef GL_KHR_shader_subgroup #define GL_KHR_shader_subgroup 1 #define GL_SUBGROUP_SIZE_KHR 0x9532 #define GL_SUBGROUP_SUPPORTED_STAGES_KHR 0x9533 #define GL_SUBGROUP_SUPPORTED_FEATURES_KHR 0x9534 #define GL_SUBGROUP_QUAD_ALL_STAGES_KHR 0x9535 #define GL_SUBGROUP_FEATURE_BASIC_BIT_KHR 0x00000001 #define GL_SUBGROUP_FEATURE_VOTE_BIT_KHR 0x00000002 #define GL_SUBGROUP_FEATURE_ARITHMETIC_BIT_KHR 0x00000004 #define GL_SUBGROUP_FEATURE_BALLOT_BIT_KHR 0x00000008 #define GL_SUBGROUP_FEATURE_SHUFFLE_BIT_KHR 0x00000010 #define GL_SUBGROUP_FEATURE_SHUFFLE_RELATIVE_BIT_KHR 0x00000020 #define GL_SUBGROUP_FEATURE_CLUSTERED_BIT_KHR 0x00000040 #define GL_SUBGROUP_FEATURE_QUAD_BIT_KHR 0x00000080 #endif /* GL_KHR_shader_subgroup */ #ifndef GL_KHR_texture_compression_astc_hdr #define GL_KHR_texture_compression_astc_hdr 1 #define GL_COMPRESSED_RGBA_ASTC_4x4_KHR 0x93B0 #define GL_COMPRESSED_RGBA_ASTC_5x4_KHR 0x93B1 #define GL_COMPRESSED_RGBA_ASTC_5x5_KHR 0x93B2 #define GL_COMPRESSED_RGBA_ASTC_6x5_KHR 0x93B3 #define GL_COMPRESSED_RGBA_ASTC_6x6_KHR 0x93B4 #define GL_COMPRESSED_RGBA_ASTC_8x5_KHR 0x93B5 #define GL_COMPRESSED_RGBA_ASTC_8x6_KHR 0x93B6 #define GL_COMPRESSED_RGBA_ASTC_8x8_KHR 0x93B7 #define GL_COMPRESSED_RGBA_ASTC_10x5_KHR 0x93B8 #define GL_COMPRESSED_RGBA_ASTC_10x6_KHR 0x93B9 #define GL_COMPRESSED_RGBA_ASTC_10x8_KHR 0x93BA #define GL_COMPRESSED_RGBA_ASTC_10x10_KHR 0x93BB #define GL_COMPRESSED_RGBA_ASTC_12x10_KHR 0x93BC #define GL_COMPRESSED_RGBA_ASTC_12x12_KHR 0x93BD #define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR 0x93D0 #define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR 0x93D1 #define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR 0x93D2 #define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR 0x93D3 #define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR 0x93D4 #define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR 0x93D5 #define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR 0x93D6 #define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR 0x93D7 #define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR 0x93D8 #define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR 0x93D9 #define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR 0x93DA #define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR 0x93DB #define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR 0x93DC #define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR 0x93DD #endif /* GL_KHR_texture_compression_astc_hdr */ #ifndef GL_KHR_texture_compression_astc_ldr #define GL_KHR_texture_compression_astc_ldr 1 #endif /* GL_KHR_texture_compression_astc_ldr */ #ifndef GL_KHR_texture_compression_astc_sliced_3d #define GL_KHR_texture_compression_astc_sliced_3d 1 #endif /* GL_KHR_texture_compression_astc_sliced_3d */ #ifndef GL_OES_byte_coordinates #define GL_OES_byte_coordinates 1 typedef void (APIENTRYP PFNGLMULTITEXCOORD1BOESPROC) (GLenum texture, GLbyte s); typedef void (APIENTRYP PFNGLMULTITEXCOORD1BVOESPROC) (GLenum texture, const GLbyte *coords); typedef void (APIENTRYP PFNGLMULTITEXCOORD2BOESPROC) (GLenum texture, GLbyte s, GLbyte t); typedef void (APIENTRYP PFNGLMULTITEXCOORD2BVOESPROC) (GLenum texture, const GLbyte *coords); typedef void (APIENTRYP PFNGLMULTITEXCOORD3BOESPROC) (GLenum texture, GLbyte s, GLbyte t, GLbyte r); typedef void (APIENTRYP PFNGLMULTITEXCOORD3BVOESPROC) (GLenum texture, const GLbyte *coords); typedef void (APIENTRYP PFNGLMULTITEXCOORD4BOESPROC) (GLenum texture, GLbyte s, GLbyte t, GLbyte r, GLbyte q); typedef void (APIENTRYP PFNGLMULTITEXCOORD4BVOESPROC) (GLenum texture, const GLbyte *coords); typedef void (APIENTRYP PFNGLTEXCOORD1BOESPROC) (GLbyte s); typedef void (APIENTRYP PFNGLTEXCOORD1BVOESPROC) (const GLbyte *coords); typedef void (APIENTRYP PFNGLTEXCOORD2BOESPROC) (GLbyte s, GLbyte t); typedef void (APIENTRYP PFNGLTEXCOORD2BVOESPROC) (const GLbyte *coords); typedef void (APIENTRYP PFNGLTEXCOORD3BOESPROC) (GLbyte s, GLbyte t, GLbyte r); typedef void (APIENTRYP PFNGLTEXCOORD3BVOESPROC) (const GLbyte *coords); typedef void (APIENTRYP PFNGLTEXCOORD4BOESPROC) (GLbyte s, GLbyte t, GLbyte r, GLbyte q); typedef void (APIENTRYP PFNGLTEXCOORD4BVOESPROC) (const GLbyte *coords); typedef void (APIENTRYP PFNGLVERTEX2BOESPROC) (GLbyte x, GLbyte y); typedef void (APIENTRYP PFNGLVERTEX2BVOESPROC) (const GLbyte *coords); typedef void (APIENTRYP PFNGLVERTEX3BOESPROC) (GLbyte x, GLbyte y, GLbyte z); typedef void (APIENTRYP PFNGLVERTEX3BVOESPROC) (const GLbyte *coords); typedef void (APIENTRYP PFNGLVERTEX4BOESPROC) (GLbyte x, GLbyte y, GLbyte z, GLbyte w); typedef void (APIENTRYP PFNGLVERTEX4BVOESPROC) (const GLbyte *coords); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glMultiTexCoord1bOES (GLenum texture, GLbyte s); GLAPI void APIENTRY glMultiTexCoord1bvOES (GLenum texture, const GLbyte *coords); GLAPI void APIENTRY glMultiTexCoord2bOES (GLenum texture, GLbyte s, GLbyte t); GLAPI void APIENTRY glMultiTexCoord2bvOES (GLenum texture, const GLbyte *coords); GLAPI void APIENTRY glMultiTexCoord3bOES (GLenum texture, GLbyte s, GLbyte t, GLbyte r); GLAPI void APIENTRY glMultiTexCoord3bvOES (GLenum texture, const GLbyte *coords); GLAPI void APIENTRY glMultiTexCoord4bOES (GLenum texture, GLbyte s, GLbyte t, GLbyte r, GLbyte q); GLAPI void APIENTRY glMultiTexCoord4bvOES (GLenum texture, const GLbyte *coords); GLAPI void APIENTRY glTexCoord1bOES (GLbyte s); GLAPI void APIENTRY glTexCoord1bvOES (const GLbyte *coords); GLAPI void APIENTRY glTexCoord2bOES (GLbyte s, GLbyte t); GLAPI void APIENTRY glTexCoord2bvOES (const GLbyte *coords); GLAPI void APIENTRY glTexCoord3bOES (GLbyte s, GLbyte t, GLbyte r); GLAPI void APIENTRY glTexCoord3bvOES (const GLbyte *coords); GLAPI void APIENTRY glTexCoord4bOES (GLbyte s, GLbyte t, GLbyte r, GLbyte q); GLAPI void APIENTRY glTexCoord4bvOES (const GLbyte *coords); GLAPI void APIENTRY glVertex2bOES (GLbyte x, GLbyte y); GLAPI void APIENTRY glVertex2bvOES (const GLbyte *coords); GLAPI void APIENTRY glVertex3bOES (GLbyte x, GLbyte y, GLbyte z); GLAPI void APIENTRY glVertex3bvOES (const GLbyte *coords); GLAPI void APIENTRY glVertex4bOES (GLbyte x, GLbyte y, GLbyte z, GLbyte w); GLAPI void APIENTRY glVertex4bvOES (const GLbyte *coords); #endif #endif /* GL_OES_byte_coordinates */ #ifndef GL_OES_compressed_paletted_texture #define GL_OES_compressed_paletted_texture 1 #define GL_PALETTE4_RGB8_OES 0x8B90 #define GL_PALETTE4_RGBA8_OES 0x8B91 #define GL_PALETTE4_R5_G6_B5_OES 0x8B92 #define GL_PALETTE4_RGBA4_OES 0x8B93 #define GL_PALETTE4_RGB5_A1_OES 0x8B94 #define GL_PALETTE8_RGB8_OES 0x8B95 #define GL_PALETTE8_RGBA8_OES 0x8B96 #define GL_PALETTE8_R5_G6_B5_OES 0x8B97 #define GL_PALETTE8_RGBA4_OES 0x8B98 #define GL_PALETTE8_RGB5_A1_OES 0x8B99 #endif /* GL_OES_compressed_paletted_texture */ #ifndef GL_OES_fixed_point #define GL_OES_fixed_point 1 typedef khronos_int32_t GLfixed; #define GL_FIXED_OES 0x140C typedef void (APIENTRYP PFNGLALPHAFUNCXOESPROC) (GLenum func, GLfixed ref); typedef void (APIENTRYP PFNGLCLEARCOLORXOESPROC) (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha); typedef void (APIENTRYP PFNGLCLEARDEPTHXOESPROC) (GLfixed depth); typedef void (APIENTRYP PFNGLCLIPPLANEXOESPROC) (GLenum plane, const GLfixed *equation); typedef void (APIENTRYP PFNGLCOLOR4XOESPROC) (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha); typedef void (APIENTRYP PFNGLDEPTHRANGEXOESPROC) (GLfixed n, GLfixed f); typedef void (APIENTRYP PFNGLFOGXOESPROC) (GLenum pname, GLfixed param); typedef void (APIENTRYP PFNGLFOGXVOESPROC) (GLenum pname, const GLfixed *param); typedef void (APIENTRYP PFNGLFRUSTUMXOESPROC) (GLfixed l, GLfixed r, GLfixed b, GLfixed t, GLfixed n, GLfixed f); typedef void (APIENTRYP PFNGLGETCLIPPLANEXOESPROC) (GLenum plane, GLfixed *equation); typedef void (APIENTRYP PFNGLGETFIXEDVOESPROC) (GLenum pname, GLfixed *params); typedef void (APIENTRYP PFNGLGETTEXENVXVOESPROC) (GLenum target, GLenum pname, GLfixed *params); typedef void (APIENTRYP PFNGLGETTEXPARAMETERXVOESPROC) (GLenum target, GLenum pname, GLfixed *params); typedef void (APIENTRYP PFNGLLIGHTMODELXOESPROC) (GLenum pname, GLfixed param); typedef void (APIENTRYP PFNGLLIGHTMODELXVOESPROC) (GLenum pname, const GLfixed *param); typedef void (APIENTRYP PFNGLLIGHTXOESPROC) (GLenum light, GLenum pname, GLfixed param); typedef void (APIENTRYP PFNGLLIGHTXVOESPROC) (GLenum light, GLenum pname, const GLfixed *params); typedef void (APIENTRYP PFNGLLINEWIDTHXOESPROC) (GLfixed width); typedef void (APIENTRYP PFNGLLOADMATRIXXOESPROC) (const GLfixed *m); typedef void (APIENTRYP PFNGLMATERIALXOESPROC) (GLenum face, GLenum pname, GLfixed param); typedef void (APIENTRYP PFNGLMATERIALXVOESPROC) (GLenum face, GLenum pname, const GLfixed *param); typedef void (APIENTRYP PFNGLMULTMATRIXXOESPROC) (const GLfixed *m); typedef void (APIENTRYP PFNGLMULTITEXCOORD4XOESPROC) (GLenum texture, GLfixed s, GLfixed t, GLfixed r, GLfixed q); typedef void (APIENTRYP PFNGLNORMAL3XOESPROC) (GLfixed nx, GLfixed ny, GLfixed nz); typedef void (APIENTRYP PFNGLORTHOXOESPROC) (GLfixed l, GLfixed r, GLfixed b, GLfixed t, GLfixed n, GLfixed f); typedef void (APIENTRYP PFNGLPOINTPARAMETERXVOESPROC) (GLenum pname, const GLfixed *params); typedef void (APIENTRYP PFNGLPOINTSIZEXOESPROC) (GLfixed size); typedef void (APIENTRYP PFNGLPOLYGONOFFSETXOESPROC) (GLfixed factor, GLfixed units); typedef void (APIENTRYP PFNGLROTATEXOESPROC) (GLfixed angle, GLfixed x, GLfixed y, GLfixed z); typedef void (APIENTRYP PFNGLSCALEXOESPROC) (GLfixed x, GLfixed y, GLfixed z); typedef void (APIENTRYP PFNGLTEXENVXOESPROC) (GLenum target, GLenum pname, GLfixed param); typedef void (APIENTRYP PFNGLTEXENVXVOESPROC) (GLenum target, GLenum pname, const GLfixed *params); typedef void (APIENTRYP PFNGLTEXPARAMETERXOESPROC) (GLenum target, GLenum pname, GLfixed param); typedef void (APIENTRYP PFNGLTEXPARAMETERXVOESPROC) (GLenum target, GLenum pname, const GLfixed *params); typedef void (APIENTRYP PFNGLTRANSLATEXOESPROC) (GLfixed x, GLfixed y, GLfixed z); typedef void (APIENTRYP PFNGLACCUMXOESPROC) (GLenum op, GLfixed value); typedef void (APIENTRYP PFNGLBITMAPXOESPROC) (GLsizei width, GLsizei height, GLfixed xorig, GLfixed yorig, GLfixed xmove, GLfixed ymove, const GLubyte *bitmap); typedef void (APIENTRYP PFNGLBLENDCOLORXOESPROC) (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha); typedef void (APIENTRYP PFNGLCLEARACCUMXOESPROC) (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha); typedef void (APIENTRYP PFNGLCOLOR3XOESPROC) (GLfixed red, GLfixed green, GLfixed blue); typedef void (APIENTRYP PFNGLCOLOR3XVOESPROC) (const GLfixed *components); typedef void (APIENTRYP PFNGLCOLOR4XVOESPROC) (const GLfixed *components); typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERXOESPROC) (GLenum target, GLenum pname, GLfixed param); typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERXVOESPROC) (GLenum target, GLenum pname, const GLfixed *params); typedef void (APIENTRYP PFNGLEVALCOORD1XOESPROC) (GLfixed u); typedef void (APIENTRYP PFNGLEVALCOORD1XVOESPROC) (const GLfixed *coords); typedef void (APIENTRYP PFNGLEVALCOORD2XOESPROC) (GLfixed u, GLfixed v); typedef void (APIENTRYP PFNGLEVALCOORD2XVOESPROC) (const GLfixed *coords); typedef void (APIENTRYP PFNGLFEEDBACKBUFFERXOESPROC) (GLsizei n, GLenum type, const GLfixed *buffer); typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERXVOESPROC) (GLenum target, GLenum pname, GLfixed *params); typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERXVOESPROC) (GLenum target, GLenum pname, GLfixed *params); typedef void (APIENTRYP PFNGLGETLIGHTXOESPROC) (GLenum light, GLenum pname, GLfixed *params); typedef void (APIENTRYP PFNGLGETMAPXVOESPROC) (GLenum target, GLenum query, GLfixed *v); typedef void (APIENTRYP PFNGLGETMATERIALXOESPROC) (GLenum face, GLenum pname, GLfixed param); typedef void (APIENTRYP PFNGLGETPIXELMAPXVPROC) (GLenum map, GLint size, GLfixed *values); typedef void (APIENTRYP PFNGLGETTEXGENXVOESPROC) (GLenum coord, GLenum pname, GLfixed *params); typedef void (APIENTRYP PFNGLGETTEXLEVELPARAMETERXVOESPROC) (GLenum target, GLint level, GLenum pname, GLfixed *params); typedef void (APIENTRYP PFNGLINDEXXOESPROC) (GLfixed component); typedef void (APIENTRYP PFNGLINDEXXVOESPROC) (const GLfixed *component); typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXXOESPROC) (const GLfixed *m); typedef void (APIENTRYP PFNGLMAP1XOESPROC) (GLenum target, GLfixed u1, GLfixed u2, GLint stride, GLint order, GLfixed points); typedef void (APIENTRYP PFNGLMAP2XOESPROC) (GLenum target, GLfixed u1, GLfixed u2, GLint ustride, GLint uorder, GLfixed v1, GLfixed v2, GLint vstride, GLint vorder, GLfixed points); typedef void (APIENTRYP PFNGLMAPGRID1XOESPROC) (GLint n, GLfixed u1, GLfixed u2); typedef void (APIENTRYP PFNGLMAPGRID2XOESPROC) (GLint n, GLfixed u1, GLfixed u2, GLfixed v1, GLfixed v2); typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXXOESPROC) (const GLfixed *m); typedef void (APIENTRYP PFNGLMULTITEXCOORD1XOESPROC) (GLenum texture, GLfixed s); typedef void (APIENTRYP PFNGLMULTITEXCOORD1XVOESPROC) (GLenum texture, const GLfixed *coords); typedef void (APIENTRYP PFNGLMULTITEXCOORD2XOESPROC) (GLenum texture, GLfixed s, GLfixed t); typedef void (APIENTRYP PFNGLMULTITEXCOORD2XVOESPROC) (GLenum texture, const GLfixed *coords); typedef void (APIENTRYP PFNGLMULTITEXCOORD3XOESPROC) (GLenum texture, GLfixed s, GLfixed t, GLfixed r); typedef void (APIENTRYP PFNGLMULTITEXCOORD3XVOESPROC) (GLenum texture, const GLfixed *coords); typedef void (APIENTRYP PFNGLMULTITEXCOORD4XVOESPROC) (GLenum texture, const GLfixed *coords); typedef void (APIENTRYP PFNGLNORMAL3XVOESPROC) (const GLfixed *coords); typedef void (APIENTRYP PFNGLPASSTHROUGHXOESPROC) (GLfixed token); typedef void (APIENTRYP PFNGLPIXELMAPXPROC) (GLenum map, GLint size, const GLfixed *values); typedef void (APIENTRYP PFNGLPIXELSTOREXPROC) (GLenum pname, GLfixed param); typedef void (APIENTRYP PFNGLPIXELTRANSFERXOESPROC) (GLenum pname, GLfixed param); typedef void (APIENTRYP PFNGLPIXELZOOMXOESPROC) (GLfixed xfactor, GLfixed yfactor); typedef void (APIENTRYP PFNGLPRIORITIZETEXTURESXOESPROC) (GLsizei n, const GLuint *textures, const GLfixed *priorities); typedef void (APIENTRYP PFNGLRASTERPOS2XOESPROC) (GLfixed x, GLfixed y); typedef void (APIENTRYP PFNGLRASTERPOS2XVOESPROC) (const GLfixed *coords); typedef void (APIENTRYP PFNGLRASTERPOS3XOESPROC) (GLfixed x, GLfixed y, GLfixed z); typedef void (APIENTRYP PFNGLRASTERPOS3XVOESPROC) (const GLfixed *coords); typedef void (APIENTRYP PFNGLRASTERPOS4XOESPROC) (GLfixed x, GLfixed y, GLfixed z, GLfixed w); typedef void (APIENTRYP PFNGLRASTERPOS4XVOESPROC) (const GLfixed *coords); typedef void (APIENTRYP PFNGLRECTXOESPROC) (GLfixed x1, GLfixed y1, GLfixed x2, GLfixed y2); typedef void (APIENTRYP PFNGLRECTXVOESPROC) (const GLfixed *v1, const GLfixed *v2); typedef void (APIENTRYP PFNGLTEXCOORD1XOESPROC) (GLfixed s); typedef void (APIENTRYP PFNGLTEXCOORD1XVOESPROC) (const GLfixed *coords); typedef void (APIENTRYP PFNGLTEXCOORD2XOESPROC) (GLfixed s, GLfixed t); typedef void (APIENTRYP PFNGLTEXCOORD2XVOESPROC) (const GLfixed *coords); typedef void (APIENTRYP PFNGLTEXCOORD3XOESPROC) (GLfixed s, GLfixed t, GLfixed r); typedef void (APIENTRYP PFNGLTEXCOORD3XVOESPROC) (const GLfixed *coords); typedef void (APIENTRYP PFNGLTEXCOORD4XOESPROC) (GLfixed s, GLfixed t, GLfixed r, GLfixed q); typedef void (APIENTRYP PFNGLTEXCOORD4XVOESPROC) (const GLfixed *coords); typedef void (APIENTRYP PFNGLTEXGENXOESPROC) (GLenum coord, GLenum pname, GLfixed param); typedef void (APIENTRYP PFNGLTEXGENXVOESPROC) (GLenum coord, GLenum pname, const GLfixed *params); typedef void (APIENTRYP PFNGLVERTEX2XOESPROC) (GLfixed x); typedef void (APIENTRYP PFNGLVERTEX2XVOESPROC) (const GLfixed *coords); typedef void (APIENTRYP PFNGLVERTEX3XOESPROC) (GLfixed x, GLfixed y); typedef void (APIENTRYP PFNGLVERTEX3XVOESPROC) (const GLfixed *coords); typedef void (APIENTRYP PFNGLVERTEX4XOESPROC) (GLfixed x, GLfixed y, GLfixed z); typedef void (APIENTRYP PFNGLVERTEX4XVOESPROC) (const GLfixed *coords); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glAlphaFuncxOES (GLenum func, GLfixed ref); GLAPI void APIENTRY glClearColorxOES (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha); GLAPI void APIENTRY glClearDepthxOES (GLfixed depth); GLAPI void APIENTRY glClipPlanexOES (GLenum plane, const GLfixed *equation); GLAPI void APIENTRY glColor4xOES (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha); GLAPI void APIENTRY glDepthRangexOES (GLfixed n, GLfixed f); GLAPI void APIENTRY glFogxOES (GLenum pname, GLfixed param); GLAPI void APIENTRY glFogxvOES (GLenum pname, const GLfixed *param); GLAPI void APIENTRY glFrustumxOES (GLfixed l, GLfixed r, GLfixed b, GLfixed t, GLfixed n, GLfixed f); GLAPI void APIENTRY glGetClipPlanexOES (GLenum plane, GLfixed *equation); GLAPI void APIENTRY glGetFixedvOES (GLenum pname, GLfixed *params); GLAPI void APIENTRY glGetTexEnvxvOES (GLenum target, GLenum pname, GLfixed *params); GLAPI void APIENTRY glGetTexParameterxvOES (GLenum target, GLenum pname, GLfixed *params); GLAPI void APIENTRY glLightModelxOES (GLenum pname, GLfixed param); GLAPI void APIENTRY glLightModelxvOES (GLenum pname, const GLfixed *param); GLAPI void APIENTRY glLightxOES (GLenum light, GLenum pname, GLfixed param); GLAPI void APIENTRY glLightxvOES (GLenum light, GLenum pname, const GLfixed *params); GLAPI void APIENTRY glLineWidthxOES (GLfixed width); GLAPI void APIENTRY glLoadMatrixxOES (const GLfixed *m); GLAPI void APIENTRY glMaterialxOES (GLenum face, GLenum pname, GLfixed param); GLAPI void APIENTRY glMaterialxvOES (GLenum face, GLenum pname, const GLfixed *param); GLAPI void APIENTRY glMultMatrixxOES (const GLfixed *m); GLAPI void APIENTRY glMultiTexCoord4xOES (GLenum texture, GLfixed s, GLfixed t, GLfixed r, GLfixed q); GLAPI void APIENTRY glNormal3xOES (GLfixed nx, GLfixed ny, GLfixed nz); GLAPI void APIENTRY glOrthoxOES (GLfixed l, GLfixed r, GLfixed b, GLfixed t, GLfixed n, GLfixed f); GLAPI void APIENTRY glPointParameterxvOES (GLenum pname, const GLfixed *params); GLAPI void APIENTRY glPointSizexOES (GLfixed size); GLAPI void APIENTRY glPolygonOffsetxOES (GLfixed factor, GLfixed units); GLAPI void APIENTRY glRotatexOES (GLfixed angle, GLfixed x, GLfixed y, GLfixed z); GLAPI void APIENTRY glScalexOES (GLfixed x, GLfixed y, GLfixed z); GLAPI void APIENTRY glTexEnvxOES (GLenum target, GLenum pname, GLfixed param); GLAPI void APIENTRY glTexEnvxvOES (GLenum target, GLenum pname, const GLfixed *params); GLAPI void APIENTRY glTexParameterxOES (GLenum target, GLenum pname, GLfixed param); GLAPI void APIENTRY glTexParameterxvOES (GLenum target, GLenum pname, const GLfixed *params); GLAPI void APIENTRY glTranslatexOES (GLfixed x, GLfixed y, GLfixed z); GLAPI void APIENTRY glAccumxOES (GLenum op, GLfixed value); GLAPI void APIENTRY glBitmapxOES (GLsizei width, GLsizei height, GLfixed xorig, GLfixed yorig, GLfixed xmove, GLfixed ymove, const GLubyte *bitmap); GLAPI void APIENTRY glBlendColorxOES (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha); GLAPI void APIENTRY glClearAccumxOES (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha); GLAPI void APIENTRY glColor3xOES (GLfixed red, GLfixed green, GLfixed blue); GLAPI void APIENTRY glColor3xvOES (const GLfixed *components); GLAPI void APIENTRY glColor4xvOES (const GLfixed *components); GLAPI void APIENTRY glConvolutionParameterxOES (GLenum target, GLenum pname, GLfixed param); GLAPI void APIENTRY glConvolutionParameterxvOES (GLenum target, GLenum pname, const GLfixed *params); GLAPI void APIENTRY glEvalCoord1xOES (GLfixed u); GLAPI void APIENTRY glEvalCoord1xvOES (const GLfixed *coords); GLAPI void APIENTRY glEvalCoord2xOES (GLfixed u, GLfixed v); GLAPI void APIENTRY glEvalCoord2xvOES (const GLfixed *coords); GLAPI void APIENTRY glFeedbackBufferxOES (GLsizei n, GLenum type, const GLfixed *buffer); GLAPI void APIENTRY glGetConvolutionParameterxvOES (GLenum target, GLenum pname, GLfixed *params); GLAPI void APIENTRY glGetHistogramParameterxvOES (GLenum target, GLenum pname, GLfixed *params); GLAPI void APIENTRY glGetLightxOES (GLenum light, GLenum pname, GLfixed *params); GLAPI void APIENTRY glGetMapxvOES (GLenum target, GLenum query, GLfixed *v); GLAPI void APIENTRY glGetMaterialxOES (GLenum face, GLenum pname, GLfixed param); GLAPI void APIENTRY glGetPixelMapxv (GLenum map, GLint size, GLfixed *values); GLAPI void APIENTRY glGetTexGenxvOES (GLenum coord, GLenum pname, GLfixed *params); GLAPI void APIENTRY glGetTexLevelParameterxvOES (GLenum target, GLint level, GLenum pname, GLfixed *params); GLAPI void APIENTRY glIndexxOES (GLfixed component); GLAPI void APIENTRY glIndexxvOES (const GLfixed *component); GLAPI void APIENTRY glLoadTransposeMatrixxOES (const GLfixed *m); GLAPI void APIENTRY glMap1xOES (GLenum target, GLfixed u1, GLfixed u2, GLint stride, GLint order, GLfixed points); GLAPI void APIENTRY glMap2xOES (GLenum target, GLfixed u1, GLfixed u2, GLint ustride, GLint uorder, GLfixed v1, GLfixed v2, GLint vstride, GLint vorder, GLfixed points); GLAPI void APIENTRY glMapGrid1xOES (GLint n, GLfixed u1, GLfixed u2); GLAPI void APIENTRY glMapGrid2xOES (GLint n, GLfixed u1, GLfixed u2, GLfixed v1, GLfixed v2); GLAPI void APIENTRY glMultTransposeMatrixxOES (const GLfixed *m); GLAPI void APIENTRY glMultiTexCoord1xOES (GLenum texture, GLfixed s); GLAPI void APIENTRY glMultiTexCoord1xvOES (GLenum texture, const GLfixed *coords); GLAPI void APIENTRY glMultiTexCoord2xOES (GLenum texture, GLfixed s, GLfixed t); GLAPI void APIENTRY glMultiTexCoord2xvOES (GLenum texture, const GLfixed *coords); GLAPI void APIENTRY glMultiTexCoord3xOES (GLenum texture, GLfixed s, GLfixed t, GLfixed r); GLAPI void APIENTRY glMultiTexCoord3xvOES (GLenum texture, const GLfixed *coords); GLAPI void APIENTRY glMultiTexCoord4xvOES (GLenum texture, const GLfixed *coords); GLAPI void APIENTRY glNormal3xvOES (const GLfixed *coords); GLAPI void APIENTRY glPassThroughxOES (GLfixed token); GLAPI void APIENTRY glPixelMapx (GLenum map, GLint size, const GLfixed *values); GLAPI void APIENTRY glPixelStorex (GLenum pname, GLfixed param); GLAPI void APIENTRY glPixelTransferxOES (GLenum pname, GLfixed param); GLAPI void APIENTRY glPixelZoomxOES (GLfixed xfactor, GLfixed yfactor); GLAPI void APIENTRY glPrioritizeTexturesxOES (GLsizei n, const GLuint *textures, const GLfixed *priorities); GLAPI void APIENTRY glRasterPos2xOES (GLfixed x, GLfixed y); GLAPI void APIENTRY glRasterPos2xvOES (const GLfixed *coords); GLAPI void APIENTRY glRasterPos3xOES (GLfixed x, GLfixed y, GLfixed z); GLAPI void APIENTRY glRasterPos3xvOES (const GLfixed *coords); GLAPI void APIENTRY glRasterPos4xOES (GLfixed x, GLfixed y, GLfixed z, GLfixed w); GLAPI void APIENTRY glRasterPos4xvOES (const GLfixed *coords); GLAPI void APIENTRY glRectxOES (GLfixed x1, GLfixed y1, GLfixed x2, GLfixed y2); GLAPI void APIENTRY glRectxvOES (const GLfixed *v1, const GLfixed *v2); GLAPI void APIENTRY glTexCoord1xOES (GLfixed s); GLAPI void APIENTRY glTexCoord1xvOES (const GLfixed *coords); GLAPI void APIENTRY glTexCoord2xOES (GLfixed s, GLfixed t); GLAPI void APIENTRY glTexCoord2xvOES (const GLfixed *coords); GLAPI void APIENTRY glTexCoord3xOES (GLfixed s, GLfixed t, GLfixed r); GLAPI void APIENTRY glTexCoord3xvOES (const GLfixed *coords); GLAPI void APIENTRY glTexCoord4xOES (GLfixed s, GLfixed t, GLfixed r, GLfixed q); GLAPI void APIENTRY glTexCoord4xvOES (const GLfixed *coords); GLAPI void APIENTRY glTexGenxOES (GLenum coord, GLenum pname, GLfixed param); GLAPI void APIENTRY glTexGenxvOES (GLenum coord, GLenum pname, const GLfixed *params); GLAPI void APIENTRY glVertex2xOES (GLfixed x); GLAPI void APIENTRY glVertex2xvOES (const GLfixed *coords); GLAPI void APIENTRY glVertex3xOES (GLfixed x, GLfixed y); GLAPI void APIENTRY glVertex3xvOES (const GLfixed *coords); GLAPI void APIENTRY glVertex4xOES (GLfixed x, GLfixed y, GLfixed z); GLAPI void APIENTRY glVertex4xvOES (const GLfixed *coords); #endif #endif /* GL_OES_fixed_point */ #ifndef GL_OES_query_matrix #define GL_OES_query_matrix 1 typedef GLbitfield (APIENTRYP PFNGLQUERYMATRIXXOESPROC) (GLfixed *mantissa, GLint *exponent); #ifdef GL_GLEXT_PROTOTYPES GLAPI GLbitfield APIENTRY glQueryMatrixxOES (GLfixed *mantissa, GLint *exponent); #endif #endif /* GL_OES_query_matrix */ #ifndef GL_OES_read_format #define GL_OES_read_format 1 #define GL_IMPLEMENTATION_COLOR_READ_TYPE_OES 0x8B9A #define GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES 0x8B9B #endif /* GL_OES_read_format */ #ifndef GL_OES_single_precision #define GL_OES_single_precision 1 typedef void (APIENTRYP PFNGLCLEARDEPTHFOESPROC) (GLclampf depth); typedef void (APIENTRYP PFNGLCLIPPLANEFOESPROC) (GLenum plane, const GLfloat *equation); typedef void (APIENTRYP PFNGLDEPTHRANGEFOESPROC) (GLclampf n, GLclampf f); typedef void (APIENTRYP PFNGLFRUSTUMFOESPROC) (GLfloat l, GLfloat r, GLfloat b, GLfloat t, GLfloat n, GLfloat f); typedef void (APIENTRYP PFNGLGETCLIPPLANEFOESPROC) (GLenum plane, GLfloat *equation); typedef void (APIENTRYP PFNGLORTHOFOESPROC) (GLfloat l, GLfloat r, GLfloat b, GLfloat t, GLfloat n, GLfloat f); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glClearDepthfOES (GLclampf depth); GLAPI void APIENTRY glClipPlanefOES (GLenum plane, const GLfloat *equation); GLAPI void APIENTRY glDepthRangefOES (GLclampf n, GLclampf f); GLAPI void APIENTRY glFrustumfOES (GLfloat l, GLfloat r, GLfloat b, GLfloat t, GLfloat n, GLfloat f); GLAPI void APIENTRY glGetClipPlanefOES (GLenum plane, GLfloat *equation); GLAPI void APIENTRY glOrthofOES (GLfloat l, GLfloat r, GLfloat b, GLfloat t, GLfloat n, GLfloat f); #endif #endif /* GL_OES_single_precision */ #ifndef GL_3DFX_multisample #define GL_3DFX_multisample 1 #define GL_MULTISAMPLE_3DFX 0x86B2 #define GL_SAMPLE_BUFFERS_3DFX 0x86B3 #define GL_SAMPLES_3DFX 0x86B4 #define GL_MULTISAMPLE_BIT_3DFX 0x20000000 #endif /* GL_3DFX_multisample */ #ifndef GL_3DFX_tbuffer #define GL_3DFX_tbuffer 1 typedef void (APIENTRYP PFNGLTBUFFERMASK3DFXPROC) (GLuint mask); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glTbufferMask3DFX (GLuint mask); #endif #endif /* GL_3DFX_tbuffer */ #ifndef GL_3DFX_texture_compression_FXT1 #define GL_3DFX_texture_compression_FXT1 1 #define GL_COMPRESSED_RGB_FXT1_3DFX 0x86B0 #define GL_COMPRESSED_RGBA_FXT1_3DFX 0x86B1 #endif /* GL_3DFX_texture_compression_FXT1 */ #ifndef GL_AMD_blend_minmax_factor #define GL_AMD_blend_minmax_factor 1 #define GL_FACTOR_MIN_AMD 0x901C #define GL_FACTOR_MAX_AMD 0x901D #endif /* GL_AMD_blend_minmax_factor */ #ifndef GL_AMD_conservative_depth #define GL_AMD_conservative_depth 1 #endif /* GL_AMD_conservative_depth */ #ifndef GL_AMD_debug_output #define GL_AMD_debug_output 1 typedef void (APIENTRY *GLDEBUGPROCAMD)(GLuint id,GLenum category,GLenum severity,GLsizei length,const GLchar *message,void *userParam); #define GL_MAX_DEBUG_MESSAGE_LENGTH_AMD 0x9143 #define GL_MAX_DEBUG_LOGGED_MESSAGES_AMD 0x9144 #define GL_DEBUG_LOGGED_MESSAGES_AMD 0x9145 #define GL_DEBUG_SEVERITY_HIGH_AMD 0x9146 #define GL_DEBUG_SEVERITY_MEDIUM_AMD 0x9147 #define GL_DEBUG_SEVERITY_LOW_AMD 0x9148 #define GL_DEBUG_CATEGORY_API_ERROR_AMD 0x9149 #define GL_DEBUG_CATEGORY_WINDOW_SYSTEM_AMD 0x914A #define GL_DEBUG_CATEGORY_DEPRECATION_AMD 0x914B #define GL_DEBUG_CATEGORY_UNDEFINED_BEHAVIOR_AMD 0x914C #define GL_DEBUG_CATEGORY_PERFORMANCE_AMD 0x914D #define GL_DEBUG_CATEGORY_SHADER_COMPILER_AMD 0x914E #define GL_DEBUG_CATEGORY_APPLICATION_AMD 0x914F #define GL_DEBUG_CATEGORY_OTHER_AMD 0x9150 typedef void (APIENTRYP PFNGLDEBUGMESSAGEENABLEAMDPROC) (GLenum category, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); typedef void (APIENTRYP PFNGLDEBUGMESSAGEINSERTAMDPROC) (GLenum category, GLenum severity, GLuint id, GLsizei length, const GLchar *buf); typedef void (APIENTRYP PFNGLDEBUGMESSAGECALLBACKAMDPROC) (GLDEBUGPROCAMD callback, void *userParam); typedef GLuint (APIENTRYP PFNGLGETDEBUGMESSAGELOGAMDPROC) (GLuint count, GLsizei bufSize, GLenum *categories, GLuint *severities, GLuint *ids, GLsizei *lengths, GLchar *message); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glDebugMessageEnableAMD (GLenum category, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); GLAPI void APIENTRY glDebugMessageInsertAMD (GLenum category, GLenum severity, GLuint id, GLsizei length, const GLchar *buf); GLAPI void APIENTRY glDebugMessageCallbackAMD (GLDEBUGPROCAMD callback, void *userParam); GLAPI GLuint APIENTRY glGetDebugMessageLogAMD (GLuint count, GLsizei bufSize, GLenum *categories, GLuint *severities, GLuint *ids, GLsizei *lengths, GLchar *message); #endif #endif /* GL_AMD_debug_output */ #ifndef GL_AMD_depth_clamp_separate #define GL_AMD_depth_clamp_separate 1 #define GL_DEPTH_CLAMP_NEAR_AMD 0x901E #define GL_DEPTH_CLAMP_FAR_AMD 0x901F #endif /* GL_AMD_depth_clamp_separate */ #ifndef GL_AMD_draw_buffers_blend #define GL_AMD_draw_buffers_blend 1 typedef void (APIENTRYP PFNGLBLENDFUNCINDEXEDAMDPROC) (GLuint buf, GLenum src, GLenum dst); typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEINDEXEDAMDPROC) (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); typedef void (APIENTRYP PFNGLBLENDEQUATIONINDEXEDAMDPROC) (GLuint buf, GLenum mode); typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEINDEXEDAMDPROC) (GLuint buf, GLenum modeRGB, GLenum modeAlpha); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glBlendFuncIndexedAMD (GLuint buf, GLenum src, GLenum dst); GLAPI void APIENTRY glBlendFuncSeparateIndexedAMD (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); GLAPI void APIENTRY glBlendEquationIndexedAMD (GLuint buf, GLenum mode); GLAPI void APIENTRY glBlendEquationSeparateIndexedAMD (GLuint buf, GLenum modeRGB, GLenum modeAlpha); #endif #endif /* GL_AMD_draw_buffers_blend */ #ifndef GL_AMD_framebuffer_multisample_advanced #define GL_AMD_framebuffer_multisample_advanced 1 #define GL_RENDERBUFFER_STORAGE_SAMPLES_AMD 0x91B2 #define GL_MAX_COLOR_FRAMEBUFFER_SAMPLES_AMD 0x91B3 #define GL_MAX_COLOR_FRAMEBUFFER_STORAGE_SAMPLES_AMD 0x91B4 #define GL_MAX_DEPTH_STENCIL_FRAMEBUFFER_SAMPLES_AMD 0x91B5 #define GL_NUM_SUPPORTED_MULTISAMPLE_MODES_AMD 0x91B6 #define GL_SUPPORTED_MULTISAMPLE_MODES_AMD 0x91B7 typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEADVANCEDAMDPROC) (GLenum target, GLsizei samples, GLsizei storageSamples, GLenum internalformat, GLsizei width, GLsizei height); typedef void (APIENTRYP PFNGLNAMEDRENDERBUFFERSTORAGEMULTISAMPLEADVANCEDAMDPROC) (GLuint renderbuffer, GLsizei samples, GLsizei storageSamples, GLenum internalformat, GLsizei width, GLsizei height); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glRenderbufferStorageMultisampleAdvancedAMD (GLenum target, GLsizei samples, GLsizei storageSamples, GLenum internalformat, GLsizei width, GLsizei height); GLAPI void APIENTRY glNamedRenderbufferStorageMultisampleAdvancedAMD (GLuint renderbuffer, GLsizei samples, GLsizei storageSamples, GLenum internalformat, GLsizei width, GLsizei height); #endif #endif /* GL_AMD_framebuffer_multisample_advanced */ #ifndef GL_AMD_framebuffer_sample_positions #define GL_AMD_framebuffer_sample_positions 1 #define GL_SUBSAMPLE_DISTANCE_AMD 0x883F #define GL_PIXELS_PER_SAMPLE_PATTERN_X_AMD 0x91AE #define GL_PIXELS_PER_SAMPLE_PATTERN_Y_AMD 0x91AF #define GL_ALL_PIXELS_AMD 0xFFFFFFFF typedef void (APIENTRYP PFNGLFRAMEBUFFERSAMPLEPOSITIONSFVAMDPROC) (GLenum target, GLuint numsamples, GLuint pixelindex, const GLfloat *values); typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERSAMPLEPOSITIONSFVAMDPROC) (GLuint framebuffer, GLuint numsamples, GLuint pixelindex, const GLfloat *values); typedef void (APIENTRYP PFNGLGETFRAMEBUFFERPARAMETERFVAMDPROC) (GLenum target, GLenum pname, GLuint numsamples, GLuint pixelindex, GLsizei size, GLfloat *values); typedef void (APIENTRYP PFNGLGETNAMEDFRAMEBUFFERPARAMETERFVAMDPROC) (GLuint framebuffer, GLenum pname, GLuint numsamples, GLuint pixelindex, GLsizei size, GLfloat *values); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glFramebufferSamplePositionsfvAMD (GLenum target, GLuint numsamples, GLuint pixelindex, const GLfloat *values); GLAPI void APIENTRY glNamedFramebufferSamplePositionsfvAMD (GLuint framebuffer, GLuint numsamples, GLuint pixelindex, const GLfloat *values); GLAPI void APIENTRY glGetFramebufferParameterfvAMD (GLenum target, GLenum pname, GLuint numsamples, GLuint pixelindex, GLsizei size, GLfloat *values); GLAPI void APIENTRY glGetNamedFramebufferParameterfvAMD (GLuint framebuffer, GLenum pname, GLuint numsamples, GLuint pixelindex, GLsizei size, GLfloat *values); #endif #endif /* GL_AMD_framebuffer_sample_positions */ #ifndef GL_AMD_gcn_shader #define GL_AMD_gcn_shader 1 #endif /* GL_AMD_gcn_shader */ #ifndef GL_AMD_gpu_shader_half_float #define GL_AMD_gpu_shader_half_float 1 #define GL_FLOAT16_NV 0x8FF8 #define GL_FLOAT16_VEC2_NV 0x8FF9 #define GL_FLOAT16_VEC3_NV 0x8FFA #define GL_FLOAT16_VEC4_NV 0x8FFB #define GL_FLOAT16_MAT2_AMD 0x91C5 #define GL_FLOAT16_MAT3_AMD 0x91C6 #define GL_FLOAT16_MAT4_AMD 0x91C7 #define GL_FLOAT16_MAT2x3_AMD 0x91C8 #define GL_FLOAT16_MAT2x4_AMD 0x91C9 #define GL_FLOAT16_MAT3x2_AMD 0x91CA #define GL_FLOAT16_MAT3x4_AMD 0x91CB #define GL_FLOAT16_MAT4x2_AMD 0x91CC #define GL_FLOAT16_MAT4x3_AMD 0x91CD #endif /* GL_AMD_gpu_shader_half_float */ #ifndef GL_AMD_gpu_shader_int16 #define GL_AMD_gpu_shader_int16 1 #endif /* GL_AMD_gpu_shader_int16 */ #ifndef GL_AMD_gpu_shader_int64 #define GL_AMD_gpu_shader_int64 1 typedef khronos_int64_t GLint64EXT; #define GL_INT64_NV 0x140E #define GL_UNSIGNED_INT64_NV 0x140F #define GL_INT8_NV 0x8FE0 #define GL_INT8_VEC2_NV 0x8FE1 #define GL_INT8_VEC3_NV 0x8FE2 #define GL_INT8_VEC4_NV 0x8FE3 #define GL_INT16_NV 0x8FE4 #define GL_INT16_VEC2_NV 0x8FE5 #define GL_INT16_VEC3_NV 0x8FE6 #define GL_INT16_VEC4_NV 0x8FE7 #define GL_INT64_VEC2_NV 0x8FE9 #define GL_INT64_VEC3_NV 0x8FEA #define GL_INT64_VEC4_NV 0x8FEB #define GL_UNSIGNED_INT8_NV 0x8FEC #define GL_UNSIGNED_INT8_VEC2_NV 0x8FED #define GL_UNSIGNED_INT8_VEC3_NV 0x8FEE #define GL_UNSIGNED_INT8_VEC4_NV 0x8FEF #define GL_UNSIGNED_INT16_NV 0x8FF0 #define GL_UNSIGNED_INT16_VEC2_NV 0x8FF1 #define GL_UNSIGNED_INT16_VEC3_NV 0x8FF2 #define GL_UNSIGNED_INT16_VEC4_NV 0x8FF3 #define GL_UNSIGNED_INT64_VEC2_NV 0x8FF5 #define GL_UNSIGNED_INT64_VEC3_NV 0x8FF6 #define GL_UNSIGNED_INT64_VEC4_NV 0x8FF7 typedef void (APIENTRYP PFNGLUNIFORM1I64NVPROC) (GLint location, GLint64EXT x); typedef void (APIENTRYP PFNGLUNIFORM2I64NVPROC) (GLint location, GLint64EXT x, GLint64EXT y); typedef void (APIENTRYP PFNGLUNIFORM3I64NVPROC) (GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z); typedef void (APIENTRYP PFNGLUNIFORM4I64NVPROC) (GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w); typedef void (APIENTRYP PFNGLUNIFORM1I64VNVPROC) (GLint location, GLsizei count, const GLint64EXT *value); typedef void (APIENTRYP PFNGLUNIFORM2I64VNVPROC) (GLint location, GLsizei count, const GLint64EXT *value); typedef void (APIENTRYP PFNGLUNIFORM3I64VNVPROC) (GLint location, GLsizei count, const GLint64EXT *value); typedef void (APIENTRYP PFNGLUNIFORM4I64VNVPROC) (GLint location, GLsizei count, const GLint64EXT *value); typedef void (APIENTRYP PFNGLUNIFORM1UI64NVPROC) (GLint location, GLuint64EXT x); typedef void (APIENTRYP PFNGLUNIFORM2UI64NVPROC) (GLint location, GLuint64EXT x, GLuint64EXT y); typedef void (APIENTRYP PFNGLUNIFORM3UI64NVPROC) (GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z); typedef void (APIENTRYP PFNGLUNIFORM4UI64NVPROC) (GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w); typedef void (APIENTRYP PFNGLUNIFORM1UI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT *value); typedef void (APIENTRYP PFNGLUNIFORM2UI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT *value); typedef void (APIENTRYP PFNGLUNIFORM3UI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT *value); typedef void (APIENTRYP PFNGLUNIFORM4UI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT *value); typedef void (APIENTRYP PFNGLGETUNIFORMI64VNVPROC) (GLuint program, GLint location, GLint64EXT *params); typedef void (APIENTRYP PFNGLGETUNIFORMUI64VNVPROC) (GLuint program, GLint location, GLuint64EXT *params); typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1I64NVPROC) (GLuint program, GLint location, GLint64EXT x); typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2I64NVPROC) (GLuint program, GLint location, GLint64EXT x, GLint64EXT y); typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3I64NVPROC) (GLuint program, GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z); typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4I64NVPROC) (GLuint program, GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w); typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1I64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2I64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3I64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4I64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UI64NVPROC) (GLuint program, GLint location, GLuint64EXT x); typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UI64NVPROC) (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y); typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UI64NVPROC) (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z); typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UI64NVPROC) (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w); typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glUniform1i64NV (GLint location, GLint64EXT x); GLAPI void APIENTRY glUniform2i64NV (GLint location, GLint64EXT x, GLint64EXT y); GLAPI void APIENTRY glUniform3i64NV (GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z); GLAPI void APIENTRY glUniform4i64NV (GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w); GLAPI void APIENTRY glUniform1i64vNV (GLint location, GLsizei count, const GLint64EXT *value); GLAPI void APIENTRY glUniform2i64vNV (GLint location, GLsizei count, const GLint64EXT *value); GLAPI void APIENTRY glUniform3i64vNV (GLint location, GLsizei count, const GLint64EXT *value); GLAPI void APIENTRY glUniform4i64vNV (GLint location, GLsizei count, const GLint64EXT *value); GLAPI void APIENTRY glUniform1ui64NV (GLint location, GLuint64EXT x); GLAPI void APIENTRY glUniform2ui64NV (GLint location, GLuint64EXT x, GLuint64EXT y); GLAPI void APIENTRY glUniform3ui64NV (GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z); GLAPI void APIENTRY glUniform4ui64NV (GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w); GLAPI void APIENTRY glUniform1ui64vNV (GLint location, GLsizei count, const GLuint64EXT *value); GLAPI void APIENTRY glUniform2ui64vNV (GLint location, GLsizei count, const GLuint64EXT *value); GLAPI void APIENTRY glUniform3ui64vNV (GLint location, GLsizei count, const GLuint64EXT *value); GLAPI void APIENTRY glUniform4ui64vNV (GLint location, GLsizei count, const GLuint64EXT *value); GLAPI void APIENTRY glGetUniformi64vNV (GLuint program, GLint location, GLint64EXT *params); GLAPI void APIENTRY glGetUniformui64vNV (GLuint program, GLint location, GLuint64EXT *params); GLAPI void APIENTRY glProgramUniform1i64NV (GLuint program, GLint location, GLint64EXT x); GLAPI void APIENTRY glProgramUniform2i64NV (GLuint program, GLint location, GLint64EXT x, GLint64EXT y); GLAPI void APIENTRY glProgramUniform3i64NV (GLuint program, GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z); GLAPI void APIENTRY glProgramUniform4i64NV (GLuint program, GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w); GLAPI void APIENTRY glProgramUniform1i64vNV (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); GLAPI void APIENTRY glProgramUniform2i64vNV (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); GLAPI void APIENTRY glProgramUniform3i64vNV (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); GLAPI void APIENTRY glProgramUniform4i64vNV (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); GLAPI void APIENTRY glProgramUniform1ui64NV (GLuint program, GLint location, GLuint64EXT x); GLAPI void APIENTRY glProgramUniform2ui64NV (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y); GLAPI void APIENTRY glProgramUniform3ui64NV (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z); GLAPI void APIENTRY glProgramUniform4ui64NV (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w); GLAPI void APIENTRY glProgramUniform1ui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); GLAPI void APIENTRY glProgramUniform2ui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); GLAPI void APIENTRY glProgramUniform3ui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); GLAPI void APIENTRY glProgramUniform4ui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); #endif #endif /* GL_AMD_gpu_shader_int64 */ #ifndef GL_AMD_interleaved_elements #define GL_AMD_interleaved_elements 1 #define GL_VERTEX_ELEMENT_SWIZZLE_AMD 0x91A4 #define GL_VERTEX_ID_SWIZZLE_AMD 0x91A5 typedef void (APIENTRYP PFNGLVERTEXATTRIBPARAMETERIAMDPROC) (GLuint index, GLenum pname, GLint param); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glVertexAttribParameteriAMD (GLuint index, GLenum pname, GLint param); #endif #endif /* GL_AMD_interleaved_elements */ #ifndef GL_AMD_multi_draw_indirect #define GL_AMD_multi_draw_indirect 1 typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSINDIRECTAMDPROC) (GLenum mode, const void *indirect, GLsizei primcount, GLsizei stride); typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSINDIRECTAMDPROC) (GLenum mode, GLenum type, const void *indirect, GLsizei primcount, GLsizei stride); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glMultiDrawArraysIndirectAMD (GLenum mode, const void *indirect, GLsizei primcount, GLsizei stride); GLAPI void APIENTRY glMultiDrawElementsIndirectAMD (GLenum mode, GLenum type, const void *indirect, GLsizei primcount, GLsizei stride); #endif #endif /* GL_AMD_multi_draw_indirect */ #ifndef GL_AMD_name_gen_delete #define GL_AMD_name_gen_delete 1 #define GL_DATA_BUFFER_AMD 0x9151 #define GL_PERFORMANCE_MONITOR_AMD 0x9152 #define GL_QUERY_OBJECT_AMD 0x9153 #define GL_VERTEX_ARRAY_OBJECT_AMD 0x9154 #define GL_SAMPLER_OBJECT_AMD 0x9155 typedef void (APIENTRYP PFNGLGENNAMESAMDPROC) (GLenum identifier, GLuint num, GLuint *names); typedef void (APIENTRYP PFNGLDELETENAMESAMDPROC) (GLenum identifier, GLuint num, const GLuint *names); typedef GLboolean (APIENTRYP PFNGLISNAMEAMDPROC) (GLenum identifier, GLuint name); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glGenNamesAMD (GLenum identifier, GLuint num, GLuint *names); GLAPI void APIENTRY glDeleteNamesAMD (GLenum identifier, GLuint num, const GLuint *names); GLAPI GLboolean APIENTRY glIsNameAMD (GLenum identifier, GLuint name); #endif #endif /* GL_AMD_name_gen_delete */ #ifndef GL_AMD_occlusion_query_event #define GL_AMD_occlusion_query_event 1 #define GL_OCCLUSION_QUERY_EVENT_MASK_AMD 0x874F #define GL_QUERY_DEPTH_PASS_EVENT_BIT_AMD 0x00000001 #define GL_QUERY_DEPTH_FAIL_EVENT_BIT_AMD 0x00000002 #define GL_QUERY_STENCIL_FAIL_EVENT_BIT_AMD 0x00000004 #define GL_QUERY_DEPTH_BOUNDS_FAIL_EVENT_BIT_AMD 0x00000008 #define GL_QUERY_ALL_EVENT_BITS_AMD 0xFFFFFFFF typedef void (APIENTRYP PFNGLQUERYOBJECTPARAMETERUIAMDPROC) (GLenum target, GLuint id, GLenum pname, GLuint param); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glQueryObjectParameteruiAMD (GLenum target, GLuint id, GLenum pname, GLuint param); #endif #endif /* GL_AMD_occlusion_query_event */ #ifndef GL_AMD_performance_monitor #define GL_AMD_performance_monitor 1 #define GL_COUNTER_TYPE_AMD 0x8BC0 #define GL_COUNTER_RANGE_AMD 0x8BC1 #define GL_UNSIGNED_INT64_AMD 0x8BC2 #define GL_PERCENTAGE_AMD 0x8BC3 #define GL_PERFMON_RESULT_AVAILABLE_AMD 0x8BC4 #define GL_PERFMON_RESULT_SIZE_AMD 0x8BC5 #define GL_PERFMON_RESULT_AMD 0x8BC6 typedef void (APIENTRYP PFNGLGETPERFMONITORGROUPSAMDPROC) (GLint *numGroups, GLsizei groupsSize, GLuint *groups); typedef void (APIENTRYP PFNGLGETPERFMONITORCOUNTERSAMDPROC) (GLuint group, GLint *numCounters, GLint *maxActiveCounters, GLsizei counterSize, GLuint *counters); typedef void (APIENTRYP PFNGLGETPERFMONITORGROUPSTRINGAMDPROC) (GLuint group, GLsizei bufSize, GLsizei *length, GLchar *groupString); typedef void (APIENTRYP PFNGLGETPERFMONITORCOUNTERSTRINGAMDPROC) (GLuint group, GLuint counter, GLsizei bufSize, GLsizei *length, GLchar *counterString); typedef void (APIENTRYP PFNGLGETPERFMONITORCOUNTERINFOAMDPROC) (GLuint group, GLuint counter, GLenum pname, void *data); typedef void (APIENTRYP PFNGLGENPERFMONITORSAMDPROC) (GLsizei n, GLuint *monitors); typedef void (APIENTRYP PFNGLDELETEPERFMONITORSAMDPROC) (GLsizei n, GLuint *monitors); typedef void (APIENTRYP PFNGLSELECTPERFMONITORCOUNTERSAMDPROC) (GLuint monitor, GLboolean enable, GLuint group, GLint numCounters, GLuint *counterList); typedef void (APIENTRYP PFNGLBEGINPERFMONITORAMDPROC) (GLuint monitor); typedef void (APIENTRYP PFNGLENDPERFMONITORAMDPROC) (GLuint monitor); typedef void (APIENTRYP PFNGLGETPERFMONITORCOUNTERDATAAMDPROC) (GLuint monitor, GLenum pname, GLsizei dataSize, GLuint *data, GLint *bytesWritten); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glGetPerfMonitorGroupsAMD (GLint *numGroups, GLsizei groupsSize, GLuint *groups); GLAPI void APIENTRY glGetPerfMonitorCountersAMD (GLuint group, GLint *numCounters, GLint *maxActiveCounters, GLsizei counterSize, GLuint *counters); GLAPI void APIENTRY glGetPerfMonitorGroupStringAMD (GLuint group, GLsizei bufSize, GLsizei *length, GLchar *groupString); GLAPI void APIENTRY glGetPerfMonitorCounterStringAMD (GLuint group, GLuint counter, GLsizei bufSize, GLsizei *length, GLchar *counterString); GLAPI void APIENTRY glGetPerfMonitorCounterInfoAMD (GLuint group, GLuint counter, GLenum pname, void *data); GLAPI void APIENTRY glGenPerfMonitorsAMD (GLsizei n, GLuint *monitors); GLAPI void APIENTRY glDeletePerfMonitorsAMD (GLsizei n, GLuint *monitors); GLAPI void APIENTRY glSelectPerfMonitorCountersAMD (GLuint monitor, GLboolean enable, GLuint group, GLint numCounters, GLuint *counterList); GLAPI void APIENTRY glBeginPerfMonitorAMD (GLuint monitor); GLAPI void APIENTRY glEndPerfMonitorAMD (GLuint monitor); GLAPI void APIENTRY glGetPerfMonitorCounterDataAMD (GLuint monitor, GLenum pname, GLsizei dataSize, GLuint *data, GLint *bytesWritten); #endif #endif /* GL_AMD_performance_monitor */ #ifndef GL_AMD_pinned_memory #define GL_AMD_pinned_memory 1 #define GL_EXTERNAL_VIRTUAL_MEMORY_BUFFER_AMD 0x9160 #endif /* GL_AMD_pinned_memory */ #ifndef GL_AMD_query_buffer_object #define GL_AMD_query_buffer_object 1 #define GL_QUERY_BUFFER_AMD 0x9192 #define GL_QUERY_BUFFER_BINDING_AMD 0x9193 #define GL_QUERY_RESULT_NO_WAIT_AMD 0x9194 #endif /* GL_AMD_query_buffer_object */ #ifndef GL_AMD_sample_positions #define GL_AMD_sample_positions 1 typedef void (APIENTRYP PFNGLSETMULTISAMPLEFVAMDPROC) (GLenum pname, GLuint index, const GLfloat *val); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glSetMultisamplefvAMD (GLenum pname, GLuint index, const GLfloat *val); #endif #endif /* GL_AMD_sample_positions */ #ifndef GL_AMD_seamless_cubemap_per_texture #define GL_AMD_seamless_cubemap_per_texture 1 #endif /* GL_AMD_seamless_cubemap_per_texture */ #ifndef GL_AMD_shader_atomic_counter_ops #define GL_AMD_shader_atomic_counter_ops 1 #endif /* GL_AMD_shader_atomic_counter_ops */ #ifndef GL_AMD_shader_ballot #define GL_AMD_shader_ballot 1 #endif /* GL_AMD_shader_ballot */ #ifndef GL_AMD_shader_explicit_vertex_parameter #define GL_AMD_shader_explicit_vertex_parameter 1 #endif /* GL_AMD_shader_explicit_vertex_parameter */ #ifndef GL_AMD_shader_gpu_shader_half_float_fetch #define GL_AMD_shader_gpu_shader_half_float_fetch 1 #endif /* GL_AMD_shader_gpu_shader_half_float_fetch */ #ifndef GL_AMD_shader_image_load_store_lod #define GL_AMD_shader_image_load_store_lod 1 #endif /* GL_AMD_shader_image_load_store_lod */ #ifndef GL_AMD_shader_stencil_export #define GL_AMD_shader_stencil_export 1 #endif /* GL_AMD_shader_stencil_export */ #ifndef GL_AMD_shader_trinary_minmax #define GL_AMD_shader_trinary_minmax 1 #endif /* GL_AMD_shader_trinary_minmax */ #ifndef GL_AMD_sparse_texture #define GL_AMD_sparse_texture 1 #define GL_VIRTUAL_PAGE_SIZE_X_AMD 0x9195 #define GL_VIRTUAL_PAGE_SIZE_Y_AMD 0x9196 #define GL_VIRTUAL_PAGE_SIZE_Z_AMD 0x9197 #define GL_MAX_SPARSE_TEXTURE_SIZE_AMD 0x9198 #define GL_MAX_SPARSE_3D_TEXTURE_SIZE_AMD 0x9199 #define GL_MAX_SPARSE_ARRAY_TEXTURE_LAYERS 0x919A #define GL_MIN_SPARSE_LEVEL_AMD 0x919B #define GL_MIN_LOD_WARNING_AMD 0x919C #define GL_TEXTURE_STORAGE_SPARSE_BIT_AMD 0x00000001 typedef void (APIENTRYP PFNGLTEXSTORAGESPARSEAMDPROC) (GLenum target, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLsizei layers, GLbitfield flags); typedef void (APIENTRYP PFNGLTEXTURESTORAGESPARSEAMDPROC) (GLuint texture, GLenum target, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLsizei layers, GLbitfield flags); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glTexStorageSparseAMD (GLenum target, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLsizei layers, GLbitfield flags); GLAPI void APIENTRY glTextureStorageSparseAMD (GLuint texture, GLenum target, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLsizei layers, GLbitfield flags); #endif #endif /* GL_AMD_sparse_texture */ #ifndef GL_AMD_stencil_operation_extended #define GL_AMD_stencil_operation_extended 1 #define GL_SET_AMD 0x874A #define GL_REPLACE_VALUE_AMD 0x874B #define GL_STENCIL_OP_VALUE_AMD 0x874C #define GL_STENCIL_BACK_OP_VALUE_AMD 0x874D typedef void (APIENTRYP PFNGLSTENCILOPVALUEAMDPROC) (GLenum face, GLuint value); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glStencilOpValueAMD (GLenum face, GLuint value); #endif #endif /* GL_AMD_stencil_operation_extended */ #ifndef GL_AMD_texture_gather_bias_lod #define GL_AMD_texture_gather_bias_lod 1 #endif /* GL_AMD_texture_gather_bias_lod */ #ifndef GL_AMD_texture_texture4 #define GL_AMD_texture_texture4 1 #endif /* GL_AMD_texture_texture4 */ #ifndef GL_AMD_transform_feedback3_lines_triangles #define GL_AMD_transform_feedback3_lines_triangles 1 #endif /* GL_AMD_transform_feedback3_lines_triangles */ #ifndef GL_AMD_transform_feedback4 #define GL_AMD_transform_feedback4 1 #define GL_STREAM_RASTERIZATION_AMD 0x91A0 #endif /* GL_AMD_transform_feedback4 */ #ifndef GL_AMD_vertex_shader_layer #define GL_AMD_vertex_shader_layer 1 #endif /* GL_AMD_vertex_shader_layer */ #ifndef GL_AMD_vertex_shader_tessellator #define GL_AMD_vertex_shader_tessellator 1 #define GL_SAMPLER_BUFFER_AMD 0x9001 #define GL_INT_SAMPLER_BUFFER_AMD 0x9002 #define GL_UNSIGNED_INT_SAMPLER_BUFFER_AMD 0x9003 #define GL_TESSELLATION_MODE_AMD 0x9004 #define GL_TESSELLATION_FACTOR_AMD 0x9005 #define GL_DISCRETE_AMD 0x9006 #define GL_CONTINUOUS_AMD 0x9007 typedef void (APIENTRYP PFNGLTESSELLATIONFACTORAMDPROC) (GLfloat factor); typedef void (APIENTRYP PFNGLTESSELLATIONMODEAMDPROC) (GLenum mode); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glTessellationFactorAMD (GLfloat factor); GLAPI void APIENTRY glTessellationModeAMD (GLenum mode); #endif #endif /* GL_AMD_vertex_shader_tessellator */ #ifndef GL_AMD_vertex_shader_viewport_index #define GL_AMD_vertex_shader_viewport_index 1 #endif /* GL_AMD_vertex_shader_viewport_index */ #ifndef GL_APPLE_aux_depth_stencil #define GL_APPLE_aux_depth_stencil 1 #define GL_AUX_DEPTH_STENCIL_APPLE 0x8A14 #endif /* GL_APPLE_aux_depth_stencil */ #ifndef GL_APPLE_client_storage #define GL_APPLE_client_storage 1 #define GL_UNPACK_CLIENT_STORAGE_APPLE 0x85B2 #endif /* GL_APPLE_client_storage */ #ifndef GL_APPLE_element_array #define GL_APPLE_element_array 1 #define GL_ELEMENT_ARRAY_APPLE 0x8A0C #define GL_ELEMENT_ARRAY_TYPE_APPLE 0x8A0D #define GL_ELEMENT_ARRAY_POINTER_APPLE 0x8A0E typedef void (APIENTRYP PFNGLELEMENTPOINTERAPPLEPROC) (GLenum type, const void *pointer); typedef void (APIENTRYP PFNGLDRAWELEMENTARRAYAPPLEPROC) (GLenum mode, GLint first, GLsizei count); typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTARRAYAPPLEPROC) (GLenum mode, GLuint start, GLuint end, GLint first, GLsizei count); typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTARRAYAPPLEPROC) (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount); typedef void (APIENTRYP PFNGLMULTIDRAWRANGEELEMENTARRAYAPPLEPROC) (GLenum mode, GLuint start, GLuint end, const GLint *first, const GLsizei *count, GLsizei primcount); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glElementPointerAPPLE (GLenum type, const void *pointer); GLAPI void APIENTRY glDrawElementArrayAPPLE (GLenum mode, GLint first, GLsizei count); GLAPI void APIENTRY glDrawRangeElementArrayAPPLE (GLenum mode, GLuint start, GLuint end, GLint first, GLsizei count); GLAPI void APIENTRY glMultiDrawElementArrayAPPLE (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount); GLAPI void APIENTRY glMultiDrawRangeElementArrayAPPLE (GLenum mode, GLuint start, GLuint end, const GLint *first, const GLsizei *count, GLsizei primcount); #endif #endif /* GL_APPLE_element_array */ #ifndef GL_APPLE_fence #define GL_APPLE_fence 1 #define GL_DRAW_PIXELS_APPLE 0x8A0A #define GL_FENCE_APPLE 0x8A0B typedef void (APIENTRYP PFNGLGENFENCESAPPLEPROC) (GLsizei n, GLuint *fences); typedef void (APIENTRYP PFNGLDELETEFENCESAPPLEPROC) (GLsizei n, const GLuint *fences); typedef void (APIENTRYP PFNGLSETFENCEAPPLEPROC) (GLuint fence); typedef GLboolean (APIENTRYP PFNGLISFENCEAPPLEPROC) (GLuint fence); typedef GLboolean (APIENTRYP PFNGLTESTFENCEAPPLEPROC) (GLuint fence); typedef void (APIENTRYP PFNGLFINISHFENCEAPPLEPROC) (GLuint fence); typedef GLboolean (APIENTRYP PFNGLTESTOBJECTAPPLEPROC) (GLenum object, GLuint name); typedef void (APIENTRYP PFNGLFINISHOBJECTAPPLEPROC) (GLenum object, GLint name); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glGenFencesAPPLE (GLsizei n, GLuint *fences); GLAPI void APIENTRY glDeleteFencesAPPLE (GLsizei n, const GLuint *fences); GLAPI void APIENTRY glSetFenceAPPLE (GLuint fence); GLAPI GLboolean APIENTRY glIsFenceAPPLE (GLuint fence); GLAPI GLboolean APIENTRY glTestFenceAPPLE (GLuint fence); GLAPI void APIENTRY glFinishFenceAPPLE (GLuint fence); GLAPI GLboolean APIENTRY glTestObjectAPPLE (GLenum object, GLuint name); GLAPI void APIENTRY glFinishObjectAPPLE (GLenum object, GLint name); #endif #endif /* GL_APPLE_fence */ #ifndef GL_APPLE_float_pixels #define GL_APPLE_float_pixels 1 #define GL_HALF_APPLE 0x140B #define GL_RGBA_FLOAT32_APPLE 0x8814 #define GL_RGB_FLOAT32_APPLE 0x8815 #define GL_ALPHA_FLOAT32_APPLE 0x8816 #define GL_INTENSITY_FLOAT32_APPLE 0x8817 #define GL_LUMINANCE_FLOAT32_APPLE 0x8818 #define GL_LUMINANCE_ALPHA_FLOAT32_APPLE 0x8819 #define GL_RGBA_FLOAT16_APPLE 0x881A #define GL_RGB_FLOAT16_APPLE 0x881B #define GL_ALPHA_FLOAT16_APPLE 0x881C #define GL_INTENSITY_FLOAT16_APPLE 0x881D #define GL_LUMINANCE_FLOAT16_APPLE 0x881E #define GL_LUMINANCE_ALPHA_FLOAT16_APPLE 0x881F #define GL_COLOR_FLOAT_APPLE 0x8A0F #endif /* GL_APPLE_float_pixels */ #ifndef GL_APPLE_flush_buffer_range #define GL_APPLE_flush_buffer_range 1 #define GL_BUFFER_SERIALIZED_MODIFY_APPLE 0x8A12 #define GL_BUFFER_FLUSHING_UNMAP_APPLE 0x8A13 typedef void (APIENTRYP PFNGLBUFFERPARAMETERIAPPLEPROC) (GLenum target, GLenum pname, GLint param); typedef void (APIENTRYP PFNGLFLUSHMAPPEDBUFFERRANGEAPPLEPROC) (GLenum target, GLintptr offset, GLsizeiptr size); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glBufferParameteriAPPLE (GLenum target, GLenum pname, GLint param); GLAPI void APIENTRY glFlushMappedBufferRangeAPPLE (GLenum target, GLintptr offset, GLsizeiptr size); #endif #endif /* GL_APPLE_flush_buffer_range */ #ifndef GL_APPLE_object_purgeable #define GL_APPLE_object_purgeable 1 #define GL_BUFFER_OBJECT_APPLE 0x85B3 #define GL_RELEASED_APPLE 0x8A19 #define GL_VOLATILE_APPLE 0x8A1A #define GL_RETAINED_APPLE 0x8A1B #define GL_UNDEFINED_APPLE 0x8A1C #define GL_PURGEABLE_APPLE 0x8A1D typedef GLenum (APIENTRYP PFNGLOBJECTPURGEABLEAPPLEPROC) (GLenum objectType, GLuint name, GLenum option); typedef GLenum (APIENTRYP PFNGLOBJECTUNPURGEABLEAPPLEPROC) (GLenum objectType, GLuint name, GLenum option); typedef void (APIENTRYP PFNGLGETOBJECTPARAMETERIVAPPLEPROC) (GLenum objectType, GLuint name, GLenum pname, GLint *params); #ifdef GL_GLEXT_PROTOTYPES GLAPI GLenum APIENTRY glObjectPurgeableAPPLE (GLenum objectType, GLuint name, GLenum option); GLAPI GLenum APIENTRY glObjectUnpurgeableAPPLE (GLenum objectType, GLuint name, GLenum option); GLAPI void APIENTRY glGetObjectParameterivAPPLE (GLenum objectType, GLuint name, GLenum pname, GLint *params); #endif #endif /* GL_APPLE_object_purgeable */ #ifndef GL_APPLE_rgb_422 #define GL_APPLE_rgb_422 1 #define GL_RGB_422_APPLE 0x8A1F #define GL_UNSIGNED_SHORT_8_8_APPLE 0x85BA #define GL_UNSIGNED_SHORT_8_8_REV_APPLE 0x85BB #define GL_RGB_RAW_422_APPLE 0x8A51 #endif /* GL_APPLE_rgb_422 */ #ifndef GL_APPLE_row_bytes #define GL_APPLE_row_bytes 1 #define GL_PACK_ROW_BYTES_APPLE 0x8A15 #define GL_UNPACK_ROW_BYTES_APPLE 0x8A16 #endif /* GL_APPLE_row_bytes */ #ifndef GL_APPLE_specular_vector #define GL_APPLE_specular_vector 1 #define GL_LIGHT_MODEL_SPECULAR_VECTOR_APPLE 0x85B0 #endif /* GL_APPLE_specular_vector */ #ifndef GL_APPLE_texture_range #define GL_APPLE_texture_range 1 #define GL_TEXTURE_RANGE_LENGTH_APPLE 0x85B7 #define GL_TEXTURE_RANGE_POINTER_APPLE 0x85B8 #define GL_TEXTURE_STORAGE_HINT_APPLE 0x85BC #define GL_STORAGE_PRIVATE_APPLE 0x85BD #define GL_STORAGE_CACHED_APPLE 0x85BE #define GL_STORAGE_SHARED_APPLE 0x85BF typedef void (APIENTRYP PFNGLTEXTURERANGEAPPLEPROC) (GLenum target, GLsizei length, const void *pointer); typedef void (APIENTRYP PFNGLGETTEXPARAMETERPOINTERVAPPLEPROC) (GLenum target, GLenum pname, void **params); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glTextureRangeAPPLE (GLenum target, GLsizei length, const void *pointer); GLAPI void APIENTRY glGetTexParameterPointervAPPLE (GLenum target, GLenum pname, void **params); #endif #endif /* GL_APPLE_texture_range */ #ifndef GL_APPLE_transform_hint #define GL_APPLE_transform_hint 1 #define GL_TRANSFORM_HINT_APPLE 0x85B1 #endif /* GL_APPLE_transform_hint */ #ifndef GL_APPLE_vertex_array_object #define GL_APPLE_vertex_array_object 1 #define GL_VERTEX_ARRAY_BINDING_APPLE 0x85B5 typedef void (APIENTRYP PFNGLBINDVERTEXARRAYAPPLEPROC) (GLuint array); typedef void (APIENTRYP PFNGLDELETEVERTEXARRAYSAPPLEPROC) (GLsizei n, const GLuint *arrays); typedef void (APIENTRYP PFNGLGENVERTEXARRAYSAPPLEPROC) (GLsizei n, GLuint *arrays); typedef GLboolean (APIENTRYP PFNGLISVERTEXARRAYAPPLEPROC) (GLuint array); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glBindVertexArrayAPPLE (GLuint array); GLAPI void APIENTRY glDeleteVertexArraysAPPLE (GLsizei n, const GLuint *arrays); GLAPI void APIENTRY glGenVertexArraysAPPLE (GLsizei n, GLuint *arrays); GLAPI GLboolean APIENTRY glIsVertexArrayAPPLE (GLuint array); #endif #endif /* GL_APPLE_vertex_array_object */ #ifndef GL_APPLE_vertex_array_range #define GL_APPLE_vertex_array_range 1 #define GL_VERTEX_ARRAY_RANGE_APPLE 0x851D #define GL_VERTEX_ARRAY_RANGE_LENGTH_APPLE 0x851E #define GL_VERTEX_ARRAY_STORAGE_HINT_APPLE 0x851F #define GL_VERTEX_ARRAY_RANGE_POINTER_APPLE 0x8521 #define GL_STORAGE_CLIENT_APPLE 0x85B4 typedef void (APIENTRYP PFNGLVERTEXARRAYRANGEAPPLEPROC) (GLsizei length, void *pointer); typedef void (APIENTRYP PFNGLFLUSHVERTEXARRAYRANGEAPPLEPROC) (GLsizei length, void *pointer); typedef void (APIENTRYP PFNGLVERTEXARRAYPARAMETERIAPPLEPROC) (GLenum pname, GLint param); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glVertexArrayRangeAPPLE (GLsizei length, void *pointer); GLAPI void APIENTRY glFlushVertexArrayRangeAPPLE (GLsizei length, void *pointer); GLAPI void APIENTRY glVertexArrayParameteriAPPLE (GLenum pname, GLint param); #endif #endif /* GL_APPLE_vertex_array_range */ #ifndef GL_APPLE_vertex_program_evaluators #define GL_APPLE_vertex_program_evaluators 1 #define GL_VERTEX_ATTRIB_MAP1_APPLE 0x8A00 #define GL_VERTEX_ATTRIB_MAP2_APPLE 0x8A01 #define GL_VERTEX_ATTRIB_MAP1_SIZE_APPLE 0x8A02 #define GL_VERTEX_ATTRIB_MAP1_COEFF_APPLE 0x8A03 #define GL_VERTEX_ATTRIB_MAP1_ORDER_APPLE 0x8A04 #define GL_VERTEX_ATTRIB_MAP1_DOMAIN_APPLE 0x8A05 #define GL_VERTEX_ATTRIB_MAP2_SIZE_APPLE 0x8A06 #define GL_VERTEX_ATTRIB_MAP2_COEFF_APPLE 0x8A07 #define GL_VERTEX_ATTRIB_MAP2_ORDER_APPLE 0x8A08 #define GL_VERTEX_ATTRIB_MAP2_DOMAIN_APPLE 0x8A09 typedef void (APIENTRYP PFNGLENABLEVERTEXATTRIBAPPLEPROC) (GLuint index, GLenum pname); typedef void (APIENTRYP PFNGLDISABLEVERTEXATTRIBAPPLEPROC) (GLuint index, GLenum pname); typedef GLboolean (APIENTRYP PFNGLISVERTEXATTRIBENABLEDAPPLEPROC) (GLuint index, GLenum pname); typedef void (APIENTRYP PFNGLMAPVERTEXATTRIB1DAPPLEPROC) (GLuint index, GLuint size, GLdouble u1, GLdouble u2, GLint stride, GLint order, const GLdouble *points); typedef void (APIENTRYP PFNGLMAPVERTEXATTRIB1FAPPLEPROC) (GLuint index, GLuint size, GLfloat u1, GLfloat u2, GLint stride, GLint order, const GLfloat *points); typedef void (APIENTRYP PFNGLMAPVERTEXATTRIB2DAPPLEPROC) (GLuint index, GLuint size, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, const GLdouble *points); typedef void (APIENTRYP PFNGLMAPVERTEXATTRIB2FAPPLEPROC) (GLuint index, GLuint size, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, const GLfloat *points); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glEnableVertexAttribAPPLE (GLuint index, GLenum pname); GLAPI void APIENTRY glDisableVertexAttribAPPLE (GLuint index, GLenum pname); GLAPI GLboolean APIENTRY glIsVertexAttribEnabledAPPLE (GLuint index, GLenum pname); GLAPI void APIENTRY glMapVertexAttrib1dAPPLE (GLuint index, GLuint size, GLdouble u1, GLdouble u2, GLint stride, GLint order, const GLdouble *points); GLAPI void APIENTRY glMapVertexAttrib1fAPPLE (GLuint index, GLuint size, GLfloat u1, GLfloat u2, GLint stride, GLint order, const GLfloat *points); GLAPI void APIENTRY glMapVertexAttrib2dAPPLE (GLuint index, GLuint size, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, const GLdouble *points); GLAPI void APIENTRY glMapVertexAttrib2fAPPLE (GLuint index, GLuint size, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, const GLfloat *points); #endif #endif /* GL_APPLE_vertex_program_evaluators */ #ifndef GL_APPLE_ycbcr_422 #define GL_APPLE_ycbcr_422 1 #define GL_YCBCR_422_APPLE 0x85B9 #endif /* GL_APPLE_ycbcr_422 */ #ifndef GL_ATI_draw_buffers #define GL_ATI_draw_buffers 1 #define GL_MAX_DRAW_BUFFERS_ATI 0x8824 #define GL_DRAW_BUFFER0_ATI 0x8825 #define GL_DRAW_BUFFER1_ATI 0x8826 #define GL_DRAW_BUFFER2_ATI 0x8827 #define GL_DRAW_BUFFER3_ATI 0x8828 #define GL_DRAW_BUFFER4_ATI 0x8829 #define GL_DRAW_BUFFER5_ATI 0x882A #define GL_DRAW_BUFFER6_ATI 0x882B #define GL_DRAW_BUFFER7_ATI 0x882C #define GL_DRAW_BUFFER8_ATI 0x882D #define GL_DRAW_BUFFER9_ATI 0x882E #define GL_DRAW_BUFFER10_ATI 0x882F #define GL_DRAW_BUFFER11_ATI 0x8830 #define GL_DRAW_BUFFER12_ATI 0x8831 #define GL_DRAW_BUFFER13_ATI 0x8832 #define GL_DRAW_BUFFER14_ATI 0x8833 #define GL_DRAW_BUFFER15_ATI 0x8834 typedef void (APIENTRYP PFNGLDRAWBUFFERSATIPROC) (GLsizei n, const GLenum *bufs); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glDrawBuffersATI (GLsizei n, const GLenum *bufs); #endif #endif /* GL_ATI_draw_buffers */ #ifndef GL_ATI_element_array #define GL_ATI_element_array 1 #define GL_ELEMENT_ARRAY_ATI 0x8768 #define GL_ELEMENT_ARRAY_TYPE_ATI 0x8769 #define GL_ELEMENT_ARRAY_POINTER_ATI 0x876A typedef void (APIENTRYP PFNGLELEMENTPOINTERATIPROC) (GLenum type, const void *pointer); typedef void (APIENTRYP PFNGLDRAWELEMENTARRAYATIPROC) (GLenum mode, GLsizei count); typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTARRAYATIPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glElementPointerATI (GLenum type, const void *pointer); GLAPI void APIENTRY glDrawElementArrayATI (GLenum mode, GLsizei count); GLAPI void APIENTRY glDrawRangeElementArrayATI (GLenum mode, GLuint start, GLuint end, GLsizei count); #endif #endif /* GL_ATI_element_array */ #ifndef GL_ATI_envmap_bumpmap #define GL_ATI_envmap_bumpmap 1 #define GL_BUMP_ROT_MATRIX_ATI 0x8775 #define GL_BUMP_ROT_MATRIX_SIZE_ATI 0x8776 #define GL_BUMP_NUM_TEX_UNITS_ATI 0x8777 #define GL_BUMP_TEX_UNITS_ATI 0x8778 #define GL_DUDV_ATI 0x8779 #define GL_DU8DV8_ATI 0x877A #define GL_BUMP_ENVMAP_ATI 0x877B #define GL_BUMP_TARGET_ATI 0x877C typedef void (APIENTRYP PFNGLTEXBUMPPARAMETERIVATIPROC) (GLenum pname, const GLint *param); typedef void (APIENTRYP PFNGLTEXBUMPPARAMETERFVATIPROC) (GLenum pname, const GLfloat *param); typedef void (APIENTRYP PFNGLGETTEXBUMPPARAMETERIVATIPROC) (GLenum pname, GLint *param); typedef void (APIENTRYP PFNGLGETTEXBUMPPARAMETERFVATIPROC) (GLenum pname, GLfloat *param); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glTexBumpParameterivATI (GLenum pname, const GLint *param); GLAPI void APIENTRY glTexBumpParameterfvATI (GLenum pname, const GLfloat *param); GLAPI void APIENTRY glGetTexBumpParameterivATI (GLenum pname, GLint *param); GLAPI void APIENTRY glGetTexBumpParameterfvATI (GLenum pname, GLfloat *param); #endif #endif /* GL_ATI_envmap_bumpmap */ #ifndef GL_ATI_fragment_shader #define GL_ATI_fragment_shader 1 #define GL_FRAGMENT_SHADER_ATI 0x8920 #define GL_REG_0_ATI 0x8921 #define GL_REG_1_ATI 0x8922 #define GL_REG_2_ATI 0x8923 #define GL_REG_3_ATI 0x8924 #define GL_REG_4_ATI 0x8925 #define GL_REG_5_ATI 0x8926 #define GL_REG_6_ATI 0x8927 #define GL_REG_7_ATI 0x8928 #define GL_REG_8_ATI 0x8929 #define GL_REG_9_ATI 0x892A #define GL_REG_10_ATI 0x892B #define GL_REG_11_ATI 0x892C #define GL_REG_12_ATI 0x892D #define GL_REG_13_ATI 0x892E #define GL_REG_14_ATI 0x892F #define GL_REG_15_ATI 0x8930 #define GL_REG_16_ATI 0x8931 #define GL_REG_17_ATI 0x8932 #define GL_REG_18_ATI 0x8933 #define GL_REG_19_ATI 0x8934 #define GL_REG_20_ATI 0x8935 #define GL_REG_21_ATI 0x8936 #define GL_REG_22_ATI 0x8937 #define GL_REG_23_ATI 0x8938 #define GL_REG_24_ATI 0x8939 #define GL_REG_25_ATI 0x893A #define GL_REG_26_ATI 0x893B #define GL_REG_27_ATI 0x893C #define GL_REG_28_ATI 0x893D #define GL_REG_29_ATI 0x893E #define GL_REG_30_ATI 0x893F #define GL_REG_31_ATI 0x8940 #define GL_CON_0_ATI 0x8941 #define GL_CON_1_ATI 0x8942 #define GL_CON_2_ATI 0x8943 #define GL_CON_3_ATI 0x8944 #define GL_CON_4_ATI 0x8945 #define GL_CON_5_ATI 0x8946 #define GL_CON_6_ATI 0x8947 #define GL_CON_7_ATI 0x8948 #define GL_CON_8_ATI 0x8949 #define GL_CON_9_ATI 0x894A #define GL_CON_10_ATI 0x894B #define GL_CON_11_ATI 0x894C #define GL_CON_12_ATI 0x894D #define GL_CON_13_ATI 0x894E #define GL_CON_14_ATI 0x894F #define GL_CON_15_ATI 0x8950 #define GL_CON_16_ATI 0x8951 #define GL_CON_17_ATI 0x8952 #define GL_CON_18_ATI 0x8953 #define GL_CON_19_ATI 0x8954 #define GL_CON_20_ATI 0x8955 #define GL_CON_21_ATI 0x8956 #define GL_CON_22_ATI 0x8957 #define GL_CON_23_ATI 0x8958 #define GL_CON_24_ATI 0x8959 #define GL_CON_25_ATI 0x895A #define GL_CON_26_ATI 0x895B #define GL_CON_27_ATI 0x895C #define GL_CON_28_ATI 0x895D #define GL_CON_29_ATI 0x895E #define GL_CON_30_ATI 0x895F #define GL_CON_31_ATI 0x8960 #define GL_MOV_ATI 0x8961 #define GL_ADD_ATI 0x8963 #define GL_MUL_ATI 0x8964 #define GL_SUB_ATI 0x8965 #define GL_DOT3_ATI 0x8966 #define GL_DOT4_ATI 0x8967 #define GL_MAD_ATI 0x8968 #define GL_LERP_ATI 0x8969 #define GL_CND_ATI 0x896A #define GL_CND0_ATI 0x896B #define GL_DOT2_ADD_ATI 0x896C #define GL_SECONDARY_INTERPOLATOR_ATI 0x896D #define GL_NUM_FRAGMENT_REGISTERS_ATI 0x896E #define GL_NUM_FRAGMENT_CONSTANTS_ATI 0x896F #define GL_NUM_PASSES_ATI 0x8970 #define GL_NUM_INSTRUCTIONS_PER_PASS_ATI 0x8971 #define GL_NUM_INSTRUCTIONS_TOTAL_ATI 0x8972 #define GL_NUM_INPUT_INTERPOLATOR_COMPONENTS_ATI 0x8973 #define GL_NUM_LOOPBACK_COMPONENTS_ATI 0x8974 #define GL_COLOR_ALPHA_PAIRING_ATI 0x8975 #define GL_SWIZZLE_STR_ATI 0x8976 #define GL_SWIZZLE_STQ_ATI 0x8977 #define GL_SWIZZLE_STR_DR_ATI 0x8978 #define GL_SWIZZLE_STQ_DQ_ATI 0x8979 #define GL_SWIZZLE_STRQ_ATI 0x897A #define GL_SWIZZLE_STRQ_DQ_ATI 0x897B #define GL_RED_BIT_ATI 0x00000001 #define GL_GREEN_BIT_ATI 0x00000002 #define GL_BLUE_BIT_ATI 0x00000004 #define GL_2X_BIT_ATI 0x00000001 #define GL_4X_BIT_ATI 0x00000002 #define GL_8X_BIT_ATI 0x00000004 #define GL_HALF_BIT_ATI 0x00000008 #define GL_QUARTER_BIT_ATI 0x00000010 #define GL_EIGHTH_BIT_ATI 0x00000020 #define GL_SATURATE_BIT_ATI 0x00000040 #define GL_COMP_BIT_ATI 0x00000002 #define GL_NEGATE_BIT_ATI 0x00000004 #define GL_BIAS_BIT_ATI 0x00000008 typedef GLuint (APIENTRYP PFNGLGENFRAGMENTSHADERSATIPROC) (GLuint range); typedef void (APIENTRYP PFNGLBINDFRAGMENTSHADERATIPROC) (GLuint id); typedef void (APIENTRYP PFNGLDELETEFRAGMENTSHADERATIPROC) (GLuint id); typedef void (APIENTRYP PFNGLBEGINFRAGMENTSHADERATIPROC) (void); typedef void (APIENTRYP PFNGLENDFRAGMENTSHADERATIPROC) (void); typedef void (APIENTRYP PFNGLPASSTEXCOORDATIPROC) (GLuint dst, GLuint coord, GLenum swizzle); typedef void (APIENTRYP PFNGLSAMPLEMAPATIPROC) (GLuint dst, GLuint interp, GLenum swizzle); typedef void (APIENTRYP PFNGLCOLORFRAGMENTOP1ATIPROC) (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod); typedef void (APIENTRYP PFNGLCOLORFRAGMENTOP2ATIPROC) (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod); typedef void (APIENTRYP PFNGLCOLORFRAGMENTOP3ATIPROC) (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod); typedef void (APIENTRYP PFNGLALPHAFRAGMENTOP1ATIPROC) (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod); typedef void (APIENTRYP PFNGLALPHAFRAGMENTOP2ATIPROC) (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod); typedef void (APIENTRYP PFNGLALPHAFRAGMENTOP3ATIPROC) (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod); typedef void (APIENTRYP PFNGLSETFRAGMENTSHADERCONSTANTATIPROC) (GLuint dst, const GLfloat *value); #ifdef GL_GLEXT_PROTOTYPES GLAPI GLuint APIENTRY glGenFragmentShadersATI (GLuint range); GLAPI void APIENTRY glBindFragmentShaderATI (GLuint id); GLAPI void APIENTRY glDeleteFragmentShaderATI (GLuint id); GLAPI void APIENTRY glBeginFragmentShaderATI (void); GLAPI void APIENTRY glEndFragmentShaderATI (void); GLAPI void APIENTRY glPassTexCoordATI (GLuint dst, GLuint coord, GLenum swizzle); GLAPI void APIENTRY glSampleMapATI (GLuint dst, GLuint interp, GLenum swizzle); GLAPI void APIENTRY glColorFragmentOp1ATI (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod); GLAPI void APIENTRY glColorFragmentOp2ATI (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod); GLAPI void APIENTRY glColorFragmentOp3ATI (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod); GLAPI void APIENTRY glAlphaFragmentOp1ATI (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod); GLAPI void APIENTRY glAlphaFragmentOp2ATI (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod); GLAPI void APIENTRY glAlphaFragmentOp3ATI (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod); GLAPI void APIENTRY glSetFragmentShaderConstantATI (GLuint dst, const GLfloat *value); #endif #endif /* GL_ATI_fragment_shader */ #ifndef GL_ATI_map_object_buffer #define GL_ATI_map_object_buffer 1 typedef void *(APIENTRYP PFNGLMAPOBJECTBUFFERATIPROC) (GLuint buffer); typedef void (APIENTRYP PFNGLUNMAPOBJECTBUFFERATIPROC) (GLuint buffer); #ifdef GL_GLEXT_PROTOTYPES GLAPI void *APIENTRY glMapObjectBufferATI (GLuint buffer); GLAPI void APIENTRY glUnmapObjectBufferATI (GLuint buffer); #endif #endif /* GL_ATI_map_object_buffer */ #ifndef GL_ATI_meminfo #define GL_ATI_meminfo 1 #define GL_VBO_FREE_MEMORY_ATI 0x87FB #define GL_TEXTURE_FREE_MEMORY_ATI 0x87FC #define GL_RENDERBUFFER_FREE_MEMORY_ATI 0x87FD #endif /* GL_ATI_meminfo */ #ifndef GL_ATI_pixel_format_float #define GL_ATI_pixel_format_float 1 #define GL_RGBA_FLOAT_MODE_ATI 0x8820 #define GL_COLOR_CLEAR_UNCLAMPED_VALUE_ATI 0x8835 #endif /* GL_ATI_pixel_format_float */ #ifndef GL_ATI_pn_triangles #define GL_ATI_pn_triangles 1 #define GL_PN_TRIANGLES_ATI 0x87F0 #define GL_MAX_PN_TRIANGLES_TESSELATION_LEVEL_ATI 0x87F1 #define GL_PN_TRIANGLES_POINT_MODE_ATI 0x87F2 #define GL_PN_TRIANGLES_NORMAL_MODE_ATI 0x87F3 #define GL_PN_TRIANGLES_TESSELATION_LEVEL_ATI 0x87F4 #define GL_PN_TRIANGLES_POINT_MODE_LINEAR_ATI 0x87F5 #define GL_PN_TRIANGLES_POINT_MODE_CUBIC_ATI 0x87F6 #define GL_PN_TRIANGLES_NORMAL_MODE_LINEAR_ATI 0x87F7 #define GL_PN_TRIANGLES_NORMAL_MODE_QUADRATIC_ATI 0x87F8 typedef void (APIENTRYP PFNGLPNTRIANGLESIATIPROC) (GLenum pname, GLint param); typedef void (APIENTRYP PFNGLPNTRIANGLESFATIPROC) (GLenum pname, GLfloat param); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glPNTrianglesiATI (GLenum pname, GLint param); GLAPI void APIENTRY glPNTrianglesfATI (GLenum pname, GLfloat param); #endif #endif /* GL_ATI_pn_triangles */ #ifndef GL_ATI_separate_stencil #define GL_ATI_separate_stencil 1 #define GL_STENCIL_BACK_FUNC_ATI 0x8800 #define GL_STENCIL_BACK_FAIL_ATI 0x8801 #define GL_STENCIL_BACK_PASS_DEPTH_FAIL_ATI 0x8802 #define GL_STENCIL_BACK_PASS_DEPTH_PASS_ATI 0x8803 typedef void (APIENTRYP PFNGLSTENCILOPSEPARATEATIPROC) (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); typedef void (APIENTRYP PFNGLSTENCILFUNCSEPARATEATIPROC) (GLenum frontfunc, GLenum backfunc, GLint ref, GLuint mask); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glStencilOpSeparateATI (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); GLAPI void APIENTRY glStencilFuncSeparateATI (GLenum frontfunc, GLenum backfunc, GLint ref, GLuint mask); #endif #endif /* GL_ATI_separate_stencil */ #ifndef GL_ATI_text_fragment_shader #define GL_ATI_text_fragment_shader 1 #define GL_TEXT_FRAGMENT_SHADER_ATI 0x8200 #endif /* GL_ATI_text_fragment_shader */ #ifndef GL_ATI_texture_env_combine3 #define GL_ATI_texture_env_combine3 1 #define GL_MODULATE_ADD_ATI 0x8744 #define GL_MODULATE_SIGNED_ADD_ATI 0x8745 #define GL_MODULATE_SUBTRACT_ATI 0x8746 #endif /* GL_ATI_texture_env_combine3 */ #ifndef GL_ATI_texture_float #define GL_ATI_texture_float 1 #define GL_RGBA_FLOAT32_ATI 0x8814 #define GL_RGB_FLOAT32_ATI 0x8815 #define GL_ALPHA_FLOAT32_ATI 0x8816 #define GL_INTENSITY_FLOAT32_ATI 0x8817 #define GL_LUMINANCE_FLOAT32_ATI 0x8818 #define GL_LUMINANCE_ALPHA_FLOAT32_ATI 0x8819 #define GL_RGBA_FLOAT16_ATI 0x881A #define GL_RGB_FLOAT16_ATI 0x881B #define GL_ALPHA_FLOAT16_ATI 0x881C #define GL_INTENSITY_FLOAT16_ATI 0x881D #define GL_LUMINANCE_FLOAT16_ATI 0x881E #define GL_LUMINANCE_ALPHA_FLOAT16_ATI 0x881F #endif /* GL_ATI_texture_float */ #ifndef GL_ATI_texture_mirror_once #define GL_ATI_texture_mirror_once 1 #define GL_MIRROR_CLAMP_ATI 0x8742 #define GL_MIRROR_CLAMP_TO_EDGE_ATI 0x8743 #endif /* GL_ATI_texture_mirror_once */ #ifndef GL_ATI_vertex_array_object #define GL_ATI_vertex_array_object 1 #define GL_STATIC_ATI 0x8760 #define GL_DYNAMIC_ATI 0x8761 #define GL_PRESERVE_ATI 0x8762 #define GL_DISCARD_ATI 0x8763 #define GL_OBJECT_BUFFER_SIZE_ATI 0x8764 #define GL_OBJECT_BUFFER_USAGE_ATI 0x8765 #define GL_ARRAY_OBJECT_BUFFER_ATI 0x8766 #define GL_ARRAY_OBJECT_OFFSET_ATI 0x8767 typedef GLuint (APIENTRYP PFNGLNEWOBJECTBUFFERATIPROC) (GLsizei size, const void *pointer, GLenum usage); typedef GLboolean (APIENTRYP PFNGLISOBJECTBUFFERATIPROC) (GLuint buffer); typedef void (APIENTRYP PFNGLUPDATEOBJECTBUFFERATIPROC) (GLuint buffer, GLuint offset, GLsizei size, const void *pointer, GLenum preserve); typedef void (APIENTRYP PFNGLGETOBJECTBUFFERFVATIPROC) (GLuint buffer, GLenum pname, GLfloat *params); typedef void (APIENTRYP PFNGLGETOBJECTBUFFERIVATIPROC) (GLuint buffer, GLenum pname, GLint *params); typedef void (APIENTRYP PFNGLFREEOBJECTBUFFERATIPROC) (GLuint buffer); typedef void (APIENTRYP PFNGLARRAYOBJECTATIPROC) (GLenum array, GLint size, GLenum type, GLsizei stride, GLuint buffer, GLuint offset); typedef void (APIENTRYP PFNGLGETARRAYOBJECTFVATIPROC) (GLenum array, GLenum pname, GLfloat *params); typedef void (APIENTRYP PFNGLGETARRAYOBJECTIVATIPROC) (GLenum array, GLenum pname, GLint *params); typedef void (APIENTRYP PFNGLVARIANTARRAYOBJECTATIPROC) (GLuint id, GLenum type, GLsizei stride, GLuint buffer, GLuint offset); typedef void (APIENTRYP PFNGLGETVARIANTARRAYOBJECTFVATIPROC) (GLuint id, GLenum pname, GLfloat *params); typedef void (APIENTRYP PFNGLGETVARIANTARRAYOBJECTIVATIPROC) (GLuint id, GLenum pname, GLint *params); #ifdef GL_GLEXT_PROTOTYPES GLAPI GLuint APIENTRY glNewObjectBufferATI (GLsizei size, const void *pointer, GLenum usage); GLAPI GLboolean APIENTRY glIsObjectBufferATI (GLuint buffer); GLAPI void APIENTRY glUpdateObjectBufferATI (GLuint buffer, GLuint offset, GLsizei size, const void *pointer, GLenum preserve); GLAPI void APIENTRY glGetObjectBufferfvATI (GLuint buffer, GLenum pname, GLfloat *params); GLAPI void APIENTRY glGetObjectBufferivATI (GLuint buffer, GLenum pname, GLint *params); GLAPI void APIENTRY glFreeObjectBufferATI (GLuint buffer); GLAPI void APIENTRY glArrayObjectATI (GLenum array, GLint size, GLenum type, GLsizei stride, GLuint buffer, GLuint offset); GLAPI void APIENTRY glGetArrayObjectfvATI (GLenum array, GLenum pname, GLfloat *params); GLAPI void APIENTRY glGetArrayObjectivATI (GLenum array, GLenum pname, GLint *params); GLAPI void APIENTRY glVariantArrayObjectATI (GLuint id, GLenum type, GLsizei stride, GLuint buffer, GLuint offset); GLAPI void APIENTRY glGetVariantArrayObjectfvATI (GLuint id, GLenum pname, GLfloat *params); GLAPI void APIENTRY glGetVariantArrayObjectivATI (GLuint id, GLenum pname, GLint *params); #endif #endif /* GL_ATI_vertex_array_object */ #ifndef GL_ATI_vertex_attrib_array_object #define GL_ATI_vertex_attrib_array_object 1 typedef void (APIENTRYP PFNGLVERTEXATTRIBARRAYOBJECTATIPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, GLuint buffer, GLuint offset); typedef void (APIENTRYP PFNGLGETVERTEXATTRIBARRAYOBJECTFVATIPROC) (GLuint index, GLenum pname, GLfloat *params); typedef void (APIENTRYP PFNGLGETVERTEXATTRIBARRAYOBJECTIVATIPROC) (GLuint index, GLenum pname, GLint *params); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glVertexAttribArrayObjectATI (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, GLuint buffer, GLuint offset); GLAPI void APIENTRY glGetVertexAttribArrayObjectfvATI (GLuint index, GLenum pname, GLfloat *params); GLAPI void APIENTRY glGetVertexAttribArrayObjectivATI (GLuint index, GLenum pname, GLint *params); #endif #endif /* GL_ATI_vertex_attrib_array_object */ #ifndef GL_ATI_vertex_streams #define GL_ATI_vertex_streams 1 #define GL_MAX_VERTEX_STREAMS_ATI 0x876B #define GL_VERTEX_STREAM0_ATI 0x876C #define GL_VERTEX_STREAM1_ATI 0x876D #define GL_VERTEX_STREAM2_ATI 0x876E #define GL_VERTEX_STREAM3_ATI 0x876F #define GL_VERTEX_STREAM4_ATI 0x8770 #define GL_VERTEX_STREAM5_ATI 0x8771 #define GL_VERTEX_STREAM6_ATI 0x8772 #define GL_VERTEX_STREAM7_ATI 0x8773 #define GL_VERTEX_SOURCE_ATI 0x8774 typedef void (APIENTRYP PFNGLVERTEXSTREAM1SATIPROC) (GLenum stream, GLshort x); typedef void (APIENTRYP PFNGLVERTEXSTREAM1SVATIPROC) (GLenum stream, const GLshort *coords); typedef void (APIENTRYP PFNGLVERTEXSTREAM1IATIPROC) (GLenum stream, GLint x); typedef void (APIENTRYP PFNGLVERTEXSTREAM1IVATIPROC) (GLenum stream, const GLint *coords); typedef void (APIENTRYP PFNGLVERTEXSTREAM1FATIPROC) (GLenum stream, GLfloat x); typedef void (APIENTRYP PFNGLVERTEXSTREAM1FVATIPROC) (GLenum stream, const GLfloat *coords); typedef void (APIENTRYP PFNGLVERTEXSTREAM1DATIPROC) (GLenum stream, GLdouble x); typedef void (APIENTRYP PFNGLVERTEXSTREAM1DVATIPROC) (GLenum stream, const GLdouble *coords); typedef void (APIENTRYP PFNGLVERTEXSTREAM2SATIPROC) (GLenum stream, GLshort x, GLshort y); typedef void (APIENTRYP PFNGLVERTEXSTREAM2SVATIPROC) (GLenum stream, const GLshort *coords); typedef void (APIENTRYP PFNGLVERTEXSTREAM2IATIPROC) (GLenum stream, GLint x, GLint y); typedef void (APIENTRYP PFNGLVERTEXSTREAM2IVATIPROC) (GLenum stream, const GLint *coords); typedef void (APIENTRYP PFNGLVERTEXSTREAM2FATIPROC) (GLenum stream, GLfloat x, GLfloat y); typedef void (APIENTRYP PFNGLVERTEXSTREAM2FVATIPROC) (GLenum stream, const GLfloat *coords); typedef void (APIENTRYP PFNGLVERTEXSTREAM2DATIPROC) (GLenum stream, GLdouble x, GLdouble y); typedef void (APIENTRYP PFNGLVERTEXSTREAM2DVATIPROC) (GLenum stream, const GLdouble *coords); typedef void (APIENTRYP PFNGLVERTEXSTREAM3SATIPROC) (GLenum stream, GLshort x, GLshort y, GLshort z); typedef void (APIENTRYP PFNGLVERTEXSTREAM3SVATIPROC) (GLenum stream, const GLshort *coords); typedef void (APIENTRYP PFNGLVERTEXSTREAM3IATIPROC) (GLenum stream, GLint x, GLint y, GLint z); typedef void (APIENTRYP PFNGLVERTEXSTREAM3IVATIPROC) (GLenum stream, const GLint *coords); typedef void (APIENTRYP PFNGLVERTEXSTREAM3FATIPROC) (GLenum stream, GLfloat x, GLfloat y, GLfloat z); typedef void (APIENTRYP PFNGLVERTEXSTREAM3FVATIPROC) (GLenum stream, const GLfloat *coords); typedef void (APIENTRYP PFNGLVERTEXSTREAM3DATIPROC) (GLenum stream, GLdouble x, GLdouble y, GLdouble z); typedef void (APIENTRYP PFNGLVERTEXSTREAM3DVATIPROC) (GLenum stream, const GLdouble *coords); typedef void (APIENTRYP PFNGLVERTEXSTREAM4SATIPROC) (GLenum stream, GLshort x, GLshort y, GLshort z, GLshort w); typedef void (APIENTRYP PFNGLVERTEXSTREAM4SVATIPROC) (GLenum stream, const GLshort *coords); typedef void (APIENTRYP PFNGLVERTEXSTREAM4IATIPROC) (GLenum stream, GLint x, GLint y, GLint z, GLint w); typedef void (APIENTRYP PFNGLVERTEXSTREAM4IVATIPROC) (GLenum stream, const GLint *coords); typedef void (APIENTRYP PFNGLVERTEXSTREAM4FATIPROC) (GLenum stream, GLfloat x, GLfloat y, GLfloat z, GLfloat w); typedef void (APIENTRYP PFNGLVERTEXSTREAM4FVATIPROC) (GLenum stream, const GLfloat *coords); typedef void (APIENTRYP PFNGLVERTEXSTREAM4DATIPROC) (GLenum stream, GLdouble x, GLdouble y, GLdouble z, GLdouble w); typedef void (APIENTRYP PFNGLVERTEXSTREAM4DVATIPROC) (GLenum stream, const GLdouble *coords); typedef void (APIENTRYP PFNGLNORMALSTREAM3BATIPROC) (GLenum stream, GLbyte nx, GLbyte ny, GLbyte nz); typedef void (APIENTRYP PFNGLNORMALSTREAM3BVATIPROC) (GLenum stream, const GLbyte *coords); typedef void (APIENTRYP PFNGLNORMALSTREAM3SATIPROC) (GLenum stream, GLshort nx, GLshort ny, GLshort nz); typedef void (APIENTRYP PFNGLNORMALSTREAM3SVATIPROC) (GLenum stream, const GLshort *coords); typedef void (APIENTRYP PFNGLNORMALSTREAM3IATIPROC) (GLenum stream, GLint nx, GLint ny, GLint nz); typedef void (APIENTRYP PFNGLNORMALSTREAM3IVATIPROC) (GLenum stream, const GLint *coords); typedef void (APIENTRYP PFNGLNORMALSTREAM3FATIPROC) (GLenum stream, GLfloat nx, GLfloat ny, GLfloat nz); typedef void (APIENTRYP PFNGLNORMALSTREAM3FVATIPROC) (GLenum stream, const GLfloat *coords); typedef void (APIENTRYP PFNGLNORMALSTREAM3DATIPROC) (GLenum stream, GLdouble nx, GLdouble ny, GLdouble nz); typedef void (APIENTRYP PFNGLNORMALSTREAM3DVATIPROC) (GLenum stream, const GLdouble *coords); typedef void (APIENTRYP PFNGLCLIENTACTIVEVERTEXSTREAMATIPROC) (GLenum stream); typedef void (APIENTRYP PFNGLVERTEXBLENDENVIATIPROC) (GLenum pname, GLint param); typedef void (APIENTRYP PFNGLVERTEXBLENDENVFATIPROC) (GLenum pname, GLfloat param); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glVertexStream1sATI (GLenum stream, GLshort x); GLAPI void APIENTRY glVertexStream1svATI (GLenum stream, const GLshort *coords); GLAPI void APIENTRY glVertexStream1iATI (GLenum stream, GLint x); GLAPI void APIENTRY glVertexStream1ivATI (GLenum stream, const GLint *coords); GLAPI void APIENTRY glVertexStream1fATI (GLenum stream, GLfloat x); GLAPI void APIENTRY glVertexStream1fvATI (GLenum stream, const GLfloat *coords); GLAPI void APIENTRY glVertexStream1dATI (GLenum stream, GLdouble x); GLAPI void APIENTRY glVertexStream1dvATI (GLenum stream, const GLdouble *coords); GLAPI void APIENTRY glVertexStream2sATI (GLenum stream, GLshort x, GLshort y); GLAPI void APIENTRY glVertexStream2svATI (GLenum stream, const GLshort *coords); GLAPI void APIENTRY glVertexStream2iATI (GLenum stream, GLint x, GLint y); GLAPI void APIENTRY glVertexStream2ivATI (GLenum stream, const GLint *coords); GLAPI void APIENTRY glVertexStream2fATI (GLenum stream, GLfloat x, GLfloat y); GLAPI void APIENTRY glVertexStream2fvATI (GLenum stream, const GLfloat *coords); GLAPI void APIENTRY glVertexStream2dATI (GLenum stream, GLdouble x, GLdouble y); GLAPI void APIENTRY glVertexStream2dvATI (GLenum stream, const GLdouble *coords); GLAPI void APIENTRY glVertexStream3sATI (GLenum stream, GLshort x, GLshort y, GLshort z); GLAPI void APIENTRY glVertexStream3svATI (GLenum stream, const GLshort *coords); GLAPI void APIENTRY glVertexStream3iATI (GLenum stream, GLint x, GLint y, GLint z); GLAPI void APIENTRY glVertexStream3ivATI (GLenum stream, const GLint *coords); GLAPI void APIENTRY glVertexStream3fATI (GLenum stream, GLfloat x, GLfloat y, GLfloat z); GLAPI void APIENTRY glVertexStream3fvATI (GLenum stream, const GLfloat *coords); GLAPI void APIENTRY glVertexStream3dATI (GLenum stream, GLdouble x, GLdouble y, GLdouble z); GLAPI void APIENTRY glVertexStream3dvATI (GLenum stream, const GLdouble *coords); GLAPI void APIENTRY glVertexStream4sATI (GLenum stream, GLshort x, GLshort y, GLshort z, GLshort w); GLAPI void APIENTRY glVertexStream4svATI (GLenum stream, const GLshort *coords); GLAPI void APIENTRY glVertexStream4iATI (GLenum stream, GLint x, GLint y, GLint z, GLint w); GLAPI void APIENTRY glVertexStream4ivATI (GLenum stream, const GLint *coords); GLAPI void APIENTRY glVertexStream4fATI (GLenum stream, GLfloat x, GLfloat y, GLfloat z, GLfloat w); GLAPI void APIENTRY glVertexStream4fvATI (GLenum stream, const GLfloat *coords); GLAPI void APIENTRY glVertexStream4dATI (GLenum stream, GLdouble x, GLdouble y, GLdouble z, GLdouble w); GLAPI void APIENTRY glVertexStream4dvATI (GLenum stream, const GLdouble *coords); GLAPI void APIENTRY glNormalStream3bATI (GLenum stream, GLbyte nx, GLbyte ny, GLbyte nz); GLAPI void APIENTRY glNormalStream3bvATI (GLenum stream, const GLbyte *coords); GLAPI void APIENTRY glNormalStream3sATI (GLenum stream, GLshort nx, GLshort ny, GLshort nz); GLAPI void APIENTRY glNormalStream3svATI (GLenum stream, const GLshort *coords); GLAPI void APIENTRY glNormalStream3iATI (GLenum stream, GLint nx, GLint ny, GLint nz); GLAPI void APIENTRY glNormalStream3ivATI (GLenum stream, const GLint *coords); GLAPI void APIENTRY glNormalStream3fATI (GLenum stream, GLfloat nx, GLfloat ny, GLfloat nz); GLAPI void APIENTRY glNormalStream3fvATI (GLenum stream, const GLfloat *coords); GLAPI void APIENTRY glNormalStream3dATI (GLenum stream, GLdouble nx, GLdouble ny, GLdouble nz); GLAPI void APIENTRY glNormalStream3dvATI (GLenum stream, const GLdouble *coords); GLAPI void APIENTRY glClientActiveVertexStreamATI (GLenum stream); GLAPI void APIENTRY glVertexBlendEnviATI (GLenum pname, GLint param); GLAPI void APIENTRY glVertexBlendEnvfATI (GLenum pname, GLfloat param); #endif #endif /* GL_ATI_vertex_streams */ #ifndef GL_EXT_422_pixels #define GL_EXT_422_pixels 1 #define GL_422_EXT 0x80CC #define GL_422_REV_EXT 0x80CD #define GL_422_AVERAGE_EXT 0x80CE #define GL_422_REV_AVERAGE_EXT 0x80CF #endif /* GL_EXT_422_pixels */ #ifndef GL_EXT_EGL_image_storage #define GL_EXT_EGL_image_storage 1 typedef void *GLeglImageOES; typedef void (APIENTRYP PFNGLEGLIMAGETARGETTEXSTORAGEEXTPROC) (GLenum target, GLeglImageOES image, const GLint* attrib_list); typedef void (APIENTRYP PFNGLEGLIMAGETARGETTEXTURESTORAGEEXTPROC) (GLuint texture, GLeglImageOES image, const GLint* attrib_list); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glEGLImageTargetTexStorageEXT (GLenum target, GLeglImageOES image, const GLint* attrib_list); GLAPI void APIENTRY glEGLImageTargetTextureStorageEXT (GLuint texture, GLeglImageOES image, const GLint* attrib_list); #endif #endif /* GL_EXT_EGL_image_storage */ #ifndef GL_EXT_EGL_sync #define GL_EXT_EGL_sync 1 #endif /* GL_EXT_EGL_sync */ #ifndef GL_EXT_abgr #define GL_EXT_abgr 1 #define GL_ABGR_EXT 0x8000 #endif /* GL_EXT_abgr */ #ifndef GL_EXT_bgra #define GL_EXT_bgra 1 #define GL_BGR_EXT 0x80E0 #define GL_BGRA_EXT 0x80E1 #endif /* GL_EXT_bgra */ #ifndef GL_EXT_bindable_uniform #define GL_EXT_bindable_uniform 1 #define GL_MAX_VERTEX_BINDABLE_UNIFORMS_EXT 0x8DE2 #define GL_MAX_FRAGMENT_BINDABLE_UNIFORMS_EXT 0x8DE3 #define GL_MAX_GEOMETRY_BINDABLE_UNIFORMS_EXT 0x8DE4 #define GL_MAX_BINDABLE_UNIFORM_SIZE_EXT 0x8DED #define GL_UNIFORM_BUFFER_EXT 0x8DEE #define GL_UNIFORM_BUFFER_BINDING_EXT 0x8DEF typedef void (APIENTRYP PFNGLUNIFORMBUFFEREXTPROC) (GLuint program, GLint location, GLuint buffer); typedef GLint (APIENTRYP PFNGLGETUNIFORMBUFFERSIZEEXTPROC) (GLuint program, GLint location); typedef GLintptr (APIENTRYP PFNGLGETUNIFORMOFFSETEXTPROC) (GLuint program, GLint location); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glUniformBufferEXT (GLuint program, GLint location, GLuint buffer); GLAPI GLint APIENTRY glGetUniformBufferSizeEXT (GLuint program, GLint location); GLAPI GLintptr APIENTRY glGetUniformOffsetEXT (GLuint program, GLint location); #endif #endif /* GL_EXT_bindable_uniform */ #ifndef GL_EXT_blend_color #define GL_EXT_blend_color 1 #define GL_CONSTANT_COLOR_EXT 0x8001 #define GL_ONE_MINUS_CONSTANT_COLOR_EXT 0x8002 #define GL_CONSTANT_ALPHA_EXT 0x8003 #define GL_ONE_MINUS_CONSTANT_ALPHA_EXT 0x8004 #define GL_BLEND_COLOR_EXT 0x8005 typedef void (APIENTRYP PFNGLBLENDCOLOREXTPROC) (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glBlendColorEXT (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); #endif #endif /* GL_EXT_blend_color */ #ifndef GL_EXT_blend_equation_separate #define GL_EXT_blend_equation_separate 1 #define GL_BLEND_EQUATION_RGB_EXT 0x8009 #define GL_BLEND_EQUATION_ALPHA_EXT 0x883D typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEEXTPROC) (GLenum modeRGB, GLenum modeAlpha); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glBlendEquationSeparateEXT (GLenum modeRGB, GLenum modeAlpha); #endif #endif /* GL_EXT_blend_equation_separate */ #ifndef GL_EXT_blend_func_separate #define GL_EXT_blend_func_separate 1 #define GL_BLEND_DST_RGB_EXT 0x80C8 #define GL_BLEND_SRC_RGB_EXT 0x80C9 #define GL_BLEND_DST_ALPHA_EXT 0x80CA #define GL_BLEND_SRC_ALPHA_EXT 0x80CB typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEEXTPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glBlendFuncSeparateEXT (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); #endif #endif /* GL_EXT_blend_func_separate */ #ifndef GL_EXT_blend_logic_op #define GL_EXT_blend_logic_op 1 #endif /* GL_EXT_blend_logic_op */ #ifndef GL_EXT_blend_minmax #define GL_EXT_blend_minmax 1 #define GL_MIN_EXT 0x8007 #define GL_MAX_EXT 0x8008 #define GL_FUNC_ADD_EXT 0x8006 #define GL_BLEND_EQUATION_EXT 0x8009 typedef void (APIENTRYP PFNGLBLENDEQUATIONEXTPROC) (GLenum mode); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glBlendEquationEXT (GLenum mode); #endif #endif /* GL_EXT_blend_minmax */ #ifndef GL_EXT_blend_subtract #define GL_EXT_blend_subtract 1 #define GL_FUNC_SUBTRACT_EXT 0x800A #define GL_FUNC_REVERSE_SUBTRACT_EXT 0x800B #endif /* GL_EXT_blend_subtract */ #ifndef GL_EXT_clip_volume_hint #define GL_EXT_clip_volume_hint 1 #define GL_CLIP_VOLUME_CLIPPING_HINT_EXT 0x80F0 #endif /* GL_EXT_clip_volume_hint */ #ifndef GL_EXT_cmyka #define GL_EXT_cmyka 1 #define GL_CMYK_EXT 0x800C #define GL_CMYKA_EXT 0x800D #define GL_PACK_CMYK_HINT_EXT 0x800E #define GL_UNPACK_CMYK_HINT_EXT 0x800F #endif /* GL_EXT_cmyka */ #ifndef GL_EXT_color_subtable #define GL_EXT_color_subtable 1 typedef void (APIENTRYP PFNGLCOLORSUBTABLEEXTPROC) (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const void *data); typedef void (APIENTRYP PFNGLCOPYCOLORSUBTABLEEXTPROC) (GLenum target, GLsizei start, GLint x, GLint y, GLsizei width); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glColorSubTableEXT (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const void *data); GLAPI void APIENTRY glCopyColorSubTableEXT (GLenum target, GLsizei start, GLint x, GLint y, GLsizei width); #endif #endif /* GL_EXT_color_subtable */ #ifndef GL_EXT_compiled_vertex_array #define GL_EXT_compiled_vertex_array 1 #define GL_ARRAY_ELEMENT_LOCK_FIRST_EXT 0x81A8 #define GL_ARRAY_ELEMENT_LOCK_COUNT_EXT 0x81A9 typedef void (APIENTRYP PFNGLLOCKARRAYSEXTPROC) (GLint first, GLsizei count); typedef void (APIENTRYP PFNGLUNLOCKARRAYSEXTPROC) (void); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glLockArraysEXT (GLint first, GLsizei count); GLAPI void APIENTRY glUnlockArraysEXT (void); #endif #endif /* GL_EXT_compiled_vertex_array */ #ifndef GL_EXT_convolution #define GL_EXT_convolution 1 #define GL_CONVOLUTION_1D_EXT 0x8010 #define GL_CONVOLUTION_2D_EXT 0x8011 #define GL_SEPARABLE_2D_EXT 0x8012 #define GL_CONVOLUTION_BORDER_MODE_EXT 0x8013 #define GL_CONVOLUTION_FILTER_SCALE_EXT 0x8014 #define GL_CONVOLUTION_FILTER_BIAS_EXT 0x8015 #define GL_REDUCE_EXT 0x8016 #define GL_CONVOLUTION_FORMAT_EXT 0x8017 #define GL_CONVOLUTION_WIDTH_EXT 0x8018 #define GL_CONVOLUTION_HEIGHT_EXT 0x8019 #define GL_MAX_CONVOLUTION_WIDTH_EXT 0x801A #define GL_MAX_CONVOLUTION_HEIGHT_EXT 0x801B #define GL_POST_CONVOLUTION_RED_SCALE_EXT 0x801C #define GL_POST_CONVOLUTION_GREEN_SCALE_EXT 0x801D #define GL_POST_CONVOLUTION_BLUE_SCALE_EXT 0x801E #define GL_POST_CONVOLUTION_ALPHA_SCALE_EXT 0x801F #define GL_POST_CONVOLUTION_RED_BIAS_EXT 0x8020 #define GL_POST_CONVOLUTION_GREEN_BIAS_EXT 0x8021 #define GL_POST_CONVOLUTION_BLUE_BIAS_EXT 0x8022 #define GL_POST_CONVOLUTION_ALPHA_BIAS_EXT 0x8023 typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER1DEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const void *image); typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER2DEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *image); typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFEXTPROC) (GLenum target, GLenum pname, GLfloat params); typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFVEXTPROC) (GLenum target, GLenum pname, const GLfloat *params); typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIEXTPROC) (GLenum target, GLenum pname, GLint params); typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIVEXTPROC) (GLenum target, GLenum pname, const GLint *params); typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER1DEXTPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER2DEXTPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height); typedef void (APIENTRYP PFNGLGETCONVOLUTIONFILTEREXTPROC) (GLenum target, GLenum format, GLenum type, void *image); typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); typedef void (APIENTRYP PFNGLGETSEPARABLEFILTEREXTPROC) (GLenum target, GLenum format, GLenum type, void *row, void *column, void *span); typedef void (APIENTRYP PFNGLSEPARABLEFILTER2DEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *row, const void *column); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glConvolutionFilter1DEXT (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const void *image); GLAPI void APIENTRY glConvolutionFilter2DEXT (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *image); GLAPI void APIENTRY glConvolutionParameterfEXT (GLenum target, GLenum pname, GLfloat params); GLAPI void APIENTRY glConvolutionParameterfvEXT (GLenum target, GLenum pname, const GLfloat *params); GLAPI void APIENTRY glConvolutionParameteriEXT (GLenum target, GLenum pname, GLint params); GLAPI void APIENTRY glConvolutionParameterivEXT (GLenum target, GLenum pname, const GLint *params); GLAPI void APIENTRY glCopyConvolutionFilter1DEXT (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); GLAPI void APIENTRY glCopyConvolutionFilter2DEXT (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height); GLAPI void APIENTRY glGetConvolutionFilterEXT (GLenum target, GLenum format, GLenum type, void *image); GLAPI void APIENTRY glGetConvolutionParameterfvEXT (GLenum target, GLenum pname, GLfloat *params); GLAPI void APIENTRY glGetConvolutionParameterivEXT (GLenum target, GLenum pname, GLint *params); GLAPI void APIENTRY glGetSeparableFilterEXT (GLenum target, GLenum format, GLenum type, void *row, void *column, void *span); GLAPI void APIENTRY glSeparableFilter2DEXT (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *row, const void *column); #endif #endif /* GL_EXT_convolution */ #ifndef GL_EXT_coordinate_frame #define GL_EXT_coordinate_frame 1 #define GL_TANGENT_ARRAY_EXT 0x8439 #define GL_BINORMAL_ARRAY_EXT 0x843A #define GL_CURRENT_TANGENT_EXT 0x843B #define GL_CURRENT_BINORMAL_EXT 0x843C #define GL_TANGENT_ARRAY_TYPE_EXT 0x843E #define GL_TANGENT_ARRAY_STRIDE_EXT 0x843F #define GL_BINORMAL_ARRAY_TYPE_EXT 0x8440 #define GL_BINORMAL_ARRAY_STRIDE_EXT 0x8441 #define GL_TANGENT_ARRAY_POINTER_EXT 0x8442 #define GL_BINORMAL_ARRAY_POINTER_EXT 0x8443 #define GL_MAP1_TANGENT_EXT 0x8444 #define GL_MAP2_TANGENT_EXT 0x8445 #define GL_MAP1_BINORMAL_EXT 0x8446 #define GL_MAP2_BINORMAL_EXT 0x8447 typedef void (APIENTRYP PFNGLTANGENT3BEXTPROC) (GLbyte tx, GLbyte ty, GLbyte tz); typedef void (APIENTRYP PFNGLTANGENT3BVEXTPROC) (const GLbyte *v); typedef void (APIENTRYP PFNGLTANGENT3DEXTPROC) (GLdouble tx, GLdouble ty, GLdouble tz); typedef void (APIENTRYP PFNGLTANGENT3DVEXTPROC) (const GLdouble *v); typedef void (APIENTRYP PFNGLTANGENT3FEXTPROC) (GLfloat tx, GLfloat ty, GLfloat tz); typedef void (APIENTRYP PFNGLTANGENT3FVEXTPROC) (const GLfloat *v); typedef void (APIENTRYP PFNGLTANGENT3IEXTPROC) (GLint tx, GLint ty, GLint tz); typedef void (APIENTRYP PFNGLTANGENT3IVEXTPROC) (const GLint *v); typedef void (APIENTRYP PFNGLTANGENT3SEXTPROC) (GLshort tx, GLshort ty, GLshort tz); typedef void (APIENTRYP PFNGLTANGENT3SVEXTPROC) (const GLshort *v); typedef void (APIENTRYP PFNGLBINORMAL3BEXTPROC) (GLbyte bx, GLbyte by, GLbyte bz); typedef void (APIENTRYP PFNGLBINORMAL3BVEXTPROC) (const GLbyte *v); typedef void (APIENTRYP PFNGLBINORMAL3DEXTPROC) (GLdouble bx, GLdouble by, GLdouble bz); typedef void (APIENTRYP PFNGLBINORMAL3DVEXTPROC) (const GLdouble *v); typedef void (APIENTRYP PFNGLBINORMAL3FEXTPROC) (GLfloat bx, GLfloat by, GLfloat bz); typedef void (APIENTRYP PFNGLBINORMAL3FVEXTPROC) (const GLfloat *v); typedef void (APIENTRYP PFNGLBINORMAL3IEXTPROC) (GLint bx, GLint by, GLint bz); typedef void (APIENTRYP PFNGLBINORMAL3IVEXTPROC) (const GLint *v); typedef void (APIENTRYP PFNGLBINORMAL3SEXTPROC) (GLshort bx, GLshort by, GLshort bz); typedef void (APIENTRYP PFNGLBINORMAL3SVEXTPROC) (const GLshort *v); typedef void (APIENTRYP PFNGLTANGENTPOINTEREXTPROC) (GLenum type, GLsizei stride, const void *pointer); typedef void (APIENTRYP PFNGLBINORMALPOINTEREXTPROC) (GLenum type, GLsizei stride, const void *pointer); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glTangent3bEXT (GLbyte tx, GLbyte ty, GLbyte tz); GLAPI void APIENTRY glTangent3bvEXT (const GLbyte *v); GLAPI void APIENTRY glTangent3dEXT (GLdouble tx, GLdouble ty, GLdouble tz); GLAPI void APIENTRY glTangent3dvEXT (const GLdouble *v); GLAPI void APIENTRY glTangent3fEXT (GLfloat tx, GLfloat ty, GLfloat tz); GLAPI void APIENTRY glTangent3fvEXT (const GLfloat *v); GLAPI void APIENTRY glTangent3iEXT (GLint tx, GLint ty, GLint tz); GLAPI void APIENTRY glTangent3ivEXT (const GLint *v); GLAPI void APIENTRY glTangent3sEXT (GLshort tx, GLshort ty, GLshort tz); GLAPI void APIENTRY glTangent3svEXT (const GLshort *v); GLAPI void APIENTRY glBinormal3bEXT (GLbyte bx, GLbyte by, GLbyte bz); GLAPI void APIENTRY glBinormal3bvEXT (const GLbyte *v); GLAPI void APIENTRY glBinormal3dEXT (GLdouble bx, GLdouble by, GLdouble bz); GLAPI void APIENTRY glBinormal3dvEXT (const GLdouble *v); GLAPI void APIENTRY glBinormal3fEXT (GLfloat bx, GLfloat by, GLfloat bz); GLAPI void APIENTRY glBinormal3fvEXT (const GLfloat *v); GLAPI void APIENTRY glBinormal3iEXT (GLint bx, GLint by, GLint bz); GLAPI void APIENTRY glBinormal3ivEXT (const GLint *v); GLAPI void APIENTRY glBinormal3sEXT (GLshort bx, GLshort by, GLshort bz); GLAPI void APIENTRY glBinormal3svEXT (const GLshort *v); GLAPI void APIENTRY glTangentPointerEXT (GLenum type, GLsizei stride, const void *pointer); GLAPI void APIENTRY glBinormalPointerEXT (GLenum type, GLsizei stride, const void *pointer); #endif #endif /* GL_EXT_coordinate_frame */ #ifndef GL_EXT_copy_texture #define GL_EXT_copy_texture 1 typedef void (APIENTRYP PFNGLCOPYTEXIMAGE1DEXTPROC) (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); typedef void (APIENTRYP PFNGLCOPYTEXIMAGE2DEXTPROC) (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE1DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE2DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE3DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glCopyTexImage1DEXT (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); GLAPI void APIENTRY glCopyTexImage2DEXT (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); GLAPI void APIENTRY glCopyTexSubImage1DEXT (GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); GLAPI void APIENTRY glCopyTexSubImage2DEXT (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); GLAPI void APIENTRY glCopyTexSubImage3DEXT (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); #endif #endif /* GL_EXT_copy_texture */ #ifndef GL_EXT_cull_vertex #define GL_EXT_cull_vertex 1 #define GL_CULL_VERTEX_EXT 0x81AA #define GL_CULL_VERTEX_EYE_POSITION_EXT 0x81AB #define GL_CULL_VERTEX_OBJECT_POSITION_EXT 0x81AC typedef void (APIENTRYP PFNGLCULLPARAMETERDVEXTPROC) (GLenum pname, GLdouble *params); typedef void (APIENTRYP PFNGLCULLPARAMETERFVEXTPROC) (GLenum pname, GLfloat *params); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glCullParameterdvEXT (GLenum pname, GLdouble *params); GLAPI void APIENTRY glCullParameterfvEXT (GLenum pname, GLfloat *params); #endif #endif /* GL_EXT_cull_vertex */ #ifndef GL_EXT_debug_label #define GL_EXT_debug_label 1 #define GL_PROGRAM_PIPELINE_OBJECT_EXT 0x8A4F #define GL_PROGRAM_OBJECT_EXT 0x8B40 #define GL_SHADER_OBJECT_EXT 0x8B48 #define GL_BUFFER_OBJECT_EXT 0x9151 #define GL_QUERY_OBJECT_EXT 0x9153 #define GL_VERTEX_ARRAY_OBJECT_EXT 0x9154 typedef void (APIENTRYP PFNGLLABELOBJECTEXTPROC) (GLenum type, GLuint object, GLsizei length, const GLchar *label); typedef void (APIENTRYP PFNGLGETOBJECTLABELEXTPROC) (GLenum type, GLuint object, GLsizei bufSize, GLsizei *length, GLchar *label); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glLabelObjectEXT (GLenum type, GLuint object, GLsizei length, const GLchar *label); GLAPI void APIENTRY glGetObjectLabelEXT (GLenum type, GLuint object, GLsizei bufSize, GLsizei *length, GLchar *label); #endif #endif /* GL_EXT_debug_label */ #ifndef GL_EXT_debug_marker #define GL_EXT_debug_marker 1 typedef void (APIENTRYP PFNGLINSERTEVENTMARKEREXTPROC) (GLsizei length, const GLchar *marker); typedef void (APIENTRYP PFNGLPUSHGROUPMARKEREXTPROC) (GLsizei length, const GLchar *marker); typedef void (APIENTRYP PFNGLPOPGROUPMARKEREXTPROC) (void); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glInsertEventMarkerEXT (GLsizei length, const GLchar *marker); GLAPI void APIENTRY glPushGroupMarkerEXT (GLsizei length, const GLchar *marker); GLAPI void APIENTRY glPopGroupMarkerEXT (void); #endif #endif /* GL_EXT_debug_marker */ #ifndef GL_EXT_depth_bounds_test #define GL_EXT_depth_bounds_test 1 #define GL_DEPTH_BOUNDS_TEST_EXT 0x8890 #define GL_DEPTH_BOUNDS_EXT 0x8891 typedef void (APIENTRYP PFNGLDEPTHBOUNDSEXTPROC) (GLclampd zmin, GLclampd zmax); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glDepthBoundsEXT (GLclampd zmin, GLclampd zmax); #endif #endif /* GL_EXT_depth_bounds_test */ #ifndef GL_EXT_direct_state_access #define GL_EXT_direct_state_access 1 #define GL_PROGRAM_MATRIX_EXT 0x8E2D #define GL_TRANSPOSE_PROGRAM_MATRIX_EXT 0x8E2E #define GL_PROGRAM_MATRIX_STACK_DEPTH_EXT 0x8E2F typedef void (APIENTRYP PFNGLMATRIXLOADFEXTPROC) (GLenum mode, const GLfloat *m); typedef void (APIENTRYP PFNGLMATRIXLOADDEXTPROC) (GLenum mode, const GLdouble *m); typedef void (APIENTRYP PFNGLMATRIXMULTFEXTPROC) (GLenum mode, const GLfloat *m); typedef void (APIENTRYP PFNGLMATRIXMULTDEXTPROC) (GLenum mode, const GLdouble *m); typedef void (APIENTRYP PFNGLMATRIXLOADIDENTITYEXTPROC) (GLenum mode); typedef void (APIENTRYP PFNGLMATRIXROTATEFEXTPROC) (GLenum mode, GLfloat angle, GLfloat x, GLfloat y, GLfloat z); typedef void (APIENTRYP PFNGLMATRIXROTATEDEXTPROC) (GLenum mode, GLdouble angle, GLdouble x, GLdouble y, GLdouble z); typedef void (APIENTRYP PFNGLMATRIXSCALEFEXTPROC) (GLenum mode, GLfloat x, GLfloat y, GLfloat z); typedef void (APIENTRYP PFNGLMATRIXSCALEDEXTPROC) (GLenum mode, GLdouble x, GLdouble y, GLdouble z); typedef void (APIENTRYP PFNGLMATRIXTRANSLATEFEXTPROC) (GLenum mode, GLfloat x, GLfloat y, GLfloat z); typedef void (APIENTRYP PFNGLMATRIXTRANSLATEDEXTPROC) (GLenum mode, GLdouble x, GLdouble y, GLdouble z); typedef void (APIENTRYP PFNGLMATRIXFRUSTUMEXTPROC) (GLenum mode, GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); typedef void (APIENTRYP PFNGLMATRIXORTHOEXTPROC) (GLenum mode, GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); typedef void (APIENTRYP PFNGLMATRIXPOPEXTPROC) (GLenum mode); typedef void (APIENTRYP PFNGLMATRIXPUSHEXTPROC) (GLenum mode); typedef void (APIENTRYP PFNGLCLIENTATTRIBDEFAULTEXTPROC) (GLbitfield mask); typedef void (APIENTRYP PFNGLPUSHCLIENTATTRIBDEFAULTEXTPROC) (GLbitfield mask); typedef void (APIENTRYP PFNGLTEXTUREPARAMETERFEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLfloat param); typedef void (APIENTRYP PFNGLTEXTUREPARAMETERFVEXTPROC) (GLuint texture, GLenum target, GLenum pname, const GLfloat *params); typedef void (APIENTRYP PFNGLTEXTUREPARAMETERIEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLint param); typedef void (APIENTRYP PFNGLTEXTUREPARAMETERIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, const GLint *params); typedef void (APIENTRYP PFNGLTEXTUREIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const void *pixels); typedef void (APIENTRYP PFNGLTEXTUREIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void *pixels); typedef void (APIENTRYP PFNGLTEXTURESUBIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const void *pixels); typedef void (APIENTRYP PFNGLTEXTURESUBIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels); typedef void (APIENTRYP PFNGLCOPYTEXTUREIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); typedef void (APIENTRYP PFNGLCOPYTEXTUREIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); typedef void (APIENTRYP PFNGLCOPYTEXTURESUBIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); typedef void (APIENTRYP PFNGLCOPYTEXTURESUBIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); typedef void (APIENTRYP PFNGLGETTEXTUREIMAGEEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum format, GLenum type, void *pixels); typedef void (APIENTRYP PFNGLGETTEXTUREPARAMETERFVEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLfloat *params); typedef void (APIENTRYP PFNGLGETTEXTUREPARAMETERIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLint *params); typedef void (APIENTRYP PFNGLGETTEXTURELEVELPARAMETERFVEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum pname, GLfloat *params); typedef void (APIENTRYP PFNGLGETTEXTURELEVELPARAMETERIVEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum pname, GLint *params); typedef void (APIENTRYP PFNGLTEXTUREIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void *pixels); typedef void (APIENTRYP PFNGLTEXTURESUBIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels); typedef void (APIENTRYP PFNGLCOPYTEXTURESUBIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); typedef void (APIENTRYP PFNGLBINDMULTITEXTUREEXTPROC) (GLenum texunit, GLenum target, GLuint texture); typedef void (APIENTRYP PFNGLMULTITEXCOORDPOINTEREXTPROC) (GLenum texunit, GLint size, GLenum type, GLsizei stride, const void *pointer); typedef void (APIENTRYP PFNGLMULTITEXENVFEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLfloat param); typedef void (APIENTRYP PFNGLMULTITEXENVFVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLfloat *params); typedef void (APIENTRYP PFNGLMULTITEXENVIEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint param); typedef void (APIENTRYP PFNGLMULTITEXENVIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLint *params); typedef void (APIENTRYP PFNGLMULTITEXGENDEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLdouble param); typedef void (APIENTRYP PFNGLMULTITEXGENDVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, const GLdouble *params); typedef void (APIENTRYP PFNGLMULTITEXGENFEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLfloat param); typedef void (APIENTRYP PFNGLMULTITEXGENFVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, const GLfloat *params); typedef void (APIENTRYP PFNGLMULTITEXGENIEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLint param); typedef void (APIENTRYP PFNGLMULTITEXGENIVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, const GLint *params); typedef void (APIENTRYP PFNGLGETMULTITEXENVFVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLfloat *params); typedef void (APIENTRYP PFNGLGETMULTITEXENVIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint *params); typedef void (APIENTRYP PFNGLGETMULTITEXGENDVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLdouble *params); typedef void (APIENTRYP PFNGLGETMULTITEXGENFVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLfloat *params); typedef void (APIENTRYP PFNGLGETMULTITEXGENIVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLint *params); typedef void (APIENTRYP PFNGLMULTITEXPARAMETERIEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint param); typedef void (APIENTRYP PFNGLMULTITEXPARAMETERIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLint *params); typedef void (APIENTRYP PFNGLMULTITEXPARAMETERFEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLfloat param); typedef void (APIENTRYP PFNGLMULTITEXPARAMETERFVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLfloat *params); typedef void (APIENTRYP PFNGLMULTITEXIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const void *pixels); typedef void (APIENTRYP PFNGLMULTITEXIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void *pixels); typedef void (APIENTRYP PFNGLMULTITEXSUBIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const void *pixels); typedef void (APIENTRYP PFNGLMULTITEXSUBIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels); typedef void (APIENTRYP PFNGLCOPYMULTITEXIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); typedef void (APIENTRYP PFNGLCOPYMULTITEXIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); typedef void (APIENTRYP PFNGLCOPYMULTITEXSUBIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); typedef void (APIENTRYP PFNGLCOPYMULTITEXSUBIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); typedef void (APIENTRYP PFNGLGETMULTITEXIMAGEEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum format, GLenum type, void *pixels); typedef void (APIENTRYP PFNGLGETMULTITEXPARAMETERFVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLfloat *params); typedef void (APIENTRYP PFNGLGETMULTITEXPARAMETERIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint *params); typedef void (APIENTRYP PFNGLGETMULTITEXLEVELPARAMETERFVEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum pname, GLfloat *params); typedef void (APIENTRYP PFNGLGETMULTITEXLEVELPARAMETERIVEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum pname, GLint *params); typedef void (APIENTRYP PFNGLMULTITEXIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void *pixels); typedef void (APIENTRYP PFNGLMULTITEXSUBIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels); typedef void (APIENTRYP PFNGLCOPYMULTITEXSUBIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); typedef void (APIENTRYP PFNGLENABLECLIENTSTATEINDEXEDEXTPROC) (GLenum array, GLuint index); typedef void (APIENTRYP PFNGLDISABLECLIENTSTATEINDEXEDEXTPROC) (GLenum array, GLuint index); typedef void (APIENTRYP PFNGLGETFLOATINDEXEDVEXTPROC) (GLenum target, GLuint index, GLfloat *data); typedef void (APIENTRYP PFNGLGETDOUBLEINDEXEDVEXTPROC) (GLenum target, GLuint index, GLdouble *data); typedef void (APIENTRYP PFNGLGETPOINTERINDEXEDVEXTPROC) (GLenum target, GLuint index, void **data); typedef void (APIENTRYP PFNGLENABLEINDEXEDEXTPROC) (GLenum target, GLuint index); typedef void (APIENTRYP PFNGLDISABLEINDEXEDEXTPROC) (GLenum target, GLuint index); typedef GLboolean (APIENTRYP PFNGLISENABLEDINDEXEDEXTPROC) (GLenum target, GLuint index); typedef void (APIENTRYP PFNGLGETINTEGERINDEXEDVEXTPROC) (GLenum target, GLuint index, GLint *data); typedef void (APIENTRYP PFNGLGETBOOLEANINDEXEDVEXTPROC) (GLenum target, GLuint index, GLboolean *data); typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTUREIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void *bits); typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTUREIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void *bits); typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTUREIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const void *bits); typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTURESUBIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *bits); typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTURESUBIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *bits); typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTURESUBIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void *bits); typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXTUREIMAGEEXTPROC) (GLuint texture, GLenum target, GLint lod, void *img); typedef void (APIENTRYP PFNGLCOMPRESSEDMULTITEXIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void *bits); typedef void (APIENTRYP PFNGLCOMPRESSEDMULTITEXIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void *bits); typedef void (APIENTRYP PFNGLCOMPRESSEDMULTITEXIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const void *bits); typedef void (APIENTRYP PFNGLCOMPRESSEDMULTITEXSUBIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *bits); typedef void (APIENTRYP PFNGLCOMPRESSEDMULTITEXSUBIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *bits); typedef void (APIENTRYP PFNGLCOMPRESSEDMULTITEXSUBIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void *bits); typedef void (APIENTRYP PFNGLGETCOMPRESSEDMULTITEXIMAGEEXTPROC) (GLenum texunit, GLenum target, GLint lod, void *img); typedef void (APIENTRYP PFNGLMATRIXLOADTRANSPOSEFEXTPROC) (GLenum mode, const GLfloat *m); typedef void (APIENTRYP PFNGLMATRIXLOADTRANSPOSEDEXTPROC) (GLenum mode, const GLdouble *m); typedef void (APIENTRYP PFNGLMATRIXMULTTRANSPOSEFEXTPROC) (GLenum mode, const GLfloat *m); typedef void (APIENTRYP PFNGLMATRIXMULTTRANSPOSEDEXTPROC) (GLenum mode, const GLdouble *m); typedef void (APIENTRYP PFNGLNAMEDBUFFERDATAEXTPROC) (GLuint buffer, GLsizeiptr size, const void *data, GLenum usage); typedef void (APIENTRYP PFNGLNAMEDBUFFERSUBDATAEXTPROC) (GLuint buffer, GLintptr offset, GLsizeiptr size, const void *data); typedef void *(APIENTRYP PFNGLMAPNAMEDBUFFEREXTPROC) (GLuint buffer, GLenum access); typedef GLboolean (APIENTRYP PFNGLUNMAPNAMEDBUFFEREXTPROC) (GLuint buffer); typedef void (APIENTRYP PFNGLGETNAMEDBUFFERPARAMETERIVEXTPROC) (GLuint buffer, GLenum pname, GLint *params); typedef void (APIENTRYP PFNGLGETNAMEDBUFFERPOINTERVEXTPROC) (GLuint buffer, GLenum pname, void **params); typedef void (APIENTRYP PFNGLGETNAMEDBUFFERSUBDATAEXTPROC) (GLuint buffer, GLintptr offset, GLsizeiptr size, void *data); typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1FEXTPROC) (GLuint program, GLint location, GLfloat v0); typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2FEXTPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1); typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3FEXTPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2); typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4FEXTPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1IEXTPROC) (GLuint program, GLint location, GLint v0); typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2IEXTPROC) (GLuint program, GLint location, GLint v0, GLint v1); typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3IEXTPROC) (GLuint program, GLint location, GLint v0, GLint v1, GLint v2); typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4IEXTPROC) (GLuint program, GLint location, GLint v0, GLint v1, GLint v2, GLint v3); typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X3FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X2FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X4FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X2FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X4FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X3FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); typedef void (APIENTRYP PFNGLTEXTUREBUFFEREXTPROC) (GLuint texture, GLenum target, GLenum internalformat, GLuint buffer); typedef void (APIENTRYP PFNGLMULTITEXBUFFEREXTPROC) (GLenum texunit, GLenum target, GLenum internalformat, GLuint buffer); typedef void (APIENTRYP PFNGLTEXTUREPARAMETERIIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, const GLint *params); typedef void (APIENTRYP PFNGLTEXTUREPARAMETERIUIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, const GLuint *params); typedef void (APIENTRYP PFNGLGETTEXTUREPARAMETERIIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLint *params); typedef void (APIENTRYP PFNGLGETTEXTUREPARAMETERIUIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLuint *params); typedef void (APIENTRYP PFNGLMULTITEXPARAMETERIIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLint *params); typedef void (APIENTRYP PFNGLMULTITEXPARAMETERIUIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLuint *params); typedef void (APIENTRYP PFNGLGETMULTITEXPARAMETERIIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint *params); typedef void (APIENTRYP PFNGLGETMULTITEXPARAMETERIUIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLuint *params); typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UIEXTPROC) (GLuint program, GLint location, GLuint v0); typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UIEXTPROC) (GLuint program, GLint location, GLuint v0, GLuint v1); typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UIEXTPROC) (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2); typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UIEXTPROC) (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UIVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UIVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UIVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UIVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERS4FVEXTPROC) (GLuint program, GLenum target, GLuint index, GLsizei count, const GLfloat *params); typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERI4IEXTPROC) (GLuint program, GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w); typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERI4IVEXTPROC) (GLuint program, GLenum target, GLuint index, const GLint *params); typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERSI4IVEXTPROC) (GLuint program, GLenum target, GLuint index, GLsizei count, const GLint *params); typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERI4UIEXTPROC) (GLuint program, GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERI4UIVEXTPROC) (GLuint program, GLenum target, GLuint index, const GLuint *params); typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERSI4UIVEXTPROC) (GLuint program, GLenum target, GLuint index, GLsizei count, const GLuint *params); typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMLOCALPARAMETERIIVEXTPROC) (GLuint program, GLenum target, GLuint index, GLint *params); typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMLOCALPARAMETERIUIVEXTPROC) (GLuint program, GLenum target, GLuint index, GLuint *params); typedef void (APIENTRYP PFNGLENABLECLIENTSTATEIEXTPROC) (GLenum array, GLuint index); typedef void (APIENTRYP PFNGLDISABLECLIENTSTATEIEXTPROC) (GLenum array, GLuint index); typedef void (APIENTRYP PFNGLGETFLOATI_VEXTPROC) (GLenum pname, GLuint index, GLfloat *params); typedef void (APIENTRYP PFNGLGETDOUBLEI_VEXTPROC) (GLenum pname, GLuint index, GLdouble *params); typedef void (APIENTRYP PFNGLGETPOINTERI_VEXTPROC) (GLenum pname, GLuint index, void **params); typedef void (APIENTRYP PFNGLNAMEDPROGRAMSTRINGEXTPROC) (GLuint program, GLenum target, GLenum format, GLsizei len, const void *string); typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETER4DEXTPROC) (GLuint program, GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETER4DVEXTPROC) (GLuint program, GLenum target, GLuint index, const GLdouble *params); typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETER4FEXTPROC) (GLuint program, GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETER4FVEXTPROC) (GLuint program, GLenum target, GLuint index, const GLfloat *params); typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMLOCALPARAMETERDVEXTPROC) (GLuint program, GLenum target, GLuint index, GLdouble *params); typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMLOCALPARAMETERFVEXTPROC) (GLuint program, GLenum target, GLuint index, GLfloat *params); typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMIVEXTPROC) (GLuint program, GLenum target, GLenum pname, GLint *params); typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMSTRINGEXTPROC) (GLuint program, GLenum target, GLenum pname, void *string); typedef void (APIENTRYP PFNGLNAMEDRENDERBUFFERSTORAGEEXTPROC) (GLuint renderbuffer, GLenum internalformat, GLsizei width, GLsizei height); typedef void (APIENTRYP PFNGLGETNAMEDRENDERBUFFERPARAMETERIVEXTPROC) (GLuint renderbuffer, GLenum pname, GLint *params); typedef void (APIENTRYP PFNGLNAMEDRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC) (GLuint renderbuffer, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); typedef void (APIENTRYP PFNGLNAMEDRENDERBUFFERSTORAGEMULTISAMPLECOVERAGEEXTPROC) (GLuint renderbuffer, GLsizei coverageSamples, GLsizei colorSamples, GLenum internalformat, GLsizei width, GLsizei height); typedef GLenum (APIENTRYP PFNGLCHECKNAMEDFRAMEBUFFERSTATUSEXTPROC) (GLuint framebuffer, GLenum target); typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTURE1DEXTPROC) (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level); typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTURE2DEXTPROC) (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level); typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTURE3DEXTPROC) (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERRENDERBUFFEREXTPROC) (GLuint framebuffer, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); typedef void (APIENTRYP PFNGLGETNAMEDFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC) (GLuint framebuffer, GLenum attachment, GLenum pname, GLint *params); typedef void (APIENTRYP PFNGLGENERATETEXTUREMIPMAPEXTPROC) (GLuint texture, GLenum target); typedef void (APIENTRYP PFNGLGENERATEMULTITEXMIPMAPEXTPROC) (GLenum texunit, GLenum target); typedef void (APIENTRYP PFNGLFRAMEBUFFERDRAWBUFFEREXTPROC) (GLuint framebuffer, GLenum mode); typedef void (APIENTRYP PFNGLFRAMEBUFFERDRAWBUFFERSEXTPROC) (GLuint framebuffer, GLsizei n, const GLenum *bufs); typedef void (APIENTRYP PFNGLFRAMEBUFFERREADBUFFEREXTPROC) (GLuint framebuffer, GLenum mode); typedef void (APIENTRYP PFNGLGETFRAMEBUFFERPARAMETERIVEXTPROC) (GLuint framebuffer, GLenum pname, GLint *params); typedef void (APIENTRYP PFNGLNAMEDCOPYBUFFERSUBDATAEXTPROC) (GLuint readBuffer, GLuint writeBuffer, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTUREEXTPROC) (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level); typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTURELAYEREXTPROC) (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level, GLint layer); typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTUREFACEEXTPROC) (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level, GLenum face); typedef void (APIENTRYP PFNGLTEXTURERENDERBUFFEREXTPROC) (GLuint texture, GLenum target, GLuint renderbuffer); typedef void (APIENTRYP PFNGLMULTITEXRENDERBUFFEREXTPROC) (GLenum texunit, GLenum target, GLuint renderbuffer); typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLint size, GLenum type, GLsizei stride, GLintptr offset); typedef void (APIENTRYP PFNGLVERTEXARRAYCOLOROFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLint size, GLenum type, GLsizei stride, GLintptr offset); typedef void (APIENTRYP PFNGLVERTEXARRAYEDGEFLAGOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLsizei stride, GLintptr offset); typedef void (APIENTRYP PFNGLVERTEXARRAYINDEXOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLenum type, GLsizei stride, GLintptr offset); typedef void (APIENTRYP PFNGLVERTEXARRAYNORMALOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLenum type, GLsizei stride, GLintptr offset); typedef void (APIENTRYP PFNGLVERTEXARRAYTEXCOORDOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLint size, GLenum type, GLsizei stride, GLintptr offset); typedef void (APIENTRYP PFNGLVERTEXARRAYMULTITEXCOORDOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLenum texunit, GLint size, GLenum type, GLsizei stride, GLintptr offset); typedef void (APIENTRYP PFNGLVERTEXARRAYFOGCOORDOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLenum type, GLsizei stride, GLintptr offset); typedef void (APIENTRYP PFNGLVERTEXARRAYSECONDARYCOLOROFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLint size, GLenum type, GLsizei stride, GLintptr offset); typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, GLintptr offset); typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBIOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLuint index, GLint size, GLenum type, GLsizei stride, GLintptr offset); typedef void (APIENTRYP PFNGLENABLEVERTEXARRAYEXTPROC) (GLuint vaobj, GLenum array); typedef void (APIENTRYP PFNGLDISABLEVERTEXARRAYEXTPROC) (GLuint vaobj, GLenum array); typedef void (APIENTRYP PFNGLENABLEVERTEXARRAYATTRIBEXTPROC) (GLuint vaobj, GLuint index); typedef void (APIENTRYP PFNGLDISABLEVERTEXARRAYATTRIBEXTPROC) (GLuint vaobj, GLuint index); typedef void (APIENTRYP PFNGLGETVERTEXARRAYINTEGERVEXTPROC) (GLuint vaobj, GLenum pname, GLint *param); typedef void (APIENTRYP PFNGLGETVERTEXARRAYPOINTERVEXTPROC) (GLuint vaobj, GLenum pname, void **param); typedef void (APIENTRYP PFNGLGETVERTEXARRAYINTEGERI_VEXTPROC) (GLuint vaobj, GLuint index, GLenum pname, GLint *param); typedef void (APIENTRYP PFNGLGETVERTEXARRAYPOINTERI_VEXTPROC) (GLuint vaobj, GLuint index, GLenum pname, void **param); typedef void *(APIENTRYP PFNGLMAPNAMEDBUFFERRANGEEXTPROC) (GLuint buffer, GLintptr offset, GLsizeiptr length, GLbitfield access); typedef void (APIENTRYP PFNGLFLUSHMAPPEDNAMEDBUFFERRANGEEXTPROC) (GLuint buffer, GLintptr offset, GLsizeiptr length); typedef void (APIENTRYP PFNGLNAMEDBUFFERSTORAGEEXTPROC) (GLuint buffer, GLsizeiptr size, const void *data, GLbitfield flags); typedef void (APIENTRYP PFNGLCLEARNAMEDBUFFERDATAEXTPROC) (GLuint buffer, GLenum internalformat, GLenum format, GLenum type, const void *data); typedef void (APIENTRYP PFNGLCLEARNAMEDBUFFERSUBDATAEXTPROC) (GLuint buffer, GLenum internalformat, GLsizeiptr offset, GLsizeiptr size, GLenum format, GLenum type, const void *data); typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERPARAMETERIEXTPROC) (GLuint framebuffer, GLenum pname, GLint param); typedef void (APIENTRYP PFNGLGETNAMEDFRAMEBUFFERPARAMETERIVEXTPROC) (GLuint framebuffer, GLenum pname, GLint *params); typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1DEXTPROC) (GLuint program, GLint location, GLdouble x); typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2DEXTPROC) (GLuint program, GLint location, GLdouble x, GLdouble y); typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3DEXTPROC) (GLuint program, GLint location, GLdouble x, GLdouble y, GLdouble z); typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4DEXTPROC) (GLuint program, GLint location, GLdouble x, GLdouble y, GLdouble z, GLdouble w); typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1DVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2DVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3DVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4DVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X3DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X4DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X2DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X4DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X2DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X3DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); typedef void (APIENTRYP PFNGLTEXTUREBUFFERRANGEEXTPROC) (GLuint texture, GLenum target, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size); typedef void (APIENTRYP PFNGLTEXTURESTORAGE1DEXTPROC) (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width); typedef void (APIENTRYP PFNGLTEXTURESTORAGE2DEXTPROC) (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); typedef void (APIENTRYP PFNGLTEXTURESTORAGE3DEXTPROC) (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); typedef void (APIENTRYP PFNGLTEXTURESTORAGE2DMULTISAMPLEEXTPROC) (GLuint texture, GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); typedef void (APIENTRYP PFNGLTEXTURESTORAGE3DMULTISAMPLEEXTPROC) (GLuint texture, GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); typedef void (APIENTRYP PFNGLVERTEXARRAYBINDVERTEXBUFFEREXTPROC) (GLuint vaobj, GLuint bindingindex, GLuint buffer, GLintptr offset, GLsizei stride); typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBFORMATEXTPROC) (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLboolean normalized, GLuint relativeoffset); typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBIFORMATEXTPROC) (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBLFORMATEXTPROC) (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBBINDINGEXTPROC) (GLuint vaobj, GLuint attribindex, GLuint bindingindex); typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXBINDINGDIVISOREXTPROC) (GLuint vaobj, GLuint bindingindex, GLuint divisor); typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBLOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLuint index, GLint size, GLenum type, GLsizei stride, GLintptr offset); typedef void (APIENTRYP PFNGLTEXTUREPAGECOMMITMENTEXTPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLboolean commit); typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBDIVISOREXTPROC) (GLuint vaobj, GLuint index, GLuint divisor); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glMatrixLoadfEXT (GLenum mode, const GLfloat *m); GLAPI void APIENTRY glMatrixLoaddEXT (GLenum mode, const GLdouble *m); GLAPI void APIENTRY glMatrixMultfEXT (GLenum mode, const GLfloat *m); GLAPI void APIENTRY glMatrixMultdEXT (GLenum mode, const GLdouble *m); GLAPI void APIENTRY glMatrixLoadIdentityEXT (GLenum mode); GLAPI void APIENTRY glMatrixRotatefEXT (GLenum mode, GLfloat angle, GLfloat x, GLfloat y, GLfloat z); GLAPI void APIENTRY glMatrixRotatedEXT (GLenum mode, GLdouble angle, GLdouble x, GLdouble y, GLdouble z); GLAPI void APIENTRY glMatrixScalefEXT (GLenum mode, GLfloat x, GLfloat y, GLfloat z); GLAPI void APIENTRY glMatrixScaledEXT (GLenum mode, GLdouble x, GLdouble y, GLdouble z); GLAPI void APIENTRY glMatrixTranslatefEXT (GLenum mode, GLfloat x, GLfloat y, GLfloat z); GLAPI void APIENTRY glMatrixTranslatedEXT (GLenum mode, GLdouble x, GLdouble y, GLdouble z); GLAPI void APIENTRY glMatrixFrustumEXT (GLenum mode, GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); GLAPI void APIENTRY glMatrixOrthoEXT (GLenum mode, GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); GLAPI void APIENTRY glMatrixPopEXT (GLenum mode); GLAPI void APIENTRY glMatrixPushEXT (GLenum mode); GLAPI void APIENTRY glClientAttribDefaultEXT (GLbitfield mask); GLAPI void APIENTRY glPushClientAttribDefaultEXT (GLbitfield mask); GLAPI void APIENTRY glTextureParameterfEXT (GLuint texture, GLenum target, GLenum pname, GLfloat param); GLAPI void APIENTRY glTextureParameterfvEXT (GLuint texture, GLenum target, GLenum pname, const GLfloat *params); GLAPI void APIENTRY glTextureParameteriEXT (GLuint texture, GLenum target, GLenum pname, GLint param); GLAPI void APIENTRY glTextureParameterivEXT (GLuint texture, GLenum target, GLenum pname, const GLint *params); GLAPI void APIENTRY glTextureImage1DEXT (GLuint texture, GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const void *pixels); GLAPI void APIENTRY glTextureImage2DEXT (GLuint texture, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void *pixels); GLAPI void APIENTRY glTextureSubImage1DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const void *pixels); GLAPI void APIENTRY glTextureSubImage2DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels); GLAPI void APIENTRY glCopyTextureImage1DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); GLAPI void APIENTRY glCopyTextureImage2DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); GLAPI void APIENTRY glCopyTextureSubImage1DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); GLAPI void APIENTRY glCopyTextureSubImage2DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); GLAPI void APIENTRY glGetTextureImageEXT (GLuint texture, GLenum target, GLint level, GLenum format, GLenum type, void *pixels); GLAPI void APIENTRY glGetTextureParameterfvEXT (GLuint texture, GLenum target, GLenum pname, GLfloat *params); GLAPI void APIENTRY glGetTextureParameterivEXT (GLuint texture, GLenum target, GLenum pname, GLint *params); GLAPI void APIENTRY glGetTextureLevelParameterfvEXT (GLuint texture, GLenum target, GLint level, GLenum pname, GLfloat *params); GLAPI void APIENTRY glGetTextureLevelParameterivEXT (GLuint texture, GLenum target, GLint level, GLenum pname, GLint *params); GLAPI void APIENTRY glTextureImage3DEXT (GLuint texture, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void *pixels); GLAPI void APIENTRY glTextureSubImage3DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels); GLAPI void APIENTRY glCopyTextureSubImage3DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); GLAPI void APIENTRY glBindMultiTextureEXT (GLenum texunit, GLenum target, GLuint texture); GLAPI void APIENTRY glMultiTexCoordPointerEXT (GLenum texunit, GLint size, GLenum type, GLsizei stride, const void *pointer); GLAPI void APIENTRY glMultiTexEnvfEXT (GLenum texunit, GLenum target, GLenum pname, GLfloat param); GLAPI void APIENTRY glMultiTexEnvfvEXT (GLenum texunit, GLenum target, GLenum pname, const GLfloat *params); GLAPI void APIENTRY glMultiTexEnviEXT (GLenum texunit, GLenum target, GLenum pname, GLint param); GLAPI void APIENTRY glMultiTexEnvivEXT (GLenum texunit, GLenum target, GLenum pname, const GLint *params); GLAPI void APIENTRY glMultiTexGendEXT (GLenum texunit, GLenum coord, GLenum pname, GLdouble param); GLAPI void APIENTRY glMultiTexGendvEXT (GLenum texunit, GLenum coord, GLenum pname, const GLdouble *params); GLAPI void APIENTRY glMultiTexGenfEXT (GLenum texunit, GLenum coord, GLenum pname, GLfloat param); GLAPI void APIENTRY glMultiTexGenfvEXT (GLenum texunit, GLenum coord, GLenum pname, const GLfloat *params); GLAPI void APIENTRY glMultiTexGeniEXT (GLenum texunit, GLenum coord, GLenum pname, GLint param); GLAPI void APIENTRY glMultiTexGenivEXT (GLenum texunit, GLenum coord, GLenum pname, const GLint *params); GLAPI void APIENTRY glGetMultiTexEnvfvEXT (GLenum texunit, GLenum target, GLenum pname, GLfloat *params); GLAPI void APIENTRY glGetMultiTexEnvivEXT (GLenum texunit, GLenum target, GLenum pname, GLint *params); GLAPI void APIENTRY glGetMultiTexGendvEXT (GLenum texunit, GLenum coord, GLenum pname, GLdouble *params); GLAPI void APIENTRY glGetMultiTexGenfvEXT (GLenum texunit, GLenum coord, GLenum pname, GLfloat *params); GLAPI void APIENTRY glGetMultiTexGenivEXT (GLenum texunit, GLenum coord, GLenum pname, GLint *params); GLAPI void APIENTRY glMultiTexParameteriEXT (GLenum texunit, GLenum target, GLenum pname, GLint param); GLAPI void APIENTRY glMultiTexParameterivEXT (GLenum texunit, GLenum target, GLenum pname, const GLint *params); GLAPI void APIENTRY glMultiTexParameterfEXT (GLenum texunit, GLenum target, GLenum pname, GLfloat param); GLAPI void APIENTRY glMultiTexParameterfvEXT (GLenum texunit, GLenum target, GLenum pname, const GLfloat *params); GLAPI void APIENTRY glMultiTexImage1DEXT (GLenum texunit, GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const void *pixels); GLAPI void APIENTRY glMultiTexImage2DEXT (GLenum texunit, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void *pixels); GLAPI void APIENTRY glMultiTexSubImage1DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const void *pixels); GLAPI void APIENTRY glMultiTexSubImage2DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels); GLAPI void APIENTRY glCopyMultiTexImage1DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); GLAPI void APIENTRY glCopyMultiTexImage2DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); GLAPI void APIENTRY glCopyMultiTexSubImage1DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); GLAPI void APIENTRY glCopyMultiTexSubImage2DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); GLAPI void APIENTRY glGetMultiTexImageEXT (GLenum texunit, GLenum target, GLint level, GLenum format, GLenum type, void *pixels); GLAPI void APIENTRY glGetMultiTexParameterfvEXT (GLenum texunit, GLenum target, GLenum pname, GLfloat *params); GLAPI void APIENTRY glGetMultiTexParameterivEXT (GLenum texunit, GLenum target, GLenum pname, GLint *params); GLAPI void APIENTRY glGetMultiTexLevelParameterfvEXT (GLenum texunit, GLenum target, GLint level, GLenum pname, GLfloat *params); GLAPI void APIENTRY glGetMultiTexLevelParameterivEXT (GLenum texunit, GLenum target, GLint level, GLenum pname, GLint *params); GLAPI void APIENTRY glMultiTexImage3DEXT (GLenum texunit, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void *pixels); GLAPI void APIENTRY glMultiTexSubImage3DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels); GLAPI void APIENTRY glCopyMultiTexSubImage3DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); GLAPI void APIENTRY glEnableClientStateIndexedEXT (GLenum array, GLuint index); GLAPI void APIENTRY glDisableClientStateIndexedEXT (GLenum array, GLuint index); GLAPI void APIENTRY glGetFloatIndexedvEXT (GLenum target, GLuint index, GLfloat *data); GLAPI void APIENTRY glGetDoubleIndexedvEXT (GLenum target, GLuint index, GLdouble *data); GLAPI void APIENTRY glGetPointerIndexedvEXT (GLenum target, GLuint index, void **data); GLAPI void APIENTRY glEnableIndexedEXT (GLenum target, GLuint index); GLAPI void APIENTRY glDisableIndexedEXT (GLenum target, GLuint index); GLAPI GLboolean APIENTRY glIsEnabledIndexedEXT (GLenum target, GLuint index); GLAPI void APIENTRY glGetIntegerIndexedvEXT (GLenum target, GLuint index, GLint *data); GLAPI void APIENTRY glGetBooleanIndexedvEXT (GLenum target, GLuint index, GLboolean *data); GLAPI void APIENTRY glCompressedTextureImage3DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void *bits); GLAPI void APIENTRY glCompressedTextureImage2DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void *bits); GLAPI void APIENTRY glCompressedTextureImage1DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const void *bits); GLAPI void APIENTRY glCompressedTextureSubImage3DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *bits); GLAPI void APIENTRY glCompressedTextureSubImage2DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *bits); GLAPI void APIENTRY glCompressedTextureSubImage1DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void *bits); GLAPI void APIENTRY glGetCompressedTextureImageEXT (GLuint texture, GLenum target, GLint lod, void *img); GLAPI void APIENTRY glCompressedMultiTexImage3DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void *bits); GLAPI void APIENTRY glCompressedMultiTexImage2DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void *bits); GLAPI void APIENTRY glCompressedMultiTexImage1DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const void *bits); GLAPI void APIENTRY glCompressedMultiTexSubImage3DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *bits); GLAPI void APIENTRY glCompressedMultiTexSubImage2DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *bits); GLAPI void APIENTRY glCompressedMultiTexSubImage1DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void *bits); GLAPI void APIENTRY glGetCompressedMultiTexImageEXT (GLenum texunit, GLenum target, GLint lod, void *img); GLAPI void APIENTRY glMatrixLoadTransposefEXT (GLenum mode, const GLfloat *m); GLAPI void APIENTRY glMatrixLoadTransposedEXT (GLenum mode, const GLdouble *m); GLAPI void APIENTRY glMatrixMultTransposefEXT (GLenum mode, const GLfloat *m); GLAPI void APIENTRY glMatrixMultTransposedEXT (GLenum mode, const GLdouble *m); GLAPI void APIENTRY glNamedBufferDataEXT (GLuint buffer, GLsizeiptr size, const void *data, GLenum usage); GLAPI void APIENTRY glNamedBufferSubDataEXT (GLuint buffer, GLintptr offset, GLsizeiptr size, const void *data); GLAPI void *APIENTRY glMapNamedBufferEXT (GLuint buffer, GLenum access); GLAPI GLboolean APIENTRY glUnmapNamedBufferEXT (GLuint buffer); GLAPI void APIENTRY glGetNamedBufferParameterivEXT (GLuint buffer, GLenum pname, GLint *params); GLAPI void APIENTRY glGetNamedBufferPointervEXT (GLuint buffer, GLenum pname, void **params); GLAPI void APIENTRY glGetNamedBufferSubDataEXT (GLuint buffer, GLintptr offset, GLsizeiptr size, void *data); GLAPI void APIENTRY glProgramUniform1fEXT (GLuint program, GLint location, GLfloat v0); GLAPI void APIENTRY glProgramUniform2fEXT (GLuint program, GLint location, GLfloat v0, GLfloat v1); GLAPI void APIENTRY glProgramUniform3fEXT (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2); GLAPI void APIENTRY glProgramUniform4fEXT (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); GLAPI void APIENTRY glProgramUniform1iEXT (GLuint program, GLint location, GLint v0); GLAPI void APIENTRY glProgramUniform2iEXT (GLuint program, GLint location, GLint v0, GLint v1); GLAPI void APIENTRY glProgramUniform3iEXT (GLuint program, GLint location, GLint v0, GLint v1, GLint v2); GLAPI void APIENTRY glProgramUniform4iEXT (GLuint program, GLint location, GLint v0, GLint v1, GLint v2, GLint v3); GLAPI void APIENTRY glProgramUniform1fvEXT (GLuint program, GLint location, GLsizei count, const GLfloat *value); GLAPI void APIENTRY glProgramUniform2fvEXT (GLuint program, GLint location, GLsizei count, const GLfloat *value); GLAPI void APIENTRY glProgramUniform3fvEXT (GLuint program, GLint location, GLsizei count, const GLfloat *value); GLAPI void APIENTRY glProgramUniform4fvEXT (GLuint program, GLint location, GLsizei count, const GLfloat *value); GLAPI void APIENTRY glProgramUniform1ivEXT (GLuint program, GLint location, GLsizei count, const GLint *value); GLAPI void APIENTRY glProgramUniform2ivEXT (GLuint program, GLint location, GLsizei count, const GLint *value); GLAPI void APIENTRY glProgramUniform3ivEXT (GLuint program, GLint location, GLsizei count, const GLint *value); GLAPI void APIENTRY glProgramUniform4ivEXT (GLuint program, GLint location, GLsizei count, const GLint *value); GLAPI void APIENTRY glProgramUniformMatrix2fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); GLAPI void APIENTRY glProgramUniformMatrix3fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); GLAPI void APIENTRY glProgramUniformMatrix4fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); GLAPI void APIENTRY glProgramUniformMatrix2x3fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); GLAPI void APIENTRY glProgramUniformMatrix3x2fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); GLAPI void APIENTRY glProgramUniformMatrix2x4fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); GLAPI void APIENTRY glProgramUniformMatrix4x2fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); GLAPI void APIENTRY glProgramUniformMatrix3x4fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); GLAPI void APIENTRY glProgramUniformMatrix4x3fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); GLAPI void APIENTRY glTextureBufferEXT (GLuint texture, GLenum target, GLenum internalformat, GLuint buffer); GLAPI void APIENTRY glMultiTexBufferEXT (GLenum texunit, GLenum target, GLenum internalformat, GLuint buffer); GLAPI void APIENTRY glTextureParameterIivEXT (GLuint texture, GLenum target, GLenum pname, const GLint *params); GLAPI void APIENTRY glTextureParameterIuivEXT (GLuint texture, GLenum target, GLenum pname, const GLuint *params); GLAPI void APIENTRY glGetTextureParameterIivEXT (GLuint texture, GLenum target, GLenum pname, GLint *params); GLAPI void APIENTRY glGetTextureParameterIuivEXT (GLuint texture, GLenum target, GLenum pname, GLuint *params); GLAPI void APIENTRY glMultiTexParameterIivEXT (GLenum texunit, GLenum target, GLenum pname, const GLint *params); GLAPI void APIENTRY glMultiTexParameterIuivEXT (GLenum texunit, GLenum target, GLenum pname, const GLuint *params); GLAPI void APIENTRY glGetMultiTexParameterIivEXT (GLenum texunit, GLenum target, GLenum pname, GLint *params); GLAPI void APIENTRY glGetMultiTexParameterIuivEXT (GLenum texunit, GLenum target, GLenum pname, GLuint *params); GLAPI void APIENTRY glProgramUniform1uiEXT (GLuint program, GLint location, GLuint v0); GLAPI void APIENTRY glProgramUniform2uiEXT (GLuint program, GLint location, GLuint v0, GLuint v1); GLAPI void APIENTRY glProgramUniform3uiEXT (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2); GLAPI void APIENTRY glProgramUniform4uiEXT (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); GLAPI void APIENTRY glProgramUniform1uivEXT (GLuint program, GLint location, GLsizei count, const GLuint *value); GLAPI void APIENTRY glProgramUniform2uivEXT (GLuint program, GLint location, GLsizei count, const GLuint *value); GLAPI void APIENTRY glProgramUniform3uivEXT (GLuint program, GLint location, GLsizei count, const GLuint *value); GLAPI void APIENTRY glProgramUniform4uivEXT (GLuint program, GLint location, GLsizei count, const GLuint *value); GLAPI void APIENTRY glNamedProgramLocalParameters4fvEXT (GLuint program, GLenum target, GLuint index, GLsizei count, const GLfloat *params); GLAPI void APIENTRY glNamedProgramLocalParameterI4iEXT (GLuint program, GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w); GLAPI void APIENTRY glNamedProgramLocalParameterI4ivEXT (GLuint program, GLenum target, GLuint index, const GLint *params); GLAPI void APIENTRY glNamedProgramLocalParametersI4ivEXT (GLuint program, GLenum target, GLuint index, GLsizei count, const GLint *params); GLAPI void APIENTRY glNamedProgramLocalParameterI4uiEXT (GLuint program, GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); GLAPI void APIENTRY glNamedProgramLocalParameterI4uivEXT (GLuint program, GLenum target, GLuint index, const GLuint *params); GLAPI void APIENTRY glNamedProgramLocalParametersI4uivEXT (GLuint program, GLenum target, GLuint index, GLsizei count, const GLuint *params); GLAPI void APIENTRY glGetNamedProgramLocalParameterIivEXT (GLuint program, GLenum target, GLuint index, GLint *params); GLAPI void APIENTRY glGetNamedProgramLocalParameterIuivEXT (GLuint program, GLenum target, GLuint index, GLuint *params); GLAPI void APIENTRY glEnableClientStateiEXT (GLenum array, GLuint index); GLAPI void APIENTRY glDisableClientStateiEXT (GLenum array, GLuint index); GLAPI void APIENTRY glGetFloati_vEXT (GLenum pname, GLuint index, GLfloat *params); GLAPI void APIENTRY glGetDoublei_vEXT (GLenum pname, GLuint index, GLdouble *params); GLAPI void APIENTRY glGetPointeri_vEXT (GLenum pname, GLuint index, void **params); GLAPI void APIENTRY glNamedProgramStringEXT (GLuint program, GLenum target, GLenum format, GLsizei len, const void *string); GLAPI void APIENTRY glNamedProgramLocalParameter4dEXT (GLuint program, GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); GLAPI void APIENTRY glNamedProgramLocalParameter4dvEXT (GLuint program, GLenum target, GLuint index, const GLdouble *params); GLAPI void APIENTRY glNamedProgramLocalParameter4fEXT (GLuint program, GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); GLAPI void APIENTRY glNamedProgramLocalParameter4fvEXT (GLuint program, GLenum target, GLuint index, const GLfloat *params); GLAPI void APIENTRY glGetNamedProgramLocalParameterdvEXT (GLuint program, GLenum target, GLuint index, GLdouble *params); GLAPI void APIENTRY glGetNamedProgramLocalParameterfvEXT (GLuint program, GLenum target, GLuint index, GLfloat *params); GLAPI void APIENTRY glGetNamedProgramivEXT (GLuint program, GLenum target, GLenum pname, GLint *params); GLAPI void APIENTRY glGetNamedProgramStringEXT (GLuint program, GLenum target, GLenum pname, void *string); GLAPI void APIENTRY glNamedRenderbufferStorageEXT (GLuint renderbuffer, GLenum internalformat, GLsizei width, GLsizei height); GLAPI void APIENTRY glGetNamedRenderbufferParameterivEXT (GLuint renderbuffer, GLenum pname, GLint *params); GLAPI void APIENTRY glNamedRenderbufferStorageMultisampleEXT (GLuint renderbuffer, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); GLAPI void APIENTRY glNamedRenderbufferStorageMultisampleCoverageEXT (GLuint renderbuffer, GLsizei coverageSamples, GLsizei colorSamples, GLenum internalformat, GLsizei width, GLsizei height); GLAPI GLenum APIENTRY glCheckNamedFramebufferStatusEXT (GLuint framebuffer, GLenum target); GLAPI void APIENTRY glNamedFramebufferTexture1DEXT (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level); GLAPI void APIENTRY glNamedFramebufferTexture2DEXT (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level); GLAPI void APIENTRY glNamedFramebufferTexture3DEXT (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); GLAPI void APIENTRY glNamedFramebufferRenderbufferEXT (GLuint framebuffer, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); GLAPI void APIENTRY glGetNamedFramebufferAttachmentParameterivEXT (GLuint framebuffer, GLenum attachment, GLenum pname, GLint *params); GLAPI void APIENTRY glGenerateTextureMipmapEXT (GLuint texture, GLenum target); GLAPI void APIENTRY glGenerateMultiTexMipmapEXT (GLenum texunit, GLenum target); GLAPI void APIENTRY glFramebufferDrawBufferEXT (GLuint framebuffer, GLenum mode); GLAPI void APIENTRY glFramebufferDrawBuffersEXT (GLuint framebuffer, GLsizei n, const GLenum *bufs); GLAPI void APIENTRY glFramebufferReadBufferEXT (GLuint framebuffer, GLenum mode); GLAPI void APIENTRY glGetFramebufferParameterivEXT (GLuint framebuffer, GLenum pname, GLint *params); GLAPI void APIENTRY glNamedCopyBufferSubDataEXT (GLuint readBuffer, GLuint writeBuffer, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); GLAPI void APIENTRY glNamedFramebufferTextureEXT (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level); GLAPI void APIENTRY glNamedFramebufferTextureLayerEXT (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level, GLint layer); GLAPI void APIENTRY glNamedFramebufferTextureFaceEXT (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level, GLenum face); GLAPI void APIENTRY glTextureRenderbufferEXT (GLuint texture, GLenum target, GLuint renderbuffer); GLAPI void APIENTRY glMultiTexRenderbufferEXT (GLenum texunit, GLenum target, GLuint renderbuffer); GLAPI void APIENTRY glVertexArrayVertexOffsetEXT (GLuint vaobj, GLuint buffer, GLint size, GLenum type, GLsizei stride, GLintptr offset); GLAPI void APIENTRY glVertexArrayColorOffsetEXT (GLuint vaobj, GLuint buffer, GLint size, GLenum type, GLsizei stride, GLintptr offset); GLAPI void APIENTRY glVertexArrayEdgeFlagOffsetEXT (GLuint vaobj, GLuint buffer, GLsizei stride, GLintptr offset); GLAPI void APIENTRY glVertexArrayIndexOffsetEXT (GLuint vaobj, GLuint buffer, GLenum type, GLsizei stride, GLintptr offset); GLAPI void APIENTRY glVertexArrayNormalOffsetEXT (GLuint vaobj, GLuint buffer, GLenum type, GLsizei stride, GLintptr offset); GLAPI void APIENTRY glVertexArrayTexCoordOffsetEXT (GLuint vaobj, GLuint buffer, GLint size, GLenum type, GLsizei stride, GLintptr offset); GLAPI void APIENTRY glVertexArrayMultiTexCoordOffsetEXT (GLuint vaobj, GLuint buffer, GLenum texunit, GLint size, GLenum type, GLsizei stride, GLintptr offset); GLAPI void APIENTRY glVertexArrayFogCoordOffsetEXT (GLuint vaobj, GLuint buffer, GLenum type, GLsizei stride, GLintptr offset); GLAPI void APIENTRY glVertexArraySecondaryColorOffsetEXT (GLuint vaobj, GLuint buffer, GLint size, GLenum type, GLsizei stride, GLintptr offset); GLAPI void APIENTRY glVertexArrayVertexAttribOffsetEXT (GLuint vaobj, GLuint buffer, GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, GLintptr offset); GLAPI void APIENTRY glVertexArrayVertexAttribIOffsetEXT (GLuint vaobj, GLuint buffer, GLuint index, GLint size, GLenum type, GLsizei stride, GLintptr offset); GLAPI void APIENTRY glEnableVertexArrayEXT (GLuint vaobj, GLenum array); GLAPI void APIENTRY glDisableVertexArrayEXT (GLuint vaobj, GLenum array); GLAPI void APIENTRY glEnableVertexArrayAttribEXT (GLuint vaobj, GLuint index); GLAPI void APIENTRY glDisableVertexArrayAttribEXT (GLuint vaobj, GLuint index); GLAPI void APIENTRY glGetVertexArrayIntegervEXT (GLuint vaobj, GLenum pname, GLint *param); GLAPI void APIENTRY glGetVertexArrayPointervEXT (GLuint vaobj, GLenum pname, void **param); GLAPI void APIENTRY glGetVertexArrayIntegeri_vEXT (GLuint vaobj, GLuint index, GLenum pname, GLint *param); GLAPI void APIENTRY glGetVertexArrayPointeri_vEXT (GLuint vaobj, GLuint index, GLenum pname, void **param); GLAPI void *APIENTRY glMapNamedBufferRangeEXT (GLuint buffer, GLintptr offset, GLsizeiptr length, GLbitfield access); GLAPI void APIENTRY glFlushMappedNamedBufferRangeEXT (GLuint buffer, GLintptr offset, GLsizeiptr length); GLAPI void APIENTRY glNamedBufferStorageEXT (GLuint buffer, GLsizeiptr size, const void *data, GLbitfield flags); GLAPI void APIENTRY glClearNamedBufferDataEXT (GLuint buffer, GLenum internalformat, GLenum format, GLenum type, const void *data); GLAPI void APIENTRY glClearNamedBufferSubDataEXT (GLuint buffer, GLenum internalformat, GLsizeiptr offset, GLsizeiptr size, GLenum format, GLenum type, const void *data); GLAPI void APIENTRY glNamedFramebufferParameteriEXT (GLuint framebuffer, GLenum pname, GLint param); GLAPI void APIENTRY glGetNamedFramebufferParameterivEXT (GLuint framebuffer, GLenum pname, GLint *params); GLAPI void APIENTRY glProgramUniform1dEXT (GLuint program, GLint location, GLdouble x); GLAPI void APIENTRY glProgramUniform2dEXT (GLuint program, GLint location, GLdouble x, GLdouble y); GLAPI void APIENTRY glProgramUniform3dEXT (GLuint program, GLint location, GLdouble x, GLdouble y, GLdouble z); GLAPI void APIENTRY glProgramUniform4dEXT (GLuint program, GLint location, GLdouble x, GLdouble y, GLdouble z, GLdouble w); GLAPI void APIENTRY glProgramUniform1dvEXT (GLuint program, GLint location, GLsizei count, const GLdouble *value); GLAPI void APIENTRY glProgramUniform2dvEXT (GLuint program, GLint location, GLsizei count, const GLdouble *value); GLAPI void APIENTRY glProgramUniform3dvEXT (GLuint program, GLint location, GLsizei count, const GLdouble *value); GLAPI void APIENTRY glProgramUniform4dvEXT (GLuint program, GLint location, GLsizei count, const GLdouble *value); GLAPI void APIENTRY glProgramUniformMatrix2dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); GLAPI void APIENTRY glProgramUniformMatrix3dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); GLAPI void APIENTRY glProgramUniformMatrix4dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); GLAPI void APIENTRY glProgramUniformMatrix2x3dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); GLAPI void APIENTRY glProgramUniformMatrix2x4dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); GLAPI void APIENTRY glProgramUniformMatrix3x2dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); GLAPI void APIENTRY glProgramUniformMatrix3x4dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); GLAPI void APIENTRY glProgramUniformMatrix4x2dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); GLAPI void APIENTRY glProgramUniformMatrix4x3dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); GLAPI void APIENTRY glTextureBufferRangeEXT (GLuint texture, GLenum target, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size); GLAPI void APIENTRY glTextureStorage1DEXT (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width); GLAPI void APIENTRY glTextureStorage2DEXT (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); GLAPI void APIENTRY glTextureStorage3DEXT (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); GLAPI void APIENTRY glTextureStorage2DMultisampleEXT (GLuint texture, GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); GLAPI void APIENTRY glTextureStorage3DMultisampleEXT (GLuint texture, GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); GLAPI void APIENTRY glVertexArrayBindVertexBufferEXT (GLuint vaobj, GLuint bindingindex, GLuint buffer, GLintptr offset, GLsizei stride); GLAPI void APIENTRY glVertexArrayVertexAttribFormatEXT (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLboolean normalized, GLuint relativeoffset); GLAPI void APIENTRY glVertexArrayVertexAttribIFormatEXT (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); GLAPI void APIENTRY glVertexArrayVertexAttribLFormatEXT (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); GLAPI void APIENTRY glVertexArrayVertexAttribBindingEXT (GLuint vaobj, GLuint attribindex, GLuint bindingindex); GLAPI void APIENTRY glVertexArrayVertexBindingDivisorEXT (GLuint vaobj, GLuint bindingindex, GLuint divisor); GLAPI void APIENTRY glVertexArrayVertexAttribLOffsetEXT (GLuint vaobj, GLuint buffer, GLuint index, GLint size, GLenum type, GLsizei stride, GLintptr offset); GLAPI void APIENTRY glTexturePageCommitmentEXT (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLboolean commit); GLAPI void APIENTRY glVertexArrayVertexAttribDivisorEXT (GLuint vaobj, GLuint index, GLuint divisor); #endif #endif /* GL_EXT_direct_state_access */ #ifndef GL_EXT_draw_buffers2 #define GL_EXT_draw_buffers2 1 typedef void (APIENTRYP PFNGLCOLORMASKINDEXEDEXTPROC) (GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glColorMaskIndexedEXT (GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a); #endif #endif /* GL_EXT_draw_buffers2 */ #ifndef GL_EXT_draw_instanced #define GL_EXT_draw_instanced 1 typedef void (APIENTRYP PFNGLDRAWARRAYSINSTANCEDEXTPROC) (GLenum mode, GLint start, GLsizei count, GLsizei primcount); typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDEXTPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glDrawArraysInstancedEXT (GLenum mode, GLint start, GLsizei count, GLsizei primcount); GLAPI void APIENTRY glDrawElementsInstancedEXT (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount); #endif #endif /* GL_EXT_draw_instanced */ #ifndef GL_EXT_draw_range_elements #define GL_EXT_draw_range_elements 1 #define GL_MAX_ELEMENTS_VERTICES_EXT 0x80E8 #define GL_MAX_ELEMENTS_INDICES_EXT 0x80E9 typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTSEXTPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void *indices); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glDrawRangeElementsEXT (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void *indices); #endif #endif /* GL_EXT_draw_range_elements */ #ifndef GL_EXT_external_buffer #define GL_EXT_external_buffer 1 typedef void *GLeglClientBufferEXT; typedef void (APIENTRYP PFNGLBUFFERSTORAGEEXTERNALEXTPROC) (GLenum target, GLintptr offset, GLsizeiptr size, GLeglClientBufferEXT clientBuffer, GLbitfield flags); typedef void (APIENTRYP PFNGLNAMEDBUFFERSTORAGEEXTERNALEXTPROC) (GLuint buffer, GLintptr offset, GLsizeiptr size, GLeglClientBufferEXT clientBuffer, GLbitfield flags); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glBufferStorageExternalEXT (GLenum target, GLintptr offset, GLsizeiptr size, GLeglClientBufferEXT clientBuffer, GLbitfield flags); GLAPI void APIENTRY glNamedBufferStorageExternalEXT (GLuint buffer, GLintptr offset, GLsizeiptr size, GLeglClientBufferEXT clientBuffer, GLbitfield flags); #endif #endif /* GL_EXT_external_buffer */ #ifndef GL_EXT_fog_coord #define GL_EXT_fog_coord 1 #define GL_FOG_COORDINATE_SOURCE_EXT 0x8450 #define GL_FOG_COORDINATE_EXT 0x8451 #define GL_FRAGMENT_DEPTH_EXT 0x8452 #define GL_CURRENT_FOG_COORDINATE_EXT 0x8453 #define GL_FOG_COORDINATE_ARRAY_TYPE_EXT 0x8454 #define GL_FOG_COORDINATE_ARRAY_STRIDE_EXT 0x8455 #define GL_FOG_COORDINATE_ARRAY_POINTER_EXT 0x8456 #define GL_FOG_COORDINATE_ARRAY_EXT 0x8457 typedef void (APIENTRYP PFNGLFOGCOORDFEXTPROC) (GLfloat coord); typedef void (APIENTRYP PFNGLFOGCOORDFVEXTPROC) (const GLfloat *coord); typedef void (APIENTRYP PFNGLFOGCOORDDEXTPROC) (GLdouble coord); typedef void (APIENTRYP PFNGLFOGCOORDDVEXTPROC) (const GLdouble *coord); typedef void (APIENTRYP PFNGLFOGCOORDPOINTEREXTPROC) (GLenum type, GLsizei stride, const void *pointer); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glFogCoordfEXT (GLfloat coord); GLAPI void APIENTRY glFogCoordfvEXT (const GLfloat *coord); GLAPI void APIENTRY glFogCoorddEXT (GLdouble coord); GLAPI void APIENTRY glFogCoorddvEXT (const GLdouble *coord); GLAPI void APIENTRY glFogCoordPointerEXT (GLenum type, GLsizei stride, const void *pointer); #endif #endif /* GL_EXT_fog_coord */ #ifndef GL_EXT_framebuffer_blit #define GL_EXT_framebuffer_blit 1 #define GL_READ_FRAMEBUFFER_EXT 0x8CA8 #define GL_DRAW_FRAMEBUFFER_EXT 0x8CA9 #define GL_DRAW_FRAMEBUFFER_BINDING_EXT 0x8CA6 #define GL_READ_FRAMEBUFFER_BINDING_EXT 0x8CAA typedef void (APIENTRYP PFNGLBLITFRAMEBUFFEREXTPROC) (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glBlitFramebufferEXT (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); #endif #endif /* GL_EXT_framebuffer_blit */ #ifndef GL_EXT_framebuffer_multisample #define GL_EXT_framebuffer_multisample 1 #define GL_RENDERBUFFER_SAMPLES_EXT 0x8CAB #define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_EXT 0x8D56 #define GL_MAX_SAMPLES_EXT 0x8D57 typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glRenderbufferStorageMultisampleEXT (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); #endif #endif /* GL_EXT_framebuffer_multisample */ #ifndef GL_EXT_framebuffer_multisample_blit_scaled #define GL_EXT_framebuffer_multisample_blit_scaled 1 #define GL_SCALED_RESOLVE_FASTEST_EXT 0x90BA #define GL_SCALED_RESOLVE_NICEST_EXT 0x90BB #endif /* GL_EXT_framebuffer_multisample_blit_scaled */ #ifndef GL_EXT_framebuffer_object #define GL_EXT_framebuffer_object 1 #define GL_INVALID_FRAMEBUFFER_OPERATION_EXT 0x0506 #define GL_MAX_RENDERBUFFER_SIZE_EXT 0x84E8 #define GL_FRAMEBUFFER_BINDING_EXT 0x8CA6 #define GL_RENDERBUFFER_BINDING_EXT 0x8CA7 #define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_EXT 0x8CD0 #define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_EXT 0x8CD1 #define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL_EXT 0x8CD2 #define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE_EXT 0x8CD3 #define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_EXT 0x8CD4 #define GL_FRAMEBUFFER_COMPLETE_EXT 0x8CD5 #define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT 0x8CD6 #define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT 0x8CD7 #define GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT 0x8CD9 #define GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT 0x8CDA #define GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT 0x8CDB #define GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT 0x8CDC #define GL_FRAMEBUFFER_UNSUPPORTED_EXT 0x8CDD #define GL_MAX_COLOR_ATTACHMENTS_EXT 0x8CDF #define GL_COLOR_ATTACHMENT0_EXT 0x8CE0 #define GL_COLOR_ATTACHMENT1_EXT 0x8CE1 #define GL_COLOR_ATTACHMENT2_EXT 0x8CE2 #define GL_COLOR_ATTACHMENT3_EXT 0x8CE3 #define GL_COLOR_ATTACHMENT4_EXT 0x8CE4 #define GL_COLOR_ATTACHMENT5_EXT 0x8CE5 #define GL_COLOR_ATTACHMENT6_EXT 0x8CE6 #define GL_COLOR_ATTACHMENT7_EXT 0x8CE7 #define GL_COLOR_ATTACHMENT8_EXT 0x8CE8 #define GL_COLOR_ATTACHMENT9_EXT 0x8CE9 #define GL_COLOR_ATTACHMENT10_EXT 0x8CEA #define GL_COLOR_ATTACHMENT11_EXT 0x8CEB #define GL_COLOR_ATTACHMENT12_EXT 0x8CEC #define GL_COLOR_ATTACHMENT13_EXT 0x8CED #define GL_COLOR_ATTACHMENT14_EXT 0x8CEE #define GL_COLOR_ATTACHMENT15_EXT 0x8CEF #define GL_DEPTH_ATTACHMENT_EXT 0x8D00 #define GL_STENCIL_ATTACHMENT_EXT 0x8D20 #define GL_FRAMEBUFFER_EXT 0x8D40 #define GL_RENDERBUFFER_EXT 0x8D41 #define GL_RENDERBUFFER_WIDTH_EXT 0x8D42 #define GL_RENDERBUFFER_HEIGHT_EXT 0x8D43 #define GL_RENDERBUFFER_INTERNAL_FORMAT_EXT 0x8D44 #define GL_STENCIL_INDEX1_EXT 0x8D46 #define GL_STENCIL_INDEX4_EXT 0x8D47 #define GL_STENCIL_INDEX8_EXT 0x8D48 #define GL_STENCIL_INDEX16_EXT 0x8D49 #define GL_RENDERBUFFER_RED_SIZE_EXT 0x8D50 #define GL_RENDERBUFFER_GREEN_SIZE_EXT 0x8D51 #define GL_RENDERBUFFER_BLUE_SIZE_EXT 0x8D52 #define GL_RENDERBUFFER_ALPHA_SIZE_EXT 0x8D53 #define GL_RENDERBUFFER_DEPTH_SIZE_EXT 0x8D54 #define GL_RENDERBUFFER_STENCIL_SIZE_EXT 0x8D55 typedef GLboolean (APIENTRYP PFNGLISRENDERBUFFEREXTPROC) (GLuint renderbuffer); typedef void (APIENTRYP PFNGLBINDRENDERBUFFEREXTPROC) (GLenum target, GLuint renderbuffer); typedef void (APIENTRYP PFNGLDELETERENDERBUFFERSEXTPROC) (GLsizei n, const GLuint *renderbuffers); typedef void (APIENTRYP PFNGLGENRENDERBUFFERSEXTPROC) (GLsizei n, GLuint *renderbuffers); typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height); typedef void (APIENTRYP PFNGLGETRENDERBUFFERPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); typedef GLboolean (APIENTRYP PFNGLISFRAMEBUFFEREXTPROC) (GLuint framebuffer); typedef void (APIENTRYP PFNGLBINDFRAMEBUFFEREXTPROC) (GLenum target, GLuint framebuffer); typedef void (APIENTRYP PFNGLDELETEFRAMEBUFFERSEXTPROC) (GLsizei n, const GLuint *framebuffers); typedef void (APIENTRYP PFNGLGENFRAMEBUFFERSEXTPROC) (GLsizei n, GLuint *framebuffers); typedef GLenum (APIENTRYP PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC) (GLenum target); typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE1DEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE3DEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); typedef void (APIENTRYP PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC) (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); typedef void (APIENTRYP PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC) (GLenum target, GLenum attachment, GLenum pname, GLint *params); typedef void (APIENTRYP PFNGLGENERATEMIPMAPEXTPROC) (GLenum target); #ifdef GL_GLEXT_PROTOTYPES GLAPI GLboolean APIENTRY glIsRenderbufferEXT (GLuint renderbuffer); GLAPI void APIENTRY glBindRenderbufferEXT (GLenum target, GLuint renderbuffer); GLAPI void APIENTRY glDeleteRenderbuffersEXT (GLsizei n, const GLuint *renderbuffers); GLAPI void APIENTRY glGenRenderbuffersEXT (GLsizei n, GLuint *renderbuffers); GLAPI void APIENTRY glRenderbufferStorageEXT (GLenum target, GLenum internalformat, GLsizei width, GLsizei height); GLAPI void APIENTRY glGetRenderbufferParameterivEXT (GLenum target, GLenum pname, GLint *params); GLAPI GLboolean APIENTRY glIsFramebufferEXT (GLuint framebuffer); GLAPI void APIENTRY glBindFramebufferEXT (GLenum target, GLuint framebuffer); GLAPI void APIENTRY glDeleteFramebuffersEXT (GLsizei n, const GLuint *framebuffers); GLAPI void APIENTRY glGenFramebuffersEXT (GLsizei n, GLuint *framebuffers); GLAPI GLenum APIENTRY glCheckFramebufferStatusEXT (GLenum target); GLAPI void APIENTRY glFramebufferTexture1DEXT (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); GLAPI void APIENTRY glFramebufferTexture2DEXT (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); GLAPI void APIENTRY glFramebufferTexture3DEXT (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); GLAPI void APIENTRY glFramebufferRenderbufferEXT (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); GLAPI void APIENTRY glGetFramebufferAttachmentParameterivEXT (GLenum target, GLenum attachment, GLenum pname, GLint *params); GLAPI void APIENTRY glGenerateMipmapEXT (GLenum target); #endif #endif /* GL_EXT_framebuffer_object */ #ifndef GL_EXT_framebuffer_sRGB #define GL_EXT_framebuffer_sRGB 1 #define GL_FRAMEBUFFER_SRGB_EXT 0x8DB9 #define GL_FRAMEBUFFER_SRGB_CAPABLE_EXT 0x8DBA #endif /* GL_EXT_framebuffer_sRGB */ #ifndef GL_EXT_geometry_shader4 #define GL_EXT_geometry_shader4 1 #define GL_GEOMETRY_SHADER_EXT 0x8DD9 #define GL_GEOMETRY_VERTICES_OUT_EXT 0x8DDA #define GL_GEOMETRY_INPUT_TYPE_EXT 0x8DDB #define GL_GEOMETRY_OUTPUT_TYPE_EXT 0x8DDC #define GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_EXT 0x8C29 #define GL_MAX_GEOMETRY_VARYING_COMPONENTS_EXT 0x8DDD #define GL_MAX_VERTEX_VARYING_COMPONENTS_EXT 0x8DDE #define GL_MAX_VARYING_COMPONENTS_EXT 0x8B4B #define GL_MAX_GEOMETRY_UNIFORM_COMPONENTS_EXT 0x8DDF #define GL_MAX_GEOMETRY_OUTPUT_VERTICES_EXT 0x8DE0 #define GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS_EXT 0x8DE1 #define GL_LINES_ADJACENCY_EXT 0x000A #define GL_LINE_STRIP_ADJACENCY_EXT 0x000B #define GL_TRIANGLES_ADJACENCY_EXT 0x000C #define GL_TRIANGLE_STRIP_ADJACENCY_EXT 0x000D #define GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS_EXT 0x8DA8 #define GL_FRAMEBUFFER_INCOMPLETE_LAYER_COUNT_EXT 0x8DA9 #define GL_FRAMEBUFFER_ATTACHMENT_LAYERED_EXT 0x8DA7 #define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER_EXT 0x8CD4 #define GL_PROGRAM_POINT_SIZE_EXT 0x8642 typedef void (APIENTRYP PFNGLPROGRAMPARAMETERIEXTPROC) (GLuint program, GLenum pname, GLint value); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glProgramParameteriEXT (GLuint program, GLenum pname, GLint value); #endif #endif /* GL_EXT_geometry_shader4 */ #ifndef GL_EXT_gpu_program_parameters #define GL_EXT_gpu_program_parameters 1 typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERS4FVEXTPROC) (GLenum target, GLuint index, GLsizei count, const GLfloat *params); typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERS4FVEXTPROC) (GLenum target, GLuint index, GLsizei count, const GLfloat *params); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glProgramEnvParameters4fvEXT (GLenum target, GLuint index, GLsizei count, const GLfloat *params); GLAPI void APIENTRY glProgramLocalParameters4fvEXT (GLenum target, GLuint index, GLsizei count, const GLfloat *params); #endif #endif /* GL_EXT_gpu_program_parameters */ #ifndef GL_EXT_gpu_shader4 #define GL_EXT_gpu_shader4 1 #define GL_SAMPLER_1D_ARRAY_EXT 0x8DC0 #define GL_SAMPLER_2D_ARRAY_EXT 0x8DC1 #define GL_SAMPLER_BUFFER_EXT 0x8DC2 #define GL_SAMPLER_1D_ARRAY_SHADOW_EXT 0x8DC3 #define GL_SAMPLER_2D_ARRAY_SHADOW_EXT 0x8DC4 #define GL_SAMPLER_CUBE_SHADOW_EXT 0x8DC5 #define GL_UNSIGNED_INT_VEC2_EXT 0x8DC6 #define GL_UNSIGNED_INT_VEC3_EXT 0x8DC7 #define GL_UNSIGNED_INT_VEC4_EXT 0x8DC8 #define GL_INT_SAMPLER_1D_EXT 0x8DC9 #define GL_INT_SAMPLER_2D_EXT 0x8DCA #define GL_INT_SAMPLER_3D_EXT 0x8DCB #define GL_INT_SAMPLER_CUBE_EXT 0x8DCC #define GL_INT_SAMPLER_2D_RECT_EXT 0x8DCD #define GL_INT_SAMPLER_1D_ARRAY_EXT 0x8DCE #define GL_INT_SAMPLER_2D_ARRAY_EXT 0x8DCF #define GL_INT_SAMPLER_BUFFER_EXT 0x8DD0 #define GL_UNSIGNED_INT_SAMPLER_1D_EXT 0x8DD1 #define GL_UNSIGNED_INT_SAMPLER_2D_EXT 0x8DD2 #define GL_UNSIGNED_INT_SAMPLER_3D_EXT 0x8DD3 #define GL_UNSIGNED_INT_SAMPLER_CUBE_EXT 0x8DD4 #define GL_UNSIGNED_INT_SAMPLER_2D_RECT_EXT 0x8DD5 #define GL_UNSIGNED_INT_SAMPLER_1D_ARRAY_EXT 0x8DD6 #define GL_UNSIGNED_INT_SAMPLER_2D_ARRAY_EXT 0x8DD7 #define GL_UNSIGNED_INT_SAMPLER_BUFFER_EXT 0x8DD8 #define GL_MIN_PROGRAM_TEXEL_OFFSET_EXT 0x8904 #define GL_MAX_PROGRAM_TEXEL_OFFSET_EXT 0x8905 #define GL_VERTEX_ATTRIB_ARRAY_INTEGER_EXT 0x88FD typedef void (APIENTRYP PFNGLGETUNIFORMUIVEXTPROC) (GLuint program, GLint location, GLuint *params); typedef void (APIENTRYP PFNGLBINDFRAGDATALOCATIONEXTPROC) (GLuint program, GLuint color, const GLchar *name); typedef GLint (APIENTRYP PFNGLGETFRAGDATALOCATIONEXTPROC) (GLuint program, const GLchar *name); typedef void (APIENTRYP PFNGLUNIFORM1UIEXTPROC) (GLint location, GLuint v0); typedef void (APIENTRYP PFNGLUNIFORM2UIEXTPROC) (GLint location, GLuint v0, GLuint v1); typedef void (APIENTRYP PFNGLUNIFORM3UIEXTPROC) (GLint location, GLuint v0, GLuint v1, GLuint v2); typedef void (APIENTRYP PFNGLUNIFORM4UIEXTPROC) (GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); typedef void (APIENTRYP PFNGLUNIFORM1UIVEXTPROC) (GLint location, GLsizei count, const GLuint *value); typedef void (APIENTRYP PFNGLUNIFORM2UIVEXTPROC) (GLint location, GLsizei count, const GLuint *value); typedef void (APIENTRYP PFNGLUNIFORM3UIVEXTPROC) (GLint location, GLsizei count, const GLuint *value); typedef void (APIENTRYP PFNGLUNIFORM4UIVEXTPROC) (GLint location, GLsizei count, const GLuint *value); typedef void (APIENTRYP PFNGLVERTEXATTRIBI1IEXTPROC) (GLuint index, GLint x); typedef void (APIENTRYP PFNGLVERTEXATTRIBI2IEXTPROC) (GLuint index, GLint x, GLint y); typedef void (APIENTRYP PFNGLVERTEXATTRIBI3IEXTPROC) (GLuint index, GLint x, GLint y, GLint z); typedef void (APIENTRYP PFNGLVERTEXATTRIBI4IEXTPROC) (GLuint index, GLint x, GLint y, GLint z, GLint w); typedef void (APIENTRYP PFNGLVERTEXATTRIBI1UIEXTPROC) (GLuint index, GLuint x); typedef void (APIENTRYP PFNGLVERTEXATTRIBI2UIEXTPROC) (GLuint index, GLuint x, GLuint y); typedef void (APIENTRYP PFNGLVERTEXATTRIBI3UIEXTPROC) (GLuint index, GLuint x, GLuint y, GLuint z); typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UIEXTPROC) (GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); typedef void (APIENTRYP PFNGLVERTEXATTRIBI1IVEXTPROC) (GLuint index, const GLint *v); typedef void (APIENTRYP PFNGLVERTEXATTRIBI2IVEXTPROC) (GLuint index, const GLint *v); typedef void (APIENTRYP PFNGLVERTEXATTRIBI3IVEXTPROC) (GLuint index, const GLint *v); typedef void (APIENTRYP PFNGLVERTEXATTRIBI4IVEXTPROC) (GLuint index, const GLint *v); typedef void (APIENTRYP PFNGLVERTEXATTRIBI1UIVEXTPROC) (GLuint index, const GLuint *v); typedef void (APIENTRYP PFNGLVERTEXATTRIBI2UIVEXTPROC) (GLuint index, const GLuint *v); typedef void (APIENTRYP PFNGLVERTEXATTRIBI3UIVEXTPROC) (GLuint index, const GLuint *v); typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UIVEXTPROC) (GLuint index, const GLuint *v); typedef void (APIENTRYP PFNGLVERTEXATTRIBI4BVEXTPROC) (GLuint index, const GLbyte *v); typedef void (APIENTRYP PFNGLVERTEXATTRIBI4SVEXTPROC) (GLuint index, const GLshort *v); typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UBVEXTPROC) (GLuint index, const GLubyte *v); typedef void (APIENTRYP PFNGLVERTEXATTRIBI4USVEXTPROC) (GLuint index, const GLushort *v); typedef void (APIENTRYP PFNGLVERTEXATTRIBIPOINTEREXTPROC) (GLuint index, GLint size, GLenum type, GLsizei stride, const void *pointer); typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIIVEXTPROC) (GLuint index, GLenum pname, GLint *params); typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIUIVEXTPROC) (GLuint index, GLenum pname, GLuint *params); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glGetUniformuivEXT (GLuint program, GLint location, GLuint *params); GLAPI void APIENTRY glBindFragDataLocationEXT (GLuint program, GLuint color, const GLchar *name); GLAPI GLint APIENTRY glGetFragDataLocationEXT (GLuint program, const GLchar *name); GLAPI void APIENTRY glUniform1uiEXT (GLint location, GLuint v0); GLAPI void APIENTRY glUniform2uiEXT (GLint location, GLuint v0, GLuint v1); GLAPI void APIENTRY glUniform3uiEXT (GLint location, GLuint v0, GLuint v1, GLuint v2); GLAPI void APIENTRY glUniform4uiEXT (GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); GLAPI void APIENTRY glUniform1uivEXT (GLint location, GLsizei count, const GLuint *value); GLAPI void APIENTRY glUniform2uivEXT (GLint location, GLsizei count, const GLuint *value); GLAPI void APIENTRY glUniform3uivEXT (GLint location, GLsizei count, const GLuint *value); GLAPI void APIENTRY glUniform4uivEXT (GLint location, GLsizei count, const GLuint *value); GLAPI void APIENTRY glVertexAttribI1iEXT (GLuint index, GLint x); GLAPI void APIENTRY glVertexAttribI2iEXT (GLuint index, GLint x, GLint y); GLAPI void APIENTRY glVertexAttribI3iEXT (GLuint index, GLint x, GLint y, GLint z); GLAPI void APIENTRY glVertexAttribI4iEXT (GLuint index, GLint x, GLint y, GLint z, GLint w); GLAPI void APIENTRY glVertexAttribI1uiEXT (GLuint index, GLuint x); GLAPI void APIENTRY glVertexAttribI2uiEXT (GLuint index, GLuint x, GLuint y); GLAPI void APIENTRY glVertexAttribI3uiEXT (GLuint index, GLuint x, GLuint y, GLuint z); GLAPI void APIENTRY glVertexAttribI4uiEXT (GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); GLAPI void APIENTRY glVertexAttribI1ivEXT (GLuint index, const GLint *v); GLAPI void APIENTRY glVertexAttribI2ivEXT (GLuint index, const GLint *v); GLAPI void APIENTRY glVertexAttribI3ivEXT (GLuint index, const GLint *v); GLAPI void APIENTRY glVertexAttribI4ivEXT (GLuint index, const GLint *v); GLAPI void APIENTRY glVertexAttribI1uivEXT (GLuint index, const GLuint *v); GLAPI void APIENTRY glVertexAttribI2uivEXT (GLuint index, const GLuint *v); GLAPI void APIENTRY glVertexAttribI3uivEXT (GLuint index, const GLuint *v); GLAPI void APIENTRY glVertexAttribI4uivEXT (GLuint index, const GLuint *v); GLAPI void APIENTRY glVertexAttribI4bvEXT (GLuint index, const GLbyte *v); GLAPI void APIENTRY glVertexAttribI4svEXT (GLuint index, const GLshort *v); GLAPI void APIENTRY glVertexAttribI4ubvEXT (GLuint index, const GLubyte *v); GLAPI void APIENTRY glVertexAttribI4usvEXT (GLuint index, const GLushort *v); GLAPI void APIENTRY glVertexAttribIPointerEXT (GLuint index, GLint size, GLenum type, GLsizei stride, const void *pointer); GLAPI void APIENTRY glGetVertexAttribIivEXT (GLuint index, GLenum pname, GLint *params); GLAPI void APIENTRY glGetVertexAttribIuivEXT (GLuint index, GLenum pname, GLuint *params); #endif #endif /* GL_EXT_gpu_shader4 */ #ifndef GL_EXT_histogram #define GL_EXT_histogram 1 #define GL_HISTOGRAM_EXT 0x8024 #define GL_PROXY_HISTOGRAM_EXT 0x8025 #define GL_HISTOGRAM_WIDTH_EXT 0x8026 #define GL_HISTOGRAM_FORMAT_EXT 0x8027 #define GL_HISTOGRAM_RED_SIZE_EXT 0x8028 #define GL_HISTOGRAM_GREEN_SIZE_EXT 0x8029 #define GL_HISTOGRAM_BLUE_SIZE_EXT 0x802A #define GL_HISTOGRAM_ALPHA_SIZE_EXT 0x802B #define GL_HISTOGRAM_LUMINANCE_SIZE_EXT 0x802C #define GL_HISTOGRAM_SINK_EXT 0x802D #define GL_MINMAX_EXT 0x802E #define GL_MINMAX_FORMAT_EXT 0x802F #define GL_MINMAX_SINK_EXT 0x8030 #define GL_TABLE_TOO_LARGE_EXT 0x8031 typedef void (APIENTRYP PFNGLGETHISTOGRAMEXTPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, void *values); typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); typedef void (APIENTRYP PFNGLGETMINMAXEXTPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, void *values); typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); typedef void (APIENTRYP PFNGLHISTOGRAMEXTPROC) (GLenum target, GLsizei width, GLenum internalformat, GLboolean sink); typedef void (APIENTRYP PFNGLMINMAXEXTPROC) (GLenum target, GLenum internalformat, GLboolean sink); typedef void (APIENTRYP PFNGLRESETHISTOGRAMEXTPROC) (GLenum target); typedef void (APIENTRYP PFNGLRESETMINMAXEXTPROC) (GLenum target); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glGetHistogramEXT (GLenum target, GLboolean reset, GLenum format, GLenum type, void *values); GLAPI void APIENTRY glGetHistogramParameterfvEXT (GLenum target, GLenum pname, GLfloat *params); GLAPI void APIENTRY glGetHistogramParameterivEXT (GLenum target, GLenum pname, GLint *params); GLAPI void APIENTRY glGetMinmaxEXT (GLenum target, GLboolean reset, GLenum format, GLenum type, void *values); GLAPI void APIENTRY glGetMinmaxParameterfvEXT (GLenum target, GLenum pname, GLfloat *params); GLAPI void APIENTRY glGetMinmaxParameterivEXT (GLenum target, GLenum pname, GLint *params); GLAPI void APIENTRY glHistogramEXT (GLenum target, GLsizei width, GLenum internalformat, GLboolean sink); GLAPI void APIENTRY glMinmaxEXT (GLenum target, GLenum internalformat, GLboolean sink); GLAPI void APIENTRY glResetHistogramEXT (GLenum target); GLAPI void APIENTRY glResetMinmaxEXT (GLenum target); #endif #endif /* GL_EXT_histogram */ #ifndef GL_EXT_index_array_formats #define GL_EXT_index_array_formats 1 #define GL_IUI_V2F_EXT 0x81AD #define GL_IUI_V3F_EXT 0x81AE #define GL_IUI_N3F_V2F_EXT 0x81AF #define GL_IUI_N3F_V3F_EXT 0x81B0 #define GL_T2F_IUI_V2F_EXT 0x81B1 #define GL_T2F_IUI_V3F_EXT 0x81B2 #define GL_T2F_IUI_N3F_V2F_EXT 0x81B3 #define GL_T2F_IUI_N3F_V3F_EXT 0x81B4 #endif /* GL_EXT_index_array_formats */ #ifndef GL_EXT_index_func #define GL_EXT_index_func 1 #define GL_INDEX_TEST_EXT 0x81B5 #define GL_INDEX_TEST_FUNC_EXT 0x81B6 #define GL_INDEX_TEST_REF_EXT 0x81B7 typedef void (APIENTRYP PFNGLINDEXFUNCEXTPROC) (GLenum func, GLclampf ref); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glIndexFuncEXT (GLenum func, GLclampf ref); #endif #endif /* GL_EXT_index_func */ #ifndef GL_EXT_index_material #define GL_EXT_index_material 1 #define GL_INDEX_MATERIAL_EXT 0x81B8 #define GL_INDEX_MATERIAL_PARAMETER_EXT 0x81B9 #define GL_INDEX_MATERIAL_FACE_EXT 0x81BA typedef void (APIENTRYP PFNGLINDEXMATERIALEXTPROC) (GLenum face, GLenum mode); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glIndexMaterialEXT (GLenum face, GLenum mode); #endif #endif /* GL_EXT_index_material */ #ifndef GL_EXT_index_texture #define GL_EXT_index_texture 1 #endif /* GL_EXT_index_texture */ #ifndef GL_EXT_light_texture #define GL_EXT_light_texture 1 #define GL_FRAGMENT_MATERIAL_EXT 0x8349 #define GL_FRAGMENT_NORMAL_EXT 0x834A #define GL_FRAGMENT_COLOR_EXT 0x834C #define GL_ATTENUATION_EXT 0x834D #define GL_SHADOW_ATTENUATION_EXT 0x834E #define GL_TEXTURE_APPLICATION_MODE_EXT 0x834F #define GL_TEXTURE_LIGHT_EXT 0x8350 #define GL_TEXTURE_MATERIAL_FACE_EXT 0x8351 #define GL_TEXTURE_MATERIAL_PARAMETER_EXT 0x8352 typedef void (APIENTRYP PFNGLAPPLYTEXTUREEXTPROC) (GLenum mode); typedef void (APIENTRYP PFNGLTEXTURELIGHTEXTPROC) (GLenum pname); typedef void (APIENTRYP PFNGLTEXTUREMATERIALEXTPROC) (GLenum face, GLenum mode); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glApplyTextureEXT (GLenum mode); GLAPI void APIENTRY glTextureLightEXT (GLenum pname); GLAPI void APIENTRY glTextureMaterialEXT (GLenum face, GLenum mode); #endif #endif /* GL_EXT_light_texture */ #ifndef GL_EXT_memory_object #define GL_EXT_memory_object 1 #define GL_TEXTURE_TILING_EXT 0x9580 #define GL_DEDICATED_MEMORY_OBJECT_EXT 0x9581 #define GL_PROTECTED_MEMORY_OBJECT_EXT 0x959B #define GL_NUM_TILING_TYPES_EXT 0x9582 #define GL_TILING_TYPES_EXT 0x9583 #define GL_OPTIMAL_TILING_EXT 0x9584 #define GL_LINEAR_TILING_EXT 0x9585 #define GL_NUM_DEVICE_UUIDS_EXT 0x9596 #define GL_DEVICE_UUID_EXT 0x9597 #define GL_DRIVER_UUID_EXT 0x9598 #define GL_UUID_SIZE_EXT 16 typedef void (APIENTRYP PFNGLGETUNSIGNEDBYTEVEXTPROC) (GLenum pname, GLubyte *data); typedef void (APIENTRYP PFNGLGETUNSIGNEDBYTEI_VEXTPROC) (GLenum target, GLuint index, GLubyte *data); typedef void (APIENTRYP PFNGLDELETEMEMORYOBJECTSEXTPROC) (GLsizei n, const GLuint *memoryObjects); typedef GLboolean (APIENTRYP PFNGLISMEMORYOBJECTEXTPROC) (GLuint memoryObject); typedef void (APIENTRYP PFNGLCREATEMEMORYOBJECTSEXTPROC) (GLsizei n, GLuint *memoryObjects); typedef void (APIENTRYP PFNGLMEMORYOBJECTPARAMETERIVEXTPROC) (GLuint memoryObject, GLenum pname, const GLint *params); typedef void (APIENTRYP PFNGLGETMEMORYOBJECTPARAMETERIVEXTPROC) (GLuint memoryObject, GLenum pname, GLint *params); typedef void (APIENTRYP PFNGLTEXSTORAGEMEM2DEXTPROC) (GLenum target, GLsizei levels, GLenum internalFormat, GLsizei width, GLsizei height, GLuint memory, GLuint64 offset); typedef void (APIENTRYP PFNGLTEXSTORAGEMEM2DMULTISAMPLEEXTPROC) (GLenum target, GLsizei samples, GLenum internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations, GLuint memory, GLuint64 offset); typedef void (APIENTRYP PFNGLTEXSTORAGEMEM3DEXTPROC) (GLenum target, GLsizei levels, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLuint memory, GLuint64 offset); typedef void (APIENTRYP PFNGLTEXSTORAGEMEM3DMULTISAMPLEEXTPROC) (GLenum target, GLsizei samples, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations, GLuint memory, GLuint64 offset); typedef void (APIENTRYP PFNGLBUFFERSTORAGEMEMEXTPROC) (GLenum target, GLsizeiptr size, GLuint memory, GLuint64 offset); typedef void (APIENTRYP PFNGLTEXTURESTORAGEMEM2DEXTPROC) (GLuint texture, GLsizei levels, GLenum internalFormat, GLsizei width, GLsizei height, GLuint memory, GLuint64 offset); typedef void (APIENTRYP PFNGLTEXTURESTORAGEMEM2DMULTISAMPLEEXTPROC) (GLuint texture, GLsizei samples, GLenum internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations, GLuint memory, GLuint64 offset); typedef void (APIENTRYP PFNGLTEXTURESTORAGEMEM3DEXTPROC) (GLuint texture, GLsizei levels, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLuint memory, GLuint64 offset); typedef void (APIENTRYP PFNGLTEXTURESTORAGEMEM3DMULTISAMPLEEXTPROC) (GLuint texture, GLsizei samples, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations, GLuint memory, GLuint64 offset); typedef void (APIENTRYP PFNGLNAMEDBUFFERSTORAGEMEMEXTPROC) (GLuint buffer, GLsizeiptr size, GLuint memory, GLuint64 offset); typedef void (APIENTRYP PFNGLTEXSTORAGEMEM1DEXTPROC) (GLenum target, GLsizei levels, GLenum internalFormat, GLsizei width, GLuint memory, GLuint64 offset); typedef void (APIENTRYP PFNGLTEXTURESTORAGEMEM1DEXTPROC) (GLuint texture, GLsizei levels, GLenum internalFormat, GLsizei width, GLuint memory, GLuint64 offset); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glGetUnsignedBytevEXT (GLenum pname, GLubyte *data); GLAPI void APIENTRY glGetUnsignedBytei_vEXT (GLenum target, GLuint index, GLubyte *data); GLAPI void APIENTRY glDeleteMemoryObjectsEXT (GLsizei n, const GLuint *memoryObjects); GLAPI GLboolean APIENTRY glIsMemoryObjectEXT (GLuint memoryObject); GLAPI void APIENTRY glCreateMemoryObjectsEXT (GLsizei n, GLuint *memoryObjects); GLAPI void APIENTRY glMemoryObjectParameterivEXT (GLuint memoryObject, GLenum pname, const GLint *params); GLAPI void APIENTRY glGetMemoryObjectParameterivEXT (GLuint memoryObject, GLenum pname, GLint *params); GLAPI void APIENTRY glTexStorageMem2DEXT (GLenum target, GLsizei levels, GLenum internalFormat, GLsizei width, GLsizei height, GLuint memory, GLuint64 offset); GLAPI void APIENTRY glTexStorageMem2DMultisampleEXT (GLenum target, GLsizei samples, GLenum internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations, GLuint memory, GLuint64 offset); GLAPI void APIENTRY glTexStorageMem3DEXT (GLenum target, GLsizei levels, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLuint memory, GLuint64 offset); GLAPI void APIENTRY glTexStorageMem3DMultisampleEXT (GLenum target, GLsizei samples, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations, GLuint memory, GLuint64 offset); GLAPI void APIENTRY glBufferStorageMemEXT (GLenum target, GLsizeiptr size, GLuint memory, GLuint64 offset); GLAPI void APIENTRY glTextureStorageMem2DEXT (GLuint texture, GLsizei levels, GLenum internalFormat, GLsizei width, GLsizei height, GLuint memory, GLuint64 offset); GLAPI void APIENTRY glTextureStorageMem2DMultisampleEXT (GLuint texture, GLsizei samples, GLenum internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations, GLuint memory, GLuint64 offset); GLAPI void APIENTRY glTextureStorageMem3DEXT (GLuint texture, GLsizei levels, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLuint memory, GLuint64 offset); GLAPI void APIENTRY glTextureStorageMem3DMultisampleEXT (GLuint texture, GLsizei samples, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations, GLuint memory, GLuint64 offset); GLAPI void APIENTRY glNamedBufferStorageMemEXT (GLuint buffer, GLsizeiptr size, GLuint memory, GLuint64 offset); GLAPI void APIENTRY glTexStorageMem1DEXT (GLenum target, GLsizei levels, GLenum internalFormat, GLsizei width, GLuint memory, GLuint64 offset); GLAPI void APIENTRY glTextureStorageMem1DEXT (GLuint texture, GLsizei levels, GLenum internalFormat, GLsizei width, GLuint memory, GLuint64 offset); #endif #endif /* GL_EXT_memory_object */ #ifndef GL_EXT_memory_object_fd #define GL_EXT_memory_object_fd 1 #define GL_HANDLE_TYPE_OPAQUE_FD_EXT 0x9586 typedef void (APIENTRYP PFNGLIMPORTMEMORYFDEXTPROC) (GLuint memory, GLuint64 size, GLenum handleType, GLint fd); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glImportMemoryFdEXT (GLuint memory, GLuint64 size, GLenum handleType, GLint fd); #endif #endif /* GL_EXT_memory_object_fd */ #ifndef GL_EXT_memory_object_win32 #define GL_EXT_memory_object_win32 1 #define GL_HANDLE_TYPE_OPAQUE_WIN32_EXT 0x9587 #define GL_HANDLE_TYPE_OPAQUE_WIN32_KMT_EXT 0x9588 #define GL_DEVICE_LUID_EXT 0x9599 #define GL_DEVICE_NODE_MASK_EXT 0x959A #define GL_LUID_SIZE_EXT 8 #define GL_HANDLE_TYPE_D3D12_TILEPOOL_EXT 0x9589 #define GL_HANDLE_TYPE_D3D12_RESOURCE_EXT 0x958A #define GL_HANDLE_TYPE_D3D11_IMAGE_EXT 0x958B #define GL_HANDLE_TYPE_D3D11_IMAGE_KMT_EXT 0x958C typedef void (APIENTRYP PFNGLIMPORTMEMORYWIN32HANDLEEXTPROC) (GLuint memory, GLuint64 size, GLenum handleType, void *handle); typedef void (APIENTRYP PFNGLIMPORTMEMORYWIN32NAMEEXTPROC) (GLuint memory, GLuint64 size, GLenum handleType, const void *name); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glImportMemoryWin32HandleEXT (GLuint memory, GLuint64 size, GLenum handleType, void *handle); GLAPI void APIENTRY glImportMemoryWin32NameEXT (GLuint memory, GLuint64 size, GLenum handleType, const void *name); #endif #endif /* GL_EXT_memory_object_win32 */ #ifndef GL_EXT_misc_attribute #define GL_EXT_misc_attribute 1 #endif /* GL_EXT_misc_attribute */ #ifndef GL_EXT_multi_draw_arrays #define GL_EXT_multi_draw_arrays 1 typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSEXTPROC) (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount); typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSEXTPROC) (GLenum mode, const GLsizei *count, GLenum type, const void *const*indices, GLsizei primcount); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glMultiDrawArraysEXT (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount); GLAPI void APIENTRY glMultiDrawElementsEXT (GLenum mode, const GLsizei *count, GLenum type, const void *const*indices, GLsizei primcount); #endif #endif /* GL_EXT_multi_draw_arrays */ #ifndef GL_EXT_multisample #define GL_EXT_multisample 1 #define GL_MULTISAMPLE_EXT 0x809D #define GL_SAMPLE_ALPHA_TO_MASK_EXT 0x809E #define GL_SAMPLE_ALPHA_TO_ONE_EXT 0x809F #define GL_SAMPLE_MASK_EXT 0x80A0 #define GL_1PASS_EXT 0x80A1 #define GL_2PASS_0_EXT 0x80A2 #define GL_2PASS_1_EXT 0x80A3 #define GL_4PASS_0_EXT 0x80A4 #define GL_4PASS_1_EXT 0x80A5 #define GL_4PASS_2_EXT 0x80A6 #define GL_4PASS_3_EXT 0x80A7 #define GL_SAMPLE_BUFFERS_EXT 0x80A8 #define GL_SAMPLES_EXT 0x80A9 #define GL_SAMPLE_MASK_VALUE_EXT 0x80AA #define GL_SAMPLE_MASK_INVERT_EXT 0x80AB #define GL_SAMPLE_PATTERN_EXT 0x80AC #define GL_MULTISAMPLE_BIT_EXT 0x20000000 typedef void (APIENTRYP PFNGLSAMPLEMASKEXTPROC) (GLclampf value, GLboolean invert); typedef void (APIENTRYP PFNGLSAMPLEPATTERNEXTPROC) (GLenum pattern); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glSampleMaskEXT (GLclampf value, GLboolean invert); GLAPI void APIENTRY glSamplePatternEXT (GLenum pattern); #endif #endif /* GL_EXT_multisample */ #ifndef GL_EXT_multiview_tessellation_geometry_shader #define GL_EXT_multiview_tessellation_geometry_shader 1 #endif /* GL_EXT_multiview_tessellation_geometry_shader */ #ifndef GL_EXT_multiview_texture_multisample #define GL_EXT_multiview_texture_multisample 1 #endif /* GL_EXT_multiview_texture_multisample */ #ifndef GL_EXT_multiview_timer_query #define GL_EXT_multiview_timer_query 1 #endif /* GL_EXT_multiview_timer_query */ #ifndef GL_EXT_packed_depth_stencil #define GL_EXT_packed_depth_stencil 1 #define GL_DEPTH_STENCIL_EXT 0x84F9 #define GL_UNSIGNED_INT_24_8_EXT 0x84FA #define GL_DEPTH24_STENCIL8_EXT 0x88F0 #define GL_TEXTURE_STENCIL_SIZE_EXT 0x88F1 #endif /* GL_EXT_packed_depth_stencil */ #ifndef GL_EXT_packed_float #define GL_EXT_packed_float 1 #define GL_R11F_G11F_B10F_EXT 0x8C3A #define GL_UNSIGNED_INT_10F_11F_11F_REV_EXT 0x8C3B #define GL_RGBA_SIGNED_COMPONENTS_EXT 0x8C3C #endif /* GL_EXT_packed_float */ #ifndef GL_EXT_packed_pixels #define GL_EXT_packed_pixels 1 #define GL_UNSIGNED_BYTE_3_3_2_EXT 0x8032 #define GL_UNSIGNED_SHORT_4_4_4_4_EXT 0x8033 #define GL_UNSIGNED_SHORT_5_5_5_1_EXT 0x8034 #define GL_UNSIGNED_INT_8_8_8_8_EXT 0x8035 #define GL_UNSIGNED_INT_10_10_10_2_EXT 0x8036 #endif /* GL_EXT_packed_pixels */ #ifndef GL_EXT_paletted_texture #define GL_EXT_paletted_texture 1 #define GL_COLOR_INDEX1_EXT 0x80E2 #define GL_COLOR_INDEX2_EXT 0x80E3 #define GL_COLOR_INDEX4_EXT 0x80E4 #define GL_COLOR_INDEX8_EXT 0x80E5 #define GL_COLOR_INDEX12_EXT 0x80E6 #define GL_COLOR_INDEX16_EXT 0x80E7 #define GL_TEXTURE_INDEX_SIZE_EXT 0x80ED typedef void (APIENTRYP PFNGLCOLORTABLEEXTPROC) (GLenum target, GLenum internalFormat, GLsizei width, GLenum format, GLenum type, const void *table); typedef void (APIENTRYP PFNGLGETCOLORTABLEEXTPROC) (GLenum target, GLenum format, GLenum type, void *data); typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glColorTableEXT (GLenum target, GLenum internalFormat, GLsizei width, GLenum format, GLenum type, const void *table); GLAPI void APIENTRY glGetColorTableEXT (GLenum target, GLenum format, GLenum type, void *data); GLAPI void APIENTRY glGetColorTableParameterivEXT (GLenum target, GLenum pname, GLint *params); GLAPI void APIENTRY glGetColorTableParameterfvEXT (GLenum target, GLenum pname, GLfloat *params); #endif #endif /* GL_EXT_paletted_texture */ #ifndef GL_EXT_pixel_buffer_object #define GL_EXT_pixel_buffer_object 1 #define GL_PIXEL_PACK_BUFFER_EXT 0x88EB #define GL_PIXEL_UNPACK_BUFFER_EXT 0x88EC #define GL_PIXEL_PACK_BUFFER_BINDING_EXT 0x88ED #define GL_PIXEL_UNPACK_BUFFER_BINDING_EXT 0x88EF #endif /* GL_EXT_pixel_buffer_object */ #ifndef GL_EXT_pixel_transform #define GL_EXT_pixel_transform 1 #define GL_PIXEL_TRANSFORM_2D_EXT 0x8330 #define GL_PIXEL_MAG_FILTER_EXT 0x8331 #define GL_PIXEL_MIN_FILTER_EXT 0x8332 #define GL_PIXEL_CUBIC_WEIGHT_EXT 0x8333 #define GL_CUBIC_EXT 0x8334 #define GL_AVERAGE_EXT 0x8335 #define GL_PIXEL_TRANSFORM_2D_STACK_DEPTH_EXT 0x8336 #define GL_MAX_PIXEL_TRANSFORM_2D_STACK_DEPTH_EXT 0x8337 #define GL_PIXEL_TRANSFORM_2D_MATRIX_EXT 0x8338 typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERIEXTPROC) (GLenum target, GLenum pname, GLint param); typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERFEXTPROC) (GLenum target, GLenum pname, GLfloat param); typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERIVEXTPROC) (GLenum target, GLenum pname, const GLint *params); typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERFVEXTPROC) (GLenum target, GLenum pname, const GLfloat *params); typedef void (APIENTRYP PFNGLGETPIXELTRANSFORMPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); typedef void (APIENTRYP PFNGLGETPIXELTRANSFORMPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glPixelTransformParameteriEXT (GLenum target, GLenum pname, GLint param); GLAPI void APIENTRY glPixelTransformParameterfEXT (GLenum target, GLenum pname, GLfloat param); GLAPI void APIENTRY glPixelTransformParameterivEXT (GLenum target, GLenum pname, const GLint *params); GLAPI void APIENTRY glPixelTransformParameterfvEXT (GLenum target, GLenum pname, const GLfloat *params); GLAPI void APIENTRY glGetPixelTransformParameterivEXT (GLenum target, GLenum pname, GLint *params); GLAPI void APIENTRY glGetPixelTransformParameterfvEXT (GLenum target, GLenum pname, GLfloat *params); #endif #endif /* GL_EXT_pixel_transform */ #ifndef GL_EXT_pixel_transform_color_table #define GL_EXT_pixel_transform_color_table 1 #endif /* GL_EXT_pixel_transform_color_table */ #ifndef GL_EXT_point_parameters #define GL_EXT_point_parameters 1 #define GL_POINT_SIZE_MIN_EXT 0x8126 #define GL_POINT_SIZE_MAX_EXT 0x8127 #define GL_POINT_FADE_THRESHOLD_SIZE_EXT 0x8128 #define GL_DISTANCE_ATTENUATION_EXT 0x8129 typedef void (APIENTRYP PFNGLPOINTPARAMETERFEXTPROC) (GLenum pname, GLfloat param); typedef void (APIENTRYP PFNGLPOINTPARAMETERFVEXTPROC) (GLenum pname, const GLfloat *params); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glPointParameterfEXT (GLenum pname, GLfloat param); GLAPI void APIENTRY glPointParameterfvEXT (GLenum pname, const GLfloat *params); #endif #endif /* GL_EXT_point_parameters */ #ifndef GL_EXT_polygon_offset #define GL_EXT_polygon_offset 1 #define GL_POLYGON_OFFSET_EXT 0x8037 #define GL_POLYGON_OFFSET_FACTOR_EXT 0x8038 #define GL_POLYGON_OFFSET_BIAS_EXT 0x8039 typedef void (APIENTRYP PFNGLPOLYGONOFFSETEXTPROC) (GLfloat factor, GLfloat bias); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glPolygonOffsetEXT (GLfloat factor, GLfloat bias); #endif #endif /* GL_EXT_polygon_offset */ #ifndef GL_EXT_polygon_offset_clamp #define GL_EXT_polygon_offset_clamp 1 #define GL_POLYGON_OFFSET_CLAMP_EXT 0x8E1B typedef void (APIENTRYP PFNGLPOLYGONOFFSETCLAMPEXTPROC) (GLfloat factor, GLfloat units, GLfloat clamp); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glPolygonOffsetClampEXT (GLfloat factor, GLfloat units, GLfloat clamp); #endif #endif /* GL_EXT_polygon_offset_clamp */ #ifndef GL_EXT_post_depth_coverage #define GL_EXT_post_depth_coverage 1 #endif /* GL_EXT_post_depth_coverage */ #ifndef GL_EXT_provoking_vertex #define GL_EXT_provoking_vertex 1 #define GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION_EXT 0x8E4C #define GL_FIRST_VERTEX_CONVENTION_EXT 0x8E4D #define GL_LAST_VERTEX_CONVENTION_EXT 0x8E4E #define GL_PROVOKING_VERTEX_EXT 0x8E4F typedef void (APIENTRYP PFNGLPROVOKINGVERTEXEXTPROC) (GLenum mode); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glProvokingVertexEXT (GLenum mode); #endif #endif /* GL_EXT_provoking_vertex */ #ifndef GL_EXT_raster_multisample #define GL_EXT_raster_multisample 1 #define GL_RASTER_MULTISAMPLE_EXT 0x9327 #define GL_RASTER_SAMPLES_EXT 0x9328 #define GL_MAX_RASTER_SAMPLES_EXT 0x9329 #define GL_RASTER_FIXED_SAMPLE_LOCATIONS_EXT 0x932A #define GL_MULTISAMPLE_RASTERIZATION_ALLOWED_EXT 0x932B #define GL_EFFECTIVE_RASTER_SAMPLES_EXT 0x932C typedef void (APIENTRYP PFNGLRASTERSAMPLESEXTPROC) (GLuint samples, GLboolean fixedsamplelocations); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glRasterSamplesEXT (GLuint samples, GLboolean fixedsamplelocations); #endif #endif /* GL_EXT_raster_multisample */ #ifndef GL_EXT_rescale_normal #define GL_EXT_rescale_normal 1 #define GL_RESCALE_NORMAL_EXT 0x803A #endif /* GL_EXT_rescale_normal */ #ifndef GL_EXT_secondary_color #define GL_EXT_secondary_color 1 #define GL_COLOR_SUM_EXT 0x8458 #define GL_CURRENT_SECONDARY_COLOR_EXT 0x8459 #define GL_SECONDARY_COLOR_ARRAY_SIZE_EXT 0x845A #define GL_SECONDARY_COLOR_ARRAY_TYPE_EXT 0x845B #define GL_SECONDARY_COLOR_ARRAY_STRIDE_EXT 0x845C #define GL_SECONDARY_COLOR_ARRAY_POINTER_EXT 0x845D #define GL_SECONDARY_COLOR_ARRAY_EXT 0x845E typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BEXTPROC) (GLbyte red, GLbyte green, GLbyte blue); typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BVEXTPROC) (const GLbyte *v); typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DEXTPROC) (GLdouble red, GLdouble green, GLdouble blue); typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DVEXTPROC) (const GLdouble *v); typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FEXTPROC) (GLfloat red, GLfloat green, GLfloat blue); typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FVEXTPROC) (const GLfloat *v); typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IEXTPROC) (GLint red, GLint green, GLint blue); typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IVEXTPROC) (const GLint *v); typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SEXTPROC) (GLshort red, GLshort green, GLshort blue); typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SVEXTPROC) (const GLshort *v); typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBEXTPROC) (GLubyte red, GLubyte green, GLubyte blue); typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBVEXTPROC) (const GLubyte *v); typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIEXTPROC) (GLuint red, GLuint green, GLuint blue); typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIVEXTPROC) (const GLuint *v); typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USEXTPROC) (GLushort red, GLushort green, GLushort blue); typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USVEXTPROC) (const GLushort *v); typedef void (APIENTRYP PFNGLSECONDARYCOLORPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, const void *pointer); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glSecondaryColor3bEXT (GLbyte red, GLbyte green, GLbyte blue); GLAPI void APIENTRY glSecondaryColor3bvEXT (const GLbyte *v); GLAPI void APIENTRY glSecondaryColor3dEXT (GLdouble red, GLdouble green, GLdouble blue); GLAPI void APIENTRY glSecondaryColor3dvEXT (const GLdouble *v); GLAPI void APIENTRY glSecondaryColor3fEXT (GLfloat red, GLfloat green, GLfloat blue); GLAPI void APIENTRY glSecondaryColor3fvEXT (const GLfloat *v); GLAPI void APIENTRY glSecondaryColor3iEXT (GLint red, GLint green, GLint blue); GLAPI void APIENTRY glSecondaryColor3ivEXT (const GLint *v); GLAPI void APIENTRY glSecondaryColor3sEXT (GLshort red, GLshort green, GLshort blue); GLAPI void APIENTRY glSecondaryColor3svEXT (const GLshort *v); GLAPI void APIENTRY glSecondaryColor3ubEXT (GLubyte red, GLubyte green, GLubyte blue); GLAPI void APIENTRY glSecondaryColor3ubvEXT (const GLubyte *v); GLAPI void APIENTRY glSecondaryColor3uiEXT (GLuint red, GLuint green, GLuint blue); GLAPI void APIENTRY glSecondaryColor3uivEXT (const GLuint *v); GLAPI void APIENTRY glSecondaryColor3usEXT (GLushort red, GLushort green, GLushort blue); GLAPI void APIENTRY glSecondaryColor3usvEXT (const GLushort *v); GLAPI void APIENTRY glSecondaryColorPointerEXT (GLint size, GLenum type, GLsizei stride, const void *pointer); #endif #endif /* GL_EXT_secondary_color */ #ifndef GL_EXT_semaphore #define GL_EXT_semaphore 1 #define GL_LAYOUT_GENERAL_EXT 0x958D #define GL_LAYOUT_COLOR_ATTACHMENT_EXT 0x958E #define GL_LAYOUT_DEPTH_STENCIL_ATTACHMENT_EXT 0x958F #define GL_LAYOUT_DEPTH_STENCIL_READ_ONLY_EXT 0x9590 #define GL_LAYOUT_SHADER_READ_ONLY_EXT 0x9591 #define GL_LAYOUT_TRANSFER_SRC_EXT 0x9592 #define GL_LAYOUT_TRANSFER_DST_EXT 0x9593 #define GL_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_EXT 0x9530 #define GL_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_EXT 0x9531 typedef void (APIENTRYP PFNGLGENSEMAPHORESEXTPROC) (GLsizei n, GLuint *semaphores); typedef void (APIENTRYP PFNGLDELETESEMAPHORESEXTPROC) (GLsizei n, const GLuint *semaphores); typedef GLboolean (APIENTRYP PFNGLISSEMAPHOREEXTPROC) (GLuint semaphore); typedef void (APIENTRYP PFNGLSEMAPHOREPARAMETERUI64VEXTPROC) (GLuint semaphore, GLenum pname, const GLuint64 *params); typedef void (APIENTRYP PFNGLGETSEMAPHOREPARAMETERUI64VEXTPROC) (GLuint semaphore, GLenum pname, GLuint64 *params); typedef void (APIENTRYP PFNGLWAITSEMAPHOREEXTPROC) (GLuint semaphore, GLuint numBufferBarriers, const GLuint *buffers, GLuint numTextureBarriers, const GLuint *textures, const GLenum *srcLayouts); typedef void (APIENTRYP PFNGLSIGNALSEMAPHOREEXTPROC) (GLuint semaphore, GLuint numBufferBarriers, const GLuint *buffers, GLuint numTextureBarriers, const GLuint *textures, const GLenum *dstLayouts); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glGenSemaphoresEXT (GLsizei n, GLuint *semaphores); GLAPI void APIENTRY glDeleteSemaphoresEXT (GLsizei n, const GLuint *semaphores); GLAPI GLboolean APIENTRY glIsSemaphoreEXT (GLuint semaphore); GLAPI void APIENTRY glSemaphoreParameterui64vEXT (GLuint semaphore, GLenum pname, const GLuint64 *params); GLAPI void APIENTRY glGetSemaphoreParameterui64vEXT (GLuint semaphore, GLenum pname, GLuint64 *params); GLAPI void APIENTRY glWaitSemaphoreEXT (GLuint semaphore, GLuint numBufferBarriers, const GLuint *buffers, GLuint numTextureBarriers, const GLuint *textures, const GLenum *srcLayouts); GLAPI void APIENTRY glSignalSemaphoreEXT (GLuint semaphore, GLuint numBufferBarriers, const GLuint *buffers, GLuint numTextureBarriers, const GLuint *textures, const GLenum *dstLayouts); #endif #endif /* GL_EXT_semaphore */ #ifndef GL_EXT_semaphore_fd #define GL_EXT_semaphore_fd 1 typedef void (APIENTRYP PFNGLIMPORTSEMAPHOREFDEXTPROC) (GLuint semaphore, GLenum handleType, GLint fd); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glImportSemaphoreFdEXT (GLuint semaphore, GLenum handleType, GLint fd); #endif #endif /* GL_EXT_semaphore_fd */ #ifndef GL_EXT_semaphore_win32 #define GL_EXT_semaphore_win32 1 #define GL_HANDLE_TYPE_D3D12_FENCE_EXT 0x9594 #define GL_D3D12_FENCE_VALUE_EXT 0x9595 typedef void (APIENTRYP PFNGLIMPORTSEMAPHOREWIN32HANDLEEXTPROC) (GLuint semaphore, GLenum handleType, void *handle); typedef void (APIENTRYP PFNGLIMPORTSEMAPHOREWIN32NAMEEXTPROC) (GLuint semaphore, GLenum handleType, const void *name); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glImportSemaphoreWin32HandleEXT (GLuint semaphore, GLenum handleType, void *handle); GLAPI void APIENTRY glImportSemaphoreWin32NameEXT (GLuint semaphore, GLenum handleType, const void *name); #endif #endif /* GL_EXT_semaphore_win32 */ #ifndef GL_EXT_separate_shader_objects #define GL_EXT_separate_shader_objects 1 #define GL_ACTIVE_PROGRAM_EXT 0x8B8D typedef void (APIENTRYP PFNGLUSESHADERPROGRAMEXTPROC) (GLenum type, GLuint program); typedef void (APIENTRYP PFNGLACTIVEPROGRAMEXTPROC) (GLuint program); typedef GLuint (APIENTRYP PFNGLCREATESHADERPROGRAMEXTPROC) (GLenum type, const GLchar *string); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glUseShaderProgramEXT (GLenum type, GLuint program); GLAPI void APIENTRY glActiveProgramEXT (GLuint program); GLAPI GLuint APIENTRY glCreateShaderProgramEXT (GLenum type, const GLchar *string); #endif #endif /* GL_EXT_separate_shader_objects */ #ifndef GL_EXT_separate_specular_color #define GL_EXT_separate_specular_color 1 #define GL_LIGHT_MODEL_COLOR_CONTROL_EXT 0x81F8 #define GL_SINGLE_COLOR_EXT 0x81F9 #define GL_SEPARATE_SPECULAR_COLOR_EXT 0x81FA #endif /* GL_EXT_separate_specular_color */ #ifndef GL_EXT_shader_framebuffer_fetch #define GL_EXT_shader_framebuffer_fetch 1 #define GL_FRAGMENT_SHADER_DISCARDS_SAMPLES_EXT 0x8A52 #endif /* GL_EXT_shader_framebuffer_fetch */ #ifndef GL_EXT_shader_framebuffer_fetch_non_coherent #define GL_EXT_shader_framebuffer_fetch_non_coherent 1 typedef void (APIENTRYP PFNGLFRAMEBUFFERFETCHBARRIEREXTPROC) (void); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glFramebufferFetchBarrierEXT (void); #endif #endif /* GL_EXT_shader_framebuffer_fetch_non_coherent */ #ifndef GL_EXT_shader_image_load_formatted #define GL_EXT_shader_image_load_formatted 1 #endif /* GL_EXT_shader_image_load_formatted */ #ifndef GL_EXT_shader_image_load_store #define GL_EXT_shader_image_load_store 1 #define GL_MAX_IMAGE_UNITS_EXT 0x8F38 #define GL_MAX_COMBINED_IMAGE_UNITS_AND_FRAGMENT_OUTPUTS_EXT 0x8F39 #define GL_IMAGE_BINDING_NAME_EXT 0x8F3A #define GL_IMAGE_BINDING_LEVEL_EXT 0x8F3B #define GL_IMAGE_BINDING_LAYERED_EXT 0x8F3C #define GL_IMAGE_BINDING_LAYER_EXT 0x8F3D #define GL_IMAGE_BINDING_ACCESS_EXT 0x8F3E #define GL_IMAGE_1D_EXT 0x904C #define GL_IMAGE_2D_EXT 0x904D #define GL_IMAGE_3D_EXT 0x904E #define GL_IMAGE_2D_RECT_EXT 0x904F #define GL_IMAGE_CUBE_EXT 0x9050 #define GL_IMAGE_BUFFER_EXT 0x9051 #define GL_IMAGE_1D_ARRAY_EXT 0x9052 #define GL_IMAGE_2D_ARRAY_EXT 0x9053 #define GL_IMAGE_CUBE_MAP_ARRAY_EXT 0x9054 #define GL_IMAGE_2D_MULTISAMPLE_EXT 0x9055 #define GL_IMAGE_2D_MULTISAMPLE_ARRAY_EXT 0x9056 #define GL_INT_IMAGE_1D_EXT 0x9057 #define GL_INT_IMAGE_2D_EXT 0x9058 #define GL_INT_IMAGE_3D_EXT 0x9059 #define GL_INT_IMAGE_2D_RECT_EXT 0x905A #define GL_INT_IMAGE_CUBE_EXT 0x905B #define GL_INT_IMAGE_BUFFER_EXT 0x905C #define GL_INT_IMAGE_1D_ARRAY_EXT 0x905D #define GL_INT_IMAGE_2D_ARRAY_EXT 0x905E #define GL_INT_IMAGE_CUBE_MAP_ARRAY_EXT 0x905F #define GL_INT_IMAGE_2D_MULTISAMPLE_EXT 0x9060 #define GL_INT_IMAGE_2D_MULTISAMPLE_ARRAY_EXT 0x9061 #define GL_UNSIGNED_INT_IMAGE_1D_EXT 0x9062 #define GL_UNSIGNED_INT_IMAGE_2D_EXT 0x9063 #define GL_UNSIGNED_INT_IMAGE_3D_EXT 0x9064 #define GL_UNSIGNED_INT_IMAGE_2D_RECT_EXT 0x9065 #define GL_UNSIGNED_INT_IMAGE_CUBE_EXT 0x9066 #define GL_UNSIGNED_INT_IMAGE_BUFFER_EXT 0x9067 #define GL_UNSIGNED_INT_IMAGE_1D_ARRAY_EXT 0x9068 #define GL_UNSIGNED_INT_IMAGE_2D_ARRAY_EXT 0x9069 #define GL_UNSIGNED_INT_IMAGE_CUBE_MAP_ARRAY_EXT 0x906A #define GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE_EXT 0x906B #define GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE_ARRAY_EXT 0x906C #define GL_MAX_IMAGE_SAMPLES_EXT 0x906D #define GL_IMAGE_BINDING_FORMAT_EXT 0x906E #define GL_VERTEX_ATTRIB_ARRAY_BARRIER_BIT_EXT 0x00000001 #define GL_ELEMENT_ARRAY_BARRIER_BIT_EXT 0x00000002 #define GL_UNIFORM_BARRIER_BIT_EXT 0x00000004 #define GL_TEXTURE_FETCH_BARRIER_BIT_EXT 0x00000008 #define GL_SHADER_IMAGE_ACCESS_BARRIER_BIT_EXT 0x00000020 #define GL_COMMAND_BARRIER_BIT_EXT 0x00000040 #define GL_PIXEL_BUFFER_BARRIER_BIT_EXT 0x00000080 #define GL_TEXTURE_UPDATE_BARRIER_BIT_EXT 0x00000100 #define GL_BUFFER_UPDATE_BARRIER_BIT_EXT 0x00000200 #define GL_FRAMEBUFFER_BARRIER_BIT_EXT 0x00000400 #define GL_TRANSFORM_FEEDBACK_BARRIER_BIT_EXT 0x00000800 #define GL_ATOMIC_COUNTER_BARRIER_BIT_EXT 0x00001000 #define GL_ALL_BARRIER_BITS_EXT 0xFFFFFFFF typedef void (APIENTRYP PFNGLBINDIMAGETEXTUREEXTPROC) (GLuint index, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLint format); typedef void (APIENTRYP PFNGLMEMORYBARRIEREXTPROC) (GLbitfield barriers); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glBindImageTextureEXT (GLuint index, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLint format); GLAPI void APIENTRY glMemoryBarrierEXT (GLbitfield barriers); #endif #endif /* GL_EXT_shader_image_load_store */ #ifndef GL_EXT_shader_integer_mix #define GL_EXT_shader_integer_mix 1 #endif /* GL_EXT_shader_integer_mix */ #ifndef GL_EXT_shader_samples_identical #define GL_EXT_shader_samples_identical 1 #endif /* GL_EXT_shader_samples_identical */ #ifndef GL_EXT_shadow_funcs #define GL_EXT_shadow_funcs 1 #endif /* GL_EXT_shadow_funcs */ #ifndef GL_EXT_shared_texture_palette #define GL_EXT_shared_texture_palette 1 #define GL_SHARED_TEXTURE_PALETTE_EXT 0x81FB #endif /* GL_EXT_shared_texture_palette */ #ifndef GL_EXT_sparse_texture2 #define GL_EXT_sparse_texture2 1 #endif /* GL_EXT_sparse_texture2 */ #ifndef GL_EXT_stencil_clear_tag #define GL_EXT_stencil_clear_tag 1 #define GL_STENCIL_TAG_BITS_EXT 0x88F2 #define GL_STENCIL_CLEAR_TAG_VALUE_EXT 0x88F3 typedef void (APIENTRYP PFNGLSTENCILCLEARTAGEXTPROC) (GLsizei stencilTagBits, GLuint stencilClearTag); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glStencilClearTagEXT (GLsizei stencilTagBits, GLuint stencilClearTag); #endif #endif /* GL_EXT_stencil_clear_tag */ #ifndef GL_EXT_stencil_two_side #define GL_EXT_stencil_two_side 1 #define GL_STENCIL_TEST_TWO_SIDE_EXT 0x8910 #define GL_ACTIVE_STENCIL_FACE_EXT 0x8911 typedef void (APIENTRYP PFNGLACTIVESTENCILFACEEXTPROC) (GLenum face); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glActiveStencilFaceEXT (GLenum face); #endif #endif /* GL_EXT_stencil_two_side */ #ifndef GL_EXT_stencil_wrap #define GL_EXT_stencil_wrap 1 #define GL_INCR_WRAP_EXT 0x8507 #define GL_DECR_WRAP_EXT 0x8508 #endif /* GL_EXT_stencil_wrap */ #ifndef GL_EXT_subtexture #define GL_EXT_subtexture 1 typedef void (APIENTRYP PFNGLTEXSUBIMAGE1DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const void *pixels); typedef void (APIENTRYP PFNGLTEXSUBIMAGE2DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glTexSubImage1DEXT (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const void *pixels); GLAPI void APIENTRY glTexSubImage2DEXT (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels); #endif #endif /* GL_EXT_subtexture */ #ifndef GL_EXT_texture #define GL_EXT_texture 1 #define GL_ALPHA4_EXT 0x803B #define GL_ALPHA8_EXT 0x803C #define GL_ALPHA12_EXT 0x803D #define GL_ALPHA16_EXT 0x803E #define GL_LUMINANCE4_EXT 0x803F #define GL_LUMINANCE8_EXT 0x8040 #define GL_LUMINANCE12_EXT 0x8041 #define GL_LUMINANCE16_EXT 0x8042 #define GL_LUMINANCE4_ALPHA4_EXT 0x8043 #define GL_LUMINANCE6_ALPHA2_EXT 0x8044 #define GL_LUMINANCE8_ALPHA8_EXT 0x8045 #define GL_LUMINANCE12_ALPHA4_EXT 0x8046 #define GL_LUMINANCE12_ALPHA12_EXT 0x8047 #define GL_LUMINANCE16_ALPHA16_EXT 0x8048 #define GL_INTENSITY_EXT 0x8049 #define GL_INTENSITY4_EXT 0x804A #define GL_INTENSITY8_EXT 0x804B #define GL_INTENSITY12_EXT 0x804C #define GL_INTENSITY16_EXT 0x804D #define GL_RGB2_EXT 0x804E #define GL_RGB4_EXT 0x804F #define GL_RGB5_EXT 0x8050 #define GL_RGB8_EXT 0x8051 #define GL_RGB10_EXT 0x8052 #define GL_RGB12_EXT 0x8053 #define GL_RGB16_EXT 0x8054 #define GL_RGBA2_EXT 0x8055 #define GL_RGBA4_EXT 0x8056 #define GL_RGB5_A1_EXT 0x8057 #define GL_RGBA8_EXT 0x8058 #define GL_RGB10_A2_EXT 0x8059 #define GL_RGBA12_EXT 0x805A #define GL_RGBA16_EXT 0x805B #define GL_TEXTURE_RED_SIZE_EXT 0x805C #define GL_TEXTURE_GREEN_SIZE_EXT 0x805D #define GL_TEXTURE_BLUE_SIZE_EXT 0x805E #define GL_TEXTURE_ALPHA_SIZE_EXT 0x805F #define GL_TEXTURE_LUMINANCE_SIZE_EXT 0x8060 #define GL_TEXTURE_INTENSITY_SIZE_EXT 0x8061 #define GL_REPLACE_EXT 0x8062 #define GL_PROXY_TEXTURE_1D_EXT 0x8063 #define GL_PROXY_TEXTURE_2D_EXT 0x8064 #define GL_TEXTURE_TOO_LARGE_EXT 0x8065 #endif /* GL_EXT_texture */ #ifndef GL_EXT_texture3D #define GL_EXT_texture3D 1 #define GL_PACK_SKIP_IMAGES_EXT 0x806B #define GL_PACK_IMAGE_HEIGHT_EXT 0x806C #define GL_UNPACK_SKIP_IMAGES_EXT 0x806D #define GL_UNPACK_IMAGE_HEIGHT_EXT 0x806E #define GL_TEXTURE_3D_EXT 0x806F #define GL_PROXY_TEXTURE_3D_EXT 0x8070 #define GL_TEXTURE_DEPTH_EXT 0x8071 #define GL_TEXTURE_WRAP_R_EXT 0x8072 #define GL_MAX_3D_TEXTURE_SIZE_EXT 0x8073 typedef void (APIENTRYP PFNGLTEXIMAGE3DEXTPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void *pixels); typedef void (APIENTRYP PFNGLTEXSUBIMAGE3DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glTexImage3DEXT (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void *pixels); GLAPI void APIENTRY glTexSubImage3DEXT (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels); #endif #endif /* GL_EXT_texture3D */ #ifndef GL_EXT_texture_array #define GL_EXT_texture_array 1 #define GL_TEXTURE_1D_ARRAY_EXT 0x8C18 #define GL_PROXY_TEXTURE_1D_ARRAY_EXT 0x8C19 #define GL_TEXTURE_2D_ARRAY_EXT 0x8C1A #define GL_PROXY_TEXTURE_2D_ARRAY_EXT 0x8C1B #define GL_TEXTURE_BINDING_1D_ARRAY_EXT 0x8C1C #define GL_TEXTURE_BINDING_2D_ARRAY_EXT 0x8C1D #define GL_MAX_ARRAY_TEXTURE_LAYERS_EXT 0x88FF #define GL_COMPARE_REF_DEPTH_TO_TEXTURE_EXT 0x884E typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURELAYEREXTPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glFramebufferTextureLayerEXT (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); #endif #endif /* GL_EXT_texture_array */ #ifndef GL_EXT_texture_buffer_object #define GL_EXT_texture_buffer_object 1 #define GL_TEXTURE_BUFFER_EXT 0x8C2A #define GL_MAX_TEXTURE_BUFFER_SIZE_EXT 0x8C2B #define GL_TEXTURE_BINDING_BUFFER_EXT 0x8C2C #define GL_TEXTURE_BUFFER_DATA_STORE_BINDING_EXT 0x8C2D #define GL_TEXTURE_BUFFER_FORMAT_EXT 0x8C2E typedef void (APIENTRYP PFNGLTEXBUFFEREXTPROC) (GLenum target, GLenum internalformat, GLuint buffer); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glTexBufferEXT (GLenum target, GLenum internalformat, GLuint buffer); #endif #endif /* GL_EXT_texture_buffer_object */ #ifndef GL_EXT_texture_compression_latc #define GL_EXT_texture_compression_latc 1 #define GL_COMPRESSED_LUMINANCE_LATC1_EXT 0x8C70 #define GL_COMPRESSED_SIGNED_LUMINANCE_LATC1_EXT 0x8C71 #define GL_COMPRESSED_LUMINANCE_ALPHA_LATC2_EXT 0x8C72 #define GL_COMPRESSED_SIGNED_LUMINANCE_ALPHA_LATC2_EXT 0x8C73 #endif /* GL_EXT_texture_compression_latc */ #ifndef GL_EXT_texture_compression_rgtc #define GL_EXT_texture_compression_rgtc 1 #define GL_COMPRESSED_RED_RGTC1_EXT 0x8DBB #define GL_COMPRESSED_SIGNED_RED_RGTC1_EXT 0x8DBC #define GL_COMPRESSED_RED_GREEN_RGTC2_EXT 0x8DBD #define GL_COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT 0x8DBE #endif /* GL_EXT_texture_compression_rgtc */ #ifndef GL_EXT_texture_compression_s3tc #define GL_EXT_texture_compression_s3tc 1 #define GL_COMPRESSED_RGB_S3TC_DXT1_EXT 0x83F0 #define GL_COMPRESSED_RGBA_S3TC_DXT1_EXT 0x83F1 #define GL_COMPRESSED_RGBA_S3TC_DXT3_EXT 0x83F2 #define GL_COMPRESSED_RGBA_S3TC_DXT5_EXT 0x83F3 #endif /* GL_EXT_texture_compression_s3tc */ #ifndef GL_EXT_texture_cube_map #define GL_EXT_texture_cube_map 1 #define GL_NORMAL_MAP_EXT 0x8511 #define GL_REFLECTION_MAP_EXT 0x8512 #define GL_TEXTURE_CUBE_MAP_EXT 0x8513 #define GL_TEXTURE_BINDING_CUBE_MAP_EXT 0x8514 #define GL_TEXTURE_CUBE_MAP_POSITIVE_X_EXT 0x8515 #define GL_TEXTURE_CUBE_MAP_NEGATIVE_X_EXT 0x8516 #define GL_TEXTURE_CUBE_MAP_POSITIVE_Y_EXT 0x8517 #define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_EXT 0x8518 #define GL_TEXTURE_CUBE_MAP_POSITIVE_Z_EXT 0x8519 #define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_EXT 0x851A #define GL_PROXY_TEXTURE_CUBE_MAP_EXT 0x851B #define GL_MAX_CUBE_MAP_TEXTURE_SIZE_EXT 0x851C #endif /* GL_EXT_texture_cube_map */ #ifndef GL_EXT_texture_env_add #define GL_EXT_texture_env_add 1 #endif /* GL_EXT_texture_env_add */ #ifndef GL_EXT_texture_env_combine #define GL_EXT_texture_env_combine 1 #define GL_COMBINE_EXT 0x8570 #define GL_COMBINE_RGB_EXT 0x8571 #define GL_COMBINE_ALPHA_EXT 0x8572 #define GL_RGB_SCALE_EXT 0x8573 #define GL_ADD_SIGNED_EXT 0x8574 #define GL_INTERPOLATE_EXT 0x8575 #define GL_CONSTANT_EXT 0x8576 #define GL_PRIMARY_COLOR_EXT 0x8577 #define GL_PREVIOUS_EXT 0x8578 #define GL_SOURCE0_RGB_EXT 0x8580 #define GL_SOURCE1_RGB_EXT 0x8581 #define GL_SOURCE2_RGB_EXT 0x8582 #define GL_SOURCE0_ALPHA_EXT 0x8588 #define GL_SOURCE1_ALPHA_EXT 0x8589 #define GL_SOURCE2_ALPHA_EXT 0x858A #define GL_OPERAND0_RGB_EXT 0x8590 #define GL_OPERAND1_RGB_EXT 0x8591 #define GL_OPERAND2_RGB_EXT 0x8592 #define GL_OPERAND0_ALPHA_EXT 0x8598 #define GL_OPERAND1_ALPHA_EXT 0x8599 #define GL_OPERAND2_ALPHA_EXT 0x859A #endif /* GL_EXT_texture_env_combine */ #ifndef GL_EXT_texture_env_dot3 #define GL_EXT_texture_env_dot3 1 #define GL_DOT3_RGB_EXT 0x8740 #define GL_DOT3_RGBA_EXT 0x8741 #endif /* GL_EXT_texture_env_dot3 */ #ifndef GL_EXT_texture_filter_anisotropic #define GL_EXT_texture_filter_anisotropic 1 #define GL_TEXTURE_MAX_ANISOTROPY_EXT 0x84FE #define GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT 0x84FF #endif /* GL_EXT_texture_filter_anisotropic */ #ifndef GL_EXT_texture_filter_minmax #define GL_EXT_texture_filter_minmax 1 #define GL_TEXTURE_REDUCTION_MODE_EXT 0x9366 #define GL_WEIGHTED_AVERAGE_EXT 0x9367 #endif /* GL_EXT_texture_filter_minmax */ #ifndef GL_EXT_texture_integer #define GL_EXT_texture_integer 1 #define GL_RGBA32UI_EXT 0x8D70 #define GL_RGB32UI_EXT 0x8D71 #define GL_ALPHA32UI_EXT 0x8D72 #define GL_INTENSITY32UI_EXT 0x8D73 #define GL_LUMINANCE32UI_EXT 0x8D74 #define GL_LUMINANCE_ALPHA32UI_EXT 0x8D75 #define GL_RGBA16UI_EXT 0x8D76 #define GL_RGB16UI_EXT 0x8D77 #define GL_ALPHA16UI_EXT 0x8D78 #define GL_INTENSITY16UI_EXT 0x8D79 #define GL_LUMINANCE16UI_EXT 0x8D7A #define GL_LUMINANCE_ALPHA16UI_EXT 0x8D7B #define GL_RGBA8UI_EXT 0x8D7C #define GL_RGB8UI_EXT 0x8D7D #define GL_ALPHA8UI_EXT 0x8D7E #define GL_INTENSITY8UI_EXT 0x8D7F #define GL_LUMINANCE8UI_EXT 0x8D80 #define GL_LUMINANCE_ALPHA8UI_EXT 0x8D81 #define GL_RGBA32I_EXT 0x8D82 #define GL_RGB32I_EXT 0x8D83 #define GL_ALPHA32I_EXT 0x8D84 #define GL_INTENSITY32I_EXT 0x8D85 #define GL_LUMINANCE32I_EXT 0x8D86 #define GL_LUMINANCE_ALPHA32I_EXT 0x8D87 #define GL_RGBA16I_EXT 0x8D88 #define GL_RGB16I_EXT 0x8D89 #define GL_ALPHA16I_EXT 0x8D8A #define GL_INTENSITY16I_EXT 0x8D8B #define GL_LUMINANCE16I_EXT 0x8D8C #define GL_LUMINANCE_ALPHA16I_EXT 0x8D8D #define GL_RGBA8I_EXT 0x8D8E #define GL_RGB8I_EXT 0x8D8F #define GL_ALPHA8I_EXT 0x8D90 #define GL_INTENSITY8I_EXT 0x8D91 #define GL_LUMINANCE8I_EXT 0x8D92 #define GL_LUMINANCE_ALPHA8I_EXT 0x8D93 #define GL_RED_INTEGER_EXT 0x8D94 #define GL_GREEN_INTEGER_EXT 0x8D95 #define GL_BLUE_INTEGER_EXT 0x8D96 #define GL_ALPHA_INTEGER_EXT 0x8D97 #define GL_RGB_INTEGER_EXT 0x8D98 #define GL_RGBA_INTEGER_EXT 0x8D99 #define GL_BGR_INTEGER_EXT 0x8D9A #define GL_BGRA_INTEGER_EXT 0x8D9B #define GL_LUMINANCE_INTEGER_EXT 0x8D9C #define GL_LUMINANCE_ALPHA_INTEGER_EXT 0x8D9D #define GL_RGBA_INTEGER_MODE_EXT 0x8D9E typedef void (APIENTRYP PFNGLTEXPARAMETERIIVEXTPROC) (GLenum target, GLenum pname, const GLint *params); typedef void (APIENTRYP PFNGLTEXPARAMETERIUIVEXTPROC) (GLenum target, GLenum pname, const GLuint *params); typedef void (APIENTRYP PFNGLGETTEXPARAMETERIIVEXTPROC) (GLenum target, GLenum pname, GLint *params); typedef void (APIENTRYP PFNGLGETTEXPARAMETERIUIVEXTPROC) (GLenum target, GLenum pname, GLuint *params); typedef void (APIENTRYP PFNGLCLEARCOLORIIEXTPROC) (GLint red, GLint green, GLint blue, GLint alpha); typedef void (APIENTRYP PFNGLCLEARCOLORIUIEXTPROC) (GLuint red, GLuint green, GLuint blue, GLuint alpha); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glTexParameterIivEXT (GLenum target, GLenum pname, const GLint *params); GLAPI void APIENTRY glTexParameterIuivEXT (GLenum target, GLenum pname, const GLuint *params); GLAPI void APIENTRY glGetTexParameterIivEXT (GLenum target, GLenum pname, GLint *params); GLAPI void APIENTRY glGetTexParameterIuivEXT (GLenum target, GLenum pname, GLuint *params); GLAPI void APIENTRY glClearColorIiEXT (GLint red, GLint green, GLint blue, GLint alpha); GLAPI void APIENTRY glClearColorIuiEXT (GLuint red, GLuint green, GLuint blue, GLuint alpha); #endif #endif /* GL_EXT_texture_integer */ #ifndef GL_EXT_texture_lod_bias #define GL_EXT_texture_lod_bias 1 #define GL_MAX_TEXTURE_LOD_BIAS_EXT 0x84FD #define GL_TEXTURE_FILTER_CONTROL_EXT 0x8500 #define GL_TEXTURE_LOD_BIAS_EXT 0x8501 #endif /* GL_EXT_texture_lod_bias */ #ifndef GL_EXT_texture_mirror_clamp #define GL_EXT_texture_mirror_clamp 1 #define GL_MIRROR_CLAMP_EXT 0x8742 #define GL_MIRROR_CLAMP_TO_EDGE_EXT 0x8743 #define GL_MIRROR_CLAMP_TO_BORDER_EXT 0x8912 #endif /* GL_EXT_texture_mirror_clamp */ #ifndef GL_EXT_texture_object #define GL_EXT_texture_object 1 #define GL_TEXTURE_PRIORITY_EXT 0x8066 #define GL_TEXTURE_RESIDENT_EXT 0x8067 #define GL_TEXTURE_1D_BINDING_EXT 0x8068 #define GL_TEXTURE_2D_BINDING_EXT 0x8069 #define GL_TEXTURE_3D_BINDING_EXT 0x806A typedef GLboolean (APIENTRYP PFNGLARETEXTURESRESIDENTEXTPROC) (GLsizei n, const GLuint *textures, GLboolean *residences); typedef void (APIENTRYP PFNGLBINDTEXTUREEXTPROC) (GLenum target, GLuint texture); typedef void (APIENTRYP PFNGLDELETETEXTURESEXTPROC) (GLsizei n, const GLuint *textures); typedef void (APIENTRYP PFNGLGENTEXTURESEXTPROC) (GLsizei n, GLuint *textures); typedef GLboolean (APIENTRYP PFNGLISTEXTUREEXTPROC) (GLuint texture); typedef void (APIENTRYP PFNGLPRIORITIZETEXTURESEXTPROC) (GLsizei n, const GLuint *textures, const GLclampf *priorities); #ifdef GL_GLEXT_PROTOTYPES GLAPI GLboolean APIENTRY glAreTexturesResidentEXT (GLsizei n, const GLuint *textures, GLboolean *residences); GLAPI void APIENTRY glBindTextureEXT (GLenum target, GLuint texture); GLAPI void APIENTRY glDeleteTexturesEXT (GLsizei n, const GLuint *textures); GLAPI void APIENTRY glGenTexturesEXT (GLsizei n, GLuint *textures); GLAPI GLboolean APIENTRY glIsTextureEXT (GLuint texture); GLAPI void APIENTRY glPrioritizeTexturesEXT (GLsizei n, const GLuint *textures, const GLclampf *priorities); #endif #endif /* GL_EXT_texture_object */ #ifndef GL_EXT_texture_perturb_normal #define GL_EXT_texture_perturb_normal 1 #define GL_PERTURB_EXT 0x85AE #define GL_TEXTURE_NORMAL_EXT 0x85AF typedef void (APIENTRYP PFNGLTEXTURENORMALEXTPROC) (GLenum mode); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glTextureNormalEXT (GLenum mode); #endif #endif /* GL_EXT_texture_perturb_normal */ #ifndef GL_EXT_texture_sRGB #define GL_EXT_texture_sRGB 1 #define GL_SRGB_EXT 0x8C40 #define GL_SRGB8_EXT 0x8C41 #define GL_SRGB_ALPHA_EXT 0x8C42 #define GL_SRGB8_ALPHA8_EXT 0x8C43 #define GL_SLUMINANCE_ALPHA_EXT 0x8C44 #define GL_SLUMINANCE8_ALPHA8_EXT 0x8C45 #define GL_SLUMINANCE_EXT 0x8C46 #define GL_SLUMINANCE8_EXT 0x8C47 #define GL_COMPRESSED_SRGB_EXT 0x8C48 #define GL_COMPRESSED_SRGB_ALPHA_EXT 0x8C49 #define GL_COMPRESSED_SLUMINANCE_EXT 0x8C4A #define GL_COMPRESSED_SLUMINANCE_ALPHA_EXT 0x8C4B #define GL_COMPRESSED_SRGB_S3TC_DXT1_EXT 0x8C4C #define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT 0x8C4D #define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT 0x8C4E #define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT 0x8C4F #endif /* GL_EXT_texture_sRGB */ #ifndef GL_EXT_texture_sRGB_R8 #define GL_EXT_texture_sRGB_R8 1 #define GL_SR8_EXT 0x8FBD #endif /* GL_EXT_texture_sRGB_R8 */ #ifndef GL_EXT_texture_sRGB_RG8 #define GL_EXT_texture_sRGB_RG8 1 #define GL_SRG8_EXT 0x8FBE #endif /* GL_EXT_texture_sRGB_RG8 */ #ifndef GL_EXT_texture_sRGB_decode #define GL_EXT_texture_sRGB_decode 1 #define GL_TEXTURE_SRGB_DECODE_EXT 0x8A48 #define GL_DECODE_EXT 0x8A49 #define GL_SKIP_DECODE_EXT 0x8A4A #endif /* GL_EXT_texture_sRGB_decode */ #ifndef GL_EXT_texture_shadow_lod #define GL_EXT_texture_shadow_lod 1 #endif /* GL_EXT_texture_shadow_lod */ #ifndef GL_EXT_texture_shared_exponent #define GL_EXT_texture_shared_exponent 1 #define GL_RGB9_E5_EXT 0x8C3D #define GL_UNSIGNED_INT_5_9_9_9_REV_EXT 0x8C3E #define GL_TEXTURE_SHARED_SIZE_EXT 0x8C3F #endif /* GL_EXT_texture_shared_exponent */ #ifndef GL_EXT_texture_snorm #define GL_EXT_texture_snorm 1 #define GL_ALPHA_SNORM 0x9010 #define GL_LUMINANCE_SNORM 0x9011 #define GL_LUMINANCE_ALPHA_SNORM 0x9012 #define GL_INTENSITY_SNORM 0x9013 #define GL_ALPHA8_SNORM 0x9014 #define GL_LUMINANCE8_SNORM 0x9015 #define GL_LUMINANCE8_ALPHA8_SNORM 0x9016 #define GL_INTENSITY8_SNORM 0x9017 #define GL_ALPHA16_SNORM 0x9018 #define GL_LUMINANCE16_SNORM 0x9019 #define GL_LUMINANCE16_ALPHA16_SNORM 0x901A #define GL_INTENSITY16_SNORM 0x901B #define GL_RED_SNORM 0x8F90 #define GL_RG_SNORM 0x8F91 #define GL_RGB_SNORM 0x8F92 #define GL_RGBA_SNORM 0x8F93 #endif /* GL_EXT_texture_snorm */ #ifndef GL_EXT_texture_storage #define GL_EXT_texture_storage 1 #define GL_TEXTURE_IMMUTABLE_FORMAT_EXT 0x912F #define GL_RGBA32F_EXT 0x8814 #define GL_RGB32F_EXT 0x8815 #define GL_ALPHA32F_EXT 0x8816 #define GL_LUMINANCE32F_EXT 0x8818 #define GL_LUMINANCE_ALPHA32F_EXT 0x8819 #define GL_RGBA16F_EXT 0x881A #define GL_RGB16F_EXT 0x881B #define GL_ALPHA16F_EXT 0x881C #define GL_LUMINANCE16F_EXT 0x881E #define GL_LUMINANCE_ALPHA16F_EXT 0x881F #define GL_BGRA8_EXT 0x93A1 #define GL_R8_EXT 0x8229 #define GL_RG8_EXT 0x822B #define GL_R32F_EXT 0x822E #define GL_RG32F_EXT 0x8230 #define GL_R16F_EXT 0x822D #define GL_RG16F_EXT 0x822F typedef void (APIENTRYP PFNGLTEXSTORAGE1DEXTPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width); typedef void (APIENTRYP PFNGLTEXSTORAGE2DEXTPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); typedef void (APIENTRYP PFNGLTEXSTORAGE3DEXTPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glTexStorage1DEXT (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width); GLAPI void APIENTRY glTexStorage2DEXT (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); GLAPI void APIENTRY glTexStorage3DEXT (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); #endif #endif /* GL_EXT_texture_storage */ #ifndef GL_EXT_texture_swizzle #define GL_EXT_texture_swizzle 1 #define GL_TEXTURE_SWIZZLE_R_EXT 0x8E42 #define GL_TEXTURE_SWIZZLE_G_EXT 0x8E43 #define GL_TEXTURE_SWIZZLE_B_EXT 0x8E44 #define GL_TEXTURE_SWIZZLE_A_EXT 0x8E45 #define GL_TEXTURE_SWIZZLE_RGBA_EXT 0x8E46 #endif /* GL_EXT_texture_swizzle */ #ifndef GL_EXT_timer_query #define GL_EXT_timer_query 1 #define GL_TIME_ELAPSED_EXT 0x88BF typedef void (APIENTRYP PFNGLGETQUERYOBJECTI64VEXTPROC) (GLuint id, GLenum pname, GLint64 *params); typedef void (APIENTRYP PFNGLGETQUERYOBJECTUI64VEXTPROC) (GLuint id, GLenum pname, GLuint64 *params); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glGetQueryObjecti64vEXT (GLuint id, GLenum pname, GLint64 *params); GLAPI void APIENTRY glGetQueryObjectui64vEXT (GLuint id, GLenum pname, GLuint64 *params); #endif #endif /* GL_EXT_timer_query */ #ifndef GL_EXT_transform_feedback #define GL_EXT_transform_feedback 1 #define GL_TRANSFORM_FEEDBACK_BUFFER_EXT 0x8C8E #define GL_TRANSFORM_FEEDBACK_BUFFER_START_EXT 0x8C84 #define GL_TRANSFORM_FEEDBACK_BUFFER_SIZE_EXT 0x8C85 #define GL_TRANSFORM_FEEDBACK_BUFFER_BINDING_EXT 0x8C8F #define GL_INTERLEAVED_ATTRIBS_EXT 0x8C8C #define GL_SEPARATE_ATTRIBS_EXT 0x8C8D #define GL_PRIMITIVES_GENERATED_EXT 0x8C87 #define GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN_EXT 0x8C88 #define GL_RASTERIZER_DISCARD_EXT 0x8C89 #define GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS_EXT 0x8C8A #define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS_EXT 0x8C8B #define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS_EXT 0x8C80 #define GL_TRANSFORM_FEEDBACK_VARYINGS_EXT 0x8C83 #define GL_TRANSFORM_FEEDBACK_BUFFER_MODE_EXT 0x8C7F #define GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH_EXT 0x8C76 typedef void (APIENTRYP PFNGLBEGINTRANSFORMFEEDBACKEXTPROC) (GLenum primitiveMode); typedef void (APIENTRYP PFNGLENDTRANSFORMFEEDBACKEXTPROC) (void); typedef void (APIENTRYP PFNGLBINDBUFFERRANGEEXTPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); typedef void (APIENTRYP PFNGLBINDBUFFEROFFSETEXTPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset); typedef void (APIENTRYP PFNGLBINDBUFFERBASEEXTPROC) (GLenum target, GLuint index, GLuint buffer); typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKVARYINGSEXTPROC) (GLuint program, GLsizei count, const GLchar *const*varyings, GLenum bufferMode); typedef void (APIENTRYP PFNGLGETTRANSFORMFEEDBACKVARYINGEXTPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glBeginTransformFeedbackEXT (GLenum primitiveMode); GLAPI void APIENTRY glEndTransformFeedbackEXT (void); GLAPI void APIENTRY glBindBufferRangeEXT (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); GLAPI void APIENTRY glBindBufferOffsetEXT (GLenum target, GLuint index, GLuint buffer, GLintptr offset); GLAPI void APIENTRY glBindBufferBaseEXT (GLenum target, GLuint index, GLuint buffer); GLAPI void APIENTRY glTransformFeedbackVaryingsEXT (GLuint program, GLsizei count, const GLchar *const*varyings, GLenum bufferMode); GLAPI void APIENTRY glGetTransformFeedbackVaryingEXT (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); #endif #endif /* GL_EXT_transform_feedback */ #ifndef GL_EXT_vertex_array #define GL_EXT_vertex_array 1 #define GL_VERTEX_ARRAY_EXT 0x8074 #define GL_NORMAL_ARRAY_EXT 0x8075 #define GL_COLOR_ARRAY_EXT 0x8076 #define GL_INDEX_ARRAY_EXT 0x8077 #define GL_TEXTURE_COORD_ARRAY_EXT 0x8078 #define GL_EDGE_FLAG_ARRAY_EXT 0x8079 #define GL_VERTEX_ARRAY_SIZE_EXT 0x807A #define GL_VERTEX_ARRAY_TYPE_EXT 0x807B #define GL_VERTEX_ARRAY_STRIDE_EXT 0x807C #define GL_VERTEX_ARRAY_COUNT_EXT 0x807D #define GL_NORMAL_ARRAY_TYPE_EXT 0x807E #define GL_NORMAL_ARRAY_STRIDE_EXT 0x807F #define GL_NORMAL_ARRAY_COUNT_EXT 0x8080 #define GL_COLOR_ARRAY_SIZE_EXT 0x8081 #define GL_COLOR_ARRAY_TYPE_EXT 0x8082 #define GL_COLOR_ARRAY_STRIDE_EXT 0x8083 #define GL_COLOR_ARRAY_COUNT_EXT 0x8084 #define GL_INDEX_ARRAY_TYPE_EXT 0x8085 #define GL_INDEX_ARRAY_STRIDE_EXT 0x8086 #define GL_INDEX_ARRAY_COUNT_EXT 0x8087 #define GL_TEXTURE_COORD_ARRAY_SIZE_EXT 0x8088 #define GL_TEXTURE_COORD_ARRAY_TYPE_EXT 0x8089 #define GL_TEXTURE_COORD_ARRAY_STRIDE_EXT 0x808A #define GL_TEXTURE_COORD_ARRAY_COUNT_EXT 0x808B #define GL_EDGE_FLAG_ARRAY_STRIDE_EXT 0x808C #define GL_EDGE_FLAG_ARRAY_COUNT_EXT 0x808D #define GL_VERTEX_ARRAY_POINTER_EXT 0x808E #define GL_NORMAL_ARRAY_POINTER_EXT 0x808F #define GL_COLOR_ARRAY_POINTER_EXT 0x8090 #define GL_INDEX_ARRAY_POINTER_EXT 0x8091 #define GL_TEXTURE_COORD_ARRAY_POINTER_EXT 0x8092 #define GL_EDGE_FLAG_ARRAY_POINTER_EXT 0x8093 typedef void (APIENTRYP PFNGLARRAYELEMENTEXTPROC) (GLint i); typedef void (APIENTRYP PFNGLCOLORPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLsizei count, const void *pointer); typedef void (APIENTRYP PFNGLDRAWARRAYSEXTPROC) (GLenum mode, GLint first, GLsizei count); typedef void (APIENTRYP PFNGLEDGEFLAGPOINTEREXTPROC) (GLsizei stride, GLsizei count, const GLboolean *pointer); typedef void (APIENTRYP PFNGLGETPOINTERVEXTPROC) (GLenum pname, void **params); typedef void (APIENTRYP PFNGLINDEXPOINTEREXTPROC) (GLenum type, GLsizei stride, GLsizei count, const void *pointer); typedef void (APIENTRYP PFNGLNORMALPOINTEREXTPROC) (GLenum type, GLsizei stride, GLsizei count, const void *pointer); typedef void (APIENTRYP PFNGLTEXCOORDPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLsizei count, const void *pointer); typedef void (APIENTRYP PFNGLVERTEXPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLsizei count, const void *pointer); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glArrayElementEXT (GLint i); GLAPI void APIENTRY glColorPointerEXT (GLint size, GLenum type, GLsizei stride, GLsizei count, const void *pointer); GLAPI void APIENTRY glDrawArraysEXT (GLenum mode, GLint first, GLsizei count); GLAPI void APIENTRY glEdgeFlagPointerEXT (GLsizei stride, GLsizei count, const GLboolean *pointer); GLAPI void APIENTRY glGetPointervEXT (GLenum pname, void **params); GLAPI void APIENTRY glIndexPointerEXT (GLenum type, GLsizei stride, GLsizei count, const void *pointer); GLAPI void APIENTRY glNormalPointerEXT (GLenum type, GLsizei stride, GLsizei count, const void *pointer); GLAPI void APIENTRY glTexCoordPointerEXT (GLint size, GLenum type, GLsizei stride, GLsizei count, const void *pointer); GLAPI void APIENTRY glVertexPointerEXT (GLint size, GLenum type, GLsizei stride, GLsizei count, const void *pointer); #endif #endif /* GL_EXT_vertex_array */ #ifndef GL_EXT_vertex_array_bgra #define GL_EXT_vertex_array_bgra 1 #endif /* GL_EXT_vertex_array_bgra */ #ifndef GL_EXT_vertex_attrib_64bit #define GL_EXT_vertex_attrib_64bit 1 #define GL_DOUBLE_VEC2_EXT 0x8FFC #define GL_DOUBLE_VEC3_EXT 0x8FFD #define GL_DOUBLE_VEC4_EXT 0x8FFE #define GL_DOUBLE_MAT2_EXT 0x8F46 #define GL_DOUBLE_MAT3_EXT 0x8F47 #define GL_DOUBLE_MAT4_EXT 0x8F48 #define GL_DOUBLE_MAT2x3_EXT 0x8F49 #define GL_DOUBLE_MAT2x4_EXT 0x8F4A #define GL_DOUBLE_MAT3x2_EXT 0x8F4B #define GL_DOUBLE_MAT3x4_EXT 0x8F4C #define GL_DOUBLE_MAT4x2_EXT 0x8F4D #define GL_DOUBLE_MAT4x3_EXT 0x8F4E typedef void (APIENTRYP PFNGLVERTEXATTRIBL1DEXTPROC) (GLuint index, GLdouble x); typedef void (APIENTRYP PFNGLVERTEXATTRIBL2DEXTPROC) (GLuint index, GLdouble x, GLdouble y); typedef void (APIENTRYP PFNGLVERTEXATTRIBL3DEXTPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); typedef void (APIENTRYP PFNGLVERTEXATTRIBL4DEXTPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); typedef void (APIENTRYP PFNGLVERTEXATTRIBL1DVEXTPROC) (GLuint index, const GLdouble *v); typedef void (APIENTRYP PFNGLVERTEXATTRIBL2DVEXTPROC) (GLuint index, const GLdouble *v); typedef void (APIENTRYP PFNGLVERTEXATTRIBL3DVEXTPROC) (GLuint index, const GLdouble *v); typedef void (APIENTRYP PFNGLVERTEXATTRIBL4DVEXTPROC) (GLuint index, const GLdouble *v); typedef void (APIENTRYP PFNGLVERTEXATTRIBLPOINTEREXTPROC) (GLuint index, GLint size, GLenum type, GLsizei stride, const void *pointer); typedef void (APIENTRYP PFNGLGETVERTEXATTRIBLDVEXTPROC) (GLuint index, GLenum pname, GLdouble *params); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glVertexAttribL1dEXT (GLuint index, GLdouble x); GLAPI void APIENTRY glVertexAttribL2dEXT (GLuint index, GLdouble x, GLdouble y); GLAPI void APIENTRY glVertexAttribL3dEXT (GLuint index, GLdouble x, GLdouble y, GLdouble z); GLAPI void APIENTRY glVertexAttribL4dEXT (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); GLAPI void APIENTRY glVertexAttribL1dvEXT (GLuint index, const GLdouble *v); GLAPI void APIENTRY glVertexAttribL2dvEXT (GLuint index, const GLdouble *v); GLAPI void APIENTRY glVertexAttribL3dvEXT (GLuint index, const GLdouble *v); GLAPI void APIENTRY glVertexAttribL4dvEXT (GLuint index, const GLdouble *v); GLAPI void APIENTRY glVertexAttribLPointerEXT (GLuint index, GLint size, GLenum type, GLsizei stride, const void *pointer); GLAPI void APIENTRY glGetVertexAttribLdvEXT (GLuint index, GLenum pname, GLdouble *params); #endif #endif /* GL_EXT_vertex_attrib_64bit */ #ifndef GL_EXT_vertex_shader #define GL_EXT_vertex_shader 1 #define GL_VERTEX_SHADER_EXT 0x8780 #define GL_VERTEX_SHADER_BINDING_EXT 0x8781 #define GL_OP_INDEX_EXT 0x8782 #define GL_OP_NEGATE_EXT 0x8783 #define GL_OP_DOT3_EXT 0x8784 #define GL_OP_DOT4_EXT 0x8785 #define GL_OP_MUL_EXT 0x8786 #define GL_OP_ADD_EXT 0x8787 #define GL_OP_MADD_EXT 0x8788 #define GL_OP_FRAC_EXT 0x8789 #define GL_OP_MAX_EXT 0x878A #define GL_OP_MIN_EXT 0x878B #define GL_OP_SET_GE_EXT 0x878C #define GL_OP_SET_LT_EXT 0x878D #define GL_OP_CLAMP_EXT 0x878E #define GL_OP_FLOOR_EXT 0x878F #define GL_OP_ROUND_EXT 0x8790 #define GL_OP_EXP_BASE_2_EXT 0x8791 #define GL_OP_LOG_BASE_2_EXT 0x8792 #define GL_OP_POWER_EXT 0x8793 #define GL_OP_RECIP_EXT 0x8794 #define GL_OP_RECIP_SQRT_EXT 0x8795 #define GL_OP_SUB_EXT 0x8796 #define GL_OP_CROSS_PRODUCT_EXT 0x8797 #define GL_OP_MULTIPLY_MATRIX_EXT 0x8798 #define GL_OP_MOV_EXT 0x8799 #define GL_OUTPUT_VERTEX_EXT 0x879A #define GL_OUTPUT_COLOR0_EXT 0x879B #define GL_OUTPUT_COLOR1_EXT 0x879C #define GL_OUTPUT_TEXTURE_COORD0_EXT 0x879D #define GL_OUTPUT_TEXTURE_COORD1_EXT 0x879E #define GL_OUTPUT_TEXTURE_COORD2_EXT 0x879F #define GL_OUTPUT_TEXTURE_COORD3_EXT 0x87A0 #define GL_OUTPUT_TEXTURE_COORD4_EXT 0x87A1 #define GL_OUTPUT_TEXTURE_COORD5_EXT 0x87A2 #define GL_OUTPUT_TEXTURE_COORD6_EXT 0x87A3 #define GL_OUTPUT_TEXTURE_COORD7_EXT 0x87A4 #define GL_OUTPUT_TEXTURE_COORD8_EXT 0x87A5 #define GL_OUTPUT_TEXTURE_COORD9_EXT 0x87A6 #define GL_OUTPUT_TEXTURE_COORD10_EXT 0x87A7 #define GL_OUTPUT_TEXTURE_COORD11_EXT 0x87A8 #define GL_OUTPUT_TEXTURE_COORD12_EXT 0x87A9 #define GL_OUTPUT_TEXTURE_COORD13_EXT 0x87AA #define GL_OUTPUT_TEXTURE_COORD14_EXT 0x87AB #define GL_OUTPUT_TEXTURE_COORD15_EXT 0x87AC #define GL_OUTPUT_TEXTURE_COORD16_EXT 0x87AD #define GL_OUTPUT_TEXTURE_COORD17_EXT 0x87AE #define GL_OUTPUT_TEXTURE_COORD18_EXT 0x87AF #define GL_OUTPUT_TEXTURE_COORD19_EXT 0x87B0 #define GL_OUTPUT_TEXTURE_COORD20_EXT 0x87B1 #define GL_OUTPUT_TEXTURE_COORD21_EXT 0x87B2 #define GL_OUTPUT_TEXTURE_COORD22_EXT 0x87B3 #define GL_OUTPUT_TEXTURE_COORD23_EXT 0x87B4 #define GL_OUTPUT_TEXTURE_COORD24_EXT 0x87B5 #define GL_OUTPUT_TEXTURE_COORD25_EXT 0x87B6 #define GL_OUTPUT_TEXTURE_COORD26_EXT 0x87B7 #define GL_OUTPUT_TEXTURE_COORD27_EXT 0x87B8 #define GL_OUTPUT_TEXTURE_COORD28_EXT 0x87B9 #define GL_OUTPUT_TEXTURE_COORD29_EXT 0x87BA #define GL_OUTPUT_TEXTURE_COORD30_EXT 0x87BB #define GL_OUTPUT_TEXTURE_COORD31_EXT 0x87BC #define GL_OUTPUT_FOG_EXT 0x87BD #define GL_SCALAR_EXT 0x87BE #define GL_VECTOR_EXT 0x87BF #define GL_MATRIX_EXT 0x87C0 #define GL_VARIANT_EXT 0x87C1 #define GL_INVARIANT_EXT 0x87C2 #define GL_LOCAL_CONSTANT_EXT 0x87C3 #define GL_LOCAL_EXT 0x87C4 #define GL_MAX_VERTEX_SHADER_INSTRUCTIONS_EXT 0x87C5 #define GL_MAX_VERTEX_SHADER_VARIANTS_EXT 0x87C6 #define GL_MAX_VERTEX_SHADER_INVARIANTS_EXT 0x87C7 #define GL_MAX_VERTEX_SHADER_LOCAL_CONSTANTS_EXT 0x87C8 #define GL_MAX_VERTEX_SHADER_LOCALS_EXT 0x87C9 #define GL_MAX_OPTIMIZED_VERTEX_SHADER_INSTRUCTIONS_EXT 0x87CA #define GL_MAX_OPTIMIZED_VERTEX_SHADER_VARIANTS_EXT 0x87CB #define GL_MAX_OPTIMIZED_VERTEX_SHADER_LOCAL_CONSTANTS_EXT 0x87CC #define GL_MAX_OPTIMIZED_VERTEX_SHADER_INVARIANTS_EXT 0x87CD #define GL_MAX_OPTIMIZED_VERTEX_SHADER_LOCALS_EXT 0x87CE #define GL_VERTEX_SHADER_INSTRUCTIONS_EXT 0x87CF #define GL_VERTEX_SHADER_VARIANTS_EXT 0x87D0 #define GL_VERTEX_SHADER_INVARIANTS_EXT 0x87D1 #define GL_VERTEX_SHADER_LOCAL_CONSTANTS_EXT 0x87D2 #define GL_VERTEX_SHADER_LOCALS_EXT 0x87D3 #define GL_VERTEX_SHADER_OPTIMIZED_EXT 0x87D4 #define GL_X_EXT 0x87D5 #define GL_Y_EXT 0x87D6 #define GL_Z_EXT 0x87D7 #define GL_W_EXT 0x87D8 #define GL_NEGATIVE_X_EXT 0x87D9 #define GL_NEGATIVE_Y_EXT 0x87DA #define GL_NEGATIVE_Z_EXT 0x87DB #define GL_NEGATIVE_W_EXT 0x87DC #define GL_ZERO_EXT 0x87DD #define GL_ONE_EXT 0x87DE #define GL_NEGATIVE_ONE_EXT 0x87DF #define GL_NORMALIZED_RANGE_EXT 0x87E0 #define GL_FULL_RANGE_EXT 0x87E1 #define GL_CURRENT_VERTEX_EXT 0x87E2 #define GL_MVP_MATRIX_EXT 0x87E3 #define GL_VARIANT_VALUE_EXT 0x87E4 #define GL_VARIANT_DATATYPE_EXT 0x87E5 #define GL_VARIANT_ARRAY_STRIDE_EXT 0x87E6 #define GL_VARIANT_ARRAY_TYPE_EXT 0x87E7 #define GL_VARIANT_ARRAY_EXT 0x87E8 #define GL_VARIANT_ARRAY_POINTER_EXT 0x87E9 #define GL_INVARIANT_VALUE_EXT 0x87EA #define GL_INVARIANT_DATATYPE_EXT 0x87EB #define GL_LOCAL_CONSTANT_VALUE_EXT 0x87EC #define GL_LOCAL_CONSTANT_DATATYPE_EXT 0x87ED typedef void (APIENTRYP PFNGLBEGINVERTEXSHADEREXTPROC) (void); typedef void (APIENTRYP PFNGLENDVERTEXSHADEREXTPROC) (void); typedef void (APIENTRYP PFNGLBINDVERTEXSHADEREXTPROC) (GLuint id); typedef GLuint (APIENTRYP PFNGLGENVERTEXSHADERSEXTPROC) (GLuint range); typedef void (APIENTRYP PFNGLDELETEVERTEXSHADEREXTPROC) (GLuint id); typedef void (APIENTRYP PFNGLSHADEROP1EXTPROC) (GLenum op, GLuint res, GLuint arg1); typedef void (APIENTRYP PFNGLSHADEROP2EXTPROC) (GLenum op, GLuint res, GLuint arg1, GLuint arg2); typedef void (APIENTRYP PFNGLSHADEROP3EXTPROC) (GLenum op, GLuint res, GLuint arg1, GLuint arg2, GLuint arg3); typedef void (APIENTRYP PFNGLSWIZZLEEXTPROC) (GLuint res, GLuint in, GLenum outX, GLenum outY, GLenum outZ, GLenum outW); typedef void (APIENTRYP PFNGLWRITEMASKEXTPROC) (GLuint res, GLuint in, GLenum outX, GLenum outY, GLenum outZ, GLenum outW); typedef void (APIENTRYP PFNGLINSERTCOMPONENTEXTPROC) (GLuint res, GLuint src, GLuint num); typedef void (APIENTRYP PFNGLEXTRACTCOMPONENTEXTPROC) (GLuint res, GLuint src, GLuint num); typedef GLuint (APIENTRYP PFNGLGENSYMBOLSEXTPROC) (GLenum datatype, GLenum storagetype, GLenum range, GLuint components); typedef void (APIENTRYP PFNGLSETINVARIANTEXTPROC) (GLuint id, GLenum type, const void *addr); typedef void (APIENTRYP PFNGLSETLOCALCONSTANTEXTPROC) (GLuint id, GLenum type, const void *addr); typedef void (APIENTRYP PFNGLVARIANTBVEXTPROC) (GLuint id, const GLbyte *addr); typedef void (APIENTRYP PFNGLVARIANTSVEXTPROC) (GLuint id, const GLshort *addr); typedef void (APIENTRYP PFNGLVARIANTIVEXTPROC) (GLuint id, const GLint *addr); typedef void (APIENTRYP PFNGLVARIANTFVEXTPROC) (GLuint id, const GLfloat *addr); typedef void (APIENTRYP PFNGLVARIANTDVEXTPROC) (GLuint id, const GLdouble *addr); typedef void (APIENTRYP PFNGLVARIANTUBVEXTPROC) (GLuint id, const GLubyte *addr); typedef void (APIENTRYP PFNGLVARIANTUSVEXTPROC) (GLuint id, const GLushort *addr); typedef void (APIENTRYP PFNGLVARIANTUIVEXTPROC) (GLuint id, const GLuint *addr); typedef void (APIENTRYP PFNGLVARIANTPOINTEREXTPROC) (GLuint id, GLenum type, GLuint stride, const void *addr); typedef void (APIENTRYP PFNGLENABLEVARIANTCLIENTSTATEEXTPROC) (GLuint id); typedef void (APIENTRYP PFNGLDISABLEVARIANTCLIENTSTATEEXTPROC) (GLuint id); typedef GLuint (APIENTRYP PFNGLBINDLIGHTPARAMETEREXTPROC) (GLenum light, GLenum value); typedef GLuint (APIENTRYP PFNGLBINDMATERIALPARAMETEREXTPROC) (GLenum face, GLenum value); typedef GLuint (APIENTRYP PFNGLBINDTEXGENPARAMETEREXTPROC) (GLenum unit, GLenum coord, GLenum value); typedef GLuint (APIENTRYP PFNGLBINDTEXTUREUNITPARAMETEREXTPROC) (GLenum unit, GLenum value); typedef GLuint (APIENTRYP PFNGLBINDPARAMETEREXTPROC) (GLenum value); typedef GLboolean (APIENTRYP PFNGLISVARIANTENABLEDEXTPROC) (GLuint id, GLenum cap); typedef void (APIENTRYP PFNGLGETVARIANTBOOLEANVEXTPROC) (GLuint id, GLenum value, GLboolean *data); typedef void (APIENTRYP PFNGLGETVARIANTINTEGERVEXTPROC) (GLuint id, GLenum value, GLint *data); typedef void (APIENTRYP PFNGLGETVARIANTFLOATVEXTPROC) (GLuint id, GLenum value, GLfloat *data); typedef void (APIENTRYP PFNGLGETVARIANTPOINTERVEXTPROC) (GLuint id, GLenum value, void **data); typedef void (APIENTRYP PFNGLGETINVARIANTBOOLEANVEXTPROC) (GLuint id, GLenum value, GLboolean *data); typedef void (APIENTRYP PFNGLGETINVARIANTINTEGERVEXTPROC) (GLuint id, GLenum value, GLint *data); typedef void (APIENTRYP PFNGLGETINVARIANTFLOATVEXTPROC) (GLuint id, GLenum value, GLfloat *data); typedef void (APIENTRYP PFNGLGETLOCALCONSTANTBOOLEANVEXTPROC) (GLuint id, GLenum value, GLboolean *data); typedef void (APIENTRYP PFNGLGETLOCALCONSTANTINTEGERVEXTPROC) (GLuint id, GLenum value, GLint *data); typedef void (APIENTRYP PFNGLGETLOCALCONSTANTFLOATVEXTPROC) (GLuint id, GLenum value, GLfloat *data); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glBeginVertexShaderEXT (void); GLAPI void APIENTRY glEndVertexShaderEXT (void); GLAPI void APIENTRY glBindVertexShaderEXT (GLuint id); GLAPI GLuint APIENTRY glGenVertexShadersEXT (GLuint range); GLAPI void APIENTRY glDeleteVertexShaderEXT (GLuint id); GLAPI void APIENTRY glShaderOp1EXT (GLenum op, GLuint res, GLuint arg1); GLAPI void APIENTRY glShaderOp2EXT (GLenum op, GLuint res, GLuint arg1, GLuint arg2); GLAPI void APIENTRY glShaderOp3EXT (GLenum op, GLuint res, GLuint arg1, GLuint arg2, GLuint arg3); GLAPI void APIENTRY glSwizzleEXT (GLuint res, GLuint in, GLenum outX, GLenum outY, GLenum outZ, GLenum outW); GLAPI void APIENTRY glWriteMaskEXT (GLuint res, GLuint in, GLenum outX, GLenum outY, GLenum outZ, GLenum outW); GLAPI void APIENTRY glInsertComponentEXT (GLuint res, GLuint src, GLuint num); GLAPI void APIENTRY glExtractComponentEXT (GLuint res, GLuint src, GLuint num); GLAPI GLuint APIENTRY glGenSymbolsEXT (GLenum datatype, GLenum storagetype, GLenum range, GLuint components); GLAPI void APIENTRY glSetInvariantEXT (GLuint id, GLenum type, const void *addr); GLAPI void APIENTRY glSetLocalConstantEXT (GLuint id, GLenum type, const void *addr); GLAPI void APIENTRY glVariantbvEXT (GLuint id, const GLbyte *addr); GLAPI void APIENTRY glVariantsvEXT (GLuint id, const GLshort *addr); GLAPI void APIENTRY glVariantivEXT (GLuint id, const GLint *addr); GLAPI void APIENTRY glVariantfvEXT (GLuint id, const GLfloat *addr); GLAPI void APIENTRY glVariantdvEXT (GLuint id, const GLdouble *addr); GLAPI void APIENTRY glVariantubvEXT (GLuint id, const GLubyte *addr); GLAPI void APIENTRY glVariantusvEXT (GLuint id, const GLushort *addr); GLAPI void APIENTRY glVariantuivEXT (GLuint id, const GLuint *addr); GLAPI void APIENTRY glVariantPointerEXT (GLuint id, GLenum type, GLuint stride, const void *addr); GLAPI void APIENTRY glEnableVariantClientStateEXT (GLuint id); GLAPI void APIENTRY glDisableVariantClientStateEXT (GLuint id); GLAPI GLuint APIENTRY glBindLightParameterEXT (GLenum light, GLenum value); GLAPI GLuint APIENTRY glBindMaterialParameterEXT (GLenum face, GLenum value); GLAPI GLuint APIENTRY glBindTexGenParameterEXT (GLenum unit, GLenum coord, GLenum value); GLAPI GLuint APIENTRY glBindTextureUnitParameterEXT (GLenum unit, GLenum value); GLAPI GLuint APIENTRY glBindParameterEXT (GLenum value); GLAPI GLboolean APIENTRY glIsVariantEnabledEXT (GLuint id, GLenum cap); GLAPI void APIENTRY glGetVariantBooleanvEXT (GLuint id, GLenum value, GLboolean *data); GLAPI void APIENTRY glGetVariantIntegervEXT (GLuint id, GLenum value, GLint *data); GLAPI void APIENTRY glGetVariantFloatvEXT (GLuint id, GLenum value, GLfloat *data); GLAPI void APIENTRY glGetVariantPointervEXT (GLuint id, GLenum value, void **data); GLAPI void APIENTRY glGetInvariantBooleanvEXT (GLuint id, GLenum value, GLboolean *data); GLAPI void APIENTRY glGetInvariantIntegervEXT (GLuint id, GLenum value, GLint *data); GLAPI void APIENTRY glGetInvariantFloatvEXT (GLuint id, GLenum value, GLfloat *data); GLAPI void APIENTRY glGetLocalConstantBooleanvEXT (GLuint id, GLenum value, GLboolean *data); GLAPI void APIENTRY glGetLocalConstantIntegervEXT (GLuint id, GLenum value, GLint *data); GLAPI void APIENTRY glGetLocalConstantFloatvEXT (GLuint id, GLenum value, GLfloat *data); #endif #endif /* GL_EXT_vertex_shader */ #ifndef GL_EXT_vertex_weighting #define GL_EXT_vertex_weighting 1 #define GL_MODELVIEW0_STACK_DEPTH_EXT 0x0BA3 #define GL_MODELVIEW1_STACK_DEPTH_EXT 0x8502 #define GL_MODELVIEW0_MATRIX_EXT 0x0BA6 #define GL_MODELVIEW1_MATRIX_EXT 0x8506 #define GL_VERTEX_WEIGHTING_EXT 0x8509 #define GL_MODELVIEW0_EXT 0x1700 #define GL_MODELVIEW1_EXT 0x850A #define GL_CURRENT_VERTEX_WEIGHT_EXT 0x850B #define GL_VERTEX_WEIGHT_ARRAY_EXT 0x850C #define GL_VERTEX_WEIGHT_ARRAY_SIZE_EXT 0x850D #define GL_VERTEX_WEIGHT_ARRAY_TYPE_EXT 0x850E #define GL_VERTEX_WEIGHT_ARRAY_STRIDE_EXT 0x850F #define GL_VERTEX_WEIGHT_ARRAY_POINTER_EXT 0x8510 typedef void (APIENTRYP PFNGLVERTEXWEIGHTFEXTPROC) (GLfloat weight); typedef void (APIENTRYP PFNGLVERTEXWEIGHTFVEXTPROC) (const GLfloat *weight); typedef void (APIENTRYP PFNGLVERTEXWEIGHTPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, const void *pointer); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glVertexWeightfEXT (GLfloat weight); GLAPI void APIENTRY glVertexWeightfvEXT (const GLfloat *weight); GLAPI void APIENTRY glVertexWeightPointerEXT (GLint size, GLenum type, GLsizei stride, const void *pointer); #endif #endif /* GL_EXT_vertex_weighting */ #ifndef GL_EXT_win32_keyed_mutex #define GL_EXT_win32_keyed_mutex 1 typedef GLboolean (APIENTRYP PFNGLACQUIREKEYEDMUTEXWIN32EXTPROC) (GLuint memory, GLuint64 key, GLuint timeout); typedef GLboolean (APIENTRYP PFNGLRELEASEKEYEDMUTEXWIN32EXTPROC) (GLuint memory, GLuint64 key); #ifdef GL_GLEXT_PROTOTYPES GLAPI GLboolean APIENTRY glAcquireKeyedMutexWin32EXT (GLuint memory, GLuint64 key, GLuint timeout); GLAPI GLboolean APIENTRY glReleaseKeyedMutexWin32EXT (GLuint memory, GLuint64 key); #endif #endif /* GL_EXT_win32_keyed_mutex */ #ifndef GL_EXT_window_rectangles #define GL_EXT_window_rectangles 1 #define GL_INCLUSIVE_EXT 0x8F10 #define GL_EXCLUSIVE_EXT 0x8F11 #define GL_WINDOW_RECTANGLE_EXT 0x8F12 #define GL_WINDOW_RECTANGLE_MODE_EXT 0x8F13 #define GL_MAX_WINDOW_RECTANGLES_EXT 0x8F14 #define GL_NUM_WINDOW_RECTANGLES_EXT 0x8F15 typedef void (APIENTRYP PFNGLWINDOWRECTANGLESEXTPROC) (GLenum mode, GLsizei count, const GLint *box); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glWindowRectanglesEXT (GLenum mode, GLsizei count, const GLint *box); #endif #endif /* GL_EXT_window_rectangles */ #ifndef GL_EXT_x11_sync_object #define GL_EXT_x11_sync_object 1 #define GL_SYNC_X11_FENCE_EXT 0x90E1 typedef GLsync (APIENTRYP PFNGLIMPORTSYNCEXTPROC) (GLenum external_sync_type, GLintptr external_sync, GLbitfield flags); #ifdef GL_GLEXT_PROTOTYPES GLAPI GLsync APIENTRY glImportSyncEXT (GLenum external_sync_type, GLintptr external_sync, GLbitfield flags); #endif #endif /* GL_EXT_x11_sync_object */ #ifndef GL_GREMEDY_frame_terminator #define GL_GREMEDY_frame_terminator 1 typedef void (APIENTRYP PFNGLFRAMETERMINATORGREMEDYPROC) (void); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glFrameTerminatorGREMEDY (void); #endif #endif /* GL_GREMEDY_frame_terminator */ #ifndef GL_GREMEDY_string_marker #define GL_GREMEDY_string_marker 1 typedef void (APIENTRYP PFNGLSTRINGMARKERGREMEDYPROC) (GLsizei len, const void *string); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glStringMarkerGREMEDY (GLsizei len, const void *string); #endif #endif /* GL_GREMEDY_string_marker */ #ifndef GL_HP_convolution_border_modes #define GL_HP_convolution_border_modes 1 #define GL_IGNORE_BORDER_HP 0x8150 #define GL_CONSTANT_BORDER_HP 0x8151 #define GL_REPLICATE_BORDER_HP 0x8153 #define GL_CONVOLUTION_BORDER_COLOR_HP 0x8154 #endif /* GL_HP_convolution_border_modes */ #ifndef GL_HP_image_transform #define GL_HP_image_transform 1 #define GL_IMAGE_SCALE_X_HP 0x8155 #define GL_IMAGE_SCALE_Y_HP 0x8156 #define GL_IMAGE_TRANSLATE_X_HP 0x8157 #define GL_IMAGE_TRANSLATE_Y_HP 0x8158 #define GL_IMAGE_ROTATE_ANGLE_HP 0x8159 #define GL_IMAGE_ROTATE_ORIGIN_X_HP 0x815A #define GL_IMAGE_ROTATE_ORIGIN_Y_HP 0x815B #define GL_IMAGE_MAG_FILTER_HP 0x815C #define GL_IMAGE_MIN_FILTER_HP 0x815D #define GL_IMAGE_CUBIC_WEIGHT_HP 0x815E #define GL_CUBIC_HP 0x815F #define GL_AVERAGE_HP 0x8160 #define GL_IMAGE_TRANSFORM_2D_HP 0x8161 #define GL_POST_IMAGE_TRANSFORM_COLOR_TABLE_HP 0x8162 #define GL_PROXY_POST_IMAGE_TRANSFORM_COLOR_TABLE_HP 0x8163 typedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERIHPPROC) (GLenum target, GLenum pname, GLint param); typedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERFHPPROC) (GLenum target, GLenum pname, GLfloat param); typedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERIVHPPROC) (GLenum target, GLenum pname, const GLint *params); typedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERFVHPPROC) (GLenum target, GLenum pname, const GLfloat *params); typedef void (APIENTRYP PFNGLGETIMAGETRANSFORMPARAMETERIVHPPROC) (GLenum target, GLenum pname, GLint *params); typedef void (APIENTRYP PFNGLGETIMAGETRANSFORMPARAMETERFVHPPROC) (GLenum target, GLenum pname, GLfloat *params); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glImageTransformParameteriHP (GLenum target, GLenum pname, GLint param); GLAPI void APIENTRY glImageTransformParameterfHP (GLenum target, GLenum pname, GLfloat param); GLAPI void APIENTRY glImageTransformParameterivHP (GLenum target, GLenum pname, const GLint *params); GLAPI void APIENTRY glImageTransformParameterfvHP (GLenum target, GLenum pname, const GLfloat *params); GLAPI void APIENTRY glGetImageTransformParameterivHP (GLenum target, GLenum pname, GLint *params); GLAPI void APIENTRY glGetImageTransformParameterfvHP (GLenum target, GLenum pname, GLfloat *params); #endif #endif /* GL_HP_image_transform */ #ifndef GL_HP_occlusion_test #define GL_HP_occlusion_test 1 #define GL_OCCLUSION_TEST_HP 0x8165 #define GL_OCCLUSION_TEST_RESULT_HP 0x8166 #endif /* GL_HP_occlusion_test */ #ifndef GL_HP_texture_lighting #define GL_HP_texture_lighting 1 #define GL_TEXTURE_LIGHTING_MODE_HP 0x8167 #define GL_TEXTURE_POST_SPECULAR_HP 0x8168 #define GL_TEXTURE_PRE_SPECULAR_HP 0x8169 #endif /* GL_HP_texture_lighting */ #ifndef GL_IBM_cull_vertex #define GL_IBM_cull_vertex 1 #define GL_CULL_VERTEX_IBM 103050 #endif /* GL_IBM_cull_vertex */ #ifndef GL_IBM_multimode_draw_arrays #define GL_IBM_multimode_draw_arrays 1 typedef void (APIENTRYP PFNGLMULTIMODEDRAWARRAYSIBMPROC) (const GLenum *mode, const GLint *first, const GLsizei *count, GLsizei primcount, GLint modestride); typedef void (APIENTRYP PFNGLMULTIMODEDRAWELEMENTSIBMPROC) (const GLenum *mode, const GLsizei *count, GLenum type, const void *const*indices, GLsizei primcount, GLint modestride); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glMultiModeDrawArraysIBM (const GLenum *mode, const GLint *first, const GLsizei *count, GLsizei primcount, GLint modestride); GLAPI void APIENTRY glMultiModeDrawElementsIBM (const GLenum *mode, const GLsizei *count, GLenum type, const void *const*indices, GLsizei primcount, GLint modestride); #endif #endif /* GL_IBM_multimode_draw_arrays */ #ifndef GL_IBM_rasterpos_clip #define GL_IBM_rasterpos_clip 1 #define GL_RASTER_POSITION_UNCLIPPED_IBM 0x19262 #endif /* GL_IBM_rasterpos_clip */ #ifndef GL_IBM_static_data #define GL_IBM_static_data 1 #define GL_ALL_STATIC_DATA_IBM 103060 #define GL_STATIC_VERTEX_ARRAY_IBM 103061 typedef void (APIENTRYP PFNGLFLUSHSTATICDATAIBMPROC) (GLenum target); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glFlushStaticDataIBM (GLenum target); #endif #endif /* GL_IBM_static_data */ #ifndef GL_IBM_texture_mirrored_repeat #define GL_IBM_texture_mirrored_repeat 1 #define GL_MIRRORED_REPEAT_IBM 0x8370 #endif /* GL_IBM_texture_mirrored_repeat */ #ifndef GL_IBM_vertex_array_lists #define GL_IBM_vertex_array_lists 1 #define GL_VERTEX_ARRAY_LIST_IBM 103070 #define GL_NORMAL_ARRAY_LIST_IBM 103071 #define GL_COLOR_ARRAY_LIST_IBM 103072 #define GL_INDEX_ARRAY_LIST_IBM 103073 #define GL_TEXTURE_COORD_ARRAY_LIST_IBM 103074 #define GL_EDGE_FLAG_ARRAY_LIST_IBM 103075 #define GL_FOG_COORDINATE_ARRAY_LIST_IBM 103076 #define GL_SECONDARY_COLOR_ARRAY_LIST_IBM 103077 #define GL_VERTEX_ARRAY_LIST_STRIDE_IBM 103080 #define GL_NORMAL_ARRAY_LIST_STRIDE_IBM 103081 #define GL_COLOR_ARRAY_LIST_STRIDE_IBM 103082 #define GL_INDEX_ARRAY_LIST_STRIDE_IBM 103083 #define GL_TEXTURE_COORD_ARRAY_LIST_STRIDE_IBM 103084 #define GL_EDGE_FLAG_ARRAY_LIST_STRIDE_IBM 103085 #define GL_FOG_COORDINATE_ARRAY_LIST_STRIDE_IBM 103086 #define GL_SECONDARY_COLOR_ARRAY_LIST_STRIDE_IBM 103087 typedef void (APIENTRYP PFNGLCOLORPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const void **pointer, GLint ptrstride); typedef void (APIENTRYP PFNGLSECONDARYCOLORPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const void **pointer, GLint ptrstride); typedef void (APIENTRYP PFNGLEDGEFLAGPOINTERLISTIBMPROC) (GLint stride, const GLboolean **pointer, GLint ptrstride); typedef void (APIENTRYP PFNGLFOGCOORDPOINTERLISTIBMPROC) (GLenum type, GLint stride, const void **pointer, GLint ptrstride); typedef void (APIENTRYP PFNGLINDEXPOINTERLISTIBMPROC) (GLenum type, GLint stride, const void **pointer, GLint ptrstride); typedef void (APIENTRYP PFNGLNORMALPOINTERLISTIBMPROC) (GLenum type, GLint stride, const void **pointer, GLint ptrstride); typedef void (APIENTRYP PFNGLTEXCOORDPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const void **pointer, GLint ptrstride); typedef void (APIENTRYP PFNGLVERTEXPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const void **pointer, GLint ptrstride); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glColorPointerListIBM (GLint size, GLenum type, GLint stride, const void **pointer, GLint ptrstride); GLAPI void APIENTRY glSecondaryColorPointerListIBM (GLint size, GLenum type, GLint stride, const void **pointer, GLint ptrstride); GLAPI void APIENTRY glEdgeFlagPointerListIBM (GLint stride, const GLboolean **pointer, GLint ptrstride); GLAPI void APIENTRY glFogCoordPointerListIBM (GLenum type, GLint stride, const void **pointer, GLint ptrstride); GLAPI void APIENTRY glIndexPointerListIBM (GLenum type, GLint stride, const void **pointer, GLint ptrstride); GLAPI void APIENTRY glNormalPointerListIBM (GLenum type, GLint stride, const void **pointer, GLint ptrstride); GLAPI void APIENTRY glTexCoordPointerListIBM (GLint size, GLenum type, GLint stride, const void **pointer, GLint ptrstride); GLAPI void APIENTRY glVertexPointerListIBM (GLint size, GLenum type, GLint stride, const void **pointer, GLint ptrstride); #endif #endif /* GL_IBM_vertex_array_lists */ #ifndef GL_INGR_blend_func_separate #define GL_INGR_blend_func_separate 1 typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEINGRPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glBlendFuncSeparateINGR (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); #endif #endif /* GL_INGR_blend_func_separate */ #ifndef GL_INGR_color_clamp #define GL_INGR_color_clamp 1 #define GL_RED_MIN_CLAMP_INGR 0x8560 #define GL_GREEN_MIN_CLAMP_INGR 0x8561 #define GL_BLUE_MIN_CLAMP_INGR 0x8562 #define GL_ALPHA_MIN_CLAMP_INGR 0x8563 #define GL_RED_MAX_CLAMP_INGR 0x8564 #define GL_GREEN_MAX_CLAMP_INGR 0x8565 #define GL_BLUE_MAX_CLAMP_INGR 0x8566 #define GL_ALPHA_MAX_CLAMP_INGR 0x8567 #endif /* GL_INGR_color_clamp */ #ifndef GL_INGR_interlace_read #define GL_INGR_interlace_read 1 #define GL_INTERLACE_READ_INGR 0x8568 #endif /* GL_INGR_interlace_read */ #ifndef GL_INTEL_blackhole_render #define GL_INTEL_blackhole_render 1 #define GL_BLACKHOLE_RENDER_INTEL 0x83FC #endif /* GL_INTEL_blackhole_render */ #ifndef GL_INTEL_conservative_rasterization #define GL_INTEL_conservative_rasterization 1 #define GL_CONSERVATIVE_RASTERIZATION_INTEL 0x83FE #endif /* GL_INTEL_conservative_rasterization */ #ifndef GL_INTEL_fragment_shader_ordering #define GL_INTEL_fragment_shader_ordering 1 #endif /* GL_INTEL_fragment_shader_ordering */ #ifndef GL_INTEL_framebuffer_CMAA #define GL_INTEL_framebuffer_CMAA 1 typedef void (APIENTRYP PFNGLAPPLYFRAMEBUFFERATTACHMENTCMAAINTELPROC) (void); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glApplyFramebufferAttachmentCMAAINTEL (void); #endif #endif /* GL_INTEL_framebuffer_CMAA */ #ifndef GL_INTEL_map_texture #define GL_INTEL_map_texture 1 #define GL_TEXTURE_MEMORY_LAYOUT_INTEL 0x83FF #define GL_LAYOUT_DEFAULT_INTEL 0 #define GL_LAYOUT_LINEAR_INTEL 1 #define GL_LAYOUT_LINEAR_CPU_CACHED_INTEL 2 typedef void (APIENTRYP PFNGLSYNCTEXTUREINTELPROC) (GLuint texture); typedef void (APIENTRYP PFNGLUNMAPTEXTURE2DINTELPROC) (GLuint texture, GLint level); typedef void *(APIENTRYP PFNGLMAPTEXTURE2DINTELPROC) (GLuint texture, GLint level, GLbitfield access, GLint *stride, GLenum *layout); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glSyncTextureINTEL (GLuint texture); GLAPI void APIENTRY glUnmapTexture2DINTEL (GLuint texture, GLint level); GLAPI void *APIENTRY glMapTexture2DINTEL (GLuint texture, GLint level, GLbitfield access, GLint *stride, GLenum *layout); #endif #endif /* GL_INTEL_map_texture */ #ifndef GL_INTEL_parallel_arrays #define GL_INTEL_parallel_arrays 1 #define GL_PARALLEL_ARRAYS_INTEL 0x83F4 #define GL_VERTEX_ARRAY_PARALLEL_POINTERS_INTEL 0x83F5 #define GL_NORMAL_ARRAY_PARALLEL_POINTERS_INTEL 0x83F6 #define GL_COLOR_ARRAY_PARALLEL_POINTERS_INTEL 0x83F7 #define GL_TEXTURE_COORD_ARRAY_PARALLEL_POINTERS_INTEL 0x83F8 typedef void (APIENTRYP PFNGLVERTEXPOINTERVINTELPROC) (GLint size, GLenum type, const void **pointer); typedef void (APIENTRYP PFNGLNORMALPOINTERVINTELPROC) (GLenum type, const void **pointer); typedef void (APIENTRYP PFNGLCOLORPOINTERVINTELPROC) (GLint size, GLenum type, const void **pointer); typedef void (APIENTRYP PFNGLTEXCOORDPOINTERVINTELPROC) (GLint size, GLenum type, const void **pointer); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glVertexPointervINTEL (GLint size, GLenum type, const void **pointer); GLAPI void APIENTRY glNormalPointervINTEL (GLenum type, const void **pointer); GLAPI void APIENTRY glColorPointervINTEL (GLint size, GLenum type, const void **pointer); GLAPI void APIENTRY glTexCoordPointervINTEL (GLint size, GLenum type, const void **pointer); #endif #endif /* GL_INTEL_parallel_arrays */ #ifndef GL_INTEL_performance_query #define GL_INTEL_performance_query 1 #define GL_PERFQUERY_SINGLE_CONTEXT_INTEL 0x00000000 #define GL_PERFQUERY_GLOBAL_CONTEXT_INTEL 0x00000001 #define GL_PERFQUERY_WAIT_INTEL 0x83FB #define GL_PERFQUERY_FLUSH_INTEL 0x83FA #define GL_PERFQUERY_DONOT_FLUSH_INTEL 0x83F9 #define GL_PERFQUERY_COUNTER_EVENT_INTEL 0x94F0 #define GL_PERFQUERY_COUNTER_DURATION_NORM_INTEL 0x94F1 #define GL_PERFQUERY_COUNTER_DURATION_RAW_INTEL 0x94F2 #define GL_PERFQUERY_COUNTER_THROUGHPUT_INTEL 0x94F3 #define GL_PERFQUERY_COUNTER_RAW_INTEL 0x94F4 #define GL_PERFQUERY_COUNTER_TIMESTAMP_INTEL 0x94F5 #define GL_PERFQUERY_COUNTER_DATA_UINT32_INTEL 0x94F8 #define GL_PERFQUERY_COUNTER_DATA_UINT64_INTEL 0x94F9 #define GL_PERFQUERY_COUNTER_DATA_FLOAT_INTEL 0x94FA #define GL_PERFQUERY_COUNTER_DATA_DOUBLE_INTEL 0x94FB #define GL_PERFQUERY_COUNTER_DATA_BOOL32_INTEL 0x94FC #define GL_PERFQUERY_QUERY_NAME_LENGTH_MAX_INTEL 0x94FD #define GL_PERFQUERY_COUNTER_NAME_LENGTH_MAX_INTEL 0x94FE #define GL_PERFQUERY_COUNTER_DESC_LENGTH_MAX_INTEL 0x94FF #define GL_PERFQUERY_GPA_EXTENDED_COUNTERS_INTEL 0x9500 typedef void (APIENTRYP PFNGLBEGINPERFQUERYINTELPROC) (GLuint queryHandle); typedef void (APIENTRYP PFNGLCREATEPERFQUERYINTELPROC) (GLuint queryId, GLuint *queryHandle); typedef void (APIENTRYP PFNGLDELETEPERFQUERYINTELPROC) (GLuint queryHandle); typedef void (APIENTRYP PFNGLENDPERFQUERYINTELPROC) (GLuint queryHandle); typedef void (APIENTRYP PFNGLGETFIRSTPERFQUERYIDINTELPROC) (GLuint *queryId); typedef void (APIENTRYP PFNGLGETNEXTPERFQUERYIDINTELPROC) (GLuint queryId, GLuint *nextQueryId); typedef void (APIENTRYP PFNGLGETPERFCOUNTERINFOINTELPROC) (GLuint queryId, GLuint counterId, GLuint counterNameLength, GLchar *counterName, GLuint counterDescLength, GLchar *counterDesc, GLuint *counterOffset, GLuint *counterDataSize, GLuint *counterTypeEnum, GLuint *counterDataTypeEnum, GLuint64 *rawCounterMaxValue); typedef void (APIENTRYP PFNGLGETPERFQUERYDATAINTELPROC) (GLuint queryHandle, GLuint flags, GLsizei dataSize, void *data, GLuint *bytesWritten); typedef void (APIENTRYP PFNGLGETPERFQUERYIDBYNAMEINTELPROC) (GLchar *queryName, GLuint *queryId); typedef void (APIENTRYP PFNGLGETPERFQUERYINFOINTELPROC) (GLuint queryId, GLuint queryNameLength, GLchar *queryName, GLuint *dataSize, GLuint *noCounters, GLuint *noInstances, GLuint *capsMask); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glBeginPerfQueryINTEL (GLuint queryHandle); GLAPI void APIENTRY glCreatePerfQueryINTEL (GLuint queryId, GLuint *queryHandle); GLAPI void APIENTRY glDeletePerfQueryINTEL (GLuint queryHandle); GLAPI void APIENTRY glEndPerfQueryINTEL (GLuint queryHandle); GLAPI void APIENTRY glGetFirstPerfQueryIdINTEL (GLuint *queryId); GLAPI void APIENTRY glGetNextPerfQueryIdINTEL (GLuint queryId, GLuint *nextQueryId); GLAPI void APIENTRY glGetPerfCounterInfoINTEL (GLuint queryId, GLuint counterId, GLuint counterNameLength, GLchar *counterName, GLuint counterDescLength, GLchar *counterDesc, GLuint *counterOffset, GLuint *counterDataSize, GLuint *counterTypeEnum, GLuint *counterDataTypeEnum, GLuint64 *rawCounterMaxValue); GLAPI void APIENTRY glGetPerfQueryDataINTEL (GLuint queryHandle, GLuint flags, GLsizei dataSize, void *data, GLuint *bytesWritten); GLAPI void APIENTRY glGetPerfQueryIdByNameINTEL (GLchar *queryName, GLuint *queryId); GLAPI void APIENTRY glGetPerfQueryInfoINTEL (GLuint queryId, GLuint queryNameLength, GLchar *queryName, GLuint *dataSize, GLuint *noCounters, GLuint *noInstances, GLuint *capsMask); #endif #endif /* GL_INTEL_performance_query */ #ifndef GL_MESAX_texture_stack #define GL_MESAX_texture_stack 1 #define GL_TEXTURE_1D_STACK_MESAX 0x8759 #define GL_TEXTURE_2D_STACK_MESAX 0x875A #define GL_PROXY_TEXTURE_1D_STACK_MESAX 0x875B #define GL_PROXY_TEXTURE_2D_STACK_MESAX 0x875C #define GL_TEXTURE_1D_STACK_BINDING_MESAX 0x875D #define GL_TEXTURE_2D_STACK_BINDING_MESAX 0x875E #endif /* GL_MESAX_texture_stack */ #ifndef GL_MESA_framebuffer_flip_x #define GL_MESA_framebuffer_flip_x 1 #define GL_FRAMEBUFFER_FLIP_X_MESA 0x8BBC #endif /* GL_MESA_framebuffer_flip_x */ #ifndef GL_MESA_framebuffer_flip_y #define GL_MESA_framebuffer_flip_y 1 #define GL_FRAMEBUFFER_FLIP_Y_MESA 0x8BBB typedef void (APIENTRYP PFNGLFRAMEBUFFERPARAMETERIMESAPROC) (GLenum target, GLenum pname, GLint param); typedef void (APIENTRYP PFNGLGETFRAMEBUFFERPARAMETERIVMESAPROC) (GLenum target, GLenum pname, GLint *params); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glFramebufferParameteriMESA (GLenum target, GLenum pname, GLint param); GLAPI void APIENTRY glGetFramebufferParameterivMESA (GLenum target, GLenum pname, GLint *params); #endif #endif /* GL_MESA_framebuffer_flip_y */ #ifndef GL_MESA_framebuffer_swap_xy #define GL_MESA_framebuffer_swap_xy 1 #define GL_FRAMEBUFFER_SWAP_XY_MESA 0x8BBD #endif /* GL_MESA_framebuffer_swap_xy */ #ifndef GL_MESA_pack_invert #define GL_MESA_pack_invert 1 #define GL_PACK_INVERT_MESA 0x8758 #endif /* GL_MESA_pack_invert */ #ifndef GL_MESA_program_binary_formats #define GL_MESA_program_binary_formats 1 #define GL_PROGRAM_BINARY_FORMAT_MESA 0x875F #endif /* GL_MESA_program_binary_formats */ #ifndef GL_MESA_resize_buffers #define GL_MESA_resize_buffers 1 typedef void (APIENTRYP PFNGLRESIZEBUFFERSMESAPROC) (void); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glResizeBuffersMESA (void); #endif #endif /* GL_MESA_resize_buffers */ #ifndef GL_MESA_shader_integer_functions #define GL_MESA_shader_integer_functions 1 #endif /* GL_MESA_shader_integer_functions */ #ifndef GL_MESA_tile_raster_order #define GL_MESA_tile_raster_order 1 #define GL_TILE_RASTER_ORDER_FIXED_MESA 0x8BB8 #define GL_TILE_RASTER_ORDER_INCREASING_X_MESA 0x8BB9 #define GL_TILE_RASTER_ORDER_INCREASING_Y_MESA 0x8BBA #endif /* GL_MESA_tile_raster_order */ #ifndef GL_MESA_window_pos #define GL_MESA_window_pos 1 typedef void (APIENTRYP PFNGLWINDOWPOS2DMESAPROC) (GLdouble x, GLdouble y); typedef void (APIENTRYP PFNGLWINDOWPOS2DVMESAPROC) (const GLdouble *v); typedef void (APIENTRYP PFNGLWINDOWPOS2FMESAPROC) (GLfloat x, GLfloat y); typedef void (APIENTRYP PFNGLWINDOWPOS2FVMESAPROC) (const GLfloat *v); typedef void (APIENTRYP PFNGLWINDOWPOS2IMESAPROC) (GLint x, GLint y); typedef void (APIENTRYP PFNGLWINDOWPOS2IVMESAPROC) (const GLint *v); typedef void (APIENTRYP PFNGLWINDOWPOS2SMESAPROC) (GLshort x, GLshort y); typedef void (APIENTRYP PFNGLWINDOWPOS2SVMESAPROC) (const GLshort *v); typedef void (APIENTRYP PFNGLWINDOWPOS3DMESAPROC) (GLdouble x, GLdouble y, GLdouble z); typedef void (APIENTRYP PFNGLWINDOWPOS3DVMESAPROC) (const GLdouble *v); typedef void (APIENTRYP PFNGLWINDOWPOS3FMESAPROC) (GLfloat x, GLfloat y, GLfloat z); typedef void (APIENTRYP PFNGLWINDOWPOS3FVMESAPROC) (const GLfloat *v); typedef void (APIENTRYP PFNGLWINDOWPOS3IMESAPROC) (GLint x, GLint y, GLint z); typedef void (APIENTRYP PFNGLWINDOWPOS3IVMESAPROC) (const GLint *v); typedef void (APIENTRYP PFNGLWINDOWPOS3SMESAPROC) (GLshort x, GLshort y, GLshort z); typedef void (APIENTRYP PFNGLWINDOWPOS3SVMESAPROC) (const GLshort *v); typedef void (APIENTRYP PFNGLWINDOWPOS4DMESAPROC) (GLdouble x, GLdouble y, GLdouble z, GLdouble w); typedef void (APIENTRYP PFNGLWINDOWPOS4DVMESAPROC) (const GLdouble *v); typedef void (APIENTRYP PFNGLWINDOWPOS4FMESAPROC) (GLfloat x, GLfloat y, GLfloat z, GLfloat w); typedef void (APIENTRYP PFNGLWINDOWPOS4FVMESAPROC) (const GLfloat *v); typedef void (APIENTRYP PFNGLWINDOWPOS4IMESAPROC) (GLint x, GLint y, GLint z, GLint w); typedef void (APIENTRYP PFNGLWINDOWPOS4IVMESAPROC) (const GLint *v); typedef void (APIENTRYP PFNGLWINDOWPOS4SMESAPROC) (GLshort x, GLshort y, GLshort z, GLshort w); typedef void (APIENTRYP PFNGLWINDOWPOS4SVMESAPROC) (const GLshort *v); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glWindowPos2dMESA (GLdouble x, GLdouble y); GLAPI void APIENTRY glWindowPos2dvMESA (const GLdouble *v); GLAPI void APIENTRY glWindowPos2fMESA (GLfloat x, GLfloat y); GLAPI void APIENTRY glWindowPos2fvMESA (const GLfloat *v); GLAPI void APIENTRY glWindowPos2iMESA (GLint x, GLint y); GLAPI void APIENTRY glWindowPos2ivMESA (const GLint *v); GLAPI void APIENTRY glWindowPos2sMESA (GLshort x, GLshort y); GLAPI void APIENTRY glWindowPos2svMESA (const GLshort *v); GLAPI void APIENTRY glWindowPos3dMESA (GLdouble x, GLdouble y, GLdouble z); GLAPI void APIENTRY glWindowPos3dvMESA (const GLdouble *v); GLAPI void APIENTRY glWindowPos3fMESA (GLfloat x, GLfloat y, GLfloat z); GLAPI void APIENTRY glWindowPos3fvMESA (const GLfloat *v); GLAPI void APIENTRY glWindowPos3iMESA (GLint x, GLint y, GLint z); GLAPI void APIENTRY glWindowPos3ivMESA (const GLint *v); GLAPI void APIENTRY glWindowPos3sMESA (GLshort x, GLshort y, GLshort z); GLAPI void APIENTRY glWindowPos3svMESA (const GLshort *v); GLAPI void APIENTRY glWindowPos4dMESA (GLdouble x, GLdouble y, GLdouble z, GLdouble w); GLAPI void APIENTRY glWindowPos4dvMESA (const GLdouble *v); GLAPI void APIENTRY glWindowPos4fMESA (GLfloat x, GLfloat y, GLfloat z, GLfloat w); GLAPI void APIENTRY glWindowPos4fvMESA (const GLfloat *v); GLAPI void APIENTRY glWindowPos4iMESA (GLint x, GLint y, GLint z, GLint w); GLAPI void APIENTRY glWindowPos4ivMESA (const GLint *v); GLAPI void APIENTRY glWindowPos4sMESA (GLshort x, GLshort y, GLshort z, GLshort w); GLAPI void APIENTRY glWindowPos4svMESA (const GLshort *v); #endif #endif /* GL_MESA_window_pos */ #ifndef GL_MESA_ycbcr_texture #define GL_MESA_ycbcr_texture 1 #define GL_UNSIGNED_SHORT_8_8_MESA 0x85BA #define GL_UNSIGNED_SHORT_8_8_REV_MESA 0x85BB #define GL_YCBCR_MESA 0x8757 #endif /* GL_MESA_ycbcr_texture */ #ifndef GL_NVX_blend_equation_advanced_multi_draw_buffers #define GL_NVX_blend_equation_advanced_multi_draw_buffers 1 #endif /* GL_NVX_blend_equation_advanced_multi_draw_buffers */ #ifndef GL_NVX_conditional_render #define GL_NVX_conditional_render 1 typedef void (APIENTRYP PFNGLBEGINCONDITIONALRENDERNVXPROC) (GLuint id); typedef void (APIENTRYP PFNGLENDCONDITIONALRENDERNVXPROC) (void); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glBeginConditionalRenderNVX (GLuint id); GLAPI void APIENTRY glEndConditionalRenderNVX (void); #endif #endif /* GL_NVX_conditional_render */ #ifndef GL_NVX_gpu_memory_info #define GL_NVX_gpu_memory_info 1 #define GL_GPU_MEMORY_INFO_DEDICATED_VIDMEM_NVX 0x9047 #define GL_GPU_MEMORY_INFO_TOTAL_AVAILABLE_MEMORY_NVX 0x9048 #define GL_GPU_MEMORY_INFO_CURRENT_AVAILABLE_VIDMEM_NVX 0x9049 #define GL_GPU_MEMORY_INFO_EVICTION_COUNT_NVX 0x904A #define GL_GPU_MEMORY_INFO_EVICTED_MEMORY_NVX 0x904B #endif /* GL_NVX_gpu_memory_info */ #ifndef GL_NVX_gpu_multicast2 #define GL_NVX_gpu_multicast2 1 #define GL_UPLOAD_GPU_MASK_NVX 0x954A typedef void (APIENTRYP PFNGLUPLOADGPUMASKNVXPROC) (GLbitfield mask); typedef void (APIENTRYP PFNGLMULTICASTVIEWPORTARRAYVNVXPROC) (GLuint gpu, GLuint first, GLsizei count, const GLfloat *v); typedef void (APIENTRYP PFNGLMULTICASTVIEWPORTPOSITIONWSCALENVXPROC) (GLuint gpu, GLuint index, GLfloat xcoeff, GLfloat ycoeff); typedef void (APIENTRYP PFNGLMULTICASTSCISSORARRAYVNVXPROC) (GLuint gpu, GLuint first, GLsizei count, const GLint *v); typedef GLuint (APIENTRYP PFNGLASYNCCOPYBUFFERSUBDATANVXPROC) (GLsizei waitSemaphoreCount, const GLuint *waitSemaphoreArray, const GLuint64 *fenceValueArray, GLuint readGPU, GLbitfield writeGPUMask, GLuint readBuffer, GLuint writeBuffer, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size, GLsizei signalSemaphoreCount, const GLuint *signalSemaphoreArray, const GLuint64 *signalValueArray); typedef GLuint (APIENTRYP PFNGLASYNCCOPYIMAGESUBDATANVXPROC) (GLsizei waitSemaphoreCount, const GLuint *waitSemaphoreArray, const GLuint64 *waitValueArray, GLuint srcGPU, GLbitfield dstGPUMask, GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei srcWidth, GLsizei srcHeight, GLsizei srcDepth, GLsizei signalSemaphoreCount, const GLuint *signalSemaphoreArray, const GLuint64 *signalValueArray); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glUploadGPUMaskNVX (GLbitfield mask); GLAPI void APIENTRY glMulticastViewportArrayvNVX (GLuint gpu, GLuint first, GLsizei count, const GLfloat *v); GLAPI void APIENTRY glMulticastViewportPositionWScaleNVX (GLuint gpu, GLuint index, GLfloat xcoeff, GLfloat ycoeff); GLAPI void APIENTRY glMulticastScissorArrayvNVX (GLuint gpu, GLuint first, GLsizei count, const GLint *v); GLAPI GLuint APIENTRY glAsyncCopyBufferSubDataNVX (GLsizei waitSemaphoreCount, const GLuint *waitSemaphoreArray, const GLuint64 *fenceValueArray, GLuint readGPU, GLbitfield writeGPUMask, GLuint readBuffer, GLuint writeBuffer, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size, GLsizei signalSemaphoreCount, const GLuint *signalSemaphoreArray, const GLuint64 *signalValueArray); GLAPI GLuint APIENTRY glAsyncCopyImageSubDataNVX (GLsizei waitSemaphoreCount, const GLuint *waitSemaphoreArray, const GLuint64 *waitValueArray, GLuint srcGPU, GLbitfield dstGPUMask, GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei srcWidth, GLsizei srcHeight, GLsizei srcDepth, GLsizei signalSemaphoreCount, const GLuint *signalSemaphoreArray, const GLuint64 *signalValueArray); #endif #endif /* GL_NVX_gpu_multicast2 */ #ifndef GL_NVX_linked_gpu_multicast #define GL_NVX_linked_gpu_multicast 1 #define GL_LGPU_SEPARATE_STORAGE_BIT_NVX 0x0800 #define GL_MAX_LGPU_GPUS_NVX 0x92BA typedef void (APIENTRYP PFNGLLGPUNAMEDBUFFERSUBDATANVXPROC) (GLbitfield gpuMask, GLuint buffer, GLintptr offset, GLsizeiptr size, const void *data); typedef void (APIENTRYP PFNGLLGPUCOPYIMAGESUBDATANVXPROC) (GLuint sourceGPU, GLbitfield destinationGPUMask, GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srxY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei width, GLsizei height, GLsizei depth); typedef void (APIENTRYP PFNGLLGPUINTERLOCKNVXPROC) (void); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glLGPUNamedBufferSubDataNVX (GLbitfield gpuMask, GLuint buffer, GLintptr offset, GLsizeiptr size, const void *data); GLAPI void APIENTRY glLGPUCopyImageSubDataNVX (GLuint sourceGPU, GLbitfield destinationGPUMask, GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srxY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei width, GLsizei height, GLsizei depth); GLAPI void APIENTRY glLGPUInterlockNVX (void); #endif #endif /* GL_NVX_linked_gpu_multicast */ #ifndef GL_NVX_progress_fence #define GL_NVX_progress_fence 1 typedef GLuint (APIENTRYP PFNGLCREATEPROGRESSFENCENVXPROC) (void); typedef void (APIENTRYP PFNGLSIGNALSEMAPHOREUI64NVXPROC) (GLuint signalGPU, GLsizei fenceObjectCount, const GLuint *semaphoreArray, const GLuint64 *fenceValueArray); typedef void (APIENTRYP PFNGLWAITSEMAPHOREUI64NVXPROC) (GLuint waitGPU, GLsizei fenceObjectCount, const GLuint *semaphoreArray, const GLuint64 *fenceValueArray); typedef void (APIENTRYP PFNGLCLIENTWAITSEMAPHOREUI64NVXPROC) (GLsizei fenceObjectCount, const GLuint *semaphoreArray, const GLuint64 *fenceValueArray); #ifdef GL_GLEXT_PROTOTYPES GLAPI GLuint APIENTRY glCreateProgressFenceNVX (void); GLAPI void APIENTRY glSignalSemaphoreui64NVX (GLuint signalGPU, GLsizei fenceObjectCount, const GLuint *semaphoreArray, const GLuint64 *fenceValueArray); GLAPI void APIENTRY glWaitSemaphoreui64NVX (GLuint waitGPU, GLsizei fenceObjectCount, const GLuint *semaphoreArray, const GLuint64 *fenceValueArray); GLAPI void APIENTRY glClientWaitSemaphoreui64NVX (GLsizei fenceObjectCount, const GLuint *semaphoreArray, const GLuint64 *fenceValueArray); #endif #endif /* GL_NVX_progress_fence */ #ifndef GL_NV_alpha_to_coverage_dither_control #define GL_NV_alpha_to_coverage_dither_control 1 #define GL_ALPHA_TO_COVERAGE_DITHER_DEFAULT_NV 0x934D #define GL_ALPHA_TO_COVERAGE_DITHER_ENABLE_NV 0x934E #define GL_ALPHA_TO_COVERAGE_DITHER_DISABLE_NV 0x934F #define GL_ALPHA_TO_COVERAGE_DITHER_MODE_NV 0x92BF typedef void (APIENTRYP PFNGLALPHATOCOVERAGEDITHERCONTROLNVPROC) (GLenum mode); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glAlphaToCoverageDitherControlNV (GLenum mode); #endif #endif /* GL_NV_alpha_to_coverage_dither_control */ #ifndef GL_NV_bindless_multi_draw_indirect #define GL_NV_bindless_multi_draw_indirect 1 typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSINDIRECTBINDLESSNVPROC) (GLenum mode, const void *indirect, GLsizei drawCount, GLsizei stride, GLint vertexBufferCount); typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSINDIRECTBINDLESSNVPROC) (GLenum mode, GLenum type, const void *indirect, GLsizei drawCount, GLsizei stride, GLint vertexBufferCount); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glMultiDrawArraysIndirectBindlessNV (GLenum mode, const void *indirect, GLsizei drawCount, GLsizei stride, GLint vertexBufferCount); GLAPI void APIENTRY glMultiDrawElementsIndirectBindlessNV (GLenum mode, GLenum type, const void *indirect, GLsizei drawCount, GLsizei stride, GLint vertexBufferCount); #endif #endif /* GL_NV_bindless_multi_draw_indirect */ #ifndef GL_NV_bindless_multi_draw_indirect_count #define GL_NV_bindless_multi_draw_indirect_count 1 typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSINDIRECTBINDLESSCOUNTNVPROC) (GLenum mode, const void *indirect, GLsizei drawCount, GLsizei maxDrawCount, GLsizei stride, GLint vertexBufferCount); typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSINDIRECTBINDLESSCOUNTNVPROC) (GLenum mode, GLenum type, const void *indirect, GLsizei drawCount, GLsizei maxDrawCount, GLsizei stride, GLint vertexBufferCount); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glMultiDrawArraysIndirectBindlessCountNV (GLenum mode, const void *indirect, GLsizei drawCount, GLsizei maxDrawCount, GLsizei stride, GLint vertexBufferCount); GLAPI void APIENTRY glMultiDrawElementsIndirectBindlessCountNV (GLenum mode, GLenum type, const void *indirect, GLsizei drawCount, GLsizei maxDrawCount, GLsizei stride, GLint vertexBufferCount); #endif #endif /* GL_NV_bindless_multi_draw_indirect_count */ #ifndef GL_NV_bindless_texture #define GL_NV_bindless_texture 1 typedef GLuint64 (APIENTRYP PFNGLGETTEXTUREHANDLENVPROC) (GLuint texture); typedef GLuint64 (APIENTRYP PFNGLGETTEXTURESAMPLERHANDLENVPROC) (GLuint texture, GLuint sampler); typedef void (APIENTRYP PFNGLMAKETEXTUREHANDLERESIDENTNVPROC) (GLuint64 handle); typedef void (APIENTRYP PFNGLMAKETEXTUREHANDLENONRESIDENTNVPROC) (GLuint64 handle); typedef GLuint64 (APIENTRYP PFNGLGETIMAGEHANDLENVPROC) (GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum format); typedef void (APIENTRYP PFNGLMAKEIMAGEHANDLERESIDENTNVPROC) (GLuint64 handle, GLenum access); typedef void (APIENTRYP PFNGLMAKEIMAGEHANDLENONRESIDENTNVPROC) (GLuint64 handle); typedef void (APIENTRYP PFNGLUNIFORMHANDLEUI64NVPROC) (GLint location, GLuint64 value); typedef void (APIENTRYP PFNGLUNIFORMHANDLEUI64VNVPROC) (GLint location, GLsizei count, const GLuint64 *value); typedef void (APIENTRYP PFNGLPROGRAMUNIFORMHANDLEUI64NVPROC) (GLuint program, GLint location, GLuint64 value); typedef void (APIENTRYP PFNGLPROGRAMUNIFORMHANDLEUI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64 *values); typedef GLboolean (APIENTRYP PFNGLISTEXTUREHANDLERESIDENTNVPROC) (GLuint64 handle); typedef GLboolean (APIENTRYP PFNGLISIMAGEHANDLERESIDENTNVPROC) (GLuint64 handle); #ifdef GL_GLEXT_PROTOTYPES GLAPI GLuint64 APIENTRY glGetTextureHandleNV (GLuint texture); GLAPI GLuint64 APIENTRY glGetTextureSamplerHandleNV (GLuint texture, GLuint sampler); GLAPI void APIENTRY glMakeTextureHandleResidentNV (GLuint64 handle); GLAPI void APIENTRY glMakeTextureHandleNonResidentNV (GLuint64 handle); GLAPI GLuint64 APIENTRY glGetImageHandleNV (GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum format); GLAPI void APIENTRY glMakeImageHandleResidentNV (GLuint64 handle, GLenum access); GLAPI void APIENTRY glMakeImageHandleNonResidentNV (GLuint64 handle); GLAPI void APIENTRY glUniformHandleui64NV (GLint location, GLuint64 value); GLAPI void APIENTRY glUniformHandleui64vNV (GLint location, GLsizei count, const GLuint64 *value); GLAPI void APIENTRY glProgramUniformHandleui64NV (GLuint program, GLint location, GLuint64 value); GLAPI void APIENTRY glProgramUniformHandleui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64 *values); GLAPI GLboolean APIENTRY glIsTextureHandleResidentNV (GLuint64 handle); GLAPI GLboolean APIENTRY glIsImageHandleResidentNV (GLuint64 handle); #endif #endif /* GL_NV_bindless_texture */ #ifndef GL_NV_blend_equation_advanced #define GL_NV_blend_equation_advanced 1 #define GL_BLEND_OVERLAP_NV 0x9281 #define GL_BLEND_PREMULTIPLIED_SRC_NV 0x9280 #define GL_BLUE_NV 0x1905 #define GL_COLORBURN_NV 0x929A #define GL_COLORDODGE_NV 0x9299 #define GL_CONJOINT_NV 0x9284 #define GL_CONTRAST_NV 0x92A1 #define GL_DARKEN_NV 0x9297 #define GL_DIFFERENCE_NV 0x929E #define GL_DISJOINT_NV 0x9283 #define GL_DST_ATOP_NV 0x928F #define GL_DST_IN_NV 0x928B #define GL_DST_NV 0x9287 #define GL_DST_OUT_NV 0x928D #define GL_DST_OVER_NV 0x9289 #define GL_EXCLUSION_NV 0x92A0 #define GL_GREEN_NV 0x1904 #define GL_HARDLIGHT_NV 0x929B #define GL_HARDMIX_NV 0x92A9 #define GL_HSL_COLOR_NV 0x92AF #define GL_HSL_HUE_NV 0x92AD #define GL_HSL_LUMINOSITY_NV 0x92B0 #define GL_HSL_SATURATION_NV 0x92AE #define GL_INVERT_OVG_NV 0x92B4 #define GL_INVERT_RGB_NV 0x92A3 #define GL_LIGHTEN_NV 0x9298 #define GL_LINEARBURN_NV 0x92A5 #define GL_LINEARDODGE_NV 0x92A4 #define GL_LINEARLIGHT_NV 0x92A7 #define GL_MINUS_CLAMPED_NV 0x92B3 #define GL_MINUS_NV 0x929F #define GL_MULTIPLY_NV 0x9294 #define GL_OVERLAY_NV 0x9296 #define GL_PINLIGHT_NV 0x92A8 #define GL_PLUS_CLAMPED_ALPHA_NV 0x92B2 #define GL_PLUS_CLAMPED_NV 0x92B1 #define GL_PLUS_DARKER_NV 0x9292 #define GL_PLUS_NV 0x9291 #define GL_RED_NV 0x1903 #define GL_SCREEN_NV 0x9295 #define GL_SOFTLIGHT_NV 0x929C #define GL_SRC_ATOP_NV 0x928E #define GL_SRC_IN_NV 0x928A #define GL_SRC_NV 0x9286 #define GL_SRC_OUT_NV 0x928C #define GL_SRC_OVER_NV 0x9288 #define GL_UNCORRELATED_NV 0x9282 #define GL_VIVIDLIGHT_NV 0x92A6 #define GL_XOR_NV 0x1506 typedef void (APIENTRYP PFNGLBLENDPARAMETERINVPROC) (GLenum pname, GLint value); typedef void (APIENTRYP PFNGLBLENDBARRIERNVPROC) (void); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glBlendParameteriNV (GLenum pname, GLint value); GLAPI void APIENTRY glBlendBarrierNV (void); #endif #endif /* GL_NV_blend_equation_advanced */ #ifndef GL_NV_blend_equation_advanced_coherent #define GL_NV_blend_equation_advanced_coherent 1 #define GL_BLEND_ADVANCED_COHERENT_NV 0x9285 #endif /* GL_NV_blend_equation_advanced_coherent */ #ifndef GL_NV_blend_minmax_factor #define GL_NV_blend_minmax_factor 1 #endif /* GL_NV_blend_minmax_factor */ #ifndef GL_NV_blend_square #define GL_NV_blend_square 1 #endif /* GL_NV_blend_square */ #ifndef GL_NV_clip_space_w_scaling #define GL_NV_clip_space_w_scaling 1 #define GL_VIEWPORT_POSITION_W_SCALE_NV 0x937C #define GL_VIEWPORT_POSITION_W_SCALE_X_COEFF_NV 0x937D #define GL_VIEWPORT_POSITION_W_SCALE_Y_COEFF_NV 0x937E typedef void (APIENTRYP PFNGLVIEWPORTPOSITIONWSCALENVPROC) (GLuint index, GLfloat xcoeff, GLfloat ycoeff); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glViewportPositionWScaleNV (GLuint index, GLfloat xcoeff, GLfloat ycoeff); #endif #endif /* GL_NV_clip_space_w_scaling */ #ifndef GL_NV_command_list #define GL_NV_command_list 1 #define GL_TERMINATE_SEQUENCE_COMMAND_NV 0x0000 #define GL_NOP_COMMAND_NV 0x0001 #define GL_DRAW_ELEMENTS_COMMAND_NV 0x0002 #define GL_DRAW_ARRAYS_COMMAND_NV 0x0003 #define GL_DRAW_ELEMENTS_STRIP_COMMAND_NV 0x0004 #define GL_DRAW_ARRAYS_STRIP_COMMAND_NV 0x0005 #define GL_DRAW_ELEMENTS_INSTANCED_COMMAND_NV 0x0006 #define GL_DRAW_ARRAYS_INSTANCED_COMMAND_NV 0x0007 #define GL_ELEMENT_ADDRESS_COMMAND_NV 0x0008 #define GL_ATTRIBUTE_ADDRESS_COMMAND_NV 0x0009 #define GL_UNIFORM_ADDRESS_COMMAND_NV 0x000A #define GL_BLEND_COLOR_COMMAND_NV 0x000B #define GL_STENCIL_REF_COMMAND_NV 0x000C #define GL_LINE_WIDTH_COMMAND_NV 0x000D #define GL_POLYGON_OFFSET_COMMAND_NV 0x000E #define GL_ALPHA_REF_COMMAND_NV 0x000F #define GL_VIEWPORT_COMMAND_NV 0x0010 #define GL_SCISSOR_COMMAND_NV 0x0011 #define GL_FRONT_FACE_COMMAND_NV 0x0012 typedef void (APIENTRYP PFNGLCREATESTATESNVPROC) (GLsizei n, GLuint *states); typedef void (APIENTRYP PFNGLDELETESTATESNVPROC) (GLsizei n, const GLuint *states); typedef GLboolean (APIENTRYP PFNGLISSTATENVPROC) (GLuint state); typedef void (APIENTRYP PFNGLSTATECAPTURENVPROC) (GLuint state, GLenum mode); typedef GLuint (APIENTRYP PFNGLGETCOMMANDHEADERNVPROC) (GLenum tokenID, GLuint size); typedef GLushort (APIENTRYP PFNGLGETSTAGEINDEXNVPROC) (GLenum shadertype); typedef void (APIENTRYP PFNGLDRAWCOMMANDSNVPROC) (GLenum primitiveMode, GLuint buffer, const GLintptr *indirects, const GLsizei *sizes, GLuint count); typedef void (APIENTRYP PFNGLDRAWCOMMANDSADDRESSNVPROC) (GLenum primitiveMode, const GLuint64 *indirects, const GLsizei *sizes, GLuint count); typedef void (APIENTRYP PFNGLDRAWCOMMANDSSTATESNVPROC) (GLuint buffer, const GLintptr *indirects, const GLsizei *sizes, const GLuint *states, const GLuint *fbos, GLuint count); typedef void (APIENTRYP PFNGLDRAWCOMMANDSSTATESADDRESSNVPROC) (const GLuint64 *indirects, const GLsizei *sizes, const GLuint *states, const GLuint *fbos, GLuint count); typedef void (APIENTRYP PFNGLCREATECOMMANDLISTSNVPROC) (GLsizei n, GLuint *lists); typedef void (APIENTRYP PFNGLDELETECOMMANDLISTSNVPROC) (GLsizei n, const GLuint *lists); typedef GLboolean (APIENTRYP PFNGLISCOMMANDLISTNVPROC) (GLuint list); typedef void (APIENTRYP PFNGLLISTDRAWCOMMANDSSTATESCLIENTNVPROC) (GLuint list, GLuint segment, const void **indirects, const GLsizei *sizes, const GLuint *states, const GLuint *fbos, GLuint count); typedef void (APIENTRYP PFNGLCOMMANDLISTSEGMENTSNVPROC) (GLuint list, GLuint segments); typedef void (APIENTRYP PFNGLCOMPILECOMMANDLISTNVPROC) (GLuint list); typedef void (APIENTRYP PFNGLCALLCOMMANDLISTNVPROC) (GLuint list); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glCreateStatesNV (GLsizei n, GLuint *states); GLAPI void APIENTRY glDeleteStatesNV (GLsizei n, const GLuint *states); GLAPI GLboolean APIENTRY glIsStateNV (GLuint state); GLAPI void APIENTRY glStateCaptureNV (GLuint state, GLenum mode); GLAPI GLuint APIENTRY glGetCommandHeaderNV (GLenum tokenID, GLuint size); GLAPI GLushort APIENTRY glGetStageIndexNV (GLenum shadertype); GLAPI void APIENTRY glDrawCommandsNV (GLenum primitiveMode, GLuint buffer, const GLintptr *indirects, const GLsizei *sizes, GLuint count); GLAPI void APIENTRY glDrawCommandsAddressNV (GLenum primitiveMode, const GLuint64 *indirects, const GLsizei *sizes, GLuint count); GLAPI void APIENTRY glDrawCommandsStatesNV (GLuint buffer, const GLintptr *indirects, const GLsizei *sizes, const GLuint *states, const GLuint *fbos, GLuint count); GLAPI void APIENTRY glDrawCommandsStatesAddressNV (const GLuint64 *indirects, const GLsizei *sizes, const GLuint *states, const GLuint *fbos, GLuint count); GLAPI void APIENTRY glCreateCommandListsNV (GLsizei n, GLuint *lists); GLAPI void APIENTRY glDeleteCommandListsNV (GLsizei n, const GLuint *lists); GLAPI GLboolean APIENTRY glIsCommandListNV (GLuint list); GLAPI void APIENTRY glListDrawCommandsStatesClientNV (GLuint list, GLuint segment, const void **indirects, const GLsizei *sizes, const GLuint *states, const GLuint *fbos, GLuint count); GLAPI void APIENTRY glCommandListSegmentsNV (GLuint list, GLuint segments); GLAPI void APIENTRY glCompileCommandListNV (GLuint list); GLAPI void APIENTRY glCallCommandListNV (GLuint list); #endif #endif /* GL_NV_command_list */ #ifndef GL_NV_compute_program5 #define GL_NV_compute_program5 1 #define GL_COMPUTE_PROGRAM_NV 0x90FB #define GL_COMPUTE_PROGRAM_PARAMETER_BUFFER_NV 0x90FC #endif /* GL_NV_compute_program5 */ #ifndef GL_NV_compute_shader_derivatives #define GL_NV_compute_shader_derivatives 1 #endif /* GL_NV_compute_shader_derivatives */ #ifndef GL_NV_conditional_render #define GL_NV_conditional_render 1 #define GL_QUERY_WAIT_NV 0x8E13 #define GL_QUERY_NO_WAIT_NV 0x8E14 #define GL_QUERY_BY_REGION_WAIT_NV 0x8E15 #define GL_QUERY_BY_REGION_NO_WAIT_NV 0x8E16 typedef void (APIENTRYP PFNGLBEGINCONDITIONALRENDERNVPROC) (GLuint id, GLenum mode); typedef void (APIENTRYP PFNGLENDCONDITIONALRENDERNVPROC) (void); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glBeginConditionalRenderNV (GLuint id, GLenum mode); GLAPI void APIENTRY glEndConditionalRenderNV (void); #endif #endif /* GL_NV_conditional_render */ #ifndef GL_NV_conservative_raster #define GL_NV_conservative_raster 1 #define GL_CONSERVATIVE_RASTERIZATION_NV 0x9346 #define GL_SUBPIXEL_PRECISION_BIAS_X_BITS_NV 0x9347 #define GL_SUBPIXEL_PRECISION_BIAS_Y_BITS_NV 0x9348 #define GL_MAX_SUBPIXEL_PRECISION_BIAS_BITS_NV 0x9349 typedef void (APIENTRYP PFNGLSUBPIXELPRECISIONBIASNVPROC) (GLuint xbits, GLuint ybits); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glSubpixelPrecisionBiasNV (GLuint xbits, GLuint ybits); #endif #endif /* GL_NV_conservative_raster */ #ifndef GL_NV_conservative_raster_dilate #define GL_NV_conservative_raster_dilate 1 #define GL_CONSERVATIVE_RASTER_DILATE_NV 0x9379 #define GL_CONSERVATIVE_RASTER_DILATE_RANGE_NV 0x937A #define GL_CONSERVATIVE_RASTER_DILATE_GRANULARITY_NV 0x937B typedef void (APIENTRYP PFNGLCONSERVATIVERASTERPARAMETERFNVPROC) (GLenum pname, GLfloat value); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glConservativeRasterParameterfNV (GLenum pname, GLfloat value); #endif #endif /* GL_NV_conservative_raster_dilate */ #ifndef GL_NV_conservative_raster_pre_snap #define GL_NV_conservative_raster_pre_snap 1 #define GL_CONSERVATIVE_RASTER_MODE_PRE_SNAP_NV 0x9550 #endif /* GL_NV_conservative_raster_pre_snap */ #ifndef GL_NV_conservative_raster_pre_snap_triangles #define GL_NV_conservative_raster_pre_snap_triangles 1 #define GL_CONSERVATIVE_RASTER_MODE_NV 0x954D #define GL_CONSERVATIVE_RASTER_MODE_POST_SNAP_NV 0x954E #define GL_CONSERVATIVE_RASTER_MODE_PRE_SNAP_TRIANGLES_NV 0x954F typedef void (APIENTRYP PFNGLCONSERVATIVERASTERPARAMETERINVPROC) (GLenum pname, GLint param); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glConservativeRasterParameteriNV (GLenum pname, GLint param); #endif #endif /* GL_NV_conservative_raster_pre_snap_triangles */ #ifndef GL_NV_conservative_raster_underestimation #define GL_NV_conservative_raster_underestimation 1 #endif /* GL_NV_conservative_raster_underestimation */ #ifndef GL_NV_copy_depth_to_color #define GL_NV_copy_depth_to_color 1 #define GL_DEPTH_STENCIL_TO_RGBA_NV 0x886E #define GL_DEPTH_STENCIL_TO_BGRA_NV 0x886F #endif /* GL_NV_copy_depth_to_color */ #ifndef GL_NV_copy_image #define GL_NV_copy_image 1 typedef void (APIENTRYP PFNGLCOPYIMAGESUBDATANVPROC) (GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei width, GLsizei height, GLsizei depth); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glCopyImageSubDataNV (GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei width, GLsizei height, GLsizei depth); #endif #endif /* GL_NV_copy_image */ #ifndef GL_NV_deep_texture3D #define GL_NV_deep_texture3D 1 #define GL_MAX_DEEP_3D_TEXTURE_WIDTH_HEIGHT_NV 0x90D0 #define GL_MAX_DEEP_3D_TEXTURE_DEPTH_NV 0x90D1 #endif /* GL_NV_deep_texture3D */ #ifndef GL_NV_depth_buffer_float #define GL_NV_depth_buffer_float 1 #define GL_DEPTH_COMPONENT32F_NV 0x8DAB #define GL_DEPTH32F_STENCIL8_NV 0x8DAC #define GL_FLOAT_32_UNSIGNED_INT_24_8_REV_NV 0x8DAD #define GL_DEPTH_BUFFER_FLOAT_MODE_NV 0x8DAF typedef void (APIENTRYP PFNGLDEPTHRANGEDNVPROC) (GLdouble zNear, GLdouble zFar); typedef void (APIENTRYP PFNGLCLEARDEPTHDNVPROC) (GLdouble depth); typedef void (APIENTRYP PFNGLDEPTHBOUNDSDNVPROC) (GLdouble zmin, GLdouble zmax); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glDepthRangedNV (GLdouble zNear, GLdouble zFar); GLAPI void APIENTRY glClearDepthdNV (GLdouble depth); GLAPI void APIENTRY glDepthBoundsdNV (GLdouble zmin, GLdouble zmax); #endif #endif /* GL_NV_depth_buffer_float */ #ifndef GL_NV_depth_clamp #define GL_NV_depth_clamp 1 #define GL_DEPTH_CLAMP_NV 0x864F #endif /* GL_NV_depth_clamp */ #ifndef GL_NV_draw_texture #define GL_NV_draw_texture 1 typedef void (APIENTRYP PFNGLDRAWTEXTURENVPROC) (GLuint texture, GLuint sampler, GLfloat x0, GLfloat y0, GLfloat x1, GLfloat y1, GLfloat z, GLfloat s0, GLfloat t0, GLfloat s1, GLfloat t1); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glDrawTextureNV (GLuint texture, GLuint sampler, GLfloat x0, GLfloat y0, GLfloat x1, GLfloat y1, GLfloat z, GLfloat s0, GLfloat t0, GLfloat s1, GLfloat t1); #endif #endif /* GL_NV_draw_texture */ #ifndef GL_NV_draw_vulkan_image #define GL_NV_draw_vulkan_image 1 typedef void (APIENTRY *GLVULKANPROCNV)(void); typedef void (APIENTRYP PFNGLDRAWVKIMAGENVPROC) (GLuint64 vkImage, GLuint sampler, GLfloat x0, GLfloat y0, GLfloat x1, GLfloat y1, GLfloat z, GLfloat s0, GLfloat t0, GLfloat s1, GLfloat t1); typedef GLVULKANPROCNV (APIENTRYP PFNGLGETVKPROCADDRNVPROC) (const GLchar *name); typedef void (APIENTRYP PFNGLWAITVKSEMAPHORENVPROC) (GLuint64 vkSemaphore); typedef void (APIENTRYP PFNGLSIGNALVKSEMAPHORENVPROC) (GLuint64 vkSemaphore); typedef void (APIENTRYP PFNGLSIGNALVKFENCENVPROC) (GLuint64 vkFence); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glDrawVkImageNV (GLuint64 vkImage, GLuint sampler, GLfloat x0, GLfloat y0, GLfloat x1, GLfloat y1, GLfloat z, GLfloat s0, GLfloat t0, GLfloat s1, GLfloat t1); GLAPI GLVULKANPROCNV APIENTRY glGetVkProcAddrNV (const GLchar *name); GLAPI void APIENTRY glWaitVkSemaphoreNV (GLuint64 vkSemaphore); GLAPI void APIENTRY glSignalVkSemaphoreNV (GLuint64 vkSemaphore); GLAPI void APIENTRY glSignalVkFenceNV (GLuint64 vkFence); #endif #endif /* GL_NV_draw_vulkan_image */ #ifndef GL_NV_evaluators #define GL_NV_evaluators 1 #define GL_EVAL_2D_NV 0x86C0 #define GL_EVAL_TRIANGULAR_2D_NV 0x86C1 #define GL_MAP_TESSELLATION_NV 0x86C2 #define GL_MAP_ATTRIB_U_ORDER_NV 0x86C3 #define GL_MAP_ATTRIB_V_ORDER_NV 0x86C4 #define GL_EVAL_FRACTIONAL_TESSELLATION_NV 0x86C5 #define GL_EVAL_VERTEX_ATTRIB0_NV 0x86C6 #define GL_EVAL_VERTEX_ATTRIB1_NV 0x86C7 #define GL_EVAL_VERTEX_ATTRIB2_NV 0x86C8 #define GL_EVAL_VERTEX_ATTRIB3_NV 0x86C9 #define GL_EVAL_VERTEX_ATTRIB4_NV 0x86CA #define GL_EVAL_VERTEX_ATTRIB5_NV 0x86CB #define GL_EVAL_VERTEX_ATTRIB6_NV 0x86CC #define GL_EVAL_VERTEX_ATTRIB7_NV 0x86CD #define GL_EVAL_VERTEX_ATTRIB8_NV 0x86CE #define GL_EVAL_VERTEX_ATTRIB9_NV 0x86CF #define GL_EVAL_VERTEX_ATTRIB10_NV 0x86D0 #define GL_EVAL_VERTEX_ATTRIB11_NV 0x86D1 #define GL_EVAL_VERTEX_ATTRIB12_NV 0x86D2 #define GL_EVAL_VERTEX_ATTRIB13_NV 0x86D3 #define GL_EVAL_VERTEX_ATTRIB14_NV 0x86D4 #define GL_EVAL_VERTEX_ATTRIB15_NV 0x86D5 #define GL_MAX_MAP_TESSELLATION_NV 0x86D6 #define GL_MAX_RATIONAL_EVAL_ORDER_NV 0x86D7 typedef void (APIENTRYP PFNGLMAPCONTROLPOINTSNVPROC) (GLenum target, GLuint index, GLenum type, GLsizei ustride, GLsizei vstride, GLint uorder, GLint vorder, GLboolean packed, const void *points); typedef void (APIENTRYP PFNGLMAPPARAMETERIVNVPROC) (GLenum target, GLenum pname, const GLint *params); typedef void (APIENTRYP PFNGLMAPPARAMETERFVNVPROC) (GLenum target, GLenum pname, const GLfloat *params); typedef void (APIENTRYP PFNGLGETMAPCONTROLPOINTSNVPROC) (GLenum target, GLuint index, GLenum type, GLsizei ustride, GLsizei vstride, GLboolean packed, void *points); typedef void (APIENTRYP PFNGLGETMAPPARAMETERIVNVPROC) (GLenum target, GLenum pname, GLint *params); typedef void (APIENTRYP PFNGLGETMAPPARAMETERFVNVPROC) (GLenum target, GLenum pname, GLfloat *params); typedef void (APIENTRYP PFNGLGETMAPATTRIBPARAMETERIVNVPROC) (GLenum target, GLuint index, GLenum pname, GLint *params); typedef void (APIENTRYP PFNGLGETMAPATTRIBPARAMETERFVNVPROC) (GLenum target, GLuint index, GLenum pname, GLfloat *params); typedef void (APIENTRYP PFNGLEVALMAPSNVPROC) (GLenum target, GLenum mode); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glMapControlPointsNV (GLenum target, GLuint index, GLenum type, GLsizei ustride, GLsizei vstride, GLint uorder, GLint vorder, GLboolean packed, const void *points); GLAPI void APIENTRY glMapParameterivNV (GLenum target, GLenum pname, const GLint *params); GLAPI void APIENTRY glMapParameterfvNV (GLenum target, GLenum pname, const GLfloat *params); GLAPI void APIENTRY glGetMapControlPointsNV (GLenum target, GLuint index, GLenum type, GLsizei ustride, GLsizei vstride, GLboolean packed, void *points); GLAPI void APIENTRY glGetMapParameterivNV (GLenum target, GLenum pname, GLint *params); GLAPI void APIENTRY glGetMapParameterfvNV (GLenum target, GLenum pname, GLfloat *params); GLAPI void APIENTRY glGetMapAttribParameterivNV (GLenum target, GLuint index, GLenum pname, GLint *params); GLAPI void APIENTRY glGetMapAttribParameterfvNV (GLenum target, GLuint index, GLenum pname, GLfloat *params); GLAPI void APIENTRY glEvalMapsNV (GLenum target, GLenum mode); #endif #endif /* GL_NV_evaluators */ #ifndef GL_NV_explicit_multisample #define GL_NV_explicit_multisample 1 #define GL_SAMPLE_POSITION_NV 0x8E50 #define GL_SAMPLE_MASK_NV 0x8E51 #define GL_SAMPLE_MASK_VALUE_NV 0x8E52 #define GL_TEXTURE_BINDING_RENDERBUFFER_NV 0x8E53 #define GL_TEXTURE_RENDERBUFFER_DATA_STORE_BINDING_NV 0x8E54 #define GL_TEXTURE_RENDERBUFFER_NV 0x8E55 #define GL_SAMPLER_RENDERBUFFER_NV 0x8E56 #define GL_INT_SAMPLER_RENDERBUFFER_NV 0x8E57 #define GL_UNSIGNED_INT_SAMPLER_RENDERBUFFER_NV 0x8E58 #define GL_MAX_SAMPLE_MASK_WORDS_NV 0x8E59 typedef void (APIENTRYP PFNGLGETMULTISAMPLEFVNVPROC) (GLenum pname, GLuint index, GLfloat *val); typedef void (APIENTRYP PFNGLSAMPLEMASKINDEXEDNVPROC) (GLuint index, GLbitfield mask); typedef void (APIENTRYP PFNGLTEXRENDERBUFFERNVPROC) (GLenum target, GLuint renderbuffer); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glGetMultisamplefvNV (GLenum pname, GLuint index, GLfloat *val); GLAPI void APIENTRY glSampleMaskIndexedNV (GLuint index, GLbitfield mask); GLAPI void APIENTRY glTexRenderbufferNV (GLenum target, GLuint renderbuffer); #endif #endif /* GL_NV_explicit_multisample */ #ifndef GL_NV_fence #define GL_NV_fence 1 #define GL_ALL_COMPLETED_NV 0x84F2 #define GL_FENCE_STATUS_NV 0x84F3 #define GL_FENCE_CONDITION_NV 0x84F4 typedef void (APIENTRYP PFNGLDELETEFENCESNVPROC) (GLsizei n, const GLuint *fences); typedef void (APIENTRYP PFNGLGENFENCESNVPROC) (GLsizei n, GLuint *fences); typedef GLboolean (APIENTRYP PFNGLISFENCENVPROC) (GLuint fence); typedef GLboolean (APIENTRYP PFNGLTESTFENCENVPROC) (GLuint fence); typedef void (APIENTRYP PFNGLGETFENCEIVNVPROC) (GLuint fence, GLenum pname, GLint *params); typedef void (APIENTRYP PFNGLFINISHFENCENVPROC) (GLuint fence); typedef void (APIENTRYP PFNGLSETFENCENVPROC) (GLuint fence, GLenum condition); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glDeleteFencesNV (GLsizei n, const GLuint *fences); GLAPI void APIENTRY glGenFencesNV (GLsizei n, GLuint *fences); GLAPI GLboolean APIENTRY glIsFenceNV (GLuint fence); GLAPI GLboolean APIENTRY glTestFenceNV (GLuint fence); GLAPI void APIENTRY glGetFenceivNV (GLuint fence, GLenum pname, GLint *params); GLAPI void APIENTRY glFinishFenceNV (GLuint fence); GLAPI void APIENTRY glSetFenceNV (GLuint fence, GLenum condition); #endif #endif /* GL_NV_fence */ #ifndef GL_NV_fill_rectangle #define GL_NV_fill_rectangle 1 #define GL_FILL_RECTANGLE_NV 0x933C #endif /* GL_NV_fill_rectangle */ #ifndef GL_NV_float_buffer #define GL_NV_float_buffer 1 #define GL_FLOAT_R_NV 0x8880 #define GL_FLOAT_RG_NV 0x8881 #define GL_FLOAT_RGB_NV 0x8882 #define GL_FLOAT_RGBA_NV 0x8883 #define GL_FLOAT_R16_NV 0x8884 #define GL_FLOAT_R32_NV 0x8885 #define GL_FLOAT_RG16_NV 0x8886 #define GL_FLOAT_RG32_NV 0x8887 #define GL_FLOAT_RGB16_NV 0x8888 #define GL_FLOAT_RGB32_NV 0x8889 #define GL_FLOAT_RGBA16_NV 0x888A #define GL_FLOAT_RGBA32_NV 0x888B #define GL_TEXTURE_FLOAT_COMPONENTS_NV 0x888C #define GL_FLOAT_CLEAR_COLOR_VALUE_NV 0x888D #define GL_FLOAT_RGBA_MODE_NV 0x888E #endif /* GL_NV_float_buffer */ #ifndef GL_NV_fog_distance #define GL_NV_fog_distance 1 #define GL_FOG_DISTANCE_MODE_NV 0x855A #define GL_EYE_RADIAL_NV 0x855B #define GL_EYE_PLANE_ABSOLUTE_NV 0x855C #endif /* GL_NV_fog_distance */ #ifndef GL_NV_fragment_coverage_to_color #define GL_NV_fragment_coverage_to_color 1 #define GL_FRAGMENT_COVERAGE_TO_COLOR_NV 0x92DD #define GL_FRAGMENT_COVERAGE_COLOR_NV 0x92DE typedef void (APIENTRYP PFNGLFRAGMENTCOVERAGECOLORNVPROC) (GLuint color); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glFragmentCoverageColorNV (GLuint color); #endif #endif /* GL_NV_fragment_coverage_to_color */ #ifndef GL_NV_fragment_program #define GL_NV_fragment_program 1 #define GL_MAX_FRAGMENT_PROGRAM_LOCAL_PARAMETERS_NV 0x8868 #define GL_FRAGMENT_PROGRAM_NV 0x8870 #define GL_MAX_TEXTURE_COORDS_NV 0x8871 #define GL_MAX_TEXTURE_IMAGE_UNITS_NV 0x8872 #define GL_FRAGMENT_PROGRAM_BINDING_NV 0x8873 #define GL_PROGRAM_ERROR_STRING_NV 0x8874 typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4FNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLfloat x, GLfloat y, GLfloat z, GLfloat w); typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4FVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, const GLfloat *v); typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4DNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLdouble x, GLdouble y, GLdouble z, GLdouble w); typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4DVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, const GLdouble *v); typedef void (APIENTRYP PFNGLGETPROGRAMNAMEDPARAMETERFVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLfloat *params); typedef void (APIENTRYP PFNGLGETPROGRAMNAMEDPARAMETERDVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLdouble *params); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glProgramNamedParameter4fNV (GLuint id, GLsizei len, const GLubyte *name, GLfloat x, GLfloat y, GLfloat z, GLfloat w); GLAPI void APIENTRY glProgramNamedParameter4fvNV (GLuint id, GLsizei len, const GLubyte *name, const GLfloat *v); GLAPI void APIENTRY glProgramNamedParameter4dNV (GLuint id, GLsizei len, const GLubyte *name, GLdouble x, GLdouble y, GLdouble z, GLdouble w); GLAPI void APIENTRY glProgramNamedParameter4dvNV (GLuint id, GLsizei len, const GLubyte *name, const GLdouble *v); GLAPI void APIENTRY glGetProgramNamedParameterfvNV (GLuint id, GLsizei len, const GLubyte *name, GLfloat *params); GLAPI void APIENTRY glGetProgramNamedParameterdvNV (GLuint id, GLsizei len, const GLubyte *name, GLdouble *params); #endif #endif /* GL_NV_fragment_program */ #ifndef GL_NV_fragment_program2 #define GL_NV_fragment_program2 1 #define GL_MAX_PROGRAM_EXEC_INSTRUCTIONS_NV 0x88F4 #define GL_MAX_PROGRAM_CALL_DEPTH_NV 0x88F5 #define GL_MAX_PROGRAM_IF_DEPTH_NV 0x88F6 #define GL_MAX_PROGRAM_LOOP_DEPTH_NV 0x88F7 #define GL_MAX_PROGRAM_LOOP_COUNT_NV 0x88F8 #endif /* GL_NV_fragment_program2 */ #ifndef GL_NV_fragment_program4 #define GL_NV_fragment_program4 1 #endif /* GL_NV_fragment_program4 */ #ifndef GL_NV_fragment_program_option #define GL_NV_fragment_program_option 1 #endif /* GL_NV_fragment_program_option */ #ifndef GL_NV_fragment_shader_barycentric #define GL_NV_fragment_shader_barycentric 1 #endif /* GL_NV_fragment_shader_barycentric */ #ifndef GL_NV_fragment_shader_interlock #define GL_NV_fragment_shader_interlock 1 #endif /* GL_NV_fragment_shader_interlock */ #ifndef GL_NV_framebuffer_mixed_samples #define GL_NV_framebuffer_mixed_samples 1 #define GL_COVERAGE_MODULATION_TABLE_NV 0x9331 #define GL_COLOR_SAMPLES_NV 0x8E20 #define GL_DEPTH_SAMPLES_NV 0x932D #define GL_STENCIL_SAMPLES_NV 0x932E #define GL_MIXED_DEPTH_SAMPLES_SUPPORTED_NV 0x932F #define GL_MIXED_STENCIL_SAMPLES_SUPPORTED_NV 0x9330 #define GL_COVERAGE_MODULATION_NV 0x9332 #define GL_COVERAGE_MODULATION_TABLE_SIZE_NV 0x9333 typedef void (APIENTRYP PFNGLCOVERAGEMODULATIONTABLENVPROC) (GLsizei n, const GLfloat *v); typedef void (APIENTRYP PFNGLGETCOVERAGEMODULATIONTABLENVPROC) (GLsizei bufSize, GLfloat *v); typedef void (APIENTRYP PFNGLCOVERAGEMODULATIONNVPROC) (GLenum components); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glCoverageModulationTableNV (GLsizei n, const GLfloat *v); GLAPI void APIENTRY glGetCoverageModulationTableNV (GLsizei bufSize, GLfloat *v); GLAPI void APIENTRY glCoverageModulationNV (GLenum components); #endif #endif /* GL_NV_framebuffer_mixed_samples */ #ifndef GL_NV_framebuffer_multisample_coverage #define GL_NV_framebuffer_multisample_coverage 1 #define GL_RENDERBUFFER_COVERAGE_SAMPLES_NV 0x8CAB #define GL_RENDERBUFFER_COLOR_SAMPLES_NV 0x8E10 #define GL_MAX_MULTISAMPLE_COVERAGE_MODES_NV 0x8E11 #define GL_MULTISAMPLE_COVERAGE_MODES_NV 0x8E12 typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLECOVERAGENVPROC) (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLenum internalformat, GLsizei width, GLsizei height); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glRenderbufferStorageMultisampleCoverageNV (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLenum internalformat, GLsizei width, GLsizei height); #endif #endif /* GL_NV_framebuffer_multisample_coverage */ #ifndef GL_NV_geometry_program4 #define GL_NV_geometry_program4 1 #define GL_GEOMETRY_PROGRAM_NV 0x8C26 #define GL_MAX_PROGRAM_OUTPUT_VERTICES_NV 0x8C27 #define GL_MAX_PROGRAM_TOTAL_OUTPUT_COMPONENTS_NV 0x8C28 typedef void (APIENTRYP PFNGLPROGRAMVERTEXLIMITNVPROC) (GLenum target, GLint limit); typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREEXTPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level); typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREFACEEXTPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLenum face); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glProgramVertexLimitNV (GLenum target, GLint limit); GLAPI void APIENTRY glFramebufferTextureEXT (GLenum target, GLenum attachment, GLuint texture, GLint level); GLAPI void APIENTRY glFramebufferTextureFaceEXT (GLenum target, GLenum attachment, GLuint texture, GLint level, GLenum face); #endif #endif /* GL_NV_geometry_program4 */ #ifndef GL_NV_geometry_shader4 #define GL_NV_geometry_shader4 1 #endif /* GL_NV_geometry_shader4 */ #ifndef GL_NV_geometry_shader_passthrough #define GL_NV_geometry_shader_passthrough 1 #endif /* GL_NV_geometry_shader_passthrough */ #ifndef GL_NV_gpu_multicast #define GL_NV_gpu_multicast 1 #define GL_PER_GPU_STORAGE_BIT_NV 0x0800 #define GL_MULTICAST_GPUS_NV 0x92BA #define GL_RENDER_GPU_MASK_NV 0x9558 #define GL_PER_GPU_STORAGE_NV 0x9548 #define GL_MULTICAST_PROGRAMMABLE_SAMPLE_LOCATION_NV 0x9549 typedef void (APIENTRYP PFNGLRENDERGPUMASKNVPROC) (GLbitfield mask); typedef void (APIENTRYP PFNGLMULTICASTBUFFERSUBDATANVPROC) (GLbitfield gpuMask, GLuint buffer, GLintptr offset, GLsizeiptr size, const void *data); typedef void (APIENTRYP PFNGLMULTICASTCOPYBUFFERSUBDATANVPROC) (GLuint readGPU, GLbitfield writeGPUMask, GLuint readBuffer, GLuint writeBuffer, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); typedef void (APIENTRYP PFNGLMULTICASTCOPYIMAGESUBDATANVPROC) (GLuint srcGPU, GLbitfield dstGPUMask, GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei srcWidth, GLsizei srcHeight, GLsizei srcDepth); typedef void (APIENTRYP PFNGLMULTICASTBLITFRAMEBUFFERNVPROC) (GLuint srcGPU, GLuint dstGPU, GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); typedef void (APIENTRYP PFNGLMULTICASTFRAMEBUFFERSAMPLELOCATIONSFVNVPROC) (GLuint gpu, GLuint framebuffer, GLuint start, GLsizei count, const GLfloat *v); typedef void (APIENTRYP PFNGLMULTICASTBARRIERNVPROC) (void); typedef void (APIENTRYP PFNGLMULTICASTWAITSYNCNVPROC) (GLuint signalGPU, GLbitfield waitGPUMask); typedef void (APIENTRYP PFNGLMULTICASTGETQUERYOBJECTIVNVPROC) (GLuint gpu, GLuint id, GLenum pname, GLint *params); typedef void (APIENTRYP PFNGLMULTICASTGETQUERYOBJECTUIVNVPROC) (GLuint gpu, GLuint id, GLenum pname, GLuint *params); typedef void (APIENTRYP PFNGLMULTICASTGETQUERYOBJECTI64VNVPROC) (GLuint gpu, GLuint id, GLenum pname, GLint64 *params); typedef void (APIENTRYP PFNGLMULTICASTGETQUERYOBJECTUI64VNVPROC) (GLuint gpu, GLuint id, GLenum pname, GLuint64 *params); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glRenderGPUMaskNV (GLbitfield mask); GLAPI void APIENTRY glMulticastBufferSubDataNV (GLbitfield gpuMask, GLuint buffer, GLintptr offset, GLsizeiptr size, const void *data); GLAPI void APIENTRY glMulticastCopyBufferSubDataNV (GLuint readGPU, GLbitfield writeGPUMask, GLuint readBuffer, GLuint writeBuffer, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); GLAPI void APIENTRY glMulticastCopyImageSubDataNV (GLuint srcGPU, GLbitfield dstGPUMask, GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei srcWidth, GLsizei srcHeight, GLsizei srcDepth); GLAPI void APIENTRY glMulticastBlitFramebufferNV (GLuint srcGPU, GLuint dstGPU, GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); GLAPI void APIENTRY glMulticastFramebufferSampleLocationsfvNV (GLuint gpu, GLuint framebuffer, GLuint start, GLsizei count, const GLfloat *v); GLAPI void APIENTRY glMulticastBarrierNV (void); GLAPI void APIENTRY glMulticastWaitSyncNV (GLuint signalGPU, GLbitfield waitGPUMask); GLAPI void APIENTRY glMulticastGetQueryObjectivNV (GLuint gpu, GLuint id, GLenum pname, GLint *params); GLAPI void APIENTRY glMulticastGetQueryObjectuivNV (GLuint gpu, GLuint id, GLenum pname, GLuint *params); GLAPI void APIENTRY glMulticastGetQueryObjecti64vNV (GLuint gpu, GLuint id, GLenum pname, GLint64 *params); GLAPI void APIENTRY glMulticastGetQueryObjectui64vNV (GLuint gpu, GLuint id, GLenum pname, GLuint64 *params); #endif #endif /* GL_NV_gpu_multicast */ #ifndef GL_NV_gpu_program4 #define GL_NV_gpu_program4 1 #define GL_MIN_PROGRAM_TEXEL_OFFSET_NV 0x8904 #define GL_MAX_PROGRAM_TEXEL_OFFSET_NV 0x8905 #define GL_PROGRAM_ATTRIB_COMPONENTS_NV 0x8906 #define GL_PROGRAM_RESULT_COMPONENTS_NV 0x8907 #define GL_MAX_PROGRAM_ATTRIB_COMPONENTS_NV 0x8908 #define GL_MAX_PROGRAM_RESULT_COMPONENTS_NV 0x8909 #define GL_MAX_PROGRAM_GENERIC_ATTRIBS_NV 0x8DA5 #define GL_MAX_PROGRAM_GENERIC_RESULTS_NV 0x8DA6 typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERI4INVPROC) (GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w); typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERI4IVNVPROC) (GLenum target, GLuint index, const GLint *params); typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERSI4IVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLint *params); typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERI4UINVPROC) (GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERI4UIVNVPROC) (GLenum target, GLuint index, const GLuint *params); typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERSI4UIVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLuint *params); typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERI4INVPROC) (GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w); typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERI4IVNVPROC) (GLenum target, GLuint index, const GLint *params); typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERSI4IVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLint *params); typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERI4UINVPROC) (GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERI4UIVNVPROC) (GLenum target, GLuint index, const GLuint *params); typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERSI4UIVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLuint *params); typedef void (APIENTRYP PFNGLGETPROGRAMLOCALPARAMETERIIVNVPROC) (GLenum target, GLuint index, GLint *params); typedef void (APIENTRYP PFNGLGETPROGRAMLOCALPARAMETERIUIVNVPROC) (GLenum target, GLuint index, GLuint *params); typedef void (APIENTRYP PFNGLGETPROGRAMENVPARAMETERIIVNVPROC) (GLenum target, GLuint index, GLint *params); typedef void (APIENTRYP PFNGLGETPROGRAMENVPARAMETERIUIVNVPROC) (GLenum target, GLuint index, GLuint *params); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glProgramLocalParameterI4iNV (GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w); GLAPI void APIENTRY glProgramLocalParameterI4ivNV (GLenum target, GLuint index, const GLint *params); GLAPI void APIENTRY glProgramLocalParametersI4ivNV (GLenum target, GLuint index, GLsizei count, const GLint *params); GLAPI void APIENTRY glProgramLocalParameterI4uiNV (GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); GLAPI void APIENTRY glProgramLocalParameterI4uivNV (GLenum target, GLuint index, const GLuint *params); GLAPI void APIENTRY glProgramLocalParametersI4uivNV (GLenum target, GLuint index, GLsizei count, const GLuint *params); GLAPI void APIENTRY glProgramEnvParameterI4iNV (GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w); GLAPI void APIENTRY glProgramEnvParameterI4ivNV (GLenum target, GLuint index, const GLint *params); GLAPI void APIENTRY glProgramEnvParametersI4ivNV (GLenum target, GLuint index, GLsizei count, const GLint *params); GLAPI void APIENTRY glProgramEnvParameterI4uiNV (GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); GLAPI void APIENTRY glProgramEnvParameterI4uivNV (GLenum target, GLuint index, const GLuint *params); GLAPI void APIENTRY glProgramEnvParametersI4uivNV (GLenum target, GLuint index, GLsizei count, const GLuint *params); GLAPI void APIENTRY glGetProgramLocalParameterIivNV (GLenum target, GLuint index, GLint *params); GLAPI void APIENTRY glGetProgramLocalParameterIuivNV (GLenum target, GLuint index, GLuint *params); GLAPI void APIENTRY glGetProgramEnvParameterIivNV (GLenum target, GLuint index, GLint *params); GLAPI void APIENTRY glGetProgramEnvParameterIuivNV (GLenum target, GLuint index, GLuint *params); #endif #endif /* GL_NV_gpu_program4 */ #ifndef GL_NV_gpu_program5 #define GL_NV_gpu_program5 1 #define GL_MAX_GEOMETRY_PROGRAM_INVOCATIONS_NV 0x8E5A #define GL_MIN_FRAGMENT_INTERPOLATION_OFFSET_NV 0x8E5B #define GL_MAX_FRAGMENT_INTERPOLATION_OFFSET_NV 0x8E5C #define GL_FRAGMENT_PROGRAM_INTERPOLATION_OFFSET_BITS_NV 0x8E5D #define GL_MIN_PROGRAM_TEXTURE_GATHER_OFFSET_NV 0x8E5E #define GL_MAX_PROGRAM_TEXTURE_GATHER_OFFSET_NV 0x8E5F #define GL_MAX_PROGRAM_SUBROUTINE_PARAMETERS_NV 0x8F44 #define GL_MAX_PROGRAM_SUBROUTINE_NUM_NV 0x8F45 typedef void (APIENTRYP PFNGLPROGRAMSUBROUTINEPARAMETERSUIVNVPROC) (GLenum target, GLsizei count, const GLuint *params); typedef void (APIENTRYP PFNGLGETPROGRAMSUBROUTINEPARAMETERUIVNVPROC) (GLenum target, GLuint index, GLuint *param); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glProgramSubroutineParametersuivNV (GLenum target, GLsizei count, const GLuint *params); GLAPI void APIENTRY glGetProgramSubroutineParameteruivNV (GLenum target, GLuint index, GLuint *param); #endif #endif /* GL_NV_gpu_program5 */ #ifndef GL_NV_gpu_program5_mem_extended #define GL_NV_gpu_program5_mem_extended 1 #endif /* GL_NV_gpu_program5_mem_extended */ #ifndef GL_NV_gpu_shader5 #define GL_NV_gpu_shader5 1 #endif /* GL_NV_gpu_shader5 */ #ifndef GL_NV_half_float #define GL_NV_half_float 1 typedef unsigned short GLhalfNV; #define GL_HALF_FLOAT_NV 0x140B typedef void (APIENTRYP PFNGLVERTEX2HNVPROC) (GLhalfNV x, GLhalfNV y); typedef void (APIENTRYP PFNGLVERTEX2HVNVPROC) (const GLhalfNV *v); typedef void (APIENTRYP PFNGLVERTEX3HNVPROC) (GLhalfNV x, GLhalfNV y, GLhalfNV z); typedef void (APIENTRYP PFNGLVERTEX3HVNVPROC) (const GLhalfNV *v); typedef void (APIENTRYP PFNGLVERTEX4HNVPROC) (GLhalfNV x, GLhalfNV y, GLhalfNV z, GLhalfNV w); typedef void (APIENTRYP PFNGLVERTEX4HVNVPROC) (const GLhalfNV *v); typedef void (APIENTRYP PFNGLNORMAL3HNVPROC) (GLhalfNV nx, GLhalfNV ny, GLhalfNV nz); typedef void (APIENTRYP PFNGLNORMAL3HVNVPROC) (const GLhalfNV *v); typedef void (APIENTRYP PFNGLCOLOR3HNVPROC) (GLhalfNV red, GLhalfNV green, GLhalfNV blue); typedef void (APIENTRYP PFNGLCOLOR3HVNVPROC) (const GLhalfNV *v); typedef void (APIENTRYP PFNGLCOLOR4HNVPROC) (GLhalfNV red, GLhalfNV green, GLhalfNV blue, GLhalfNV alpha); typedef void (APIENTRYP PFNGLCOLOR4HVNVPROC) (const GLhalfNV *v); typedef void (APIENTRYP PFNGLTEXCOORD1HNVPROC) (GLhalfNV s); typedef void (APIENTRYP PFNGLTEXCOORD1HVNVPROC) (const GLhalfNV *v); typedef void (APIENTRYP PFNGLTEXCOORD2HNVPROC) (GLhalfNV s, GLhalfNV t); typedef void (APIENTRYP PFNGLTEXCOORD2HVNVPROC) (const GLhalfNV *v); typedef void (APIENTRYP PFNGLTEXCOORD3HNVPROC) (GLhalfNV s, GLhalfNV t, GLhalfNV r); typedef void (APIENTRYP PFNGLTEXCOORD3HVNVPROC) (const GLhalfNV *v); typedef void (APIENTRYP PFNGLTEXCOORD4HNVPROC) (GLhalfNV s, GLhalfNV t, GLhalfNV r, GLhalfNV q); typedef void (APIENTRYP PFNGLTEXCOORD4HVNVPROC) (const GLhalfNV *v); typedef void (APIENTRYP PFNGLMULTITEXCOORD1HNVPROC) (GLenum target, GLhalfNV s); typedef void (APIENTRYP PFNGLMULTITEXCOORD1HVNVPROC) (GLenum target, const GLhalfNV *v); typedef void (APIENTRYP PFNGLMULTITEXCOORD2HNVPROC) (GLenum target, GLhalfNV s, GLhalfNV t); typedef void (APIENTRYP PFNGLMULTITEXCOORD2HVNVPROC) (GLenum target, const GLhalfNV *v); typedef void (APIENTRYP PFNGLMULTITEXCOORD3HNVPROC) (GLenum target, GLhalfNV s, GLhalfNV t, GLhalfNV r); typedef void (APIENTRYP PFNGLMULTITEXCOORD3HVNVPROC) (GLenum target, const GLhalfNV *v); typedef void (APIENTRYP PFNGLMULTITEXCOORD4HNVPROC) (GLenum target, GLhalfNV s, GLhalfNV t, GLhalfNV r, GLhalfNV q); typedef void (APIENTRYP PFNGLMULTITEXCOORD4HVNVPROC) (GLenum target, const GLhalfNV *v); typedef void (APIENTRYP PFNGLFOGCOORDHNVPROC) (GLhalfNV fog); typedef void (APIENTRYP PFNGLFOGCOORDHVNVPROC) (const GLhalfNV *fog); typedef void (APIENTRYP PFNGLSECONDARYCOLOR3HNVPROC) (GLhalfNV red, GLhalfNV green, GLhalfNV blue); typedef void (APIENTRYP PFNGLSECONDARYCOLOR3HVNVPROC) (const GLhalfNV *v); typedef void (APIENTRYP PFNGLVERTEXWEIGHTHNVPROC) (GLhalfNV weight); typedef void (APIENTRYP PFNGLVERTEXWEIGHTHVNVPROC) (const GLhalfNV *weight); typedef void (APIENTRYP PFNGLVERTEXATTRIB1HNVPROC) (GLuint index, GLhalfNV x); typedef void (APIENTRYP PFNGLVERTEXATTRIB1HVNVPROC) (GLuint index, const GLhalfNV *v); typedef void (APIENTRYP PFNGLVERTEXATTRIB2HNVPROC) (GLuint index, GLhalfNV x, GLhalfNV y); typedef void (APIENTRYP PFNGLVERTEXATTRIB2HVNVPROC) (GLuint index, const GLhalfNV *v); typedef void (APIENTRYP PFNGLVERTEXATTRIB3HNVPROC) (GLuint index, GLhalfNV x, GLhalfNV y, GLhalfNV z); typedef void (APIENTRYP PFNGLVERTEXATTRIB3HVNVPROC) (GLuint index, const GLhalfNV *v); typedef void (APIENTRYP PFNGLVERTEXATTRIB4HNVPROC) (GLuint index, GLhalfNV x, GLhalfNV y, GLhalfNV z, GLhalfNV w); typedef void (APIENTRYP PFNGLVERTEXATTRIB4HVNVPROC) (GLuint index, const GLhalfNV *v); typedef void (APIENTRYP PFNGLVERTEXATTRIBS1HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v); typedef void (APIENTRYP PFNGLVERTEXATTRIBS2HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v); typedef void (APIENTRYP PFNGLVERTEXATTRIBS3HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v); typedef void (APIENTRYP PFNGLVERTEXATTRIBS4HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glVertex2hNV (GLhalfNV x, GLhalfNV y); GLAPI void APIENTRY glVertex2hvNV (const GLhalfNV *v); GLAPI void APIENTRY glVertex3hNV (GLhalfNV x, GLhalfNV y, GLhalfNV z); GLAPI void APIENTRY glVertex3hvNV (const GLhalfNV *v); GLAPI void APIENTRY glVertex4hNV (GLhalfNV x, GLhalfNV y, GLhalfNV z, GLhalfNV w); GLAPI void APIENTRY glVertex4hvNV (const GLhalfNV *v); GLAPI void APIENTRY glNormal3hNV (GLhalfNV nx, GLhalfNV ny, GLhalfNV nz); GLAPI void APIENTRY glNormal3hvNV (const GLhalfNV *v); GLAPI void APIENTRY glColor3hNV (GLhalfNV red, GLhalfNV green, GLhalfNV blue); GLAPI void APIENTRY glColor3hvNV (const GLhalfNV *v); GLAPI void APIENTRY glColor4hNV (GLhalfNV red, GLhalfNV green, GLhalfNV blue, GLhalfNV alpha); GLAPI void APIENTRY glColor4hvNV (const GLhalfNV *v); GLAPI void APIENTRY glTexCoord1hNV (GLhalfNV s); GLAPI void APIENTRY glTexCoord1hvNV (const GLhalfNV *v); GLAPI void APIENTRY glTexCoord2hNV (GLhalfNV s, GLhalfNV t); GLAPI void APIENTRY glTexCoord2hvNV (const GLhalfNV *v); GLAPI void APIENTRY glTexCoord3hNV (GLhalfNV s, GLhalfNV t, GLhalfNV r); GLAPI void APIENTRY glTexCoord3hvNV (const GLhalfNV *v); GLAPI void APIENTRY glTexCoord4hNV (GLhalfNV s, GLhalfNV t, GLhalfNV r, GLhalfNV q); GLAPI void APIENTRY glTexCoord4hvNV (const GLhalfNV *v); GLAPI void APIENTRY glMultiTexCoord1hNV (GLenum target, GLhalfNV s); GLAPI void APIENTRY glMultiTexCoord1hvNV (GLenum target, const GLhalfNV *v); GLAPI void APIENTRY glMultiTexCoord2hNV (GLenum target, GLhalfNV s, GLhalfNV t); GLAPI void APIENTRY glMultiTexCoord2hvNV (GLenum target, const GLhalfNV *v); GLAPI void APIENTRY glMultiTexCoord3hNV (GLenum target, GLhalfNV s, GLhalfNV t, GLhalfNV r); GLAPI void APIENTRY glMultiTexCoord3hvNV (GLenum target, const GLhalfNV *v); GLAPI void APIENTRY glMultiTexCoord4hNV (GLenum target, GLhalfNV s, GLhalfNV t, GLhalfNV r, GLhalfNV q); GLAPI void APIENTRY glMultiTexCoord4hvNV (GLenum target, const GLhalfNV *v); GLAPI void APIENTRY glFogCoordhNV (GLhalfNV fog); GLAPI void APIENTRY glFogCoordhvNV (const GLhalfNV *fog); GLAPI void APIENTRY glSecondaryColor3hNV (GLhalfNV red, GLhalfNV green, GLhalfNV blue); GLAPI void APIENTRY glSecondaryColor3hvNV (const GLhalfNV *v); GLAPI void APIENTRY glVertexWeighthNV (GLhalfNV weight); GLAPI void APIENTRY glVertexWeighthvNV (const GLhalfNV *weight); GLAPI void APIENTRY glVertexAttrib1hNV (GLuint index, GLhalfNV x); GLAPI void APIENTRY glVertexAttrib1hvNV (GLuint index, const GLhalfNV *v); GLAPI void APIENTRY glVertexAttrib2hNV (GLuint index, GLhalfNV x, GLhalfNV y); GLAPI void APIENTRY glVertexAttrib2hvNV (GLuint index, const GLhalfNV *v); GLAPI void APIENTRY glVertexAttrib3hNV (GLuint index, GLhalfNV x, GLhalfNV y, GLhalfNV z); GLAPI void APIENTRY glVertexAttrib3hvNV (GLuint index, const GLhalfNV *v); GLAPI void APIENTRY glVertexAttrib4hNV (GLuint index, GLhalfNV x, GLhalfNV y, GLhalfNV z, GLhalfNV w); GLAPI void APIENTRY glVertexAttrib4hvNV (GLuint index, const GLhalfNV *v); GLAPI void APIENTRY glVertexAttribs1hvNV (GLuint index, GLsizei n, const GLhalfNV *v); GLAPI void APIENTRY glVertexAttribs2hvNV (GLuint index, GLsizei n, const GLhalfNV *v); GLAPI void APIENTRY glVertexAttribs3hvNV (GLuint index, GLsizei n, const GLhalfNV *v); GLAPI void APIENTRY glVertexAttribs4hvNV (GLuint index, GLsizei n, const GLhalfNV *v); #endif #endif /* GL_NV_half_float */ #ifndef GL_NV_internalformat_sample_query #define GL_NV_internalformat_sample_query 1 #define GL_MULTISAMPLES_NV 0x9371 #define GL_SUPERSAMPLE_SCALE_X_NV 0x9372 #define GL_SUPERSAMPLE_SCALE_Y_NV 0x9373 #define GL_CONFORMANT_NV 0x9374 typedef void (APIENTRYP PFNGLGETINTERNALFORMATSAMPLEIVNVPROC) (GLenum target, GLenum internalformat, GLsizei samples, GLenum pname, GLsizei count, GLint *params); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glGetInternalformatSampleivNV (GLenum target, GLenum internalformat, GLsizei samples, GLenum pname, GLsizei count, GLint *params); #endif #endif /* GL_NV_internalformat_sample_query */ #ifndef GL_NV_light_max_exponent #define GL_NV_light_max_exponent 1 #define GL_MAX_SHININESS_NV 0x8504 #define GL_MAX_SPOT_EXPONENT_NV 0x8505 #endif /* GL_NV_light_max_exponent */ #ifndef GL_NV_memory_attachment #define GL_NV_memory_attachment 1 #define GL_ATTACHED_MEMORY_OBJECT_NV 0x95A4 #define GL_ATTACHED_MEMORY_OFFSET_NV 0x95A5 #define GL_MEMORY_ATTACHABLE_ALIGNMENT_NV 0x95A6 #define GL_MEMORY_ATTACHABLE_SIZE_NV 0x95A7 #define GL_MEMORY_ATTACHABLE_NV 0x95A8 #define GL_DETACHED_MEMORY_INCARNATION_NV 0x95A9 #define GL_DETACHED_TEXTURES_NV 0x95AA #define GL_DETACHED_BUFFERS_NV 0x95AB #define GL_MAX_DETACHED_TEXTURES_NV 0x95AC #define GL_MAX_DETACHED_BUFFERS_NV 0x95AD typedef void (APIENTRYP PFNGLGETMEMORYOBJECTDETACHEDRESOURCESUIVNVPROC) (GLuint memory, GLenum pname, GLint first, GLsizei count, GLuint *params); typedef void (APIENTRYP PFNGLRESETMEMORYOBJECTPARAMETERNVPROC) (GLuint memory, GLenum pname); typedef void (APIENTRYP PFNGLTEXATTACHMEMORYNVPROC) (GLenum target, GLuint memory, GLuint64 offset); typedef void (APIENTRYP PFNGLBUFFERATTACHMEMORYNVPROC) (GLenum target, GLuint memory, GLuint64 offset); typedef void (APIENTRYP PFNGLTEXTUREATTACHMEMORYNVPROC) (GLuint texture, GLuint memory, GLuint64 offset); typedef void (APIENTRYP PFNGLNAMEDBUFFERATTACHMEMORYNVPROC) (GLuint buffer, GLuint memory, GLuint64 offset); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glGetMemoryObjectDetachedResourcesuivNV (GLuint memory, GLenum pname, GLint first, GLsizei count, GLuint *params); GLAPI void APIENTRY glResetMemoryObjectParameterNV (GLuint memory, GLenum pname); GLAPI void APIENTRY glTexAttachMemoryNV (GLenum target, GLuint memory, GLuint64 offset); GLAPI void APIENTRY glBufferAttachMemoryNV (GLenum target, GLuint memory, GLuint64 offset); GLAPI void APIENTRY glTextureAttachMemoryNV (GLuint texture, GLuint memory, GLuint64 offset); GLAPI void APIENTRY glNamedBufferAttachMemoryNV (GLuint buffer, GLuint memory, GLuint64 offset); #endif #endif /* GL_NV_memory_attachment */ #ifndef GL_NV_memory_object_sparse #define GL_NV_memory_object_sparse 1 typedef void (APIENTRYP PFNGLBUFFERPAGECOMMITMENTMEMNVPROC) (GLenum target, GLintptr offset, GLsizeiptr size, GLuint memory, GLuint64 memOffset, GLboolean commit); typedef void (APIENTRYP PFNGLTEXPAGECOMMITMENTMEMNVPROC) (GLenum target, GLint layer, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLuint memory, GLuint64 offset, GLboolean commit); typedef void (APIENTRYP PFNGLNAMEDBUFFERPAGECOMMITMENTMEMNVPROC) (GLuint buffer, GLintptr offset, GLsizeiptr size, GLuint memory, GLuint64 memOffset, GLboolean commit); typedef void (APIENTRYP PFNGLTEXTUREPAGECOMMITMENTMEMNVPROC) (GLuint texture, GLint layer, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLuint memory, GLuint64 offset, GLboolean commit); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glBufferPageCommitmentMemNV (GLenum target, GLintptr offset, GLsizeiptr size, GLuint memory, GLuint64 memOffset, GLboolean commit); GLAPI void APIENTRY glTexPageCommitmentMemNV (GLenum target, GLint layer, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLuint memory, GLuint64 offset, GLboolean commit); GLAPI void APIENTRY glNamedBufferPageCommitmentMemNV (GLuint buffer, GLintptr offset, GLsizeiptr size, GLuint memory, GLuint64 memOffset, GLboolean commit); GLAPI void APIENTRY glTexturePageCommitmentMemNV (GLuint texture, GLint layer, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLuint memory, GLuint64 offset, GLboolean commit); #endif #endif /* GL_NV_memory_object_sparse */ #ifndef GL_NV_mesh_shader #define GL_NV_mesh_shader 1 #define GL_MESH_SHADER_NV 0x9559 #define GL_TASK_SHADER_NV 0x955A #define GL_MAX_MESH_UNIFORM_BLOCKS_NV 0x8E60 #define GL_MAX_MESH_TEXTURE_IMAGE_UNITS_NV 0x8E61 #define GL_MAX_MESH_IMAGE_UNIFORMS_NV 0x8E62 #define GL_MAX_MESH_UNIFORM_COMPONENTS_NV 0x8E63 #define GL_MAX_MESH_ATOMIC_COUNTER_BUFFERS_NV 0x8E64 #define GL_MAX_MESH_ATOMIC_COUNTERS_NV 0x8E65 #define GL_MAX_MESH_SHADER_STORAGE_BLOCKS_NV 0x8E66 #define GL_MAX_COMBINED_MESH_UNIFORM_COMPONENTS_NV 0x8E67 #define GL_MAX_TASK_UNIFORM_BLOCKS_NV 0x8E68 #define GL_MAX_TASK_TEXTURE_IMAGE_UNITS_NV 0x8E69 #define GL_MAX_TASK_IMAGE_UNIFORMS_NV 0x8E6A #define GL_MAX_TASK_UNIFORM_COMPONENTS_NV 0x8E6B #define GL_MAX_TASK_ATOMIC_COUNTER_BUFFERS_NV 0x8E6C #define GL_MAX_TASK_ATOMIC_COUNTERS_NV 0x8E6D #define GL_MAX_TASK_SHADER_STORAGE_BLOCKS_NV 0x8E6E #define GL_MAX_COMBINED_TASK_UNIFORM_COMPONENTS_NV 0x8E6F #define GL_MAX_MESH_WORK_GROUP_INVOCATIONS_NV 0x95A2 #define GL_MAX_TASK_WORK_GROUP_INVOCATIONS_NV 0x95A3 #define GL_MAX_MESH_TOTAL_MEMORY_SIZE_NV 0x9536 #define GL_MAX_TASK_TOTAL_MEMORY_SIZE_NV 0x9537 #define GL_MAX_MESH_OUTPUT_VERTICES_NV 0x9538 #define GL_MAX_MESH_OUTPUT_PRIMITIVES_NV 0x9539 #define GL_MAX_TASK_OUTPUT_COUNT_NV 0x953A #define GL_MAX_DRAW_MESH_TASKS_COUNT_NV 0x953D #define GL_MAX_MESH_VIEWS_NV 0x9557 #define GL_MESH_OUTPUT_PER_VERTEX_GRANULARITY_NV 0x92DF #define GL_MESH_OUTPUT_PER_PRIMITIVE_GRANULARITY_NV 0x9543 #define GL_MAX_MESH_WORK_GROUP_SIZE_NV 0x953B #define GL_MAX_TASK_WORK_GROUP_SIZE_NV 0x953C #define GL_MESH_WORK_GROUP_SIZE_NV 0x953E #define GL_TASK_WORK_GROUP_SIZE_NV 0x953F #define GL_MESH_VERTICES_OUT_NV 0x9579 #define GL_MESH_PRIMITIVES_OUT_NV 0x957A #define GL_MESH_OUTPUT_TYPE_NV 0x957B #define GL_UNIFORM_BLOCK_REFERENCED_BY_MESH_SHADER_NV 0x959C #define GL_UNIFORM_BLOCK_REFERENCED_BY_TASK_SHADER_NV 0x959D #define GL_REFERENCED_BY_MESH_SHADER_NV 0x95A0 #define GL_REFERENCED_BY_TASK_SHADER_NV 0x95A1 #define GL_MESH_SHADER_BIT_NV 0x00000040 #define GL_TASK_SHADER_BIT_NV 0x00000080 #define GL_MESH_SUBROUTINE_NV 0x957C #define GL_TASK_SUBROUTINE_NV 0x957D #define GL_MESH_SUBROUTINE_UNIFORM_NV 0x957E #define GL_TASK_SUBROUTINE_UNIFORM_NV 0x957F #define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_MESH_SHADER_NV 0x959E #define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_TASK_SHADER_NV 0x959F typedef void (APIENTRYP PFNGLDRAWMESHTASKSNVPROC) (GLuint first, GLuint count); typedef void (APIENTRYP PFNGLDRAWMESHTASKSINDIRECTNVPROC) (GLintptr indirect); typedef void (APIENTRYP PFNGLMULTIDRAWMESHTASKSINDIRECTNVPROC) (GLintptr indirect, GLsizei drawcount, GLsizei stride); typedef void (APIENTRYP PFNGLMULTIDRAWMESHTASKSINDIRECTCOUNTNVPROC) (GLintptr indirect, GLintptr drawcount, GLsizei maxdrawcount, GLsizei stride); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glDrawMeshTasksNV (GLuint first, GLuint count); GLAPI void APIENTRY glDrawMeshTasksIndirectNV (GLintptr indirect); GLAPI void APIENTRY glMultiDrawMeshTasksIndirectNV (GLintptr indirect, GLsizei drawcount, GLsizei stride); GLAPI void APIENTRY glMultiDrawMeshTasksIndirectCountNV (GLintptr indirect, GLintptr drawcount, GLsizei maxdrawcount, GLsizei stride); #endif #endif /* GL_NV_mesh_shader */ #ifndef GL_NV_multisample_coverage #define GL_NV_multisample_coverage 1 #endif /* GL_NV_multisample_coverage */ #ifndef GL_NV_multisample_filter_hint #define GL_NV_multisample_filter_hint 1 #define GL_MULTISAMPLE_FILTER_HINT_NV 0x8534 #endif /* GL_NV_multisample_filter_hint */ #ifndef GL_NV_occlusion_query #define GL_NV_occlusion_query 1 #define GL_PIXEL_COUNTER_BITS_NV 0x8864 #define GL_CURRENT_OCCLUSION_QUERY_ID_NV 0x8865 #define GL_PIXEL_COUNT_NV 0x8866 #define GL_PIXEL_COUNT_AVAILABLE_NV 0x8867 typedef void (APIENTRYP PFNGLGENOCCLUSIONQUERIESNVPROC) (GLsizei n, GLuint *ids); typedef void (APIENTRYP PFNGLDELETEOCCLUSIONQUERIESNVPROC) (GLsizei n, const GLuint *ids); typedef GLboolean (APIENTRYP PFNGLISOCCLUSIONQUERYNVPROC) (GLuint id); typedef void (APIENTRYP PFNGLBEGINOCCLUSIONQUERYNVPROC) (GLuint id); typedef void (APIENTRYP PFNGLENDOCCLUSIONQUERYNVPROC) (void); typedef void (APIENTRYP PFNGLGETOCCLUSIONQUERYIVNVPROC) (GLuint id, GLenum pname, GLint *params); typedef void (APIENTRYP PFNGLGETOCCLUSIONQUERYUIVNVPROC) (GLuint id, GLenum pname, GLuint *params); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glGenOcclusionQueriesNV (GLsizei n, GLuint *ids); GLAPI void APIENTRY glDeleteOcclusionQueriesNV (GLsizei n, const GLuint *ids); GLAPI GLboolean APIENTRY glIsOcclusionQueryNV (GLuint id); GLAPI void APIENTRY glBeginOcclusionQueryNV (GLuint id); GLAPI void APIENTRY glEndOcclusionQueryNV (void); GLAPI void APIENTRY glGetOcclusionQueryivNV (GLuint id, GLenum pname, GLint *params); GLAPI void APIENTRY glGetOcclusionQueryuivNV (GLuint id, GLenum pname, GLuint *params); #endif #endif /* GL_NV_occlusion_query */ #ifndef GL_NV_packed_depth_stencil #define GL_NV_packed_depth_stencil 1 #define GL_DEPTH_STENCIL_NV 0x84F9 #define GL_UNSIGNED_INT_24_8_NV 0x84FA #endif /* GL_NV_packed_depth_stencil */ #ifndef GL_NV_parameter_buffer_object #define GL_NV_parameter_buffer_object 1 #define GL_MAX_PROGRAM_PARAMETER_BUFFER_BINDINGS_NV 0x8DA0 #define GL_MAX_PROGRAM_PARAMETER_BUFFER_SIZE_NV 0x8DA1 #define GL_VERTEX_PROGRAM_PARAMETER_BUFFER_NV 0x8DA2 #define GL_GEOMETRY_PROGRAM_PARAMETER_BUFFER_NV 0x8DA3 #define GL_FRAGMENT_PROGRAM_PARAMETER_BUFFER_NV 0x8DA4 typedef void (APIENTRYP PFNGLPROGRAMBUFFERPARAMETERSFVNVPROC) (GLenum target, GLuint bindingIndex, GLuint wordIndex, GLsizei count, const GLfloat *params); typedef void (APIENTRYP PFNGLPROGRAMBUFFERPARAMETERSIIVNVPROC) (GLenum target, GLuint bindingIndex, GLuint wordIndex, GLsizei count, const GLint *params); typedef void (APIENTRYP PFNGLPROGRAMBUFFERPARAMETERSIUIVNVPROC) (GLenum target, GLuint bindingIndex, GLuint wordIndex, GLsizei count, const GLuint *params); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glProgramBufferParametersfvNV (GLenum target, GLuint bindingIndex, GLuint wordIndex, GLsizei count, const GLfloat *params); GLAPI void APIENTRY glProgramBufferParametersIivNV (GLenum target, GLuint bindingIndex, GLuint wordIndex, GLsizei count, const GLint *params); GLAPI void APIENTRY glProgramBufferParametersIuivNV (GLenum target, GLuint bindingIndex, GLuint wordIndex, GLsizei count, const GLuint *params); #endif #endif /* GL_NV_parameter_buffer_object */ #ifndef GL_NV_parameter_buffer_object2 #define GL_NV_parameter_buffer_object2 1 #endif /* GL_NV_parameter_buffer_object2 */ #ifndef GL_NV_path_rendering #define GL_NV_path_rendering 1 #define GL_PATH_FORMAT_SVG_NV 0x9070 #define GL_PATH_FORMAT_PS_NV 0x9071 #define GL_STANDARD_FONT_NAME_NV 0x9072 #define GL_SYSTEM_FONT_NAME_NV 0x9073 #define GL_FILE_NAME_NV 0x9074 #define GL_PATH_STROKE_WIDTH_NV 0x9075 #define GL_PATH_END_CAPS_NV 0x9076 #define GL_PATH_INITIAL_END_CAP_NV 0x9077 #define GL_PATH_TERMINAL_END_CAP_NV 0x9078 #define GL_PATH_JOIN_STYLE_NV 0x9079 #define GL_PATH_MITER_LIMIT_NV 0x907A #define GL_PATH_DASH_CAPS_NV 0x907B #define GL_PATH_INITIAL_DASH_CAP_NV 0x907C #define GL_PATH_TERMINAL_DASH_CAP_NV 0x907D #define GL_PATH_DASH_OFFSET_NV 0x907E #define GL_PATH_CLIENT_LENGTH_NV 0x907F #define GL_PATH_FILL_MODE_NV 0x9080 #define GL_PATH_FILL_MASK_NV 0x9081 #define GL_PATH_FILL_COVER_MODE_NV 0x9082 #define GL_PATH_STROKE_COVER_MODE_NV 0x9083 #define GL_PATH_STROKE_MASK_NV 0x9084 #define GL_COUNT_UP_NV 0x9088 #define GL_COUNT_DOWN_NV 0x9089 #define GL_PATH_OBJECT_BOUNDING_BOX_NV 0x908A #define GL_CONVEX_HULL_NV 0x908B #define GL_BOUNDING_BOX_NV 0x908D #define GL_TRANSLATE_X_NV 0x908E #define GL_TRANSLATE_Y_NV 0x908F #define GL_TRANSLATE_2D_NV 0x9090 #define GL_TRANSLATE_3D_NV 0x9091 #define GL_AFFINE_2D_NV 0x9092 #define GL_AFFINE_3D_NV 0x9094 #define GL_TRANSPOSE_AFFINE_2D_NV 0x9096 #define GL_TRANSPOSE_AFFINE_3D_NV 0x9098 #define GL_UTF8_NV 0x909A #define GL_UTF16_NV 0x909B #define GL_BOUNDING_BOX_OF_BOUNDING_BOXES_NV 0x909C #define GL_PATH_COMMAND_COUNT_NV 0x909D #define GL_PATH_COORD_COUNT_NV 0x909E #define GL_PATH_DASH_ARRAY_COUNT_NV 0x909F #define GL_PATH_COMPUTED_LENGTH_NV 0x90A0 #define GL_PATH_FILL_BOUNDING_BOX_NV 0x90A1 #define GL_PATH_STROKE_BOUNDING_BOX_NV 0x90A2 #define GL_SQUARE_NV 0x90A3 #define GL_ROUND_NV 0x90A4 #define GL_TRIANGULAR_NV 0x90A5 #define GL_BEVEL_NV 0x90A6 #define GL_MITER_REVERT_NV 0x90A7 #define GL_MITER_TRUNCATE_NV 0x90A8 #define GL_SKIP_MISSING_GLYPH_NV 0x90A9 #define GL_USE_MISSING_GLYPH_NV 0x90AA #define GL_PATH_ERROR_POSITION_NV 0x90AB #define GL_ACCUM_ADJACENT_PAIRS_NV 0x90AD #define GL_ADJACENT_PAIRS_NV 0x90AE #define GL_FIRST_TO_REST_NV 0x90AF #define GL_PATH_GEN_MODE_NV 0x90B0 #define GL_PATH_GEN_COEFF_NV 0x90B1 #define GL_PATH_GEN_COMPONENTS_NV 0x90B3 #define GL_PATH_STENCIL_FUNC_NV 0x90B7 #define GL_PATH_STENCIL_REF_NV 0x90B8 #define GL_PATH_STENCIL_VALUE_MASK_NV 0x90B9 #define GL_PATH_STENCIL_DEPTH_OFFSET_FACTOR_NV 0x90BD #define GL_PATH_STENCIL_DEPTH_OFFSET_UNITS_NV 0x90BE #define GL_PATH_COVER_DEPTH_FUNC_NV 0x90BF #define GL_PATH_DASH_OFFSET_RESET_NV 0x90B4 #define GL_MOVE_TO_RESETS_NV 0x90B5 #define GL_MOVE_TO_CONTINUES_NV 0x90B6 #define GL_CLOSE_PATH_NV 0x00 #define GL_MOVE_TO_NV 0x02 #define GL_RELATIVE_MOVE_TO_NV 0x03 #define GL_LINE_TO_NV 0x04 #define GL_RELATIVE_LINE_TO_NV 0x05 #define GL_HORIZONTAL_LINE_TO_NV 0x06 #define GL_RELATIVE_HORIZONTAL_LINE_TO_NV 0x07 #define GL_VERTICAL_LINE_TO_NV 0x08 #define GL_RELATIVE_VERTICAL_LINE_TO_NV 0x09 #define GL_QUADRATIC_CURVE_TO_NV 0x0A #define GL_RELATIVE_QUADRATIC_CURVE_TO_NV 0x0B #define GL_CUBIC_CURVE_TO_NV 0x0C #define GL_RELATIVE_CUBIC_CURVE_TO_NV 0x0D #define GL_SMOOTH_QUADRATIC_CURVE_TO_NV 0x0E #define GL_RELATIVE_SMOOTH_QUADRATIC_CURVE_TO_NV 0x0F #define GL_SMOOTH_CUBIC_CURVE_TO_NV 0x10 #define GL_RELATIVE_SMOOTH_CUBIC_CURVE_TO_NV 0x11 #define GL_SMALL_CCW_ARC_TO_NV 0x12 #define GL_RELATIVE_SMALL_CCW_ARC_TO_NV 0x13 #define GL_SMALL_CW_ARC_TO_NV 0x14 #define GL_RELATIVE_SMALL_CW_ARC_TO_NV 0x15 #define GL_LARGE_CCW_ARC_TO_NV 0x16 #define GL_RELATIVE_LARGE_CCW_ARC_TO_NV 0x17 #define GL_LARGE_CW_ARC_TO_NV 0x18 #define GL_RELATIVE_LARGE_CW_ARC_TO_NV 0x19 #define GL_RESTART_PATH_NV 0xF0 #define GL_DUP_FIRST_CUBIC_CURVE_TO_NV 0xF2 #define GL_DUP_LAST_CUBIC_CURVE_TO_NV 0xF4 #define GL_RECT_NV 0xF6 #define GL_CIRCULAR_CCW_ARC_TO_NV 0xF8 #define GL_CIRCULAR_CW_ARC_TO_NV 0xFA #define GL_CIRCULAR_TANGENT_ARC_TO_NV 0xFC #define GL_ARC_TO_NV 0xFE #define GL_RELATIVE_ARC_TO_NV 0xFF #define GL_BOLD_BIT_NV 0x01 #define GL_ITALIC_BIT_NV 0x02 #define GL_GLYPH_WIDTH_BIT_NV 0x01 #define GL_GLYPH_HEIGHT_BIT_NV 0x02 #define GL_GLYPH_HORIZONTAL_BEARING_X_BIT_NV 0x04 #define GL_GLYPH_HORIZONTAL_BEARING_Y_BIT_NV 0x08 #define GL_GLYPH_HORIZONTAL_BEARING_ADVANCE_BIT_NV 0x10 #define GL_GLYPH_VERTICAL_BEARING_X_BIT_NV 0x20 #define GL_GLYPH_VERTICAL_BEARING_Y_BIT_NV 0x40 #define GL_GLYPH_VERTICAL_BEARING_ADVANCE_BIT_NV 0x80 #define GL_GLYPH_HAS_KERNING_BIT_NV 0x100 #define GL_FONT_X_MIN_BOUNDS_BIT_NV 0x00010000 #define GL_FONT_Y_MIN_BOUNDS_BIT_NV 0x00020000 #define GL_FONT_X_MAX_BOUNDS_BIT_NV 0x00040000 #define GL_FONT_Y_MAX_BOUNDS_BIT_NV 0x00080000 #define GL_FONT_UNITS_PER_EM_BIT_NV 0x00100000 #define GL_FONT_ASCENDER_BIT_NV 0x00200000 #define GL_FONT_DESCENDER_BIT_NV 0x00400000 #define GL_FONT_HEIGHT_BIT_NV 0x00800000 #define GL_FONT_MAX_ADVANCE_WIDTH_BIT_NV 0x01000000 #define GL_FONT_MAX_ADVANCE_HEIGHT_BIT_NV 0x02000000 #define GL_FONT_UNDERLINE_POSITION_BIT_NV 0x04000000 #define GL_FONT_UNDERLINE_THICKNESS_BIT_NV 0x08000000 #define GL_FONT_HAS_KERNING_BIT_NV 0x10000000 #define GL_ROUNDED_RECT_NV 0xE8 #define GL_RELATIVE_ROUNDED_RECT_NV 0xE9 #define GL_ROUNDED_RECT2_NV 0xEA #define GL_RELATIVE_ROUNDED_RECT2_NV 0xEB #define GL_ROUNDED_RECT4_NV 0xEC #define GL_RELATIVE_ROUNDED_RECT4_NV 0xED #define GL_ROUNDED_RECT8_NV 0xEE #define GL_RELATIVE_ROUNDED_RECT8_NV 0xEF #define GL_RELATIVE_RECT_NV 0xF7 #define GL_FONT_GLYPHS_AVAILABLE_NV 0x9368 #define GL_FONT_TARGET_UNAVAILABLE_NV 0x9369 #define GL_FONT_UNAVAILABLE_NV 0x936A #define GL_FONT_UNINTELLIGIBLE_NV 0x936B #define GL_CONIC_CURVE_TO_NV 0x1A #define GL_RELATIVE_CONIC_CURVE_TO_NV 0x1B #define GL_FONT_NUM_GLYPH_INDICES_BIT_NV 0x20000000 #define GL_STANDARD_FONT_FORMAT_NV 0x936C #define GL_2_BYTES_NV 0x1407 #define GL_3_BYTES_NV 0x1408 #define GL_4_BYTES_NV 0x1409 #define GL_EYE_LINEAR_NV 0x2400 #define GL_OBJECT_LINEAR_NV 0x2401 #define GL_CONSTANT_NV 0x8576 #define GL_PATH_FOG_GEN_MODE_NV 0x90AC #define GL_PRIMARY_COLOR_NV 0x852C #define GL_SECONDARY_COLOR_NV 0x852D #define GL_PATH_GEN_COLOR_FORMAT_NV 0x90B2 #define GL_PATH_PROJECTION_NV 0x1701 #define GL_PATH_MODELVIEW_NV 0x1700 #define GL_PATH_MODELVIEW_STACK_DEPTH_NV 0x0BA3 #define GL_PATH_MODELVIEW_MATRIX_NV 0x0BA6 #define GL_PATH_MAX_MODELVIEW_STACK_DEPTH_NV 0x0D36 #define GL_PATH_TRANSPOSE_MODELVIEW_MATRIX_NV 0x84E3 #define GL_PATH_PROJECTION_STACK_DEPTH_NV 0x0BA4 #define GL_PATH_PROJECTION_MATRIX_NV 0x0BA7 #define GL_PATH_MAX_PROJECTION_STACK_DEPTH_NV 0x0D38 #define GL_PATH_TRANSPOSE_PROJECTION_MATRIX_NV 0x84E4 #define GL_FRAGMENT_INPUT_NV 0x936D typedef GLuint (APIENTRYP PFNGLGENPATHSNVPROC) (GLsizei range); typedef void (APIENTRYP PFNGLDELETEPATHSNVPROC) (GLuint path, GLsizei range); typedef GLboolean (APIENTRYP PFNGLISPATHNVPROC) (GLuint path); typedef void (APIENTRYP PFNGLPATHCOMMANDSNVPROC) (GLuint path, GLsizei numCommands, const GLubyte *commands, GLsizei numCoords, GLenum coordType, const void *coords); typedef void (APIENTRYP PFNGLPATHCOORDSNVPROC) (GLuint path, GLsizei numCoords, GLenum coordType, const void *coords); typedef void (APIENTRYP PFNGLPATHSUBCOMMANDSNVPROC) (GLuint path, GLsizei commandStart, GLsizei commandsToDelete, GLsizei numCommands, const GLubyte *commands, GLsizei numCoords, GLenum coordType, const void *coords); typedef void (APIENTRYP PFNGLPATHSUBCOORDSNVPROC) (GLuint path, GLsizei coordStart, GLsizei numCoords, GLenum coordType, const void *coords); typedef void (APIENTRYP PFNGLPATHSTRINGNVPROC) (GLuint path, GLenum format, GLsizei length, const void *pathString); typedef void (APIENTRYP PFNGLPATHGLYPHSNVPROC) (GLuint firstPathName, GLenum fontTarget, const void *fontName, GLbitfield fontStyle, GLsizei numGlyphs, GLenum type, const void *charcodes, GLenum handleMissingGlyphs, GLuint pathParameterTemplate, GLfloat emScale); typedef void (APIENTRYP PFNGLPATHGLYPHRANGENVPROC) (GLuint firstPathName, GLenum fontTarget, const void *fontName, GLbitfield fontStyle, GLuint firstGlyph, GLsizei numGlyphs, GLenum handleMissingGlyphs, GLuint pathParameterTemplate, GLfloat emScale); typedef void (APIENTRYP PFNGLWEIGHTPATHSNVPROC) (GLuint resultPath, GLsizei numPaths, const GLuint *paths, const GLfloat *weights); typedef void (APIENTRYP PFNGLCOPYPATHNVPROC) (GLuint resultPath, GLuint srcPath); typedef void (APIENTRYP PFNGLINTERPOLATEPATHSNVPROC) (GLuint resultPath, GLuint pathA, GLuint pathB, GLfloat weight); typedef void (APIENTRYP PFNGLTRANSFORMPATHNVPROC) (GLuint resultPath, GLuint srcPath, GLenum transformType, const GLfloat *transformValues); typedef void (APIENTRYP PFNGLPATHPARAMETERIVNVPROC) (GLuint path, GLenum pname, const GLint *value); typedef void (APIENTRYP PFNGLPATHPARAMETERINVPROC) (GLuint path, GLenum pname, GLint value); typedef void (APIENTRYP PFNGLPATHPARAMETERFVNVPROC) (GLuint path, GLenum pname, const GLfloat *value); typedef void (APIENTRYP PFNGLPATHPARAMETERFNVPROC) (GLuint path, GLenum pname, GLfloat value); typedef void (APIENTRYP PFNGLPATHDASHARRAYNVPROC) (GLuint path, GLsizei dashCount, const GLfloat *dashArray); typedef void (APIENTRYP PFNGLPATHSTENCILFUNCNVPROC) (GLenum func, GLint ref, GLuint mask); typedef void (APIENTRYP PFNGLPATHSTENCILDEPTHOFFSETNVPROC) (GLfloat factor, GLfloat units); typedef void (APIENTRYP PFNGLSTENCILFILLPATHNVPROC) (GLuint path, GLenum fillMode, GLuint mask); typedef void (APIENTRYP PFNGLSTENCILSTROKEPATHNVPROC) (GLuint path, GLint reference, GLuint mask); typedef void (APIENTRYP PFNGLSTENCILFILLPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLenum fillMode, GLuint mask, GLenum transformType, const GLfloat *transformValues); typedef void (APIENTRYP PFNGLSTENCILSTROKEPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLint reference, GLuint mask, GLenum transformType, const GLfloat *transformValues); typedef void (APIENTRYP PFNGLPATHCOVERDEPTHFUNCNVPROC) (GLenum func); typedef void (APIENTRYP PFNGLCOVERFILLPATHNVPROC) (GLuint path, GLenum coverMode); typedef void (APIENTRYP PFNGLCOVERSTROKEPATHNVPROC) (GLuint path, GLenum coverMode); typedef void (APIENTRYP PFNGLCOVERFILLPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLenum coverMode, GLenum transformType, const GLfloat *transformValues); typedef void (APIENTRYP PFNGLCOVERSTROKEPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLenum coverMode, GLenum transformType, const GLfloat *transformValues); typedef void (APIENTRYP PFNGLGETPATHPARAMETERIVNVPROC) (GLuint path, GLenum pname, GLint *value); typedef void (APIENTRYP PFNGLGETPATHPARAMETERFVNVPROC) (GLuint path, GLenum pname, GLfloat *value); typedef void (APIENTRYP PFNGLGETPATHCOMMANDSNVPROC) (GLuint path, GLubyte *commands); typedef void (APIENTRYP PFNGLGETPATHCOORDSNVPROC) (GLuint path, GLfloat *coords); typedef void (APIENTRYP PFNGLGETPATHDASHARRAYNVPROC) (GLuint path, GLfloat *dashArray); typedef void (APIENTRYP PFNGLGETPATHMETRICSNVPROC) (GLbitfield metricQueryMask, GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLsizei stride, GLfloat *metrics); typedef void (APIENTRYP PFNGLGETPATHMETRICRANGENVPROC) (GLbitfield metricQueryMask, GLuint firstPathName, GLsizei numPaths, GLsizei stride, GLfloat *metrics); typedef void (APIENTRYP PFNGLGETPATHSPACINGNVPROC) (GLenum pathListMode, GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLfloat advanceScale, GLfloat kerningScale, GLenum transformType, GLfloat *returnedSpacing); typedef GLboolean (APIENTRYP PFNGLISPOINTINFILLPATHNVPROC) (GLuint path, GLuint mask, GLfloat x, GLfloat y); typedef GLboolean (APIENTRYP PFNGLISPOINTINSTROKEPATHNVPROC) (GLuint path, GLfloat x, GLfloat y); typedef GLfloat (APIENTRYP PFNGLGETPATHLENGTHNVPROC) (GLuint path, GLsizei startSegment, GLsizei numSegments); typedef GLboolean (APIENTRYP PFNGLPOINTALONGPATHNVPROC) (GLuint path, GLsizei startSegment, GLsizei numSegments, GLfloat distance, GLfloat *x, GLfloat *y, GLfloat *tangentX, GLfloat *tangentY); typedef void (APIENTRYP PFNGLMATRIXLOAD3X2FNVPROC) (GLenum matrixMode, const GLfloat *m); typedef void (APIENTRYP PFNGLMATRIXLOAD3X3FNVPROC) (GLenum matrixMode, const GLfloat *m); typedef void (APIENTRYP PFNGLMATRIXLOADTRANSPOSE3X3FNVPROC) (GLenum matrixMode, const GLfloat *m); typedef void (APIENTRYP PFNGLMATRIXMULT3X2FNVPROC) (GLenum matrixMode, const GLfloat *m); typedef void (APIENTRYP PFNGLMATRIXMULT3X3FNVPROC) (GLenum matrixMode, const GLfloat *m); typedef void (APIENTRYP PFNGLMATRIXMULTTRANSPOSE3X3FNVPROC) (GLenum matrixMode, const GLfloat *m); typedef void (APIENTRYP PFNGLSTENCILTHENCOVERFILLPATHNVPROC) (GLuint path, GLenum fillMode, GLuint mask, GLenum coverMode); typedef void (APIENTRYP PFNGLSTENCILTHENCOVERSTROKEPATHNVPROC) (GLuint path, GLint reference, GLuint mask, GLenum coverMode); typedef void (APIENTRYP PFNGLSTENCILTHENCOVERFILLPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLenum fillMode, GLuint mask, GLenum coverMode, GLenum transformType, const GLfloat *transformValues); typedef void (APIENTRYP PFNGLSTENCILTHENCOVERSTROKEPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLint reference, GLuint mask, GLenum coverMode, GLenum transformType, const GLfloat *transformValues); typedef GLenum (APIENTRYP PFNGLPATHGLYPHINDEXRANGENVPROC) (GLenum fontTarget, const void *fontName, GLbitfield fontStyle, GLuint pathParameterTemplate, GLfloat emScale, GLuint *baseAndCount); typedef GLenum (APIENTRYP PFNGLPATHGLYPHINDEXARRAYNVPROC) (GLuint firstPathName, GLenum fontTarget, const void *fontName, GLbitfield fontStyle, GLuint firstGlyphIndex, GLsizei numGlyphs, GLuint pathParameterTemplate, GLfloat emScale); typedef GLenum (APIENTRYP PFNGLPATHMEMORYGLYPHINDEXARRAYNVPROC) (GLuint firstPathName, GLenum fontTarget, GLsizeiptr fontSize, const void *fontData, GLsizei faceIndex, GLuint firstGlyphIndex, GLsizei numGlyphs, GLuint pathParameterTemplate, GLfloat emScale); typedef void (APIENTRYP PFNGLPROGRAMPATHFRAGMENTINPUTGENNVPROC) (GLuint program, GLint location, GLenum genMode, GLint components, const GLfloat *coeffs); typedef void (APIENTRYP PFNGLGETPROGRAMRESOURCEFVNVPROC) (GLuint program, GLenum programInterface, GLuint index, GLsizei propCount, const GLenum *props, GLsizei count, GLsizei *length, GLfloat *params); typedef void (APIENTRYP PFNGLPATHCOLORGENNVPROC) (GLenum color, GLenum genMode, GLenum colorFormat, const GLfloat *coeffs); typedef void (APIENTRYP PFNGLPATHTEXGENNVPROC) (GLenum texCoordSet, GLenum genMode, GLint components, const GLfloat *coeffs); typedef void (APIENTRYP PFNGLPATHFOGGENNVPROC) (GLenum genMode); typedef void (APIENTRYP PFNGLGETPATHCOLORGENIVNVPROC) (GLenum color, GLenum pname, GLint *value); typedef void (APIENTRYP PFNGLGETPATHCOLORGENFVNVPROC) (GLenum color, GLenum pname, GLfloat *value); typedef void (APIENTRYP PFNGLGETPATHTEXGENIVNVPROC) (GLenum texCoordSet, GLenum pname, GLint *value); typedef void (APIENTRYP PFNGLGETPATHTEXGENFVNVPROC) (GLenum texCoordSet, GLenum pname, GLfloat *value); #ifdef GL_GLEXT_PROTOTYPES GLAPI GLuint APIENTRY glGenPathsNV (GLsizei range); GLAPI void APIENTRY glDeletePathsNV (GLuint path, GLsizei range); GLAPI GLboolean APIENTRY glIsPathNV (GLuint path); GLAPI void APIENTRY glPathCommandsNV (GLuint path, GLsizei numCommands, const GLubyte *commands, GLsizei numCoords, GLenum coordType, const void *coords); GLAPI void APIENTRY glPathCoordsNV (GLuint path, GLsizei numCoords, GLenum coordType, const void *coords); GLAPI void APIENTRY glPathSubCommandsNV (GLuint path, GLsizei commandStart, GLsizei commandsToDelete, GLsizei numCommands, const GLubyte *commands, GLsizei numCoords, GLenum coordType, const void *coords); GLAPI void APIENTRY glPathSubCoordsNV (GLuint path, GLsizei coordStart, GLsizei numCoords, GLenum coordType, const void *coords); GLAPI void APIENTRY glPathStringNV (GLuint path, GLenum format, GLsizei length, const void *pathString); GLAPI void APIENTRY glPathGlyphsNV (GLuint firstPathName, GLenum fontTarget, const void *fontName, GLbitfield fontStyle, GLsizei numGlyphs, GLenum type, const void *charcodes, GLenum handleMissingGlyphs, GLuint pathParameterTemplate, GLfloat emScale); GLAPI void APIENTRY glPathGlyphRangeNV (GLuint firstPathName, GLenum fontTarget, const void *fontName, GLbitfield fontStyle, GLuint firstGlyph, GLsizei numGlyphs, GLenum handleMissingGlyphs, GLuint pathParameterTemplate, GLfloat emScale); GLAPI void APIENTRY glWeightPathsNV (GLuint resultPath, GLsizei numPaths, const GLuint *paths, const GLfloat *weights); GLAPI void APIENTRY glCopyPathNV (GLuint resultPath, GLuint srcPath); GLAPI void APIENTRY glInterpolatePathsNV (GLuint resultPath, GLuint pathA, GLuint pathB, GLfloat weight); GLAPI void APIENTRY glTransformPathNV (GLuint resultPath, GLuint srcPath, GLenum transformType, const GLfloat *transformValues); GLAPI void APIENTRY glPathParameterivNV (GLuint path, GLenum pname, const GLint *value); GLAPI void APIENTRY glPathParameteriNV (GLuint path, GLenum pname, GLint value); GLAPI void APIENTRY glPathParameterfvNV (GLuint path, GLenum pname, const GLfloat *value); GLAPI void APIENTRY glPathParameterfNV (GLuint path, GLenum pname, GLfloat value); GLAPI void APIENTRY glPathDashArrayNV (GLuint path, GLsizei dashCount, const GLfloat *dashArray); GLAPI void APIENTRY glPathStencilFuncNV (GLenum func, GLint ref, GLuint mask); GLAPI void APIENTRY glPathStencilDepthOffsetNV (GLfloat factor, GLfloat units); GLAPI void APIENTRY glStencilFillPathNV (GLuint path, GLenum fillMode, GLuint mask); GLAPI void APIENTRY glStencilStrokePathNV (GLuint path, GLint reference, GLuint mask); GLAPI void APIENTRY glStencilFillPathInstancedNV (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLenum fillMode, GLuint mask, GLenum transformType, const GLfloat *transformValues); GLAPI void APIENTRY glStencilStrokePathInstancedNV (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLint reference, GLuint mask, GLenum transformType, const GLfloat *transformValues); GLAPI void APIENTRY glPathCoverDepthFuncNV (GLenum func); GLAPI void APIENTRY glCoverFillPathNV (GLuint path, GLenum coverMode); GLAPI void APIENTRY glCoverStrokePathNV (GLuint path, GLenum coverMode); GLAPI void APIENTRY glCoverFillPathInstancedNV (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLenum coverMode, GLenum transformType, const GLfloat *transformValues); GLAPI void APIENTRY glCoverStrokePathInstancedNV (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLenum coverMode, GLenum transformType, const GLfloat *transformValues); GLAPI void APIENTRY glGetPathParameterivNV (GLuint path, GLenum pname, GLint *value); GLAPI void APIENTRY glGetPathParameterfvNV (GLuint path, GLenum pname, GLfloat *value); GLAPI void APIENTRY glGetPathCommandsNV (GLuint path, GLubyte *commands); GLAPI void APIENTRY glGetPathCoordsNV (GLuint path, GLfloat *coords); GLAPI void APIENTRY glGetPathDashArrayNV (GLuint path, GLfloat *dashArray); GLAPI void APIENTRY glGetPathMetricsNV (GLbitfield metricQueryMask, GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLsizei stride, GLfloat *metrics); GLAPI void APIENTRY glGetPathMetricRangeNV (GLbitfield metricQueryMask, GLuint firstPathName, GLsizei numPaths, GLsizei stride, GLfloat *metrics); GLAPI void APIENTRY glGetPathSpacingNV (GLenum pathListMode, GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLfloat advanceScale, GLfloat kerningScale, GLenum transformType, GLfloat *returnedSpacing); GLAPI GLboolean APIENTRY glIsPointInFillPathNV (GLuint path, GLuint mask, GLfloat x, GLfloat y); GLAPI GLboolean APIENTRY glIsPointInStrokePathNV (GLuint path, GLfloat x, GLfloat y); GLAPI GLfloat APIENTRY glGetPathLengthNV (GLuint path, GLsizei startSegment, GLsizei numSegments); GLAPI GLboolean APIENTRY glPointAlongPathNV (GLuint path, GLsizei startSegment, GLsizei numSegments, GLfloat distance, GLfloat *x, GLfloat *y, GLfloat *tangentX, GLfloat *tangentY); GLAPI void APIENTRY glMatrixLoad3x2fNV (GLenum matrixMode, const GLfloat *m); GLAPI void APIENTRY glMatrixLoad3x3fNV (GLenum matrixMode, const GLfloat *m); GLAPI void APIENTRY glMatrixLoadTranspose3x3fNV (GLenum matrixMode, const GLfloat *m); GLAPI void APIENTRY glMatrixMult3x2fNV (GLenum matrixMode, const GLfloat *m); GLAPI void APIENTRY glMatrixMult3x3fNV (GLenum matrixMode, const GLfloat *m); GLAPI void APIENTRY glMatrixMultTranspose3x3fNV (GLenum matrixMode, const GLfloat *m); GLAPI void APIENTRY glStencilThenCoverFillPathNV (GLuint path, GLenum fillMode, GLuint mask, GLenum coverMode); GLAPI void APIENTRY glStencilThenCoverStrokePathNV (GLuint path, GLint reference, GLuint mask, GLenum coverMode); GLAPI void APIENTRY glStencilThenCoverFillPathInstancedNV (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLenum fillMode, GLuint mask, GLenum coverMode, GLenum transformType, const GLfloat *transformValues); GLAPI void APIENTRY glStencilThenCoverStrokePathInstancedNV (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLint reference, GLuint mask, GLenum coverMode, GLenum transformType, const GLfloat *transformValues); GLAPI GLenum APIENTRY glPathGlyphIndexRangeNV (GLenum fontTarget, const void *fontName, GLbitfield fontStyle, GLuint pathParameterTemplate, GLfloat emScale, GLuint *baseAndCount); GLAPI GLenum APIENTRY glPathGlyphIndexArrayNV (GLuint firstPathName, GLenum fontTarget, const void *fontName, GLbitfield fontStyle, GLuint firstGlyphIndex, GLsizei numGlyphs, GLuint pathParameterTemplate, GLfloat emScale); GLAPI GLenum APIENTRY glPathMemoryGlyphIndexArrayNV (GLuint firstPathName, GLenum fontTarget, GLsizeiptr fontSize, const void *fontData, GLsizei faceIndex, GLuint firstGlyphIndex, GLsizei numGlyphs, GLuint pathParameterTemplate, GLfloat emScale); GLAPI void APIENTRY glProgramPathFragmentInputGenNV (GLuint program, GLint location, GLenum genMode, GLint components, const GLfloat *coeffs); GLAPI void APIENTRY glGetProgramResourcefvNV (GLuint program, GLenum programInterface, GLuint index, GLsizei propCount, const GLenum *props, GLsizei count, GLsizei *length, GLfloat *params); GLAPI void APIENTRY glPathColorGenNV (GLenum color, GLenum genMode, GLenum colorFormat, const GLfloat *coeffs); GLAPI void APIENTRY glPathTexGenNV (GLenum texCoordSet, GLenum genMode, GLint components, const GLfloat *coeffs); GLAPI void APIENTRY glPathFogGenNV (GLenum genMode); GLAPI void APIENTRY glGetPathColorGenivNV (GLenum color, GLenum pname, GLint *value); GLAPI void APIENTRY glGetPathColorGenfvNV (GLenum color, GLenum pname, GLfloat *value); GLAPI void APIENTRY glGetPathTexGenivNV (GLenum texCoordSet, GLenum pname, GLint *value); GLAPI void APIENTRY glGetPathTexGenfvNV (GLenum texCoordSet, GLenum pname, GLfloat *value); #endif #endif /* GL_NV_path_rendering */ #ifndef GL_NV_path_rendering_shared_edge #define GL_NV_path_rendering_shared_edge 1 #define GL_SHARED_EDGE_NV 0xC0 #endif /* GL_NV_path_rendering_shared_edge */ #ifndef GL_NV_pixel_data_range #define GL_NV_pixel_data_range 1 #define GL_WRITE_PIXEL_DATA_RANGE_NV 0x8878 #define GL_READ_PIXEL_DATA_RANGE_NV 0x8879 #define GL_WRITE_PIXEL_DATA_RANGE_LENGTH_NV 0x887A #define GL_READ_PIXEL_DATA_RANGE_LENGTH_NV 0x887B #define GL_WRITE_PIXEL_DATA_RANGE_POINTER_NV 0x887C #define GL_READ_PIXEL_DATA_RANGE_POINTER_NV 0x887D typedef void (APIENTRYP PFNGLPIXELDATARANGENVPROC) (GLenum target, GLsizei length, const void *pointer); typedef void (APIENTRYP PFNGLFLUSHPIXELDATARANGENVPROC) (GLenum target); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glPixelDataRangeNV (GLenum target, GLsizei length, const void *pointer); GLAPI void APIENTRY glFlushPixelDataRangeNV (GLenum target); #endif #endif /* GL_NV_pixel_data_range */ #ifndef GL_NV_point_sprite #define GL_NV_point_sprite 1 #define GL_POINT_SPRITE_NV 0x8861 #define GL_COORD_REPLACE_NV 0x8862 #define GL_POINT_SPRITE_R_MODE_NV 0x8863 typedef void (APIENTRYP PFNGLPOINTPARAMETERINVPROC) (GLenum pname, GLint param); typedef void (APIENTRYP PFNGLPOINTPARAMETERIVNVPROC) (GLenum pname, const GLint *params); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glPointParameteriNV (GLenum pname, GLint param); GLAPI void APIENTRY glPointParameterivNV (GLenum pname, const GLint *params); #endif #endif /* GL_NV_point_sprite */ #ifndef GL_NV_present_video #define GL_NV_present_video 1 #define GL_FRAME_NV 0x8E26 #define GL_FIELDS_NV 0x8E27 #define GL_CURRENT_TIME_NV 0x8E28 #define GL_NUM_FILL_STREAMS_NV 0x8E29 #define GL_PRESENT_TIME_NV 0x8E2A #define GL_PRESENT_DURATION_NV 0x8E2B typedef void (APIENTRYP PFNGLPRESENTFRAMEKEYEDNVPROC) (GLuint video_slot, GLuint64EXT minPresentTime, GLuint beginPresentTimeId, GLuint presentDurationId, GLenum type, GLenum target0, GLuint fill0, GLuint key0, GLenum target1, GLuint fill1, GLuint key1); typedef void (APIENTRYP PFNGLPRESENTFRAMEDUALFILLNVPROC) (GLuint video_slot, GLuint64EXT minPresentTime, GLuint beginPresentTimeId, GLuint presentDurationId, GLenum type, GLenum target0, GLuint fill0, GLenum target1, GLuint fill1, GLenum target2, GLuint fill2, GLenum target3, GLuint fill3); typedef void (APIENTRYP PFNGLGETVIDEOIVNVPROC) (GLuint video_slot, GLenum pname, GLint *params); typedef void (APIENTRYP PFNGLGETVIDEOUIVNVPROC) (GLuint video_slot, GLenum pname, GLuint *params); typedef void (APIENTRYP PFNGLGETVIDEOI64VNVPROC) (GLuint video_slot, GLenum pname, GLint64EXT *params); typedef void (APIENTRYP PFNGLGETVIDEOUI64VNVPROC) (GLuint video_slot, GLenum pname, GLuint64EXT *params); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glPresentFrameKeyedNV (GLuint video_slot, GLuint64EXT minPresentTime, GLuint beginPresentTimeId, GLuint presentDurationId, GLenum type, GLenum target0, GLuint fill0, GLuint key0, GLenum target1, GLuint fill1, GLuint key1); GLAPI void APIENTRY glPresentFrameDualFillNV (GLuint video_slot, GLuint64EXT minPresentTime, GLuint beginPresentTimeId, GLuint presentDurationId, GLenum type, GLenum target0, GLuint fill0, GLenum target1, GLuint fill1, GLenum target2, GLuint fill2, GLenum target3, GLuint fill3); GLAPI void APIENTRY glGetVideoivNV (GLuint video_slot, GLenum pname, GLint *params); GLAPI void APIENTRY glGetVideouivNV (GLuint video_slot, GLenum pname, GLuint *params); GLAPI void APIENTRY glGetVideoi64vNV (GLuint video_slot, GLenum pname, GLint64EXT *params); GLAPI void APIENTRY glGetVideoui64vNV (GLuint video_slot, GLenum pname, GLuint64EXT *params); #endif #endif /* GL_NV_present_video */ #ifndef GL_NV_primitive_restart #define GL_NV_primitive_restart 1 #define GL_PRIMITIVE_RESTART_NV 0x8558 #define GL_PRIMITIVE_RESTART_INDEX_NV 0x8559 typedef void (APIENTRYP PFNGLPRIMITIVERESTARTNVPROC) (void); typedef void (APIENTRYP PFNGLPRIMITIVERESTARTINDEXNVPROC) (GLuint index); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glPrimitiveRestartNV (void); GLAPI void APIENTRY glPrimitiveRestartIndexNV (GLuint index); #endif #endif /* GL_NV_primitive_restart */ #ifndef GL_NV_primitive_shading_rate #define GL_NV_primitive_shading_rate 1 #define GL_SHADING_RATE_IMAGE_PER_PRIMITIVE_NV 0x95B1 #define GL_SHADING_RATE_IMAGE_PALETTE_COUNT_NV 0x95B2 #endif /* GL_NV_primitive_shading_rate */ #ifndef GL_NV_query_resource #define GL_NV_query_resource 1 #define GL_QUERY_RESOURCE_TYPE_VIDMEM_ALLOC_NV 0x9540 #define GL_QUERY_RESOURCE_MEMTYPE_VIDMEM_NV 0x9542 #define GL_QUERY_RESOURCE_SYS_RESERVED_NV 0x9544 #define GL_QUERY_RESOURCE_TEXTURE_NV 0x9545 #define GL_QUERY_RESOURCE_RENDERBUFFER_NV 0x9546 #define GL_QUERY_RESOURCE_BUFFEROBJECT_NV 0x9547 typedef GLint (APIENTRYP PFNGLQUERYRESOURCENVPROC) (GLenum queryType, GLint tagId, GLuint count, GLint *buffer); #ifdef GL_GLEXT_PROTOTYPES GLAPI GLint APIENTRY glQueryResourceNV (GLenum queryType, GLint tagId, GLuint count, GLint *buffer); #endif #endif /* GL_NV_query_resource */ #ifndef GL_NV_query_resource_tag #define GL_NV_query_resource_tag 1 typedef void (APIENTRYP PFNGLGENQUERYRESOURCETAGNVPROC) (GLsizei n, GLint *tagIds); typedef void (APIENTRYP PFNGLDELETEQUERYRESOURCETAGNVPROC) (GLsizei n, const GLint *tagIds); typedef void (APIENTRYP PFNGLQUERYRESOURCETAGNVPROC) (GLint tagId, const GLchar *tagString); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glGenQueryResourceTagNV (GLsizei n, GLint *tagIds); GLAPI void APIENTRY glDeleteQueryResourceTagNV (GLsizei n, const GLint *tagIds); GLAPI void APIENTRY glQueryResourceTagNV (GLint tagId, const GLchar *tagString); #endif #endif /* GL_NV_query_resource_tag */ #ifndef GL_NV_register_combiners #define GL_NV_register_combiners 1 #define GL_REGISTER_COMBINERS_NV 0x8522 #define GL_VARIABLE_A_NV 0x8523 #define GL_VARIABLE_B_NV 0x8524 #define GL_VARIABLE_C_NV 0x8525 #define GL_VARIABLE_D_NV 0x8526 #define GL_VARIABLE_E_NV 0x8527 #define GL_VARIABLE_F_NV 0x8528 #define GL_VARIABLE_G_NV 0x8529 #define GL_CONSTANT_COLOR0_NV 0x852A #define GL_CONSTANT_COLOR1_NV 0x852B #define GL_SPARE0_NV 0x852E #define GL_SPARE1_NV 0x852F #define GL_DISCARD_NV 0x8530 #define GL_E_TIMES_F_NV 0x8531 #define GL_SPARE0_PLUS_SECONDARY_COLOR_NV 0x8532 #define GL_UNSIGNED_IDENTITY_NV 0x8536 #define GL_UNSIGNED_INVERT_NV 0x8537 #define GL_EXPAND_NORMAL_NV 0x8538 #define GL_EXPAND_NEGATE_NV 0x8539 #define GL_HALF_BIAS_NORMAL_NV 0x853A #define GL_HALF_BIAS_NEGATE_NV 0x853B #define GL_SIGNED_IDENTITY_NV 0x853C #define GL_SIGNED_NEGATE_NV 0x853D #define GL_SCALE_BY_TWO_NV 0x853E #define GL_SCALE_BY_FOUR_NV 0x853F #define GL_SCALE_BY_ONE_HALF_NV 0x8540 #define GL_BIAS_BY_NEGATIVE_ONE_HALF_NV 0x8541 #define GL_COMBINER_INPUT_NV 0x8542 #define GL_COMBINER_MAPPING_NV 0x8543 #define GL_COMBINER_COMPONENT_USAGE_NV 0x8544 #define GL_COMBINER_AB_DOT_PRODUCT_NV 0x8545 #define GL_COMBINER_CD_DOT_PRODUCT_NV 0x8546 #define GL_COMBINER_MUX_SUM_NV 0x8547 #define GL_COMBINER_SCALE_NV 0x8548 #define GL_COMBINER_BIAS_NV 0x8549 #define GL_COMBINER_AB_OUTPUT_NV 0x854A #define GL_COMBINER_CD_OUTPUT_NV 0x854B #define GL_COMBINER_SUM_OUTPUT_NV 0x854C #define GL_MAX_GENERAL_COMBINERS_NV 0x854D #define GL_NUM_GENERAL_COMBINERS_NV 0x854E #define GL_COLOR_SUM_CLAMP_NV 0x854F #define GL_COMBINER0_NV 0x8550 #define GL_COMBINER1_NV 0x8551 #define GL_COMBINER2_NV 0x8552 #define GL_COMBINER3_NV 0x8553 #define GL_COMBINER4_NV 0x8554 #define GL_COMBINER5_NV 0x8555 #define GL_COMBINER6_NV 0x8556 #define GL_COMBINER7_NV 0x8557 typedef void (APIENTRYP PFNGLCOMBINERPARAMETERFVNVPROC) (GLenum pname, const GLfloat *params); typedef void (APIENTRYP PFNGLCOMBINERPARAMETERFNVPROC) (GLenum pname, GLfloat param); typedef void (APIENTRYP PFNGLCOMBINERPARAMETERIVNVPROC) (GLenum pname, const GLint *params); typedef void (APIENTRYP PFNGLCOMBINERPARAMETERINVPROC) (GLenum pname, GLint param); typedef void (APIENTRYP PFNGLCOMBINERINPUTNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage); typedef void (APIENTRYP PFNGLCOMBINEROUTPUTNVPROC) (GLenum stage, GLenum portion, GLenum abOutput, GLenum cdOutput, GLenum sumOutput, GLenum scale, GLenum bias, GLboolean abDotProduct, GLboolean cdDotProduct, GLboolean muxSum); typedef void (APIENTRYP PFNGLFINALCOMBINERINPUTNVPROC) (GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage); typedef void (APIENTRYP PFNGLGETCOMBINERINPUTPARAMETERFVNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLfloat *params); typedef void (APIENTRYP PFNGLGETCOMBINERINPUTPARAMETERIVNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLint *params); typedef void (APIENTRYP PFNGLGETCOMBINEROUTPUTPARAMETERFVNVPROC) (GLenum stage, GLenum portion, GLenum pname, GLfloat *params); typedef void (APIENTRYP PFNGLGETCOMBINEROUTPUTPARAMETERIVNVPROC) (GLenum stage, GLenum portion, GLenum pname, GLint *params); typedef void (APIENTRYP PFNGLGETFINALCOMBINERINPUTPARAMETERFVNVPROC) (GLenum variable, GLenum pname, GLfloat *params); typedef void (APIENTRYP PFNGLGETFINALCOMBINERINPUTPARAMETERIVNVPROC) (GLenum variable, GLenum pname, GLint *params); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glCombinerParameterfvNV (GLenum pname, const GLfloat *params); GLAPI void APIENTRY glCombinerParameterfNV (GLenum pname, GLfloat param); GLAPI void APIENTRY glCombinerParameterivNV (GLenum pname, const GLint *params); GLAPI void APIENTRY glCombinerParameteriNV (GLenum pname, GLint param); GLAPI void APIENTRY glCombinerInputNV (GLenum stage, GLenum portion, GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage); GLAPI void APIENTRY glCombinerOutputNV (GLenum stage, GLenum portion, GLenum abOutput, GLenum cdOutput, GLenum sumOutput, GLenum scale, GLenum bias, GLboolean abDotProduct, GLboolean cdDotProduct, GLboolean muxSum); GLAPI void APIENTRY glFinalCombinerInputNV (GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage); GLAPI void APIENTRY glGetCombinerInputParameterfvNV (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLfloat *params); GLAPI void APIENTRY glGetCombinerInputParameterivNV (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLint *params); GLAPI void APIENTRY glGetCombinerOutputParameterfvNV (GLenum stage, GLenum portion, GLenum pname, GLfloat *params); GLAPI void APIENTRY glGetCombinerOutputParameterivNV (GLenum stage, GLenum portion, GLenum pname, GLint *params); GLAPI void APIENTRY glGetFinalCombinerInputParameterfvNV (GLenum variable, GLenum pname, GLfloat *params); GLAPI void APIENTRY glGetFinalCombinerInputParameterivNV (GLenum variable, GLenum pname, GLint *params); #endif #endif /* GL_NV_register_combiners */ #ifndef GL_NV_register_combiners2 #define GL_NV_register_combiners2 1 #define GL_PER_STAGE_CONSTANTS_NV 0x8535 typedef void (APIENTRYP PFNGLCOMBINERSTAGEPARAMETERFVNVPROC) (GLenum stage, GLenum pname, const GLfloat *params); typedef void (APIENTRYP PFNGLGETCOMBINERSTAGEPARAMETERFVNVPROC) (GLenum stage, GLenum pname, GLfloat *params); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glCombinerStageParameterfvNV (GLenum stage, GLenum pname, const GLfloat *params); GLAPI void APIENTRY glGetCombinerStageParameterfvNV (GLenum stage, GLenum pname, GLfloat *params); #endif #endif /* GL_NV_register_combiners2 */ #ifndef GL_NV_representative_fragment_test #define GL_NV_representative_fragment_test 1 #define GL_REPRESENTATIVE_FRAGMENT_TEST_NV 0x937F #endif /* GL_NV_representative_fragment_test */ #ifndef GL_NV_robustness_video_memory_purge #define GL_NV_robustness_video_memory_purge 1 #define GL_PURGED_CONTEXT_RESET_NV 0x92BB #endif /* GL_NV_robustness_video_memory_purge */ #ifndef GL_NV_sample_locations #define GL_NV_sample_locations 1 #define GL_SAMPLE_LOCATION_SUBPIXEL_BITS_NV 0x933D #define GL_SAMPLE_LOCATION_PIXEL_GRID_WIDTH_NV 0x933E #define GL_SAMPLE_LOCATION_PIXEL_GRID_HEIGHT_NV 0x933F #define GL_PROGRAMMABLE_SAMPLE_LOCATION_TABLE_SIZE_NV 0x9340 #define GL_SAMPLE_LOCATION_NV 0x8E50 #define GL_PROGRAMMABLE_SAMPLE_LOCATION_NV 0x9341 #define GL_FRAMEBUFFER_PROGRAMMABLE_SAMPLE_LOCATIONS_NV 0x9342 #define GL_FRAMEBUFFER_SAMPLE_LOCATION_PIXEL_GRID_NV 0x9343 typedef void (APIENTRYP PFNGLFRAMEBUFFERSAMPLELOCATIONSFVNVPROC) (GLenum target, GLuint start, GLsizei count, const GLfloat *v); typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERSAMPLELOCATIONSFVNVPROC) (GLuint framebuffer, GLuint start, GLsizei count, const GLfloat *v); typedef void (APIENTRYP PFNGLRESOLVEDEPTHVALUESNVPROC) (void); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glFramebufferSampleLocationsfvNV (GLenum target, GLuint start, GLsizei count, const GLfloat *v); GLAPI void APIENTRY glNamedFramebufferSampleLocationsfvNV (GLuint framebuffer, GLuint start, GLsizei count, const GLfloat *v); GLAPI void APIENTRY glResolveDepthValuesNV (void); #endif #endif /* GL_NV_sample_locations */ #ifndef GL_NV_sample_mask_override_coverage #define GL_NV_sample_mask_override_coverage 1 #endif /* GL_NV_sample_mask_override_coverage */ #ifndef GL_NV_scissor_exclusive #define GL_NV_scissor_exclusive 1 #define GL_SCISSOR_TEST_EXCLUSIVE_NV 0x9555 #define GL_SCISSOR_BOX_EXCLUSIVE_NV 0x9556 typedef void (APIENTRYP PFNGLSCISSOREXCLUSIVENVPROC) (GLint x, GLint y, GLsizei width, GLsizei height); typedef void (APIENTRYP PFNGLSCISSOREXCLUSIVEARRAYVNVPROC) (GLuint first, GLsizei count, const GLint *v); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glScissorExclusiveNV (GLint x, GLint y, GLsizei width, GLsizei height); GLAPI void APIENTRY glScissorExclusiveArrayvNV (GLuint first, GLsizei count, const GLint *v); #endif #endif /* GL_NV_scissor_exclusive */ #ifndef GL_NV_shader_atomic_counters #define GL_NV_shader_atomic_counters 1 #endif /* GL_NV_shader_atomic_counters */ #ifndef GL_NV_shader_atomic_float #define GL_NV_shader_atomic_float 1 #endif /* GL_NV_shader_atomic_float */ #ifndef GL_NV_shader_atomic_float64 #define GL_NV_shader_atomic_float64 1 #endif /* GL_NV_shader_atomic_float64 */ #ifndef GL_NV_shader_atomic_fp16_vector #define GL_NV_shader_atomic_fp16_vector 1 #endif /* GL_NV_shader_atomic_fp16_vector */ #ifndef GL_NV_shader_atomic_int64 #define GL_NV_shader_atomic_int64 1 #endif /* GL_NV_shader_atomic_int64 */ #ifndef GL_NV_shader_buffer_load #define GL_NV_shader_buffer_load 1 #define GL_BUFFER_GPU_ADDRESS_NV 0x8F1D #define GL_GPU_ADDRESS_NV 0x8F34 #define GL_MAX_SHADER_BUFFER_ADDRESS_NV 0x8F35 typedef void (APIENTRYP PFNGLMAKEBUFFERRESIDENTNVPROC) (GLenum target, GLenum access); typedef void (APIENTRYP PFNGLMAKEBUFFERNONRESIDENTNVPROC) (GLenum target); typedef GLboolean (APIENTRYP PFNGLISBUFFERRESIDENTNVPROC) (GLenum target); typedef void (APIENTRYP PFNGLMAKENAMEDBUFFERRESIDENTNVPROC) (GLuint buffer, GLenum access); typedef void (APIENTRYP PFNGLMAKENAMEDBUFFERNONRESIDENTNVPROC) (GLuint buffer); typedef GLboolean (APIENTRYP PFNGLISNAMEDBUFFERRESIDENTNVPROC) (GLuint buffer); typedef void (APIENTRYP PFNGLGETBUFFERPARAMETERUI64VNVPROC) (GLenum target, GLenum pname, GLuint64EXT *params); typedef void (APIENTRYP PFNGLGETNAMEDBUFFERPARAMETERUI64VNVPROC) (GLuint buffer, GLenum pname, GLuint64EXT *params); typedef void (APIENTRYP PFNGLGETINTEGERUI64VNVPROC) (GLenum value, GLuint64EXT *result); typedef void (APIENTRYP PFNGLUNIFORMUI64NVPROC) (GLint location, GLuint64EXT value); typedef void (APIENTRYP PFNGLUNIFORMUI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT *value); typedef void (APIENTRYP PFNGLPROGRAMUNIFORMUI64NVPROC) (GLuint program, GLint location, GLuint64EXT value); typedef void (APIENTRYP PFNGLPROGRAMUNIFORMUI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glMakeBufferResidentNV (GLenum target, GLenum access); GLAPI void APIENTRY glMakeBufferNonResidentNV (GLenum target); GLAPI GLboolean APIENTRY glIsBufferResidentNV (GLenum target); GLAPI void APIENTRY glMakeNamedBufferResidentNV (GLuint buffer, GLenum access); GLAPI void APIENTRY glMakeNamedBufferNonResidentNV (GLuint buffer); GLAPI GLboolean APIENTRY glIsNamedBufferResidentNV (GLuint buffer); GLAPI void APIENTRY glGetBufferParameterui64vNV (GLenum target, GLenum pname, GLuint64EXT *params); GLAPI void APIENTRY glGetNamedBufferParameterui64vNV (GLuint buffer, GLenum pname, GLuint64EXT *params); GLAPI void APIENTRY glGetIntegerui64vNV (GLenum value, GLuint64EXT *result); GLAPI void APIENTRY glUniformui64NV (GLint location, GLuint64EXT value); GLAPI void APIENTRY glUniformui64vNV (GLint location, GLsizei count, const GLuint64EXT *value); GLAPI void APIENTRY glProgramUniformui64NV (GLuint program, GLint location, GLuint64EXT value); GLAPI void APIENTRY glProgramUniformui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); #endif #endif /* GL_NV_shader_buffer_load */ #ifndef GL_NV_shader_buffer_store #define GL_NV_shader_buffer_store 1 #define GL_SHADER_GLOBAL_ACCESS_BARRIER_BIT_NV 0x00000010 #endif /* GL_NV_shader_buffer_store */ #ifndef GL_NV_shader_storage_buffer_object #define GL_NV_shader_storage_buffer_object 1 #endif /* GL_NV_shader_storage_buffer_object */ #ifndef GL_NV_shader_subgroup_partitioned #define GL_NV_shader_subgroup_partitioned 1 #define GL_SUBGROUP_FEATURE_PARTITIONED_BIT_NV 0x00000100 #endif /* GL_NV_shader_subgroup_partitioned */ #ifndef GL_NV_shader_texture_footprint #define GL_NV_shader_texture_footprint 1 #endif /* GL_NV_shader_texture_footprint */ #ifndef GL_NV_shader_thread_group #define GL_NV_shader_thread_group 1 #define GL_WARP_SIZE_NV 0x9339 #define GL_WARPS_PER_SM_NV 0x933A #define GL_SM_COUNT_NV 0x933B #endif /* GL_NV_shader_thread_group */ #ifndef GL_NV_shader_thread_shuffle #define GL_NV_shader_thread_shuffle 1 #endif /* GL_NV_shader_thread_shuffle */ #ifndef GL_NV_shading_rate_image #define GL_NV_shading_rate_image 1 #define GL_SHADING_RATE_IMAGE_NV 0x9563 #define GL_SHADING_RATE_NO_INVOCATIONS_NV 0x9564 #define GL_SHADING_RATE_1_INVOCATION_PER_PIXEL_NV 0x9565 #define GL_SHADING_RATE_1_INVOCATION_PER_1X2_PIXELS_NV 0x9566 #define GL_SHADING_RATE_1_INVOCATION_PER_2X1_PIXELS_NV 0x9567 #define GL_SHADING_RATE_1_INVOCATION_PER_2X2_PIXELS_NV 0x9568 #define GL_SHADING_RATE_1_INVOCATION_PER_2X4_PIXELS_NV 0x9569 #define GL_SHADING_RATE_1_INVOCATION_PER_4X2_PIXELS_NV 0x956A #define GL_SHADING_RATE_1_INVOCATION_PER_4X4_PIXELS_NV 0x956B #define GL_SHADING_RATE_2_INVOCATIONS_PER_PIXEL_NV 0x956C #define GL_SHADING_RATE_4_INVOCATIONS_PER_PIXEL_NV 0x956D #define GL_SHADING_RATE_8_INVOCATIONS_PER_PIXEL_NV 0x956E #define GL_SHADING_RATE_16_INVOCATIONS_PER_PIXEL_NV 0x956F #define GL_SHADING_RATE_IMAGE_BINDING_NV 0x955B #define GL_SHADING_RATE_IMAGE_TEXEL_WIDTH_NV 0x955C #define GL_SHADING_RATE_IMAGE_TEXEL_HEIGHT_NV 0x955D #define GL_SHADING_RATE_IMAGE_PALETTE_SIZE_NV 0x955E #define GL_MAX_COARSE_FRAGMENT_SAMPLES_NV 0x955F #define GL_SHADING_RATE_SAMPLE_ORDER_DEFAULT_NV 0x95AE #define GL_SHADING_RATE_SAMPLE_ORDER_PIXEL_MAJOR_NV 0x95AF #define GL_SHADING_RATE_SAMPLE_ORDER_SAMPLE_MAJOR_NV 0x95B0 typedef void (APIENTRYP PFNGLBINDSHADINGRATEIMAGENVPROC) (GLuint texture); typedef void (APIENTRYP PFNGLGETSHADINGRATEIMAGEPALETTENVPROC) (GLuint viewport, GLuint entry, GLenum *rate); typedef void (APIENTRYP PFNGLGETSHADINGRATESAMPLELOCATIONIVNVPROC) (GLenum rate, GLuint samples, GLuint index, GLint *location); typedef void (APIENTRYP PFNGLSHADINGRATEIMAGEBARRIERNVPROC) (GLboolean synchronize); typedef void (APIENTRYP PFNGLSHADINGRATEIMAGEPALETTENVPROC) (GLuint viewport, GLuint first, GLsizei count, const GLenum *rates); typedef void (APIENTRYP PFNGLSHADINGRATESAMPLEORDERNVPROC) (GLenum order); typedef void (APIENTRYP PFNGLSHADINGRATESAMPLEORDERCUSTOMNVPROC) (GLenum rate, GLuint samples, const GLint *locations); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glBindShadingRateImageNV (GLuint texture); GLAPI void APIENTRY glGetShadingRateImagePaletteNV (GLuint viewport, GLuint entry, GLenum *rate); GLAPI void APIENTRY glGetShadingRateSampleLocationivNV (GLenum rate, GLuint samples, GLuint index, GLint *location); GLAPI void APIENTRY glShadingRateImageBarrierNV (GLboolean synchronize); GLAPI void APIENTRY glShadingRateImagePaletteNV (GLuint viewport, GLuint first, GLsizei count, const GLenum *rates); GLAPI void APIENTRY glShadingRateSampleOrderNV (GLenum order); GLAPI void APIENTRY glShadingRateSampleOrderCustomNV (GLenum rate, GLuint samples, const GLint *locations); #endif #endif /* GL_NV_shading_rate_image */ #ifndef GL_NV_stereo_view_rendering #define GL_NV_stereo_view_rendering 1 #endif /* GL_NV_stereo_view_rendering */ #ifndef GL_NV_tessellation_program5 #define GL_NV_tessellation_program5 1 #define GL_MAX_PROGRAM_PATCH_ATTRIBS_NV 0x86D8 #define GL_TESS_CONTROL_PROGRAM_NV 0x891E #define GL_TESS_EVALUATION_PROGRAM_NV 0x891F #define GL_TESS_CONTROL_PROGRAM_PARAMETER_BUFFER_NV 0x8C74 #define GL_TESS_EVALUATION_PROGRAM_PARAMETER_BUFFER_NV 0x8C75 #endif /* GL_NV_tessellation_program5 */ #ifndef GL_NV_texgen_emboss #define GL_NV_texgen_emboss 1 #define GL_EMBOSS_LIGHT_NV 0x855D #define GL_EMBOSS_CONSTANT_NV 0x855E #define GL_EMBOSS_MAP_NV 0x855F #endif /* GL_NV_texgen_emboss */ #ifndef GL_NV_texgen_reflection #define GL_NV_texgen_reflection 1 #define GL_NORMAL_MAP_NV 0x8511 #define GL_REFLECTION_MAP_NV 0x8512 #endif /* GL_NV_texgen_reflection */ #ifndef GL_NV_texture_barrier #define GL_NV_texture_barrier 1 typedef void (APIENTRYP PFNGLTEXTUREBARRIERNVPROC) (void); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glTextureBarrierNV (void); #endif #endif /* GL_NV_texture_barrier */ #ifndef GL_NV_texture_compression_vtc #define GL_NV_texture_compression_vtc 1 #endif /* GL_NV_texture_compression_vtc */ #ifndef GL_NV_texture_env_combine4 #define GL_NV_texture_env_combine4 1 #define GL_COMBINE4_NV 0x8503 #define GL_SOURCE3_RGB_NV 0x8583 #define GL_SOURCE3_ALPHA_NV 0x858B #define GL_OPERAND3_RGB_NV 0x8593 #define GL_OPERAND3_ALPHA_NV 0x859B #endif /* GL_NV_texture_env_combine4 */ #ifndef GL_NV_texture_expand_normal #define GL_NV_texture_expand_normal 1 #define GL_TEXTURE_UNSIGNED_REMAP_MODE_NV 0x888F #endif /* GL_NV_texture_expand_normal */ #ifndef GL_NV_texture_multisample #define GL_NV_texture_multisample 1 #define GL_TEXTURE_COVERAGE_SAMPLES_NV 0x9045 #define GL_TEXTURE_COLOR_SAMPLES_NV 0x9046 typedef void (APIENTRYP PFNGLTEXIMAGE2DMULTISAMPLECOVERAGENVPROC) (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations); typedef void (APIENTRYP PFNGLTEXIMAGE3DMULTISAMPLECOVERAGENVPROC) (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations); typedef void (APIENTRYP PFNGLTEXTUREIMAGE2DMULTISAMPLENVPROC) (GLuint texture, GLenum target, GLsizei samples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations); typedef void (APIENTRYP PFNGLTEXTUREIMAGE3DMULTISAMPLENVPROC) (GLuint texture, GLenum target, GLsizei samples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations); typedef void (APIENTRYP PFNGLTEXTUREIMAGE2DMULTISAMPLECOVERAGENVPROC) (GLuint texture, GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations); typedef void (APIENTRYP PFNGLTEXTUREIMAGE3DMULTISAMPLECOVERAGENVPROC) (GLuint texture, GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glTexImage2DMultisampleCoverageNV (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations); GLAPI void APIENTRY glTexImage3DMultisampleCoverageNV (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations); GLAPI void APIENTRY glTextureImage2DMultisampleNV (GLuint texture, GLenum target, GLsizei samples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations); GLAPI void APIENTRY glTextureImage3DMultisampleNV (GLuint texture, GLenum target, GLsizei samples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations); GLAPI void APIENTRY glTextureImage2DMultisampleCoverageNV (GLuint texture, GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations); GLAPI void APIENTRY glTextureImage3DMultisampleCoverageNV (GLuint texture, GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations); #endif #endif /* GL_NV_texture_multisample */ #ifndef GL_NV_texture_rectangle #define GL_NV_texture_rectangle 1 #define GL_TEXTURE_RECTANGLE_NV 0x84F5 #define GL_TEXTURE_BINDING_RECTANGLE_NV 0x84F6 #define GL_PROXY_TEXTURE_RECTANGLE_NV 0x84F7 #define GL_MAX_RECTANGLE_TEXTURE_SIZE_NV 0x84F8 #endif /* GL_NV_texture_rectangle */ #ifndef GL_NV_texture_rectangle_compressed #define GL_NV_texture_rectangle_compressed 1 #endif /* GL_NV_texture_rectangle_compressed */ #ifndef GL_NV_texture_shader #define GL_NV_texture_shader 1 #define GL_OFFSET_TEXTURE_RECTANGLE_NV 0x864C #define GL_OFFSET_TEXTURE_RECTANGLE_SCALE_NV 0x864D #define GL_DOT_PRODUCT_TEXTURE_RECTANGLE_NV 0x864E #define GL_RGBA_UNSIGNED_DOT_PRODUCT_MAPPING_NV 0x86D9 #define GL_UNSIGNED_INT_S8_S8_8_8_NV 0x86DA #define GL_UNSIGNED_INT_8_8_S8_S8_REV_NV 0x86DB #define GL_DSDT_MAG_INTENSITY_NV 0x86DC #define GL_SHADER_CONSISTENT_NV 0x86DD #define GL_TEXTURE_SHADER_NV 0x86DE #define GL_SHADER_OPERATION_NV 0x86DF #define GL_CULL_MODES_NV 0x86E0 #define GL_OFFSET_TEXTURE_MATRIX_NV 0x86E1 #define GL_OFFSET_TEXTURE_SCALE_NV 0x86E2 #define GL_OFFSET_TEXTURE_BIAS_NV 0x86E3 #define GL_OFFSET_TEXTURE_2D_MATRIX_NV 0x86E1 #define GL_OFFSET_TEXTURE_2D_SCALE_NV 0x86E2 #define GL_OFFSET_TEXTURE_2D_BIAS_NV 0x86E3 #define GL_PREVIOUS_TEXTURE_INPUT_NV 0x86E4 #define GL_CONST_EYE_NV 0x86E5 #define GL_PASS_THROUGH_NV 0x86E6 #define GL_CULL_FRAGMENT_NV 0x86E7 #define GL_OFFSET_TEXTURE_2D_NV 0x86E8 #define GL_DEPENDENT_AR_TEXTURE_2D_NV 0x86E9 #define GL_DEPENDENT_GB_TEXTURE_2D_NV 0x86EA #define GL_DOT_PRODUCT_NV 0x86EC #define GL_DOT_PRODUCT_DEPTH_REPLACE_NV 0x86ED #define GL_DOT_PRODUCT_TEXTURE_2D_NV 0x86EE #define GL_DOT_PRODUCT_TEXTURE_CUBE_MAP_NV 0x86F0 #define GL_DOT_PRODUCT_DIFFUSE_CUBE_MAP_NV 0x86F1 #define GL_DOT_PRODUCT_REFLECT_CUBE_MAP_NV 0x86F2 #define GL_DOT_PRODUCT_CONST_EYE_REFLECT_CUBE_MAP_NV 0x86F3 #define GL_HILO_NV 0x86F4 #define GL_DSDT_NV 0x86F5 #define GL_DSDT_MAG_NV 0x86F6 #define GL_DSDT_MAG_VIB_NV 0x86F7 #define GL_HILO16_NV 0x86F8 #define GL_SIGNED_HILO_NV 0x86F9 #define GL_SIGNED_HILO16_NV 0x86FA #define GL_SIGNED_RGBA_NV 0x86FB #define GL_SIGNED_RGBA8_NV 0x86FC #define GL_SIGNED_RGB_NV 0x86FE #define GL_SIGNED_RGB8_NV 0x86FF #define GL_SIGNED_LUMINANCE_NV 0x8701 #define GL_SIGNED_LUMINANCE8_NV 0x8702 #define GL_SIGNED_LUMINANCE_ALPHA_NV 0x8703 #define GL_SIGNED_LUMINANCE8_ALPHA8_NV 0x8704 #define GL_SIGNED_ALPHA_NV 0x8705 #define GL_SIGNED_ALPHA8_NV 0x8706 #define GL_SIGNED_INTENSITY_NV 0x8707 #define GL_SIGNED_INTENSITY8_NV 0x8708 #define GL_DSDT8_NV 0x8709 #define GL_DSDT8_MAG8_NV 0x870A #define GL_DSDT8_MAG8_INTENSITY8_NV 0x870B #define GL_SIGNED_RGB_UNSIGNED_ALPHA_NV 0x870C #define GL_SIGNED_RGB8_UNSIGNED_ALPHA8_NV 0x870D #define GL_HI_SCALE_NV 0x870E #define GL_LO_SCALE_NV 0x870F #define GL_DS_SCALE_NV 0x8710 #define GL_DT_SCALE_NV 0x8711 #define GL_MAGNITUDE_SCALE_NV 0x8712 #define GL_VIBRANCE_SCALE_NV 0x8713 #define GL_HI_BIAS_NV 0x8714 #define GL_LO_BIAS_NV 0x8715 #define GL_DS_BIAS_NV 0x8716 #define GL_DT_BIAS_NV 0x8717 #define GL_MAGNITUDE_BIAS_NV 0x8718 #define GL_VIBRANCE_BIAS_NV 0x8719 #define GL_TEXTURE_BORDER_VALUES_NV 0x871A #define GL_TEXTURE_HI_SIZE_NV 0x871B #define GL_TEXTURE_LO_SIZE_NV 0x871C #define GL_TEXTURE_DS_SIZE_NV 0x871D #define GL_TEXTURE_DT_SIZE_NV 0x871E #define GL_TEXTURE_MAG_SIZE_NV 0x871F #endif /* GL_NV_texture_shader */ #ifndef GL_NV_texture_shader2 #define GL_NV_texture_shader2 1 #define GL_DOT_PRODUCT_TEXTURE_3D_NV 0x86EF #endif /* GL_NV_texture_shader2 */ #ifndef GL_NV_texture_shader3 #define GL_NV_texture_shader3 1 #define GL_OFFSET_PROJECTIVE_TEXTURE_2D_NV 0x8850 #define GL_OFFSET_PROJECTIVE_TEXTURE_2D_SCALE_NV 0x8851 #define GL_OFFSET_PROJECTIVE_TEXTURE_RECTANGLE_NV 0x8852 #define GL_OFFSET_PROJECTIVE_TEXTURE_RECTANGLE_SCALE_NV 0x8853 #define GL_OFFSET_HILO_TEXTURE_2D_NV 0x8854 #define GL_OFFSET_HILO_TEXTURE_RECTANGLE_NV 0x8855 #define GL_OFFSET_HILO_PROJECTIVE_TEXTURE_2D_NV 0x8856 #define GL_OFFSET_HILO_PROJECTIVE_TEXTURE_RECTANGLE_NV 0x8857 #define GL_DEPENDENT_HILO_TEXTURE_2D_NV 0x8858 #define GL_DEPENDENT_RGB_TEXTURE_3D_NV 0x8859 #define GL_DEPENDENT_RGB_TEXTURE_CUBE_MAP_NV 0x885A #define GL_DOT_PRODUCT_PASS_THROUGH_NV 0x885B #define GL_DOT_PRODUCT_TEXTURE_1D_NV 0x885C #define GL_DOT_PRODUCT_AFFINE_DEPTH_REPLACE_NV 0x885D #define GL_HILO8_NV 0x885E #define GL_SIGNED_HILO8_NV 0x885F #define GL_FORCE_BLUE_TO_ONE_NV 0x8860 #endif /* GL_NV_texture_shader3 */ #ifndef GL_NV_timeline_semaphore #define GL_NV_timeline_semaphore 1 #define GL_TIMELINE_SEMAPHORE_VALUE_NV 0x9595 #define GL_SEMAPHORE_TYPE_NV 0x95B3 #define GL_SEMAPHORE_TYPE_BINARY_NV 0x95B4 #define GL_SEMAPHORE_TYPE_TIMELINE_NV 0x95B5 #define GL_MAX_TIMELINE_SEMAPHORE_VALUE_DIFFERENCE_NV 0x95B6 typedef void (APIENTRYP PFNGLCREATESEMAPHORESNVPROC) (GLsizei n, GLuint *semaphores); typedef void (APIENTRYP PFNGLSEMAPHOREPARAMETERIVNVPROC) (GLuint semaphore, GLenum pname, const GLint *params); typedef void (APIENTRYP PFNGLGETSEMAPHOREPARAMETERIVNVPROC) (GLuint semaphore, GLenum pname, GLint *params); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glCreateSemaphoresNV (GLsizei n, GLuint *semaphores); GLAPI void APIENTRY glSemaphoreParameterivNV (GLuint semaphore, GLenum pname, const GLint *params); GLAPI void APIENTRY glGetSemaphoreParameterivNV (GLuint semaphore, GLenum pname, GLint *params); #endif #endif /* GL_NV_timeline_semaphore */ #ifndef GL_NV_transform_feedback #define GL_NV_transform_feedback 1 #define GL_BACK_PRIMARY_COLOR_NV 0x8C77 #define GL_BACK_SECONDARY_COLOR_NV 0x8C78 #define GL_TEXTURE_COORD_NV 0x8C79 #define GL_CLIP_DISTANCE_NV 0x8C7A #define GL_VERTEX_ID_NV 0x8C7B #define GL_PRIMITIVE_ID_NV 0x8C7C #define GL_GENERIC_ATTRIB_NV 0x8C7D #define GL_TRANSFORM_FEEDBACK_ATTRIBS_NV 0x8C7E #define GL_TRANSFORM_FEEDBACK_BUFFER_MODE_NV 0x8C7F #define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS_NV 0x8C80 #define GL_ACTIVE_VARYINGS_NV 0x8C81 #define GL_ACTIVE_VARYING_MAX_LENGTH_NV 0x8C82 #define GL_TRANSFORM_FEEDBACK_VARYINGS_NV 0x8C83 #define GL_TRANSFORM_FEEDBACK_BUFFER_START_NV 0x8C84 #define GL_TRANSFORM_FEEDBACK_BUFFER_SIZE_NV 0x8C85 #define GL_TRANSFORM_FEEDBACK_RECORD_NV 0x8C86 #define GL_PRIMITIVES_GENERATED_NV 0x8C87 #define GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN_NV 0x8C88 #define GL_RASTERIZER_DISCARD_NV 0x8C89 #define GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS_NV 0x8C8A #define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS_NV 0x8C8B #define GL_INTERLEAVED_ATTRIBS_NV 0x8C8C #define GL_SEPARATE_ATTRIBS_NV 0x8C8D #define GL_TRANSFORM_FEEDBACK_BUFFER_NV 0x8C8E #define GL_TRANSFORM_FEEDBACK_BUFFER_BINDING_NV 0x8C8F #define GL_LAYER_NV 0x8DAA #define GL_NEXT_BUFFER_NV -2 #define GL_SKIP_COMPONENTS4_NV -3 #define GL_SKIP_COMPONENTS3_NV -4 #define GL_SKIP_COMPONENTS2_NV -5 #define GL_SKIP_COMPONENTS1_NV -6 typedef void (APIENTRYP PFNGLBEGINTRANSFORMFEEDBACKNVPROC) (GLenum primitiveMode); typedef void (APIENTRYP PFNGLENDTRANSFORMFEEDBACKNVPROC) (void); typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKATTRIBSNVPROC) (GLsizei count, const GLint *attribs, GLenum bufferMode); typedef void (APIENTRYP PFNGLBINDBUFFERRANGENVPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); typedef void (APIENTRYP PFNGLBINDBUFFEROFFSETNVPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset); typedef void (APIENTRYP PFNGLBINDBUFFERBASENVPROC) (GLenum target, GLuint index, GLuint buffer); typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKVARYINGSNVPROC) (GLuint program, GLsizei count, const GLint *locations, GLenum bufferMode); typedef void (APIENTRYP PFNGLACTIVEVARYINGNVPROC) (GLuint program, const GLchar *name); typedef GLint (APIENTRYP PFNGLGETVARYINGLOCATIONNVPROC) (GLuint program, const GLchar *name); typedef void (APIENTRYP PFNGLGETACTIVEVARYINGNVPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); typedef void (APIENTRYP PFNGLGETTRANSFORMFEEDBACKVARYINGNVPROC) (GLuint program, GLuint index, GLint *location); typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKSTREAMATTRIBSNVPROC) (GLsizei count, const GLint *attribs, GLsizei nbuffers, const GLint *bufstreams, GLenum bufferMode); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glBeginTransformFeedbackNV (GLenum primitiveMode); GLAPI void APIENTRY glEndTransformFeedbackNV (void); GLAPI void APIENTRY glTransformFeedbackAttribsNV (GLsizei count, const GLint *attribs, GLenum bufferMode); GLAPI void APIENTRY glBindBufferRangeNV (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); GLAPI void APIENTRY glBindBufferOffsetNV (GLenum target, GLuint index, GLuint buffer, GLintptr offset); GLAPI void APIENTRY glBindBufferBaseNV (GLenum target, GLuint index, GLuint buffer); GLAPI void APIENTRY glTransformFeedbackVaryingsNV (GLuint program, GLsizei count, const GLint *locations, GLenum bufferMode); GLAPI void APIENTRY glActiveVaryingNV (GLuint program, const GLchar *name); GLAPI GLint APIENTRY glGetVaryingLocationNV (GLuint program, const GLchar *name); GLAPI void APIENTRY glGetActiveVaryingNV (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); GLAPI void APIENTRY glGetTransformFeedbackVaryingNV (GLuint program, GLuint index, GLint *location); GLAPI void APIENTRY glTransformFeedbackStreamAttribsNV (GLsizei count, const GLint *attribs, GLsizei nbuffers, const GLint *bufstreams, GLenum bufferMode); #endif #endif /* GL_NV_transform_feedback */ #ifndef GL_NV_transform_feedback2 #define GL_NV_transform_feedback2 1 #define GL_TRANSFORM_FEEDBACK_NV 0x8E22 #define GL_TRANSFORM_FEEDBACK_BUFFER_PAUSED_NV 0x8E23 #define GL_TRANSFORM_FEEDBACK_BUFFER_ACTIVE_NV 0x8E24 #define GL_TRANSFORM_FEEDBACK_BINDING_NV 0x8E25 typedef void (APIENTRYP PFNGLBINDTRANSFORMFEEDBACKNVPROC) (GLenum target, GLuint id); typedef void (APIENTRYP PFNGLDELETETRANSFORMFEEDBACKSNVPROC) (GLsizei n, const GLuint *ids); typedef void (APIENTRYP PFNGLGENTRANSFORMFEEDBACKSNVPROC) (GLsizei n, GLuint *ids); typedef GLboolean (APIENTRYP PFNGLISTRANSFORMFEEDBACKNVPROC) (GLuint id); typedef void (APIENTRYP PFNGLPAUSETRANSFORMFEEDBACKNVPROC) (void); typedef void (APIENTRYP PFNGLRESUMETRANSFORMFEEDBACKNVPROC) (void); typedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKNVPROC) (GLenum mode, GLuint id); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glBindTransformFeedbackNV (GLenum target, GLuint id); GLAPI void APIENTRY glDeleteTransformFeedbacksNV (GLsizei n, const GLuint *ids); GLAPI void APIENTRY glGenTransformFeedbacksNV (GLsizei n, GLuint *ids); GLAPI GLboolean APIENTRY glIsTransformFeedbackNV (GLuint id); GLAPI void APIENTRY glPauseTransformFeedbackNV (void); GLAPI void APIENTRY glResumeTransformFeedbackNV (void); GLAPI void APIENTRY glDrawTransformFeedbackNV (GLenum mode, GLuint id); #endif #endif /* GL_NV_transform_feedback2 */ #ifndef GL_NV_uniform_buffer_unified_memory #define GL_NV_uniform_buffer_unified_memory 1 #define GL_UNIFORM_BUFFER_UNIFIED_NV 0x936E #define GL_UNIFORM_BUFFER_ADDRESS_NV 0x936F #define GL_UNIFORM_BUFFER_LENGTH_NV 0x9370 #endif /* GL_NV_uniform_buffer_unified_memory */ #ifndef GL_NV_vdpau_interop #define GL_NV_vdpau_interop 1 typedef GLintptr GLvdpauSurfaceNV; #define GL_SURFACE_STATE_NV 0x86EB #define GL_SURFACE_REGISTERED_NV 0x86FD #define GL_SURFACE_MAPPED_NV 0x8700 #define GL_WRITE_DISCARD_NV 0x88BE typedef void (APIENTRYP PFNGLVDPAUINITNVPROC) (const void *vdpDevice, const void *getProcAddress); typedef void (APIENTRYP PFNGLVDPAUFININVPROC) (void); typedef GLvdpauSurfaceNV (APIENTRYP PFNGLVDPAUREGISTERVIDEOSURFACENVPROC) (const void *vdpSurface, GLenum target, GLsizei numTextureNames, const GLuint *textureNames); typedef GLvdpauSurfaceNV (APIENTRYP PFNGLVDPAUREGISTEROUTPUTSURFACENVPROC) (const void *vdpSurface, GLenum target, GLsizei numTextureNames, const GLuint *textureNames); typedef GLboolean (APIENTRYP PFNGLVDPAUISSURFACENVPROC) (GLvdpauSurfaceNV surface); typedef void (APIENTRYP PFNGLVDPAUUNREGISTERSURFACENVPROC) (GLvdpauSurfaceNV surface); typedef void (APIENTRYP PFNGLVDPAUGETSURFACEIVNVPROC) (GLvdpauSurfaceNV surface, GLenum pname, GLsizei count, GLsizei *length, GLint *values); typedef void (APIENTRYP PFNGLVDPAUSURFACEACCESSNVPROC) (GLvdpauSurfaceNV surface, GLenum access); typedef void (APIENTRYP PFNGLVDPAUMAPSURFACESNVPROC) (GLsizei numSurfaces, const GLvdpauSurfaceNV *surfaces); typedef void (APIENTRYP PFNGLVDPAUUNMAPSURFACESNVPROC) (GLsizei numSurface, const GLvdpauSurfaceNV *surfaces); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glVDPAUInitNV (const void *vdpDevice, const void *getProcAddress); GLAPI void APIENTRY glVDPAUFiniNV (void); GLAPI GLvdpauSurfaceNV APIENTRY glVDPAURegisterVideoSurfaceNV (const void *vdpSurface, GLenum target, GLsizei numTextureNames, const GLuint *textureNames); GLAPI GLvdpauSurfaceNV APIENTRY glVDPAURegisterOutputSurfaceNV (const void *vdpSurface, GLenum target, GLsizei numTextureNames, const GLuint *textureNames); GLAPI GLboolean APIENTRY glVDPAUIsSurfaceNV (GLvdpauSurfaceNV surface); GLAPI void APIENTRY glVDPAUUnregisterSurfaceNV (GLvdpauSurfaceNV surface); GLAPI void APIENTRY glVDPAUGetSurfaceivNV (GLvdpauSurfaceNV surface, GLenum pname, GLsizei count, GLsizei *length, GLint *values); GLAPI void APIENTRY glVDPAUSurfaceAccessNV (GLvdpauSurfaceNV surface, GLenum access); GLAPI void APIENTRY glVDPAUMapSurfacesNV (GLsizei numSurfaces, const GLvdpauSurfaceNV *surfaces); GLAPI void APIENTRY glVDPAUUnmapSurfacesNV (GLsizei numSurface, const GLvdpauSurfaceNV *surfaces); #endif #endif /* GL_NV_vdpau_interop */ #ifndef GL_NV_vdpau_interop2 #define GL_NV_vdpau_interop2 1 typedef GLvdpauSurfaceNV (APIENTRYP PFNGLVDPAUREGISTERVIDEOSURFACEWITHPICTURESTRUCTURENVPROC) (const void *vdpSurface, GLenum target, GLsizei numTextureNames, const GLuint *textureNames, GLboolean isFrameStructure); #ifdef GL_GLEXT_PROTOTYPES GLAPI GLvdpauSurfaceNV APIENTRY glVDPAURegisterVideoSurfaceWithPictureStructureNV (const void *vdpSurface, GLenum target, GLsizei numTextureNames, const GLuint *textureNames, GLboolean isFrameStructure); #endif #endif /* GL_NV_vdpau_interop2 */ #ifndef GL_NV_vertex_array_range #define GL_NV_vertex_array_range 1 #define GL_VERTEX_ARRAY_RANGE_NV 0x851D #define GL_VERTEX_ARRAY_RANGE_LENGTH_NV 0x851E #define GL_VERTEX_ARRAY_RANGE_VALID_NV 0x851F #define GL_MAX_VERTEX_ARRAY_RANGE_ELEMENT_NV 0x8520 #define GL_VERTEX_ARRAY_RANGE_POINTER_NV 0x8521 typedef void (APIENTRYP PFNGLFLUSHVERTEXARRAYRANGENVPROC) (void); typedef void (APIENTRYP PFNGLVERTEXARRAYRANGENVPROC) (GLsizei length, const void *pointer); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glFlushVertexArrayRangeNV (void); GLAPI void APIENTRY glVertexArrayRangeNV (GLsizei length, const void *pointer); #endif #endif /* GL_NV_vertex_array_range */ #ifndef GL_NV_vertex_array_range2 #define GL_NV_vertex_array_range2 1 #define GL_VERTEX_ARRAY_RANGE_WITHOUT_FLUSH_NV 0x8533 #endif /* GL_NV_vertex_array_range2 */ #ifndef GL_NV_vertex_attrib_integer_64bit #define GL_NV_vertex_attrib_integer_64bit 1 typedef void (APIENTRYP PFNGLVERTEXATTRIBL1I64NVPROC) (GLuint index, GLint64EXT x); typedef void (APIENTRYP PFNGLVERTEXATTRIBL2I64NVPROC) (GLuint index, GLint64EXT x, GLint64EXT y); typedef void (APIENTRYP PFNGLVERTEXATTRIBL3I64NVPROC) (GLuint index, GLint64EXT x, GLint64EXT y, GLint64EXT z); typedef void (APIENTRYP PFNGLVERTEXATTRIBL4I64NVPROC) (GLuint index, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w); typedef void (APIENTRYP PFNGLVERTEXATTRIBL1I64VNVPROC) (GLuint index, const GLint64EXT *v); typedef void (APIENTRYP PFNGLVERTEXATTRIBL2I64VNVPROC) (GLuint index, const GLint64EXT *v); typedef void (APIENTRYP PFNGLVERTEXATTRIBL3I64VNVPROC) (GLuint index, const GLint64EXT *v); typedef void (APIENTRYP PFNGLVERTEXATTRIBL4I64VNVPROC) (GLuint index, const GLint64EXT *v); typedef void (APIENTRYP PFNGLVERTEXATTRIBL1UI64NVPROC) (GLuint index, GLuint64EXT x); typedef void (APIENTRYP PFNGLVERTEXATTRIBL2UI64NVPROC) (GLuint index, GLuint64EXT x, GLuint64EXT y); typedef void (APIENTRYP PFNGLVERTEXATTRIBL3UI64NVPROC) (GLuint index, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z); typedef void (APIENTRYP PFNGLVERTEXATTRIBL4UI64NVPROC) (GLuint index, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w); typedef void (APIENTRYP PFNGLVERTEXATTRIBL1UI64VNVPROC) (GLuint index, const GLuint64EXT *v); typedef void (APIENTRYP PFNGLVERTEXATTRIBL2UI64VNVPROC) (GLuint index, const GLuint64EXT *v); typedef void (APIENTRYP PFNGLVERTEXATTRIBL3UI64VNVPROC) (GLuint index, const GLuint64EXT *v); typedef void (APIENTRYP PFNGLVERTEXATTRIBL4UI64VNVPROC) (GLuint index, const GLuint64EXT *v); typedef void (APIENTRYP PFNGLGETVERTEXATTRIBLI64VNVPROC) (GLuint index, GLenum pname, GLint64EXT *params); typedef void (APIENTRYP PFNGLGETVERTEXATTRIBLUI64VNVPROC) (GLuint index, GLenum pname, GLuint64EXT *params); typedef void (APIENTRYP PFNGLVERTEXATTRIBLFORMATNVPROC) (GLuint index, GLint size, GLenum type, GLsizei stride); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glVertexAttribL1i64NV (GLuint index, GLint64EXT x); GLAPI void APIENTRY glVertexAttribL2i64NV (GLuint index, GLint64EXT x, GLint64EXT y); GLAPI void APIENTRY glVertexAttribL3i64NV (GLuint index, GLint64EXT x, GLint64EXT y, GLint64EXT z); GLAPI void APIENTRY glVertexAttribL4i64NV (GLuint index, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w); GLAPI void APIENTRY glVertexAttribL1i64vNV (GLuint index, const GLint64EXT *v); GLAPI void APIENTRY glVertexAttribL2i64vNV (GLuint index, const GLint64EXT *v); GLAPI void APIENTRY glVertexAttribL3i64vNV (GLuint index, const GLint64EXT *v); GLAPI void APIENTRY glVertexAttribL4i64vNV (GLuint index, const GLint64EXT *v); GLAPI void APIENTRY glVertexAttribL1ui64NV (GLuint index, GLuint64EXT x); GLAPI void APIENTRY glVertexAttribL2ui64NV (GLuint index, GLuint64EXT x, GLuint64EXT y); GLAPI void APIENTRY glVertexAttribL3ui64NV (GLuint index, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z); GLAPI void APIENTRY glVertexAttribL4ui64NV (GLuint index, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w); GLAPI void APIENTRY glVertexAttribL1ui64vNV (GLuint index, const GLuint64EXT *v); GLAPI void APIENTRY glVertexAttribL2ui64vNV (GLuint index, const GLuint64EXT *v); GLAPI void APIENTRY glVertexAttribL3ui64vNV (GLuint index, const GLuint64EXT *v); GLAPI void APIENTRY glVertexAttribL4ui64vNV (GLuint index, const GLuint64EXT *v); GLAPI void APIENTRY glGetVertexAttribLi64vNV (GLuint index, GLenum pname, GLint64EXT *params); GLAPI void APIENTRY glGetVertexAttribLui64vNV (GLuint index, GLenum pname, GLuint64EXT *params); GLAPI void APIENTRY glVertexAttribLFormatNV (GLuint index, GLint size, GLenum type, GLsizei stride); #endif #endif /* GL_NV_vertex_attrib_integer_64bit */ #ifndef GL_NV_vertex_buffer_unified_memory #define GL_NV_vertex_buffer_unified_memory 1 #define GL_VERTEX_ATTRIB_ARRAY_UNIFIED_NV 0x8F1E #define GL_ELEMENT_ARRAY_UNIFIED_NV 0x8F1F #define GL_VERTEX_ATTRIB_ARRAY_ADDRESS_NV 0x8F20 #define GL_VERTEX_ARRAY_ADDRESS_NV 0x8F21 #define GL_NORMAL_ARRAY_ADDRESS_NV 0x8F22 #define GL_COLOR_ARRAY_ADDRESS_NV 0x8F23 #define GL_INDEX_ARRAY_ADDRESS_NV 0x8F24 #define GL_TEXTURE_COORD_ARRAY_ADDRESS_NV 0x8F25 #define GL_EDGE_FLAG_ARRAY_ADDRESS_NV 0x8F26 #define GL_SECONDARY_COLOR_ARRAY_ADDRESS_NV 0x8F27 #define GL_FOG_COORD_ARRAY_ADDRESS_NV 0x8F28 #define GL_ELEMENT_ARRAY_ADDRESS_NV 0x8F29 #define GL_VERTEX_ATTRIB_ARRAY_LENGTH_NV 0x8F2A #define GL_VERTEX_ARRAY_LENGTH_NV 0x8F2B #define GL_NORMAL_ARRAY_LENGTH_NV 0x8F2C #define GL_COLOR_ARRAY_LENGTH_NV 0x8F2D #define GL_INDEX_ARRAY_LENGTH_NV 0x8F2E #define GL_TEXTURE_COORD_ARRAY_LENGTH_NV 0x8F2F #define GL_EDGE_FLAG_ARRAY_LENGTH_NV 0x8F30 #define GL_SECONDARY_COLOR_ARRAY_LENGTH_NV 0x8F31 #define GL_FOG_COORD_ARRAY_LENGTH_NV 0x8F32 #define GL_ELEMENT_ARRAY_LENGTH_NV 0x8F33 #define GL_DRAW_INDIRECT_UNIFIED_NV 0x8F40 #define GL_DRAW_INDIRECT_ADDRESS_NV 0x8F41 #define GL_DRAW_INDIRECT_LENGTH_NV 0x8F42 typedef void (APIENTRYP PFNGLBUFFERADDRESSRANGENVPROC) (GLenum pname, GLuint index, GLuint64EXT address, GLsizeiptr length); typedef void (APIENTRYP PFNGLVERTEXFORMATNVPROC) (GLint size, GLenum type, GLsizei stride); typedef void (APIENTRYP PFNGLNORMALFORMATNVPROC) (GLenum type, GLsizei stride); typedef void (APIENTRYP PFNGLCOLORFORMATNVPROC) (GLint size, GLenum type, GLsizei stride); typedef void (APIENTRYP PFNGLINDEXFORMATNVPROC) (GLenum type, GLsizei stride); typedef void (APIENTRYP PFNGLTEXCOORDFORMATNVPROC) (GLint size, GLenum type, GLsizei stride); typedef void (APIENTRYP PFNGLEDGEFLAGFORMATNVPROC) (GLsizei stride); typedef void (APIENTRYP PFNGLSECONDARYCOLORFORMATNVPROC) (GLint size, GLenum type, GLsizei stride); typedef void (APIENTRYP PFNGLFOGCOORDFORMATNVPROC) (GLenum type, GLsizei stride); typedef void (APIENTRYP PFNGLVERTEXATTRIBFORMATNVPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride); typedef void (APIENTRYP PFNGLVERTEXATTRIBIFORMATNVPROC) (GLuint index, GLint size, GLenum type, GLsizei stride); typedef void (APIENTRYP PFNGLGETINTEGERUI64I_VNVPROC) (GLenum value, GLuint index, GLuint64EXT *result); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glBufferAddressRangeNV (GLenum pname, GLuint index, GLuint64EXT address, GLsizeiptr length); GLAPI void APIENTRY glVertexFormatNV (GLint size, GLenum type, GLsizei stride); GLAPI void APIENTRY glNormalFormatNV (GLenum type, GLsizei stride); GLAPI void APIENTRY glColorFormatNV (GLint size, GLenum type, GLsizei stride); GLAPI void APIENTRY glIndexFormatNV (GLenum type, GLsizei stride); GLAPI void APIENTRY glTexCoordFormatNV (GLint size, GLenum type, GLsizei stride); GLAPI void APIENTRY glEdgeFlagFormatNV (GLsizei stride); GLAPI void APIENTRY glSecondaryColorFormatNV (GLint size, GLenum type, GLsizei stride); GLAPI void APIENTRY glFogCoordFormatNV (GLenum type, GLsizei stride); GLAPI void APIENTRY glVertexAttribFormatNV (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride); GLAPI void APIENTRY glVertexAttribIFormatNV (GLuint index, GLint size, GLenum type, GLsizei stride); GLAPI void APIENTRY glGetIntegerui64i_vNV (GLenum value, GLuint index, GLuint64EXT *result); #endif #endif /* GL_NV_vertex_buffer_unified_memory */ #ifndef GL_NV_vertex_program #define GL_NV_vertex_program 1 #define GL_VERTEX_PROGRAM_NV 0x8620 #define GL_VERTEX_STATE_PROGRAM_NV 0x8621 #define GL_ATTRIB_ARRAY_SIZE_NV 0x8623 #define GL_ATTRIB_ARRAY_STRIDE_NV 0x8624 #define GL_ATTRIB_ARRAY_TYPE_NV 0x8625 #define GL_CURRENT_ATTRIB_NV 0x8626 #define GL_PROGRAM_LENGTH_NV 0x8627 #define GL_PROGRAM_STRING_NV 0x8628 #define GL_MODELVIEW_PROJECTION_NV 0x8629 #define GL_IDENTITY_NV 0x862A #define GL_INVERSE_NV 0x862B #define GL_TRANSPOSE_NV 0x862C #define GL_INVERSE_TRANSPOSE_NV 0x862D #define GL_MAX_TRACK_MATRIX_STACK_DEPTH_NV 0x862E #define GL_MAX_TRACK_MATRICES_NV 0x862F #define GL_MATRIX0_NV 0x8630 #define GL_MATRIX1_NV 0x8631 #define GL_MATRIX2_NV 0x8632 #define GL_MATRIX3_NV 0x8633 #define GL_MATRIX4_NV 0x8634 #define GL_MATRIX5_NV 0x8635 #define GL_MATRIX6_NV 0x8636 #define GL_MATRIX7_NV 0x8637 #define GL_CURRENT_MATRIX_STACK_DEPTH_NV 0x8640 #define GL_CURRENT_MATRIX_NV 0x8641 #define GL_VERTEX_PROGRAM_POINT_SIZE_NV 0x8642 #define GL_VERTEX_PROGRAM_TWO_SIDE_NV 0x8643 #define GL_PROGRAM_PARAMETER_NV 0x8644 #define GL_ATTRIB_ARRAY_POINTER_NV 0x8645 #define GL_PROGRAM_TARGET_NV 0x8646 #define GL_PROGRAM_RESIDENT_NV 0x8647 #define GL_TRACK_MATRIX_NV 0x8648 #define GL_TRACK_MATRIX_TRANSFORM_NV 0x8649 #define GL_VERTEX_PROGRAM_BINDING_NV 0x864A #define GL_PROGRAM_ERROR_POSITION_NV 0x864B #define GL_VERTEX_ATTRIB_ARRAY0_NV 0x8650 #define GL_VERTEX_ATTRIB_ARRAY1_NV 0x8651 #define GL_VERTEX_ATTRIB_ARRAY2_NV 0x8652 #define GL_VERTEX_ATTRIB_ARRAY3_NV 0x8653 #define GL_VERTEX_ATTRIB_ARRAY4_NV 0x8654 #define GL_VERTEX_ATTRIB_ARRAY5_NV 0x8655 #define GL_VERTEX_ATTRIB_ARRAY6_NV 0x8656 #define GL_VERTEX_ATTRIB_ARRAY7_NV 0x8657 #define GL_VERTEX_ATTRIB_ARRAY8_NV 0x8658 #define GL_VERTEX_ATTRIB_ARRAY9_NV 0x8659 #define GL_VERTEX_ATTRIB_ARRAY10_NV 0x865A #define GL_VERTEX_ATTRIB_ARRAY11_NV 0x865B #define GL_VERTEX_ATTRIB_ARRAY12_NV 0x865C #define GL_VERTEX_ATTRIB_ARRAY13_NV 0x865D #define GL_VERTEX_ATTRIB_ARRAY14_NV 0x865E #define GL_VERTEX_ATTRIB_ARRAY15_NV 0x865F #define GL_MAP1_VERTEX_ATTRIB0_4_NV 0x8660 #define GL_MAP1_VERTEX_ATTRIB1_4_NV 0x8661 #define GL_MAP1_VERTEX_ATTRIB2_4_NV 0x8662 #define GL_MAP1_VERTEX_ATTRIB3_4_NV 0x8663 #define GL_MAP1_VERTEX_ATTRIB4_4_NV 0x8664 #define GL_MAP1_VERTEX_ATTRIB5_4_NV 0x8665 #define GL_MAP1_VERTEX_ATTRIB6_4_NV 0x8666 #define GL_MAP1_VERTEX_ATTRIB7_4_NV 0x8667 #define GL_MAP1_VERTEX_ATTRIB8_4_NV 0x8668 #define GL_MAP1_VERTEX_ATTRIB9_4_NV 0x8669 #define GL_MAP1_VERTEX_ATTRIB10_4_NV 0x866A #define GL_MAP1_VERTEX_ATTRIB11_4_NV 0x866B #define GL_MAP1_VERTEX_ATTRIB12_4_NV 0x866C #define GL_MAP1_VERTEX_ATTRIB13_4_NV 0x866D #define GL_MAP1_VERTEX_ATTRIB14_4_NV 0x866E #define GL_MAP1_VERTEX_ATTRIB15_4_NV 0x866F #define GL_MAP2_VERTEX_ATTRIB0_4_NV 0x8670 #define GL_MAP2_VERTEX_ATTRIB1_4_NV 0x8671 #define GL_MAP2_VERTEX_ATTRIB2_4_NV 0x8672 #define GL_MAP2_VERTEX_ATTRIB3_4_NV 0x8673 #define GL_MAP2_VERTEX_ATTRIB4_4_NV 0x8674 #define GL_MAP2_VERTEX_ATTRIB5_4_NV 0x8675 #define GL_MAP2_VERTEX_ATTRIB6_4_NV 0x8676 #define GL_MAP2_VERTEX_ATTRIB7_4_NV 0x8677 #define GL_MAP2_VERTEX_ATTRIB8_4_NV 0x8678 #define GL_MAP2_VERTEX_ATTRIB9_4_NV 0x8679 #define GL_MAP2_VERTEX_ATTRIB10_4_NV 0x867A #define GL_MAP2_VERTEX_ATTRIB11_4_NV 0x867B #define GL_MAP2_VERTEX_ATTRIB12_4_NV 0x867C #define GL_MAP2_VERTEX_ATTRIB13_4_NV 0x867D #define GL_MAP2_VERTEX_ATTRIB14_4_NV 0x867E #define GL_MAP2_VERTEX_ATTRIB15_4_NV 0x867F typedef GLboolean (APIENTRYP PFNGLAREPROGRAMSRESIDENTNVPROC) (GLsizei n, const GLuint *programs, GLboolean *residences); typedef void (APIENTRYP PFNGLBINDPROGRAMNVPROC) (GLenum target, GLuint id); typedef void (APIENTRYP PFNGLDELETEPROGRAMSNVPROC) (GLsizei n, const GLuint *programs); typedef void (APIENTRYP PFNGLEXECUTEPROGRAMNVPROC) (GLenum target, GLuint id, const GLfloat *params); typedef void (APIENTRYP PFNGLGENPROGRAMSNVPROC) (GLsizei n, GLuint *programs); typedef void (APIENTRYP PFNGLGETPROGRAMPARAMETERDVNVPROC) (GLenum target, GLuint index, GLenum pname, GLdouble *params); typedef void (APIENTRYP PFNGLGETPROGRAMPARAMETERFVNVPROC) (GLenum target, GLuint index, GLenum pname, GLfloat *params); typedef void (APIENTRYP PFNGLGETPROGRAMIVNVPROC) (GLuint id, GLenum pname, GLint *params); typedef void (APIENTRYP PFNGLGETPROGRAMSTRINGNVPROC) (GLuint id, GLenum pname, GLubyte *program); typedef void (APIENTRYP PFNGLGETTRACKMATRIXIVNVPROC) (GLenum target, GLuint address, GLenum pname, GLint *params); typedef void (APIENTRYP PFNGLGETVERTEXATTRIBDVNVPROC) (GLuint index, GLenum pname, GLdouble *params); typedef void (APIENTRYP PFNGLGETVERTEXATTRIBFVNVPROC) (GLuint index, GLenum pname, GLfloat *params); typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIVNVPROC) (GLuint index, GLenum pname, GLint *params); typedef void (APIENTRYP PFNGLGETVERTEXATTRIBPOINTERVNVPROC) (GLuint index, GLenum pname, void **pointer); typedef GLboolean (APIENTRYP PFNGLISPROGRAMNVPROC) (GLuint id); typedef void (APIENTRYP PFNGLLOADPROGRAMNVPROC) (GLenum target, GLuint id, GLsizei len, const GLubyte *program); typedef void (APIENTRYP PFNGLPROGRAMPARAMETER4DNVPROC) (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); typedef void (APIENTRYP PFNGLPROGRAMPARAMETER4DVNVPROC) (GLenum target, GLuint index, const GLdouble *v); typedef void (APIENTRYP PFNGLPROGRAMPARAMETER4FNVPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); typedef void (APIENTRYP PFNGLPROGRAMPARAMETER4FVNVPROC) (GLenum target, GLuint index, const GLfloat *v); typedef void (APIENTRYP PFNGLPROGRAMPARAMETERS4DVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLdouble *v); typedef void (APIENTRYP PFNGLPROGRAMPARAMETERS4FVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLfloat *v); typedef void (APIENTRYP PFNGLREQUESTRESIDENTPROGRAMSNVPROC) (GLsizei n, const GLuint *programs); typedef void (APIENTRYP PFNGLTRACKMATRIXNVPROC) (GLenum target, GLuint address, GLenum matrix, GLenum transform); typedef void (APIENTRYP PFNGLVERTEXATTRIBPOINTERNVPROC) (GLuint index, GLint fsize, GLenum type, GLsizei stride, const void *pointer); typedef void (APIENTRYP PFNGLVERTEXATTRIB1DNVPROC) (GLuint index, GLdouble x); typedef void (APIENTRYP PFNGLVERTEXATTRIB1DVNVPROC) (GLuint index, const GLdouble *v); typedef void (APIENTRYP PFNGLVERTEXATTRIB1FNVPROC) (GLuint index, GLfloat x); typedef void (APIENTRYP PFNGLVERTEXATTRIB1FVNVPROC) (GLuint index, const GLfloat *v); typedef void (APIENTRYP PFNGLVERTEXATTRIB1SNVPROC) (GLuint index, GLshort x); typedef void (APIENTRYP PFNGLVERTEXATTRIB1SVNVPROC) (GLuint index, const GLshort *v); typedef void (APIENTRYP PFNGLVERTEXATTRIB2DNVPROC) (GLuint index, GLdouble x, GLdouble y); typedef void (APIENTRYP PFNGLVERTEXATTRIB2DVNVPROC) (GLuint index, const GLdouble *v); typedef void (APIENTRYP PFNGLVERTEXATTRIB2FNVPROC) (GLuint index, GLfloat x, GLfloat y); typedef void (APIENTRYP PFNGLVERTEXATTRIB2FVNVPROC) (GLuint index, const GLfloat *v); typedef void (APIENTRYP PFNGLVERTEXATTRIB2SNVPROC) (GLuint index, GLshort x, GLshort y); typedef void (APIENTRYP PFNGLVERTEXATTRIB2SVNVPROC) (GLuint index, const GLshort *v); typedef void (APIENTRYP PFNGLVERTEXATTRIB3DNVPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); typedef void (APIENTRYP PFNGLVERTEXATTRIB3DVNVPROC) (GLuint index, const GLdouble *v); typedef void (APIENTRYP PFNGLVERTEXATTRIB3FNVPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z); typedef void (APIENTRYP PFNGLVERTEXATTRIB3FVNVPROC) (GLuint index, const GLfloat *v); typedef void (APIENTRYP PFNGLVERTEXATTRIB3SNVPROC) (GLuint index, GLshort x, GLshort y, GLshort z); typedef void (APIENTRYP PFNGLVERTEXATTRIB3SVNVPROC) (GLuint index, const GLshort *v); typedef void (APIENTRYP PFNGLVERTEXATTRIB4DNVPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); typedef void (APIENTRYP PFNGLVERTEXATTRIB4DVNVPROC) (GLuint index, const GLdouble *v); typedef void (APIENTRYP PFNGLVERTEXATTRIB4FNVPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); typedef void (APIENTRYP PFNGLVERTEXATTRIB4FVNVPROC) (GLuint index, const GLfloat *v); typedef void (APIENTRYP PFNGLVERTEXATTRIB4SNVPROC) (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); typedef void (APIENTRYP PFNGLVERTEXATTRIB4SVNVPROC) (GLuint index, const GLshort *v); typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBNVPROC) (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBVNVPROC) (GLuint index, const GLubyte *v); typedef void (APIENTRYP PFNGLVERTEXATTRIBS1DVNVPROC) (GLuint index, GLsizei count, const GLdouble *v); typedef void (APIENTRYP PFNGLVERTEXATTRIBS1FVNVPROC) (GLuint index, GLsizei count, const GLfloat *v); typedef void (APIENTRYP PFNGLVERTEXATTRIBS1SVNVPROC) (GLuint index, GLsizei count, const GLshort *v); typedef void (APIENTRYP PFNGLVERTEXATTRIBS2DVNVPROC) (GLuint index, GLsizei count, const GLdouble *v); typedef void (APIENTRYP PFNGLVERTEXATTRIBS2FVNVPROC) (GLuint index, GLsizei count, const GLfloat *v); typedef void (APIENTRYP PFNGLVERTEXATTRIBS2SVNVPROC) (GLuint index, GLsizei count, const GLshort *v); typedef void (APIENTRYP PFNGLVERTEXATTRIBS3DVNVPROC) (GLuint index, GLsizei count, const GLdouble *v); typedef void (APIENTRYP PFNGLVERTEXATTRIBS3FVNVPROC) (GLuint index, GLsizei count, const GLfloat *v); typedef void (APIENTRYP PFNGLVERTEXATTRIBS3SVNVPROC) (GLuint index, GLsizei count, const GLshort *v); typedef void (APIENTRYP PFNGLVERTEXATTRIBS4DVNVPROC) (GLuint index, GLsizei count, const GLdouble *v); typedef void (APIENTRYP PFNGLVERTEXATTRIBS4FVNVPROC) (GLuint index, GLsizei count, const GLfloat *v); typedef void (APIENTRYP PFNGLVERTEXATTRIBS4SVNVPROC) (GLuint index, GLsizei count, const GLshort *v); typedef void (APIENTRYP PFNGLVERTEXATTRIBS4UBVNVPROC) (GLuint index, GLsizei count, const GLubyte *v); #ifdef GL_GLEXT_PROTOTYPES GLAPI GLboolean APIENTRY glAreProgramsResidentNV (GLsizei n, const GLuint *programs, GLboolean *residences); GLAPI void APIENTRY glBindProgramNV (GLenum target, GLuint id); GLAPI void APIENTRY glDeleteProgramsNV (GLsizei n, const GLuint *programs); GLAPI void APIENTRY glExecuteProgramNV (GLenum target, GLuint id, const GLfloat *params); GLAPI void APIENTRY glGenProgramsNV (GLsizei n, GLuint *programs); GLAPI void APIENTRY glGetProgramParameterdvNV (GLenum target, GLuint index, GLenum pname, GLdouble *params); GLAPI void APIENTRY glGetProgramParameterfvNV (GLenum target, GLuint index, GLenum pname, GLfloat *params); GLAPI void APIENTRY glGetProgramivNV (GLuint id, GLenum pname, GLint *params); GLAPI void APIENTRY glGetProgramStringNV (GLuint id, GLenum pname, GLubyte *program); GLAPI void APIENTRY glGetTrackMatrixivNV (GLenum target, GLuint address, GLenum pname, GLint *params); GLAPI void APIENTRY glGetVertexAttribdvNV (GLuint index, GLenum pname, GLdouble *params); GLAPI void APIENTRY glGetVertexAttribfvNV (GLuint index, GLenum pname, GLfloat *params); GLAPI void APIENTRY glGetVertexAttribivNV (GLuint index, GLenum pname, GLint *params); GLAPI void APIENTRY glGetVertexAttribPointervNV (GLuint index, GLenum pname, void **pointer); GLAPI GLboolean APIENTRY glIsProgramNV (GLuint id); GLAPI void APIENTRY glLoadProgramNV (GLenum target, GLuint id, GLsizei len, const GLubyte *program); GLAPI void APIENTRY glProgramParameter4dNV (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); GLAPI void APIENTRY glProgramParameter4dvNV (GLenum target, GLuint index, const GLdouble *v); GLAPI void APIENTRY glProgramParameter4fNV (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); GLAPI void APIENTRY glProgramParameter4fvNV (GLenum target, GLuint index, const GLfloat *v); GLAPI void APIENTRY glProgramParameters4dvNV (GLenum target, GLuint index, GLsizei count, const GLdouble *v); GLAPI void APIENTRY glProgramParameters4fvNV (GLenum target, GLuint index, GLsizei count, const GLfloat *v); GLAPI void APIENTRY glRequestResidentProgramsNV (GLsizei n, const GLuint *programs); GLAPI void APIENTRY glTrackMatrixNV (GLenum target, GLuint address, GLenum matrix, GLenum transform); GLAPI void APIENTRY glVertexAttribPointerNV (GLuint index, GLint fsize, GLenum type, GLsizei stride, const void *pointer); GLAPI void APIENTRY glVertexAttrib1dNV (GLuint index, GLdouble x); GLAPI void APIENTRY glVertexAttrib1dvNV (GLuint index, const GLdouble *v); GLAPI void APIENTRY glVertexAttrib1fNV (GLuint index, GLfloat x); GLAPI void APIENTRY glVertexAttrib1fvNV (GLuint index, const GLfloat *v); GLAPI void APIENTRY glVertexAttrib1sNV (GLuint index, GLshort x); GLAPI void APIENTRY glVertexAttrib1svNV (GLuint index, const GLshort *v); GLAPI void APIENTRY glVertexAttrib2dNV (GLuint index, GLdouble x, GLdouble y); GLAPI void APIENTRY glVertexAttrib2dvNV (GLuint index, const GLdouble *v); GLAPI void APIENTRY glVertexAttrib2fNV (GLuint index, GLfloat x, GLfloat y); GLAPI void APIENTRY glVertexAttrib2fvNV (GLuint index, const GLfloat *v); GLAPI void APIENTRY glVertexAttrib2sNV (GLuint index, GLshort x, GLshort y); GLAPI void APIENTRY glVertexAttrib2svNV (GLuint index, const GLshort *v); GLAPI void APIENTRY glVertexAttrib3dNV (GLuint index, GLdouble x, GLdouble y, GLdouble z); GLAPI void APIENTRY glVertexAttrib3dvNV (GLuint index, const GLdouble *v); GLAPI void APIENTRY glVertexAttrib3fNV (GLuint index, GLfloat x, GLfloat y, GLfloat z); GLAPI void APIENTRY glVertexAttrib3fvNV (GLuint index, const GLfloat *v); GLAPI void APIENTRY glVertexAttrib3sNV (GLuint index, GLshort x, GLshort y, GLshort z); GLAPI void APIENTRY glVertexAttrib3svNV (GLuint index, const GLshort *v); GLAPI void APIENTRY glVertexAttrib4dNV (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); GLAPI void APIENTRY glVertexAttrib4dvNV (GLuint index, const GLdouble *v); GLAPI void APIENTRY glVertexAttrib4fNV (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); GLAPI void APIENTRY glVertexAttrib4fvNV (GLuint index, const GLfloat *v); GLAPI void APIENTRY glVertexAttrib4sNV (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); GLAPI void APIENTRY glVertexAttrib4svNV (GLuint index, const GLshort *v); GLAPI void APIENTRY glVertexAttrib4ubNV (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); GLAPI void APIENTRY glVertexAttrib4ubvNV (GLuint index, const GLubyte *v); GLAPI void APIENTRY glVertexAttribs1dvNV (GLuint index, GLsizei count, const GLdouble *v); GLAPI void APIENTRY glVertexAttribs1fvNV (GLuint index, GLsizei count, const GLfloat *v); GLAPI void APIENTRY glVertexAttribs1svNV (GLuint index, GLsizei count, const GLshort *v); GLAPI void APIENTRY glVertexAttribs2dvNV (GLuint index, GLsizei count, const GLdouble *v); GLAPI void APIENTRY glVertexAttribs2fvNV (GLuint index, GLsizei count, const GLfloat *v); GLAPI void APIENTRY glVertexAttribs2svNV (GLuint index, GLsizei count, const GLshort *v); GLAPI void APIENTRY glVertexAttribs3dvNV (GLuint index, GLsizei count, const GLdouble *v); GLAPI void APIENTRY glVertexAttribs3fvNV (GLuint index, GLsizei count, const GLfloat *v); GLAPI void APIENTRY glVertexAttribs3svNV (GLuint index, GLsizei count, const GLshort *v); GLAPI void APIENTRY glVertexAttribs4dvNV (GLuint index, GLsizei count, const GLdouble *v); GLAPI void APIENTRY glVertexAttribs4fvNV (GLuint index, GLsizei count, const GLfloat *v); GLAPI void APIENTRY glVertexAttribs4svNV (GLuint index, GLsizei count, const GLshort *v); GLAPI void APIENTRY glVertexAttribs4ubvNV (GLuint index, GLsizei count, const GLubyte *v); #endif #endif /* GL_NV_vertex_program */ #ifndef GL_NV_vertex_program1_1 #define GL_NV_vertex_program1_1 1 #endif /* GL_NV_vertex_program1_1 */ #ifndef GL_NV_vertex_program2 #define GL_NV_vertex_program2 1 #endif /* GL_NV_vertex_program2 */ #ifndef GL_NV_vertex_program2_option #define GL_NV_vertex_program2_option 1 #endif /* GL_NV_vertex_program2_option */ #ifndef GL_NV_vertex_program3 #define GL_NV_vertex_program3 1 #endif /* GL_NV_vertex_program3 */ #ifndef GL_NV_vertex_program4 #define GL_NV_vertex_program4 1 #define GL_VERTEX_ATTRIB_ARRAY_INTEGER_NV 0x88FD #endif /* GL_NV_vertex_program4 */ #ifndef GL_NV_video_capture #define GL_NV_video_capture 1 #define GL_VIDEO_BUFFER_NV 0x9020 #define GL_VIDEO_BUFFER_BINDING_NV 0x9021 #define GL_FIELD_UPPER_NV 0x9022 #define GL_FIELD_LOWER_NV 0x9023 #define GL_NUM_VIDEO_CAPTURE_STREAMS_NV 0x9024 #define GL_NEXT_VIDEO_CAPTURE_BUFFER_STATUS_NV 0x9025 #define GL_VIDEO_CAPTURE_TO_422_SUPPORTED_NV 0x9026 #define GL_LAST_VIDEO_CAPTURE_STATUS_NV 0x9027 #define GL_VIDEO_BUFFER_PITCH_NV 0x9028 #define GL_VIDEO_COLOR_CONVERSION_MATRIX_NV 0x9029 #define GL_VIDEO_COLOR_CONVERSION_MAX_NV 0x902A #define GL_VIDEO_COLOR_CONVERSION_MIN_NV 0x902B #define GL_VIDEO_COLOR_CONVERSION_OFFSET_NV 0x902C #define GL_VIDEO_BUFFER_INTERNAL_FORMAT_NV 0x902D #define GL_PARTIAL_SUCCESS_NV 0x902E #define GL_SUCCESS_NV 0x902F #define GL_FAILURE_NV 0x9030 #define GL_YCBYCR8_422_NV 0x9031 #define GL_YCBAYCR8A_4224_NV 0x9032 #define GL_Z6Y10Z6CB10Z6Y10Z6CR10_422_NV 0x9033 #define GL_Z6Y10Z6CB10Z6A10Z6Y10Z6CR10Z6A10_4224_NV 0x9034 #define GL_Z4Y12Z4CB12Z4Y12Z4CR12_422_NV 0x9035 #define GL_Z4Y12Z4CB12Z4A12Z4Y12Z4CR12Z4A12_4224_NV 0x9036 #define GL_Z4Y12Z4CB12Z4CR12_444_NV 0x9037 #define GL_VIDEO_CAPTURE_FRAME_WIDTH_NV 0x9038 #define GL_VIDEO_CAPTURE_FRAME_HEIGHT_NV 0x9039 #define GL_VIDEO_CAPTURE_FIELD_UPPER_HEIGHT_NV 0x903A #define GL_VIDEO_CAPTURE_FIELD_LOWER_HEIGHT_NV 0x903B #define GL_VIDEO_CAPTURE_SURFACE_ORIGIN_NV 0x903C typedef void (APIENTRYP PFNGLBEGINVIDEOCAPTURENVPROC) (GLuint video_capture_slot); typedef void (APIENTRYP PFNGLBINDVIDEOCAPTURESTREAMBUFFERNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum frame_region, GLintptrARB offset); typedef void (APIENTRYP PFNGLBINDVIDEOCAPTURESTREAMTEXTURENVPROC) (GLuint video_capture_slot, GLuint stream, GLenum frame_region, GLenum target, GLuint texture); typedef void (APIENTRYP PFNGLENDVIDEOCAPTURENVPROC) (GLuint video_capture_slot); typedef void (APIENTRYP PFNGLGETVIDEOCAPTUREIVNVPROC) (GLuint video_capture_slot, GLenum pname, GLint *params); typedef void (APIENTRYP PFNGLGETVIDEOCAPTURESTREAMIVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, GLint *params); typedef void (APIENTRYP PFNGLGETVIDEOCAPTURESTREAMFVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, GLfloat *params); typedef void (APIENTRYP PFNGLGETVIDEOCAPTURESTREAMDVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, GLdouble *params); typedef GLenum (APIENTRYP PFNGLVIDEOCAPTURENVPROC) (GLuint video_capture_slot, GLuint *sequence_num, GLuint64EXT *capture_time); typedef void (APIENTRYP PFNGLVIDEOCAPTURESTREAMPARAMETERIVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLint *params); typedef void (APIENTRYP PFNGLVIDEOCAPTURESTREAMPARAMETERFVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLfloat *params); typedef void (APIENTRYP PFNGLVIDEOCAPTURESTREAMPARAMETERDVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLdouble *params); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glBeginVideoCaptureNV (GLuint video_capture_slot); GLAPI void APIENTRY glBindVideoCaptureStreamBufferNV (GLuint video_capture_slot, GLuint stream, GLenum frame_region, GLintptrARB offset); GLAPI void APIENTRY glBindVideoCaptureStreamTextureNV (GLuint video_capture_slot, GLuint stream, GLenum frame_region, GLenum target, GLuint texture); GLAPI void APIENTRY glEndVideoCaptureNV (GLuint video_capture_slot); GLAPI void APIENTRY glGetVideoCaptureivNV (GLuint video_capture_slot, GLenum pname, GLint *params); GLAPI void APIENTRY glGetVideoCaptureStreamivNV (GLuint video_capture_slot, GLuint stream, GLenum pname, GLint *params); GLAPI void APIENTRY glGetVideoCaptureStreamfvNV (GLuint video_capture_slot, GLuint stream, GLenum pname, GLfloat *params); GLAPI void APIENTRY glGetVideoCaptureStreamdvNV (GLuint video_capture_slot, GLuint stream, GLenum pname, GLdouble *params); GLAPI GLenum APIENTRY glVideoCaptureNV (GLuint video_capture_slot, GLuint *sequence_num, GLuint64EXT *capture_time); GLAPI void APIENTRY glVideoCaptureStreamParameterivNV (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLint *params); GLAPI void APIENTRY glVideoCaptureStreamParameterfvNV (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLfloat *params); GLAPI void APIENTRY glVideoCaptureStreamParameterdvNV (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLdouble *params); #endif #endif /* GL_NV_video_capture */ #ifndef GL_NV_viewport_array2 #define GL_NV_viewport_array2 1 #endif /* GL_NV_viewport_array2 */ #ifndef GL_NV_viewport_swizzle #define GL_NV_viewport_swizzle 1 #define GL_VIEWPORT_SWIZZLE_POSITIVE_X_NV 0x9350 #define GL_VIEWPORT_SWIZZLE_NEGATIVE_X_NV 0x9351 #define GL_VIEWPORT_SWIZZLE_POSITIVE_Y_NV 0x9352 #define GL_VIEWPORT_SWIZZLE_NEGATIVE_Y_NV 0x9353 #define GL_VIEWPORT_SWIZZLE_POSITIVE_Z_NV 0x9354 #define GL_VIEWPORT_SWIZZLE_NEGATIVE_Z_NV 0x9355 #define GL_VIEWPORT_SWIZZLE_POSITIVE_W_NV 0x9356 #define GL_VIEWPORT_SWIZZLE_NEGATIVE_W_NV 0x9357 #define GL_VIEWPORT_SWIZZLE_X_NV 0x9358 #define GL_VIEWPORT_SWIZZLE_Y_NV 0x9359 #define GL_VIEWPORT_SWIZZLE_Z_NV 0x935A #define GL_VIEWPORT_SWIZZLE_W_NV 0x935B typedef void (APIENTRYP PFNGLVIEWPORTSWIZZLENVPROC) (GLuint index, GLenum swizzlex, GLenum swizzley, GLenum swizzlez, GLenum swizzlew); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glViewportSwizzleNV (GLuint index, GLenum swizzlex, GLenum swizzley, GLenum swizzlez, GLenum swizzlew); #endif #endif /* GL_NV_viewport_swizzle */ #ifndef GL_OML_interlace #define GL_OML_interlace 1 #define GL_INTERLACE_OML 0x8980 #define GL_INTERLACE_READ_OML 0x8981 #endif /* GL_OML_interlace */ #ifndef GL_OML_resample #define GL_OML_resample 1 #define GL_PACK_RESAMPLE_OML 0x8984 #define GL_UNPACK_RESAMPLE_OML 0x8985 #define GL_RESAMPLE_REPLICATE_OML 0x8986 #define GL_RESAMPLE_ZERO_FILL_OML 0x8987 #define GL_RESAMPLE_AVERAGE_OML 0x8988 #define GL_RESAMPLE_DECIMATE_OML 0x8989 #endif /* GL_OML_resample */ #ifndef GL_OML_subsample #define GL_OML_subsample 1 #define GL_FORMAT_SUBSAMPLE_24_24_OML 0x8982 #define GL_FORMAT_SUBSAMPLE_244_244_OML 0x8983 #endif /* GL_OML_subsample */ #ifndef GL_OVR_multiview #define GL_OVR_multiview 1 #define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_NUM_VIEWS_OVR 0x9630 #define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_BASE_VIEW_INDEX_OVR 0x9632 #define GL_MAX_VIEWS_OVR 0x9631 #define GL_FRAMEBUFFER_INCOMPLETE_VIEW_TARGETS_OVR 0x9633 typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREMULTIVIEWOVRPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint baseViewIndex, GLsizei numViews); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glFramebufferTextureMultiviewOVR (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint baseViewIndex, GLsizei numViews); #endif #endif /* GL_OVR_multiview */ #ifndef GL_OVR_multiview2 #define GL_OVR_multiview2 1 #endif /* GL_OVR_multiview2 */ #ifndef GL_PGI_misc_hints #define GL_PGI_misc_hints 1 #define GL_PREFER_DOUBLEBUFFER_HINT_PGI 0x1A1F8 #define GL_CONSERVE_MEMORY_HINT_PGI 0x1A1FD #define GL_RECLAIM_MEMORY_HINT_PGI 0x1A1FE #define GL_NATIVE_GRAPHICS_HANDLE_PGI 0x1A202 #define GL_NATIVE_GRAPHICS_BEGIN_HINT_PGI 0x1A203 #define GL_NATIVE_GRAPHICS_END_HINT_PGI 0x1A204 #define GL_ALWAYS_FAST_HINT_PGI 0x1A20C #define GL_ALWAYS_SOFT_HINT_PGI 0x1A20D #define GL_ALLOW_DRAW_OBJ_HINT_PGI 0x1A20E #define GL_ALLOW_DRAW_WIN_HINT_PGI 0x1A20F #define GL_ALLOW_DRAW_FRG_HINT_PGI 0x1A210 #define GL_ALLOW_DRAW_MEM_HINT_PGI 0x1A211 #define GL_STRICT_DEPTHFUNC_HINT_PGI 0x1A216 #define GL_STRICT_LIGHTING_HINT_PGI 0x1A217 #define GL_STRICT_SCISSOR_HINT_PGI 0x1A218 #define GL_FULL_STIPPLE_HINT_PGI 0x1A219 #define GL_CLIP_NEAR_HINT_PGI 0x1A220 #define GL_CLIP_FAR_HINT_PGI 0x1A221 #define GL_WIDE_LINE_HINT_PGI 0x1A222 #define GL_BACK_NORMALS_HINT_PGI 0x1A223 typedef void (APIENTRYP PFNGLHINTPGIPROC) (GLenum target, GLint mode); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glHintPGI (GLenum target, GLint mode); #endif #endif /* GL_PGI_misc_hints */ #ifndef GL_PGI_vertex_hints #define GL_PGI_vertex_hints 1 #define GL_VERTEX_DATA_HINT_PGI 0x1A22A #define GL_VERTEX_CONSISTENT_HINT_PGI 0x1A22B #define GL_MATERIAL_SIDE_HINT_PGI 0x1A22C #define GL_MAX_VERTEX_HINT_PGI 0x1A22D #define GL_COLOR3_BIT_PGI 0x00010000 #define GL_COLOR4_BIT_PGI 0x00020000 #define GL_EDGEFLAG_BIT_PGI 0x00040000 #define GL_INDEX_BIT_PGI 0x00080000 #define GL_MAT_AMBIENT_BIT_PGI 0x00100000 #define GL_MAT_AMBIENT_AND_DIFFUSE_BIT_PGI 0x00200000 #define GL_MAT_DIFFUSE_BIT_PGI 0x00400000 #define GL_MAT_EMISSION_BIT_PGI 0x00800000 #define GL_MAT_COLOR_INDEXES_BIT_PGI 0x01000000 #define GL_MAT_SHININESS_BIT_PGI 0x02000000 #define GL_MAT_SPECULAR_BIT_PGI 0x04000000 #define GL_NORMAL_BIT_PGI 0x08000000 #define GL_TEXCOORD1_BIT_PGI 0x10000000 #define GL_TEXCOORD2_BIT_PGI 0x20000000 #define GL_TEXCOORD3_BIT_PGI 0x40000000 #define GL_TEXCOORD4_BIT_PGI 0x80000000 #define GL_VERTEX23_BIT_PGI 0x00000004 #define GL_VERTEX4_BIT_PGI 0x00000008 #endif /* GL_PGI_vertex_hints */ #ifndef GL_REND_screen_coordinates #define GL_REND_screen_coordinates 1 #define GL_SCREEN_COORDINATES_REND 0x8490 #define GL_INVERTED_SCREEN_W_REND 0x8491 #endif /* GL_REND_screen_coordinates */ #ifndef GL_S3_s3tc #define GL_S3_s3tc 1 #define GL_RGB_S3TC 0x83A0 #define GL_RGB4_S3TC 0x83A1 #define GL_RGBA_S3TC 0x83A2 #define GL_RGBA4_S3TC 0x83A3 #define GL_RGBA_DXT5_S3TC 0x83A4 #define GL_RGBA4_DXT5_S3TC 0x83A5 #endif /* GL_S3_s3tc */ #ifndef GL_SGIS_detail_texture #define GL_SGIS_detail_texture 1 #define GL_DETAIL_TEXTURE_2D_SGIS 0x8095 #define GL_DETAIL_TEXTURE_2D_BINDING_SGIS 0x8096 #define GL_LINEAR_DETAIL_SGIS 0x8097 #define GL_LINEAR_DETAIL_ALPHA_SGIS 0x8098 #define GL_LINEAR_DETAIL_COLOR_SGIS 0x8099 #define GL_DETAIL_TEXTURE_LEVEL_SGIS 0x809A #define GL_DETAIL_TEXTURE_MODE_SGIS 0x809B #define GL_DETAIL_TEXTURE_FUNC_POINTS_SGIS 0x809C typedef void (APIENTRYP PFNGLDETAILTEXFUNCSGISPROC) (GLenum target, GLsizei n, const GLfloat *points); typedef void (APIENTRYP PFNGLGETDETAILTEXFUNCSGISPROC) (GLenum target, GLfloat *points); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glDetailTexFuncSGIS (GLenum target, GLsizei n, const GLfloat *points); GLAPI void APIENTRY glGetDetailTexFuncSGIS (GLenum target, GLfloat *points); #endif #endif /* GL_SGIS_detail_texture */ #ifndef GL_SGIS_fog_function #define GL_SGIS_fog_function 1 #define GL_FOG_FUNC_SGIS 0x812A #define GL_FOG_FUNC_POINTS_SGIS 0x812B #define GL_MAX_FOG_FUNC_POINTS_SGIS 0x812C typedef void (APIENTRYP PFNGLFOGFUNCSGISPROC) (GLsizei n, const GLfloat *points); typedef void (APIENTRYP PFNGLGETFOGFUNCSGISPROC) (GLfloat *points); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glFogFuncSGIS (GLsizei n, const GLfloat *points); GLAPI void APIENTRY glGetFogFuncSGIS (GLfloat *points); #endif #endif /* GL_SGIS_fog_function */ #ifndef GL_SGIS_generate_mipmap #define GL_SGIS_generate_mipmap 1 #define GL_GENERATE_MIPMAP_SGIS 0x8191 #define GL_GENERATE_MIPMAP_HINT_SGIS 0x8192 #endif /* GL_SGIS_generate_mipmap */ #ifndef GL_SGIS_multisample #define GL_SGIS_multisample 1 #define GL_MULTISAMPLE_SGIS 0x809D #define GL_SAMPLE_ALPHA_TO_MASK_SGIS 0x809E #define GL_SAMPLE_ALPHA_TO_ONE_SGIS 0x809F #define GL_SAMPLE_MASK_SGIS 0x80A0 #define GL_1PASS_SGIS 0x80A1 #define GL_2PASS_0_SGIS 0x80A2 #define GL_2PASS_1_SGIS 0x80A3 #define GL_4PASS_0_SGIS 0x80A4 #define GL_4PASS_1_SGIS 0x80A5 #define GL_4PASS_2_SGIS 0x80A6 #define GL_4PASS_3_SGIS 0x80A7 #define GL_SAMPLE_BUFFERS_SGIS 0x80A8 #define GL_SAMPLES_SGIS 0x80A9 #define GL_SAMPLE_MASK_VALUE_SGIS 0x80AA #define GL_SAMPLE_MASK_INVERT_SGIS 0x80AB #define GL_SAMPLE_PATTERN_SGIS 0x80AC typedef void (APIENTRYP PFNGLSAMPLEMASKSGISPROC) (GLclampf value, GLboolean invert); typedef void (APIENTRYP PFNGLSAMPLEPATTERNSGISPROC) (GLenum pattern); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glSampleMaskSGIS (GLclampf value, GLboolean invert); GLAPI void APIENTRY glSamplePatternSGIS (GLenum pattern); #endif #endif /* GL_SGIS_multisample */ #ifndef GL_SGIS_pixel_texture #define GL_SGIS_pixel_texture 1 #define GL_PIXEL_TEXTURE_SGIS 0x8353 #define GL_PIXEL_FRAGMENT_RGB_SOURCE_SGIS 0x8354 #define GL_PIXEL_FRAGMENT_ALPHA_SOURCE_SGIS 0x8355 #define GL_PIXEL_GROUP_COLOR_SGIS 0x8356 typedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERISGISPROC) (GLenum pname, GLint param); typedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERIVSGISPROC) (GLenum pname, const GLint *params); typedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERFSGISPROC) (GLenum pname, GLfloat param); typedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERFVSGISPROC) (GLenum pname, const GLfloat *params); typedef void (APIENTRYP PFNGLGETPIXELTEXGENPARAMETERIVSGISPROC) (GLenum pname, GLint *params); typedef void (APIENTRYP PFNGLGETPIXELTEXGENPARAMETERFVSGISPROC) (GLenum pname, GLfloat *params); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glPixelTexGenParameteriSGIS (GLenum pname, GLint param); GLAPI void APIENTRY glPixelTexGenParameterivSGIS (GLenum pname, const GLint *params); GLAPI void APIENTRY glPixelTexGenParameterfSGIS (GLenum pname, GLfloat param); GLAPI void APIENTRY glPixelTexGenParameterfvSGIS (GLenum pname, const GLfloat *params); GLAPI void APIENTRY glGetPixelTexGenParameterivSGIS (GLenum pname, GLint *params); GLAPI void APIENTRY glGetPixelTexGenParameterfvSGIS (GLenum pname, GLfloat *params); #endif #endif /* GL_SGIS_pixel_texture */ #ifndef GL_SGIS_point_line_texgen #define GL_SGIS_point_line_texgen 1 #define GL_EYE_DISTANCE_TO_POINT_SGIS 0x81F0 #define GL_OBJECT_DISTANCE_TO_POINT_SGIS 0x81F1 #define GL_EYE_DISTANCE_TO_LINE_SGIS 0x81F2 #define GL_OBJECT_DISTANCE_TO_LINE_SGIS 0x81F3 #define GL_EYE_POINT_SGIS 0x81F4 #define GL_OBJECT_POINT_SGIS 0x81F5 #define GL_EYE_LINE_SGIS 0x81F6 #define GL_OBJECT_LINE_SGIS 0x81F7 #endif /* GL_SGIS_point_line_texgen */ #ifndef GL_SGIS_point_parameters #define GL_SGIS_point_parameters 1 #define GL_POINT_SIZE_MIN_SGIS 0x8126 #define GL_POINT_SIZE_MAX_SGIS 0x8127 #define GL_POINT_FADE_THRESHOLD_SIZE_SGIS 0x8128 #define GL_DISTANCE_ATTENUATION_SGIS 0x8129 typedef void (APIENTRYP PFNGLPOINTPARAMETERFSGISPROC) (GLenum pname, GLfloat param); typedef void (APIENTRYP PFNGLPOINTPARAMETERFVSGISPROC) (GLenum pname, const GLfloat *params); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glPointParameterfSGIS (GLenum pname, GLfloat param); GLAPI void APIENTRY glPointParameterfvSGIS (GLenum pname, const GLfloat *params); #endif #endif /* GL_SGIS_point_parameters */ #ifndef GL_SGIS_sharpen_texture #define GL_SGIS_sharpen_texture 1 #define GL_LINEAR_SHARPEN_SGIS 0x80AD #define GL_LINEAR_SHARPEN_ALPHA_SGIS 0x80AE #define GL_LINEAR_SHARPEN_COLOR_SGIS 0x80AF #define GL_SHARPEN_TEXTURE_FUNC_POINTS_SGIS 0x80B0 typedef void (APIENTRYP PFNGLSHARPENTEXFUNCSGISPROC) (GLenum target, GLsizei n, const GLfloat *points); typedef void (APIENTRYP PFNGLGETSHARPENTEXFUNCSGISPROC) (GLenum target, GLfloat *points); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glSharpenTexFuncSGIS (GLenum target, GLsizei n, const GLfloat *points); GLAPI void APIENTRY glGetSharpenTexFuncSGIS (GLenum target, GLfloat *points); #endif #endif /* GL_SGIS_sharpen_texture */ #ifndef GL_SGIS_texture4D #define GL_SGIS_texture4D 1 #define GL_PACK_SKIP_VOLUMES_SGIS 0x8130 #define GL_PACK_IMAGE_DEPTH_SGIS 0x8131 #define GL_UNPACK_SKIP_VOLUMES_SGIS 0x8132 #define GL_UNPACK_IMAGE_DEPTH_SGIS 0x8133 #define GL_TEXTURE_4D_SGIS 0x8134 #define GL_PROXY_TEXTURE_4D_SGIS 0x8135 #define GL_TEXTURE_4DSIZE_SGIS 0x8136 #define GL_TEXTURE_WRAP_Q_SGIS 0x8137 #define GL_MAX_4D_TEXTURE_SIZE_SGIS 0x8138 #define GL_TEXTURE_4D_BINDING_SGIS 0x814F typedef void (APIENTRYP PFNGLTEXIMAGE4DSGISPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLsizei size4d, GLint border, GLenum format, GLenum type, const void *pixels); typedef void (APIENTRYP PFNGLTEXSUBIMAGE4DSGISPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint woffset, GLsizei width, GLsizei height, GLsizei depth, GLsizei size4d, GLenum format, GLenum type, const void *pixels); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glTexImage4DSGIS (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLsizei size4d, GLint border, GLenum format, GLenum type, const void *pixels); GLAPI void APIENTRY glTexSubImage4DSGIS (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint woffset, GLsizei width, GLsizei height, GLsizei depth, GLsizei size4d, GLenum format, GLenum type, const void *pixels); #endif #endif /* GL_SGIS_texture4D */ #ifndef GL_SGIS_texture_border_clamp #define GL_SGIS_texture_border_clamp 1 #define GL_CLAMP_TO_BORDER_SGIS 0x812D #endif /* GL_SGIS_texture_border_clamp */ #ifndef GL_SGIS_texture_color_mask #define GL_SGIS_texture_color_mask 1 #define GL_TEXTURE_COLOR_WRITEMASK_SGIS 0x81EF typedef void (APIENTRYP PFNGLTEXTURECOLORMASKSGISPROC) (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glTextureColorMaskSGIS (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); #endif #endif /* GL_SGIS_texture_color_mask */ #ifndef GL_SGIS_texture_edge_clamp #define GL_SGIS_texture_edge_clamp 1 #define GL_CLAMP_TO_EDGE_SGIS 0x812F #endif /* GL_SGIS_texture_edge_clamp */ #ifndef GL_SGIS_texture_filter4 #define GL_SGIS_texture_filter4 1 #define GL_FILTER4_SGIS 0x8146 #define GL_TEXTURE_FILTER4_SIZE_SGIS 0x8147 typedef void (APIENTRYP PFNGLGETTEXFILTERFUNCSGISPROC) (GLenum target, GLenum filter, GLfloat *weights); typedef void (APIENTRYP PFNGLTEXFILTERFUNCSGISPROC) (GLenum target, GLenum filter, GLsizei n, const GLfloat *weights); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glGetTexFilterFuncSGIS (GLenum target, GLenum filter, GLfloat *weights); GLAPI void APIENTRY glTexFilterFuncSGIS (GLenum target, GLenum filter, GLsizei n, const GLfloat *weights); #endif #endif /* GL_SGIS_texture_filter4 */ #ifndef GL_SGIS_texture_lod #define GL_SGIS_texture_lod 1 #define GL_TEXTURE_MIN_LOD_SGIS 0x813A #define GL_TEXTURE_MAX_LOD_SGIS 0x813B #define GL_TEXTURE_BASE_LEVEL_SGIS 0x813C #define GL_TEXTURE_MAX_LEVEL_SGIS 0x813D #endif /* GL_SGIS_texture_lod */ #ifndef GL_SGIS_texture_select #define GL_SGIS_texture_select 1 #define GL_DUAL_ALPHA4_SGIS 0x8110 #define GL_DUAL_ALPHA8_SGIS 0x8111 #define GL_DUAL_ALPHA12_SGIS 0x8112 #define GL_DUAL_ALPHA16_SGIS 0x8113 #define GL_DUAL_LUMINANCE4_SGIS 0x8114 #define GL_DUAL_LUMINANCE8_SGIS 0x8115 #define GL_DUAL_LUMINANCE12_SGIS 0x8116 #define GL_DUAL_LUMINANCE16_SGIS 0x8117 #define GL_DUAL_INTENSITY4_SGIS 0x8118 #define GL_DUAL_INTENSITY8_SGIS 0x8119 #define GL_DUAL_INTENSITY12_SGIS 0x811A #define GL_DUAL_INTENSITY16_SGIS 0x811B #define GL_DUAL_LUMINANCE_ALPHA4_SGIS 0x811C #define GL_DUAL_LUMINANCE_ALPHA8_SGIS 0x811D #define GL_QUAD_ALPHA4_SGIS 0x811E #define GL_QUAD_ALPHA8_SGIS 0x811F #define GL_QUAD_LUMINANCE4_SGIS 0x8120 #define GL_QUAD_LUMINANCE8_SGIS 0x8121 #define GL_QUAD_INTENSITY4_SGIS 0x8122 #define GL_QUAD_INTENSITY8_SGIS 0x8123 #define GL_DUAL_TEXTURE_SELECT_SGIS 0x8124 #define GL_QUAD_TEXTURE_SELECT_SGIS 0x8125 #endif /* GL_SGIS_texture_select */ #ifndef GL_SGIX_async #define GL_SGIX_async 1 #define GL_ASYNC_MARKER_SGIX 0x8329 typedef void (APIENTRYP PFNGLASYNCMARKERSGIXPROC) (GLuint marker); typedef GLint (APIENTRYP PFNGLFINISHASYNCSGIXPROC) (GLuint *markerp); typedef GLint (APIENTRYP PFNGLPOLLASYNCSGIXPROC) (GLuint *markerp); typedef GLuint (APIENTRYP PFNGLGENASYNCMARKERSSGIXPROC) (GLsizei range); typedef void (APIENTRYP PFNGLDELETEASYNCMARKERSSGIXPROC) (GLuint marker, GLsizei range); typedef GLboolean (APIENTRYP PFNGLISASYNCMARKERSGIXPROC) (GLuint marker); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glAsyncMarkerSGIX (GLuint marker); GLAPI GLint APIENTRY glFinishAsyncSGIX (GLuint *markerp); GLAPI GLint APIENTRY glPollAsyncSGIX (GLuint *markerp); GLAPI GLuint APIENTRY glGenAsyncMarkersSGIX (GLsizei range); GLAPI void APIENTRY glDeleteAsyncMarkersSGIX (GLuint marker, GLsizei range); GLAPI GLboolean APIENTRY glIsAsyncMarkerSGIX (GLuint marker); #endif #endif /* GL_SGIX_async */ #ifndef GL_SGIX_async_histogram #define GL_SGIX_async_histogram 1 #define GL_ASYNC_HISTOGRAM_SGIX 0x832C #define GL_MAX_ASYNC_HISTOGRAM_SGIX 0x832D #endif /* GL_SGIX_async_histogram */ #ifndef GL_SGIX_async_pixel #define GL_SGIX_async_pixel 1 #define GL_ASYNC_TEX_IMAGE_SGIX 0x835C #define GL_ASYNC_DRAW_PIXELS_SGIX 0x835D #define GL_ASYNC_READ_PIXELS_SGIX 0x835E #define GL_MAX_ASYNC_TEX_IMAGE_SGIX 0x835F #define GL_MAX_ASYNC_DRAW_PIXELS_SGIX 0x8360 #define GL_MAX_ASYNC_READ_PIXELS_SGIX 0x8361 #endif /* GL_SGIX_async_pixel */ #ifndef GL_SGIX_blend_alpha_minmax #define GL_SGIX_blend_alpha_minmax 1 #define GL_ALPHA_MIN_SGIX 0x8320 #define GL_ALPHA_MAX_SGIX 0x8321 #endif /* GL_SGIX_blend_alpha_minmax */ #ifndef GL_SGIX_calligraphic_fragment #define GL_SGIX_calligraphic_fragment 1 #define GL_CALLIGRAPHIC_FRAGMENT_SGIX 0x8183 #endif /* GL_SGIX_calligraphic_fragment */ #ifndef GL_SGIX_clipmap #define GL_SGIX_clipmap 1 #define GL_LINEAR_CLIPMAP_LINEAR_SGIX 0x8170 #define GL_TEXTURE_CLIPMAP_CENTER_SGIX 0x8171 #define GL_TEXTURE_CLIPMAP_FRAME_SGIX 0x8172 #define GL_TEXTURE_CLIPMAP_OFFSET_SGIX 0x8173 #define GL_TEXTURE_CLIPMAP_VIRTUAL_DEPTH_SGIX 0x8174 #define GL_TEXTURE_CLIPMAP_LOD_OFFSET_SGIX 0x8175 #define GL_TEXTURE_CLIPMAP_DEPTH_SGIX 0x8176 #define GL_MAX_CLIPMAP_DEPTH_SGIX 0x8177 #define GL_MAX_CLIPMAP_VIRTUAL_DEPTH_SGIX 0x8178 #define GL_NEAREST_CLIPMAP_NEAREST_SGIX 0x844D #define GL_NEAREST_CLIPMAP_LINEAR_SGIX 0x844E #define GL_LINEAR_CLIPMAP_NEAREST_SGIX 0x844F #endif /* GL_SGIX_clipmap */ #ifndef GL_SGIX_convolution_accuracy #define GL_SGIX_convolution_accuracy 1 #define GL_CONVOLUTION_HINT_SGIX 0x8316 #endif /* GL_SGIX_convolution_accuracy */ #ifndef GL_SGIX_depth_pass_instrument #define GL_SGIX_depth_pass_instrument 1 #endif /* GL_SGIX_depth_pass_instrument */ #ifndef GL_SGIX_depth_texture #define GL_SGIX_depth_texture 1 #define GL_DEPTH_COMPONENT16_SGIX 0x81A5 #define GL_DEPTH_COMPONENT24_SGIX 0x81A6 #define GL_DEPTH_COMPONENT32_SGIX 0x81A7 #endif /* GL_SGIX_depth_texture */ #ifndef GL_SGIX_flush_raster #define GL_SGIX_flush_raster 1 typedef void (APIENTRYP PFNGLFLUSHRASTERSGIXPROC) (void); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glFlushRasterSGIX (void); #endif #endif /* GL_SGIX_flush_raster */ #ifndef GL_SGIX_fog_offset #define GL_SGIX_fog_offset 1 #define GL_FOG_OFFSET_SGIX 0x8198 #define GL_FOG_OFFSET_VALUE_SGIX 0x8199 #endif /* GL_SGIX_fog_offset */ #ifndef GL_SGIX_fragment_lighting #define GL_SGIX_fragment_lighting 1 #define GL_FRAGMENT_LIGHTING_SGIX 0x8400 #define GL_FRAGMENT_COLOR_MATERIAL_SGIX 0x8401 #define GL_FRAGMENT_COLOR_MATERIAL_FACE_SGIX 0x8402 #define GL_FRAGMENT_COLOR_MATERIAL_PARAMETER_SGIX 0x8403 #define GL_MAX_FRAGMENT_LIGHTS_SGIX 0x8404 #define GL_MAX_ACTIVE_LIGHTS_SGIX 0x8405 #define GL_CURRENT_RASTER_NORMAL_SGIX 0x8406 #define GL_LIGHT_ENV_MODE_SGIX 0x8407 #define GL_FRAGMENT_LIGHT_MODEL_LOCAL_VIEWER_SGIX 0x8408 #define GL_FRAGMENT_LIGHT_MODEL_TWO_SIDE_SGIX 0x8409 #define GL_FRAGMENT_LIGHT_MODEL_AMBIENT_SGIX 0x840A #define GL_FRAGMENT_LIGHT_MODEL_NORMAL_INTERPOLATION_SGIX 0x840B #define GL_FRAGMENT_LIGHT0_SGIX 0x840C #define GL_FRAGMENT_LIGHT1_SGIX 0x840D #define GL_FRAGMENT_LIGHT2_SGIX 0x840E #define GL_FRAGMENT_LIGHT3_SGIX 0x840F #define GL_FRAGMENT_LIGHT4_SGIX 0x8410 #define GL_FRAGMENT_LIGHT5_SGIX 0x8411 #define GL_FRAGMENT_LIGHT6_SGIX 0x8412 #define GL_FRAGMENT_LIGHT7_SGIX 0x8413 typedef void (APIENTRYP PFNGLFRAGMENTCOLORMATERIALSGIXPROC) (GLenum face, GLenum mode); typedef void (APIENTRYP PFNGLFRAGMENTLIGHTFSGIXPROC) (GLenum light, GLenum pname, GLfloat param); typedef void (APIENTRYP PFNGLFRAGMENTLIGHTFVSGIXPROC) (GLenum light, GLenum pname, const GLfloat *params); typedef void (APIENTRYP PFNGLFRAGMENTLIGHTISGIXPROC) (GLenum light, GLenum pname, GLint param); typedef void (APIENTRYP PFNGLFRAGMENTLIGHTIVSGIXPROC) (GLenum light, GLenum pname, const GLint *params); typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELFSGIXPROC) (GLenum pname, GLfloat param); typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELFVSGIXPROC) (GLenum pname, const GLfloat *params); typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELISGIXPROC) (GLenum pname, GLint param); typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELIVSGIXPROC) (GLenum pname, const GLint *params); typedef void (APIENTRYP PFNGLFRAGMENTMATERIALFSGIXPROC) (GLenum face, GLenum pname, GLfloat param); typedef void (APIENTRYP PFNGLFRAGMENTMATERIALFVSGIXPROC) (GLenum face, GLenum pname, const GLfloat *params); typedef void (APIENTRYP PFNGLFRAGMENTMATERIALISGIXPROC) (GLenum face, GLenum pname, GLint param); typedef void (APIENTRYP PFNGLFRAGMENTMATERIALIVSGIXPROC) (GLenum face, GLenum pname, const GLint *params); typedef void (APIENTRYP PFNGLGETFRAGMENTLIGHTFVSGIXPROC) (GLenum light, GLenum pname, GLfloat *params); typedef void (APIENTRYP PFNGLGETFRAGMENTLIGHTIVSGIXPROC) (GLenum light, GLenum pname, GLint *params); typedef void (APIENTRYP PFNGLGETFRAGMENTMATERIALFVSGIXPROC) (GLenum face, GLenum pname, GLfloat *params); typedef void (APIENTRYP PFNGLGETFRAGMENTMATERIALIVSGIXPROC) (GLenum face, GLenum pname, GLint *params); typedef void (APIENTRYP PFNGLLIGHTENVISGIXPROC) (GLenum pname, GLint param); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glFragmentColorMaterialSGIX (GLenum face, GLenum mode); GLAPI void APIENTRY glFragmentLightfSGIX (GLenum light, GLenum pname, GLfloat param); GLAPI void APIENTRY glFragmentLightfvSGIX (GLenum light, GLenum pname, const GLfloat *params); GLAPI void APIENTRY glFragmentLightiSGIX (GLenum light, GLenum pname, GLint param); GLAPI void APIENTRY glFragmentLightivSGIX (GLenum light, GLenum pname, const GLint *params); GLAPI void APIENTRY glFragmentLightModelfSGIX (GLenum pname, GLfloat param); GLAPI void APIENTRY glFragmentLightModelfvSGIX (GLenum pname, const GLfloat *params); GLAPI void APIENTRY glFragmentLightModeliSGIX (GLenum pname, GLint param); GLAPI void APIENTRY glFragmentLightModelivSGIX (GLenum pname, const GLint *params); GLAPI void APIENTRY glFragmentMaterialfSGIX (GLenum face, GLenum pname, GLfloat param); GLAPI void APIENTRY glFragmentMaterialfvSGIX (GLenum face, GLenum pname, const GLfloat *params); GLAPI void APIENTRY glFragmentMaterialiSGIX (GLenum face, GLenum pname, GLint param); GLAPI void APIENTRY glFragmentMaterialivSGIX (GLenum face, GLenum pname, const GLint *params); GLAPI void APIENTRY glGetFragmentLightfvSGIX (GLenum light, GLenum pname, GLfloat *params); GLAPI void APIENTRY glGetFragmentLightivSGIX (GLenum light, GLenum pname, GLint *params); GLAPI void APIENTRY glGetFragmentMaterialfvSGIX (GLenum face, GLenum pname, GLfloat *params); GLAPI void APIENTRY glGetFragmentMaterialivSGIX (GLenum face, GLenum pname, GLint *params); GLAPI void APIENTRY glLightEnviSGIX (GLenum pname, GLint param); #endif #endif /* GL_SGIX_fragment_lighting */ #ifndef GL_SGIX_framezoom #define GL_SGIX_framezoom 1 #define GL_FRAMEZOOM_SGIX 0x818B #define GL_FRAMEZOOM_FACTOR_SGIX 0x818C #define GL_MAX_FRAMEZOOM_FACTOR_SGIX 0x818D typedef void (APIENTRYP PFNGLFRAMEZOOMSGIXPROC) (GLint factor); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glFrameZoomSGIX (GLint factor); #endif #endif /* GL_SGIX_framezoom */ #ifndef GL_SGIX_igloo_interface #define GL_SGIX_igloo_interface 1 typedef void (APIENTRYP PFNGLIGLOOINTERFACESGIXPROC) (GLenum pname, const void *params); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glIglooInterfaceSGIX (GLenum pname, const void *params); #endif #endif /* GL_SGIX_igloo_interface */ #ifndef GL_SGIX_instruments #define GL_SGIX_instruments 1 #define GL_INSTRUMENT_BUFFER_POINTER_SGIX 0x8180 #define GL_INSTRUMENT_MEASUREMENTS_SGIX 0x8181 typedef GLint (APIENTRYP PFNGLGETINSTRUMENTSSGIXPROC) (void); typedef void (APIENTRYP PFNGLINSTRUMENTSBUFFERSGIXPROC) (GLsizei size, GLint *buffer); typedef GLint (APIENTRYP PFNGLPOLLINSTRUMENTSSGIXPROC) (GLint *marker_p); typedef void (APIENTRYP PFNGLREADINSTRUMENTSSGIXPROC) (GLint marker); typedef void (APIENTRYP PFNGLSTARTINSTRUMENTSSGIXPROC) (void); typedef void (APIENTRYP PFNGLSTOPINSTRUMENTSSGIXPROC) (GLint marker); #ifdef GL_GLEXT_PROTOTYPES GLAPI GLint APIENTRY glGetInstrumentsSGIX (void); GLAPI void APIENTRY glInstrumentsBufferSGIX (GLsizei size, GLint *buffer); GLAPI GLint APIENTRY glPollInstrumentsSGIX (GLint *marker_p); GLAPI void APIENTRY glReadInstrumentsSGIX (GLint marker); GLAPI void APIENTRY glStartInstrumentsSGIX (void); GLAPI void APIENTRY glStopInstrumentsSGIX (GLint marker); #endif #endif /* GL_SGIX_instruments */ #ifndef GL_SGIX_interlace #define GL_SGIX_interlace 1 #define GL_INTERLACE_SGIX 0x8094 #endif /* GL_SGIX_interlace */ #ifndef GL_SGIX_ir_instrument1 #define GL_SGIX_ir_instrument1 1 #define GL_IR_INSTRUMENT1_SGIX 0x817F #endif /* GL_SGIX_ir_instrument1 */ #ifndef GL_SGIX_list_priority #define GL_SGIX_list_priority 1 #define GL_LIST_PRIORITY_SGIX 0x8182 typedef void (APIENTRYP PFNGLGETLISTPARAMETERFVSGIXPROC) (GLuint list, GLenum pname, GLfloat *params); typedef void (APIENTRYP PFNGLGETLISTPARAMETERIVSGIXPROC) (GLuint list, GLenum pname, GLint *params); typedef void (APIENTRYP PFNGLLISTPARAMETERFSGIXPROC) (GLuint list, GLenum pname, GLfloat param); typedef void (APIENTRYP PFNGLLISTPARAMETERFVSGIXPROC) (GLuint list, GLenum pname, const GLfloat *params); typedef void (APIENTRYP PFNGLLISTPARAMETERISGIXPROC) (GLuint list, GLenum pname, GLint param); typedef void (APIENTRYP PFNGLLISTPARAMETERIVSGIXPROC) (GLuint list, GLenum pname, const GLint *params); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glGetListParameterfvSGIX (GLuint list, GLenum pname, GLfloat *params); GLAPI void APIENTRY glGetListParameterivSGIX (GLuint list, GLenum pname, GLint *params); GLAPI void APIENTRY glListParameterfSGIX (GLuint list, GLenum pname, GLfloat param); GLAPI void APIENTRY glListParameterfvSGIX (GLuint list, GLenum pname, const GLfloat *params); GLAPI void APIENTRY glListParameteriSGIX (GLuint list, GLenum pname, GLint param); GLAPI void APIENTRY glListParameterivSGIX (GLuint list, GLenum pname, const GLint *params); #endif #endif /* GL_SGIX_list_priority */ #ifndef GL_SGIX_pixel_texture #define GL_SGIX_pixel_texture 1 #define GL_PIXEL_TEX_GEN_SGIX 0x8139 #define GL_PIXEL_TEX_GEN_MODE_SGIX 0x832B typedef void (APIENTRYP PFNGLPIXELTEXGENSGIXPROC) (GLenum mode); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glPixelTexGenSGIX (GLenum mode); #endif #endif /* GL_SGIX_pixel_texture */ #ifndef GL_SGIX_pixel_tiles #define GL_SGIX_pixel_tiles 1 #define GL_PIXEL_TILE_BEST_ALIGNMENT_SGIX 0x813E #define GL_PIXEL_TILE_CACHE_INCREMENT_SGIX 0x813F #define GL_PIXEL_TILE_WIDTH_SGIX 0x8140 #define GL_PIXEL_TILE_HEIGHT_SGIX 0x8141 #define GL_PIXEL_TILE_GRID_WIDTH_SGIX 0x8142 #define GL_PIXEL_TILE_GRID_HEIGHT_SGIX 0x8143 #define GL_PIXEL_TILE_GRID_DEPTH_SGIX 0x8144 #define GL_PIXEL_TILE_CACHE_SIZE_SGIX 0x8145 #endif /* GL_SGIX_pixel_tiles */ #ifndef GL_SGIX_polynomial_ffd #define GL_SGIX_polynomial_ffd 1 #define GL_TEXTURE_DEFORMATION_BIT_SGIX 0x00000001 #define GL_GEOMETRY_DEFORMATION_BIT_SGIX 0x00000002 #define GL_GEOMETRY_DEFORMATION_SGIX 0x8194 #define GL_TEXTURE_DEFORMATION_SGIX 0x8195 #define GL_DEFORMATIONS_MASK_SGIX 0x8196 #define GL_MAX_DEFORMATION_ORDER_SGIX 0x8197 typedef void (APIENTRYP PFNGLDEFORMATIONMAP3DSGIXPROC) (GLenum target, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, GLdouble w1, GLdouble w2, GLint wstride, GLint worder, const GLdouble *points); typedef void (APIENTRYP PFNGLDEFORMATIONMAP3FSGIXPROC) (GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, GLfloat w1, GLfloat w2, GLint wstride, GLint worder, const GLfloat *points); typedef void (APIENTRYP PFNGLDEFORMSGIXPROC) (GLbitfield mask); typedef void (APIENTRYP PFNGLLOADIDENTITYDEFORMATIONMAPSGIXPROC) (GLbitfield mask); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glDeformationMap3dSGIX (GLenum target, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, GLdouble w1, GLdouble w2, GLint wstride, GLint worder, const GLdouble *points); GLAPI void APIENTRY glDeformationMap3fSGIX (GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, GLfloat w1, GLfloat w2, GLint wstride, GLint worder, const GLfloat *points); GLAPI void APIENTRY glDeformSGIX (GLbitfield mask); GLAPI void APIENTRY glLoadIdentityDeformationMapSGIX (GLbitfield mask); #endif #endif /* GL_SGIX_polynomial_ffd */ #ifndef GL_SGIX_reference_plane #define GL_SGIX_reference_plane 1 #define GL_REFERENCE_PLANE_SGIX 0x817D #define GL_REFERENCE_PLANE_EQUATION_SGIX 0x817E typedef void (APIENTRYP PFNGLREFERENCEPLANESGIXPROC) (const GLdouble *equation); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glReferencePlaneSGIX (const GLdouble *equation); #endif #endif /* GL_SGIX_reference_plane */ #ifndef GL_SGIX_resample #define GL_SGIX_resample 1 #define GL_PACK_RESAMPLE_SGIX 0x842E #define GL_UNPACK_RESAMPLE_SGIX 0x842F #define GL_RESAMPLE_REPLICATE_SGIX 0x8433 #define GL_RESAMPLE_ZERO_FILL_SGIX 0x8434 #define GL_RESAMPLE_DECIMATE_SGIX 0x8430 #endif /* GL_SGIX_resample */ #ifndef GL_SGIX_scalebias_hint #define GL_SGIX_scalebias_hint 1 #define GL_SCALEBIAS_HINT_SGIX 0x8322 #endif /* GL_SGIX_scalebias_hint */ #ifndef GL_SGIX_shadow #define GL_SGIX_shadow 1 #define GL_TEXTURE_COMPARE_SGIX 0x819A #define GL_TEXTURE_COMPARE_OPERATOR_SGIX 0x819B #define GL_TEXTURE_LEQUAL_R_SGIX 0x819C #define GL_TEXTURE_GEQUAL_R_SGIX 0x819D #endif /* GL_SGIX_shadow */ #ifndef GL_SGIX_shadow_ambient #define GL_SGIX_shadow_ambient 1 #define GL_SHADOW_AMBIENT_SGIX 0x80BF #endif /* GL_SGIX_shadow_ambient */ #ifndef GL_SGIX_sprite #define GL_SGIX_sprite 1 #define GL_SPRITE_SGIX 0x8148 #define GL_SPRITE_MODE_SGIX 0x8149 #define GL_SPRITE_AXIS_SGIX 0x814A #define GL_SPRITE_TRANSLATION_SGIX 0x814B #define GL_SPRITE_AXIAL_SGIX 0x814C #define GL_SPRITE_OBJECT_ALIGNED_SGIX 0x814D #define GL_SPRITE_EYE_ALIGNED_SGIX 0x814E typedef void (APIENTRYP PFNGLSPRITEPARAMETERFSGIXPROC) (GLenum pname, GLfloat param); typedef void (APIENTRYP PFNGLSPRITEPARAMETERFVSGIXPROC) (GLenum pname, const GLfloat *params); typedef void (APIENTRYP PFNGLSPRITEPARAMETERISGIXPROC) (GLenum pname, GLint param); typedef void (APIENTRYP PFNGLSPRITEPARAMETERIVSGIXPROC) (GLenum pname, const GLint *params); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glSpriteParameterfSGIX (GLenum pname, GLfloat param); GLAPI void APIENTRY glSpriteParameterfvSGIX (GLenum pname, const GLfloat *params); GLAPI void APIENTRY glSpriteParameteriSGIX (GLenum pname, GLint param); GLAPI void APIENTRY glSpriteParameterivSGIX (GLenum pname, const GLint *params); #endif #endif /* GL_SGIX_sprite */ #ifndef GL_SGIX_subsample #define GL_SGIX_subsample 1 #define GL_PACK_SUBSAMPLE_RATE_SGIX 0x85A0 #define GL_UNPACK_SUBSAMPLE_RATE_SGIX 0x85A1 #define GL_PIXEL_SUBSAMPLE_4444_SGIX 0x85A2 #define GL_PIXEL_SUBSAMPLE_2424_SGIX 0x85A3 #define GL_PIXEL_SUBSAMPLE_4242_SGIX 0x85A4 #endif /* GL_SGIX_subsample */ #ifndef GL_SGIX_tag_sample_buffer #define GL_SGIX_tag_sample_buffer 1 typedef void (APIENTRYP PFNGLTAGSAMPLEBUFFERSGIXPROC) (void); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glTagSampleBufferSGIX (void); #endif #endif /* GL_SGIX_tag_sample_buffer */ #ifndef GL_SGIX_texture_add_env #define GL_SGIX_texture_add_env 1 #define GL_TEXTURE_ENV_BIAS_SGIX 0x80BE #endif /* GL_SGIX_texture_add_env */ #ifndef GL_SGIX_texture_coordinate_clamp #define GL_SGIX_texture_coordinate_clamp 1 #define GL_TEXTURE_MAX_CLAMP_S_SGIX 0x8369 #define GL_TEXTURE_MAX_CLAMP_T_SGIX 0x836A #define GL_TEXTURE_MAX_CLAMP_R_SGIX 0x836B #endif /* GL_SGIX_texture_coordinate_clamp */ #ifndef GL_SGIX_texture_lod_bias #define GL_SGIX_texture_lod_bias 1 #define GL_TEXTURE_LOD_BIAS_S_SGIX 0x818E #define GL_TEXTURE_LOD_BIAS_T_SGIX 0x818F #define GL_TEXTURE_LOD_BIAS_R_SGIX 0x8190 #endif /* GL_SGIX_texture_lod_bias */ #ifndef GL_SGIX_texture_multi_buffer #define GL_SGIX_texture_multi_buffer 1 #define GL_TEXTURE_MULTI_BUFFER_HINT_SGIX 0x812E #endif /* GL_SGIX_texture_multi_buffer */ #ifndef GL_SGIX_texture_scale_bias #define GL_SGIX_texture_scale_bias 1 #define GL_POST_TEXTURE_FILTER_BIAS_SGIX 0x8179 #define GL_POST_TEXTURE_FILTER_SCALE_SGIX 0x817A #define GL_POST_TEXTURE_FILTER_BIAS_RANGE_SGIX 0x817B #define GL_POST_TEXTURE_FILTER_SCALE_RANGE_SGIX 0x817C #endif /* GL_SGIX_texture_scale_bias */ #ifndef GL_SGIX_vertex_preclip #define GL_SGIX_vertex_preclip 1 #define GL_VERTEX_PRECLIP_SGIX 0x83EE #define GL_VERTEX_PRECLIP_HINT_SGIX 0x83EF #endif /* GL_SGIX_vertex_preclip */ #ifndef GL_SGIX_ycrcb #define GL_SGIX_ycrcb 1 #define GL_YCRCB_422_SGIX 0x81BB #define GL_YCRCB_444_SGIX 0x81BC #endif /* GL_SGIX_ycrcb */ #ifndef GL_SGIX_ycrcb_subsample #define GL_SGIX_ycrcb_subsample 1 #endif /* GL_SGIX_ycrcb_subsample */ #ifndef GL_SGIX_ycrcba #define GL_SGIX_ycrcba 1 #define GL_YCRCB_SGIX 0x8318 #define GL_YCRCBA_SGIX 0x8319 #endif /* GL_SGIX_ycrcba */ #ifndef GL_SGI_color_matrix #define GL_SGI_color_matrix 1 #define GL_COLOR_MATRIX_SGI 0x80B1 #define GL_COLOR_MATRIX_STACK_DEPTH_SGI 0x80B2 #define GL_MAX_COLOR_MATRIX_STACK_DEPTH_SGI 0x80B3 #define GL_POST_COLOR_MATRIX_RED_SCALE_SGI 0x80B4 #define GL_POST_COLOR_MATRIX_GREEN_SCALE_SGI 0x80B5 #define GL_POST_COLOR_MATRIX_BLUE_SCALE_SGI 0x80B6 #define GL_POST_COLOR_MATRIX_ALPHA_SCALE_SGI 0x80B7 #define GL_POST_COLOR_MATRIX_RED_BIAS_SGI 0x80B8 #define GL_POST_COLOR_MATRIX_GREEN_BIAS_SGI 0x80B9 #define GL_POST_COLOR_MATRIX_BLUE_BIAS_SGI 0x80BA #define GL_POST_COLOR_MATRIX_ALPHA_BIAS_SGI 0x80BB #endif /* GL_SGI_color_matrix */ #ifndef GL_SGI_color_table #define GL_SGI_color_table 1 #define GL_COLOR_TABLE_SGI 0x80D0 #define GL_POST_CONVOLUTION_COLOR_TABLE_SGI 0x80D1 #define GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI 0x80D2 #define GL_PROXY_COLOR_TABLE_SGI 0x80D3 #define GL_PROXY_POST_CONVOLUTION_COLOR_TABLE_SGI 0x80D4 #define GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE_SGI 0x80D5 #define GL_COLOR_TABLE_SCALE_SGI 0x80D6 #define GL_COLOR_TABLE_BIAS_SGI 0x80D7 #define GL_COLOR_TABLE_FORMAT_SGI 0x80D8 #define GL_COLOR_TABLE_WIDTH_SGI 0x80D9 #define GL_COLOR_TABLE_RED_SIZE_SGI 0x80DA #define GL_COLOR_TABLE_GREEN_SIZE_SGI 0x80DB #define GL_COLOR_TABLE_BLUE_SIZE_SGI 0x80DC #define GL_COLOR_TABLE_ALPHA_SIZE_SGI 0x80DD #define GL_COLOR_TABLE_LUMINANCE_SIZE_SGI 0x80DE #define GL_COLOR_TABLE_INTENSITY_SIZE_SGI 0x80DF typedef void (APIENTRYP PFNGLCOLORTABLESGIPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const void *table); typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERFVSGIPROC) (GLenum target, GLenum pname, const GLfloat *params); typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERIVSGIPROC) (GLenum target, GLenum pname, const GLint *params); typedef void (APIENTRYP PFNGLCOPYCOLORTABLESGIPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); typedef void (APIENTRYP PFNGLGETCOLORTABLESGIPROC) (GLenum target, GLenum format, GLenum type, void *table); typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERFVSGIPROC) (GLenum target, GLenum pname, GLfloat *params); typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERIVSGIPROC) (GLenum target, GLenum pname, GLint *params); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glColorTableSGI (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const void *table); GLAPI void APIENTRY glColorTableParameterfvSGI (GLenum target, GLenum pname, const GLfloat *params); GLAPI void APIENTRY glColorTableParameterivSGI (GLenum target, GLenum pname, const GLint *params); GLAPI void APIENTRY glCopyColorTableSGI (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); GLAPI void APIENTRY glGetColorTableSGI (GLenum target, GLenum format, GLenum type, void *table); GLAPI void APIENTRY glGetColorTableParameterfvSGI (GLenum target, GLenum pname, GLfloat *params); GLAPI void APIENTRY glGetColorTableParameterivSGI (GLenum target, GLenum pname, GLint *params); #endif #endif /* GL_SGI_color_table */ #ifndef GL_SGI_texture_color_table #define GL_SGI_texture_color_table 1 #define GL_TEXTURE_COLOR_TABLE_SGI 0x80BC #define GL_PROXY_TEXTURE_COLOR_TABLE_SGI 0x80BD #endif /* GL_SGI_texture_color_table */ #ifndef GL_SUNX_constant_data #define GL_SUNX_constant_data 1 #define GL_UNPACK_CONSTANT_DATA_SUNX 0x81D5 #define GL_TEXTURE_CONSTANT_DATA_SUNX 0x81D6 typedef void (APIENTRYP PFNGLFINISHTEXTURESUNXPROC) (void); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glFinishTextureSUNX (void); #endif #endif /* GL_SUNX_constant_data */ #ifndef GL_SUN_convolution_border_modes #define GL_SUN_convolution_border_modes 1 #define GL_WRAP_BORDER_SUN 0x81D4 #endif /* GL_SUN_convolution_border_modes */ #ifndef GL_SUN_global_alpha #define GL_SUN_global_alpha 1 #define GL_GLOBAL_ALPHA_SUN 0x81D9 #define GL_GLOBAL_ALPHA_FACTOR_SUN 0x81DA typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORBSUNPROC) (GLbyte factor); typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORSSUNPROC) (GLshort factor); typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORISUNPROC) (GLint factor); typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORFSUNPROC) (GLfloat factor); typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORDSUNPROC) (GLdouble factor); typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORUBSUNPROC) (GLubyte factor); typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORUSSUNPROC) (GLushort factor); typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORUISUNPROC) (GLuint factor); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glGlobalAlphaFactorbSUN (GLbyte factor); GLAPI void APIENTRY glGlobalAlphaFactorsSUN (GLshort factor); GLAPI void APIENTRY glGlobalAlphaFactoriSUN (GLint factor); GLAPI void APIENTRY glGlobalAlphaFactorfSUN (GLfloat factor); GLAPI void APIENTRY glGlobalAlphaFactordSUN (GLdouble factor); GLAPI void APIENTRY glGlobalAlphaFactorubSUN (GLubyte factor); GLAPI void APIENTRY glGlobalAlphaFactorusSUN (GLushort factor); GLAPI void APIENTRY glGlobalAlphaFactoruiSUN (GLuint factor); #endif #endif /* GL_SUN_global_alpha */ #ifndef GL_SUN_mesh_array #define GL_SUN_mesh_array 1 #define GL_QUAD_MESH_SUN 0x8614 #define GL_TRIANGLE_MESH_SUN 0x8615 typedef void (APIENTRYP PFNGLDRAWMESHARRAYSSUNPROC) (GLenum mode, GLint first, GLsizei count, GLsizei width); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glDrawMeshArraysSUN (GLenum mode, GLint first, GLsizei count, GLsizei width); #endif #endif /* GL_SUN_mesh_array */ #ifndef GL_SUN_slice_accum #define GL_SUN_slice_accum 1 #define GL_SLICE_ACCUM_SUN 0x85CC #endif /* GL_SUN_slice_accum */ #ifndef GL_SUN_triangle_list #define GL_SUN_triangle_list 1 #define GL_RESTART_SUN 0x0001 #define GL_REPLACE_MIDDLE_SUN 0x0002 #define GL_REPLACE_OLDEST_SUN 0x0003 #define GL_TRIANGLE_LIST_SUN 0x81D7 #define GL_REPLACEMENT_CODE_SUN 0x81D8 #define GL_REPLACEMENT_CODE_ARRAY_SUN 0x85C0 #define GL_REPLACEMENT_CODE_ARRAY_TYPE_SUN 0x85C1 #define GL_REPLACEMENT_CODE_ARRAY_STRIDE_SUN 0x85C2 #define GL_REPLACEMENT_CODE_ARRAY_POINTER_SUN 0x85C3 #define GL_R1UI_V3F_SUN 0x85C4 #define GL_R1UI_C4UB_V3F_SUN 0x85C5 #define GL_R1UI_C3F_V3F_SUN 0x85C6 #define GL_R1UI_N3F_V3F_SUN 0x85C7 #define GL_R1UI_C4F_N3F_V3F_SUN 0x85C8 #define GL_R1UI_T2F_V3F_SUN 0x85C9 #define GL_R1UI_T2F_N3F_V3F_SUN 0x85CA #define GL_R1UI_T2F_C4F_N3F_V3F_SUN 0x85CB typedef void (APIENTRYP PFNGLREPLACEMENTCODEUISUNPROC) (GLuint code); typedef void (APIENTRYP PFNGLREPLACEMENTCODEUSSUNPROC) (GLushort code); typedef void (APIENTRYP PFNGLREPLACEMENTCODEUBSUNPROC) (GLubyte code); typedef void (APIENTRYP PFNGLREPLACEMENTCODEUIVSUNPROC) (const GLuint *code); typedef void (APIENTRYP PFNGLREPLACEMENTCODEUSVSUNPROC) (const GLushort *code); typedef void (APIENTRYP PFNGLREPLACEMENTCODEUBVSUNPROC) (const GLubyte *code); typedef void (APIENTRYP PFNGLREPLACEMENTCODEPOINTERSUNPROC) (GLenum type, GLsizei stride, const void **pointer); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glReplacementCodeuiSUN (GLuint code); GLAPI void APIENTRY glReplacementCodeusSUN (GLushort code); GLAPI void APIENTRY glReplacementCodeubSUN (GLubyte code); GLAPI void APIENTRY glReplacementCodeuivSUN (const GLuint *code); GLAPI void APIENTRY glReplacementCodeusvSUN (const GLushort *code); GLAPI void APIENTRY glReplacementCodeubvSUN (const GLubyte *code); GLAPI void APIENTRY glReplacementCodePointerSUN (GLenum type, GLsizei stride, const void **pointer); #endif #endif /* GL_SUN_triangle_list */ #ifndef GL_SUN_vertex #define GL_SUN_vertex 1 typedef void (APIENTRYP PFNGLCOLOR4UBVERTEX2FSUNPROC) (GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y); typedef void (APIENTRYP PFNGLCOLOR4UBVERTEX2FVSUNPROC) (const GLubyte *c, const GLfloat *v); typedef void (APIENTRYP PFNGLCOLOR4UBVERTEX3FSUNPROC) (GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); typedef void (APIENTRYP PFNGLCOLOR4UBVERTEX3FVSUNPROC) (const GLubyte *c, const GLfloat *v); typedef void (APIENTRYP PFNGLCOLOR3FVERTEX3FSUNPROC) (GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); typedef void (APIENTRYP PFNGLCOLOR3FVERTEX3FVSUNPROC) (const GLfloat *c, const GLfloat *v); typedef void (APIENTRYP PFNGLNORMAL3FVERTEX3FSUNPROC) (GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); typedef void (APIENTRYP PFNGLNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *n, const GLfloat *v); typedef void (APIENTRYP PFNGLCOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); typedef void (APIENTRYP PFNGLCOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *c, const GLfloat *n, const GLfloat *v); typedef void (APIENTRYP PFNGLTEXCOORD2FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat x, GLfloat y, GLfloat z); typedef void (APIENTRYP PFNGLTEXCOORD2FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *v); typedef void (APIENTRYP PFNGLTEXCOORD4FVERTEX4FSUNPROC) (GLfloat s, GLfloat t, GLfloat p, GLfloat q, GLfloat x, GLfloat y, GLfloat z, GLfloat w); typedef void (APIENTRYP PFNGLTEXCOORD4FVERTEX4FVSUNPROC) (const GLfloat *tc, const GLfloat *v); typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4UBVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4UBVERTEX3FVSUNPROC) (const GLfloat *tc, const GLubyte *c, const GLfloat *v); typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR3FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR3FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *c, const GLfloat *v); typedef void (APIENTRYP PFNGLTEXCOORD2FNORMAL3FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); typedef void (APIENTRYP PFNGLTEXCOORD2FNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *n, const GLfloat *v); typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); typedef void (APIENTRYP PFNGLTEXCOORD4FCOLOR4FNORMAL3FVERTEX4FSUNPROC) (GLfloat s, GLfloat t, GLfloat p, GLfloat q, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z, GLfloat w); typedef void (APIENTRYP PFNGLTEXCOORD4FCOLOR4FNORMAL3FVERTEX4FVSUNPROC) (const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); typedef void (APIENTRYP PFNGLREPLACEMENTCODEUIVERTEX3FSUNPROC) (GLuint rc, GLfloat x, GLfloat y, GLfloat z); typedef void (APIENTRYP PFNGLREPLACEMENTCODEUIVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *v); typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4UBVERTEX3FSUNPROC) (GLuint rc, GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4UBVERTEX3FVSUNPROC) (const GLuint *rc, const GLubyte *c, const GLfloat *v); typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR3FVERTEX3FSUNPROC) (GLuint rc, GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *c, const GLfloat *v); typedef void (APIENTRYP PFNGLREPLACEMENTCODEUINORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); typedef void (APIENTRYP PFNGLREPLACEMENTCODEUINORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *n, const GLfloat *v); typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *c, const GLfloat *n, const GLfloat *v); typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FVERTEX3FSUNPROC) (GLuint rc, GLfloat s, GLfloat t, GLfloat x, GLfloat y, GLfloat z); typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *tc, const GLfloat *v); typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FNORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat s, GLfloat t, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FNORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *tc, const GLfloat *n, const GLfloat *v); typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FCOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FCOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glColor4ubVertex2fSUN (GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y); GLAPI void APIENTRY glColor4ubVertex2fvSUN (const GLubyte *c, const GLfloat *v); GLAPI void APIENTRY glColor4ubVertex3fSUN (GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); GLAPI void APIENTRY glColor4ubVertex3fvSUN (const GLubyte *c, const GLfloat *v); GLAPI void APIENTRY glColor3fVertex3fSUN (GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); GLAPI void APIENTRY glColor3fVertex3fvSUN (const GLfloat *c, const GLfloat *v); GLAPI void APIENTRY glNormal3fVertex3fSUN (GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); GLAPI void APIENTRY glNormal3fVertex3fvSUN (const GLfloat *n, const GLfloat *v); GLAPI void APIENTRY glColor4fNormal3fVertex3fSUN (GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); GLAPI void APIENTRY glColor4fNormal3fVertex3fvSUN (const GLfloat *c, const GLfloat *n, const GLfloat *v); GLAPI void APIENTRY glTexCoord2fVertex3fSUN (GLfloat s, GLfloat t, GLfloat x, GLfloat y, GLfloat z); GLAPI void APIENTRY glTexCoord2fVertex3fvSUN (const GLfloat *tc, const GLfloat *v); GLAPI void APIENTRY glTexCoord4fVertex4fSUN (GLfloat s, GLfloat t, GLfloat p, GLfloat q, GLfloat x, GLfloat y, GLfloat z, GLfloat w); GLAPI void APIENTRY glTexCoord4fVertex4fvSUN (const GLfloat *tc, const GLfloat *v); GLAPI void APIENTRY glTexCoord2fColor4ubVertex3fSUN (GLfloat s, GLfloat t, GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); GLAPI void APIENTRY glTexCoord2fColor4ubVertex3fvSUN (const GLfloat *tc, const GLubyte *c, const GLfloat *v); GLAPI void APIENTRY glTexCoord2fColor3fVertex3fSUN (GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); GLAPI void APIENTRY glTexCoord2fColor3fVertex3fvSUN (const GLfloat *tc, const GLfloat *c, const GLfloat *v); GLAPI void APIENTRY glTexCoord2fNormal3fVertex3fSUN (GLfloat s, GLfloat t, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); GLAPI void APIENTRY glTexCoord2fNormal3fVertex3fvSUN (const GLfloat *tc, const GLfloat *n, const GLfloat *v); GLAPI void APIENTRY glTexCoord2fColor4fNormal3fVertex3fSUN (GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); GLAPI void APIENTRY glTexCoord2fColor4fNormal3fVertex3fvSUN (const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); GLAPI void APIENTRY glTexCoord4fColor4fNormal3fVertex4fSUN (GLfloat s, GLfloat t, GLfloat p, GLfloat q, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z, GLfloat w); GLAPI void APIENTRY glTexCoord4fColor4fNormal3fVertex4fvSUN (const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); GLAPI void APIENTRY glReplacementCodeuiVertex3fSUN (GLuint rc, GLfloat x, GLfloat y, GLfloat z); GLAPI void APIENTRY glReplacementCodeuiVertex3fvSUN (const GLuint *rc, const GLfloat *v); GLAPI void APIENTRY glReplacementCodeuiColor4ubVertex3fSUN (GLuint rc, GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); GLAPI void APIENTRY glReplacementCodeuiColor4ubVertex3fvSUN (const GLuint *rc, const GLubyte *c, const GLfloat *v); GLAPI void APIENTRY glReplacementCodeuiColor3fVertex3fSUN (GLuint rc, GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); GLAPI void APIENTRY glReplacementCodeuiColor3fVertex3fvSUN (const GLuint *rc, const GLfloat *c, const GLfloat *v); GLAPI void APIENTRY glReplacementCodeuiNormal3fVertex3fSUN (GLuint rc, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); GLAPI void APIENTRY glReplacementCodeuiNormal3fVertex3fvSUN (const GLuint *rc, const GLfloat *n, const GLfloat *v); GLAPI void APIENTRY glReplacementCodeuiColor4fNormal3fVertex3fSUN (GLuint rc, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); GLAPI void APIENTRY glReplacementCodeuiColor4fNormal3fVertex3fvSUN (const GLuint *rc, const GLfloat *c, const GLfloat *n, const GLfloat *v); GLAPI void APIENTRY glReplacementCodeuiTexCoord2fVertex3fSUN (GLuint rc, GLfloat s, GLfloat t, GLfloat x, GLfloat y, GLfloat z); GLAPI void APIENTRY glReplacementCodeuiTexCoord2fVertex3fvSUN (const GLuint *rc, const GLfloat *tc, const GLfloat *v); GLAPI void APIENTRY glReplacementCodeuiTexCoord2fNormal3fVertex3fSUN (GLuint rc, GLfloat s, GLfloat t, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); GLAPI void APIENTRY glReplacementCodeuiTexCoord2fNormal3fVertex3fvSUN (const GLuint *rc, const GLfloat *tc, const GLfloat *n, const GLfloat *v); GLAPI void APIENTRY glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fSUN (GLuint rc, GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); GLAPI void APIENTRY glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fvSUN (const GLuint *rc, const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); #endif #endif /* GL_SUN_vertex */ #ifndef GL_WIN_phong_shading #define GL_WIN_phong_shading 1 #define GL_PHONG_WIN 0x80EA #define GL_PHONG_HINT_WIN 0x80EB #endif /* GL_WIN_phong_shading */ #ifndef GL_WIN_specular_fog #define GL_WIN_specular_fog 1 #define GL_FOG_SPECULAR_TEXTURE_WIN 0x80EC #endif /* GL_WIN_specular_fog */ #ifdef __cplusplus } #endif #endif ================================================ FILE: deps/include/SDL3/SDL_opengles.h ================================================ /* Simple DirectMedia Layer Copyright (C) 1997-2026 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ /* * This is a simple file to encapsulate the OpenGL ES 1.X API headers. */ #include #ifdef SDL_PLATFORM_IOS #include #include #else #include #include #endif #ifndef APIENTRY #define APIENTRY #endif ================================================ FILE: deps/include/SDL3/SDL_opengles2.h ================================================ /* Simple DirectMedia Layer Copyright (C) 1997-2026 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ /* * This is a simple file to encapsulate the OpenGL ES 2.0 API headers. */ #include #if !defined(_MSC_VER) && !defined(SDL_USE_BUILTIN_OPENGL_DEFINITIONS) #ifdef SDL_PLATFORM_IOS #include #include #else #include #include #include #endif #else /* _MSC_VER */ /* OpenGL ES2 headers for Visual Studio */ #include #include #include #include #endif /* _MSC_VER */ #ifndef APIENTRY #define APIENTRY GL_APIENTRY #endif ================================================ FILE: deps/include/SDL3/SDL_opengles2_gl2.h ================================================ #ifndef __gles2_gl2_h_ #define __gles2_gl2_h_ 1 #ifdef __cplusplus extern "C" { #endif /* ** Copyright 2013-2020 The Khronos Group Inc. ** SPDX-License-Identifier: MIT ** ** This header is generated from the Khronos OpenGL / OpenGL ES XML ** API Registry. The current version of the Registry, generator scripts ** used to make the header, and the header can be found at ** https://github.com/KhronosGroup/OpenGL-Registry */ /*#include */ #ifndef GL_APIENTRYP #define GL_APIENTRYP GL_APIENTRY* #endif #ifndef GL_GLES_PROTOTYPES #define GL_GLES_PROTOTYPES 1 #endif /* Generated on date 20220530 */ /* Generated C header for: * API: gles2 * Profile: common * Versions considered: 2\.[0-9] * Versions emitted: .* * Default extensions included: None * Additional extensions included: _nomatch_^ * Extensions removed: _nomatch_^ */ #ifndef GL_ES_VERSION_2_0 #define GL_ES_VERSION_2_0 1 /*#include */ typedef khronos_int8_t GLbyte; typedef khronos_float_t GLclampf; typedef khronos_int32_t GLfixed; typedef khronos_int16_t GLshort; typedef khronos_uint16_t GLushort; typedef void GLvoid; typedef struct __GLsync *GLsync; typedef khronos_int64_t GLint64; typedef khronos_uint64_t GLuint64; typedef unsigned int GLenum; typedef unsigned int GLuint; typedef char GLchar; typedef khronos_float_t GLfloat; typedef khronos_ssize_t GLsizeiptr; typedef khronos_intptr_t GLintptr; typedef unsigned int GLbitfield; typedef int GLint; typedef unsigned char GLboolean; typedef int GLsizei; typedef khronos_uint8_t GLubyte; #define GL_DEPTH_BUFFER_BIT 0x00000100 #define GL_STENCIL_BUFFER_BIT 0x00000400 #define GL_COLOR_BUFFER_BIT 0x00004000 #define GL_FALSE 0 #define GL_TRUE 1 #define GL_POINTS 0x0000 #define GL_LINES 0x0001 #define GL_LINE_LOOP 0x0002 #define GL_LINE_STRIP 0x0003 #define GL_TRIANGLES 0x0004 #define GL_TRIANGLE_STRIP 0x0005 #define GL_TRIANGLE_FAN 0x0006 #define GL_ZERO 0 #define GL_ONE 1 #define GL_SRC_COLOR 0x0300 #define GL_ONE_MINUS_SRC_COLOR 0x0301 #define GL_SRC_ALPHA 0x0302 #define GL_ONE_MINUS_SRC_ALPHA 0x0303 #define GL_DST_ALPHA 0x0304 #define GL_ONE_MINUS_DST_ALPHA 0x0305 #define GL_DST_COLOR 0x0306 #define GL_ONE_MINUS_DST_COLOR 0x0307 #define GL_SRC_ALPHA_SATURATE 0x0308 #define GL_FUNC_ADD 0x8006 #define GL_BLEND_EQUATION 0x8009 #define GL_BLEND_EQUATION_RGB 0x8009 #define GL_BLEND_EQUATION_ALPHA 0x883D #define GL_FUNC_SUBTRACT 0x800A #define GL_FUNC_REVERSE_SUBTRACT 0x800B #define GL_BLEND_DST_RGB 0x80C8 #define GL_BLEND_SRC_RGB 0x80C9 #define GL_BLEND_DST_ALPHA 0x80CA #define GL_BLEND_SRC_ALPHA 0x80CB #define GL_CONSTANT_COLOR 0x8001 #define GL_ONE_MINUS_CONSTANT_COLOR 0x8002 #define GL_CONSTANT_ALPHA 0x8003 #define GL_ONE_MINUS_CONSTANT_ALPHA 0x8004 #define GL_BLEND_COLOR 0x8005 #define GL_ARRAY_BUFFER 0x8892 #define GL_ELEMENT_ARRAY_BUFFER 0x8893 #define GL_ARRAY_BUFFER_BINDING 0x8894 #define GL_ELEMENT_ARRAY_BUFFER_BINDING 0x8895 #define GL_STREAM_DRAW 0x88E0 #define GL_STATIC_DRAW 0x88E4 #define GL_DYNAMIC_DRAW 0x88E8 #define GL_BUFFER_SIZE 0x8764 #define GL_BUFFER_USAGE 0x8765 #define GL_CURRENT_VERTEX_ATTRIB 0x8626 #define GL_FRONT 0x0404 #define GL_BACK 0x0405 #define GL_FRONT_AND_BACK 0x0408 #define GL_TEXTURE_2D 0x0DE1 #define GL_CULL_FACE 0x0B44 #define GL_BLEND 0x0BE2 #define GL_DITHER 0x0BD0 #define GL_STENCIL_TEST 0x0B90 #define GL_DEPTH_TEST 0x0B71 #define GL_SCISSOR_TEST 0x0C11 #define GL_POLYGON_OFFSET_FILL 0x8037 #define GL_SAMPLE_ALPHA_TO_COVERAGE 0x809E #define GL_SAMPLE_COVERAGE 0x80A0 #define GL_NO_ERROR 0 #define GL_INVALID_ENUM 0x0500 #define GL_INVALID_VALUE 0x0501 #define GL_INVALID_OPERATION 0x0502 #define GL_OUT_OF_MEMORY 0x0505 #define GL_CW 0x0900 #define GL_CCW 0x0901 #define GL_LINE_WIDTH 0x0B21 #define GL_ALIASED_POINT_SIZE_RANGE 0x846D #define GL_ALIASED_LINE_WIDTH_RANGE 0x846E #define GL_CULL_FACE_MODE 0x0B45 #define GL_FRONT_FACE 0x0B46 #define GL_DEPTH_RANGE 0x0B70 #define GL_DEPTH_WRITEMASK 0x0B72 #define GL_DEPTH_CLEAR_VALUE 0x0B73 #define GL_DEPTH_FUNC 0x0B74 #define GL_STENCIL_CLEAR_VALUE 0x0B91 #define GL_STENCIL_FUNC 0x0B92 #define GL_STENCIL_FAIL 0x0B94 #define GL_STENCIL_PASS_DEPTH_FAIL 0x0B95 #define GL_STENCIL_PASS_DEPTH_PASS 0x0B96 #define GL_STENCIL_REF 0x0B97 #define GL_STENCIL_VALUE_MASK 0x0B93 #define GL_STENCIL_WRITEMASK 0x0B98 #define GL_STENCIL_BACK_FUNC 0x8800 #define GL_STENCIL_BACK_FAIL 0x8801 #define GL_STENCIL_BACK_PASS_DEPTH_FAIL 0x8802 #define GL_STENCIL_BACK_PASS_DEPTH_PASS 0x8803 #define GL_STENCIL_BACK_REF 0x8CA3 #define GL_STENCIL_BACK_VALUE_MASK 0x8CA4 #define GL_STENCIL_BACK_WRITEMASK 0x8CA5 #define GL_VIEWPORT 0x0BA2 #define GL_SCISSOR_BOX 0x0C10 #define GL_COLOR_CLEAR_VALUE 0x0C22 #define GL_COLOR_WRITEMASK 0x0C23 #define GL_UNPACK_ALIGNMENT 0x0CF5 #define GL_PACK_ALIGNMENT 0x0D05 #define GL_MAX_TEXTURE_SIZE 0x0D33 #define GL_MAX_VIEWPORT_DIMS 0x0D3A #define GL_SUBPIXEL_BITS 0x0D50 #define GL_RED_BITS 0x0D52 #define GL_GREEN_BITS 0x0D53 #define GL_BLUE_BITS 0x0D54 #define GL_ALPHA_BITS 0x0D55 #define GL_DEPTH_BITS 0x0D56 #define GL_STENCIL_BITS 0x0D57 #define GL_POLYGON_OFFSET_UNITS 0x2A00 #define GL_POLYGON_OFFSET_FACTOR 0x8038 #define GL_TEXTURE_BINDING_2D 0x8069 #define GL_SAMPLE_BUFFERS 0x80A8 #define GL_SAMPLES 0x80A9 #define GL_SAMPLE_COVERAGE_VALUE 0x80AA #define GL_SAMPLE_COVERAGE_INVERT 0x80AB #define GL_NUM_COMPRESSED_TEXTURE_FORMATS 0x86A2 #define GL_COMPRESSED_TEXTURE_FORMATS 0x86A3 #define GL_DONT_CARE 0x1100 #define GL_FASTEST 0x1101 #define GL_NICEST 0x1102 #define GL_GENERATE_MIPMAP_HINT 0x8192 #define GL_BYTE 0x1400 #define GL_UNSIGNED_BYTE 0x1401 #define GL_SHORT 0x1402 #define GL_UNSIGNED_SHORT 0x1403 #define GL_INT 0x1404 #define GL_UNSIGNED_INT 0x1405 #define GL_FLOAT 0x1406 #define GL_FIXED 0x140C #define GL_DEPTH_COMPONENT 0x1902 #define GL_ALPHA 0x1906 #define GL_RGB 0x1907 #define GL_RGBA 0x1908 #define GL_LUMINANCE 0x1909 #define GL_LUMINANCE_ALPHA 0x190A #define GL_UNSIGNED_SHORT_4_4_4_4 0x8033 #define GL_UNSIGNED_SHORT_5_5_5_1 0x8034 #define GL_UNSIGNED_SHORT_5_6_5 0x8363 #define GL_FRAGMENT_SHADER 0x8B30 #define GL_VERTEX_SHADER 0x8B31 #define GL_MAX_VERTEX_ATTRIBS 0x8869 #define GL_MAX_VERTEX_UNIFORM_VECTORS 0x8DFB #define GL_MAX_VARYING_VECTORS 0x8DFC #define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS 0x8B4D #define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS 0x8B4C #define GL_MAX_TEXTURE_IMAGE_UNITS 0x8872 #define GL_MAX_FRAGMENT_UNIFORM_VECTORS 0x8DFD #define GL_SHADER_TYPE 0x8B4F #define GL_DELETE_STATUS 0x8B80 #define GL_LINK_STATUS 0x8B82 #define GL_VALIDATE_STATUS 0x8B83 #define GL_ATTACHED_SHADERS 0x8B85 #define GL_ACTIVE_UNIFORMS 0x8B86 #define GL_ACTIVE_UNIFORM_MAX_LENGTH 0x8B87 #define GL_ACTIVE_ATTRIBUTES 0x8B89 #define GL_ACTIVE_ATTRIBUTE_MAX_LENGTH 0x8B8A #define GL_SHADING_LANGUAGE_VERSION 0x8B8C #define GL_CURRENT_PROGRAM 0x8B8D #define GL_NEVER 0x0200 #define GL_LESS 0x0201 #define GL_EQUAL 0x0202 #define GL_LEQUAL 0x0203 #define GL_GREATER 0x0204 #define GL_NOTEQUAL 0x0205 #define GL_GEQUAL 0x0206 #define GL_ALWAYS 0x0207 #define GL_KEEP 0x1E00 #define GL_REPLACE 0x1E01 #define GL_INCR 0x1E02 #define GL_DECR 0x1E03 #define GL_INVERT 0x150A #define GL_INCR_WRAP 0x8507 #define GL_DECR_WRAP 0x8508 #define GL_VENDOR 0x1F00 #define GL_RENDERER 0x1F01 #define GL_VERSION 0x1F02 #define GL_EXTENSIONS 0x1F03 #define GL_NEAREST 0x2600 #define GL_LINEAR 0x2601 #define GL_NEAREST_MIPMAP_NEAREST 0x2700 #define GL_LINEAR_MIPMAP_NEAREST 0x2701 #define GL_NEAREST_MIPMAP_LINEAR 0x2702 #define GL_LINEAR_MIPMAP_LINEAR 0x2703 #define GL_TEXTURE_MAG_FILTER 0x2800 #define GL_TEXTURE_MIN_FILTER 0x2801 #define GL_TEXTURE_WRAP_S 0x2802 #define GL_TEXTURE_WRAP_T 0x2803 #define GL_TEXTURE 0x1702 #define GL_TEXTURE_CUBE_MAP 0x8513 #define GL_TEXTURE_BINDING_CUBE_MAP 0x8514 #define GL_TEXTURE_CUBE_MAP_POSITIVE_X 0x8515 #define GL_TEXTURE_CUBE_MAP_NEGATIVE_X 0x8516 #define GL_TEXTURE_CUBE_MAP_POSITIVE_Y 0x8517 #define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y 0x8518 #define GL_TEXTURE_CUBE_MAP_POSITIVE_Z 0x8519 #define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z 0x851A #define GL_MAX_CUBE_MAP_TEXTURE_SIZE 0x851C #define GL_TEXTURE0 0x84C0 #define GL_TEXTURE1 0x84C1 #define GL_TEXTURE2 0x84C2 #define GL_TEXTURE3 0x84C3 #define GL_TEXTURE4 0x84C4 #define GL_TEXTURE5 0x84C5 #define GL_TEXTURE6 0x84C6 #define GL_TEXTURE7 0x84C7 #define GL_TEXTURE8 0x84C8 #define GL_TEXTURE9 0x84C9 #define GL_TEXTURE10 0x84CA #define GL_TEXTURE11 0x84CB #define GL_TEXTURE12 0x84CC #define GL_TEXTURE13 0x84CD #define GL_TEXTURE14 0x84CE #define GL_TEXTURE15 0x84CF #define GL_TEXTURE16 0x84D0 #define GL_TEXTURE17 0x84D1 #define GL_TEXTURE18 0x84D2 #define GL_TEXTURE19 0x84D3 #define GL_TEXTURE20 0x84D4 #define GL_TEXTURE21 0x84D5 #define GL_TEXTURE22 0x84D6 #define GL_TEXTURE23 0x84D7 #define GL_TEXTURE24 0x84D8 #define GL_TEXTURE25 0x84D9 #define GL_TEXTURE26 0x84DA #define GL_TEXTURE27 0x84DB #define GL_TEXTURE28 0x84DC #define GL_TEXTURE29 0x84DD #define GL_TEXTURE30 0x84DE #define GL_TEXTURE31 0x84DF #define GL_ACTIVE_TEXTURE 0x84E0 #define GL_REPEAT 0x2901 #define GL_CLAMP_TO_EDGE 0x812F #define GL_MIRRORED_REPEAT 0x8370 #define GL_FLOAT_VEC2 0x8B50 #define GL_FLOAT_VEC3 0x8B51 #define GL_FLOAT_VEC4 0x8B52 #define GL_INT_VEC2 0x8B53 #define GL_INT_VEC3 0x8B54 #define GL_INT_VEC4 0x8B55 #define GL_BOOL 0x8B56 #define GL_BOOL_VEC2 0x8B57 #define GL_BOOL_VEC3 0x8B58 #define GL_BOOL_VEC4 0x8B59 #define GL_FLOAT_MAT2 0x8B5A #define GL_FLOAT_MAT3 0x8B5B #define GL_FLOAT_MAT4 0x8B5C #define GL_SAMPLER_2D 0x8B5E #define GL_SAMPLER_CUBE 0x8B60 #define GL_VERTEX_ATTRIB_ARRAY_ENABLED 0x8622 #define GL_VERTEX_ATTRIB_ARRAY_SIZE 0x8623 #define GL_VERTEX_ATTRIB_ARRAY_STRIDE 0x8624 #define GL_VERTEX_ATTRIB_ARRAY_TYPE 0x8625 #define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED 0x886A #define GL_VERTEX_ATTRIB_ARRAY_POINTER 0x8645 #define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING 0x889F #define GL_IMPLEMENTATION_COLOR_READ_TYPE 0x8B9A #define GL_IMPLEMENTATION_COLOR_READ_FORMAT 0x8B9B #define GL_COMPILE_STATUS 0x8B81 #define GL_INFO_LOG_LENGTH 0x8B84 #define GL_SHADER_SOURCE_LENGTH 0x8B88 #define GL_SHADER_COMPILER 0x8DFA #define GL_SHADER_BINARY_FORMATS 0x8DF8 #define GL_NUM_SHADER_BINARY_FORMATS 0x8DF9 #define GL_LOW_FLOAT 0x8DF0 #define GL_MEDIUM_FLOAT 0x8DF1 #define GL_HIGH_FLOAT 0x8DF2 #define GL_LOW_INT 0x8DF3 #define GL_MEDIUM_INT 0x8DF4 #define GL_HIGH_INT 0x8DF5 #define GL_FRAMEBUFFER 0x8D40 #define GL_RENDERBUFFER 0x8D41 #define GL_RGBA4 0x8056 #define GL_RGB5_A1 0x8057 #define GL_RGB565 0x8D62 #define GL_DEPTH_COMPONENT16 0x81A5 #define GL_STENCIL_INDEX8 0x8D48 #define GL_RENDERBUFFER_WIDTH 0x8D42 #define GL_RENDERBUFFER_HEIGHT 0x8D43 #define GL_RENDERBUFFER_INTERNAL_FORMAT 0x8D44 #define GL_RENDERBUFFER_RED_SIZE 0x8D50 #define GL_RENDERBUFFER_GREEN_SIZE 0x8D51 #define GL_RENDERBUFFER_BLUE_SIZE 0x8D52 #define GL_RENDERBUFFER_ALPHA_SIZE 0x8D53 #define GL_RENDERBUFFER_DEPTH_SIZE 0x8D54 #define GL_RENDERBUFFER_STENCIL_SIZE 0x8D55 #define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE 0x8CD0 #define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME 0x8CD1 #define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL 0x8CD2 #define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE 0x8CD3 #define GL_COLOR_ATTACHMENT0 0x8CE0 #define GL_DEPTH_ATTACHMENT 0x8D00 #define GL_STENCIL_ATTACHMENT 0x8D20 #define GL_NONE 0 #define GL_FRAMEBUFFER_COMPLETE 0x8CD5 #define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT 0x8CD6 #define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT 0x8CD7 #define GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS 0x8CD9 #define GL_FRAMEBUFFER_UNSUPPORTED 0x8CDD #define GL_FRAMEBUFFER_BINDING 0x8CA6 #define GL_RENDERBUFFER_BINDING 0x8CA7 #define GL_MAX_RENDERBUFFER_SIZE 0x84E8 #define GL_INVALID_FRAMEBUFFER_OPERATION 0x0506 typedef void (GL_APIENTRYP PFNGLACTIVETEXTUREPROC) (GLenum texture); typedef void (GL_APIENTRYP PFNGLATTACHSHADERPROC) (GLuint program, GLuint shader); typedef void (GL_APIENTRYP PFNGLBINDATTRIBLOCATIONPROC) (GLuint program, GLuint index, const GLchar *name); typedef void (GL_APIENTRYP PFNGLBINDBUFFERPROC) (GLenum target, GLuint buffer); typedef void (GL_APIENTRYP PFNGLBINDFRAMEBUFFERPROC) (GLenum target, GLuint framebuffer); typedef void (GL_APIENTRYP PFNGLBINDRENDERBUFFERPROC) (GLenum target, GLuint renderbuffer); typedef void (GL_APIENTRYP PFNGLBINDTEXTUREPROC) (GLenum target, GLuint texture); typedef void (GL_APIENTRYP PFNGLBLENDCOLORPROC) (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); typedef void (GL_APIENTRYP PFNGLBLENDEQUATIONPROC) (GLenum mode); typedef void (GL_APIENTRYP PFNGLBLENDEQUATIONSEPARATEPROC) (GLenum modeRGB, GLenum modeAlpha); typedef void (GL_APIENTRYP PFNGLBLENDFUNCPROC) (GLenum sfactor, GLenum dfactor); typedef void (GL_APIENTRYP PFNGLBLENDFUNCSEPARATEPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); typedef void (GL_APIENTRYP PFNGLBUFFERDATAPROC) (GLenum target, GLsizeiptr size, const void *data, GLenum usage); typedef void (GL_APIENTRYP PFNGLBUFFERSUBDATAPROC) (GLenum target, GLintptr offset, GLsizeiptr size, const void *data); typedef GLenum (GL_APIENTRYP PFNGLCHECKFRAMEBUFFERSTATUSPROC) (GLenum target); typedef void (GL_APIENTRYP PFNGLCLEARPROC) (GLbitfield mask); typedef void (GL_APIENTRYP PFNGLCLEARCOLORPROC) (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); typedef void (GL_APIENTRYP PFNGLCLEARDEPTHFPROC) (GLfloat d); typedef void (GL_APIENTRYP PFNGLCLEARSTENCILPROC) (GLint s); typedef void (GL_APIENTRYP PFNGLCOLORMASKPROC) (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); typedef void (GL_APIENTRYP PFNGLCOMPILESHADERPROC) (GLuint shader); typedef void (GL_APIENTRYP PFNGLCOMPRESSEDTEXIMAGE2DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void *data); typedef void (GL_APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *data); typedef void (GL_APIENTRYP PFNGLCOPYTEXIMAGE2DPROC) (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); typedef void (GL_APIENTRYP PFNGLCOPYTEXSUBIMAGE2DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); typedef GLuint (GL_APIENTRYP PFNGLCREATEPROGRAMPROC) (void); typedef GLuint (GL_APIENTRYP PFNGLCREATESHADERPROC) (GLenum type); typedef void (GL_APIENTRYP PFNGLCULLFACEPROC) (GLenum mode); typedef void (GL_APIENTRYP PFNGLDELETEBUFFERSPROC) (GLsizei n, const GLuint *buffers); typedef void (GL_APIENTRYP PFNGLDELETEFRAMEBUFFERSPROC) (GLsizei n, const GLuint *framebuffers); typedef void (GL_APIENTRYP PFNGLDELETEPROGRAMPROC) (GLuint program); typedef void (GL_APIENTRYP PFNGLDELETERENDERBUFFERSPROC) (GLsizei n, const GLuint *renderbuffers); typedef void (GL_APIENTRYP PFNGLDELETESHADERPROC) (GLuint shader); typedef void (GL_APIENTRYP PFNGLDELETETEXTURESPROC) (GLsizei n, const GLuint *textures); typedef void (GL_APIENTRYP PFNGLDEPTHFUNCPROC) (GLenum func); typedef void (GL_APIENTRYP PFNGLDEPTHMASKPROC) (GLboolean flag); typedef void (GL_APIENTRYP PFNGLDEPTHRANGEFPROC) (GLfloat n, GLfloat f); typedef void (GL_APIENTRYP PFNGLDETACHSHADERPROC) (GLuint program, GLuint shader); typedef void (GL_APIENTRYP PFNGLDISABLEPROC) (GLenum cap); typedef void (GL_APIENTRYP PFNGLDISABLEVERTEXATTRIBARRAYPROC) (GLuint index); typedef void (GL_APIENTRYP PFNGLDRAWARRAYSPROC) (GLenum mode, GLint first, GLsizei count); typedef void (GL_APIENTRYP PFNGLDRAWELEMENTSPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices); typedef void (GL_APIENTRYP PFNGLENABLEPROC) (GLenum cap); typedef void (GL_APIENTRYP PFNGLENABLEVERTEXATTRIBARRAYPROC) (GLuint index); typedef void (GL_APIENTRYP PFNGLFINISHPROC) (void); typedef void (GL_APIENTRYP PFNGLFLUSHPROC) (void); typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERRENDERBUFFERPROC) (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); typedef void (GL_APIENTRYP PFNGLFRONTFACEPROC) (GLenum mode); typedef void (GL_APIENTRYP PFNGLGENBUFFERSPROC) (GLsizei n, GLuint *buffers); typedef void (GL_APIENTRYP PFNGLGENERATEMIPMAPPROC) (GLenum target); typedef void (GL_APIENTRYP PFNGLGENFRAMEBUFFERSPROC) (GLsizei n, GLuint *framebuffers); typedef void (GL_APIENTRYP PFNGLGENRENDERBUFFERSPROC) (GLsizei n, GLuint *renderbuffers); typedef void (GL_APIENTRYP PFNGLGENTEXTURESPROC) (GLsizei n, GLuint *textures); typedef void (GL_APIENTRYP PFNGLGETACTIVEATTRIBPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); typedef void (GL_APIENTRYP PFNGLGETACTIVEUNIFORMPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); typedef void (GL_APIENTRYP PFNGLGETATTACHEDSHADERSPROC) (GLuint program, GLsizei maxCount, GLsizei *count, GLuint *shaders); typedef GLint (GL_APIENTRYP PFNGLGETATTRIBLOCATIONPROC) (GLuint program, const GLchar *name); typedef void (GL_APIENTRYP PFNGLGETBOOLEANVPROC) (GLenum pname, GLboolean *data); typedef void (GL_APIENTRYP PFNGLGETBUFFERPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); typedef GLenum (GL_APIENTRYP PFNGLGETERRORPROC) (void); typedef void (GL_APIENTRYP PFNGLGETFLOATVPROC) (GLenum pname, GLfloat *data); typedef void (GL_APIENTRYP PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC) (GLenum target, GLenum attachment, GLenum pname, GLint *params); typedef void (GL_APIENTRYP PFNGLGETINTEGERVPROC) (GLenum pname, GLint *data); typedef void (GL_APIENTRYP PFNGLGETPROGRAMIVPROC) (GLuint program, GLenum pname, GLint *params); typedef void (GL_APIENTRYP PFNGLGETPROGRAMINFOLOGPROC) (GLuint program, GLsizei bufSize, GLsizei *length, GLchar *infoLog); typedef void (GL_APIENTRYP PFNGLGETRENDERBUFFERPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); typedef void (GL_APIENTRYP PFNGLGETSHADERIVPROC) (GLuint shader, GLenum pname, GLint *params); typedef void (GL_APIENTRYP PFNGLGETSHADERINFOLOGPROC) (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog); typedef void (GL_APIENTRYP PFNGLGETSHADERPRECISIONFORMATPROC) (GLenum shadertype, GLenum precisiontype, GLint *range, GLint *precision); typedef void (GL_APIENTRYP PFNGLGETSHADERSOURCEPROC) (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *source); typedef const GLubyte *(GL_APIENTRYP PFNGLGETSTRINGPROC) (GLenum name); typedef void (GL_APIENTRYP PFNGLGETTEXPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); typedef void (GL_APIENTRYP PFNGLGETTEXPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); typedef void (GL_APIENTRYP PFNGLGETUNIFORMFVPROC) (GLuint program, GLint location, GLfloat *params); typedef void (GL_APIENTRYP PFNGLGETUNIFORMIVPROC) (GLuint program, GLint location, GLint *params); typedef GLint (GL_APIENTRYP PFNGLGETUNIFORMLOCATIONPROC) (GLuint program, const GLchar *name); typedef void (GL_APIENTRYP PFNGLGETVERTEXATTRIBFVPROC) (GLuint index, GLenum pname, GLfloat *params); typedef void (GL_APIENTRYP PFNGLGETVERTEXATTRIBIVPROC) (GLuint index, GLenum pname, GLint *params); typedef void (GL_APIENTRYP PFNGLGETVERTEXATTRIBPOINTERVPROC) (GLuint index, GLenum pname, void **pointer); typedef void (GL_APIENTRYP PFNGLHINTPROC) (GLenum target, GLenum mode); typedef GLboolean (GL_APIENTRYP PFNGLISBUFFERPROC) (GLuint buffer); typedef GLboolean (GL_APIENTRYP PFNGLISENABLEDPROC) (GLenum cap); typedef GLboolean (GL_APIENTRYP PFNGLISFRAMEBUFFERPROC) (GLuint framebuffer); typedef GLboolean (GL_APIENTRYP PFNGLISPROGRAMPROC) (GLuint program); typedef GLboolean (GL_APIENTRYP PFNGLISRENDERBUFFERPROC) (GLuint renderbuffer); typedef GLboolean (GL_APIENTRYP PFNGLISSHADERPROC) (GLuint shader); typedef GLboolean (GL_APIENTRYP PFNGLISTEXTUREPROC) (GLuint texture); typedef void (GL_APIENTRYP PFNGLLINEWIDTHPROC) (GLfloat width); typedef void (GL_APIENTRYP PFNGLLINKPROGRAMPROC) (GLuint program); typedef void (GL_APIENTRYP PFNGLPIXELSTOREIPROC) (GLenum pname, GLint param); typedef void (GL_APIENTRYP PFNGLPOLYGONOFFSETPROC) (GLfloat factor, GLfloat units); typedef void (GL_APIENTRYP PFNGLREADPIXELSPROC) (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void *pixels); typedef void (GL_APIENTRYP PFNGLRELEASESHADERCOMPILERPROC) (void); typedef void (GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height); typedef void (GL_APIENTRYP PFNGLSAMPLECOVERAGEPROC) (GLfloat value, GLboolean invert); typedef void (GL_APIENTRYP PFNGLSCISSORPROC) (GLint x, GLint y, GLsizei width, GLsizei height); typedef void (GL_APIENTRYP PFNGLSHADERBINARYPROC) (GLsizei count, const GLuint *shaders, GLenum binaryFormat, const void *binary, GLsizei length); typedef void (GL_APIENTRYP PFNGLSHADERSOURCEPROC) (GLuint shader, GLsizei count, const GLchar *const*string, const GLint *length); typedef void (GL_APIENTRYP PFNGLSTENCILFUNCPROC) (GLenum func, GLint ref, GLuint mask); typedef void (GL_APIENTRYP PFNGLSTENCILFUNCSEPARATEPROC) (GLenum face, GLenum func, GLint ref, GLuint mask); typedef void (GL_APIENTRYP PFNGLSTENCILMASKPROC) (GLuint mask); typedef void (GL_APIENTRYP PFNGLSTENCILMASKSEPARATEPROC) (GLenum face, GLuint mask); typedef void (GL_APIENTRYP PFNGLSTENCILOPPROC) (GLenum fail, GLenum zfail, GLenum zpass); typedef void (GL_APIENTRYP PFNGLSTENCILOPSEPARATEPROC) (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); typedef void (GL_APIENTRYP PFNGLTEXIMAGE2DPROC) (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void *pixels); typedef void (GL_APIENTRYP PFNGLTEXPARAMETERFPROC) (GLenum target, GLenum pname, GLfloat param); typedef void (GL_APIENTRYP PFNGLTEXPARAMETERFVPROC) (GLenum target, GLenum pname, const GLfloat *params); typedef void (GL_APIENTRYP PFNGLTEXPARAMETERIPROC) (GLenum target, GLenum pname, GLint param); typedef void (GL_APIENTRYP PFNGLTEXPARAMETERIVPROC) (GLenum target, GLenum pname, const GLint *params); typedef void (GL_APIENTRYP PFNGLTEXSUBIMAGE2DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels); typedef void (GL_APIENTRYP PFNGLUNIFORM1FPROC) (GLint location, GLfloat v0); typedef void (GL_APIENTRYP PFNGLUNIFORM1FVPROC) (GLint location, GLsizei count, const GLfloat *value); typedef void (GL_APIENTRYP PFNGLUNIFORM1IPROC) (GLint location, GLint v0); typedef void (GL_APIENTRYP PFNGLUNIFORM1IVPROC) (GLint location, GLsizei count, const GLint *value); typedef void (GL_APIENTRYP PFNGLUNIFORM2FPROC) (GLint location, GLfloat v0, GLfloat v1); typedef void (GL_APIENTRYP PFNGLUNIFORM2FVPROC) (GLint location, GLsizei count, const GLfloat *value); typedef void (GL_APIENTRYP PFNGLUNIFORM2IPROC) (GLint location, GLint v0, GLint v1); typedef void (GL_APIENTRYP PFNGLUNIFORM2IVPROC) (GLint location, GLsizei count, const GLint *value); typedef void (GL_APIENTRYP PFNGLUNIFORM3FPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2); typedef void (GL_APIENTRYP PFNGLUNIFORM3FVPROC) (GLint location, GLsizei count, const GLfloat *value); typedef void (GL_APIENTRYP PFNGLUNIFORM3IPROC) (GLint location, GLint v0, GLint v1, GLint v2); typedef void (GL_APIENTRYP PFNGLUNIFORM3IVPROC) (GLint location, GLsizei count, const GLint *value); typedef void (GL_APIENTRYP PFNGLUNIFORM4FPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); typedef void (GL_APIENTRYP PFNGLUNIFORM4FVPROC) (GLint location, GLsizei count, const GLfloat *value); typedef void (GL_APIENTRYP PFNGLUNIFORM4IPROC) (GLint location, GLint v0, GLint v1, GLint v2, GLint v3); typedef void (GL_APIENTRYP PFNGLUNIFORM4IVPROC) (GLint location, GLsizei count, const GLint *value); typedef void (GL_APIENTRYP PFNGLUNIFORMMATRIX2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); typedef void (GL_APIENTRYP PFNGLUNIFORMMATRIX3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); typedef void (GL_APIENTRYP PFNGLUNIFORMMATRIX4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); typedef void (GL_APIENTRYP PFNGLUSEPROGRAMPROC) (GLuint program); typedef void (GL_APIENTRYP PFNGLVALIDATEPROGRAMPROC) (GLuint program); typedef void (GL_APIENTRYP PFNGLVERTEXATTRIB1FPROC) (GLuint index, GLfloat x); typedef void (GL_APIENTRYP PFNGLVERTEXATTRIB1FVPROC) (GLuint index, const GLfloat *v); typedef void (GL_APIENTRYP PFNGLVERTEXATTRIB2FPROC) (GLuint index, GLfloat x, GLfloat y); typedef void (GL_APIENTRYP PFNGLVERTEXATTRIB2FVPROC) (GLuint index, const GLfloat *v); typedef void (GL_APIENTRYP PFNGLVERTEXATTRIB3FPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z); typedef void (GL_APIENTRYP PFNGLVERTEXATTRIB3FVPROC) (GLuint index, const GLfloat *v); typedef void (GL_APIENTRYP PFNGLVERTEXATTRIB4FPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); typedef void (GL_APIENTRYP PFNGLVERTEXATTRIB4FVPROC) (GLuint index, const GLfloat *v); typedef void (GL_APIENTRYP PFNGLVERTEXATTRIBPOINTERPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void *pointer); typedef void (GL_APIENTRYP PFNGLVIEWPORTPROC) (GLint x, GLint y, GLsizei width, GLsizei height); #if GL_GLES_PROTOTYPES GL_APICALL void GL_APIENTRY glActiveTexture (GLenum texture); GL_APICALL void GL_APIENTRY glAttachShader (GLuint program, GLuint shader); GL_APICALL void GL_APIENTRY glBindAttribLocation (GLuint program, GLuint index, const GLchar *name); GL_APICALL void GL_APIENTRY glBindBuffer (GLenum target, GLuint buffer); GL_APICALL void GL_APIENTRY glBindFramebuffer (GLenum target, GLuint framebuffer); GL_APICALL void GL_APIENTRY glBindRenderbuffer (GLenum target, GLuint renderbuffer); GL_APICALL void GL_APIENTRY glBindTexture (GLenum target, GLuint texture); GL_APICALL void GL_APIENTRY glBlendColor (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); GL_APICALL void GL_APIENTRY glBlendEquation (GLenum mode); GL_APICALL void GL_APIENTRY glBlendEquationSeparate (GLenum modeRGB, GLenum modeAlpha); GL_APICALL void GL_APIENTRY glBlendFunc (GLenum sfactor, GLenum dfactor); GL_APICALL void GL_APIENTRY glBlendFuncSeparate (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); GL_APICALL void GL_APIENTRY glBufferData (GLenum target, GLsizeiptr size, const void *data, GLenum usage); GL_APICALL void GL_APIENTRY glBufferSubData (GLenum target, GLintptr offset, GLsizeiptr size, const void *data); GL_APICALL GLenum GL_APIENTRY glCheckFramebufferStatus (GLenum target); GL_APICALL void GL_APIENTRY glClear (GLbitfield mask); GL_APICALL void GL_APIENTRY glClearColor (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); GL_APICALL void GL_APIENTRY glClearDepthf (GLfloat d); GL_APICALL void GL_APIENTRY glClearStencil (GLint s); GL_APICALL void GL_APIENTRY glColorMask (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); GL_APICALL void GL_APIENTRY glCompileShader (GLuint shader); GL_APICALL void GL_APIENTRY glCompressedTexImage2D (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void *data); GL_APICALL void GL_APIENTRY glCompressedTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *data); GL_APICALL void GL_APIENTRY glCopyTexImage2D (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); GL_APICALL void GL_APIENTRY glCopyTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); GL_APICALL GLuint GL_APIENTRY glCreateProgram (void); GL_APICALL GLuint GL_APIENTRY glCreateShader (GLenum type); GL_APICALL void GL_APIENTRY glCullFace (GLenum mode); GL_APICALL void GL_APIENTRY glDeleteBuffers (GLsizei n, const GLuint *buffers); GL_APICALL void GL_APIENTRY glDeleteFramebuffers (GLsizei n, const GLuint *framebuffers); GL_APICALL void GL_APIENTRY glDeleteProgram (GLuint program); GL_APICALL void GL_APIENTRY glDeleteRenderbuffers (GLsizei n, const GLuint *renderbuffers); GL_APICALL void GL_APIENTRY glDeleteShader (GLuint shader); GL_APICALL void GL_APIENTRY glDeleteTextures (GLsizei n, const GLuint *textures); GL_APICALL void GL_APIENTRY glDepthFunc (GLenum func); GL_APICALL void GL_APIENTRY glDepthMask (GLboolean flag); GL_APICALL void GL_APIENTRY glDepthRangef (GLfloat n, GLfloat f); GL_APICALL void GL_APIENTRY glDetachShader (GLuint program, GLuint shader); GL_APICALL void GL_APIENTRY glDisable (GLenum cap); GL_APICALL void GL_APIENTRY glDisableVertexAttribArray (GLuint index); GL_APICALL void GL_APIENTRY glDrawArrays (GLenum mode, GLint first, GLsizei count); GL_APICALL void GL_APIENTRY glDrawElements (GLenum mode, GLsizei count, GLenum type, const void *indices); GL_APICALL void GL_APIENTRY glEnable (GLenum cap); GL_APICALL void GL_APIENTRY glEnableVertexAttribArray (GLuint index); GL_APICALL void GL_APIENTRY glFinish (void); GL_APICALL void GL_APIENTRY glFlush (void); GL_APICALL void GL_APIENTRY glFramebufferRenderbuffer (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); GL_APICALL void GL_APIENTRY glFramebufferTexture2D (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); GL_APICALL void GL_APIENTRY glFrontFace (GLenum mode); GL_APICALL void GL_APIENTRY glGenBuffers (GLsizei n, GLuint *buffers); GL_APICALL void GL_APIENTRY glGenerateMipmap (GLenum target); GL_APICALL void GL_APIENTRY glGenFramebuffers (GLsizei n, GLuint *framebuffers); GL_APICALL void GL_APIENTRY glGenRenderbuffers (GLsizei n, GLuint *renderbuffers); GL_APICALL void GL_APIENTRY glGenTextures (GLsizei n, GLuint *textures); GL_APICALL void GL_APIENTRY glGetActiveAttrib (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); GL_APICALL void GL_APIENTRY glGetActiveUniform (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); GL_APICALL void GL_APIENTRY glGetAttachedShaders (GLuint program, GLsizei maxCount, GLsizei *count, GLuint *shaders); GL_APICALL GLint GL_APIENTRY glGetAttribLocation (GLuint program, const GLchar *name); GL_APICALL void GL_APIENTRY glGetBooleanv (GLenum pname, GLboolean *data); GL_APICALL void GL_APIENTRY glGetBufferParameteriv (GLenum target, GLenum pname, GLint *params); GL_APICALL GLenum GL_APIENTRY glGetError (void); GL_APICALL void GL_APIENTRY glGetFloatv (GLenum pname, GLfloat *data); GL_APICALL void GL_APIENTRY glGetFramebufferAttachmentParameteriv (GLenum target, GLenum attachment, GLenum pname, GLint *params); GL_APICALL void GL_APIENTRY glGetIntegerv (GLenum pname, GLint *data); GL_APICALL void GL_APIENTRY glGetProgramiv (GLuint program, GLenum pname, GLint *params); GL_APICALL void GL_APIENTRY glGetProgramInfoLog (GLuint program, GLsizei bufSize, GLsizei *length, GLchar *infoLog); GL_APICALL void GL_APIENTRY glGetRenderbufferParameteriv (GLenum target, GLenum pname, GLint *params); GL_APICALL void GL_APIENTRY glGetShaderiv (GLuint shader, GLenum pname, GLint *params); GL_APICALL void GL_APIENTRY glGetShaderInfoLog (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog); GL_APICALL void GL_APIENTRY glGetShaderPrecisionFormat (GLenum shadertype, GLenum precisiontype, GLint *range, GLint *precision); GL_APICALL void GL_APIENTRY glGetShaderSource (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *source); GL_APICALL const GLubyte *GL_APIENTRY glGetString (GLenum name); GL_APICALL void GL_APIENTRY glGetTexParameterfv (GLenum target, GLenum pname, GLfloat *params); GL_APICALL void GL_APIENTRY glGetTexParameteriv (GLenum target, GLenum pname, GLint *params); GL_APICALL void GL_APIENTRY glGetUniformfv (GLuint program, GLint location, GLfloat *params); GL_APICALL void GL_APIENTRY glGetUniformiv (GLuint program, GLint location, GLint *params); GL_APICALL GLint GL_APIENTRY glGetUniformLocation (GLuint program, const GLchar *name); GL_APICALL void GL_APIENTRY glGetVertexAttribfv (GLuint index, GLenum pname, GLfloat *params); GL_APICALL void GL_APIENTRY glGetVertexAttribiv (GLuint index, GLenum pname, GLint *params); GL_APICALL void GL_APIENTRY glGetVertexAttribPointerv (GLuint index, GLenum pname, void **pointer); GL_APICALL void GL_APIENTRY glHint (GLenum target, GLenum mode); GL_APICALL GLboolean GL_APIENTRY glIsBuffer (GLuint buffer); GL_APICALL GLboolean GL_APIENTRY glIsEnabled (GLenum cap); GL_APICALL GLboolean GL_APIENTRY glIsFramebuffer (GLuint framebuffer); GL_APICALL GLboolean GL_APIENTRY glIsProgram (GLuint program); GL_APICALL GLboolean GL_APIENTRY glIsRenderbuffer (GLuint renderbuffer); GL_APICALL GLboolean GL_APIENTRY glIsShader (GLuint shader); GL_APICALL GLboolean GL_APIENTRY glIsTexture (GLuint texture); GL_APICALL void GL_APIENTRY glLineWidth (GLfloat width); GL_APICALL void GL_APIENTRY glLinkProgram (GLuint program); GL_APICALL void GL_APIENTRY glPixelStorei (GLenum pname, GLint param); GL_APICALL void GL_APIENTRY glPolygonOffset (GLfloat factor, GLfloat units); GL_APICALL void GL_APIENTRY glReadPixels (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void *pixels); GL_APICALL void GL_APIENTRY glReleaseShaderCompiler (void); GL_APICALL void GL_APIENTRY glRenderbufferStorage (GLenum target, GLenum internalformat, GLsizei width, GLsizei height); GL_APICALL void GL_APIENTRY glSampleCoverage (GLfloat value, GLboolean invert); GL_APICALL void GL_APIENTRY glScissor (GLint x, GLint y, GLsizei width, GLsizei height); GL_APICALL void GL_APIENTRY glShaderBinary (GLsizei count, const GLuint *shaders, GLenum binaryFormat, const void *binary, GLsizei length); GL_APICALL void GL_APIENTRY glShaderSource (GLuint shader, GLsizei count, const GLchar *const*string, const GLint *length); GL_APICALL void GL_APIENTRY glStencilFunc (GLenum func, GLint ref, GLuint mask); GL_APICALL void GL_APIENTRY glStencilFuncSeparate (GLenum face, GLenum func, GLint ref, GLuint mask); GL_APICALL void GL_APIENTRY glStencilMask (GLuint mask); GL_APICALL void GL_APIENTRY glStencilMaskSeparate (GLenum face, GLuint mask); GL_APICALL void GL_APIENTRY glStencilOp (GLenum fail, GLenum zfail, GLenum zpass); GL_APICALL void GL_APIENTRY glStencilOpSeparate (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); GL_APICALL void GL_APIENTRY glTexImage2D (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void *pixels); GL_APICALL void GL_APIENTRY glTexParameterf (GLenum target, GLenum pname, GLfloat param); GL_APICALL void GL_APIENTRY glTexParameterfv (GLenum target, GLenum pname, const GLfloat *params); GL_APICALL void GL_APIENTRY glTexParameteri (GLenum target, GLenum pname, GLint param); GL_APICALL void GL_APIENTRY glTexParameteriv (GLenum target, GLenum pname, const GLint *params); GL_APICALL void GL_APIENTRY glTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels); GL_APICALL void GL_APIENTRY glUniform1f (GLint location, GLfloat v0); GL_APICALL void GL_APIENTRY glUniform1fv (GLint location, GLsizei count, const GLfloat *value); GL_APICALL void GL_APIENTRY glUniform1i (GLint location, GLint v0); GL_APICALL void GL_APIENTRY glUniform1iv (GLint location, GLsizei count, const GLint *value); GL_APICALL void GL_APIENTRY glUniform2f (GLint location, GLfloat v0, GLfloat v1); GL_APICALL void GL_APIENTRY glUniform2fv (GLint location, GLsizei count, const GLfloat *value); GL_APICALL void GL_APIENTRY glUniform2i (GLint location, GLint v0, GLint v1); GL_APICALL void GL_APIENTRY glUniform2iv (GLint location, GLsizei count, const GLint *value); GL_APICALL void GL_APIENTRY glUniform3f (GLint location, GLfloat v0, GLfloat v1, GLfloat v2); GL_APICALL void GL_APIENTRY glUniform3fv (GLint location, GLsizei count, const GLfloat *value); GL_APICALL void GL_APIENTRY glUniform3i (GLint location, GLint v0, GLint v1, GLint v2); GL_APICALL void GL_APIENTRY glUniform3iv (GLint location, GLsizei count, const GLint *value); GL_APICALL void GL_APIENTRY glUniform4f (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); GL_APICALL void GL_APIENTRY glUniform4fv (GLint location, GLsizei count, const GLfloat *value); GL_APICALL void GL_APIENTRY glUniform4i (GLint location, GLint v0, GLint v1, GLint v2, GLint v3); GL_APICALL void GL_APIENTRY glUniform4iv (GLint location, GLsizei count, const GLint *value); GL_APICALL void GL_APIENTRY glUniformMatrix2fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); GL_APICALL void GL_APIENTRY glUniformMatrix3fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); GL_APICALL void GL_APIENTRY glUniformMatrix4fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); GL_APICALL void GL_APIENTRY glUseProgram (GLuint program); GL_APICALL void GL_APIENTRY glValidateProgram (GLuint program); GL_APICALL void GL_APIENTRY glVertexAttrib1f (GLuint index, GLfloat x); GL_APICALL void GL_APIENTRY glVertexAttrib1fv (GLuint index, const GLfloat *v); GL_APICALL void GL_APIENTRY glVertexAttrib2f (GLuint index, GLfloat x, GLfloat y); GL_APICALL void GL_APIENTRY glVertexAttrib2fv (GLuint index, const GLfloat *v); GL_APICALL void GL_APIENTRY glVertexAttrib3f (GLuint index, GLfloat x, GLfloat y, GLfloat z); GL_APICALL void GL_APIENTRY glVertexAttrib3fv (GLuint index, const GLfloat *v); GL_APICALL void GL_APIENTRY glVertexAttrib4f (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); GL_APICALL void GL_APIENTRY glVertexAttrib4fv (GLuint index, const GLfloat *v); GL_APICALL void GL_APIENTRY glVertexAttribPointer (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void *pointer); GL_APICALL void GL_APIENTRY glViewport (GLint x, GLint y, GLsizei width, GLsizei height); #endif #endif /* GL_ES_VERSION_2_0 */ #ifdef __cplusplus } #endif #endif ================================================ FILE: deps/include/SDL3/SDL_opengles2_gl2ext.h ================================================ #ifndef __gles2_gl2ext_h_ #define __gles2_gl2ext_h_ 1 #ifdef __cplusplus extern "C" { #endif /* ** Copyright 2013-2020 The Khronos Group Inc. ** SPDX-License-Identifier: MIT ** ** This header is generated from the Khronos OpenGL / OpenGL ES XML ** API Registry. The current version of the Registry, generator scripts ** used to make the header, and the header can be found at ** https://github.com/KhronosGroup/OpenGL-Registry */ #ifndef GL_APIENTRYP #define GL_APIENTRYP GL_APIENTRY* #endif /* Generated on date 20220530 */ /* Generated C header for: * API: gles2 * Profile: common * Versions considered: 2\.[0-9] * Versions emitted: _nomatch_^ * Default extensions included: gles2 * Additional extensions included: _nomatch_^ * Extensions removed: _nomatch_^ */ #ifndef GL_KHR_blend_equation_advanced #define GL_KHR_blend_equation_advanced 1 #define GL_MULTIPLY_KHR 0x9294 #define GL_SCREEN_KHR 0x9295 #define GL_OVERLAY_KHR 0x9296 #define GL_DARKEN_KHR 0x9297 #define GL_LIGHTEN_KHR 0x9298 #define GL_COLORDODGE_KHR 0x9299 #define GL_COLORBURN_KHR 0x929A #define GL_HARDLIGHT_KHR 0x929B #define GL_SOFTLIGHT_KHR 0x929C #define GL_DIFFERENCE_KHR 0x929E #define GL_EXCLUSION_KHR 0x92A0 #define GL_HSL_HUE_KHR 0x92AD #define GL_HSL_SATURATION_KHR 0x92AE #define GL_HSL_COLOR_KHR 0x92AF #define GL_HSL_LUMINOSITY_KHR 0x92B0 typedef void (GL_APIENTRYP PFNGLBLENDBARRIERKHRPROC) (void); #ifdef GL_GLEXT_PROTOTYPES GL_APICALL void GL_APIENTRY glBlendBarrierKHR (void); #endif #endif /* GL_KHR_blend_equation_advanced */ #ifndef GL_KHR_blend_equation_advanced_coherent #define GL_KHR_blend_equation_advanced_coherent 1 #define GL_BLEND_ADVANCED_COHERENT_KHR 0x9285 #endif /* GL_KHR_blend_equation_advanced_coherent */ #ifndef GL_KHR_context_flush_control #define GL_KHR_context_flush_control 1 #define GL_CONTEXT_RELEASE_BEHAVIOR_KHR 0x82FB #define GL_CONTEXT_RELEASE_BEHAVIOR_FLUSH_KHR 0x82FC #endif /* GL_KHR_context_flush_control */ #ifndef GL_KHR_debug #define GL_KHR_debug 1 typedef void (GL_APIENTRY *GLDEBUGPROCKHR)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,const void *userParam); #define GL_SAMPLER 0x82E6 #define GL_DEBUG_OUTPUT_SYNCHRONOUS_KHR 0x8242 #define GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH_KHR 0x8243 #define GL_DEBUG_CALLBACK_FUNCTION_KHR 0x8244 #define GL_DEBUG_CALLBACK_USER_PARAM_KHR 0x8245 #define GL_DEBUG_SOURCE_API_KHR 0x8246 #define GL_DEBUG_SOURCE_WINDOW_SYSTEM_KHR 0x8247 #define GL_DEBUG_SOURCE_SHADER_COMPILER_KHR 0x8248 #define GL_DEBUG_SOURCE_THIRD_PARTY_KHR 0x8249 #define GL_DEBUG_SOURCE_APPLICATION_KHR 0x824A #define GL_DEBUG_SOURCE_OTHER_KHR 0x824B #define GL_DEBUG_TYPE_ERROR_KHR 0x824C #define GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR_KHR 0x824D #define GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR_KHR 0x824E #define GL_DEBUG_TYPE_PORTABILITY_KHR 0x824F #define GL_DEBUG_TYPE_PERFORMANCE_KHR 0x8250 #define GL_DEBUG_TYPE_OTHER_KHR 0x8251 #define GL_DEBUG_TYPE_MARKER_KHR 0x8268 #define GL_DEBUG_TYPE_PUSH_GROUP_KHR 0x8269 #define GL_DEBUG_TYPE_POP_GROUP_KHR 0x826A #define GL_DEBUG_SEVERITY_NOTIFICATION_KHR 0x826B #define GL_MAX_DEBUG_GROUP_STACK_DEPTH_KHR 0x826C #define GL_DEBUG_GROUP_STACK_DEPTH_KHR 0x826D #define GL_BUFFER_KHR 0x82E0 #define GL_SHADER_KHR 0x82E1 #define GL_PROGRAM_KHR 0x82E2 #define GL_VERTEX_ARRAY_KHR 0x8074 #define GL_QUERY_KHR 0x82E3 #define GL_PROGRAM_PIPELINE_KHR 0x82E4 #define GL_SAMPLER_KHR 0x82E6 #define GL_MAX_LABEL_LENGTH_KHR 0x82E8 #define GL_MAX_DEBUG_MESSAGE_LENGTH_KHR 0x9143 #define GL_MAX_DEBUG_LOGGED_MESSAGES_KHR 0x9144 #define GL_DEBUG_LOGGED_MESSAGES_KHR 0x9145 #define GL_DEBUG_SEVERITY_HIGH_KHR 0x9146 #define GL_DEBUG_SEVERITY_MEDIUM_KHR 0x9147 #define GL_DEBUG_SEVERITY_LOW_KHR 0x9148 #define GL_DEBUG_OUTPUT_KHR 0x92E0 #define GL_CONTEXT_FLAG_DEBUG_BIT_KHR 0x00000002 #define GL_STACK_OVERFLOW_KHR 0x0503 #define GL_STACK_UNDERFLOW_KHR 0x0504 typedef void (GL_APIENTRYP PFNGLDEBUGMESSAGECONTROLKHRPROC) (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); typedef void (GL_APIENTRYP PFNGLDEBUGMESSAGEINSERTKHRPROC) (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf); typedef void (GL_APIENTRYP PFNGLDEBUGMESSAGECALLBACKKHRPROC) (GLDEBUGPROCKHR callback, const void *userParam); typedef GLuint (GL_APIENTRYP PFNGLGETDEBUGMESSAGELOGKHRPROC) (GLuint count, GLsizei bufSize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog); typedef void (GL_APIENTRYP PFNGLPUSHDEBUGGROUPKHRPROC) (GLenum source, GLuint id, GLsizei length, const GLchar *message); typedef void (GL_APIENTRYP PFNGLPOPDEBUGGROUPKHRPROC) (void); typedef void (GL_APIENTRYP PFNGLOBJECTLABELKHRPROC) (GLenum identifier, GLuint name, GLsizei length, const GLchar *label); typedef void (GL_APIENTRYP PFNGLGETOBJECTLABELKHRPROC) (GLenum identifier, GLuint name, GLsizei bufSize, GLsizei *length, GLchar *label); typedef void (GL_APIENTRYP PFNGLOBJECTPTRLABELKHRPROC) (const void *ptr, GLsizei length, const GLchar *label); typedef void (GL_APIENTRYP PFNGLGETOBJECTPTRLABELKHRPROC) (const void *ptr, GLsizei bufSize, GLsizei *length, GLchar *label); typedef void (GL_APIENTRYP PFNGLGETPOINTERVKHRPROC) (GLenum pname, void **params); #ifdef GL_GLEXT_PROTOTYPES GL_APICALL void GL_APIENTRY glDebugMessageControlKHR (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); GL_APICALL void GL_APIENTRY glDebugMessageInsertKHR (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf); GL_APICALL void GL_APIENTRY glDebugMessageCallbackKHR (GLDEBUGPROCKHR callback, const void *userParam); GL_APICALL GLuint GL_APIENTRY glGetDebugMessageLogKHR (GLuint count, GLsizei bufSize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog); GL_APICALL void GL_APIENTRY glPushDebugGroupKHR (GLenum source, GLuint id, GLsizei length, const GLchar *message); GL_APICALL void GL_APIENTRY glPopDebugGroupKHR (void); GL_APICALL void GL_APIENTRY glObjectLabelKHR (GLenum identifier, GLuint name, GLsizei length, const GLchar *label); GL_APICALL void GL_APIENTRY glGetObjectLabelKHR (GLenum identifier, GLuint name, GLsizei bufSize, GLsizei *length, GLchar *label); GL_APICALL void GL_APIENTRY glObjectPtrLabelKHR (const void *ptr, GLsizei length, const GLchar *label); GL_APICALL void GL_APIENTRY glGetObjectPtrLabelKHR (const void *ptr, GLsizei bufSize, GLsizei *length, GLchar *label); GL_APICALL void GL_APIENTRY glGetPointervKHR (GLenum pname, void **params); #endif #endif /* GL_KHR_debug */ #ifndef GL_KHR_no_error #define GL_KHR_no_error 1 #define GL_CONTEXT_FLAG_NO_ERROR_BIT_KHR 0x00000008 #endif /* GL_KHR_no_error */ #ifndef GL_KHR_parallel_shader_compile #define GL_KHR_parallel_shader_compile 1 #define GL_MAX_SHADER_COMPILER_THREADS_KHR 0x91B0 #define GL_COMPLETION_STATUS_KHR 0x91B1 typedef void (GL_APIENTRYP PFNGLMAXSHADERCOMPILERTHREADSKHRPROC) (GLuint count); #ifdef GL_GLEXT_PROTOTYPES GL_APICALL void GL_APIENTRY glMaxShaderCompilerThreadsKHR (GLuint count); #endif #endif /* GL_KHR_parallel_shader_compile */ #ifndef GL_KHR_robust_buffer_access_behavior #define GL_KHR_robust_buffer_access_behavior 1 #endif /* GL_KHR_robust_buffer_access_behavior */ #ifndef GL_KHR_robustness #define GL_KHR_robustness 1 #define GL_CONTEXT_ROBUST_ACCESS_KHR 0x90F3 #define GL_LOSE_CONTEXT_ON_RESET_KHR 0x8252 #define GL_GUILTY_CONTEXT_RESET_KHR 0x8253 #define GL_INNOCENT_CONTEXT_RESET_KHR 0x8254 #define GL_UNKNOWN_CONTEXT_RESET_KHR 0x8255 #define GL_RESET_NOTIFICATION_STRATEGY_KHR 0x8256 #define GL_NO_RESET_NOTIFICATION_KHR 0x8261 #define GL_CONTEXT_LOST_KHR 0x0507 typedef GLenum (GL_APIENTRYP PFNGLGETGRAPHICSRESETSTATUSKHRPROC) (void); typedef void (GL_APIENTRYP PFNGLREADNPIXELSKHRPROC) (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei bufSize, void *data); typedef void (GL_APIENTRYP PFNGLGETNUNIFORMFVKHRPROC) (GLuint program, GLint location, GLsizei bufSize, GLfloat *params); typedef void (GL_APIENTRYP PFNGLGETNUNIFORMIVKHRPROC) (GLuint program, GLint location, GLsizei bufSize, GLint *params); typedef void (GL_APIENTRYP PFNGLGETNUNIFORMUIVKHRPROC) (GLuint program, GLint location, GLsizei bufSize, GLuint *params); #ifdef GL_GLEXT_PROTOTYPES GL_APICALL GLenum GL_APIENTRY glGetGraphicsResetStatusKHR (void); GL_APICALL void GL_APIENTRY glReadnPixelsKHR (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei bufSize, void *data); GL_APICALL void GL_APIENTRY glGetnUniformfvKHR (GLuint program, GLint location, GLsizei bufSize, GLfloat *params); GL_APICALL void GL_APIENTRY glGetnUniformivKHR (GLuint program, GLint location, GLsizei bufSize, GLint *params); GL_APICALL void GL_APIENTRY glGetnUniformuivKHR (GLuint program, GLint location, GLsizei bufSize, GLuint *params); #endif #endif /* GL_KHR_robustness */ #ifndef GL_KHR_shader_subgroup #define GL_KHR_shader_subgroup 1 #define GL_SUBGROUP_SIZE_KHR 0x9532 #define GL_SUBGROUP_SUPPORTED_STAGES_KHR 0x9533 #define GL_SUBGROUP_SUPPORTED_FEATURES_KHR 0x9534 #define GL_SUBGROUP_QUAD_ALL_STAGES_KHR 0x9535 #define GL_SUBGROUP_FEATURE_BASIC_BIT_KHR 0x00000001 #define GL_SUBGROUP_FEATURE_VOTE_BIT_KHR 0x00000002 #define GL_SUBGROUP_FEATURE_ARITHMETIC_BIT_KHR 0x00000004 #define GL_SUBGROUP_FEATURE_BALLOT_BIT_KHR 0x00000008 #define GL_SUBGROUP_FEATURE_SHUFFLE_BIT_KHR 0x00000010 #define GL_SUBGROUP_FEATURE_SHUFFLE_RELATIVE_BIT_KHR 0x00000020 #define GL_SUBGROUP_FEATURE_CLUSTERED_BIT_KHR 0x00000040 #define GL_SUBGROUP_FEATURE_QUAD_BIT_KHR 0x00000080 #endif /* GL_KHR_shader_subgroup */ #ifndef GL_KHR_texture_compression_astc_hdr #define GL_KHR_texture_compression_astc_hdr 1 #define GL_COMPRESSED_RGBA_ASTC_4x4_KHR 0x93B0 #define GL_COMPRESSED_RGBA_ASTC_5x4_KHR 0x93B1 #define GL_COMPRESSED_RGBA_ASTC_5x5_KHR 0x93B2 #define GL_COMPRESSED_RGBA_ASTC_6x5_KHR 0x93B3 #define GL_COMPRESSED_RGBA_ASTC_6x6_KHR 0x93B4 #define GL_COMPRESSED_RGBA_ASTC_8x5_KHR 0x93B5 #define GL_COMPRESSED_RGBA_ASTC_8x6_KHR 0x93B6 #define GL_COMPRESSED_RGBA_ASTC_8x8_KHR 0x93B7 #define GL_COMPRESSED_RGBA_ASTC_10x5_KHR 0x93B8 #define GL_COMPRESSED_RGBA_ASTC_10x6_KHR 0x93B9 #define GL_COMPRESSED_RGBA_ASTC_10x8_KHR 0x93BA #define GL_COMPRESSED_RGBA_ASTC_10x10_KHR 0x93BB #define GL_COMPRESSED_RGBA_ASTC_12x10_KHR 0x93BC #define GL_COMPRESSED_RGBA_ASTC_12x12_KHR 0x93BD #define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR 0x93D0 #define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR 0x93D1 #define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR 0x93D2 #define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR 0x93D3 #define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR 0x93D4 #define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR 0x93D5 #define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR 0x93D6 #define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR 0x93D7 #define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR 0x93D8 #define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR 0x93D9 #define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR 0x93DA #define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR 0x93DB #define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR 0x93DC #define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR 0x93DD #endif /* GL_KHR_texture_compression_astc_hdr */ #ifndef GL_KHR_texture_compression_astc_ldr #define GL_KHR_texture_compression_astc_ldr 1 #endif /* GL_KHR_texture_compression_astc_ldr */ #ifndef GL_KHR_texture_compression_astc_sliced_3d #define GL_KHR_texture_compression_astc_sliced_3d 1 #endif /* GL_KHR_texture_compression_astc_sliced_3d */ #ifndef GL_OES_EGL_image #define GL_OES_EGL_image 1 typedef void *GLeglImageOES; typedef void (GL_APIENTRYP PFNGLEGLIMAGETARGETTEXTURE2DOESPROC) (GLenum target, GLeglImageOES image); typedef void (GL_APIENTRYP PFNGLEGLIMAGETARGETRENDERBUFFERSTORAGEOESPROC) (GLenum target, GLeglImageOES image); #ifdef GL_GLEXT_PROTOTYPES GL_APICALL void GL_APIENTRY glEGLImageTargetTexture2DOES (GLenum target, GLeglImageOES image); GL_APICALL void GL_APIENTRY glEGLImageTargetRenderbufferStorageOES (GLenum target, GLeglImageOES image); #endif #endif /* GL_OES_EGL_image */ #ifndef GL_OES_EGL_image_external #define GL_OES_EGL_image_external 1 #define GL_TEXTURE_EXTERNAL_OES 0x8D65 #define GL_TEXTURE_BINDING_EXTERNAL_OES 0x8D67 #define GL_REQUIRED_TEXTURE_IMAGE_UNITS_OES 0x8D68 #define GL_SAMPLER_EXTERNAL_OES 0x8D66 #endif /* GL_OES_EGL_image_external */ #ifndef GL_OES_EGL_image_external_essl3 #define GL_OES_EGL_image_external_essl3 1 #endif /* GL_OES_EGL_image_external_essl3 */ #ifndef GL_OES_compressed_ETC1_RGB8_sub_texture #define GL_OES_compressed_ETC1_RGB8_sub_texture 1 #endif /* GL_OES_compressed_ETC1_RGB8_sub_texture */ #ifndef GL_OES_compressed_ETC1_RGB8_texture #define GL_OES_compressed_ETC1_RGB8_texture 1 #define GL_ETC1_RGB8_OES 0x8D64 #endif /* GL_OES_compressed_ETC1_RGB8_texture */ #ifndef GL_OES_compressed_paletted_texture #define GL_OES_compressed_paletted_texture 1 #define GL_PALETTE4_RGB8_OES 0x8B90 #define GL_PALETTE4_RGBA8_OES 0x8B91 #define GL_PALETTE4_R5_G6_B5_OES 0x8B92 #define GL_PALETTE4_RGBA4_OES 0x8B93 #define GL_PALETTE4_RGB5_A1_OES 0x8B94 #define GL_PALETTE8_RGB8_OES 0x8B95 #define GL_PALETTE8_RGBA8_OES 0x8B96 #define GL_PALETTE8_R5_G6_B5_OES 0x8B97 #define GL_PALETTE8_RGBA4_OES 0x8B98 #define GL_PALETTE8_RGB5_A1_OES 0x8B99 #endif /* GL_OES_compressed_paletted_texture */ #ifndef GL_OES_copy_image #define GL_OES_copy_image 1 typedef void (GL_APIENTRYP PFNGLCOPYIMAGESUBDATAOESPROC) (GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei srcWidth, GLsizei srcHeight, GLsizei srcDepth); #ifdef GL_GLEXT_PROTOTYPES GL_APICALL void GL_APIENTRY glCopyImageSubDataOES (GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei srcWidth, GLsizei srcHeight, GLsizei srcDepth); #endif #endif /* GL_OES_copy_image */ #ifndef GL_OES_depth24 #define GL_OES_depth24 1 #define GL_DEPTH_COMPONENT24_OES 0x81A6 #endif /* GL_OES_depth24 */ #ifndef GL_OES_depth32 #define GL_OES_depth32 1 #define GL_DEPTH_COMPONENT32_OES 0x81A7 #endif /* GL_OES_depth32 */ #ifndef GL_OES_depth_texture #define GL_OES_depth_texture 1 #endif /* GL_OES_depth_texture */ #ifndef GL_OES_draw_buffers_indexed #define GL_OES_draw_buffers_indexed 1 #define GL_MIN 0x8007 #define GL_MAX 0x8008 typedef void (GL_APIENTRYP PFNGLENABLEIOESPROC) (GLenum target, GLuint index); typedef void (GL_APIENTRYP PFNGLDISABLEIOESPROC) (GLenum target, GLuint index); typedef void (GL_APIENTRYP PFNGLBLENDEQUATIONIOESPROC) (GLuint buf, GLenum mode); typedef void (GL_APIENTRYP PFNGLBLENDEQUATIONSEPARATEIOESPROC) (GLuint buf, GLenum modeRGB, GLenum modeAlpha); typedef void (GL_APIENTRYP PFNGLBLENDFUNCIOESPROC) (GLuint buf, GLenum src, GLenum dst); typedef void (GL_APIENTRYP PFNGLBLENDFUNCSEPARATEIOESPROC) (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); typedef void (GL_APIENTRYP PFNGLCOLORMASKIOESPROC) (GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a); typedef GLboolean (GL_APIENTRYP PFNGLISENABLEDIOESPROC) (GLenum target, GLuint index); #ifdef GL_GLEXT_PROTOTYPES GL_APICALL void GL_APIENTRY glEnableiOES (GLenum target, GLuint index); GL_APICALL void GL_APIENTRY glDisableiOES (GLenum target, GLuint index); GL_APICALL void GL_APIENTRY glBlendEquationiOES (GLuint buf, GLenum mode); GL_APICALL void GL_APIENTRY glBlendEquationSeparateiOES (GLuint buf, GLenum modeRGB, GLenum modeAlpha); GL_APICALL void GL_APIENTRY glBlendFunciOES (GLuint buf, GLenum src, GLenum dst); GL_APICALL void GL_APIENTRY glBlendFuncSeparateiOES (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); GL_APICALL void GL_APIENTRY glColorMaskiOES (GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a); GL_APICALL GLboolean GL_APIENTRY glIsEnablediOES (GLenum target, GLuint index); #endif #endif /* GL_OES_draw_buffers_indexed */ #ifndef GL_OES_draw_elements_base_vertex #define GL_OES_draw_elements_base_vertex 1 typedef void (GL_APIENTRYP PFNGLDRAWELEMENTSBASEVERTEXOESPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLint basevertex); typedef void (GL_APIENTRYP PFNGLDRAWRANGEELEMENTSBASEVERTEXOESPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void *indices, GLint basevertex); typedef void (GL_APIENTRYP PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXOESPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLint basevertex); typedef void (GL_APIENTRYP PFNGLMULTIDRAWELEMENTSBASEVERTEXEXTPROC) (GLenum mode, const GLsizei *count, GLenum type, const void *const*indices, GLsizei drawcount, const GLint *basevertex); #ifdef GL_GLEXT_PROTOTYPES GL_APICALL void GL_APIENTRY glDrawElementsBaseVertexOES (GLenum mode, GLsizei count, GLenum type, const void *indices, GLint basevertex); GL_APICALL void GL_APIENTRY glDrawRangeElementsBaseVertexOES (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void *indices, GLint basevertex); GL_APICALL void GL_APIENTRY glDrawElementsInstancedBaseVertexOES (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLint basevertex); GL_APICALL void GL_APIENTRY glMultiDrawElementsBaseVertexEXT (GLenum mode, const GLsizei *count, GLenum type, const void *const*indices, GLsizei drawcount, const GLint *basevertex); #endif #endif /* GL_OES_draw_elements_base_vertex */ #ifndef GL_OES_element_index_uint #define GL_OES_element_index_uint 1 #endif /* GL_OES_element_index_uint */ #ifndef GL_OES_fbo_render_mipmap #define GL_OES_fbo_render_mipmap 1 #endif /* GL_OES_fbo_render_mipmap */ #ifndef GL_OES_fragment_precision_high #define GL_OES_fragment_precision_high 1 #endif /* GL_OES_fragment_precision_high */ #ifndef GL_OES_geometry_point_size #define GL_OES_geometry_point_size 1 #endif /* GL_OES_geometry_point_size */ #ifndef GL_OES_geometry_shader #define GL_OES_geometry_shader 1 #define GL_GEOMETRY_SHADER_OES 0x8DD9 #define GL_GEOMETRY_SHADER_BIT_OES 0x00000004 #define GL_GEOMETRY_LINKED_VERTICES_OUT_OES 0x8916 #define GL_GEOMETRY_LINKED_INPUT_TYPE_OES 0x8917 #define GL_GEOMETRY_LINKED_OUTPUT_TYPE_OES 0x8918 #define GL_GEOMETRY_SHADER_INVOCATIONS_OES 0x887F #define GL_LAYER_PROVOKING_VERTEX_OES 0x825E #define GL_LINES_ADJACENCY_OES 0x000A #define GL_LINE_STRIP_ADJACENCY_OES 0x000B #define GL_TRIANGLES_ADJACENCY_OES 0x000C #define GL_TRIANGLE_STRIP_ADJACENCY_OES 0x000D #define GL_MAX_GEOMETRY_UNIFORM_COMPONENTS_OES 0x8DDF #define GL_MAX_GEOMETRY_UNIFORM_BLOCKS_OES 0x8A2C #define GL_MAX_COMBINED_GEOMETRY_UNIFORM_COMPONENTS_OES 0x8A32 #define GL_MAX_GEOMETRY_INPUT_COMPONENTS_OES 0x9123 #define GL_MAX_GEOMETRY_OUTPUT_COMPONENTS_OES 0x9124 #define GL_MAX_GEOMETRY_OUTPUT_VERTICES_OES 0x8DE0 #define GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS_OES 0x8DE1 #define GL_MAX_GEOMETRY_SHADER_INVOCATIONS_OES 0x8E5A #define GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_OES 0x8C29 #define GL_MAX_GEOMETRY_ATOMIC_COUNTER_BUFFERS_OES 0x92CF #define GL_MAX_GEOMETRY_ATOMIC_COUNTERS_OES 0x92D5 #define GL_MAX_GEOMETRY_IMAGE_UNIFORMS_OES 0x90CD #define GL_MAX_GEOMETRY_SHADER_STORAGE_BLOCKS_OES 0x90D7 #define GL_FIRST_VERTEX_CONVENTION_OES 0x8E4D #define GL_LAST_VERTEX_CONVENTION_OES 0x8E4E #define GL_UNDEFINED_VERTEX_OES 0x8260 #define GL_PRIMITIVES_GENERATED_OES 0x8C87 #define GL_FRAMEBUFFER_DEFAULT_LAYERS_OES 0x9312 #define GL_MAX_FRAMEBUFFER_LAYERS_OES 0x9317 #define GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS_OES 0x8DA8 #define GL_FRAMEBUFFER_ATTACHMENT_LAYERED_OES 0x8DA7 #define GL_REFERENCED_BY_GEOMETRY_SHADER_OES 0x9309 typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERTEXTUREOESPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level); #ifdef GL_GLEXT_PROTOTYPES GL_APICALL void GL_APIENTRY glFramebufferTextureOES (GLenum target, GLenum attachment, GLuint texture, GLint level); #endif #endif /* GL_OES_geometry_shader */ #ifndef GL_OES_get_program_binary #define GL_OES_get_program_binary 1 #define GL_PROGRAM_BINARY_LENGTH_OES 0x8741 #define GL_NUM_PROGRAM_BINARY_FORMATS_OES 0x87FE #define GL_PROGRAM_BINARY_FORMATS_OES 0x87FF typedef void (GL_APIENTRYP PFNGLGETPROGRAMBINARYOESPROC) (GLuint program, GLsizei bufSize, GLsizei *length, GLenum *binaryFormat, void *binary); typedef void (GL_APIENTRYP PFNGLPROGRAMBINARYOESPROC) (GLuint program, GLenum binaryFormat, const void *binary, GLint length); #ifdef GL_GLEXT_PROTOTYPES GL_APICALL void GL_APIENTRY glGetProgramBinaryOES (GLuint program, GLsizei bufSize, GLsizei *length, GLenum *binaryFormat, void *binary); GL_APICALL void GL_APIENTRY glProgramBinaryOES (GLuint program, GLenum binaryFormat, const void *binary, GLint length); #endif #endif /* GL_OES_get_program_binary */ #ifndef GL_OES_gpu_shader5 #define GL_OES_gpu_shader5 1 #endif /* GL_OES_gpu_shader5 */ #ifndef GL_OES_mapbuffer #define GL_OES_mapbuffer 1 #define GL_WRITE_ONLY_OES 0x88B9 #define GL_BUFFER_ACCESS_OES 0x88BB #define GL_BUFFER_MAPPED_OES 0x88BC #define GL_BUFFER_MAP_POINTER_OES 0x88BD typedef void *(GL_APIENTRYP PFNGLMAPBUFFEROESPROC) (GLenum target, GLenum access); typedef GLboolean (GL_APIENTRYP PFNGLUNMAPBUFFEROESPROC) (GLenum target); typedef void (GL_APIENTRYP PFNGLGETBUFFERPOINTERVOESPROC) (GLenum target, GLenum pname, void **params); #ifdef GL_GLEXT_PROTOTYPES GL_APICALL void *GL_APIENTRY glMapBufferOES (GLenum target, GLenum access); GL_APICALL GLboolean GL_APIENTRY glUnmapBufferOES (GLenum target); GL_APICALL void GL_APIENTRY glGetBufferPointervOES (GLenum target, GLenum pname, void **params); #endif #endif /* GL_OES_mapbuffer */ #ifndef GL_OES_packed_depth_stencil #define GL_OES_packed_depth_stencil 1 #define GL_DEPTH_STENCIL_OES 0x84F9 #define GL_UNSIGNED_INT_24_8_OES 0x84FA #define GL_DEPTH24_STENCIL8_OES 0x88F0 #endif /* GL_OES_packed_depth_stencil */ #ifndef GL_OES_primitive_bounding_box #define GL_OES_primitive_bounding_box 1 #define GL_PRIMITIVE_BOUNDING_BOX_OES 0x92BE typedef void (GL_APIENTRYP PFNGLPRIMITIVEBOUNDINGBOXOESPROC) (GLfloat minX, GLfloat minY, GLfloat minZ, GLfloat minW, GLfloat maxX, GLfloat maxY, GLfloat maxZ, GLfloat maxW); #ifdef GL_GLEXT_PROTOTYPES GL_APICALL void GL_APIENTRY glPrimitiveBoundingBoxOES (GLfloat minX, GLfloat minY, GLfloat minZ, GLfloat minW, GLfloat maxX, GLfloat maxY, GLfloat maxZ, GLfloat maxW); #endif #endif /* GL_OES_primitive_bounding_box */ #ifndef GL_OES_required_internalformat #define GL_OES_required_internalformat 1 #define GL_ALPHA8_OES 0x803C #define GL_DEPTH_COMPONENT16_OES 0x81A5 #define GL_LUMINANCE4_ALPHA4_OES 0x8043 #define GL_LUMINANCE8_ALPHA8_OES 0x8045 #define GL_LUMINANCE8_OES 0x8040 #define GL_RGBA4_OES 0x8056 #define GL_RGB5_A1_OES 0x8057 #define GL_RGB565_OES 0x8D62 #define GL_RGB8_OES 0x8051 #define GL_RGBA8_OES 0x8058 #define GL_RGB10_EXT 0x8052 #define GL_RGB10_A2_EXT 0x8059 #endif /* GL_OES_required_internalformat */ #ifndef GL_OES_rgb8_rgba8 #define GL_OES_rgb8_rgba8 1 #endif /* GL_OES_rgb8_rgba8 */ #ifndef GL_OES_sample_shading #define GL_OES_sample_shading 1 #define GL_SAMPLE_SHADING_OES 0x8C36 #define GL_MIN_SAMPLE_SHADING_VALUE_OES 0x8C37 typedef void (GL_APIENTRYP PFNGLMINSAMPLESHADINGOESPROC) (GLfloat value); #ifdef GL_GLEXT_PROTOTYPES GL_APICALL void GL_APIENTRY glMinSampleShadingOES (GLfloat value); #endif #endif /* GL_OES_sample_shading */ #ifndef GL_OES_sample_variables #define GL_OES_sample_variables 1 #endif /* GL_OES_sample_variables */ #ifndef GL_OES_shader_image_atomic #define GL_OES_shader_image_atomic 1 #endif /* GL_OES_shader_image_atomic */ #ifndef GL_OES_shader_io_blocks #define GL_OES_shader_io_blocks 1 #endif /* GL_OES_shader_io_blocks */ #ifndef GL_OES_shader_multisample_interpolation #define GL_OES_shader_multisample_interpolation 1 #define GL_MIN_FRAGMENT_INTERPOLATION_OFFSET_OES 0x8E5B #define GL_MAX_FRAGMENT_INTERPOLATION_OFFSET_OES 0x8E5C #define GL_FRAGMENT_INTERPOLATION_OFFSET_BITS_OES 0x8E5D #endif /* GL_OES_shader_multisample_interpolation */ #ifndef GL_OES_standard_derivatives #define GL_OES_standard_derivatives 1 #define GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES 0x8B8B #endif /* GL_OES_standard_derivatives */ #ifndef GL_OES_stencil1 #define GL_OES_stencil1 1 #define GL_STENCIL_INDEX1_OES 0x8D46 #endif /* GL_OES_stencil1 */ #ifndef GL_OES_stencil4 #define GL_OES_stencil4 1 #define GL_STENCIL_INDEX4_OES 0x8D47 #endif /* GL_OES_stencil4 */ #ifndef GL_OES_surfaceless_context #define GL_OES_surfaceless_context 1 #define GL_FRAMEBUFFER_UNDEFINED_OES 0x8219 #endif /* GL_OES_surfaceless_context */ #ifndef GL_OES_tessellation_point_size #define GL_OES_tessellation_point_size 1 #endif /* GL_OES_tessellation_point_size */ #ifndef GL_OES_tessellation_shader #define GL_OES_tessellation_shader 1 #define GL_PATCHES_OES 0x000E #define GL_PATCH_VERTICES_OES 0x8E72 #define GL_TESS_CONTROL_OUTPUT_VERTICES_OES 0x8E75 #define GL_TESS_GEN_MODE_OES 0x8E76 #define GL_TESS_GEN_SPACING_OES 0x8E77 #define GL_TESS_GEN_VERTEX_ORDER_OES 0x8E78 #define GL_TESS_GEN_POINT_MODE_OES 0x8E79 #define GL_ISOLINES_OES 0x8E7A #define GL_QUADS_OES 0x0007 #define GL_FRACTIONAL_ODD_OES 0x8E7B #define GL_FRACTIONAL_EVEN_OES 0x8E7C #define GL_MAX_PATCH_VERTICES_OES 0x8E7D #define GL_MAX_TESS_GEN_LEVEL_OES 0x8E7E #define GL_MAX_TESS_CONTROL_UNIFORM_COMPONENTS_OES 0x8E7F #define GL_MAX_TESS_EVALUATION_UNIFORM_COMPONENTS_OES 0x8E80 #define GL_MAX_TESS_CONTROL_TEXTURE_IMAGE_UNITS_OES 0x8E81 #define GL_MAX_TESS_EVALUATION_TEXTURE_IMAGE_UNITS_OES 0x8E82 #define GL_MAX_TESS_CONTROL_OUTPUT_COMPONENTS_OES 0x8E83 #define GL_MAX_TESS_PATCH_COMPONENTS_OES 0x8E84 #define GL_MAX_TESS_CONTROL_TOTAL_OUTPUT_COMPONENTS_OES 0x8E85 #define GL_MAX_TESS_EVALUATION_OUTPUT_COMPONENTS_OES 0x8E86 #define GL_MAX_TESS_CONTROL_UNIFORM_BLOCKS_OES 0x8E89 #define GL_MAX_TESS_EVALUATION_UNIFORM_BLOCKS_OES 0x8E8A #define GL_MAX_TESS_CONTROL_INPUT_COMPONENTS_OES 0x886C #define GL_MAX_TESS_EVALUATION_INPUT_COMPONENTS_OES 0x886D #define GL_MAX_COMBINED_TESS_CONTROL_UNIFORM_COMPONENTS_OES 0x8E1E #define GL_MAX_COMBINED_TESS_EVALUATION_UNIFORM_COMPONENTS_OES 0x8E1F #define GL_MAX_TESS_CONTROL_ATOMIC_COUNTER_BUFFERS_OES 0x92CD #define GL_MAX_TESS_EVALUATION_ATOMIC_COUNTER_BUFFERS_OES 0x92CE #define GL_MAX_TESS_CONTROL_ATOMIC_COUNTERS_OES 0x92D3 #define GL_MAX_TESS_EVALUATION_ATOMIC_COUNTERS_OES 0x92D4 #define GL_MAX_TESS_CONTROL_IMAGE_UNIFORMS_OES 0x90CB #define GL_MAX_TESS_EVALUATION_IMAGE_UNIFORMS_OES 0x90CC #define GL_MAX_TESS_CONTROL_SHADER_STORAGE_BLOCKS_OES 0x90D8 #define GL_MAX_TESS_EVALUATION_SHADER_STORAGE_BLOCKS_OES 0x90D9 #define GL_PRIMITIVE_RESTART_FOR_PATCHES_SUPPORTED_OES 0x8221 #define GL_IS_PER_PATCH_OES 0x92E7 #define GL_REFERENCED_BY_TESS_CONTROL_SHADER_OES 0x9307 #define GL_REFERENCED_BY_TESS_EVALUATION_SHADER_OES 0x9308 #define GL_TESS_CONTROL_SHADER_OES 0x8E88 #define GL_TESS_EVALUATION_SHADER_OES 0x8E87 #define GL_TESS_CONTROL_SHADER_BIT_OES 0x00000008 #define GL_TESS_EVALUATION_SHADER_BIT_OES 0x00000010 typedef void (GL_APIENTRYP PFNGLPATCHPARAMETERIOESPROC) (GLenum pname, GLint value); #ifdef GL_GLEXT_PROTOTYPES GL_APICALL void GL_APIENTRY glPatchParameteriOES (GLenum pname, GLint value); #endif #endif /* GL_OES_tessellation_shader */ #ifndef GL_OES_texture_3D #define GL_OES_texture_3D 1 #define GL_TEXTURE_WRAP_R_OES 0x8072 #define GL_TEXTURE_3D_OES 0x806F #define GL_TEXTURE_BINDING_3D_OES 0x806A #define GL_MAX_3D_TEXTURE_SIZE_OES 0x8073 #define GL_SAMPLER_3D_OES 0x8B5F #define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_OES 0x8CD4 typedef void (GL_APIENTRYP PFNGLTEXIMAGE3DOESPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void *pixels); typedef void (GL_APIENTRYP PFNGLTEXSUBIMAGE3DOESPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels); typedef void (GL_APIENTRYP PFNGLCOPYTEXSUBIMAGE3DOESPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); typedef void (GL_APIENTRYP PFNGLCOMPRESSEDTEXIMAGE3DOESPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void *data); typedef void (GL_APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE3DOESPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *data); typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERTEXTURE3DOESPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); #ifdef GL_GLEXT_PROTOTYPES GL_APICALL void GL_APIENTRY glTexImage3DOES (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void *pixels); GL_APICALL void GL_APIENTRY glTexSubImage3DOES (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels); GL_APICALL void GL_APIENTRY glCopyTexSubImage3DOES (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); GL_APICALL void GL_APIENTRY glCompressedTexImage3DOES (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void *data); GL_APICALL void GL_APIENTRY glCompressedTexSubImage3DOES (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *data); GL_APICALL void GL_APIENTRY glFramebufferTexture3DOES (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); #endif #endif /* GL_OES_texture_3D */ #ifndef GL_OES_texture_border_clamp #define GL_OES_texture_border_clamp 1 #define GL_TEXTURE_BORDER_COLOR_OES 0x1004 #define GL_CLAMP_TO_BORDER_OES 0x812D typedef void (GL_APIENTRYP PFNGLTEXPARAMETERIIVOESPROC) (GLenum target, GLenum pname, const GLint *params); typedef void (GL_APIENTRYP PFNGLTEXPARAMETERIUIVOESPROC) (GLenum target, GLenum pname, const GLuint *params); typedef void (GL_APIENTRYP PFNGLGETTEXPARAMETERIIVOESPROC) (GLenum target, GLenum pname, GLint *params); typedef void (GL_APIENTRYP PFNGLGETTEXPARAMETERIUIVOESPROC) (GLenum target, GLenum pname, GLuint *params); typedef void (GL_APIENTRYP PFNGLSAMPLERPARAMETERIIVOESPROC) (GLuint sampler, GLenum pname, const GLint *param); typedef void (GL_APIENTRYP PFNGLSAMPLERPARAMETERIUIVOESPROC) (GLuint sampler, GLenum pname, const GLuint *param); typedef void (GL_APIENTRYP PFNGLGETSAMPLERPARAMETERIIVOESPROC) (GLuint sampler, GLenum pname, GLint *params); typedef void (GL_APIENTRYP PFNGLGETSAMPLERPARAMETERIUIVOESPROC) (GLuint sampler, GLenum pname, GLuint *params); #ifdef GL_GLEXT_PROTOTYPES GL_APICALL void GL_APIENTRY glTexParameterIivOES (GLenum target, GLenum pname, const GLint *params); GL_APICALL void GL_APIENTRY glTexParameterIuivOES (GLenum target, GLenum pname, const GLuint *params); GL_APICALL void GL_APIENTRY glGetTexParameterIivOES (GLenum target, GLenum pname, GLint *params); GL_APICALL void GL_APIENTRY glGetTexParameterIuivOES (GLenum target, GLenum pname, GLuint *params); GL_APICALL void GL_APIENTRY glSamplerParameterIivOES (GLuint sampler, GLenum pname, const GLint *param); GL_APICALL void GL_APIENTRY glSamplerParameterIuivOES (GLuint sampler, GLenum pname, const GLuint *param); GL_APICALL void GL_APIENTRY glGetSamplerParameterIivOES (GLuint sampler, GLenum pname, GLint *params); GL_APICALL void GL_APIENTRY glGetSamplerParameterIuivOES (GLuint sampler, GLenum pname, GLuint *params); #endif #endif /* GL_OES_texture_border_clamp */ #ifndef GL_OES_texture_buffer #define GL_OES_texture_buffer 1 #define GL_TEXTURE_BUFFER_OES 0x8C2A #define GL_TEXTURE_BUFFER_BINDING_OES 0x8C2A #define GL_MAX_TEXTURE_BUFFER_SIZE_OES 0x8C2B #define GL_TEXTURE_BINDING_BUFFER_OES 0x8C2C #define GL_TEXTURE_BUFFER_DATA_STORE_BINDING_OES 0x8C2D #define GL_TEXTURE_BUFFER_OFFSET_ALIGNMENT_OES 0x919F #define GL_SAMPLER_BUFFER_OES 0x8DC2 #define GL_INT_SAMPLER_BUFFER_OES 0x8DD0 #define GL_UNSIGNED_INT_SAMPLER_BUFFER_OES 0x8DD8 #define GL_IMAGE_BUFFER_OES 0x9051 #define GL_INT_IMAGE_BUFFER_OES 0x905C #define GL_UNSIGNED_INT_IMAGE_BUFFER_OES 0x9067 #define GL_TEXTURE_BUFFER_OFFSET_OES 0x919D #define GL_TEXTURE_BUFFER_SIZE_OES 0x919E typedef void (GL_APIENTRYP PFNGLTEXBUFFEROESPROC) (GLenum target, GLenum internalformat, GLuint buffer); typedef void (GL_APIENTRYP PFNGLTEXBUFFERRANGEOESPROC) (GLenum target, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size); #ifdef GL_GLEXT_PROTOTYPES GL_APICALL void GL_APIENTRY glTexBufferOES (GLenum target, GLenum internalformat, GLuint buffer); GL_APICALL void GL_APIENTRY glTexBufferRangeOES (GLenum target, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size); #endif #endif /* GL_OES_texture_buffer */ #ifndef GL_OES_texture_compression_astc #define GL_OES_texture_compression_astc 1 #define GL_COMPRESSED_RGBA_ASTC_3x3x3_OES 0x93C0 #define GL_COMPRESSED_RGBA_ASTC_4x3x3_OES 0x93C1 #define GL_COMPRESSED_RGBA_ASTC_4x4x3_OES 0x93C2 #define GL_COMPRESSED_RGBA_ASTC_4x4x4_OES 0x93C3 #define GL_COMPRESSED_RGBA_ASTC_5x4x4_OES 0x93C4 #define GL_COMPRESSED_RGBA_ASTC_5x5x4_OES 0x93C5 #define GL_COMPRESSED_RGBA_ASTC_5x5x5_OES 0x93C6 #define GL_COMPRESSED_RGBA_ASTC_6x5x5_OES 0x93C7 #define GL_COMPRESSED_RGBA_ASTC_6x6x5_OES 0x93C8 #define GL_COMPRESSED_RGBA_ASTC_6x6x6_OES 0x93C9 #define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_3x3x3_OES 0x93E0 #define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x3x3_OES 0x93E1 #define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4x3_OES 0x93E2 #define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4x4_OES 0x93E3 #define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4x4_OES 0x93E4 #define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5x4_OES 0x93E5 #define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5x5_OES 0x93E6 #define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5x5_OES 0x93E7 #define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6x5_OES 0x93E8 #define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6x6_OES 0x93E9 #endif /* GL_OES_texture_compression_astc */ #ifndef GL_OES_texture_cube_map_array #define GL_OES_texture_cube_map_array 1 #define GL_TEXTURE_CUBE_MAP_ARRAY_OES 0x9009 #define GL_TEXTURE_BINDING_CUBE_MAP_ARRAY_OES 0x900A #define GL_SAMPLER_CUBE_MAP_ARRAY_OES 0x900C #define GL_SAMPLER_CUBE_MAP_ARRAY_SHADOW_OES 0x900D #define GL_INT_SAMPLER_CUBE_MAP_ARRAY_OES 0x900E #define GL_UNSIGNED_INT_SAMPLER_CUBE_MAP_ARRAY_OES 0x900F #define GL_IMAGE_CUBE_MAP_ARRAY_OES 0x9054 #define GL_INT_IMAGE_CUBE_MAP_ARRAY_OES 0x905F #define GL_UNSIGNED_INT_IMAGE_CUBE_MAP_ARRAY_OES 0x906A #endif /* GL_OES_texture_cube_map_array */ #ifndef GL_OES_texture_float #define GL_OES_texture_float 1 #endif /* GL_OES_texture_float */ #ifndef GL_OES_texture_float_linear #define GL_OES_texture_float_linear 1 #endif /* GL_OES_texture_float_linear */ #ifndef GL_OES_texture_half_float #define GL_OES_texture_half_float 1 #define GL_HALF_FLOAT_OES 0x8D61 #endif /* GL_OES_texture_half_float */ #ifndef GL_OES_texture_half_float_linear #define GL_OES_texture_half_float_linear 1 #endif /* GL_OES_texture_half_float_linear */ #ifndef GL_OES_texture_npot #define GL_OES_texture_npot 1 #endif /* GL_OES_texture_npot */ #ifndef GL_OES_texture_stencil8 #define GL_OES_texture_stencil8 1 #define GL_STENCIL_INDEX_OES 0x1901 #define GL_STENCIL_INDEX8_OES 0x8D48 #endif /* GL_OES_texture_stencil8 */ #ifndef GL_OES_texture_storage_multisample_2d_array #define GL_OES_texture_storage_multisample_2d_array 1 #define GL_TEXTURE_2D_MULTISAMPLE_ARRAY_OES 0x9102 #define GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY_OES 0x9105 #define GL_SAMPLER_2D_MULTISAMPLE_ARRAY_OES 0x910B #define GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAY_OES 0x910C #define GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY_OES 0x910D typedef void (GL_APIENTRYP PFNGLTEXSTORAGE3DMULTISAMPLEOESPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); #ifdef GL_GLEXT_PROTOTYPES GL_APICALL void GL_APIENTRY glTexStorage3DMultisampleOES (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); #endif #endif /* GL_OES_texture_storage_multisample_2d_array */ #ifndef GL_OES_texture_view #define GL_OES_texture_view 1 #define GL_TEXTURE_VIEW_MIN_LEVEL_OES 0x82DB #define GL_TEXTURE_VIEW_NUM_LEVELS_OES 0x82DC #define GL_TEXTURE_VIEW_MIN_LAYER_OES 0x82DD #define GL_TEXTURE_VIEW_NUM_LAYERS_OES 0x82DE #define GL_TEXTURE_IMMUTABLE_LEVELS 0x82DF typedef void (GL_APIENTRYP PFNGLTEXTUREVIEWOESPROC) (GLuint texture, GLenum target, GLuint origtexture, GLenum internalformat, GLuint minlevel, GLuint numlevels, GLuint minlayer, GLuint numlayers); #ifdef GL_GLEXT_PROTOTYPES GL_APICALL void GL_APIENTRY glTextureViewOES (GLuint texture, GLenum target, GLuint origtexture, GLenum internalformat, GLuint minlevel, GLuint numlevels, GLuint minlayer, GLuint numlayers); #endif #endif /* GL_OES_texture_view */ #ifndef GL_OES_vertex_array_object #define GL_OES_vertex_array_object 1 #define GL_VERTEX_ARRAY_BINDING_OES 0x85B5 typedef void (GL_APIENTRYP PFNGLBINDVERTEXARRAYOESPROC) (GLuint array); typedef void (GL_APIENTRYP PFNGLDELETEVERTEXARRAYSOESPROC) (GLsizei n, const GLuint *arrays); typedef void (GL_APIENTRYP PFNGLGENVERTEXARRAYSOESPROC) (GLsizei n, GLuint *arrays); typedef GLboolean (GL_APIENTRYP PFNGLISVERTEXARRAYOESPROC) (GLuint array); #ifdef GL_GLEXT_PROTOTYPES GL_APICALL void GL_APIENTRY glBindVertexArrayOES (GLuint array); GL_APICALL void GL_APIENTRY glDeleteVertexArraysOES (GLsizei n, const GLuint *arrays); GL_APICALL void GL_APIENTRY glGenVertexArraysOES (GLsizei n, GLuint *arrays); GL_APICALL GLboolean GL_APIENTRY glIsVertexArrayOES (GLuint array); #endif #endif /* GL_OES_vertex_array_object */ #ifndef GL_OES_vertex_half_float #define GL_OES_vertex_half_float 1 #endif /* GL_OES_vertex_half_float */ #ifndef GL_OES_vertex_type_10_10_10_2 #define GL_OES_vertex_type_10_10_10_2 1 #define GL_UNSIGNED_INT_10_10_10_2_OES 0x8DF6 #define GL_INT_10_10_10_2_OES 0x8DF7 #endif /* GL_OES_vertex_type_10_10_10_2 */ #ifndef GL_OES_viewport_array #define GL_OES_viewport_array 1 #define GL_MAX_VIEWPORTS_OES 0x825B #define GL_VIEWPORT_SUBPIXEL_BITS_OES 0x825C #define GL_VIEWPORT_BOUNDS_RANGE_OES 0x825D #define GL_VIEWPORT_INDEX_PROVOKING_VERTEX_OES 0x825F typedef void (GL_APIENTRYP PFNGLVIEWPORTARRAYVOESPROC) (GLuint first, GLsizei count, const GLfloat *v); typedef void (GL_APIENTRYP PFNGLVIEWPORTINDEXEDFOESPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat w, GLfloat h); typedef void (GL_APIENTRYP PFNGLVIEWPORTINDEXEDFVOESPROC) (GLuint index, const GLfloat *v); typedef void (GL_APIENTRYP PFNGLSCISSORARRAYVOESPROC) (GLuint first, GLsizei count, const GLint *v); typedef void (GL_APIENTRYP PFNGLSCISSORINDEXEDOESPROC) (GLuint index, GLint left, GLint bottom, GLsizei width, GLsizei height); typedef void (GL_APIENTRYP PFNGLSCISSORINDEXEDVOESPROC) (GLuint index, const GLint *v); typedef void (GL_APIENTRYP PFNGLDEPTHRANGEARRAYFVOESPROC) (GLuint first, GLsizei count, const GLfloat *v); typedef void (GL_APIENTRYP PFNGLDEPTHRANGEINDEXEDFOESPROC) (GLuint index, GLfloat n, GLfloat f); typedef void (GL_APIENTRYP PFNGLGETFLOATI_VOESPROC) (GLenum target, GLuint index, GLfloat *data); #ifdef GL_GLEXT_PROTOTYPES GL_APICALL void GL_APIENTRY glViewportArrayvOES (GLuint first, GLsizei count, const GLfloat *v); GL_APICALL void GL_APIENTRY glViewportIndexedfOES (GLuint index, GLfloat x, GLfloat y, GLfloat w, GLfloat h); GL_APICALL void GL_APIENTRY glViewportIndexedfvOES (GLuint index, const GLfloat *v); GL_APICALL void GL_APIENTRY glScissorArrayvOES (GLuint first, GLsizei count, const GLint *v); GL_APICALL void GL_APIENTRY glScissorIndexedOES (GLuint index, GLint left, GLint bottom, GLsizei width, GLsizei height); GL_APICALL void GL_APIENTRY glScissorIndexedvOES (GLuint index, const GLint *v); GL_APICALL void GL_APIENTRY glDepthRangeArrayfvOES (GLuint first, GLsizei count, const GLfloat *v); GL_APICALL void GL_APIENTRY glDepthRangeIndexedfOES (GLuint index, GLfloat n, GLfloat f); GL_APICALL void GL_APIENTRY glGetFloati_vOES (GLenum target, GLuint index, GLfloat *data); #endif #endif /* GL_OES_viewport_array */ #ifndef GL_AMD_compressed_3DC_texture #define GL_AMD_compressed_3DC_texture 1 #define GL_3DC_X_AMD 0x87F9 #define GL_3DC_XY_AMD 0x87FA #endif /* GL_AMD_compressed_3DC_texture */ #ifndef GL_AMD_compressed_ATC_texture #define GL_AMD_compressed_ATC_texture 1 #define GL_ATC_RGB_AMD 0x8C92 #define GL_ATC_RGBA_EXPLICIT_ALPHA_AMD 0x8C93 #define GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD 0x87EE #endif /* GL_AMD_compressed_ATC_texture */ #ifndef GL_AMD_framebuffer_multisample_advanced #define GL_AMD_framebuffer_multisample_advanced 1 #define GL_RENDERBUFFER_STORAGE_SAMPLES_AMD 0x91B2 #define GL_MAX_COLOR_FRAMEBUFFER_SAMPLES_AMD 0x91B3 #define GL_MAX_COLOR_FRAMEBUFFER_STORAGE_SAMPLES_AMD 0x91B4 #define GL_MAX_DEPTH_STENCIL_FRAMEBUFFER_SAMPLES_AMD 0x91B5 #define GL_NUM_SUPPORTED_MULTISAMPLE_MODES_AMD 0x91B6 #define GL_SUPPORTED_MULTISAMPLE_MODES_AMD 0x91B7 typedef void (GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEADVANCEDAMDPROC) (GLenum target, GLsizei samples, GLsizei storageSamples, GLenum internalformat, GLsizei width, GLsizei height); typedef void (GL_APIENTRYP PFNGLNAMEDRENDERBUFFERSTORAGEMULTISAMPLEADVANCEDAMDPROC) (GLuint renderbuffer, GLsizei samples, GLsizei storageSamples, GLenum internalformat, GLsizei width, GLsizei height); #ifdef GL_GLEXT_PROTOTYPES GL_APICALL void GL_APIENTRY glRenderbufferStorageMultisampleAdvancedAMD (GLenum target, GLsizei samples, GLsizei storageSamples, GLenum internalformat, GLsizei width, GLsizei height); GL_APICALL void GL_APIENTRY glNamedRenderbufferStorageMultisampleAdvancedAMD (GLuint renderbuffer, GLsizei samples, GLsizei storageSamples, GLenum internalformat, GLsizei width, GLsizei height); #endif #endif /* GL_AMD_framebuffer_multisample_advanced */ #ifndef GL_AMD_performance_monitor #define GL_AMD_performance_monitor 1 #define GL_COUNTER_TYPE_AMD 0x8BC0 #define GL_COUNTER_RANGE_AMD 0x8BC1 #define GL_UNSIGNED_INT64_AMD 0x8BC2 #define GL_PERCENTAGE_AMD 0x8BC3 #define GL_PERFMON_RESULT_AVAILABLE_AMD 0x8BC4 #define GL_PERFMON_RESULT_SIZE_AMD 0x8BC5 #define GL_PERFMON_RESULT_AMD 0x8BC6 typedef void (GL_APIENTRYP PFNGLGETPERFMONITORGROUPSAMDPROC) (GLint *numGroups, GLsizei groupsSize, GLuint *groups); typedef void (GL_APIENTRYP PFNGLGETPERFMONITORCOUNTERSAMDPROC) (GLuint group, GLint *numCounters, GLint *maxActiveCounters, GLsizei counterSize, GLuint *counters); typedef void (GL_APIENTRYP PFNGLGETPERFMONITORGROUPSTRINGAMDPROC) (GLuint group, GLsizei bufSize, GLsizei *length, GLchar *groupString); typedef void (GL_APIENTRYP PFNGLGETPERFMONITORCOUNTERSTRINGAMDPROC) (GLuint group, GLuint counter, GLsizei bufSize, GLsizei *length, GLchar *counterString); typedef void (GL_APIENTRYP PFNGLGETPERFMONITORCOUNTERINFOAMDPROC) (GLuint group, GLuint counter, GLenum pname, void *data); typedef void (GL_APIENTRYP PFNGLGENPERFMONITORSAMDPROC) (GLsizei n, GLuint *monitors); typedef void (GL_APIENTRYP PFNGLDELETEPERFMONITORSAMDPROC) (GLsizei n, GLuint *monitors); typedef void (GL_APIENTRYP PFNGLSELECTPERFMONITORCOUNTERSAMDPROC) (GLuint monitor, GLboolean enable, GLuint group, GLint numCounters, GLuint *counterList); typedef void (GL_APIENTRYP PFNGLBEGINPERFMONITORAMDPROC) (GLuint monitor); typedef void (GL_APIENTRYP PFNGLENDPERFMONITORAMDPROC) (GLuint monitor); typedef void (GL_APIENTRYP PFNGLGETPERFMONITORCOUNTERDATAAMDPROC) (GLuint monitor, GLenum pname, GLsizei dataSize, GLuint *data, GLint *bytesWritten); #ifdef GL_GLEXT_PROTOTYPES GL_APICALL void GL_APIENTRY glGetPerfMonitorGroupsAMD (GLint *numGroups, GLsizei groupsSize, GLuint *groups); GL_APICALL void GL_APIENTRY glGetPerfMonitorCountersAMD (GLuint group, GLint *numCounters, GLint *maxActiveCounters, GLsizei counterSize, GLuint *counters); GL_APICALL void GL_APIENTRY glGetPerfMonitorGroupStringAMD (GLuint group, GLsizei bufSize, GLsizei *length, GLchar *groupString); GL_APICALL void GL_APIENTRY glGetPerfMonitorCounterStringAMD (GLuint group, GLuint counter, GLsizei bufSize, GLsizei *length, GLchar *counterString); GL_APICALL void GL_APIENTRY glGetPerfMonitorCounterInfoAMD (GLuint group, GLuint counter, GLenum pname, void *data); GL_APICALL void GL_APIENTRY glGenPerfMonitorsAMD (GLsizei n, GLuint *monitors); GL_APICALL void GL_APIENTRY glDeletePerfMonitorsAMD (GLsizei n, GLuint *monitors); GL_APICALL void GL_APIENTRY glSelectPerfMonitorCountersAMD (GLuint monitor, GLboolean enable, GLuint group, GLint numCounters, GLuint *counterList); GL_APICALL void GL_APIENTRY glBeginPerfMonitorAMD (GLuint monitor); GL_APICALL void GL_APIENTRY glEndPerfMonitorAMD (GLuint monitor); GL_APICALL void GL_APIENTRY glGetPerfMonitorCounterDataAMD (GLuint monitor, GLenum pname, GLsizei dataSize, GLuint *data, GLint *bytesWritten); #endif #endif /* GL_AMD_performance_monitor */ #ifndef GL_AMD_program_binary_Z400 #define GL_AMD_program_binary_Z400 1 #define GL_Z400_BINARY_AMD 0x8740 #endif /* GL_AMD_program_binary_Z400 */ #ifndef GL_ANDROID_extension_pack_es31a #define GL_ANDROID_extension_pack_es31a 1 #endif /* GL_ANDROID_extension_pack_es31a */ #ifndef GL_ANGLE_depth_texture #define GL_ANGLE_depth_texture 1 #endif /* GL_ANGLE_depth_texture */ #ifndef GL_ANGLE_framebuffer_blit #define GL_ANGLE_framebuffer_blit 1 #define GL_READ_FRAMEBUFFER_ANGLE 0x8CA8 #define GL_DRAW_FRAMEBUFFER_ANGLE 0x8CA9 #define GL_DRAW_FRAMEBUFFER_BINDING_ANGLE 0x8CA6 #define GL_READ_FRAMEBUFFER_BINDING_ANGLE 0x8CAA typedef void (GL_APIENTRYP PFNGLBLITFRAMEBUFFERANGLEPROC) (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); #ifdef GL_GLEXT_PROTOTYPES GL_APICALL void GL_APIENTRY glBlitFramebufferANGLE (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); #endif #endif /* GL_ANGLE_framebuffer_blit */ #ifndef GL_ANGLE_framebuffer_multisample #define GL_ANGLE_framebuffer_multisample 1 #define GL_RENDERBUFFER_SAMPLES_ANGLE 0x8CAB #define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_ANGLE 0x8D56 #define GL_MAX_SAMPLES_ANGLE 0x8D57 typedef void (GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEANGLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); #ifdef GL_GLEXT_PROTOTYPES GL_APICALL void GL_APIENTRY glRenderbufferStorageMultisampleANGLE (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); #endif #endif /* GL_ANGLE_framebuffer_multisample */ #ifndef GL_ANGLE_instanced_arrays #define GL_ANGLE_instanced_arrays 1 #define GL_VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE 0x88FE typedef void (GL_APIENTRYP PFNGLDRAWARRAYSINSTANCEDANGLEPROC) (GLenum mode, GLint first, GLsizei count, GLsizei primcount); typedef void (GL_APIENTRYP PFNGLDRAWELEMENTSINSTANCEDANGLEPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount); typedef void (GL_APIENTRYP PFNGLVERTEXATTRIBDIVISORANGLEPROC) (GLuint index, GLuint divisor); #ifdef GL_GLEXT_PROTOTYPES GL_APICALL void GL_APIENTRY glDrawArraysInstancedANGLE (GLenum mode, GLint first, GLsizei count, GLsizei primcount); GL_APICALL void GL_APIENTRY glDrawElementsInstancedANGLE (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount); GL_APICALL void GL_APIENTRY glVertexAttribDivisorANGLE (GLuint index, GLuint divisor); #endif #endif /* GL_ANGLE_instanced_arrays */ #ifndef GL_ANGLE_pack_reverse_row_order #define GL_ANGLE_pack_reverse_row_order 1 #define GL_PACK_REVERSE_ROW_ORDER_ANGLE 0x93A4 #endif /* GL_ANGLE_pack_reverse_row_order */ #ifndef GL_ANGLE_program_binary #define GL_ANGLE_program_binary 1 #define GL_PROGRAM_BINARY_ANGLE 0x93A6 #endif /* GL_ANGLE_program_binary */ #ifndef GL_ANGLE_texture_compression_dxt3 #define GL_ANGLE_texture_compression_dxt3 1 #define GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE 0x83F2 #endif /* GL_ANGLE_texture_compression_dxt3 */ #ifndef GL_ANGLE_texture_compression_dxt5 #define GL_ANGLE_texture_compression_dxt5 1 #define GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE 0x83F3 #endif /* GL_ANGLE_texture_compression_dxt5 */ #ifndef GL_ANGLE_texture_usage #define GL_ANGLE_texture_usage 1 #define GL_TEXTURE_USAGE_ANGLE 0x93A2 #define GL_FRAMEBUFFER_ATTACHMENT_ANGLE 0x93A3 #endif /* GL_ANGLE_texture_usage */ #ifndef GL_ANGLE_translated_shader_source #define GL_ANGLE_translated_shader_source 1 #define GL_TRANSLATED_SHADER_SOURCE_LENGTH_ANGLE 0x93A0 typedef void (GL_APIENTRYP PFNGLGETTRANSLATEDSHADERSOURCEANGLEPROC) (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *source); #ifdef GL_GLEXT_PROTOTYPES GL_APICALL void GL_APIENTRY glGetTranslatedShaderSourceANGLE (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *source); #endif #endif /* GL_ANGLE_translated_shader_source */ #ifndef GL_APPLE_clip_distance #define GL_APPLE_clip_distance 1 #define GL_MAX_CLIP_DISTANCES_APPLE 0x0D32 #define GL_CLIP_DISTANCE0_APPLE 0x3000 #define GL_CLIP_DISTANCE1_APPLE 0x3001 #define GL_CLIP_DISTANCE2_APPLE 0x3002 #define GL_CLIP_DISTANCE3_APPLE 0x3003 #define GL_CLIP_DISTANCE4_APPLE 0x3004 #define GL_CLIP_DISTANCE5_APPLE 0x3005 #define GL_CLIP_DISTANCE6_APPLE 0x3006 #define GL_CLIP_DISTANCE7_APPLE 0x3007 #endif /* GL_APPLE_clip_distance */ #ifndef GL_APPLE_color_buffer_packed_float #define GL_APPLE_color_buffer_packed_float 1 #endif /* GL_APPLE_color_buffer_packed_float */ #ifndef GL_APPLE_copy_texture_levels #define GL_APPLE_copy_texture_levels 1 typedef void (GL_APIENTRYP PFNGLCOPYTEXTURELEVELSAPPLEPROC) (GLuint destinationTexture, GLuint sourceTexture, GLint sourceBaseLevel, GLsizei sourceLevelCount); #ifdef GL_GLEXT_PROTOTYPES GL_APICALL void GL_APIENTRY glCopyTextureLevelsAPPLE (GLuint destinationTexture, GLuint sourceTexture, GLint sourceBaseLevel, GLsizei sourceLevelCount); #endif #endif /* GL_APPLE_copy_texture_levels */ #ifndef GL_APPLE_framebuffer_multisample #define GL_APPLE_framebuffer_multisample 1 #define GL_RENDERBUFFER_SAMPLES_APPLE 0x8CAB #define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_APPLE 0x8D56 #define GL_MAX_SAMPLES_APPLE 0x8D57 #define GL_READ_FRAMEBUFFER_APPLE 0x8CA8 #define GL_DRAW_FRAMEBUFFER_APPLE 0x8CA9 #define GL_DRAW_FRAMEBUFFER_BINDING_APPLE 0x8CA6 #define GL_READ_FRAMEBUFFER_BINDING_APPLE 0x8CAA typedef void (GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEAPPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); typedef void (GL_APIENTRYP PFNGLRESOLVEMULTISAMPLEFRAMEBUFFERAPPLEPROC) (void); #ifdef GL_GLEXT_PROTOTYPES GL_APICALL void GL_APIENTRY glRenderbufferStorageMultisampleAPPLE (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); GL_APICALL void GL_APIENTRY glResolveMultisampleFramebufferAPPLE (void); #endif #endif /* GL_APPLE_framebuffer_multisample */ #ifndef GL_APPLE_rgb_422 #define GL_APPLE_rgb_422 1 #define GL_RGB_422_APPLE 0x8A1F #define GL_UNSIGNED_SHORT_8_8_APPLE 0x85BA #define GL_UNSIGNED_SHORT_8_8_REV_APPLE 0x85BB #define GL_RGB_RAW_422_APPLE 0x8A51 #endif /* GL_APPLE_rgb_422 */ #ifndef GL_APPLE_sync #define GL_APPLE_sync 1 #define GL_SYNC_OBJECT_APPLE 0x8A53 #define GL_MAX_SERVER_WAIT_TIMEOUT_APPLE 0x9111 #define GL_OBJECT_TYPE_APPLE 0x9112 #define GL_SYNC_CONDITION_APPLE 0x9113 #define GL_SYNC_STATUS_APPLE 0x9114 #define GL_SYNC_FLAGS_APPLE 0x9115 #define GL_SYNC_FENCE_APPLE 0x9116 #define GL_SYNC_GPU_COMMANDS_COMPLETE_APPLE 0x9117 #define GL_UNSIGNALED_APPLE 0x9118 #define GL_SIGNALED_APPLE 0x9119 #define GL_ALREADY_SIGNALED_APPLE 0x911A #define GL_TIMEOUT_EXPIRED_APPLE 0x911B #define GL_CONDITION_SATISFIED_APPLE 0x911C #define GL_WAIT_FAILED_APPLE 0x911D #define GL_SYNC_FLUSH_COMMANDS_BIT_APPLE 0x00000001 #define GL_TIMEOUT_IGNORED_APPLE 0xFFFFFFFFFFFFFFFFull typedef GLsync (GL_APIENTRYP PFNGLFENCESYNCAPPLEPROC) (GLenum condition, GLbitfield flags); typedef GLboolean (GL_APIENTRYP PFNGLISSYNCAPPLEPROC) (GLsync sync); typedef void (GL_APIENTRYP PFNGLDELETESYNCAPPLEPROC) (GLsync sync); typedef GLenum (GL_APIENTRYP PFNGLCLIENTWAITSYNCAPPLEPROC) (GLsync sync, GLbitfield flags, GLuint64 timeout); typedef void (GL_APIENTRYP PFNGLWAITSYNCAPPLEPROC) (GLsync sync, GLbitfield flags, GLuint64 timeout); typedef void (GL_APIENTRYP PFNGLGETINTEGER64VAPPLEPROC) (GLenum pname, GLint64 *params); typedef void (GL_APIENTRYP PFNGLGETSYNCIVAPPLEPROC) (GLsync sync, GLenum pname, GLsizei count, GLsizei *length, GLint *values); #ifdef GL_GLEXT_PROTOTYPES GL_APICALL GLsync GL_APIENTRY glFenceSyncAPPLE (GLenum condition, GLbitfield flags); GL_APICALL GLboolean GL_APIENTRY glIsSyncAPPLE (GLsync sync); GL_APICALL void GL_APIENTRY glDeleteSyncAPPLE (GLsync sync); GL_APICALL GLenum GL_APIENTRY glClientWaitSyncAPPLE (GLsync sync, GLbitfield flags, GLuint64 timeout); GL_APICALL void GL_APIENTRY glWaitSyncAPPLE (GLsync sync, GLbitfield flags, GLuint64 timeout); GL_APICALL void GL_APIENTRY glGetInteger64vAPPLE (GLenum pname, GLint64 *params); GL_APICALL void GL_APIENTRY glGetSyncivAPPLE (GLsync sync, GLenum pname, GLsizei count, GLsizei *length, GLint *values); #endif #endif /* GL_APPLE_sync */ #ifndef GL_APPLE_texture_format_BGRA8888 #define GL_APPLE_texture_format_BGRA8888 1 #define GL_BGRA_EXT 0x80E1 #define GL_BGRA8_EXT 0x93A1 #endif /* GL_APPLE_texture_format_BGRA8888 */ #ifndef GL_APPLE_texture_max_level #define GL_APPLE_texture_max_level 1 #define GL_TEXTURE_MAX_LEVEL_APPLE 0x813D #endif /* GL_APPLE_texture_max_level */ #ifndef GL_APPLE_texture_packed_float #define GL_APPLE_texture_packed_float 1 #define GL_UNSIGNED_INT_10F_11F_11F_REV_APPLE 0x8C3B #define GL_UNSIGNED_INT_5_9_9_9_REV_APPLE 0x8C3E #define GL_R11F_G11F_B10F_APPLE 0x8C3A #define GL_RGB9_E5_APPLE 0x8C3D #endif /* GL_APPLE_texture_packed_float */ #ifndef GL_ARM_mali_program_binary #define GL_ARM_mali_program_binary 1 #define GL_MALI_PROGRAM_BINARY_ARM 0x8F61 #endif /* GL_ARM_mali_program_binary */ #ifndef GL_ARM_mali_shader_binary #define GL_ARM_mali_shader_binary 1 #define GL_MALI_SHADER_BINARY_ARM 0x8F60 #endif /* GL_ARM_mali_shader_binary */ #ifndef GL_ARM_rgba8 #define GL_ARM_rgba8 1 #endif /* GL_ARM_rgba8 */ #ifndef GL_ARM_shader_framebuffer_fetch #define GL_ARM_shader_framebuffer_fetch 1 #define GL_FETCH_PER_SAMPLE_ARM 0x8F65 #define GL_FRAGMENT_SHADER_FRAMEBUFFER_FETCH_MRT_ARM 0x8F66 #endif /* GL_ARM_shader_framebuffer_fetch */ #ifndef GL_ARM_shader_framebuffer_fetch_depth_stencil #define GL_ARM_shader_framebuffer_fetch_depth_stencil 1 #endif /* GL_ARM_shader_framebuffer_fetch_depth_stencil */ #ifndef GL_ARM_texture_unnormalized_coordinates #define GL_ARM_texture_unnormalized_coordinates 1 #define GL_TEXTURE_UNNORMALIZED_COORDINATES_ARM 0x8F6A #endif /* GL_ARM_texture_unnormalized_coordinates */ #ifndef GL_DMP_program_binary #define GL_DMP_program_binary 1 #define GL_SMAPHS30_PROGRAM_BINARY_DMP 0x9251 #define GL_SMAPHS_PROGRAM_BINARY_DMP 0x9252 #define GL_DMP_PROGRAM_BINARY_DMP 0x9253 #endif /* GL_DMP_program_binary */ #ifndef GL_DMP_shader_binary #define GL_DMP_shader_binary 1 #define GL_SHADER_BINARY_DMP 0x9250 #endif /* GL_DMP_shader_binary */ #ifndef GL_EXT_EGL_image_array #define GL_EXT_EGL_image_array 1 #endif /* GL_EXT_EGL_image_array */ #ifndef GL_EXT_EGL_image_storage #define GL_EXT_EGL_image_storage 1 typedef void (GL_APIENTRYP PFNGLEGLIMAGETARGETTEXSTORAGEEXTPROC) (GLenum target, GLeglImageOES image, const GLint* attrib_list); typedef void (GL_APIENTRYP PFNGLEGLIMAGETARGETTEXTURESTORAGEEXTPROC) (GLuint texture, GLeglImageOES image, const GLint* attrib_list); #ifdef GL_GLEXT_PROTOTYPES GL_APICALL void GL_APIENTRY glEGLImageTargetTexStorageEXT (GLenum target, GLeglImageOES image, const GLint* attrib_list); GL_APICALL void GL_APIENTRY glEGLImageTargetTextureStorageEXT (GLuint texture, GLeglImageOES image, const GLint* attrib_list); #endif #endif /* GL_EXT_EGL_image_storage */ #ifndef GL_EXT_EGL_image_storage_compression #define GL_EXT_EGL_image_storage_compression 1 #define GL_SURFACE_COMPRESSION_EXT 0x96C0 #define GL_SURFACE_COMPRESSION_FIXED_RATE_NONE_EXT 0x96C1 #define GL_SURFACE_COMPRESSION_FIXED_RATE_DEFAULT_EXT 0x96C2 #endif /* GL_EXT_EGL_image_storage_compression */ #ifndef GL_EXT_YUV_target #define GL_EXT_YUV_target 1 #define GL_SAMPLER_EXTERNAL_2D_Y2Y_EXT 0x8BE7 #endif /* GL_EXT_YUV_target */ #ifndef GL_EXT_base_instance #define GL_EXT_base_instance 1 typedef void (GL_APIENTRYP PFNGLDRAWARRAYSINSTANCEDBASEINSTANCEEXTPROC) (GLenum mode, GLint first, GLsizei count, GLsizei instancecount, GLuint baseinstance); typedef void (GL_APIENTRYP PFNGLDRAWELEMENTSINSTANCEDBASEINSTANCEEXTPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLuint baseinstance); typedef void (GL_APIENTRYP PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXBASEINSTANCEEXTPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLint basevertex, GLuint baseinstance); #ifdef GL_GLEXT_PROTOTYPES GL_APICALL void GL_APIENTRY glDrawArraysInstancedBaseInstanceEXT (GLenum mode, GLint first, GLsizei count, GLsizei instancecount, GLuint baseinstance); GL_APICALL void GL_APIENTRY glDrawElementsInstancedBaseInstanceEXT (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLuint baseinstance); GL_APICALL void GL_APIENTRY glDrawElementsInstancedBaseVertexBaseInstanceEXT (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLint basevertex, GLuint baseinstance); #endif #endif /* GL_EXT_base_instance */ #ifndef GL_EXT_blend_func_extended #define GL_EXT_blend_func_extended 1 #define GL_SRC1_COLOR_EXT 0x88F9 #define GL_SRC1_ALPHA_EXT 0x8589 #define GL_ONE_MINUS_SRC1_COLOR_EXT 0x88FA #define GL_ONE_MINUS_SRC1_ALPHA_EXT 0x88FB #define GL_SRC_ALPHA_SATURATE_EXT 0x0308 #define GL_LOCATION_INDEX_EXT 0x930F #define GL_MAX_DUAL_SOURCE_DRAW_BUFFERS_EXT 0x88FC typedef void (GL_APIENTRYP PFNGLBINDFRAGDATALOCATIONINDEXEDEXTPROC) (GLuint program, GLuint colorNumber, GLuint index, const GLchar *name); typedef void (GL_APIENTRYP PFNGLBINDFRAGDATALOCATIONEXTPROC) (GLuint program, GLuint color, const GLchar *name); typedef GLint (GL_APIENTRYP PFNGLGETPROGRAMRESOURCELOCATIONINDEXEXTPROC) (GLuint program, GLenum programInterface, const GLchar *name); typedef GLint (GL_APIENTRYP PFNGLGETFRAGDATAINDEXEXTPROC) (GLuint program, const GLchar *name); #ifdef GL_GLEXT_PROTOTYPES GL_APICALL void GL_APIENTRY glBindFragDataLocationIndexedEXT (GLuint program, GLuint colorNumber, GLuint index, const GLchar *name); GL_APICALL void GL_APIENTRY glBindFragDataLocationEXT (GLuint program, GLuint color, const GLchar *name); GL_APICALL GLint GL_APIENTRY glGetProgramResourceLocationIndexEXT (GLuint program, GLenum programInterface, const GLchar *name); GL_APICALL GLint GL_APIENTRY glGetFragDataIndexEXT (GLuint program, const GLchar *name); #endif #endif /* GL_EXT_blend_func_extended */ #ifndef GL_EXT_blend_minmax #define GL_EXT_blend_minmax 1 #define GL_MIN_EXT 0x8007 #define GL_MAX_EXT 0x8008 #endif /* GL_EXT_blend_minmax */ #ifndef GL_EXT_buffer_storage #define GL_EXT_buffer_storage 1 #define GL_MAP_READ_BIT 0x0001 #define GL_MAP_WRITE_BIT 0x0002 #define GL_MAP_PERSISTENT_BIT_EXT 0x0040 #define GL_MAP_COHERENT_BIT_EXT 0x0080 #define GL_DYNAMIC_STORAGE_BIT_EXT 0x0100 #define GL_CLIENT_STORAGE_BIT_EXT 0x0200 #define GL_CLIENT_MAPPED_BUFFER_BARRIER_BIT_EXT 0x00004000 #define GL_BUFFER_IMMUTABLE_STORAGE_EXT 0x821F #define GL_BUFFER_STORAGE_FLAGS_EXT 0x8220 typedef void (GL_APIENTRYP PFNGLBUFFERSTORAGEEXTPROC) (GLenum target, GLsizeiptr size, const void *data, GLbitfield flags); #ifdef GL_GLEXT_PROTOTYPES GL_APICALL void GL_APIENTRY glBufferStorageEXT (GLenum target, GLsizeiptr size, const void *data, GLbitfield flags); #endif #endif /* GL_EXT_buffer_storage */ #ifndef GL_EXT_clear_texture #define GL_EXT_clear_texture 1 typedef void (GL_APIENTRYP PFNGLCLEARTEXIMAGEEXTPROC) (GLuint texture, GLint level, GLenum format, GLenum type, const void *data); typedef void (GL_APIENTRYP PFNGLCLEARTEXSUBIMAGEEXTPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *data); #ifdef GL_GLEXT_PROTOTYPES GL_APICALL void GL_APIENTRY glClearTexImageEXT (GLuint texture, GLint level, GLenum format, GLenum type, const void *data); GL_APICALL void GL_APIENTRY glClearTexSubImageEXT (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *data); #endif #endif /* GL_EXT_clear_texture */ #ifndef GL_EXT_clip_control #define GL_EXT_clip_control 1 #define GL_LOWER_LEFT_EXT 0x8CA1 #define GL_UPPER_LEFT_EXT 0x8CA2 #define GL_NEGATIVE_ONE_TO_ONE_EXT 0x935E #define GL_ZERO_TO_ONE_EXT 0x935F #define GL_CLIP_ORIGIN_EXT 0x935C #define GL_CLIP_DEPTH_MODE_EXT 0x935D typedef void (GL_APIENTRYP PFNGLCLIPCONTROLEXTPROC) (GLenum origin, GLenum depth); #ifdef GL_GLEXT_PROTOTYPES GL_APICALL void GL_APIENTRY glClipControlEXT (GLenum origin, GLenum depth); #endif #endif /* GL_EXT_clip_control */ #ifndef GL_EXT_clip_cull_distance #define GL_EXT_clip_cull_distance 1 #define GL_MAX_CLIP_DISTANCES_EXT 0x0D32 #define GL_MAX_CULL_DISTANCES_EXT 0x82F9 #define GL_MAX_COMBINED_CLIP_AND_CULL_DISTANCES_EXT 0x82FA #define GL_CLIP_DISTANCE0_EXT 0x3000 #define GL_CLIP_DISTANCE1_EXT 0x3001 #define GL_CLIP_DISTANCE2_EXT 0x3002 #define GL_CLIP_DISTANCE3_EXT 0x3003 #define GL_CLIP_DISTANCE4_EXT 0x3004 #define GL_CLIP_DISTANCE5_EXT 0x3005 #define GL_CLIP_DISTANCE6_EXT 0x3006 #define GL_CLIP_DISTANCE7_EXT 0x3007 #endif /* GL_EXT_clip_cull_distance */ #ifndef GL_EXT_color_buffer_float #define GL_EXT_color_buffer_float 1 #endif /* GL_EXT_color_buffer_float */ #ifndef GL_EXT_color_buffer_half_float #define GL_EXT_color_buffer_half_float 1 #define GL_RGBA16F_EXT 0x881A #define GL_RGB16F_EXT 0x881B #define GL_RG16F_EXT 0x822F #define GL_R16F_EXT 0x822D #define GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE_EXT 0x8211 #define GL_UNSIGNED_NORMALIZED_EXT 0x8C17 #endif /* GL_EXT_color_buffer_half_float */ #ifndef GL_EXT_conservative_depth #define GL_EXT_conservative_depth 1 #endif /* GL_EXT_conservative_depth */ #ifndef GL_EXT_copy_image #define GL_EXT_copy_image 1 typedef void (GL_APIENTRYP PFNGLCOPYIMAGESUBDATAEXTPROC) (GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei srcWidth, GLsizei srcHeight, GLsizei srcDepth); #ifdef GL_GLEXT_PROTOTYPES GL_APICALL void GL_APIENTRY glCopyImageSubDataEXT (GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei srcWidth, GLsizei srcHeight, GLsizei srcDepth); #endif #endif /* GL_EXT_copy_image */ #ifndef GL_EXT_debug_label #define GL_EXT_debug_label 1 #define GL_PROGRAM_PIPELINE_OBJECT_EXT 0x8A4F #define GL_PROGRAM_OBJECT_EXT 0x8B40 #define GL_SHADER_OBJECT_EXT 0x8B48 #define GL_BUFFER_OBJECT_EXT 0x9151 #define GL_QUERY_OBJECT_EXT 0x9153 #define GL_VERTEX_ARRAY_OBJECT_EXT 0x9154 #define GL_TRANSFORM_FEEDBACK 0x8E22 typedef void (GL_APIENTRYP PFNGLLABELOBJECTEXTPROC) (GLenum type, GLuint object, GLsizei length, const GLchar *label); typedef void (GL_APIENTRYP PFNGLGETOBJECTLABELEXTPROC) (GLenum type, GLuint object, GLsizei bufSize, GLsizei *length, GLchar *label); #ifdef GL_GLEXT_PROTOTYPES GL_APICALL void GL_APIENTRY glLabelObjectEXT (GLenum type, GLuint object, GLsizei length, const GLchar *label); GL_APICALL void GL_APIENTRY glGetObjectLabelEXT (GLenum type, GLuint object, GLsizei bufSize, GLsizei *length, GLchar *label); #endif #endif /* GL_EXT_debug_label */ #ifndef GL_EXT_debug_marker #define GL_EXT_debug_marker 1 typedef void (GL_APIENTRYP PFNGLINSERTEVENTMARKEREXTPROC) (GLsizei length, const GLchar *marker); typedef void (GL_APIENTRYP PFNGLPUSHGROUPMARKEREXTPROC) (GLsizei length, const GLchar *marker); typedef void (GL_APIENTRYP PFNGLPOPGROUPMARKEREXTPROC) (void); #ifdef GL_GLEXT_PROTOTYPES GL_APICALL void GL_APIENTRY glInsertEventMarkerEXT (GLsizei length, const GLchar *marker); GL_APICALL void GL_APIENTRY glPushGroupMarkerEXT (GLsizei length, const GLchar *marker); GL_APICALL void GL_APIENTRY glPopGroupMarkerEXT (void); #endif #endif /* GL_EXT_debug_marker */ #ifndef GL_EXT_depth_clamp #define GL_EXT_depth_clamp 1 #define GL_DEPTH_CLAMP_EXT 0x864F #endif /* GL_EXT_depth_clamp */ #ifndef GL_EXT_discard_framebuffer #define GL_EXT_discard_framebuffer 1 #define GL_COLOR_EXT 0x1800 #define GL_DEPTH_EXT 0x1801 #define GL_STENCIL_EXT 0x1802 typedef void (GL_APIENTRYP PFNGLDISCARDFRAMEBUFFEREXTPROC) (GLenum target, GLsizei numAttachments, const GLenum *attachments); #ifdef GL_GLEXT_PROTOTYPES GL_APICALL void GL_APIENTRY glDiscardFramebufferEXT (GLenum target, GLsizei numAttachments, const GLenum *attachments); #endif #endif /* GL_EXT_discard_framebuffer */ #ifndef GL_EXT_disjoint_timer_query #define GL_EXT_disjoint_timer_query 1 #define GL_QUERY_COUNTER_BITS_EXT 0x8864 #define GL_CURRENT_QUERY_EXT 0x8865 #define GL_QUERY_RESULT_EXT 0x8866 #define GL_QUERY_RESULT_AVAILABLE_EXT 0x8867 #define GL_TIME_ELAPSED_EXT 0x88BF #define GL_TIMESTAMP_EXT 0x8E28 #define GL_GPU_DISJOINT_EXT 0x8FBB typedef void (GL_APIENTRYP PFNGLGENQUERIESEXTPROC) (GLsizei n, GLuint *ids); typedef void (GL_APIENTRYP PFNGLDELETEQUERIESEXTPROC) (GLsizei n, const GLuint *ids); typedef GLboolean (GL_APIENTRYP PFNGLISQUERYEXTPROC) (GLuint id); typedef void (GL_APIENTRYP PFNGLBEGINQUERYEXTPROC) (GLenum target, GLuint id); typedef void (GL_APIENTRYP PFNGLENDQUERYEXTPROC) (GLenum target); typedef void (GL_APIENTRYP PFNGLQUERYCOUNTEREXTPROC) (GLuint id, GLenum target); typedef void (GL_APIENTRYP PFNGLGETQUERYIVEXTPROC) (GLenum target, GLenum pname, GLint *params); typedef void (GL_APIENTRYP PFNGLGETQUERYOBJECTIVEXTPROC) (GLuint id, GLenum pname, GLint *params); typedef void (GL_APIENTRYP PFNGLGETQUERYOBJECTUIVEXTPROC) (GLuint id, GLenum pname, GLuint *params); typedef void (GL_APIENTRYP PFNGLGETQUERYOBJECTI64VEXTPROC) (GLuint id, GLenum pname, GLint64 *params); typedef void (GL_APIENTRYP PFNGLGETQUERYOBJECTUI64VEXTPROC) (GLuint id, GLenum pname, GLuint64 *params); typedef void (GL_APIENTRYP PFNGLGETINTEGER64VEXTPROC) (GLenum pname, GLint64 *data); #ifdef GL_GLEXT_PROTOTYPES GL_APICALL void GL_APIENTRY glGenQueriesEXT (GLsizei n, GLuint *ids); GL_APICALL void GL_APIENTRY glDeleteQueriesEXT (GLsizei n, const GLuint *ids); GL_APICALL GLboolean GL_APIENTRY glIsQueryEXT (GLuint id); GL_APICALL void GL_APIENTRY glBeginQueryEXT (GLenum target, GLuint id); GL_APICALL void GL_APIENTRY glEndQueryEXT (GLenum target); GL_APICALL void GL_APIENTRY glQueryCounterEXT (GLuint id, GLenum target); GL_APICALL void GL_APIENTRY glGetQueryivEXT (GLenum target, GLenum pname, GLint *params); GL_APICALL void GL_APIENTRY glGetQueryObjectivEXT (GLuint id, GLenum pname, GLint *params); GL_APICALL void GL_APIENTRY glGetQueryObjectuivEXT (GLuint id, GLenum pname, GLuint *params); GL_APICALL void GL_APIENTRY glGetQueryObjecti64vEXT (GLuint id, GLenum pname, GLint64 *params); GL_APICALL void GL_APIENTRY glGetQueryObjectui64vEXT (GLuint id, GLenum pname, GLuint64 *params); GL_APICALL void GL_APIENTRY glGetInteger64vEXT (GLenum pname, GLint64 *data); #endif #endif /* GL_EXT_disjoint_timer_query */ #ifndef GL_EXT_draw_buffers #define GL_EXT_draw_buffers 1 #define GL_MAX_COLOR_ATTACHMENTS_EXT 0x8CDF #define GL_MAX_DRAW_BUFFERS_EXT 0x8824 #define GL_DRAW_BUFFER0_EXT 0x8825 #define GL_DRAW_BUFFER1_EXT 0x8826 #define GL_DRAW_BUFFER2_EXT 0x8827 #define GL_DRAW_BUFFER3_EXT 0x8828 #define GL_DRAW_BUFFER4_EXT 0x8829 #define GL_DRAW_BUFFER5_EXT 0x882A #define GL_DRAW_BUFFER6_EXT 0x882B #define GL_DRAW_BUFFER7_EXT 0x882C #define GL_DRAW_BUFFER8_EXT 0x882D #define GL_DRAW_BUFFER9_EXT 0x882E #define GL_DRAW_BUFFER10_EXT 0x882F #define GL_DRAW_BUFFER11_EXT 0x8830 #define GL_DRAW_BUFFER12_EXT 0x8831 #define GL_DRAW_BUFFER13_EXT 0x8832 #define GL_DRAW_BUFFER14_EXT 0x8833 #define GL_DRAW_BUFFER15_EXT 0x8834 #define GL_COLOR_ATTACHMENT0_EXT 0x8CE0 #define GL_COLOR_ATTACHMENT1_EXT 0x8CE1 #define GL_COLOR_ATTACHMENT2_EXT 0x8CE2 #define GL_COLOR_ATTACHMENT3_EXT 0x8CE3 #define GL_COLOR_ATTACHMENT4_EXT 0x8CE4 #define GL_COLOR_ATTACHMENT5_EXT 0x8CE5 #define GL_COLOR_ATTACHMENT6_EXT 0x8CE6 #define GL_COLOR_ATTACHMENT7_EXT 0x8CE7 #define GL_COLOR_ATTACHMENT8_EXT 0x8CE8 #define GL_COLOR_ATTACHMENT9_EXT 0x8CE9 #define GL_COLOR_ATTACHMENT10_EXT 0x8CEA #define GL_COLOR_ATTACHMENT11_EXT 0x8CEB #define GL_COLOR_ATTACHMENT12_EXT 0x8CEC #define GL_COLOR_ATTACHMENT13_EXT 0x8CED #define GL_COLOR_ATTACHMENT14_EXT 0x8CEE #define GL_COLOR_ATTACHMENT15_EXT 0x8CEF typedef void (GL_APIENTRYP PFNGLDRAWBUFFERSEXTPROC) (GLsizei n, const GLenum *bufs); #ifdef GL_GLEXT_PROTOTYPES GL_APICALL void GL_APIENTRY glDrawBuffersEXT (GLsizei n, const GLenum *bufs); #endif #endif /* GL_EXT_draw_buffers */ #ifndef GL_EXT_draw_buffers_indexed #define GL_EXT_draw_buffers_indexed 1 typedef void (GL_APIENTRYP PFNGLENABLEIEXTPROC) (GLenum target, GLuint index); typedef void (GL_APIENTRYP PFNGLDISABLEIEXTPROC) (GLenum target, GLuint index); typedef void (GL_APIENTRYP PFNGLBLENDEQUATIONIEXTPROC) (GLuint buf, GLenum mode); typedef void (GL_APIENTRYP PFNGLBLENDEQUATIONSEPARATEIEXTPROC) (GLuint buf, GLenum modeRGB, GLenum modeAlpha); typedef void (GL_APIENTRYP PFNGLBLENDFUNCIEXTPROC) (GLuint buf, GLenum src, GLenum dst); typedef void (GL_APIENTRYP PFNGLBLENDFUNCSEPARATEIEXTPROC) (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); typedef void (GL_APIENTRYP PFNGLCOLORMASKIEXTPROC) (GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a); typedef GLboolean (GL_APIENTRYP PFNGLISENABLEDIEXTPROC) (GLenum target, GLuint index); #ifdef GL_GLEXT_PROTOTYPES GL_APICALL void GL_APIENTRY glEnableiEXT (GLenum target, GLuint index); GL_APICALL void GL_APIENTRY glDisableiEXT (GLenum target, GLuint index); GL_APICALL void GL_APIENTRY glBlendEquationiEXT (GLuint buf, GLenum mode); GL_APICALL void GL_APIENTRY glBlendEquationSeparateiEXT (GLuint buf, GLenum modeRGB, GLenum modeAlpha); GL_APICALL void GL_APIENTRY glBlendFunciEXT (GLuint buf, GLenum src, GLenum dst); GL_APICALL void GL_APIENTRY glBlendFuncSeparateiEXT (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); GL_APICALL void GL_APIENTRY glColorMaskiEXT (GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a); GL_APICALL GLboolean GL_APIENTRY glIsEnablediEXT (GLenum target, GLuint index); #endif #endif /* GL_EXT_draw_buffers_indexed */ #ifndef GL_EXT_draw_elements_base_vertex #define GL_EXT_draw_elements_base_vertex 1 typedef void (GL_APIENTRYP PFNGLDRAWELEMENTSBASEVERTEXEXTPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLint basevertex); typedef void (GL_APIENTRYP PFNGLDRAWRANGEELEMENTSBASEVERTEXEXTPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void *indices, GLint basevertex); typedef void (GL_APIENTRYP PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXEXTPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLint basevertex); #ifdef GL_GLEXT_PROTOTYPES GL_APICALL void GL_APIENTRY glDrawElementsBaseVertexEXT (GLenum mode, GLsizei count, GLenum type, const void *indices, GLint basevertex); GL_APICALL void GL_APIENTRY glDrawRangeElementsBaseVertexEXT (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void *indices, GLint basevertex); GL_APICALL void GL_APIENTRY glDrawElementsInstancedBaseVertexEXT (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLint basevertex); #endif #endif /* GL_EXT_draw_elements_base_vertex */ #ifndef GL_EXT_draw_instanced #define GL_EXT_draw_instanced 1 typedef void (GL_APIENTRYP PFNGLDRAWARRAYSINSTANCEDEXTPROC) (GLenum mode, GLint start, GLsizei count, GLsizei primcount); typedef void (GL_APIENTRYP PFNGLDRAWELEMENTSINSTANCEDEXTPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount); #ifdef GL_GLEXT_PROTOTYPES GL_APICALL void GL_APIENTRY glDrawArraysInstancedEXT (GLenum mode, GLint start, GLsizei count, GLsizei primcount); GL_APICALL void GL_APIENTRY glDrawElementsInstancedEXT (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount); #endif #endif /* GL_EXT_draw_instanced */ #ifndef GL_EXT_draw_transform_feedback #define GL_EXT_draw_transform_feedback 1 typedef void (GL_APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKEXTPROC) (GLenum mode, GLuint id); typedef void (GL_APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKINSTANCEDEXTPROC) (GLenum mode, GLuint id, GLsizei instancecount); #ifdef GL_GLEXT_PROTOTYPES GL_APICALL void GL_APIENTRY glDrawTransformFeedbackEXT (GLenum mode, GLuint id); GL_APICALL void GL_APIENTRY glDrawTransformFeedbackInstancedEXT (GLenum mode, GLuint id, GLsizei instancecount); #endif #endif /* GL_EXT_draw_transform_feedback */ #ifndef GL_EXT_external_buffer #define GL_EXT_external_buffer 1 typedef void *GLeglClientBufferEXT; typedef void (GL_APIENTRYP PFNGLBUFFERSTORAGEEXTERNALEXTPROC) (GLenum target, GLintptr offset, GLsizeiptr size, GLeglClientBufferEXT clientBuffer, GLbitfield flags); typedef void (GL_APIENTRYP PFNGLNAMEDBUFFERSTORAGEEXTERNALEXTPROC) (GLuint buffer, GLintptr offset, GLsizeiptr size, GLeglClientBufferEXT clientBuffer, GLbitfield flags); #ifdef GL_GLEXT_PROTOTYPES GL_APICALL void GL_APIENTRY glBufferStorageExternalEXT (GLenum target, GLintptr offset, GLsizeiptr size, GLeglClientBufferEXT clientBuffer, GLbitfield flags); GL_APICALL void GL_APIENTRY glNamedBufferStorageExternalEXT (GLuint buffer, GLintptr offset, GLsizeiptr size, GLeglClientBufferEXT clientBuffer, GLbitfield flags); #endif #endif /* GL_EXT_external_buffer */ #ifndef GL_EXT_float_blend #define GL_EXT_float_blend 1 #endif /* GL_EXT_float_blend */ #ifndef GL_EXT_fragment_shading_rate #define GL_EXT_fragment_shading_rate 1 #define GL_SHADING_RATE_1X1_PIXELS_EXT 0x96A6 #define GL_SHADING_RATE_1X2_PIXELS_EXT 0x96A7 #define GL_SHADING_RATE_2X1_PIXELS_EXT 0x96A8 #define GL_SHADING_RATE_2X2_PIXELS_EXT 0x96A9 #define GL_SHADING_RATE_1X4_PIXELS_EXT 0x96AA #define GL_SHADING_RATE_4X1_PIXELS_EXT 0x96AB #define GL_SHADING_RATE_4X2_PIXELS_EXT 0x96AC #define GL_SHADING_RATE_2X4_PIXELS_EXT 0x96AD #define GL_SHADING_RATE_4X4_PIXELS_EXT 0x96AE #define GL_SHADING_RATE_EXT 0x96D0 #define GL_SHADING_RATE_ATTACHMENT_EXT 0x96D1 #define GL_FRAGMENT_SHADING_RATE_COMBINER_OP_KEEP_EXT 0x96D2 #define GL_FRAGMENT_SHADING_RATE_COMBINER_OP_REPLACE_EXT 0x96D3 #define GL_FRAGMENT_SHADING_RATE_COMBINER_OP_MIN_EXT 0x96D4 #define GL_FRAGMENT_SHADING_RATE_COMBINER_OP_MAX_EXT 0x96D5 #define GL_FRAGMENT_SHADING_RATE_COMBINER_OP_MUL_EXT 0x96D6 #define GL_MIN_FRAGMENT_SHADING_RATE_ATTACHMENT_TEXEL_WIDTH_EXT 0x96D7 #define GL_MAX_FRAGMENT_SHADING_RATE_ATTACHMENT_TEXEL_WIDTH_EXT 0x96D8 #define GL_MIN_FRAGMENT_SHADING_RATE_ATTACHMENT_TEXEL_HEIGHT_EXT 0x96D9 #define GL_MAX_FRAGMENT_SHADING_RATE_ATTACHMENT_TEXEL_HEIGHT_EXT 0x96DA #define GL_MAX_FRAGMENT_SHADING_RATE_ATTACHMENT_TEXEL_ASPECT_RATIO_EXT 0x96DB #define GL_MAX_FRAGMENT_SHADING_RATE_ATTACHMENT_LAYERS_EXT 0x96DC #define GL_FRAGMENT_SHADING_RATE_WITH_SHADER_DEPTH_STENCIL_WRITES_SUPPORTED_EXT 0x96DD #define GL_FRAGMENT_SHADING_RATE_WITH_SAMPLE_MASK_SUPPORTED_EXT 0x96DE #define GL_FRAGMENT_SHADING_RATE_ATTACHMENT_WITH_DEFAULT_FRAMEBUFFER_SUPPORTED_EXT 0x96DF #define GL_FRAGMENT_SHADING_RATE_NON_TRIVIAL_COMBINERS_SUPPORTED_EXT 0x8F6F typedef void (GL_APIENTRYP PFNGLGETFRAGMENTSHADINGRATESEXTPROC) (GLsizei samples, GLsizei maxCount, GLsizei *count, GLenum *shadingRates); typedef void (GL_APIENTRYP PFNGLSHADINGRATEEXTPROC) (GLenum rate); typedef void (GL_APIENTRYP PFNGLSHADINGRATECOMBINEROPSEXTPROC) (GLenum combinerOp0, GLenum combinerOp1); typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERSHADINGRATEEXTPROC) (GLenum target, GLenum attachment, GLuint texture, GLint baseLayer, GLsizei numLayers, GLsizei texelWidth, GLsizei texelHeight); #ifdef GL_GLEXT_PROTOTYPES GL_APICALL void GL_APIENTRY glGetFragmentShadingRatesEXT (GLsizei samples, GLsizei maxCount, GLsizei *count, GLenum *shadingRates); GL_APICALL void GL_APIENTRY glShadingRateEXT (GLenum rate); GL_APICALL void GL_APIENTRY glShadingRateCombinerOpsEXT (GLenum combinerOp0, GLenum combinerOp1); GL_APICALL void GL_APIENTRY glFramebufferShadingRateEXT (GLenum target, GLenum attachment, GLuint texture, GLint baseLayer, GLsizei numLayers, GLsizei texelWidth, GLsizei texelHeight); #endif #endif /* GL_EXT_fragment_shading_rate */ #ifndef GL_EXT_geometry_point_size #define GL_EXT_geometry_point_size 1 #endif /* GL_EXT_geometry_point_size */ #ifndef GL_EXT_geometry_shader #define GL_EXT_geometry_shader 1 #define GL_GEOMETRY_SHADER_EXT 0x8DD9 #define GL_GEOMETRY_SHADER_BIT_EXT 0x00000004 #define GL_GEOMETRY_LINKED_VERTICES_OUT_EXT 0x8916 #define GL_GEOMETRY_LINKED_INPUT_TYPE_EXT 0x8917 #define GL_GEOMETRY_LINKED_OUTPUT_TYPE_EXT 0x8918 #define GL_GEOMETRY_SHADER_INVOCATIONS_EXT 0x887F #define GL_LAYER_PROVOKING_VERTEX_EXT 0x825E #define GL_LINES_ADJACENCY_EXT 0x000A #define GL_LINE_STRIP_ADJACENCY_EXT 0x000B #define GL_TRIANGLES_ADJACENCY_EXT 0x000C #define GL_TRIANGLE_STRIP_ADJACENCY_EXT 0x000D #define GL_MAX_GEOMETRY_UNIFORM_COMPONENTS_EXT 0x8DDF #define GL_MAX_GEOMETRY_UNIFORM_BLOCKS_EXT 0x8A2C #define GL_MAX_COMBINED_GEOMETRY_UNIFORM_COMPONENTS_EXT 0x8A32 #define GL_MAX_GEOMETRY_INPUT_COMPONENTS_EXT 0x9123 #define GL_MAX_GEOMETRY_OUTPUT_COMPONENTS_EXT 0x9124 #define GL_MAX_GEOMETRY_OUTPUT_VERTICES_EXT 0x8DE0 #define GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS_EXT 0x8DE1 #define GL_MAX_GEOMETRY_SHADER_INVOCATIONS_EXT 0x8E5A #define GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_EXT 0x8C29 #define GL_MAX_GEOMETRY_ATOMIC_COUNTER_BUFFERS_EXT 0x92CF #define GL_MAX_GEOMETRY_ATOMIC_COUNTERS_EXT 0x92D5 #define GL_MAX_GEOMETRY_IMAGE_UNIFORMS_EXT 0x90CD #define GL_MAX_GEOMETRY_SHADER_STORAGE_BLOCKS_EXT 0x90D7 #define GL_FIRST_VERTEX_CONVENTION_EXT 0x8E4D #define GL_LAST_VERTEX_CONVENTION_EXT 0x8E4E #define GL_UNDEFINED_VERTEX_EXT 0x8260 #define GL_PRIMITIVES_GENERATED_EXT 0x8C87 #define GL_FRAMEBUFFER_DEFAULT_LAYERS_EXT 0x9312 #define GL_MAX_FRAMEBUFFER_LAYERS_EXT 0x9317 #define GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS_EXT 0x8DA8 #define GL_FRAMEBUFFER_ATTACHMENT_LAYERED_EXT 0x8DA7 #define GL_REFERENCED_BY_GEOMETRY_SHADER_EXT 0x9309 typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERTEXTUREEXTPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level); #ifdef GL_GLEXT_PROTOTYPES GL_APICALL void GL_APIENTRY glFramebufferTextureEXT (GLenum target, GLenum attachment, GLuint texture, GLint level); #endif #endif /* GL_EXT_geometry_shader */ #ifndef GL_EXT_gpu_shader5 #define GL_EXT_gpu_shader5 1 #endif /* GL_EXT_gpu_shader5 */ #ifndef GL_EXT_instanced_arrays #define GL_EXT_instanced_arrays 1 #define GL_VERTEX_ATTRIB_ARRAY_DIVISOR_EXT 0x88FE typedef void (GL_APIENTRYP PFNGLVERTEXATTRIBDIVISOREXTPROC) (GLuint index, GLuint divisor); #ifdef GL_GLEXT_PROTOTYPES GL_APICALL void GL_APIENTRY glVertexAttribDivisorEXT (GLuint index, GLuint divisor); #endif #endif /* GL_EXT_instanced_arrays */ #ifndef GL_EXT_map_buffer_range #define GL_EXT_map_buffer_range 1 #define GL_MAP_READ_BIT_EXT 0x0001 #define GL_MAP_WRITE_BIT_EXT 0x0002 #define GL_MAP_INVALIDATE_RANGE_BIT_EXT 0x0004 #define GL_MAP_INVALIDATE_BUFFER_BIT_EXT 0x0008 #define GL_MAP_FLUSH_EXPLICIT_BIT_EXT 0x0010 #define GL_MAP_UNSYNCHRONIZED_BIT_EXT 0x0020 typedef void *(GL_APIENTRYP PFNGLMAPBUFFERRANGEEXTPROC) (GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access); typedef void (GL_APIENTRYP PFNGLFLUSHMAPPEDBUFFERRANGEEXTPROC) (GLenum target, GLintptr offset, GLsizeiptr length); #ifdef GL_GLEXT_PROTOTYPES GL_APICALL void *GL_APIENTRY glMapBufferRangeEXT (GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access); GL_APICALL void GL_APIENTRY glFlushMappedBufferRangeEXT (GLenum target, GLintptr offset, GLsizeiptr length); #endif #endif /* GL_EXT_map_buffer_range */ #ifndef GL_EXT_memory_object #define GL_EXT_memory_object 1 #define GL_TEXTURE_TILING_EXT 0x9580 #define GL_DEDICATED_MEMORY_OBJECT_EXT 0x9581 #define GL_PROTECTED_MEMORY_OBJECT_EXT 0x959B #define GL_NUM_TILING_TYPES_EXT 0x9582 #define GL_TILING_TYPES_EXT 0x9583 #define GL_OPTIMAL_TILING_EXT 0x9584 #define GL_LINEAR_TILING_EXT 0x9585 #define GL_NUM_DEVICE_UUIDS_EXT 0x9596 #define GL_DEVICE_UUID_EXT 0x9597 #define GL_DRIVER_UUID_EXT 0x9598 #define GL_UUID_SIZE_EXT 16 typedef void (GL_APIENTRYP PFNGLGETUNSIGNEDBYTEVEXTPROC) (GLenum pname, GLubyte *data); typedef void (GL_APIENTRYP PFNGLGETUNSIGNEDBYTEI_VEXTPROC) (GLenum target, GLuint index, GLubyte *data); typedef void (GL_APIENTRYP PFNGLDELETEMEMORYOBJECTSEXTPROC) (GLsizei n, const GLuint *memoryObjects); typedef GLboolean (GL_APIENTRYP PFNGLISMEMORYOBJECTEXTPROC) (GLuint memoryObject); typedef void (GL_APIENTRYP PFNGLCREATEMEMORYOBJECTSEXTPROC) (GLsizei n, GLuint *memoryObjects); typedef void (GL_APIENTRYP PFNGLMEMORYOBJECTPARAMETERIVEXTPROC) (GLuint memoryObject, GLenum pname, const GLint *params); typedef void (GL_APIENTRYP PFNGLGETMEMORYOBJECTPARAMETERIVEXTPROC) (GLuint memoryObject, GLenum pname, GLint *params); typedef void (GL_APIENTRYP PFNGLTEXSTORAGEMEM2DEXTPROC) (GLenum target, GLsizei levels, GLenum internalFormat, GLsizei width, GLsizei height, GLuint memory, GLuint64 offset); typedef void (GL_APIENTRYP PFNGLTEXSTORAGEMEM2DMULTISAMPLEEXTPROC) (GLenum target, GLsizei samples, GLenum internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations, GLuint memory, GLuint64 offset); typedef void (GL_APIENTRYP PFNGLTEXSTORAGEMEM3DEXTPROC) (GLenum target, GLsizei levels, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLuint memory, GLuint64 offset); typedef void (GL_APIENTRYP PFNGLTEXSTORAGEMEM3DMULTISAMPLEEXTPROC) (GLenum target, GLsizei samples, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations, GLuint memory, GLuint64 offset); typedef void (GL_APIENTRYP PFNGLBUFFERSTORAGEMEMEXTPROC) (GLenum target, GLsizeiptr size, GLuint memory, GLuint64 offset); typedef void (GL_APIENTRYP PFNGLTEXTURESTORAGEMEM2DEXTPROC) (GLuint texture, GLsizei levels, GLenum internalFormat, GLsizei width, GLsizei height, GLuint memory, GLuint64 offset); typedef void (GL_APIENTRYP PFNGLTEXTURESTORAGEMEM2DMULTISAMPLEEXTPROC) (GLuint texture, GLsizei samples, GLenum internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations, GLuint memory, GLuint64 offset); typedef void (GL_APIENTRYP PFNGLTEXTURESTORAGEMEM3DEXTPROC) (GLuint texture, GLsizei levels, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLuint memory, GLuint64 offset); typedef void (GL_APIENTRYP PFNGLTEXTURESTORAGEMEM3DMULTISAMPLEEXTPROC) (GLuint texture, GLsizei samples, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations, GLuint memory, GLuint64 offset); typedef void (GL_APIENTRYP PFNGLNAMEDBUFFERSTORAGEMEMEXTPROC) (GLuint buffer, GLsizeiptr size, GLuint memory, GLuint64 offset); #ifdef GL_GLEXT_PROTOTYPES GL_APICALL void GL_APIENTRY glGetUnsignedBytevEXT (GLenum pname, GLubyte *data); GL_APICALL void GL_APIENTRY glGetUnsignedBytei_vEXT (GLenum target, GLuint index, GLubyte *data); GL_APICALL void GL_APIENTRY glDeleteMemoryObjectsEXT (GLsizei n, const GLuint *memoryObjects); GL_APICALL GLboolean GL_APIENTRY glIsMemoryObjectEXT (GLuint memoryObject); GL_APICALL void GL_APIENTRY glCreateMemoryObjectsEXT (GLsizei n, GLuint *memoryObjects); GL_APICALL void GL_APIENTRY glMemoryObjectParameterivEXT (GLuint memoryObject, GLenum pname, const GLint *params); GL_APICALL void GL_APIENTRY glGetMemoryObjectParameterivEXT (GLuint memoryObject, GLenum pname, GLint *params); GL_APICALL void GL_APIENTRY glTexStorageMem2DEXT (GLenum target, GLsizei levels, GLenum internalFormat, GLsizei width, GLsizei height, GLuint memory, GLuint64 offset); GL_APICALL void GL_APIENTRY glTexStorageMem2DMultisampleEXT (GLenum target, GLsizei samples, GLenum internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations, GLuint memory, GLuint64 offset); GL_APICALL void GL_APIENTRY glTexStorageMem3DEXT (GLenum target, GLsizei levels, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLuint memory, GLuint64 offset); GL_APICALL void GL_APIENTRY glTexStorageMem3DMultisampleEXT (GLenum target, GLsizei samples, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations, GLuint memory, GLuint64 offset); GL_APICALL void GL_APIENTRY glBufferStorageMemEXT (GLenum target, GLsizeiptr size, GLuint memory, GLuint64 offset); GL_APICALL void GL_APIENTRY glTextureStorageMem2DEXT (GLuint texture, GLsizei levels, GLenum internalFormat, GLsizei width, GLsizei height, GLuint memory, GLuint64 offset); GL_APICALL void GL_APIENTRY glTextureStorageMem2DMultisampleEXT (GLuint texture, GLsizei samples, GLenum internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations, GLuint memory, GLuint64 offset); GL_APICALL void GL_APIENTRY glTextureStorageMem3DEXT (GLuint texture, GLsizei levels, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLuint memory, GLuint64 offset); GL_APICALL void GL_APIENTRY glTextureStorageMem3DMultisampleEXT (GLuint texture, GLsizei samples, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations, GLuint memory, GLuint64 offset); GL_APICALL void GL_APIENTRY glNamedBufferStorageMemEXT (GLuint buffer, GLsizeiptr size, GLuint memory, GLuint64 offset); #endif #endif /* GL_EXT_memory_object */ #ifndef GL_EXT_memory_object_fd #define GL_EXT_memory_object_fd 1 #define GL_HANDLE_TYPE_OPAQUE_FD_EXT 0x9586 typedef void (GL_APIENTRYP PFNGLIMPORTMEMORYFDEXTPROC) (GLuint memory, GLuint64 size, GLenum handleType, GLint fd); #ifdef GL_GLEXT_PROTOTYPES GL_APICALL void GL_APIENTRY glImportMemoryFdEXT (GLuint memory, GLuint64 size, GLenum handleType, GLint fd); #endif #endif /* GL_EXT_memory_object_fd */ #ifndef GL_EXT_memory_object_win32 #define GL_EXT_memory_object_win32 1 #define GL_HANDLE_TYPE_OPAQUE_WIN32_EXT 0x9587 #define GL_HANDLE_TYPE_OPAQUE_WIN32_KMT_EXT 0x9588 #define GL_DEVICE_LUID_EXT 0x9599 #define GL_DEVICE_NODE_MASK_EXT 0x959A #define GL_LUID_SIZE_EXT 8 #define GL_HANDLE_TYPE_D3D12_TILEPOOL_EXT 0x9589 #define GL_HANDLE_TYPE_D3D12_RESOURCE_EXT 0x958A #define GL_HANDLE_TYPE_D3D11_IMAGE_EXT 0x958B #define GL_HANDLE_TYPE_D3D11_IMAGE_KMT_EXT 0x958C typedef void (GL_APIENTRYP PFNGLIMPORTMEMORYWIN32HANDLEEXTPROC) (GLuint memory, GLuint64 size, GLenum handleType, void *handle); typedef void (GL_APIENTRYP PFNGLIMPORTMEMORYWIN32NAMEEXTPROC) (GLuint memory, GLuint64 size, GLenum handleType, const void *name); #ifdef GL_GLEXT_PROTOTYPES GL_APICALL void GL_APIENTRY glImportMemoryWin32HandleEXT (GLuint memory, GLuint64 size, GLenum handleType, void *handle); GL_APICALL void GL_APIENTRY glImportMemoryWin32NameEXT (GLuint memory, GLuint64 size, GLenum handleType, const void *name); #endif #endif /* GL_EXT_memory_object_win32 */ #ifndef GL_EXT_multi_draw_arrays #define GL_EXT_multi_draw_arrays 1 typedef void (GL_APIENTRYP PFNGLMULTIDRAWARRAYSEXTPROC) (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount); typedef void (GL_APIENTRYP PFNGLMULTIDRAWELEMENTSEXTPROC) (GLenum mode, const GLsizei *count, GLenum type, const void *const*indices, GLsizei primcount); #ifdef GL_GLEXT_PROTOTYPES GL_APICALL void GL_APIENTRY glMultiDrawArraysEXT (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount); GL_APICALL void GL_APIENTRY glMultiDrawElementsEXT (GLenum mode, const GLsizei *count, GLenum type, const void *const*indices, GLsizei primcount); #endif #endif /* GL_EXT_multi_draw_arrays */ #ifndef GL_EXT_multi_draw_indirect #define GL_EXT_multi_draw_indirect 1 typedef void (GL_APIENTRYP PFNGLMULTIDRAWARRAYSINDIRECTEXTPROC) (GLenum mode, const void *indirect, GLsizei drawcount, GLsizei stride); typedef void (GL_APIENTRYP PFNGLMULTIDRAWELEMENTSINDIRECTEXTPROC) (GLenum mode, GLenum type, const void *indirect, GLsizei drawcount, GLsizei stride); #ifdef GL_GLEXT_PROTOTYPES GL_APICALL void GL_APIENTRY glMultiDrawArraysIndirectEXT (GLenum mode, const void *indirect, GLsizei drawcount, GLsizei stride); GL_APICALL void GL_APIENTRY glMultiDrawElementsIndirectEXT (GLenum mode, GLenum type, const void *indirect, GLsizei drawcount, GLsizei stride); #endif #endif /* GL_EXT_multi_draw_indirect */ #ifndef GL_EXT_multisampled_compatibility #define GL_EXT_multisampled_compatibility 1 #define GL_MULTISAMPLE_EXT 0x809D #define GL_SAMPLE_ALPHA_TO_ONE_EXT 0x809F #endif /* GL_EXT_multisampled_compatibility */ #ifndef GL_EXT_multisampled_render_to_texture #define GL_EXT_multisampled_render_to_texture 1 #define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_SAMPLES_EXT 0x8D6C #define GL_RENDERBUFFER_SAMPLES_EXT 0x8CAB #define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_EXT 0x8D56 #define GL_MAX_SAMPLES_EXT 0x8D57 typedef void (GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DMULTISAMPLEEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLsizei samples); #ifdef GL_GLEXT_PROTOTYPES GL_APICALL void GL_APIENTRY glRenderbufferStorageMultisampleEXT (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); GL_APICALL void GL_APIENTRY glFramebufferTexture2DMultisampleEXT (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLsizei samples); #endif #endif /* GL_EXT_multisampled_render_to_texture */ #ifndef GL_EXT_multisampled_render_to_texture2 #define GL_EXT_multisampled_render_to_texture2 1 #endif /* GL_EXT_multisampled_render_to_texture2 */ #ifndef GL_EXT_multiview_draw_buffers #define GL_EXT_multiview_draw_buffers 1 #define GL_COLOR_ATTACHMENT_EXT 0x90F0 #define GL_MULTIVIEW_EXT 0x90F1 #define GL_DRAW_BUFFER_EXT 0x0C01 #define GL_READ_BUFFER_EXT 0x0C02 #define GL_MAX_MULTIVIEW_BUFFERS_EXT 0x90F2 typedef void (GL_APIENTRYP PFNGLREADBUFFERINDEXEDEXTPROC) (GLenum src, GLint index); typedef void (GL_APIENTRYP PFNGLDRAWBUFFERSINDEXEDEXTPROC) (GLint n, const GLenum *location, const GLint *indices); typedef void (GL_APIENTRYP PFNGLGETINTEGERI_VEXTPROC) (GLenum target, GLuint index, GLint *data); #ifdef GL_GLEXT_PROTOTYPES GL_APICALL void GL_APIENTRY glReadBufferIndexedEXT (GLenum src, GLint index); GL_APICALL void GL_APIENTRY glDrawBuffersIndexedEXT (GLint n, const GLenum *location, const GLint *indices); GL_APICALL void GL_APIENTRY glGetIntegeri_vEXT (GLenum target, GLuint index, GLint *data); #endif #endif /* GL_EXT_multiview_draw_buffers */ #ifndef GL_EXT_multiview_tessellation_geometry_shader #define GL_EXT_multiview_tessellation_geometry_shader 1 #endif /* GL_EXT_multiview_tessellation_geometry_shader */ #ifndef GL_EXT_multiview_texture_multisample #define GL_EXT_multiview_texture_multisample 1 #endif /* GL_EXT_multiview_texture_multisample */ #ifndef GL_EXT_multiview_timer_query #define GL_EXT_multiview_timer_query 1 #endif /* GL_EXT_multiview_timer_query */ #ifndef GL_EXT_occlusion_query_boolean #define GL_EXT_occlusion_query_boolean 1 #define GL_ANY_SAMPLES_PASSED_EXT 0x8C2F #define GL_ANY_SAMPLES_PASSED_CONSERVATIVE_EXT 0x8D6A #endif /* GL_EXT_occlusion_query_boolean */ #ifndef GL_EXT_polygon_offset_clamp #define GL_EXT_polygon_offset_clamp 1 #define GL_POLYGON_OFFSET_CLAMP_EXT 0x8E1B typedef void (GL_APIENTRYP PFNGLPOLYGONOFFSETCLAMPEXTPROC) (GLfloat factor, GLfloat units, GLfloat clamp); #ifdef GL_GLEXT_PROTOTYPES GL_APICALL void GL_APIENTRY glPolygonOffsetClampEXT (GLfloat factor, GLfloat units, GLfloat clamp); #endif #endif /* GL_EXT_polygon_offset_clamp */ #ifndef GL_EXT_post_depth_coverage #define GL_EXT_post_depth_coverage 1 #endif /* GL_EXT_post_depth_coverage */ #ifndef GL_EXT_primitive_bounding_box #define GL_EXT_primitive_bounding_box 1 #define GL_PRIMITIVE_BOUNDING_BOX_EXT 0x92BE typedef void (GL_APIENTRYP PFNGLPRIMITIVEBOUNDINGBOXEXTPROC) (GLfloat minX, GLfloat minY, GLfloat minZ, GLfloat minW, GLfloat maxX, GLfloat maxY, GLfloat maxZ, GLfloat maxW); #ifdef GL_GLEXT_PROTOTYPES GL_APICALL void GL_APIENTRY glPrimitiveBoundingBoxEXT (GLfloat minX, GLfloat minY, GLfloat minZ, GLfloat minW, GLfloat maxX, GLfloat maxY, GLfloat maxZ, GLfloat maxW); #endif #endif /* GL_EXT_primitive_bounding_box */ #ifndef GL_EXT_protected_textures #define GL_EXT_protected_textures 1 #define GL_CONTEXT_FLAG_PROTECTED_CONTENT_BIT_EXT 0x00000010 #define GL_TEXTURE_PROTECTED_EXT 0x8BFA #endif /* GL_EXT_protected_textures */ #ifndef GL_EXT_pvrtc_sRGB #define GL_EXT_pvrtc_sRGB 1 #define GL_COMPRESSED_SRGB_PVRTC_2BPPV1_EXT 0x8A54 #define GL_COMPRESSED_SRGB_PVRTC_4BPPV1_EXT 0x8A55 #define GL_COMPRESSED_SRGB_ALPHA_PVRTC_2BPPV1_EXT 0x8A56 #define GL_COMPRESSED_SRGB_ALPHA_PVRTC_4BPPV1_EXT 0x8A57 #define GL_COMPRESSED_SRGB_ALPHA_PVRTC_2BPPV2_IMG 0x93F0 #define GL_COMPRESSED_SRGB_ALPHA_PVRTC_4BPPV2_IMG 0x93F1 #endif /* GL_EXT_pvrtc_sRGB */ #ifndef GL_EXT_raster_multisample #define GL_EXT_raster_multisample 1 #define GL_RASTER_MULTISAMPLE_EXT 0x9327 #define GL_RASTER_SAMPLES_EXT 0x9328 #define GL_MAX_RASTER_SAMPLES_EXT 0x9329 #define GL_RASTER_FIXED_SAMPLE_LOCATIONS_EXT 0x932A #define GL_MULTISAMPLE_RASTERIZATION_ALLOWED_EXT 0x932B #define GL_EFFECTIVE_RASTER_SAMPLES_EXT 0x932C typedef void (GL_APIENTRYP PFNGLRASTERSAMPLESEXTPROC) (GLuint samples, GLboolean fixedsamplelocations); #ifdef GL_GLEXT_PROTOTYPES GL_APICALL void GL_APIENTRY glRasterSamplesEXT (GLuint samples, GLboolean fixedsamplelocations); #endif #endif /* GL_EXT_raster_multisample */ #ifndef GL_EXT_read_format_bgra #define GL_EXT_read_format_bgra 1 #define GL_UNSIGNED_SHORT_4_4_4_4_REV_EXT 0x8365 #define GL_UNSIGNED_SHORT_1_5_5_5_REV_EXT 0x8366 #endif /* GL_EXT_read_format_bgra */ #ifndef GL_EXT_render_snorm #define GL_EXT_render_snorm 1 #define GL_R8_SNORM 0x8F94 #define GL_RG8_SNORM 0x8F95 #define GL_RGBA8_SNORM 0x8F97 #define GL_R16_SNORM_EXT 0x8F98 #define GL_RG16_SNORM_EXT 0x8F99 #define GL_RGBA16_SNORM_EXT 0x8F9B #endif /* GL_EXT_render_snorm */ #ifndef GL_EXT_robustness #define GL_EXT_robustness 1 #define GL_GUILTY_CONTEXT_RESET_EXT 0x8253 #define GL_INNOCENT_CONTEXT_RESET_EXT 0x8254 #define GL_UNKNOWN_CONTEXT_RESET_EXT 0x8255 #define GL_CONTEXT_ROBUST_ACCESS_EXT 0x90F3 #define GL_RESET_NOTIFICATION_STRATEGY_EXT 0x8256 #define GL_LOSE_CONTEXT_ON_RESET_EXT 0x8252 #define GL_NO_RESET_NOTIFICATION_EXT 0x8261 typedef GLenum (GL_APIENTRYP PFNGLGETGRAPHICSRESETSTATUSEXTPROC) (void); typedef void (GL_APIENTRYP PFNGLREADNPIXELSEXTPROC) (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei bufSize, void *data); typedef void (GL_APIENTRYP PFNGLGETNUNIFORMFVEXTPROC) (GLuint program, GLint location, GLsizei bufSize, GLfloat *params); typedef void (GL_APIENTRYP PFNGLGETNUNIFORMIVEXTPROC) (GLuint program, GLint location, GLsizei bufSize, GLint *params); #ifdef GL_GLEXT_PROTOTYPES GL_APICALL GLenum GL_APIENTRY glGetGraphicsResetStatusEXT (void); GL_APICALL void GL_APIENTRY glReadnPixelsEXT (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei bufSize, void *data); GL_APICALL void GL_APIENTRY glGetnUniformfvEXT (GLuint program, GLint location, GLsizei bufSize, GLfloat *params); GL_APICALL void GL_APIENTRY glGetnUniformivEXT (GLuint program, GLint location, GLsizei bufSize, GLint *params); #endif #endif /* GL_EXT_robustness */ #ifndef GL_EXT_sRGB #define GL_EXT_sRGB 1 #define GL_SRGB_EXT 0x8C40 #define GL_SRGB_ALPHA_EXT 0x8C42 #define GL_SRGB8_ALPHA8_EXT 0x8C43 #define GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING_EXT 0x8210 #endif /* GL_EXT_sRGB */ #ifndef GL_EXT_sRGB_write_control #define GL_EXT_sRGB_write_control 1 #define GL_FRAMEBUFFER_SRGB_EXT 0x8DB9 #endif /* GL_EXT_sRGB_write_control */ #ifndef GL_EXT_semaphore #define GL_EXT_semaphore 1 #define GL_LAYOUT_GENERAL_EXT 0x958D #define GL_LAYOUT_COLOR_ATTACHMENT_EXT 0x958E #define GL_LAYOUT_DEPTH_STENCIL_ATTACHMENT_EXT 0x958F #define GL_LAYOUT_DEPTH_STENCIL_READ_ONLY_EXT 0x9590 #define GL_LAYOUT_SHADER_READ_ONLY_EXT 0x9591 #define GL_LAYOUT_TRANSFER_SRC_EXT 0x9592 #define GL_LAYOUT_TRANSFER_DST_EXT 0x9593 #define GL_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_EXT 0x9530 #define GL_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_EXT 0x9531 typedef void (GL_APIENTRYP PFNGLGENSEMAPHORESEXTPROC) (GLsizei n, GLuint *semaphores); typedef void (GL_APIENTRYP PFNGLDELETESEMAPHORESEXTPROC) (GLsizei n, const GLuint *semaphores); typedef GLboolean (GL_APIENTRYP PFNGLISSEMAPHOREEXTPROC) (GLuint semaphore); typedef void (GL_APIENTRYP PFNGLSEMAPHOREPARAMETERUI64VEXTPROC) (GLuint semaphore, GLenum pname, const GLuint64 *params); typedef void (GL_APIENTRYP PFNGLGETSEMAPHOREPARAMETERUI64VEXTPROC) (GLuint semaphore, GLenum pname, GLuint64 *params); typedef void (GL_APIENTRYP PFNGLWAITSEMAPHOREEXTPROC) (GLuint semaphore, GLuint numBufferBarriers, const GLuint *buffers, GLuint numTextureBarriers, const GLuint *textures, const GLenum *srcLayouts); typedef void (GL_APIENTRYP PFNGLSIGNALSEMAPHOREEXTPROC) (GLuint semaphore, GLuint numBufferBarriers, const GLuint *buffers, GLuint numTextureBarriers, const GLuint *textures, const GLenum *dstLayouts); #ifdef GL_GLEXT_PROTOTYPES GL_APICALL void GL_APIENTRY glGenSemaphoresEXT (GLsizei n, GLuint *semaphores); GL_APICALL void GL_APIENTRY glDeleteSemaphoresEXT (GLsizei n, const GLuint *semaphores); GL_APICALL GLboolean GL_APIENTRY glIsSemaphoreEXT (GLuint semaphore); GL_APICALL void GL_APIENTRY glSemaphoreParameterui64vEXT (GLuint semaphore, GLenum pname, const GLuint64 *params); GL_APICALL void GL_APIENTRY glGetSemaphoreParameterui64vEXT (GLuint semaphore, GLenum pname, GLuint64 *params); GL_APICALL void GL_APIENTRY glWaitSemaphoreEXT (GLuint semaphore, GLuint numBufferBarriers, const GLuint *buffers, GLuint numTextureBarriers, const GLuint *textures, const GLenum *srcLayouts); GL_APICALL void GL_APIENTRY glSignalSemaphoreEXT (GLuint semaphore, GLuint numBufferBarriers, const GLuint *buffers, GLuint numTextureBarriers, const GLuint *textures, const GLenum *dstLayouts); #endif #endif /* GL_EXT_semaphore */ #ifndef GL_EXT_semaphore_fd #define GL_EXT_semaphore_fd 1 typedef void (GL_APIENTRYP PFNGLIMPORTSEMAPHOREFDEXTPROC) (GLuint semaphore, GLenum handleType, GLint fd); #ifdef GL_GLEXT_PROTOTYPES GL_APICALL void GL_APIENTRY glImportSemaphoreFdEXT (GLuint semaphore, GLenum handleType, GLint fd); #endif #endif /* GL_EXT_semaphore_fd */ #ifndef GL_EXT_semaphore_win32 #define GL_EXT_semaphore_win32 1 #define GL_HANDLE_TYPE_D3D12_FENCE_EXT 0x9594 #define GL_D3D12_FENCE_VALUE_EXT 0x9595 typedef void (GL_APIENTRYP PFNGLIMPORTSEMAPHOREWIN32HANDLEEXTPROC) (GLuint semaphore, GLenum handleType, void *handle); typedef void (GL_APIENTRYP PFNGLIMPORTSEMAPHOREWIN32NAMEEXTPROC) (GLuint semaphore, GLenum handleType, const void *name); #ifdef GL_GLEXT_PROTOTYPES GL_APICALL void GL_APIENTRY glImportSemaphoreWin32HandleEXT (GLuint semaphore, GLenum handleType, void *handle); GL_APICALL void GL_APIENTRY glImportSemaphoreWin32NameEXT (GLuint semaphore, GLenum handleType, const void *name); #endif #endif /* GL_EXT_semaphore_win32 */ #ifndef GL_EXT_separate_depth_stencil #define GL_EXT_separate_depth_stencil 1 #endif /* GL_EXT_separate_depth_stencil */ #ifndef GL_EXT_separate_shader_objects #define GL_EXT_separate_shader_objects 1 #define GL_ACTIVE_PROGRAM_EXT 0x8259 #define GL_VERTEX_SHADER_BIT_EXT 0x00000001 #define GL_FRAGMENT_SHADER_BIT_EXT 0x00000002 #define GL_ALL_SHADER_BITS_EXT 0xFFFFFFFF #define GL_PROGRAM_SEPARABLE_EXT 0x8258 #define GL_PROGRAM_PIPELINE_BINDING_EXT 0x825A typedef void (GL_APIENTRYP PFNGLACTIVESHADERPROGRAMEXTPROC) (GLuint pipeline, GLuint program); typedef void (GL_APIENTRYP PFNGLBINDPROGRAMPIPELINEEXTPROC) (GLuint pipeline); typedef GLuint (GL_APIENTRYP PFNGLCREATESHADERPROGRAMVEXTPROC) (GLenum type, GLsizei count, const GLchar **strings); typedef void (GL_APIENTRYP PFNGLDELETEPROGRAMPIPELINESEXTPROC) (GLsizei n, const GLuint *pipelines); typedef void (GL_APIENTRYP PFNGLGENPROGRAMPIPELINESEXTPROC) (GLsizei n, GLuint *pipelines); typedef void (GL_APIENTRYP PFNGLGETPROGRAMPIPELINEINFOLOGEXTPROC) (GLuint pipeline, GLsizei bufSize, GLsizei *length, GLchar *infoLog); typedef void (GL_APIENTRYP PFNGLGETPROGRAMPIPELINEIVEXTPROC) (GLuint pipeline, GLenum pname, GLint *params); typedef GLboolean (GL_APIENTRYP PFNGLISPROGRAMPIPELINEEXTPROC) (GLuint pipeline); typedef void (GL_APIENTRYP PFNGLPROGRAMPARAMETERIEXTPROC) (GLuint program, GLenum pname, GLint value); typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM1FEXTPROC) (GLuint program, GLint location, GLfloat v0); typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM1FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM1IEXTPROC) (GLuint program, GLint location, GLint v0); typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM1IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM2FEXTPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1); typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM2FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM2IEXTPROC) (GLuint program, GLint location, GLint v0, GLint v1); typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM2IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM3FEXTPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2); typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM3FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM3IEXTPROC) (GLuint program, GLint location, GLint v0, GLint v1, GLint v2); typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM3IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM4FEXTPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM4FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM4IEXTPROC) (GLuint program, GLint location, GLint v0, GLint v1, GLint v2, GLint v3); typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM4IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); typedef void (GL_APIENTRYP PFNGLUSEPROGRAMSTAGESEXTPROC) (GLuint pipeline, GLbitfield stages, GLuint program); typedef void (GL_APIENTRYP PFNGLVALIDATEPROGRAMPIPELINEEXTPROC) (GLuint pipeline); typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM1UIEXTPROC) (GLuint program, GLint location, GLuint v0); typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM2UIEXTPROC) (GLuint program, GLint location, GLuint v0, GLuint v1); typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM3UIEXTPROC) (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2); typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM4UIEXTPROC) (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM1UIVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM2UIVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM3UIVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM4UIVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X3FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X2FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X4FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X2FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X4FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X3FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); #ifdef GL_GLEXT_PROTOTYPES GL_APICALL void GL_APIENTRY glActiveShaderProgramEXT (GLuint pipeline, GLuint program); GL_APICALL void GL_APIENTRY glBindProgramPipelineEXT (GLuint pipeline); GL_APICALL GLuint GL_APIENTRY glCreateShaderProgramvEXT (GLenum type, GLsizei count, const GLchar **strings); GL_APICALL void GL_APIENTRY glDeleteProgramPipelinesEXT (GLsizei n, const GLuint *pipelines); GL_APICALL void GL_APIENTRY glGenProgramPipelinesEXT (GLsizei n, GLuint *pipelines); GL_APICALL void GL_APIENTRY glGetProgramPipelineInfoLogEXT (GLuint pipeline, GLsizei bufSize, GLsizei *length, GLchar *infoLog); GL_APICALL void GL_APIENTRY glGetProgramPipelineivEXT (GLuint pipeline, GLenum pname, GLint *params); GL_APICALL GLboolean GL_APIENTRY glIsProgramPipelineEXT (GLuint pipeline); GL_APICALL void GL_APIENTRY glProgramParameteriEXT (GLuint program, GLenum pname, GLint value); GL_APICALL void GL_APIENTRY glProgramUniform1fEXT (GLuint program, GLint location, GLfloat v0); GL_APICALL void GL_APIENTRY glProgramUniform1fvEXT (GLuint program, GLint location, GLsizei count, const GLfloat *value); GL_APICALL void GL_APIENTRY glProgramUniform1iEXT (GLuint program, GLint location, GLint v0); GL_APICALL void GL_APIENTRY glProgramUniform1ivEXT (GLuint program, GLint location, GLsizei count, const GLint *value); GL_APICALL void GL_APIENTRY glProgramUniform2fEXT (GLuint program, GLint location, GLfloat v0, GLfloat v1); GL_APICALL void GL_APIENTRY glProgramUniform2fvEXT (GLuint program, GLint location, GLsizei count, const GLfloat *value); GL_APICALL void GL_APIENTRY glProgramUniform2iEXT (GLuint program, GLint location, GLint v0, GLint v1); GL_APICALL void GL_APIENTRY glProgramUniform2ivEXT (GLuint program, GLint location, GLsizei count, const GLint *value); GL_APICALL void GL_APIENTRY glProgramUniform3fEXT (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2); GL_APICALL void GL_APIENTRY glProgramUniform3fvEXT (GLuint program, GLint location, GLsizei count, const GLfloat *value); GL_APICALL void GL_APIENTRY glProgramUniform3iEXT (GLuint program, GLint location, GLint v0, GLint v1, GLint v2); GL_APICALL void GL_APIENTRY glProgramUniform3ivEXT (GLuint program, GLint location, GLsizei count, const GLint *value); GL_APICALL void GL_APIENTRY glProgramUniform4fEXT (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); GL_APICALL void GL_APIENTRY glProgramUniform4fvEXT (GLuint program, GLint location, GLsizei count, const GLfloat *value); GL_APICALL void GL_APIENTRY glProgramUniform4iEXT (GLuint program, GLint location, GLint v0, GLint v1, GLint v2, GLint v3); GL_APICALL void GL_APIENTRY glProgramUniform4ivEXT (GLuint program, GLint location, GLsizei count, const GLint *value); GL_APICALL void GL_APIENTRY glProgramUniformMatrix2fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); GL_APICALL void GL_APIENTRY glProgramUniformMatrix3fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); GL_APICALL void GL_APIENTRY glProgramUniformMatrix4fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); GL_APICALL void GL_APIENTRY glUseProgramStagesEXT (GLuint pipeline, GLbitfield stages, GLuint program); GL_APICALL void GL_APIENTRY glValidateProgramPipelineEXT (GLuint pipeline); GL_APICALL void GL_APIENTRY glProgramUniform1uiEXT (GLuint program, GLint location, GLuint v0); GL_APICALL void GL_APIENTRY glProgramUniform2uiEXT (GLuint program, GLint location, GLuint v0, GLuint v1); GL_APICALL void GL_APIENTRY glProgramUniform3uiEXT (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2); GL_APICALL void GL_APIENTRY glProgramUniform4uiEXT (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); GL_APICALL void GL_APIENTRY glProgramUniform1uivEXT (GLuint program, GLint location, GLsizei count, const GLuint *value); GL_APICALL void GL_APIENTRY glProgramUniform2uivEXT (GLuint program, GLint location, GLsizei count, const GLuint *value); GL_APICALL void GL_APIENTRY glProgramUniform3uivEXT (GLuint program, GLint location, GLsizei count, const GLuint *value); GL_APICALL void GL_APIENTRY glProgramUniform4uivEXT (GLuint program, GLint location, GLsizei count, const GLuint *value); GL_APICALL void GL_APIENTRY glProgramUniformMatrix2x3fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); GL_APICALL void GL_APIENTRY glProgramUniformMatrix3x2fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); GL_APICALL void GL_APIENTRY glProgramUniformMatrix2x4fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); GL_APICALL void GL_APIENTRY glProgramUniformMatrix4x2fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); GL_APICALL void GL_APIENTRY glProgramUniformMatrix3x4fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); GL_APICALL void GL_APIENTRY glProgramUniformMatrix4x3fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); #endif #endif /* GL_EXT_separate_shader_objects */ #ifndef GL_EXT_shader_framebuffer_fetch #define GL_EXT_shader_framebuffer_fetch 1 #define GL_FRAGMENT_SHADER_DISCARDS_SAMPLES_EXT 0x8A52 #endif /* GL_EXT_shader_framebuffer_fetch */ #ifndef GL_EXT_shader_framebuffer_fetch_non_coherent #define GL_EXT_shader_framebuffer_fetch_non_coherent 1 typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERFETCHBARRIEREXTPROC) (void); #ifdef GL_GLEXT_PROTOTYPES GL_APICALL void GL_APIENTRY glFramebufferFetchBarrierEXT (void); #endif #endif /* GL_EXT_shader_framebuffer_fetch_non_coherent */ #ifndef GL_EXT_shader_group_vote #define GL_EXT_shader_group_vote 1 #endif /* GL_EXT_shader_group_vote */ #ifndef GL_EXT_shader_implicit_conversions #define GL_EXT_shader_implicit_conversions 1 #endif /* GL_EXT_shader_implicit_conversions */ #ifndef GL_EXT_shader_integer_mix #define GL_EXT_shader_integer_mix 1 #endif /* GL_EXT_shader_integer_mix */ #ifndef GL_EXT_shader_io_blocks #define GL_EXT_shader_io_blocks 1 #endif /* GL_EXT_shader_io_blocks */ #ifndef GL_EXT_shader_non_constant_global_initializers #define GL_EXT_shader_non_constant_global_initializers 1 #endif /* GL_EXT_shader_non_constant_global_initializers */ #ifndef GL_EXT_shader_pixel_local_storage #define GL_EXT_shader_pixel_local_storage 1 #define GL_MAX_SHADER_PIXEL_LOCAL_STORAGE_FAST_SIZE_EXT 0x8F63 #define GL_MAX_SHADER_PIXEL_LOCAL_STORAGE_SIZE_EXT 0x8F67 #define GL_SHADER_PIXEL_LOCAL_STORAGE_EXT 0x8F64 #endif /* GL_EXT_shader_pixel_local_storage */ #ifndef GL_EXT_shader_pixel_local_storage2 #define GL_EXT_shader_pixel_local_storage2 1 #define GL_MAX_SHADER_COMBINED_LOCAL_STORAGE_FAST_SIZE_EXT 0x9650 #define GL_MAX_SHADER_COMBINED_LOCAL_STORAGE_SIZE_EXT 0x9651 #define GL_FRAMEBUFFER_INCOMPLETE_INSUFFICIENT_SHADER_COMBINED_LOCAL_STORAGE_EXT 0x9652 typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERPIXELLOCALSTORAGESIZEEXTPROC) (GLuint target, GLsizei size); typedef GLsizei (GL_APIENTRYP PFNGLGETFRAMEBUFFERPIXELLOCALSTORAGESIZEEXTPROC) (GLuint target); typedef void (GL_APIENTRYP PFNGLCLEARPIXELLOCALSTORAGEUIEXTPROC) (GLsizei offset, GLsizei n, const GLuint *values); #ifdef GL_GLEXT_PROTOTYPES GL_APICALL void GL_APIENTRY glFramebufferPixelLocalStorageSizeEXT (GLuint target, GLsizei size); GL_APICALL GLsizei GL_APIENTRY glGetFramebufferPixelLocalStorageSizeEXT (GLuint target); GL_APICALL void GL_APIENTRY glClearPixelLocalStorageuiEXT (GLsizei offset, GLsizei n, const GLuint *values); #endif #endif /* GL_EXT_shader_pixel_local_storage2 */ #ifndef GL_EXT_shader_samples_identical #define GL_EXT_shader_samples_identical 1 #endif /* GL_EXT_shader_samples_identical */ #ifndef GL_EXT_shader_texture_lod #define GL_EXT_shader_texture_lod 1 #endif /* GL_EXT_shader_texture_lod */ #ifndef GL_EXT_shadow_samplers #define GL_EXT_shadow_samplers 1 #define GL_TEXTURE_COMPARE_MODE_EXT 0x884C #define GL_TEXTURE_COMPARE_FUNC_EXT 0x884D #define GL_COMPARE_REF_TO_TEXTURE_EXT 0x884E #define GL_SAMPLER_2D_SHADOW_EXT 0x8B62 #endif /* GL_EXT_shadow_samplers */ #ifndef GL_EXT_sparse_texture #define GL_EXT_sparse_texture 1 #define GL_TEXTURE_SPARSE_EXT 0x91A6 #define GL_VIRTUAL_PAGE_SIZE_INDEX_EXT 0x91A7 #define GL_NUM_SPARSE_LEVELS_EXT 0x91AA #define GL_NUM_VIRTUAL_PAGE_SIZES_EXT 0x91A8 #define GL_VIRTUAL_PAGE_SIZE_X_EXT 0x9195 #define GL_VIRTUAL_PAGE_SIZE_Y_EXT 0x9196 #define GL_VIRTUAL_PAGE_SIZE_Z_EXT 0x9197 #define GL_TEXTURE_2D_ARRAY 0x8C1A #define GL_TEXTURE_3D 0x806F #define GL_MAX_SPARSE_TEXTURE_SIZE_EXT 0x9198 #define GL_MAX_SPARSE_3D_TEXTURE_SIZE_EXT 0x9199 #define GL_MAX_SPARSE_ARRAY_TEXTURE_LAYERS_EXT 0x919A #define GL_SPARSE_TEXTURE_FULL_ARRAY_CUBE_MIPMAPS_EXT 0x91A9 typedef void (GL_APIENTRYP PFNGLTEXPAGECOMMITMENTEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLboolean commit); #ifdef GL_GLEXT_PROTOTYPES GL_APICALL void GL_APIENTRY glTexPageCommitmentEXT (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLboolean commit); #endif #endif /* GL_EXT_sparse_texture */ #ifndef GL_EXT_sparse_texture2 #define GL_EXT_sparse_texture2 1 #endif /* GL_EXT_sparse_texture2 */ #ifndef GL_EXT_tessellation_point_size #define GL_EXT_tessellation_point_size 1 #endif /* GL_EXT_tessellation_point_size */ #ifndef GL_EXT_tessellation_shader #define GL_EXT_tessellation_shader 1 #define GL_PATCHES_EXT 0x000E #define GL_PATCH_VERTICES_EXT 0x8E72 #define GL_TESS_CONTROL_OUTPUT_VERTICES_EXT 0x8E75 #define GL_TESS_GEN_MODE_EXT 0x8E76 #define GL_TESS_GEN_SPACING_EXT 0x8E77 #define GL_TESS_GEN_VERTEX_ORDER_EXT 0x8E78 #define GL_TESS_GEN_POINT_MODE_EXT 0x8E79 #define GL_ISOLINES_EXT 0x8E7A #define GL_QUADS_EXT 0x0007 #define GL_FRACTIONAL_ODD_EXT 0x8E7B #define GL_FRACTIONAL_EVEN_EXT 0x8E7C #define GL_MAX_PATCH_VERTICES_EXT 0x8E7D #define GL_MAX_TESS_GEN_LEVEL_EXT 0x8E7E #define GL_MAX_TESS_CONTROL_UNIFORM_COMPONENTS_EXT 0x8E7F #define GL_MAX_TESS_EVALUATION_UNIFORM_COMPONENTS_EXT 0x8E80 #define GL_MAX_TESS_CONTROL_TEXTURE_IMAGE_UNITS_EXT 0x8E81 #define GL_MAX_TESS_EVALUATION_TEXTURE_IMAGE_UNITS_EXT 0x8E82 #define GL_MAX_TESS_CONTROL_OUTPUT_COMPONENTS_EXT 0x8E83 #define GL_MAX_TESS_PATCH_COMPONENTS_EXT 0x8E84 #define GL_MAX_TESS_CONTROL_TOTAL_OUTPUT_COMPONENTS_EXT 0x8E85 #define GL_MAX_TESS_EVALUATION_OUTPUT_COMPONENTS_EXT 0x8E86 #define GL_MAX_TESS_CONTROL_UNIFORM_BLOCKS_EXT 0x8E89 #define GL_MAX_TESS_EVALUATION_UNIFORM_BLOCKS_EXT 0x8E8A #define GL_MAX_TESS_CONTROL_INPUT_COMPONENTS_EXT 0x886C #define GL_MAX_TESS_EVALUATION_INPUT_COMPONENTS_EXT 0x886D #define GL_MAX_COMBINED_TESS_CONTROL_UNIFORM_COMPONENTS_EXT 0x8E1E #define GL_MAX_COMBINED_TESS_EVALUATION_UNIFORM_COMPONENTS_EXT 0x8E1F #define GL_MAX_TESS_CONTROL_ATOMIC_COUNTER_BUFFERS_EXT 0x92CD #define GL_MAX_TESS_EVALUATION_ATOMIC_COUNTER_BUFFERS_EXT 0x92CE #define GL_MAX_TESS_CONTROL_ATOMIC_COUNTERS_EXT 0x92D3 #define GL_MAX_TESS_EVALUATION_ATOMIC_COUNTERS_EXT 0x92D4 #define GL_MAX_TESS_CONTROL_IMAGE_UNIFORMS_EXT 0x90CB #define GL_MAX_TESS_EVALUATION_IMAGE_UNIFORMS_EXT 0x90CC #define GL_MAX_TESS_CONTROL_SHADER_STORAGE_BLOCKS_EXT 0x90D8 #define GL_MAX_TESS_EVALUATION_SHADER_STORAGE_BLOCKS_EXT 0x90D9 #define GL_PRIMITIVE_RESTART_FOR_PATCHES_SUPPORTED 0x8221 #define GL_IS_PER_PATCH_EXT 0x92E7 #define GL_REFERENCED_BY_TESS_CONTROL_SHADER_EXT 0x9307 #define GL_REFERENCED_BY_TESS_EVALUATION_SHADER_EXT 0x9308 #define GL_TESS_CONTROL_SHADER_EXT 0x8E88 #define GL_TESS_EVALUATION_SHADER_EXT 0x8E87 #define GL_TESS_CONTROL_SHADER_BIT_EXT 0x00000008 #define GL_TESS_EVALUATION_SHADER_BIT_EXT 0x00000010 typedef void (GL_APIENTRYP PFNGLPATCHPARAMETERIEXTPROC) (GLenum pname, GLint value); #ifdef GL_GLEXT_PROTOTYPES GL_APICALL void GL_APIENTRY glPatchParameteriEXT (GLenum pname, GLint value); #endif #endif /* GL_EXT_tessellation_shader */ #ifndef GL_EXT_texture_border_clamp #define GL_EXT_texture_border_clamp 1 #define GL_TEXTURE_BORDER_COLOR_EXT 0x1004 #define GL_CLAMP_TO_BORDER_EXT 0x812D typedef void (GL_APIENTRYP PFNGLTEXPARAMETERIIVEXTPROC) (GLenum target, GLenum pname, const GLint *params); typedef void (GL_APIENTRYP PFNGLTEXPARAMETERIUIVEXTPROC) (GLenum target, GLenum pname, const GLuint *params); typedef void (GL_APIENTRYP PFNGLGETTEXPARAMETERIIVEXTPROC) (GLenum target, GLenum pname, GLint *params); typedef void (GL_APIENTRYP PFNGLGETTEXPARAMETERIUIVEXTPROC) (GLenum target, GLenum pname, GLuint *params); typedef void (GL_APIENTRYP PFNGLSAMPLERPARAMETERIIVEXTPROC) (GLuint sampler, GLenum pname, const GLint *param); typedef void (GL_APIENTRYP PFNGLSAMPLERPARAMETERIUIVEXTPROC) (GLuint sampler, GLenum pname, const GLuint *param); typedef void (GL_APIENTRYP PFNGLGETSAMPLERPARAMETERIIVEXTPROC) (GLuint sampler, GLenum pname, GLint *params); typedef void (GL_APIENTRYP PFNGLGETSAMPLERPARAMETERIUIVEXTPROC) (GLuint sampler, GLenum pname, GLuint *params); #ifdef GL_GLEXT_PROTOTYPES GL_APICALL void GL_APIENTRY glTexParameterIivEXT (GLenum target, GLenum pname, const GLint *params); GL_APICALL void GL_APIENTRY glTexParameterIuivEXT (GLenum target, GLenum pname, const GLuint *params); GL_APICALL void GL_APIENTRY glGetTexParameterIivEXT (GLenum target, GLenum pname, GLint *params); GL_APICALL void GL_APIENTRY glGetTexParameterIuivEXT (GLenum target, GLenum pname, GLuint *params); GL_APICALL void GL_APIENTRY glSamplerParameterIivEXT (GLuint sampler, GLenum pname, const GLint *param); GL_APICALL void GL_APIENTRY glSamplerParameterIuivEXT (GLuint sampler, GLenum pname, const GLuint *param); GL_APICALL void GL_APIENTRY glGetSamplerParameterIivEXT (GLuint sampler, GLenum pname, GLint *params); GL_APICALL void GL_APIENTRY glGetSamplerParameterIuivEXT (GLuint sampler, GLenum pname, GLuint *params); #endif #endif /* GL_EXT_texture_border_clamp */ #ifndef GL_EXT_texture_buffer #define GL_EXT_texture_buffer 1 #define GL_TEXTURE_BUFFER_EXT 0x8C2A #define GL_TEXTURE_BUFFER_BINDING_EXT 0x8C2A #define GL_MAX_TEXTURE_BUFFER_SIZE_EXT 0x8C2B #define GL_TEXTURE_BINDING_BUFFER_EXT 0x8C2C #define GL_TEXTURE_BUFFER_DATA_STORE_BINDING_EXT 0x8C2D #define GL_TEXTURE_BUFFER_OFFSET_ALIGNMENT_EXT 0x919F #define GL_SAMPLER_BUFFER_EXT 0x8DC2 #define GL_INT_SAMPLER_BUFFER_EXT 0x8DD0 #define GL_UNSIGNED_INT_SAMPLER_BUFFER_EXT 0x8DD8 #define GL_IMAGE_BUFFER_EXT 0x9051 #define GL_INT_IMAGE_BUFFER_EXT 0x905C #define GL_UNSIGNED_INT_IMAGE_BUFFER_EXT 0x9067 #define GL_TEXTURE_BUFFER_OFFSET_EXT 0x919D #define GL_TEXTURE_BUFFER_SIZE_EXT 0x919E typedef void (GL_APIENTRYP PFNGLTEXBUFFEREXTPROC) (GLenum target, GLenum internalformat, GLuint buffer); typedef void (GL_APIENTRYP PFNGLTEXBUFFERRANGEEXTPROC) (GLenum target, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size); #ifdef GL_GLEXT_PROTOTYPES GL_APICALL void GL_APIENTRY glTexBufferEXT (GLenum target, GLenum internalformat, GLuint buffer); GL_APICALL void GL_APIENTRY glTexBufferRangeEXT (GLenum target, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size); #endif #endif /* GL_EXT_texture_buffer */ #ifndef GL_EXT_texture_compression_astc_decode_mode #define GL_EXT_texture_compression_astc_decode_mode 1 #define GL_TEXTURE_ASTC_DECODE_PRECISION_EXT 0x8F69 #endif /* GL_EXT_texture_compression_astc_decode_mode */ #ifndef GL_EXT_texture_compression_bptc #define GL_EXT_texture_compression_bptc 1 #define GL_COMPRESSED_RGBA_BPTC_UNORM_EXT 0x8E8C #define GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT 0x8E8D #define GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT 0x8E8E #define GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT 0x8E8F #endif /* GL_EXT_texture_compression_bptc */ #ifndef GL_EXT_texture_compression_dxt1 #define GL_EXT_texture_compression_dxt1 1 #define GL_COMPRESSED_RGB_S3TC_DXT1_EXT 0x83F0 #define GL_COMPRESSED_RGBA_S3TC_DXT1_EXT 0x83F1 #endif /* GL_EXT_texture_compression_dxt1 */ #ifndef GL_EXT_texture_compression_rgtc #define GL_EXT_texture_compression_rgtc 1 #define GL_COMPRESSED_RED_RGTC1_EXT 0x8DBB #define GL_COMPRESSED_SIGNED_RED_RGTC1_EXT 0x8DBC #define GL_COMPRESSED_RED_GREEN_RGTC2_EXT 0x8DBD #define GL_COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT 0x8DBE #endif /* GL_EXT_texture_compression_rgtc */ #ifndef GL_EXT_texture_compression_s3tc #define GL_EXT_texture_compression_s3tc 1 #define GL_COMPRESSED_RGBA_S3TC_DXT3_EXT 0x83F2 #define GL_COMPRESSED_RGBA_S3TC_DXT5_EXT 0x83F3 #endif /* GL_EXT_texture_compression_s3tc */ #ifndef GL_EXT_texture_compression_s3tc_srgb #define GL_EXT_texture_compression_s3tc_srgb 1 #define GL_COMPRESSED_SRGB_S3TC_DXT1_EXT 0x8C4C #define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT 0x8C4D #define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT 0x8C4E #define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT 0x8C4F #endif /* GL_EXT_texture_compression_s3tc_srgb */ #ifndef GL_EXT_texture_cube_map_array #define GL_EXT_texture_cube_map_array 1 #define GL_TEXTURE_CUBE_MAP_ARRAY_EXT 0x9009 #define GL_TEXTURE_BINDING_CUBE_MAP_ARRAY_EXT 0x900A #define GL_SAMPLER_CUBE_MAP_ARRAY_EXT 0x900C #define GL_SAMPLER_CUBE_MAP_ARRAY_SHADOW_EXT 0x900D #define GL_INT_SAMPLER_CUBE_MAP_ARRAY_EXT 0x900E #define GL_UNSIGNED_INT_SAMPLER_CUBE_MAP_ARRAY_EXT 0x900F #define GL_IMAGE_CUBE_MAP_ARRAY_EXT 0x9054 #define GL_INT_IMAGE_CUBE_MAP_ARRAY_EXT 0x905F #define GL_UNSIGNED_INT_IMAGE_CUBE_MAP_ARRAY_EXT 0x906A #endif /* GL_EXT_texture_cube_map_array */ #ifndef GL_EXT_texture_filter_anisotropic #define GL_EXT_texture_filter_anisotropic 1 #define GL_TEXTURE_MAX_ANISOTROPY_EXT 0x84FE #define GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT 0x84FF #endif /* GL_EXT_texture_filter_anisotropic */ #ifndef GL_EXT_texture_filter_minmax #define GL_EXT_texture_filter_minmax 1 #define GL_TEXTURE_REDUCTION_MODE_EXT 0x9366 #define GL_WEIGHTED_AVERAGE_EXT 0x9367 #endif /* GL_EXT_texture_filter_minmax */ #ifndef GL_EXT_texture_format_BGRA8888 #define GL_EXT_texture_format_BGRA8888 1 #endif /* GL_EXT_texture_format_BGRA8888 */ #ifndef GL_EXT_texture_format_sRGB_override #define GL_EXT_texture_format_sRGB_override 1 #define GL_TEXTURE_FORMAT_SRGB_OVERRIDE_EXT 0x8FBF #endif /* GL_EXT_texture_format_sRGB_override */ #ifndef GL_EXT_texture_mirror_clamp_to_edge #define GL_EXT_texture_mirror_clamp_to_edge 1 #define GL_MIRROR_CLAMP_TO_EDGE_EXT 0x8743 #endif /* GL_EXT_texture_mirror_clamp_to_edge */ #ifndef GL_EXT_texture_norm16 #define GL_EXT_texture_norm16 1 #define GL_R16_EXT 0x822A #define GL_RG16_EXT 0x822C #define GL_RGBA16_EXT 0x805B #define GL_RGB16_EXT 0x8054 #define GL_RGB16_SNORM_EXT 0x8F9A #endif /* GL_EXT_texture_norm16 */ #ifndef GL_EXT_texture_query_lod #define GL_EXT_texture_query_lod 1 #endif /* GL_EXT_texture_query_lod */ #ifndef GL_EXT_texture_rg #define GL_EXT_texture_rg 1 #define GL_RED_EXT 0x1903 #define GL_RG_EXT 0x8227 #define GL_R8_EXT 0x8229 #define GL_RG8_EXT 0x822B #endif /* GL_EXT_texture_rg */ #ifndef GL_EXT_texture_sRGB_R8 #define GL_EXT_texture_sRGB_R8 1 #define GL_SR8_EXT 0x8FBD #endif /* GL_EXT_texture_sRGB_R8 */ #ifndef GL_EXT_texture_sRGB_RG8 #define GL_EXT_texture_sRGB_RG8 1 #define GL_SRG8_EXT 0x8FBE #endif /* GL_EXT_texture_sRGB_RG8 */ #ifndef GL_EXT_texture_sRGB_decode #define GL_EXT_texture_sRGB_decode 1 #define GL_TEXTURE_SRGB_DECODE_EXT 0x8A48 #define GL_DECODE_EXT 0x8A49 #define GL_SKIP_DECODE_EXT 0x8A4A #endif /* GL_EXT_texture_sRGB_decode */ #ifndef GL_EXT_texture_shadow_lod #define GL_EXT_texture_shadow_lod 1 #endif /* GL_EXT_texture_shadow_lod */ #ifndef GL_EXT_texture_storage #define GL_EXT_texture_storage 1 #define GL_TEXTURE_IMMUTABLE_FORMAT_EXT 0x912F #define GL_ALPHA8_EXT 0x803C #define GL_LUMINANCE8_EXT 0x8040 #define GL_LUMINANCE8_ALPHA8_EXT 0x8045 #define GL_RGBA32F_EXT 0x8814 #define GL_RGB32F_EXT 0x8815 #define GL_ALPHA32F_EXT 0x8816 #define GL_LUMINANCE32F_EXT 0x8818 #define GL_LUMINANCE_ALPHA32F_EXT 0x8819 #define GL_ALPHA16F_EXT 0x881C #define GL_LUMINANCE16F_EXT 0x881E #define GL_LUMINANCE_ALPHA16F_EXT 0x881F #define GL_R32F_EXT 0x822E #define GL_RG32F_EXT 0x8230 typedef void (GL_APIENTRYP PFNGLTEXSTORAGE1DEXTPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width); typedef void (GL_APIENTRYP PFNGLTEXSTORAGE2DEXTPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); typedef void (GL_APIENTRYP PFNGLTEXSTORAGE3DEXTPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); typedef void (GL_APIENTRYP PFNGLTEXTURESTORAGE1DEXTPROC) (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width); typedef void (GL_APIENTRYP PFNGLTEXTURESTORAGE2DEXTPROC) (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); typedef void (GL_APIENTRYP PFNGLTEXTURESTORAGE3DEXTPROC) (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); #ifdef GL_GLEXT_PROTOTYPES GL_APICALL void GL_APIENTRY glTexStorage1DEXT (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width); GL_APICALL void GL_APIENTRY glTexStorage2DEXT (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); GL_APICALL void GL_APIENTRY glTexStorage3DEXT (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); GL_APICALL void GL_APIENTRY glTextureStorage1DEXT (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width); GL_APICALL void GL_APIENTRY glTextureStorage2DEXT (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); GL_APICALL void GL_APIENTRY glTextureStorage3DEXT (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); #endif #endif /* GL_EXT_texture_storage */ #ifndef GL_EXT_texture_storage_compression #define GL_EXT_texture_storage_compression 1 #define GL_NUM_SURFACE_COMPRESSION_FIXED_RATES_EXT 0x8F6E #define GL_SURFACE_COMPRESSION_FIXED_RATE_1BPC_EXT 0x96C4 #define GL_SURFACE_COMPRESSION_FIXED_RATE_2BPC_EXT 0x96C5 #define GL_SURFACE_COMPRESSION_FIXED_RATE_3BPC_EXT 0x96C6 #define GL_SURFACE_COMPRESSION_FIXED_RATE_4BPC_EXT 0x96C7 #define GL_SURFACE_COMPRESSION_FIXED_RATE_5BPC_EXT 0x96C8 #define GL_SURFACE_COMPRESSION_FIXED_RATE_6BPC_EXT 0x96C9 #define GL_SURFACE_COMPRESSION_FIXED_RATE_7BPC_EXT 0x96CA #define GL_SURFACE_COMPRESSION_FIXED_RATE_8BPC_EXT 0x96CB #define GL_SURFACE_COMPRESSION_FIXED_RATE_9BPC_EXT 0x96CC #define GL_SURFACE_COMPRESSION_FIXED_RATE_10BPC_EXT 0x96CD #define GL_SURFACE_COMPRESSION_FIXED_RATE_11BPC_EXT 0x96CE #define GL_SURFACE_COMPRESSION_FIXED_RATE_12BPC_EXT 0x96CF typedef void (GL_APIENTRYP PFNGLTEXSTORAGEATTRIBS2DEXTPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, const GLint* attrib_list); typedef void (GL_APIENTRYP PFNGLTEXSTORAGEATTRIBS3DEXTPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, const GLint* attrib_list); #ifdef GL_GLEXT_PROTOTYPES GL_APICALL void GL_APIENTRY glTexStorageAttribs2DEXT (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, const GLint* attrib_list); GL_APICALL void GL_APIENTRY glTexStorageAttribs3DEXT (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, const GLint* attrib_list); #endif #endif /* GL_EXT_texture_storage_compression */ #ifndef GL_EXT_texture_type_2_10_10_10_REV #define GL_EXT_texture_type_2_10_10_10_REV 1 #define GL_UNSIGNED_INT_2_10_10_10_REV_EXT 0x8368 #endif /* GL_EXT_texture_type_2_10_10_10_REV */ #ifndef GL_EXT_texture_view #define GL_EXT_texture_view 1 #define GL_TEXTURE_VIEW_MIN_LEVEL_EXT 0x82DB #define GL_TEXTURE_VIEW_NUM_LEVELS_EXT 0x82DC #define GL_TEXTURE_VIEW_MIN_LAYER_EXT 0x82DD #define GL_TEXTURE_VIEW_NUM_LAYERS_EXT 0x82DE typedef void (GL_APIENTRYP PFNGLTEXTUREVIEWEXTPROC) (GLuint texture, GLenum target, GLuint origtexture, GLenum internalformat, GLuint minlevel, GLuint numlevels, GLuint minlayer, GLuint numlayers); #ifdef GL_GLEXT_PROTOTYPES GL_APICALL void GL_APIENTRY glTextureViewEXT (GLuint texture, GLenum target, GLuint origtexture, GLenum internalformat, GLuint minlevel, GLuint numlevels, GLuint minlayer, GLuint numlayers); #endif #endif /* GL_EXT_texture_view */ #ifndef GL_EXT_unpack_subimage #define GL_EXT_unpack_subimage 1 #define GL_UNPACK_ROW_LENGTH_EXT 0x0CF2 #define GL_UNPACK_SKIP_ROWS_EXT 0x0CF3 #define GL_UNPACK_SKIP_PIXELS_EXT 0x0CF4 #endif /* GL_EXT_unpack_subimage */ #ifndef GL_EXT_win32_keyed_mutex #define GL_EXT_win32_keyed_mutex 1 typedef GLboolean (GL_APIENTRYP PFNGLACQUIREKEYEDMUTEXWIN32EXTPROC) (GLuint memory, GLuint64 key, GLuint timeout); typedef GLboolean (GL_APIENTRYP PFNGLRELEASEKEYEDMUTEXWIN32EXTPROC) (GLuint memory, GLuint64 key); #ifdef GL_GLEXT_PROTOTYPES GL_APICALL GLboolean GL_APIENTRY glAcquireKeyedMutexWin32EXT (GLuint memory, GLuint64 key, GLuint timeout); GL_APICALL GLboolean GL_APIENTRY glReleaseKeyedMutexWin32EXT (GLuint memory, GLuint64 key); #endif #endif /* GL_EXT_win32_keyed_mutex */ #ifndef GL_EXT_window_rectangles #define GL_EXT_window_rectangles 1 #define GL_INCLUSIVE_EXT 0x8F10 #define GL_EXCLUSIVE_EXT 0x8F11 #define GL_WINDOW_RECTANGLE_EXT 0x8F12 #define GL_WINDOW_RECTANGLE_MODE_EXT 0x8F13 #define GL_MAX_WINDOW_RECTANGLES_EXT 0x8F14 #define GL_NUM_WINDOW_RECTANGLES_EXT 0x8F15 typedef void (GL_APIENTRYP PFNGLWINDOWRECTANGLESEXTPROC) (GLenum mode, GLsizei count, const GLint *box); #ifdef GL_GLEXT_PROTOTYPES GL_APICALL void GL_APIENTRY glWindowRectanglesEXT (GLenum mode, GLsizei count, const GLint *box); #endif #endif /* GL_EXT_window_rectangles */ #ifndef GL_FJ_shader_binary_GCCSO #define GL_FJ_shader_binary_GCCSO 1 #define GL_GCCSO_SHADER_BINARY_FJ 0x9260 #endif /* GL_FJ_shader_binary_GCCSO */ #ifndef GL_IMG_bindless_texture #define GL_IMG_bindless_texture 1 typedef GLuint64 (GL_APIENTRYP PFNGLGETTEXTUREHANDLEIMGPROC) (GLuint texture); typedef GLuint64 (GL_APIENTRYP PFNGLGETTEXTURESAMPLERHANDLEIMGPROC) (GLuint texture, GLuint sampler); typedef void (GL_APIENTRYP PFNGLUNIFORMHANDLEUI64IMGPROC) (GLint location, GLuint64 value); typedef void (GL_APIENTRYP PFNGLUNIFORMHANDLEUI64VIMGPROC) (GLint location, GLsizei count, const GLuint64 *value); typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORMHANDLEUI64IMGPROC) (GLuint program, GLint location, GLuint64 value); typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORMHANDLEUI64VIMGPROC) (GLuint program, GLint location, GLsizei count, const GLuint64 *values); #ifdef GL_GLEXT_PROTOTYPES GL_APICALL GLuint64 GL_APIENTRY glGetTextureHandleIMG (GLuint texture); GL_APICALL GLuint64 GL_APIENTRY glGetTextureSamplerHandleIMG (GLuint texture, GLuint sampler); GL_APICALL void GL_APIENTRY glUniformHandleui64IMG (GLint location, GLuint64 value); GL_APICALL void GL_APIENTRY glUniformHandleui64vIMG (GLint location, GLsizei count, const GLuint64 *value); GL_APICALL void GL_APIENTRY glProgramUniformHandleui64IMG (GLuint program, GLint location, GLuint64 value); GL_APICALL void GL_APIENTRY glProgramUniformHandleui64vIMG (GLuint program, GLint location, GLsizei count, const GLuint64 *values); #endif #endif /* GL_IMG_bindless_texture */ #ifndef GL_IMG_framebuffer_downsample #define GL_IMG_framebuffer_downsample 1 #define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_AND_DOWNSAMPLE_IMG 0x913C #define GL_NUM_DOWNSAMPLE_SCALES_IMG 0x913D #define GL_DOWNSAMPLE_SCALES_IMG 0x913E #define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_SCALE_IMG 0x913F typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DDOWNSAMPLEIMGPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint xscale, GLint yscale); typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERTEXTURELAYERDOWNSAMPLEIMGPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer, GLint xscale, GLint yscale); #ifdef GL_GLEXT_PROTOTYPES GL_APICALL void GL_APIENTRY glFramebufferTexture2DDownsampleIMG (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint xscale, GLint yscale); GL_APICALL void GL_APIENTRY glFramebufferTextureLayerDownsampleIMG (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer, GLint xscale, GLint yscale); #endif #endif /* GL_IMG_framebuffer_downsample */ #ifndef GL_IMG_multisampled_render_to_texture #define GL_IMG_multisampled_render_to_texture 1 #define GL_RENDERBUFFER_SAMPLES_IMG 0x9133 #define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_IMG 0x9134 #define GL_MAX_SAMPLES_IMG 0x9135 #define GL_TEXTURE_SAMPLES_IMG 0x9136 typedef void (GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEIMGPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DMULTISAMPLEIMGPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLsizei samples); #ifdef GL_GLEXT_PROTOTYPES GL_APICALL void GL_APIENTRY glRenderbufferStorageMultisampleIMG (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); GL_APICALL void GL_APIENTRY glFramebufferTexture2DMultisampleIMG (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLsizei samples); #endif #endif /* GL_IMG_multisampled_render_to_texture */ #ifndef GL_IMG_program_binary #define GL_IMG_program_binary 1 #define GL_SGX_PROGRAM_BINARY_IMG 0x9130 #endif /* GL_IMG_program_binary */ #ifndef GL_IMG_read_format #define GL_IMG_read_format 1 #define GL_BGRA_IMG 0x80E1 #define GL_UNSIGNED_SHORT_4_4_4_4_REV_IMG 0x8365 #endif /* GL_IMG_read_format */ #ifndef GL_IMG_shader_binary #define GL_IMG_shader_binary 1 #define GL_SGX_BINARY_IMG 0x8C0A #endif /* GL_IMG_shader_binary */ #ifndef GL_IMG_texture_compression_pvrtc #define GL_IMG_texture_compression_pvrtc 1 #define GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG 0x8C00 #define GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG 0x8C01 #define GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG 0x8C02 #define GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG 0x8C03 #endif /* GL_IMG_texture_compression_pvrtc */ #ifndef GL_IMG_texture_compression_pvrtc2 #define GL_IMG_texture_compression_pvrtc2 1 #define GL_COMPRESSED_RGBA_PVRTC_2BPPV2_IMG 0x9137 #define GL_COMPRESSED_RGBA_PVRTC_4BPPV2_IMG 0x9138 #endif /* GL_IMG_texture_compression_pvrtc2 */ #ifndef GL_IMG_texture_filter_cubic #define GL_IMG_texture_filter_cubic 1 #define GL_CUBIC_IMG 0x9139 #define GL_CUBIC_MIPMAP_NEAREST_IMG 0x913A #define GL_CUBIC_MIPMAP_LINEAR_IMG 0x913B #endif /* GL_IMG_texture_filter_cubic */ #ifndef GL_INTEL_blackhole_render #define GL_INTEL_blackhole_render 1 #define GL_BLACKHOLE_RENDER_INTEL 0x83FC #endif /* GL_INTEL_blackhole_render */ #ifndef GL_INTEL_conservative_rasterization #define GL_INTEL_conservative_rasterization 1 #define GL_CONSERVATIVE_RASTERIZATION_INTEL 0x83FE #endif /* GL_INTEL_conservative_rasterization */ #ifndef GL_INTEL_framebuffer_CMAA #define GL_INTEL_framebuffer_CMAA 1 typedef void (GL_APIENTRYP PFNGLAPPLYFRAMEBUFFERATTACHMENTCMAAINTELPROC) (void); #ifdef GL_GLEXT_PROTOTYPES GL_APICALL void GL_APIENTRY glApplyFramebufferAttachmentCMAAINTEL (void); #endif #endif /* GL_INTEL_framebuffer_CMAA */ #ifndef GL_INTEL_performance_query #define GL_INTEL_performance_query 1 #define GL_PERFQUERY_SINGLE_CONTEXT_INTEL 0x00000000 #define GL_PERFQUERY_GLOBAL_CONTEXT_INTEL 0x00000001 #define GL_PERFQUERY_WAIT_INTEL 0x83FB #define GL_PERFQUERY_FLUSH_INTEL 0x83FA #define GL_PERFQUERY_DONOT_FLUSH_INTEL 0x83F9 #define GL_PERFQUERY_COUNTER_EVENT_INTEL 0x94F0 #define GL_PERFQUERY_COUNTER_DURATION_NORM_INTEL 0x94F1 #define GL_PERFQUERY_COUNTER_DURATION_RAW_INTEL 0x94F2 #define GL_PERFQUERY_COUNTER_THROUGHPUT_INTEL 0x94F3 #define GL_PERFQUERY_COUNTER_RAW_INTEL 0x94F4 #define GL_PERFQUERY_COUNTER_TIMESTAMP_INTEL 0x94F5 #define GL_PERFQUERY_COUNTER_DATA_UINT32_INTEL 0x94F8 #define GL_PERFQUERY_COUNTER_DATA_UINT64_INTEL 0x94F9 #define GL_PERFQUERY_COUNTER_DATA_FLOAT_INTEL 0x94FA #define GL_PERFQUERY_COUNTER_DATA_DOUBLE_INTEL 0x94FB #define GL_PERFQUERY_COUNTER_DATA_BOOL32_INTEL 0x94FC #define GL_PERFQUERY_QUERY_NAME_LENGTH_MAX_INTEL 0x94FD #define GL_PERFQUERY_COUNTER_NAME_LENGTH_MAX_INTEL 0x94FE #define GL_PERFQUERY_COUNTER_DESC_LENGTH_MAX_INTEL 0x94FF #define GL_PERFQUERY_GPA_EXTENDED_COUNTERS_INTEL 0x9500 typedef void (GL_APIENTRYP PFNGLBEGINPERFQUERYINTELPROC) (GLuint queryHandle); typedef void (GL_APIENTRYP PFNGLCREATEPERFQUERYINTELPROC) (GLuint queryId, GLuint *queryHandle); typedef void (GL_APIENTRYP PFNGLDELETEPERFQUERYINTELPROC) (GLuint queryHandle); typedef void (GL_APIENTRYP PFNGLENDPERFQUERYINTELPROC) (GLuint queryHandle); typedef void (GL_APIENTRYP PFNGLGETFIRSTPERFQUERYIDINTELPROC) (GLuint *queryId); typedef void (GL_APIENTRYP PFNGLGETNEXTPERFQUERYIDINTELPROC) (GLuint queryId, GLuint *nextQueryId); typedef void (GL_APIENTRYP PFNGLGETPERFCOUNTERINFOINTELPROC) (GLuint queryId, GLuint counterId, GLuint counterNameLength, GLchar *counterName, GLuint counterDescLength, GLchar *counterDesc, GLuint *counterOffset, GLuint *counterDataSize, GLuint *counterTypeEnum, GLuint *counterDataTypeEnum, GLuint64 *rawCounterMaxValue); typedef void (GL_APIENTRYP PFNGLGETPERFQUERYDATAINTELPROC) (GLuint queryHandle, GLuint flags, GLsizei dataSize, void *data, GLuint *bytesWritten); typedef void (GL_APIENTRYP PFNGLGETPERFQUERYIDBYNAMEINTELPROC) (GLchar *queryName, GLuint *queryId); typedef void (GL_APIENTRYP PFNGLGETPERFQUERYINFOINTELPROC) (GLuint queryId, GLuint queryNameLength, GLchar *queryName, GLuint *dataSize, GLuint *noCounters, GLuint *noInstances, GLuint *capsMask); #ifdef GL_GLEXT_PROTOTYPES GL_APICALL void GL_APIENTRY glBeginPerfQueryINTEL (GLuint queryHandle); GL_APICALL void GL_APIENTRY glCreatePerfQueryINTEL (GLuint queryId, GLuint *queryHandle); GL_APICALL void GL_APIENTRY glDeletePerfQueryINTEL (GLuint queryHandle); GL_APICALL void GL_APIENTRY glEndPerfQueryINTEL (GLuint queryHandle); GL_APICALL void GL_APIENTRY glGetFirstPerfQueryIdINTEL (GLuint *queryId); GL_APICALL void GL_APIENTRY glGetNextPerfQueryIdINTEL (GLuint queryId, GLuint *nextQueryId); GL_APICALL void GL_APIENTRY glGetPerfCounterInfoINTEL (GLuint queryId, GLuint counterId, GLuint counterNameLength, GLchar *counterName, GLuint counterDescLength, GLchar *counterDesc, GLuint *counterOffset, GLuint *counterDataSize, GLuint *counterTypeEnum, GLuint *counterDataTypeEnum, GLuint64 *rawCounterMaxValue); GL_APICALL void GL_APIENTRY glGetPerfQueryDataINTEL (GLuint queryHandle, GLuint flags, GLsizei dataSize, void *data, GLuint *bytesWritten); GL_APICALL void GL_APIENTRY glGetPerfQueryIdByNameINTEL (GLchar *queryName, GLuint *queryId); GL_APICALL void GL_APIENTRY glGetPerfQueryInfoINTEL (GLuint queryId, GLuint queryNameLength, GLchar *queryName, GLuint *dataSize, GLuint *noCounters, GLuint *noInstances, GLuint *capsMask); #endif #endif /* GL_INTEL_performance_query */ #ifndef GL_MESA_bgra #define GL_MESA_bgra 1 #define GL_BGR_EXT 0x80E0 #endif /* GL_MESA_bgra */ #ifndef GL_MESA_framebuffer_flip_x #define GL_MESA_framebuffer_flip_x 1 #define GL_FRAMEBUFFER_FLIP_X_MESA 0x8BBC #endif /* GL_MESA_framebuffer_flip_x */ #ifndef GL_MESA_framebuffer_flip_y #define GL_MESA_framebuffer_flip_y 1 #define GL_FRAMEBUFFER_FLIP_Y_MESA 0x8BBB typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERPARAMETERIMESAPROC) (GLenum target, GLenum pname, GLint param); typedef void (GL_APIENTRYP PFNGLGETFRAMEBUFFERPARAMETERIVMESAPROC) (GLenum target, GLenum pname, GLint *params); #ifdef GL_GLEXT_PROTOTYPES GL_APICALL void GL_APIENTRY glFramebufferParameteriMESA (GLenum target, GLenum pname, GLint param); GL_APICALL void GL_APIENTRY glGetFramebufferParameterivMESA (GLenum target, GLenum pname, GLint *params); #endif #endif /* GL_MESA_framebuffer_flip_y */ #ifndef GL_MESA_framebuffer_swap_xy #define GL_MESA_framebuffer_swap_xy 1 #define GL_FRAMEBUFFER_SWAP_XY_MESA 0x8BBD #endif /* GL_MESA_framebuffer_swap_xy */ #ifndef GL_MESA_program_binary_formats #define GL_MESA_program_binary_formats 1 #define GL_PROGRAM_BINARY_FORMAT_MESA 0x875F #endif /* GL_MESA_program_binary_formats */ #ifndef GL_MESA_shader_integer_functions #define GL_MESA_shader_integer_functions 1 #endif /* GL_MESA_shader_integer_functions */ #ifndef GL_NVX_blend_equation_advanced_multi_draw_buffers #define GL_NVX_blend_equation_advanced_multi_draw_buffers 1 #endif /* GL_NVX_blend_equation_advanced_multi_draw_buffers */ #ifndef GL_NV_bindless_texture #define GL_NV_bindless_texture 1 typedef GLuint64 (GL_APIENTRYP PFNGLGETTEXTUREHANDLENVPROC) (GLuint texture); typedef GLuint64 (GL_APIENTRYP PFNGLGETTEXTURESAMPLERHANDLENVPROC) (GLuint texture, GLuint sampler); typedef void (GL_APIENTRYP PFNGLMAKETEXTUREHANDLERESIDENTNVPROC) (GLuint64 handle); typedef void (GL_APIENTRYP PFNGLMAKETEXTUREHANDLENONRESIDENTNVPROC) (GLuint64 handle); typedef GLuint64 (GL_APIENTRYP PFNGLGETIMAGEHANDLENVPROC) (GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum format); typedef void (GL_APIENTRYP PFNGLMAKEIMAGEHANDLERESIDENTNVPROC) (GLuint64 handle, GLenum access); typedef void (GL_APIENTRYP PFNGLMAKEIMAGEHANDLENONRESIDENTNVPROC) (GLuint64 handle); typedef void (GL_APIENTRYP PFNGLUNIFORMHANDLEUI64NVPROC) (GLint location, GLuint64 value); typedef void (GL_APIENTRYP PFNGLUNIFORMHANDLEUI64VNVPROC) (GLint location, GLsizei count, const GLuint64 *value); typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORMHANDLEUI64NVPROC) (GLuint program, GLint location, GLuint64 value); typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORMHANDLEUI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64 *values); typedef GLboolean (GL_APIENTRYP PFNGLISTEXTUREHANDLERESIDENTNVPROC) (GLuint64 handle); typedef GLboolean (GL_APIENTRYP PFNGLISIMAGEHANDLERESIDENTNVPROC) (GLuint64 handle); #ifdef GL_GLEXT_PROTOTYPES GL_APICALL GLuint64 GL_APIENTRY glGetTextureHandleNV (GLuint texture); GL_APICALL GLuint64 GL_APIENTRY glGetTextureSamplerHandleNV (GLuint texture, GLuint sampler); GL_APICALL void GL_APIENTRY glMakeTextureHandleResidentNV (GLuint64 handle); GL_APICALL void GL_APIENTRY glMakeTextureHandleNonResidentNV (GLuint64 handle); GL_APICALL GLuint64 GL_APIENTRY glGetImageHandleNV (GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum format); GL_APICALL void GL_APIENTRY glMakeImageHandleResidentNV (GLuint64 handle, GLenum access); GL_APICALL void GL_APIENTRY glMakeImageHandleNonResidentNV (GLuint64 handle); GL_APICALL void GL_APIENTRY glUniformHandleui64NV (GLint location, GLuint64 value); GL_APICALL void GL_APIENTRY glUniformHandleui64vNV (GLint location, GLsizei count, const GLuint64 *value); GL_APICALL void GL_APIENTRY glProgramUniformHandleui64NV (GLuint program, GLint location, GLuint64 value); GL_APICALL void GL_APIENTRY glProgramUniformHandleui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64 *values); GL_APICALL GLboolean GL_APIENTRY glIsTextureHandleResidentNV (GLuint64 handle); GL_APICALL GLboolean GL_APIENTRY glIsImageHandleResidentNV (GLuint64 handle); #endif #endif /* GL_NV_bindless_texture */ #ifndef GL_NV_blend_equation_advanced #define GL_NV_blend_equation_advanced 1 #define GL_BLEND_OVERLAP_NV 0x9281 #define GL_BLEND_PREMULTIPLIED_SRC_NV 0x9280 #define GL_BLUE_NV 0x1905 #define GL_COLORBURN_NV 0x929A #define GL_COLORDODGE_NV 0x9299 #define GL_CONJOINT_NV 0x9284 #define GL_CONTRAST_NV 0x92A1 #define GL_DARKEN_NV 0x9297 #define GL_DIFFERENCE_NV 0x929E #define GL_DISJOINT_NV 0x9283 #define GL_DST_ATOP_NV 0x928F #define GL_DST_IN_NV 0x928B #define GL_DST_NV 0x9287 #define GL_DST_OUT_NV 0x928D #define GL_DST_OVER_NV 0x9289 #define GL_EXCLUSION_NV 0x92A0 #define GL_GREEN_NV 0x1904 #define GL_HARDLIGHT_NV 0x929B #define GL_HARDMIX_NV 0x92A9 #define GL_HSL_COLOR_NV 0x92AF #define GL_HSL_HUE_NV 0x92AD #define GL_HSL_LUMINOSITY_NV 0x92B0 #define GL_HSL_SATURATION_NV 0x92AE #define GL_INVERT_OVG_NV 0x92B4 #define GL_INVERT_RGB_NV 0x92A3 #define GL_LIGHTEN_NV 0x9298 #define GL_LINEARBURN_NV 0x92A5 #define GL_LINEARDODGE_NV 0x92A4 #define GL_LINEARLIGHT_NV 0x92A7 #define GL_MINUS_CLAMPED_NV 0x92B3 #define GL_MINUS_NV 0x929F #define GL_MULTIPLY_NV 0x9294 #define GL_OVERLAY_NV 0x9296 #define GL_PINLIGHT_NV 0x92A8 #define GL_PLUS_CLAMPED_ALPHA_NV 0x92B2 #define GL_PLUS_CLAMPED_NV 0x92B1 #define GL_PLUS_DARKER_NV 0x9292 #define GL_PLUS_NV 0x9291 #define GL_RED_NV 0x1903 #define GL_SCREEN_NV 0x9295 #define GL_SOFTLIGHT_NV 0x929C #define GL_SRC_ATOP_NV 0x928E #define GL_SRC_IN_NV 0x928A #define GL_SRC_NV 0x9286 #define GL_SRC_OUT_NV 0x928C #define GL_SRC_OVER_NV 0x9288 #define GL_UNCORRELATED_NV 0x9282 #define GL_VIVIDLIGHT_NV 0x92A6 #define GL_XOR_NV 0x1506 typedef void (GL_APIENTRYP PFNGLBLENDPARAMETERINVPROC) (GLenum pname, GLint value); typedef void (GL_APIENTRYP PFNGLBLENDBARRIERNVPROC) (void); #ifdef GL_GLEXT_PROTOTYPES GL_APICALL void GL_APIENTRY glBlendParameteriNV (GLenum pname, GLint value); GL_APICALL void GL_APIENTRY glBlendBarrierNV (void); #endif #endif /* GL_NV_blend_equation_advanced */ #ifndef GL_NV_blend_equation_advanced_coherent #define GL_NV_blend_equation_advanced_coherent 1 #define GL_BLEND_ADVANCED_COHERENT_NV 0x9285 #endif /* GL_NV_blend_equation_advanced_coherent */ #ifndef GL_NV_blend_minmax_factor #define GL_NV_blend_minmax_factor 1 #define GL_FACTOR_MIN_AMD 0x901C #define GL_FACTOR_MAX_AMD 0x901D #endif /* GL_NV_blend_minmax_factor */ #ifndef GL_NV_clip_space_w_scaling #define GL_NV_clip_space_w_scaling 1 #define GL_VIEWPORT_POSITION_W_SCALE_NV 0x937C #define GL_VIEWPORT_POSITION_W_SCALE_X_COEFF_NV 0x937D #define GL_VIEWPORT_POSITION_W_SCALE_Y_COEFF_NV 0x937E typedef void (GL_APIENTRYP PFNGLVIEWPORTPOSITIONWSCALENVPROC) (GLuint index, GLfloat xcoeff, GLfloat ycoeff); #ifdef GL_GLEXT_PROTOTYPES GL_APICALL void GL_APIENTRY glViewportPositionWScaleNV (GLuint index, GLfloat xcoeff, GLfloat ycoeff); #endif #endif /* GL_NV_clip_space_w_scaling */ #ifndef GL_NV_compute_shader_derivatives #define GL_NV_compute_shader_derivatives 1 #endif /* GL_NV_compute_shader_derivatives */ #ifndef GL_NV_conditional_render #define GL_NV_conditional_render 1 #define GL_QUERY_WAIT_NV 0x8E13 #define GL_QUERY_NO_WAIT_NV 0x8E14 #define GL_QUERY_BY_REGION_WAIT_NV 0x8E15 #define GL_QUERY_BY_REGION_NO_WAIT_NV 0x8E16 typedef void (GL_APIENTRYP PFNGLBEGINCONDITIONALRENDERNVPROC) (GLuint id, GLenum mode); typedef void (GL_APIENTRYP PFNGLENDCONDITIONALRENDERNVPROC) (void); #ifdef GL_GLEXT_PROTOTYPES GL_APICALL void GL_APIENTRY glBeginConditionalRenderNV (GLuint id, GLenum mode); GL_APICALL void GL_APIENTRY glEndConditionalRenderNV (void); #endif #endif /* GL_NV_conditional_render */ #ifndef GL_NV_conservative_raster #define GL_NV_conservative_raster 1 #define GL_CONSERVATIVE_RASTERIZATION_NV 0x9346 #define GL_SUBPIXEL_PRECISION_BIAS_X_BITS_NV 0x9347 #define GL_SUBPIXEL_PRECISION_BIAS_Y_BITS_NV 0x9348 #define GL_MAX_SUBPIXEL_PRECISION_BIAS_BITS_NV 0x9349 typedef void (GL_APIENTRYP PFNGLSUBPIXELPRECISIONBIASNVPROC) (GLuint xbits, GLuint ybits); #ifdef GL_GLEXT_PROTOTYPES GL_APICALL void GL_APIENTRY glSubpixelPrecisionBiasNV (GLuint xbits, GLuint ybits); #endif #endif /* GL_NV_conservative_raster */ #ifndef GL_NV_conservative_raster_pre_snap #define GL_NV_conservative_raster_pre_snap 1 #define GL_CONSERVATIVE_RASTER_MODE_PRE_SNAP_NV 0x9550 #endif /* GL_NV_conservative_raster_pre_snap */ #ifndef GL_NV_conservative_raster_pre_snap_triangles #define GL_NV_conservative_raster_pre_snap_triangles 1 #define GL_CONSERVATIVE_RASTER_MODE_NV 0x954D #define GL_CONSERVATIVE_RASTER_MODE_POST_SNAP_NV 0x954E #define GL_CONSERVATIVE_RASTER_MODE_PRE_SNAP_TRIANGLES_NV 0x954F typedef void (GL_APIENTRYP PFNGLCONSERVATIVERASTERPARAMETERINVPROC) (GLenum pname, GLint param); #ifdef GL_GLEXT_PROTOTYPES GL_APICALL void GL_APIENTRY glConservativeRasterParameteriNV (GLenum pname, GLint param); #endif #endif /* GL_NV_conservative_raster_pre_snap_triangles */ #ifndef GL_NV_copy_buffer #define GL_NV_copy_buffer 1 #define GL_COPY_READ_BUFFER_NV 0x8F36 #define GL_COPY_WRITE_BUFFER_NV 0x8F37 typedef void (GL_APIENTRYP PFNGLCOPYBUFFERSUBDATANVPROC) (GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); #ifdef GL_GLEXT_PROTOTYPES GL_APICALL void GL_APIENTRY glCopyBufferSubDataNV (GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); #endif #endif /* GL_NV_copy_buffer */ #ifndef GL_NV_coverage_sample #define GL_NV_coverage_sample 1 #define GL_COVERAGE_COMPONENT_NV 0x8ED0 #define GL_COVERAGE_COMPONENT4_NV 0x8ED1 #define GL_COVERAGE_ATTACHMENT_NV 0x8ED2 #define GL_COVERAGE_BUFFERS_NV 0x8ED3 #define GL_COVERAGE_SAMPLES_NV 0x8ED4 #define GL_COVERAGE_ALL_FRAGMENTS_NV 0x8ED5 #define GL_COVERAGE_EDGE_FRAGMENTS_NV 0x8ED6 #define GL_COVERAGE_AUTOMATIC_NV 0x8ED7 #define GL_COVERAGE_BUFFER_BIT_NV 0x00008000 typedef void (GL_APIENTRYP PFNGLCOVERAGEMASKNVPROC) (GLboolean mask); typedef void (GL_APIENTRYP PFNGLCOVERAGEOPERATIONNVPROC) (GLenum operation); #ifdef GL_GLEXT_PROTOTYPES GL_APICALL void GL_APIENTRY glCoverageMaskNV (GLboolean mask); GL_APICALL void GL_APIENTRY glCoverageOperationNV (GLenum operation); #endif #endif /* GL_NV_coverage_sample */ #ifndef GL_NV_depth_nonlinear #define GL_NV_depth_nonlinear 1 #define GL_DEPTH_COMPONENT16_NONLINEAR_NV 0x8E2C #endif /* GL_NV_depth_nonlinear */ #ifndef GL_NV_draw_buffers #define GL_NV_draw_buffers 1 #define GL_MAX_DRAW_BUFFERS_NV 0x8824 #define GL_DRAW_BUFFER0_NV 0x8825 #define GL_DRAW_BUFFER1_NV 0x8826 #define GL_DRAW_BUFFER2_NV 0x8827 #define GL_DRAW_BUFFER3_NV 0x8828 #define GL_DRAW_BUFFER4_NV 0x8829 #define GL_DRAW_BUFFER5_NV 0x882A #define GL_DRAW_BUFFER6_NV 0x882B #define GL_DRAW_BUFFER7_NV 0x882C #define GL_DRAW_BUFFER8_NV 0x882D #define GL_DRAW_BUFFER9_NV 0x882E #define GL_DRAW_BUFFER10_NV 0x882F #define GL_DRAW_BUFFER11_NV 0x8830 #define GL_DRAW_BUFFER12_NV 0x8831 #define GL_DRAW_BUFFER13_NV 0x8832 #define GL_DRAW_BUFFER14_NV 0x8833 #define GL_DRAW_BUFFER15_NV 0x8834 #define GL_COLOR_ATTACHMENT0_NV 0x8CE0 #define GL_COLOR_ATTACHMENT1_NV 0x8CE1 #define GL_COLOR_ATTACHMENT2_NV 0x8CE2 #define GL_COLOR_ATTACHMENT3_NV 0x8CE3 #define GL_COLOR_ATTACHMENT4_NV 0x8CE4 #define GL_COLOR_ATTACHMENT5_NV 0x8CE5 #define GL_COLOR_ATTACHMENT6_NV 0x8CE6 #define GL_COLOR_ATTACHMENT7_NV 0x8CE7 #define GL_COLOR_ATTACHMENT8_NV 0x8CE8 #define GL_COLOR_ATTACHMENT9_NV 0x8CE9 #define GL_COLOR_ATTACHMENT10_NV 0x8CEA #define GL_COLOR_ATTACHMENT11_NV 0x8CEB #define GL_COLOR_ATTACHMENT12_NV 0x8CEC #define GL_COLOR_ATTACHMENT13_NV 0x8CED #define GL_COLOR_ATTACHMENT14_NV 0x8CEE #define GL_COLOR_ATTACHMENT15_NV 0x8CEF typedef void (GL_APIENTRYP PFNGLDRAWBUFFERSNVPROC) (GLsizei n, const GLenum *bufs); #ifdef GL_GLEXT_PROTOTYPES GL_APICALL void GL_APIENTRY glDrawBuffersNV (GLsizei n, const GLenum *bufs); #endif #endif /* GL_NV_draw_buffers */ #ifndef GL_NV_draw_instanced #define GL_NV_draw_instanced 1 typedef void (GL_APIENTRYP PFNGLDRAWARRAYSINSTANCEDNVPROC) (GLenum mode, GLint first, GLsizei count, GLsizei primcount); typedef void (GL_APIENTRYP PFNGLDRAWELEMENTSINSTANCEDNVPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount); #ifdef GL_GLEXT_PROTOTYPES GL_APICALL void GL_APIENTRY glDrawArraysInstancedNV (GLenum mode, GLint first, GLsizei count, GLsizei primcount); GL_APICALL void GL_APIENTRY glDrawElementsInstancedNV (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount); #endif #endif /* GL_NV_draw_instanced */ #ifndef GL_NV_draw_vulkan_image #define GL_NV_draw_vulkan_image 1 typedef void (GL_APIENTRY *GLVULKANPROCNV)(void); typedef void (GL_APIENTRYP PFNGLDRAWVKIMAGENVPROC) (GLuint64 vkImage, GLuint sampler, GLfloat x0, GLfloat y0, GLfloat x1, GLfloat y1, GLfloat z, GLfloat s0, GLfloat t0, GLfloat s1, GLfloat t1); typedef GLVULKANPROCNV (GL_APIENTRYP PFNGLGETVKPROCADDRNVPROC) (const GLchar *name); typedef void (GL_APIENTRYP PFNGLWAITVKSEMAPHORENVPROC) (GLuint64 vkSemaphore); typedef void (GL_APIENTRYP PFNGLSIGNALVKSEMAPHORENVPROC) (GLuint64 vkSemaphore); typedef void (GL_APIENTRYP PFNGLSIGNALVKFENCENVPROC) (GLuint64 vkFence); #ifdef GL_GLEXT_PROTOTYPES GL_APICALL void GL_APIENTRY glDrawVkImageNV (GLuint64 vkImage, GLuint sampler, GLfloat x0, GLfloat y0, GLfloat x1, GLfloat y1, GLfloat z, GLfloat s0, GLfloat t0, GLfloat s1, GLfloat t1); GL_APICALL GLVULKANPROCNV GL_APIENTRY glGetVkProcAddrNV (const GLchar *name); GL_APICALL void GL_APIENTRY glWaitVkSemaphoreNV (GLuint64 vkSemaphore); GL_APICALL void GL_APIENTRY glSignalVkSemaphoreNV (GLuint64 vkSemaphore); GL_APICALL void GL_APIENTRY glSignalVkFenceNV (GLuint64 vkFence); #endif #endif /* GL_NV_draw_vulkan_image */ #ifndef GL_NV_explicit_attrib_location #define GL_NV_explicit_attrib_location 1 #endif /* GL_NV_explicit_attrib_location */ #ifndef GL_NV_fbo_color_attachments #define GL_NV_fbo_color_attachments 1 #define GL_MAX_COLOR_ATTACHMENTS_NV 0x8CDF #endif /* GL_NV_fbo_color_attachments */ #ifndef GL_NV_fence #define GL_NV_fence 1 #define GL_ALL_COMPLETED_NV 0x84F2 #define GL_FENCE_STATUS_NV 0x84F3 #define GL_FENCE_CONDITION_NV 0x84F4 typedef void (GL_APIENTRYP PFNGLDELETEFENCESNVPROC) (GLsizei n, const GLuint *fences); typedef void (GL_APIENTRYP PFNGLGENFENCESNVPROC) (GLsizei n, GLuint *fences); typedef GLboolean (GL_APIENTRYP PFNGLISFENCENVPROC) (GLuint fence); typedef GLboolean (GL_APIENTRYP PFNGLTESTFENCENVPROC) (GLuint fence); typedef void (GL_APIENTRYP PFNGLGETFENCEIVNVPROC) (GLuint fence, GLenum pname, GLint *params); typedef void (GL_APIENTRYP PFNGLFINISHFENCENVPROC) (GLuint fence); typedef void (GL_APIENTRYP PFNGLSETFENCENVPROC) (GLuint fence, GLenum condition); #ifdef GL_GLEXT_PROTOTYPES GL_APICALL void GL_APIENTRY glDeleteFencesNV (GLsizei n, const GLuint *fences); GL_APICALL void GL_APIENTRY glGenFencesNV (GLsizei n, GLuint *fences); GL_APICALL GLboolean GL_APIENTRY glIsFenceNV (GLuint fence); GL_APICALL GLboolean GL_APIENTRY glTestFenceNV (GLuint fence); GL_APICALL void GL_APIENTRY glGetFenceivNV (GLuint fence, GLenum pname, GLint *params); GL_APICALL void GL_APIENTRY glFinishFenceNV (GLuint fence); GL_APICALL void GL_APIENTRY glSetFenceNV (GLuint fence, GLenum condition); #endif #endif /* GL_NV_fence */ #ifndef GL_NV_fill_rectangle #define GL_NV_fill_rectangle 1 #define GL_FILL_RECTANGLE_NV 0x933C #endif /* GL_NV_fill_rectangle */ #ifndef GL_NV_fragment_coverage_to_color #define GL_NV_fragment_coverage_to_color 1 #define GL_FRAGMENT_COVERAGE_TO_COLOR_NV 0x92DD #define GL_FRAGMENT_COVERAGE_COLOR_NV 0x92DE typedef void (GL_APIENTRYP PFNGLFRAGMENTCOVERAGECOLORNVPROC) (GLuint color); #ifdef GL_GLEXT_PROTOTYPES GL_APICALL void GL_APIENTRY glFragmentCoverageColorNV (GLuint color); #endif #endif /* GL_NV_fragment_coverage_to_color */ #ifndef GL_NV_fragment_shader_barycentric #define GL_NV_fragment_shader_barycentric 1 #endif /* GL_NV_fragment_shader_barycentric */ #ifndef GL_NV_fragment_shader_interlock #define GL_NV_fragment_shader_interlock 1 #endif /* GL_NV_fragment_shader_interlock */ #ifndef GL_NV_framebuffer_blit #define GL_NV_framebuffer_blit 1 #define GL_READ_FRAMEBUFFER_NV 0x8CA8 #define GL_DRAW_FRAMEBUFFER_NV 0x8CA9 #define GL_DRAW_FRAMEBUFFER_BINDING_NV 0x8CA6 #define GL_READ_FRAMEBUFFER_BINDING_NV 0x8CAA typedef void (GL_APIENTRYP PFNGLBLITFRAMEBUFFERNVPROC) (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); #ifdef GL_GLEXT_PROTOTYPES GL_APICALL void GL_APIENTRY glBlitFramebufferNV (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); #endif #endif /* GL_NV_framebuffer_blit */ #ifndef GL_NV_framebuffer_mixed_samples #define GL_NV_framebuffer_mixed_samples 1 #define GL_COVERAGE_MODULATION_TABLE_NV 0x9331 #define GL_COLOR_SAMPLES_NV 0x8E20 #define GL_DEPTH_SAMPLES_NV 0x932D #define GL_STENCIL_SAMPLES_NV 0x932E #define GL_MIXED_DEPTH_SAMPLES_SUPPORTED_NV 0x932F #define GL_MIXED_STENCIL_SAMPLES_SUPPORTED_NV 0x9330 #define GL_COVERAGE_MODULATION_NV 0x9332 #define GL_COVERAGE_MODULATION_TABLE_SIZE_NV 0x9333 typedef void (GL_APIENTRYP PFNGLCOVERAGEMODULATIONTABLENVPROC) (GLsizei n, const GLfloat *v); typedef void (GL_APIENTRYP PFNGLGETCOVERAGEMODULATIONTABLENVPROC) (GLsizei bufSize, GLfloat *v); typedef void (GL_APIENTRYP PFNGLCOVERAGEMODULATIONNVPROC) (GLenum components); #ifdef GL_GLEXT_PROTOTYPES GL_APICALL void GL_APIENTRY glCoverageModulationTableNV (GLsizei n, const GLfloat *v); GL_APICALL void GL_APIENTRY glGetCoverageModulationTableNV (GLsizei bufSize, GLfloat *v); GL_APICALL void GL_APIENTRY glCoverageModulationNV (GLenum components); #endif #endif /* GL_NV_framebuffer_mixed_samples */ #ifndef GL_NV_framebuffer_multisample #define GL_NV_framebuffer_multisample 1 #define GL_RENDERBUFFER_SAMPLES_NV 0x8CAB #define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_NV 0x8D56 #define GL_MAX_SAMPLES_NV 0x8D57 typedef void (GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLENVPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); #ifdef GL_GLEXT_PROTOTYPES GL_APICALL void GL_APIENTRY glRenderbufferStorageMultisampleNV (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); #endif #endif /* GL_NV_framebuffer_multisample */ #ifndef GL_NV_generate_mipmap_sRGB #define GL_NV_generate_mipmap_sRGB 1 #endif /* GL_NV_generate_mipmap_sRGB */ #ifndef GL_NV_geometry_shader_passthrough #define GL_NV_geometry_shader_passthrough 1 #endif /* GL_NV_geometry_shader_passthrough */ #ifndef GL_NV_gpu_shader5 #define GL_NV_gpu_shader5 1 typedef khronos_int64_t GLint64EXT; typedef khronos_uint64_t GLuint64EXT; #define GL_INT64_NV 0x140E #define GL_UNSIGNED_INT64_NV 0x140F #define GL_INT8_NV 0x8FE0 #define GL_INT8_VEC2_NV 0x8FE1 #define GL_INT8_VEC3_NV 0x8FE2 #define GL_INT8_VEC4_NV 0x8FE3 #define GL_INT16_NV 0x8FE4 #define GL_INT16_VEC2_NV 0x8FE5 #define GL_INT16_VEC3_NV 0x8FE6 #define GL_INT16_VEC4_NV 0x8FE7 #define GL_INT64_VEC2_NV 0x8FE9 #define GL_INT64_VEC3_NV 0x8FEA #define GL_INT64_VEC4_NV 0x8FEB #define GL_UNSIGNED_INT8_NV 0x8FEC #define GL_UNSIGNED_INT8_VEC2_NV 0x8FED #define GL_UNSIGNED_INT8_VEC3_NV 0x8FEE #define GL_UNSIGNED_INT8_VEC4_NV 0x8FEF #define GL_UNSIGNED_INT16_NV 0x8FF0 #define GL_UNSIGNED_INT16_VEC2_NV 0x8FF1 #define GL_UNSIGNED_INT16_VEC3_NV 0x8FF2 #define GL_UNSIGNED_INT16_VEC4_NV 0x8FF3 #define GL_UNSIGNED_INT64_VEC2_NV 0x8FF5 #define GL_UNSIGNED_INT64_VEC3_NV 0x8FF6 #define GL_UNSIGNED_INT64_VEC4_NV 0x8FF7 #define GL_FLOAT16_NV 0x8FF8 #define GL_FLOAT16_VEC2_NV 0x8FF9 #define GL_FLOAT16_VEC3_NV 0x8FFA #define GL_FLOAT16_VEC4_NV 0x8FFB #define GL_PATCHES 0x000E typedef void (GL_APIENTRYP PFNGLUNIFORM1I64NVPROC) (GLint location, GLint64EXT x); typedef void (GL_APIENTRYP PFNGLUNIFORM2I64NVPROC) (GLint location, GLint64EXT x, GLint64EXT y); typedef void (GL_APIENTRYP PFNGLUNIFORM3I64NVPROC) (GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z); typedef void (GL_APIENTRYP PFNGLUNIFORM4I64NVPROC) (GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w); typedef void (GL_APIENTRYP PFNGLUNIFORM1I64VNVPROC) (GLint location, GLsizei count, const GLint64EXT *value); typedef void (GL_APIENTRYP PFNGLUNIFORM2I64VNVPROC) (GLint location, GLsizei count, const GLint64EXT *value); typedef void (GL_APIENTRYP PFNGLUNIFORM3I64VNVPROC) (GLint location, GLsizei count, const GLint64EXT *value); typedef void (GL_APIENTRYP PFNGLUNIFORM4I64VNVPROC) (GLint location, GLsizei count, const GLint64EXT *value); typedef void (GL_APIENTRYP PFNGLUNIFORM1UI64NVPROC) (GLint location, GLuint64EXT x); typedef void (GL_APIENTRYP PFNGLUNIFORM2UI64NVPROC) (GLint location, GLuint64EXT x, GLuint64EXT y); typedef void (GL_APIENTRYP PFNGLUNIFORM3UI64NVPROC) (GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z); typedef void (GL_APIENTRYP PFNGLUNIFORM4UI64NVPROC) (GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w); typedef void (GL_APIENTRYP PFNGLUNIFORM1UI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT *value); typedef void (GL_APIENTRYP PFNGLUNIFORM2UI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT *value); typedef void (GL_APIENTRYP PFNGLUNIFORM3UI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT *value); typedef void (GL_APIENTRYP PFNGLUNIFORM4UI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT *value); typedef void (GL_APIENTRYP PFNGLGETUNIFORMI64VNVPROC) (GLuint program, GLint location, GLint64EXT *params); typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM1I64NVPROC) (GLuint program, GLint location, GLint64EXT x); typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM2I64NVPROC) (GLuint program, GLint location, GLint64EXT x, GLint64EXT y); typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM3I64NVPROC) (GLuint program, GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z); typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM4I64NVPROC) (GLuint program, GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w); typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM1I64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM2I64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM3I64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM4I64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM1UI64NVPROC) (GLuint program, GLint location, GLuint64EXT x); typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM2UI64NVPROC) (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y); typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM3UI64NVPROC) (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z); typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM4UI64NVPROC) (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w); typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM1UI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM2UI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM3UI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM4UI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); #ifdef GL_GLEXT_PROTOTYPES GL_APICALL void GL_APIENTRY glUniform1i64NV (GLint location, GLint64EXT x); GL_APICALL void GL_APIENTRY glUniform2i64NV (GLint location, GLint64EXT x, GLint64EXT y); GL_APICALL void GL_APIENTRY glUniform3i64NV (GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z); GL_APICALL void GL_APIENTRY glUniform4i64NV (GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w); GL_APICALL void GL_APIENTRY glUniform1i64vNV (GLint location, GLsizei count, const GLint64EXT *value); GL_APICALL void GL_APIENTRY glUniform2i64vNV (GLint location, GLsizei count, const GLint64EXT *value); GL_APICALL void GL_APIENTRY glUniform3i64vNV (GLint location, GLsizei count, const GLint64EXT *value); GL_APICALL void GL_APIENTRY glUniform4i64vNV (GLint location, GLsizei count, const GLint64EXT *value); GL_APICALL void GL_APIENTRY glUniform1ui64NV (GLint location, GLuint64EXT x); GL_APICALL void GL_APIENTRY glUniform2ui64NV (GLint location, GLuint64EXT x, GLuint64EXT y); GL_APICALL void GL_APIENTRY glUniform3ui64NV (GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z); GL_APICALL void GL_APIENTRY glUniform4ui64NV (GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w); GL_APICALL void GL_APIENTRY glUniform1ui64vNV (GLint location, GLsizei count, const GLuint64EXT *value); GL_APICALL void GL_APIENTRY glUniform2ui64vNV (GLint location, GLsizei count, const GLuint64EXT *value); GL_APICALL void GL_APIENTRY glUniform3ui64vNV (GLint location, GLsizei count, const GLuint64EXT *value); GL_APICALL void GL_APIENTRY glUniform4ui64vNV (GLint location, GLsizei count, const GLuint64EXT *value); GL_APICALL void GL_APIENTRY glGetUniformi64vNV (GLuint program, GLint location, GLint64EXT *params); GL_APICALL void GL_APIENTRY glProgramUniform1i64NV (GLuint program, GLint location, GLint64EXT x); GL_APICALL void GL_APIENTRY glProgramUniform2i64NV (GLuint program, GLint location, GLint64EXT x, GLint64EXT y); GL_APICALL void GL_APIENTRY glProgramUniform3i64NV (GLuint program, GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z); GL_APICALL void GL_APIENTRY glProgramUniform4i64NV (GLuint program, GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w); GL_APICALL void GL_APIENTRY glProgramUniform1i64vNV (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); GL_APICALL void GL_APIENTRY glProgramUniform2i64vNV (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); GL_APICALL void GL_APIENTRY glProgramUniform3i64vNV (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); GL_APICALL void GL_APIENTRY glProgramUniform4i64vNV (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); GL_APICALL void GL_APIENTRY glProgramUniform1ui64NV (GLuint program, GLint location, GLuint64EXT x); GL_APICALL void GL_APIENTRY glProgramUniform2ui64NV (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y); GL_APICALL void GL_APIENTRY glProgramUniform3ui64NV (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z); GL_APICALL void GL_APIENTRY glProgramUniform4ui64NV (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w); GL_APICALL void GL_APIENTRY glProgramUniform1ui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); GL_APICALL void GL_APIENTRY glProgramUniform2ui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); GL_APICALL void GL_APIENTRY glProgramUniform3ui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); GL_APICALL void GL_APIENTRY glProgramUniform4ui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); #endif #endif /* GL_NV_gpu_shader5 */ #ifndef GL_NV_image_formats #define GL_NV_image_formats 1 #endif /* GL_NV_image_formats */ #ifndef GL_NV_instanced_arrays #define GL_NV_instanced_arrays 1 #define GL_VERTEX_ATTRIB_ARRAY_DIVISOR_NV 0x88FE typedef void (GL_APIENTRYP PFNGLVERTEXATTRIBDIVISORNVPROC) (GLuint index, GLuint divisor); #ifdef GL_GLEXT_PROTOTYPES GL_APICALL void GL_APIENTRY glVertexAttribDivisorNV (GLuint index, GLuint divisor); #endif #endif /* GL_NV_instanced_arrays */ #ifndef GL_NV_internalformat_sample_query #define GL_NV_internalformat_sample_query 1 #define GL_TEXTURE_2D_MULTISAMPLE 0x9100 #define GL_TEXTURE_2D_MULTISAMPLE_ARRAY 0x9102 #define GL_MULTISAMPLES_NV 0x9371 #define GL_SUPERSAMPLE_SCALE_X_NV 0x9372 #define GL_SUPERSAMPLE_SCALE_Y_NV 0x9373 #define GL_CONFORMANT_NV 0x9374 typedef void (GL_APIENTRYP PFNGLGETINTERNALFORMATSAMPLEIVNVPROC) (GLenum target, GLenum internalformat, GLsizei samples, GLenum pname, GLsizei count, GLint *params); #ifdef GL_GLEXT_PROTOTYPES GL_APICALL void GL_APIENTRY glGetInternalformatSampleivNV (GLenum target, GLenum internalformat, GLsizei samples, GLenum pname, GLsizei count, GLint *params); #endif #endif /* GL_NV_internalformat_sample_query */ #ifndef GL_NV_memory_attachment #define GL_NV_memory_attachment 1 #define GL_ATTACHED_MEMORY_OBJECT_NV 0x95A4 #define GL_ATTACHED_MEMORY_OFFSET_NV 0x95A5 #define GL_MEMORY_ATTACHABLE_ALIGNMENT_NV 0x95A6 #define GL_MEMORY_ATTACHABLE_SIZE_NV 0x95A7 #define GL_MEMORY_ATTACHABLE_NV 0x95A8 #define GL_DETACHED_MEMORY_INCARNATION_NV 0x95A9 #define GL_DETACHED_TEXTURES_NV 0x95AA #define GL_DETACHED_BUFFERS_NV 0x95AB #define GL_MAX_DETACHED_TEXTURES_NV 0x95AC #define GL_MAX_DETACHED_BUFFERS_NV 0x95AD typedef void (GL_APIENTRYP PFNGLGETMEMORYOBJECTDETACHEDRESOURCESUIVNVPROC) (GLuint memory, GLenum pname, GLint first, GLsizei count, GLuint *params); typedef void (GL_APIENTRYP PFNGLRESETMEMORYOBJECTPARAMETERNVPROC) (GLuint memory, GLenum pname); typedef void (GL_APIENTRYP PFNGLTEXATTACHMEMORYNVPROC) (GLenum target, GLuint memory, GLuint64 offset); typedef void (GL_APIENTRYP PFNGLBUFFERATTACHMEMORYNVPROC) (GLenum target, GLuint memory, GLuint64 offset); typedef void (GL_APIENTRYP PFNGLTEXTUREATTACHMEMORYNVPROC) (GLuint texture, GLuint memory, GLuint64 offset); typedef void (GL_APIENTRYP PFNGLNAMEDBUFFERATTACHMEMORYNVPROC) (GLuint buffer, GLuint memory, GLuint64 offset); #ifdef GL_GLEXT_PROTOTYPES GL_APICALL void GL_APIENTRY glGetMemoryObjectDetachedResourcesuivNV (GLuint memory, GLenum pname, GLint first, GLsizei count, GLuint *params); GL_APICALL void GL_APIENTRY glResetMemoryObjectParameterNV (GLuint memory, GLenum pname); GL_APICALL void GL_APIENTRY glTexAttachMemoryNV (GLenum target, GLuint memory, GLuint64 offset); GL_APICALL void GL_APIENTRY glBufferAttachMemoryNV (GLenum target, GLuint memory, GLuint64 offset); GL_APICALL void GL_APIENTRY glTextureAttachMemoryNV (GLuint texture, GLuint memory, GLuint64 offset); GL_APICALL void GL_APIENTRY glNamedBufferAttachMemoryNV (GLuint buffer, GLuint memory, GLuint64 offset); #endif #endif /* GL_NV_memory_attachment */ #ifndef GL_NV_memory_object_sparse #define GL_NV_memory_object_sparse 1 typedef void (GL_APIENTRYP PFNGLBUFFERPAGECOMMITMENTMEMNVPROC) (GLenum target, GLintptr offset, GLsizeiptr size, GLuint memory, GLuint64 memOffset, GLboolean commit); typedef void (GL_APIENTRYP PFNGLTEXPAGECOMMITMENTMEMNVPROC) (GLenum target, GLint layer, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLuint memory, GLuint64 offset, GLboolean commit); typedef void (GL_APIENTRYP PFNGLNAMEDBUFFERPAGECOMMITMENTMEMNVPROC) (GLuint buffer, GLintptr offset, GLsizeiptr size, GLuint memory, GLuint64 memOffset, GLboolean commit); typedef void (GL_APIENTRYP PFNGLTEXTUREPAGECOMMITMENTMEMNVPROC) (GLuint texture, GLint layer, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLuint memory, GLuint64 offset, GLboolean commit); #ifdef GL_GLEXT_PROTOTYPES GL_APICALL void GL_APIENTRY glBufferPageCommitmentMemNV (GLenum target, GLintptr offset, GLsizeiptr size, GLuint memory, GLuint64 memOffset, GLboolean commit); GL_APICALL void GL_APIENTRY glTexPageCommitmentMemNV (GLenum target, GLint layer, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLuint memory, GLuint64 offset, GLboolean commit); GL_APICALL void GL_APIENTRY glNamedBufferPageCommitmentMemNV (GLuint buffer, GLintptr offset, GLsizeiptr size, GLuint memory, GLuint64 memOffset, GLboolean commit); GL_APICALL void GL_APIENTRY glTexturePageCommitmentMemNV (GLuint texture, GLint layer, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLuint memory, GLuint64 offset, GLboolean commit); #endif #endif /* GL_NV_memory_object_sparse */ #ifndef GL_NV_mesh_shader #define GL_NV_mesh_shader 1 #define GL_MESH_SHADER_NV 0x9559 #define GL_TASK_SHADER_NV 0x955A #define GL_MAX_MESH_UNIFORM_BLOCKS_NV 0x8E60 #define GL_MAX_MESH_TEXTURE_IMAGE_UNITS_NV 0x8E61 #define GL_MAX_MESH_IMAGE_UNIFORMS_NV 0x8E62 #define GL_MAX_MESH_UNIFORM_COMPONENTS_NV 0x8E63 #define GL_MAX_MESH_ATOMIC_COUNTER_BUFFERS_NV 0x8E64 #define GL_MAX_MESH_ATOMIC_COUNTERS_NV 0x8E65 #define GL_MAX_MESH_SHADER_STORAGE_BLOCKS_NV 0x8E66 #define GL_MAX_COMBINED_MESH_UNIFORM_COMPONENTS_NV 0x8E67 #define GL_MAX_TASK_UNIFORM_BLOCKS_NV 0x8E68 #define GL_MAX_TASK_TEXTURE_IMAGE_UNITS_NV 0x8E69 #define GL_MAX_TASK_IMAGE_UNIFORMS_NV 0x8E6A #define GL_MAX_TASK_UNIFORM_COMPONENTS_NV 0x8E6B #define GL_MAX_TASK_ATOMIC_COUNTER_BUFFERS_NV 0x8E6C #define GL_MAX_TASK_ATOMIC_COUNTERS_NV 0x8E6D #define GL_MAX_TASK_SHADER_STORAGE_BLOCKS_NV 0x8E6E #define GL_MAX_COMBINED_TASK_UNIFORM_COMPONENTS_NV 0x8E6F #define GL_MAX_MESH_WORK_GROUP_INVOCATIONS_NV 0x95A2 #define GL_MAX_TASK_WORK_GROUP_INVOCATIONS_NV 0x95A3 #define GL_MAX_MESH_TOTAL_MEMORY_SIZE_NV 0x9536 #define GL_MAX_TASK_TOTAL_MEMORY_SIZE_NV 0x9537 #define GL_MAX_MESH_OUTPUT_VERTICES_NV 0x9538 #define GL_MAX_MESH_OUTPUT_PRIMITIVES_NV 0x9539 #define GL_MAX_TASK_OUTPUT_COUNT_NV 0x953A #define GL_MAX_DRAW_MESH_TASKS_COUNT_NV 0x953D #define GL_MAX_MESH_VIEWS_NV 0x9557 #define GL_MESH_OUTPUT_PER_VERTEX_GRANULARITY_NV 0x92DF #define GL_MESH_OUTPUT_PER_PRIMITIVE_GRANULARITY_NV 0x9543 #define GL_MAX_MESH_WORK_GROUP_SIZE_NV 0x953B #define GL_MAX_TASK_WORK_GROUP_SIZE_NV 0x953C #define GL_MESH_WORK_GROUP_SIZE_NV 0x953E #define GL_TASK_WORK_GROUP_SIZE_NV 0x953F #define GL_MESH_VERTICES_OUT_NV 0x9579 #define GL_MESH_PRIMITIVES_OUT_NV 0x957A #define GL_MESH_OUTPUT_TYPE_NV 0x957B #define GL_UNIFORM_BLOCK_REFERENCED_BY_MESH_SHADER_NV 0x959C #define GL_UNIFORM_BLOCK_REFERENCED_BY_TASK_SHADER_NV 0x959D #define GL_REFERENCED_BY_MESH_SHADER_NV 0x95A0 #define GL_REFERENCED_BY_TASK_SHADER_NV 0x95A1 #define GL_MESH_SHADER_BIT_NV 0x00000040 #define GL_TASK_SHADER_BIT_NV 0x00000080 #define GL_MESH_SUBROUTINE_NV 0x957C #define GL_TASK_SUBROUTINE_NV 0x957D #define GL_MESH_SUBROUTINE_UNIFORM_NV 0x957E #define GL_TASK_SUBROUTINE_UNIFORM_NV 0x957F #define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_MESH_SHADER_NV 0x959E #define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_TASK_SHADER_NV 0x959F typedef void (GL_APIENTRYP PFNGLDRAWMESHTASKSNVPROC) (GLuint first, GLuint count); typedef void (GL_APIENTRYP PFNGLDRAWMESHTASKSINDIRECTNVPROC) (GLintptr indirect); typedef void (GL_APIENTRYP PFNGLMULTIDRAWMESHTASKSINDIRECTNVPROC) (GLintptr indirect, GLsizei drawcount, GLsizei stride); typedef void (GL_APIENTRYP PFNGLMULTIDRAWMESHTASKSINDIRECTCOUNTNVPROC) (GLintptr indirect, GLintptr drawcount, GLsizei maxdrawcount, GLsizei stride); #ifdef GL_GLEXT_PROTOTYPES GL_APICALL void GL_APIENTRY glDrawMeshTasksNV (GLuint first, GLuint count); GL_APICALL void GL_APIENTRY glDrawMeshTasksIndirectNV (GLintptr indirect); GL_APICALL void GL_APIENTRY glMultiDrawMeshTasksIndirectNV (GLintptr indirect, GLsizei drawcount, GLsizei stride); GL_APICALL void GL_APIENTRY glMultiDrawMeshTasksIndirectCountNV (GLintptr indirect, GLintptr drawcount, GLsizei maxdrawcount, GLsizei stride); #endif #endif /* GL_NV_mesh_shader */ #ifndef GL_NV_non_square_matrices #define GL_NV_non_square_matrices 1 #define GL_FLOAT_MAT2x3_NV 0x8B65 #define GL_FLOAT_MAT2x4_NV 0x8B66 #define GL_FLOAT_MAT3x2_NV 0x8B67 #define GL_FLOAT_MAT3x4_NV 0x8B68 #define GL_FLOAT_MAT4x2_NV 0x8B69 #define GL_FLOAT_MAT4x3_NV 0x8B6A typedef void (GL_APIENTRYP PFNGLUNIFORMMATRIX2X3FVNVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); typedef void (GL_APIENTRYP PFNGLUNIFORMMATRIX3X2FVNVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); typedef void (GL_APIENTRYP PFNGLUNIFORMMATRIX2X4FVNVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); typedef void (GL_APIENTRYP PFNGLUNIFORMMATRIX4X2FVNVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); typedef void (GL_APIENTRYP PFNGLUNIFORMMATRIX3X4FVNVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); typedef void (GL_APIENTRYP PFNGLUNIFORMMATRIX4X3FVNVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); #ifdef GL_GLEXT_PROTOTYPES GL_APICALL void GL_APIENTRY glUniformMatrix2x3fvNV (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); GL_APICALL void GL_APIENTRY glUniformMatrix3x2fvNV (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); GL_APICALL void GL_APIENTRY glUniformMatrix2x4fvNV (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); GL_APICALL void GL_APIENTRY glUniformMatrix4x2fvNV (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); GL_APICALL void GL_APIENTRY glUniformMatrix3x4fvNV (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); GL_APICALL void GL_APIENTRY glUniformMatrix4x3fvNV (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); #endif #endif /* GL_NV_non_square_matrices */ #ifndef GL_NV_path_rendering #define GL_NV_path_rendering 1 typedef double GLdouble; #define GL_PATH_FORMAT_SVG_NV 0x9070 #define GL_PATH_FORMAT_PS_NV 0x9071 #define GL_STANDARD_FONT_NAME_NV 0x9072 #define GL_SYSTEM_FONT_NAME_NV 0x9073 #define GL_FILE_NAME_NV 0x9074 #define GL_PATH_STROKE_WIDTH_NV 0x9075 #define GL_PATH_END_CAPS_NV 0x9076 #define GL_PATH_INITIAL_END_CAP_NV 0x9077 #define GL_PATH_TERMINAL_END_CAP_NV 0x9078 #define GL_PATH_JOIN_STYLE_NV 0x9079 #define GL_PATH_MITER_LIMIT_NV 0x907A #define GL_PATH_DASH_CAPS_NV 0x907B #define GL_PATH_INITIAL_DASH_CAP_NV 0x907C #define GL_PATH_TERMINAL_DASH_CAP_NV 0x907D #define GL_PATH_DASH_OFFSET_NV 0x907E #define GL_PATH_CLIENT_LENGTH_NV 0x907F #define GL_PATH_FILL_MODE_NV 0x9080 #define GL_PATH_FILL_MASK_NV 0x9081 #define GL_PATH_FILL_COVER_MODE_NV 0x9082 #define GL_PATH_STROKE_COVER_MODE_NV 0x9083 #define GL_PATH_STROKE_MASK_NV 0x9084 #define GL_COUNT_UP_NV 0x9088 #define GL_COUNT_DOWN_NV 0x9089 #define GL_PATH_OBJECT_BOUNDING_BOX_NV 0x908A #define GL_CONVEX_HULL_NV 0x908B #define GL_BOUNDING_BOX_NV 0x908D #define GL_TRANSLATE_X_NV 0x908E #define GL_TRANSLATE_Y_NV 0x908F #define GL_TRANSLATE_2D_NV 0x9090 #define GL_TRANSLATE_3D_NV 0x9091 #define GL_AFFINE_2D_NV 0x9092 #define GL_AFFINE_3D_NV 0x9094 #define GL_TRANSPOSE_AFFINE_2D_NV 0x9096 #define GL_TRANSPOSE_AFFINE_3D_NV 0x9098 #define GL_UTF8_NV 0x909A #define GL_UTF16_NV 0x909B #define GL_BOUNDING_BOX_OF_BOUNDING_BOXES_NV 0x909C #define GL_PATH_COMMAND_COUNT_NV 0x909D #define GL_PATH_COORD_COUNT_NV 0x909E #define GL_PATH_DASH_ARRAY_COUNT_NV 0x909F #define GL_PATH_COMPUTED_LENGTH_NV 0x90A0 #define GL_PATH_FILL_BOUNDING_BOX_NV 0x90A1 #define GL_PATH_STROKE_BOUNDING_BOX_NV 0x90A2 #define GL_SQUARE_NV 0x90A3 #define GL_ROUND_NV 0x90A4 #define GL_TRIANGULAR_NV 0x90A5 #define GL_BEVEL_NV 0x90A6 #define GL_MITER_REVERT_NV 0x90A7 #define GL_MITER_TRUNCATE_NV 0x90A8 #define GL_SKIP_MISSING_GLYPH_NV 0x90A9 #define GL_USE_MISSING_GLYPH_NV 0x90AA #define GL_PATH_ERROR_POSITION_NV 0x90AB #define GL_ACCUM_ADJACENT_PAIRS_NV 0x90AD #define GL_ADJACENT_PAIRS_NV 0x90AE #define GL_FIRST_TO_REST_NV 0x90AF #define GL_PATH_GEN_MODE_NV 0x90B0 #define GL_PATH_GEN_COEFF_NV 0x90B1 #define GL_PATH_GEN_COMPONENTS_NV 0x90B3 #define GL_PATH_STENCIL_FUNC_NV 0x90B7 #define GL_PATH_STENCIL_REF_NV 0x90B8 #define GL_PATH_STENCIL_VALUE_MASK_NV 0x90B9 #define GL_PATH_STENCIL_DEPTH_OFFSET_FACTOR_NV 0x90BD #define GL_PATH_STENCIL_DEPTH_OFFSET_UNITS_NV 0x90BE #define GL_PATH_COVER_DEPTH_FUNC_NV 0x90BF #define GL_PATH_DASH_OFFSET_RESET_NV 0x90B4 #define GL_MOVE_TO_RESETS_NV 0x90B5 #define GL_MOVE_TO_CONTINUES_NV 0x90B6 #define GL_CLOSE_PATH_NV 0x00 #define GL_MOVE_TO_NV 0x02 #define GL_RELATIVE_MOVE_TO_NV 0x03 #define GL_LINE_TO_NV 0x04 #define GL_RELATIVE_LINE_TO_NV 0x05 #define GL_HORIZONTAL_LINE_TO_NV 0x06 #define GL_RELATIVE_HORIZONTAL_LINE_TO_NV 0x07 #define GL_VERTICAL_LINE_TO_NV 0x08 #define GL_RELATIVE_VERTICAL_LINE_TO_NV 0x09 #define GL_QUADRATIC_CURVE_TO_NV 0x0A #define GL_RELATIVE_QUADRATIC_CURVE_TO_NV 0x0B #define GL_CUBIC_CURVE_TO_NV 0x0C #define GL_RELATIVE_CUBIC_CURVE_TO_NV 0x0D #define GL_SMOOTH_QUADRATIC_CURVE_TO_NV 0x0E #define GL_RELATIVE_SMOOTH_QUADRATIC_CURVE_TO_NV 0x0F #define GL_SMOOTH_CUBIC_CURVE_TO_NV 0x10 #define GL_RELATIVE_SMOOTH_CUBIC_CURVE_TO_NV 0x11 #define GL_SMALL_CCW_ARC_TO_NV 0x12 #define GL_RELATIVE_SMALL_CCW_ARC_TO_NV 0x13 #define GL_SMALL_CW_ARC_TO_NV 0x14 #define GL_RELATIVE_SMALL_CW_ARC_TO_NV 0x15 #define GL_LARGE_CCW_ARC_TO_NV 0x16 #define GL_RELATIVE_LARGE_CCW_ARC_TO_NV 0x17 #define GL_LARGE_CW_ARC_TO_NV 0x18 #define GL_RELATIVE_LARGE_CW_ARC_TO_NV 0x19 #define GL_RESTART_PATH_NV 0xF0 #define GL_DUP_FIRST_CUBIC_CURVE_TO_NV 0xF2 #define GL_DUP_LAST_CUBIC_CURVE_TO_NV 0xF4 #define GL_RECT_NV 0xF6 #define GL_CIRCULAR_CCW_ARC_TO_NV 0xF8 #define GL_CIRCULAR_CW_ARC_TO_NV 0xFA #define GL_CIRCULAR_TANGENT_ARC_TO_NV 0xFC #define GL_ARC_TO_NV 0xFE #define GL_RELATIVE_ARC_TO_NV 0xFF #define GL_BOLD_BIT_NV 0x01 #define GL_ITALIC_BIT_NV 0x02 #define GL_GLYPH_WIDTH_BIT_NV 0x01 #define GL_GLYPH_HEIGHT_BIT_NV 0x02 #define GL_GLYPH_HORIZONTAL_BEARING_X_BIT_NV 0x04 #define GL_GLYPH_HORIZONTAL_BEARING_Y_BIT_NV 0x08 #define GL_GLYPH_HORIZONTAL_BEARING_ADVANCE_BIT_NV 0x10 #define GL_GLYPH_VERTICAL_BEARING_X_BIT_NV 0x20 #define GL_GLYPH_VERTICAL_BEARING_Y_BIT_NV 0x40 #define GL_GLYPH_VERTICAL_BEARING_ADVANCE_BIT_NV 0x80 #define GL_GLYPH_HAS_KERNING_BIT_NV 0x100 #define GL_FONT_X_MIN_BOUNDS_BIT_NV 0x00010000 #define GL_FONT_Y_MIN_BOUNDS_BIT_NV 0x00020000 #define GL_FONT_X_MAX_BOUNDS_BIT_NV 0x00040000 #define GL_FONT_Y_MAX_BOUNDS_BIT_NV 0x00080000 #define GL_FONT_UNITS_PER_EM_BIT_NV 0x00100000 #define GL_FONT_ASCENDER_BIT_NV 0x00200000 #define GL_FONT_DESCENDER_BIT_NV 0x00400000 #define GL_FONT_HEIGHT_BIT_NV 0x00800000 #define GL_FONT_MAX_ADVANCE_WIDTH_BIT_NV 0x01000000 #define GL_FONT_MAX_ADVANCE_HEIGHT_BIT_NV 0x02000000 #define GL_FONT_UNDERLINE_POSITION_BIT_NV 0x04000000 #define GL_FONT_UNDERLINE_THICKNESS_BIT_NV 0x08000000 #define GL_FONT_HAS_KERNING_BIT_NV 0x10000000 #define GL_ROUNDED_RECT_NV 0xE8 #define GL_RELATIVE_ROUNDED_RECT_NV 0xE9 #define GL_ROUNDED_RECT2_NV 0xEA #define GL_RELATIVE_ROUNDED_RECT2_NV 0xEB #define GL_ROUNDED_RECT4_NV 0xEC #define GL_RELATIVE_ROUNDED_RECT4_NV 0xED #define GL_ROUNDED_RECT8_NV 0xEE #define GL_RELATIVE_ROUNDED_RECT8_NV 0xEF #define GL_RELATIVE_RECT_NV 0xF7 #define GL_FONT_GLYPHS_AVAILABLE_NV 0x9368 #define GL_FONT_TARGET_UNAVAILABLE_NV 0x9369 #define GL_FONT_UNAVAILABLE_NV 0x936A #define GL_FONT_UNINTELLIGIBLE_NV 0x936B #define GL_CONIC_CURVE_TO_NV 0x1A #define GL_RELATIVE_CONIC_CURVE_TO_NV 0x1B #define GL_FONT_NUM_GLYPH_INDICES_BIT_NV 0x20000000 #define GL_STANDARD_FONT_FORMAT_NV 0x936C #define GL_PATH_PROJECTION_NV 0x1701 #define GL_PATH_MODELVIEW_NV 0x1700 #define GL_PATH_MODELVIEW_STACK_DEPTH_NV 0x0BA3 #define GL_PATH_MODELVIEW_MATRIX_NV 0x0BA6 #define GL_PATH_MAX_MODELVIEW_STACK_DEPTH_NV 0x0D36 #define GL_PATH_TRANSPOSE_MODELVIEW_MATRIX_NV 0x84E3 #define GL_PATH_PROJECTION_STACK_DEPTH_NV 0x0BA4 #define GL_PATH_PROJECTION_MATRIX_NV 0x0BA7 #define GL_PATH_MAX_PROJECTION_STACK_DEPTH_NV 0x0D38 #define GL_PATH_TRANSPOSE_PROJECTION_MATRIX_NV 0x84E4 #define GL_FRAGMENT_INPUT_NV 0x936D typedef GLuint (GL_APIENTRYP PFNGLGENPATHSNVPROC) (GLsizei range); typedef void (GL_APIENTRYP PFNGLDELETEPATHSNVPROC) (GLuint path, GLsizei range); typedef GLboolean (GL_APIENTRYP PFNGLISPATHNVPROC) (GLuint path); typedef void (GL_APIENTRYP PFNGLPATHCOMMANDSNVPROC) (GLuint path, GLsizei numCommands, const GLubyte *commands, GLsizei numCoords, GLenum coordType, const void *coords); typedef void (GL_APIENTRYP PFNGLPATHCOORDSNVPROC) (GLuint path, GLsizei numCoords, GLenum coordType, const void *coords); typedef void (GL_APIENTRYP PFNGLPATHSUBCOMMANDSNVPROC) (GLuint path, GLsizei commandStart, GLsizei commandsToDelete, GLsizei numCommands, const GLubyte *commands, GLsizei numCoords, GLenum coordType, const void *coords); typedef void (GL_APIENTRYP PFNGLPATHSUBCOORDSNVPROC) (GLuint path, GLsizei coordStart, GLsizei numCoords, GLenum coordType, const void *coords); typedef void (GL_APIENTRYP PFNGLPATHSTRINGNVPROC) (GLuint path, GLenum format, GLsizei length, const void *pathString); typedef void (GL_APIENTRYP PFNGLPATHGLYPHSNVPROC) (GLuint firstPathName, GLenum fontTarget, const void *fontName, GLbitfield fontStyle, GLsizei numGlyphs, GLenum type, const void *charcodes, GLenum handleMissingGlyphs, GLuint pathParameterTemplate, GLfloat emScale); typedef void (GL_APIENTRYP PFNGLPATHGLYPHRANGENVPROC) (GLuint firstPathName, GLenum fontTarget, const void *fontName, GLbitfield fontStyle, GLuint firstGlyph, GLsizei numGlyphs, GLenum handleMissingGlyphs, GLuint pathParameterTemplate, GLfloat emScale); typedef void (GL_APIENTRYP PFNGLWEIGHTPATHSNVPROC) (GLuint resultPath, GLsizei numPaths, const GLuint *paths, const GLfloat *weights); typedef void (GL_APIENTRYP PFNGLCOPYPATHNVPROC) (GLuint resultPath, GLuint srcPath); typedef void (GL_APIENTRYP PFNGLINTERPOLATEPATHSNVPROC) (GLuint resultPath, GLuint pathA, GLuint pathB, GLfloat weight); typedef void (GL_APIENTRYP PFNGLTRANSFORMPATHNVPROC) (GLuint resultPath, GLuint srcPath, GLenum transformType, const GLfloat *transformValues); typedef void (GL_APIENTRYP PFNGLPATHPARAMETERIVNVPROC) (GLuint path, GLenum pname, const GLint *value); typedef void (GL_APIENTRYP PFNGLPATHPARAMETERINVPROC) (GLuint path, GLenum pname, GLint value); typedef void (GL_APIENTRYP PFNGLPATHPARAMETERFVNVPROC) (GLuint path, GLenum pname, const GLfloat *value); typedef void (GL_APIENTRYP PFNGLPATHPARAMETERFNVPROC) (GLuint path, GLenum pname, GLfloat value); typedef void (GL_APIENTRYP PFNGLPATHDASHARRAYNVPROC) (GLuint path, GLsizei dashCount, const GLfloat *dashArray); typedef void (GL_APIENTRYP PFNGLPATHSTENCILFUNCNVPROC) (GLenum func, GLint ref, GLuint mask); typedef void (GL_APIENTRYP PFNGLPATHSTENCILDEPTHOFFSETNVPROC) (GLfloat factor, GLfloat units); typedef void (GL_APIENTRYP PFNGLSTENCILFILLPATHNVPROC) (GLuint path, GLenum fillMode, GLuint mask); typedef void (GL_APIENTRYP PFNGLSTENCILSTROKEPATHNVPROC) (GLuint path, GLint reference, GLuint mask); typedef void (GL_APIENTRYP PFNGLSTENCILFILLPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLenum fillMode, GLuint mask, GLenum transformType, const GLfloat *transformValues); typedef void (GL_APIENTRYP PFNGLSTENCILSTROKEPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLint reference, GLuint mask, GLenum transformType, const GLfloat *transformValues); typedef void (GL_APIENTRYP PFNGLPATHCOVERDEPTHFUNCNVPROC) (GLenum func); typedef void (GL_APIENTRYP PFNGLCOVERFILLPATHNVPROC) (GLuint path, GLenum coverMode); typedef void (GL_APIENTRYP PFNGLCOVERSTROKEPATHNVPROC) (GLuint path, GLenum coverMode); typedef void (GL_APIENTRYP PFNGLCOVERFILLPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLenum coverMode, GLenum transformType, const GLfloat *transformValues); typedef void (GL_APIENTRYP PFNGLCOVERSTROKEPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLenum coverMode, GLenum transformType, const GLfloat *transformValues); typedef void (GL_APIENTRYP PFNGLGETPATHPARAMETERIVNVPROC) (GLuint path, GLenum pname, GLint *value); typedef void (GL_APIENTRYP PFNGLGETPATHPARAMETERFVNVPROC) (GLuint path, GLenum pname, GLfloat *value); typedef void (GL_APIENTRYP PFNGLGETPATHCOMMANDSNVPROC) (GLuint path, GLubyte *commands); typedef void (GL_APIENTRYP PFNGLGETPATHCOORDSNVPROC) (GLuint path, GLfloat *coords); typedef void (GL_APIENTRYP PFNGLGETPATHDASHARRAYNVPROC) (GLuint path, GLfloat *dashArray); typedef void (GL_APIENTRYP PFNGLGETPATHMETRICSNVPROC) (GLbitfield metricQueryMask, GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLsizei stride, GLfloat *metrics); typedef void (GL_APIENTRYP PFNGLGETPATHMETRICRANGENVPROC) (GLbitfield metricQueryMask, GLuint firstPathName, GLsizei numPaths, GLsizei stride, GLfloat *metrics); typedef void (GL_APIENTRYP PFNGLGETPATHSPACINGNVPROC) (GLenum pathListMode, GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLfloat advanceScale, GLfloat kerningScale, GLenum transformType, GLfloat *returnedSpacing); typedef GLboolean (GL_APIENTRYP PFNGLISPOINTINFILLPATHNVPROC) (GLuint path, GLuint mask, GLfloat x, GLfloat y); typedef GLboolean (GL_APIENTRYP PFNGLISPOINTINSTROKEPATHNVPROC) (GLuint path, GLfloat x, GLfloat y); typedef GLfloat (GL_APIENTRYP PFNGLGETPATHLENGTHNVPROC) (GLuint path, GLsizei startSegment, GLsizei numSegments); typedef GLboolean (GL_APIENTRYP PFNGLPOINTALONGPATHNVPROC) (GLuint path, GLsizei startSegment, GLsizei numSegments, GLfloat distance, GLfloat *x, GLfloat *y, GLfloat *tangentX, GLfloat *tangentY); typedef void (GL_APIENTRYP PFNGLMATRIXLOAD3X2FNVPROC) (GLenum matrixMode, const GLfloat *m); typedef void (GL_APIENTRYP PFNGLMATRIXLOAD3X3FNVPROC) (GLenum matrixMode, const GLfloat *m); typedef void (GL_APIENTRYP PFNGLMATRIXLOADTRANSPOSE3X3FNVPROC) (GLenum matrixMode, const GLfloat *m); typedef void (GL_APIENTRYP PFNGLMATRIXMULT3X2FNVPROC) (GLenum matrixMode, const GLfloat *m); typedef void (GL_APIENTRYP PFNGLMATRIXMULT3X3FNVPROC) (GLenum matrixMode, const GLfloat *m); typedef void (GL_APIENTRYP PFNGLMATRIXMULTTRANSPOSE3X3FNVPROC) (GLenum matrixMode, const GLfloat *m); typedef void (GL_APIENTRYP PFNGLSTENCILTHENCOVERFILLPATHNVPROC) (GLuint path, GLenum fillMode, GLuint mask, GLenum coverMode); typedef void (GL_APIENTRYP PFNGLSTENCILTHENCOVERSTROKEPATHNVPROC) (GLuint path, GLint reference, GLuint mask, GLenum coverMode); typedef void (GL_APIENTRYP PFNGLSTENCILTHENCOVERFILLPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLenum fillMode, GLuint mask, GLenum coverMode, GLenum transformType, const GLfloat *transformValues); typedef void (GL_APIENTRYP PFNGLSTENCILTHENCOVERSTROKEPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLint reference, GLuint mask, GLenum coverMode, GLenum transformType, const GLfloat *transformValues); typedef GLenum (GL_APIENTRYP PFNGLPATHGLYPHINDEXRANGENVPROC) (GLenum fontTarget, const void *fontName, GLbitfield fontStyle, GLuint pathParameterTemplate, GLfloat emScale, GLuint *baseAndCount); typedef GLenum (GL_APIENTRYP PFNGLPATHGLYPHINDEXARRAYNVPROC) (GLuint firstPathName, GLenum fontTarget, const void *fontName, GLbitfield fontStyle, GLuint firstGlyphIndex, GLsizei numGlyphs, GLuint pathParameterTemplate, GLfloat emScale); typedef GLenum (GL_APIENTRYP PFNGLPATHMEMORYGLYPHINDEXARRAYNVPROC) (GLuint firstPathName, GLenum fontTarget, GLsizeiptr fontSize, const void *fontData, GLsizei faceIndex, GLuint firstGlyphIndex, GLsizei numGlyphs, GLuint pathParameterTemplate, GLfloat emScale); typedef void (GL_APIENTRYP PFNGLPROGRAMPATHFRAGMENTINPUTGENNVPROC) (GLuint program, GLint location, GLenum genMode, GLint components, const GLfloat *coeffs); typedef void (GL_APIENTRYP PFNGLGETPROGRAMRESOURCEFVNVPROC) (GLuint program, GLenum programInterface, GLuint index, GLsizei propCount, const GLenum *props, GLsizei count, GLsizei *length, GLfloat *params); typedef void (GL_APIENTRYP PFNGLMATRIXFRUSTUMEXTPROC) (GLenum mode, GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); typedef void (GL_APIENTRYP PFNGLMATRIXLOADIDENTITYEXTPROC) (GLenum mode); typedef void (GL_APIENTRYP PFNGLMATRIXLOADTRANSPOSEFEXTPROC) (GLenum mode, const GLfloat *m); typedef void (GL_APIENTRYP PFNGLMATRIXLOADTRANSPOSEDEXTPROC) (GLenum mode, const GLdouble *m); typedef void (GL_APIENTRYP PFNGLMATRIXLOADFEXTPROC) (GLenum mode, const GLfloat *m); typedef void (GL_APIENTRYP PFNGLMATRIXLOADDEXTPROC) (GLenum mode, const GLdouble *m); typedef void (GL_APIENTRYP PFNGLMATRIXMULTTRANSPOSEFEXTPROC) (GLenum mode, const GLfloat *m); typedef void (GL_APIENTRYP PFNGLMATRIXMULTTRANSPOSEDEXTPROC) (GLenum mode, const GLdouble *m); typedef void (GL_APIENTRYP PFNGLMATRIXMULTFEXTPROC) (GLenum mode, const GLfloat *m); typedef void (GL_APIENTRYP PFNGLMATRIXMULTDEXTPROC) (GLenum mode, const GLdouble *m); typedef void (GL_APIENTRYP PFNGLMATRIXORTHOEXTPROC) (GLenum mode, GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); typedef void (GL_APIENTRYP PFNGLMATRIXPOPEXTPROC) (GLenum mode); typedef void (GL_APIENTRYP PFNGLMATRIXPUSHEXTPROC) (GLenum mode); typedef void (GL_APIENTRYP PFNGLMATRIXROTATEFEXTPROC) (GLenum mode, GLfloat angle, GLfloat x, GLfloat y, GLfloat z); typedef void (GL_APIENTRYP PFNGLMATRIXROTATEDEXTPROC) (GLenum mode, GLdouble angle, GLdouble x, GLdouble y, GLdouble z); typedef void (GL_APIENTRYP PFNGLMATRIXSCALEFEXTPROC) (GLenum mode, GLfloat x, GLfloat y, GLfloat z); typedef void (GL_APIENTRYP PFNGLMATRIXSCALEDEXTPROC) (GLenum mode, GLdouble x, GLdouble y, GLdouble z); typedef void (GL_APIENTRYP PFNGLMATRIXTRANSLATEFEXTPROC) (GLenum mode, GLfloat x, GLfloat y, GLfloat z); typedef void (GL_APIENTRYP PFNGLMATRIXTRANSLATEDEXTPROC) (GLenum mode, GLdouble x, GLdouble y, GLdouble z); #ifdef GL_GLEXT_PROTOTYPES GL_APICALL GLuint GL_APIENTRY glGenPathsNV (GLsizei range); GL_APICALL void GL_APIENTRY glDeletePathsNV (GLuint path, GLsizei range); GL_APICALL GLboolean GL_APIENTRY glIsPathNV (GLuint path); GL_APICALL void GL_APIENTRY glPathCommandsNV (GLuint path, GLsizei numCommands, const GLubyte *commands, GLsizei numCoords, GLenum coordType, const void *coords); GL_APICALL void GL_APIENTRY glPathCoordsNV (GLuint path, GLsizei numCoords, GLenum coordType, const void *coords); GL_APICALL void GL_APIENTRY glPathSubCommandsNV (GLuint path, GLsizei commandStart, GLsizei commandsToDelete, GLsizei numCommands, const GLubyte *commands, GLsizei numCoords, GLenum coordType, const void *coords); GL_APICALL void GL_APIENTRY glPathSubCoordsNV (GLuint path, GLsizei coordStart, GLsizei numCoords, GLenum coordType, const void *coords); GL_APICALL void GL_APIENTRY glPathStringNV (GLuint path, GLenum format, GLsizei length, const void *pathString); GL_APICALL void GL_APIENTRY glPathGlyphsNV (GLuint firstPathName, GLenum fontTarget, const void *fontName, GLbitfield fontStyle, GLsizei numGlyphs, GLenum type, const void *charcodes, GLenum handleMissingGlyphs, GLuint pathParameterTemplate, GLfloat emScale); GL_APICALL void GL_APIENTRY glPathGlyphRangeNV (GLuint firstPathName, GLenum fontTarget, const void *fontName, GLbitfield fontStyle, GLuint firstGlyph, GLsizei numGlyphs, GLenum handleMissingGlyphs, GLuint pathParameterTemplate, GLfloat emScale); GL_APICALL void GL_APIENTRY glWeightPathsNV (GLuint resultPath, GLsizei numPaths, const GLuint *paths, const GLfloat *weights); GL_APICALL void GL_APIENTRY glCopyPathNV (GLuint resultPath, GLuint srcPath); GL_APICALL void GL_APIENTRY glInterpolatePathsNV (GLuint resultPath, GLuint pathA, GLuint pathB, GLfloat weight); GL_APICALL void GL_APIENTRY glTransformPathNV (GLuint resultPath, GLuint srcPath, GLenum transformType, const GLfloat *transformValues); GL_APICALL void GL_APIENTRY glPathParameterivNV (GLuint path, GLenum pname, const GLint *value); GL_APICALL void GL_APIENTRY glPathParameteriNV (GLuint path, GLenum pname, GLint value); GL_APICALL void GL_APIENTRY glPathParameterfvNV (GLuint path, GLenum pname, const GLfloat *value); GL_APICALL void GL_APIENTRY glPathParameterfNV (GLuint path, GLenum pname, GLfloat value); GL_APICALL void GL_APIENTRY glPathDashArrayNV (GLuint path, GLsizei dashCount, const GLfloat *dashArray); GL_APICALL void GL_APIENTRY glPathStencilFuncNV (GLenum func, GLint ref, GLuint mask); GL_APICALL void GL_APIENTRY glPathStencilDepthOffsetNV (GLfloat factor, GLfloat units); GL_APICALL void GL_APIENTRY glStencilFillPathNV (GLuint path, GLenum fillMode, GLuint mask); GL_APICALL void GL_APIENTRY glStencilStrokePathNV (GLuint path, GLint reference, GLuint mask); GL_APICALL void GL_APIENTRY glStencilFillPathInstancedNV (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLenum fillMode, GLuint mask, GLenum transformType, const GLfloat *transformValues); GL_APICALL void GL_APIENTRY glStencilStrokePathInstancedNV (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLint reference, GLuint mask, GLenum transformType, const GLfloat *transformValues); GL_APICALL void GL_APIENTRY glPathCoverDepthFuncNV (GLenum func); GL_APICALL void GL_APIENTRY glCoverFillPathNV (GLuint path, GLenum coverMode); GL_APICALL void GL_APIENTRY glCoverStrokePathNV (GLuint path, GLenum coverMode); GL_APICALL void GL_APIENTRY glCoverFillPathInstancedNV (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLenum coverMode, GLenum transformType, const GLfloat *transformValues); GL_APICALL void GL_APIENTRY glCoverStrokePathInstancedNV (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLenum coverMode, GLenum transformType, const GLfloat *transformValues); GL_APICALL void GL_APIENTRY glGetPathParameterivNV (GLuint path, GLenum pname, GLint *value); GL_APICALL void GL_APIENTRY glGetPathParameterfvNV (GLuint path, GLenum pname, GLfloat *value); GL_APICALL void GL_APIENTRY glGetPathCommandsNV (GLuint path, GLubyte *commands); GL_APICALL void GL_APIENTRY glGetPathCoordsNV (GLuint path, GLfloat *coords); GL_APICALL void GL_APIENTRY glGetPathDashArrayNV (GLuint path, GLfloat *dashArray); GL_APICALL void GL_APIENTRY glGetPathMetricsNV (GLbitfield metricQueryMask, GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLsizei stride, GLfloat *metrics); GL_APICALL void GL_APIENTRY glGetPathMetricRangeNV (GLbitfield metricQueryMask, GLuint firstPathName, GLsizei numPaths, GLsizei stride, GLfloat *metrics); GL_APICALL void GL_APIENTRY glGetPathSpacingNV (GLenum pathListMode, GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLfloat advanceScale, GLfloat kerningScale, GLenum transformType, GLfloat *returnedSpacing); GL_APICALL GLboolean GL_APIENTRY glIsPointInFillPathNV (GLuint path, GLuint mask, GLfloat x, GLfloat y); GL_APICALL GLboolean GL_APIENTRY glIsPointInStrokePathNV (GLuint path, GLfloat x, GLfloat y); GL_APICALL GLfloat GL_APIENTRY glGetPathLengthNV (GLuint path, GLsizei startSegment, GLsizei numSegments); GL_APICALL GLboolean GL_APIENTRY glPointAlongPathNV (GLuint path, GLsizei startSegment, GLsizei numSegments, GLfloat distance, GLfloat *x, GLfloat *y, GLfloat *tangentX, GLfloat *tangentY); GL_APICALL void GL_APIENTRY glMatrixLoad3x2fNV (GLenum matrixMode, const GLfloat *m); GL_APICALL void GL_APIENTRY glMatrixLoad3x3fNV (GLenum matrixMode, const GLfloat *m); GL_APICALL void GL_APIENTRY glMatrixLoadTranspose3x3fNV (GLenum matrixMode, const GLfloat *m); GL_APICALL void GL_APIENTRY glMatrixMult3x2fNV (GLenum matrixMode, const GLfloat *m); GL_APICALL void GL_APIENTRY glMatrixMult3x3fNV (GLenum matrixMode, const GLfloat *m); GL_APICALL void GL_APIENTRY glMatrixMultTranspose3x3fNV (GLenum matrixMode, const GLfloat *m); GL_APICALL void GL_APIENTRY glStencilThenCoverFillPathNV (GLuint path, GLenum fillMode, GLuint mask, GLenum coverMode); GL_APICALL void GL_APIENTRY glStencilThenCoverStrokePathNV (GLuint path, GLint reference, GLuint mask, GLenum coverMode); GL_APICALL void GL_APIENTRY glStencilThenCoverFillPathInstancedNV (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLenum fillMode, GLuint mask, GLenum coverMode, GLenum transformType, const GLfloat *transformValues); GL_APICALL void GL_APIENTRY glStencilThenCoverStrokePathInstancedNV (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLint reference, GLuint mask, GLenum coverMode, GLenum transformType, const GLfloat *transformValues); GL_APICALL GLenum GL_APIENTRY glPathGlyphIndexRangeNV (GLenum fontTarget, const void *fontName, GLbitfield fontStyle, GLuint pathParameterTemplate, GLfloat emScale, GLuint *baseAndCount); GL_APICALL GLenum GL_APIENTRY glPathGlyphIndexArrayNV (GLuint firstPathName, GLenum fontTarget, const void *fontName, GLbitfield fontStyle, GLuint firstGlyphIndex, GLsizei numGlyphs, GLuint pathParameterTemplate, GLfloat emScale); GL_APICALL GLenum GL_APIENTRY glPathMemoryGlyphIndexArrayNV (GLuint firstPathName, GLenum fontTarget, GLsizeiptr fontSize, const void *fontData, GLsizei faceIndex, GLuint firstGlyphIndex, GLsizei numGlyphs, GLuint pathParameterTemplate, GLfloat emScale); GL_APICALL void GL_APIENTRY glProgramPathFragmentInputGenNV (GLuint program, GLint location, GLenum genMode, GLint components, const GLfloat *coeffs); GL_APICALL void GL_APIENTRY glGetProgramResourcefvNV (GLuint program, GLenum programInterface, GLuint index, GLsizei propCount, const GLenum *props, GLsizei count, GLsizei *length, GLfloat *params); GL_APICALL void GL_APIENTRY glMatrixFrustumEXT (GLenum mode, GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); GL_APICALL void GL_APIENTRY glMatrixLoadIdentityEXT (GLenum mode); GL_APICALL void GL_APIENTRY glMatrixLoadTransposefEXT (GLenum mode, const GLfloat *m); GL_APICALL void GL_APIENTRY glMatrixLoadTransposedEXT (GLenum mode, const GLdouble *m); GL_APICALL void GL_APIENTRY glMatrixLoadfEXT (GLenum mode, const GLfloat *m); GL_APICALL void GL_APIENTRY glMatrixLoaddEXT (GLenum mode, const GLdouble *m); GL_APICALL void GL_APIENTRY glMatrixMultTransposefEXT (GLenum mode, const GLfloat *m); GL_APICALL void GL_APIENTRY glMatrixMultTransposedEXT (GLenum mode, const GLdouble *m); GL_APICALL void GL_APIENTRY glMatrixMultfEXT (GLenum mode, const GLfloat *m); GL_APICALL void GL_APIENTRY glMatrixMultdEXT (GLenum mode, const GLdouble *m); GL_APICALL void GL_APIENTRY glMatrixOrthoEXT (GLenum mode, GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); GL_APICALL void GL_APIENTRY glMatrixPopEXT (GLenum mode); GL_APICALL void GL_APIENTRY glMatrixPushEXT (GLenum mode); GL_APICALL void GL_APIENTRY glMatrixRotatefEXT (GLenum mode, GLfloat angle, GLfloat x, GLfloat y, GLfloat z); GL_APICALL void GL_APIENTRY glMatrixRotatedEXT (GLenum mode, GLdouble angle, GLdouble x, GLdouble y, GLdouble z); GL_APICALL void GL_APIENTRY glMatrixScalefEXT (GLenum mode, GLfloat x, GLfloat y, GLfloat z); GL_APICALL void GL_APIENTRY glMatrixScaledEXT (GLenum mode, GLdouble x, GLdouble y, GLdouble z); GL_APICALL void GL_APIENTRY glMatrixTranslatefEXT (GLenum mode, GLfloat x, GLfloat y, GLfloat z); GL_APICALL void GL_APIENTRY glMatrixTranslatedEXT (GLenum mode, GLdouble x, GLdouble y, GLdouble z); #endif #endif /* GL_NV_path_rendering */ #ifndef GL_NV_path_rendering_shared_edge #define GL_NV_path_rendering_shared_edge 1 #define GL_SHARED_EDGE_NV 0xC0 #endif /* GL_NV_path_rendering_shared_edge */ #ifndef GL_NV_pixel_buffer_object #define GL_NV_pixel_buffer_object 1 #define GL_PIXEL_PACK_BUFFER_NV 0x88EB #define GL_PIXEL_UNPACK_BUFFER_NV 0x88EC #define GL_PIXEL_PACK_BUFFER_BINDING_NV 0x88ED #define GL_PIXEL_UNPACK_BUFFER_BINDING_NV 0x88EF #endif /* GL_NV_pixel_buffer_object */ #ifndef GL_NV_polygon_mode #define GL_NV_polygon_mode 1 #define GL_POLYGON_MODE_NV 0x0B40 #define GL_POLYGON_OFFSET_POINT_NV 0x2A01 #define GL_POLYGON_OFFSET_LINE_NV 0x2A02 #define GL_POINT_NV 0x1B00 #define GL_LINE_NV 0x1B01 #define GL_FILL_NV 0x1B02 typedef void (GL_APIENTRYP PFNGLPOLYGONMODENVPROC) (GLenum face, GLenum mode); #ifdef GL_GLEXT_PROTOTYPES GL_APICALL void GL_APIENTRY glPolygonModeNV (GLenum face, GLenum mode); #endif #endif /* GL_NV_polygon_mode */ #ifndef GL_NV_primitive_shading_rate #define GL_NV_primitive_shading_rate 1 #define GL_SHADING_RATE_IMAGE_PER_PRIMITIVE_NV 0x95B1 #define GL_SHADING_RATE_IMAGE_PALETTE_COUNT_NV 0x95B2 #endif /* GL_NV_primitive_shading_rate */ #ifndef GL_NV_read_buffer #define GL_NV_read_buffer 1 #define GL_READ_BUFFER_NV 0x0C02 typedef void (GL_APIENTRYP PFNGLREADBUFFERNVPROC) (GLenum mode); #ifdef GL_GLEXT_PROTOTYPES GL_APICALL void GL_APIENTRY glReadBufferNV (GLenum mode); #endif #endif /* GL_NV_read_buffer */ #ifndef GL_NV_read_buffer_front #define GL_NV_read_buffer_front 1 #endif /* GL_NV_read_buffer_front */ #ifndef GL_NV_read_depth #define GL_NV_read_depth 1 #endif /* GL_NV_read_depth */ #ifndef GL_NV_read_depth_stencil #define GL_NV_read_depth_stencil 1 #endif /* GL_NV_read_depth_stencil */ #ifndef GL_NV_read_stencil #define GL_NV_read_stencil 1 #endif /* GL_NV_read_stencil */ #ifndef GL_NV_representative_fragment_test #define GL_NV_representative_fragment_test 1 #define GL_REPRESENTATIVE_FRAGMENT_TEST_NV 0x937F #endif /* GL_NV_representative_fragment_test */ #ifndef GL_NV_sRGB_formats #define GL_NV_sRGB_formats 1 #define GL_SLUMINANCE_NV 0x8C46 #define GL_SLUMINANCE_ALPHA_NV 0x8C44 #define GL_SRGB8_NV 0x8C41 #define GL_SLUMINANCE8_NV 0x8C47 #define GL_SLUMINANCE8_ALPHA8_NV 0x8C45 #define GL_COMPRESSED_SRGB_S3TC_DXT1_NV 0x8C4C #define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_NV 0x8C4D #define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_NV 0x8C4E #define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_NV 0x8C4F #define GL_ETC1_SRGB8_NV 0x88EE #endif /* GL_NV_sRGB_formats */ #ifndef GL_NV_sample_locations #define GL_NV_sample_locations 1 #define GL_SAMPLE_LOCATION_SUBPIXEL_BITS_NV 0x933D #define GL_SAMPLE_LOCATION_PIXEL_GRID_WIDTH_NV 0x933E #define GL_SAMPLE_LOCATION_PIXEL_GRID_HEIGHT_NV 0x933F #define GL_PROGRAMMABLE_SAMPLE_LOCATION_TABLE_SIZE_NV 0x9340 #define GL_SAMPLE_LOCATION_NV 0x8E50 #define GL_PROGRAMMABLE_SAMPLE_LOCATION_NV 0x9341 #define GL_FRAMEBUFFER_PROGRAMMABLE_SAMPLE_LOCATIONS_NV 0x9342 #define GL_FRAMEBUFFER_SAMPLE_LOCATION_PIXEL_GRID_NV 0x9343 typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERSAMPLELOCATIONSFVNVPROC) (GLenum target, GLuint start, GLsizei count, const GLfloat *v); typedef void (GL_APIENTRYP PFNGLNAMEDFRAMEBUFFERSAMPLELOCATIONSFVNVPROC) (GLuint framebuffer, GLuint start, GLsizei count, const GLfloat *v); typedef void (GL_APIENTRYP PFNGLRESOLVEDEPTHVALUESNVPROC) (void); #ifdef GL_GLEXT_PROTOTYPES GL_APICALL void GL_APIENTRY glFramebufferSampleLocationsfvNV (GLenum target, GLuint start, GLsizei count, const GLfloat *v); GL_APICALL void GL_APIENTRY glNamedFramebufferSampleLocationsfvNV (GLuint framebuffer, GLuint start, GLsizei count, const GLfloat *v); GL_APICALL void GL_APIENTRY glResolveDepthValuesNV (void); #endif #endif /* GL_NV_sample_locations */ #ifndef GL_NV_sample_mask_override_coverage #define GL_NV_sample_mask_override_coverage 1 #endif /* GL_NV_sample_mask_override_coverage */ #ifndef GL_NV_scissor_exclusive #define GL_NV_scissor_exclusive 1 #define GL_SCISSOR_TEST_EXCLUSIVE_NV 0x9555 #define GL_SCISSOR_BOX_EXCLUSIVE_NV 0x9556 typedef void (GL_APIENTRYP PFNGLSCISSOREXCLUSIVENVPROC) (GLint x, GLint y, GLsizei width, GLsizei height); typedef void (GL_APIENTRYP PFNGLSCISSOREXCLUSIVEARRAYVNVPROC) (GLuint first, GLsizei count, const GLint *v); #ifdef GL_GLEXT_PROTOTYPES GL_APICALL void GL_APIENTRY glScissorExclusiveNV (GLint x, GLint y, GLsizei width, GLsizei height); GL_APICALL void GL_APIENTRY glScissorExclusiveArrayvNV (GLuint first, GLsizei count, const GLint *v); #endif #endif /* GL_NV_scissor_exclusive */ #ifndef GL_NV_shader_atomic_fp16_vector #define GL_NV_shader_atomic_fp16_vector 1 #endif /* GL_NV_shader_atomic_fp16_vector */ #ifndef GL_NV_shader_noperspective_interpolation #define GL_NV_shader_noperspective_interpolation 1 #endif /* GL_NV_shader_noperspective_interpolation */ #ifndef GL_NV_shader_subgroup_partitioned #define GL_NV_shader_subgroup_partitioned 1 #define GL_SUBGROUP_FEATURE_PARTITIONED_BIT_NV 0x00000100 #endif /* GL_NV_shader_subgroup_partitioned */ #ifndef GL_NV_shader_texture_footprint #define GL_NV_shader_texture_footprint 1 #endif /* GL_NV_shader_texture_footprint */ #ifndef GL_NV_shading_rate_image #define GL_NV_shading_rate_image 1 #define GL_SHADING_RATE_IMAGE_NV 0x9563 #define GL_SHADING_RATE_NO_INVOCATIONS_NV 0x9564 #define GL_SHADING_RATE_1_INVOCATION_PER_PIXEL_NV 0x9565 #define GL_SHADING_RATE_1_INVOCATION_PER_1X2_PIXELS_NV 0x9566 #define GL_SHADING_RATE_1_INVOCATION_PER_2X1_PIXELS_NV 0x9567 #define GL_SHADING_RATE_1_INVOCATION_PER_2X2_PIXELS_NV 0x9568 #define GL_SHADING_RATE_1_INVOCATION_PER_2X4_PIXELS_NV 0x9569 #define GL_SHADING_RATE_1_INVOCATION_PER_4X2_PIXELS_NV 0x956A #define GL_SHADING_RATE_1_INVOCATION_PER_4X4_PIXELS_NV 0x956B #define GL_SHADING_RATE_2_INVOCATIONS_PER_PIXEL_NV 0x956C #define GL_SHADING_RATE_4_INVOCATIONS_PER_PIXEL_NV 0x956D #define GL_SHADING_RATE_8_INVOCATIONS_PER_PIXEL_NV 0x956E #define GL_SHADING_RATE_16_INVOCATIONS_PER_PIXEL_NV 0x956F #define GL_SHADING_RATE_IMAGE_BINDING_NV 0x955B #define GL_SHADING_RATE_IMAGE_TEXEL_WIDTH_NV 0x955C #define GL_SHADING_RATE_IMAGE_TEXEL_HEIGHT_NV 0x955D #define GL_SHADING_RATE_IMAGE_PALETTE_SIZE_NV 0x955E #define GL_MAX_COARSE_FRAGMENT_SAMPLES_NV 0x955F #define GL_SHADING_RATE_SAMPLE_ORDER_DEFAULT_NV 0x95AE #define GL_SHADING_RATE_SAMPLE_ORDER_PIXEL_MAJOR_NV 0x95AF #define GL_SHADING_RATE_SAMPLE_ORDER_SAMPLE_MAJOR_NV 0x95B0 typedef void (GL_APIENTRYP PFNGLBINDSHADINGRATEIMAGENVPROC) (GLuint texture); typedef void (GL_APIENTRYP PFNGLGETSHADINGRATEIMAGEPALETTENVPROC) (GLuint viewport, GLuint entry, GLenum *rate); typedef void (GL_APIENTRYP PFNGLGETSHADINGRATESAMPLELOCATIONIVNVPROC) (GLenum rate, GLuint samples, GLuint index, GLint *location); typedef void (GL_APIENTRYP PFNGLSHADINGRATEIMAGEBARRIERNVPROC) (GLboolean synchronize); typedef void (GL_APIENTRYP PFNGLSHADINGRATEIMAGEPALETTENVPROC) (GLuint viewport, GLuint first, GLsizei count, const GLenum *rates); typedef void (GL_APIENTRYP PFNGLSHADINGRATESAMPLEORDERNVPROC) (GLenum order); typedef void (GL_APIENTRYP PFNGLSHADINGRATESAMPLEORDERCUSTOMNVPROC) (GLenum rate, GLuint samples, const GLint *locations); #ifdef GL_GLEXT_PROTOTYPES GL_APICALL void GL_APIENTRY glBindShadingRateImageNV (GLuint texture); GL_APICALL void GL_APIENTRY glGetShadingRateImagePaletteNV (GLuint viewport, GLuint entry, GLenum *rate); GL_APICALL void GL_APIENTRY glGetShadingRateSampleLocationivNV (GLenum rate, GLuint samples, GLuint index, GLint *location); GL_APICALL void GL_APIENTRY glShadingRateImageBarrierNV (GLboolean synchronize); GL_APICALL void GL_APIENTRY glShadingRateImagePaletteNV (GLuint viewport, GLuint first, GLsizei count, const GLenum *rates); GL_APICALL void GL_APIENTRY glShadingRateSampleOrderNV (GLenum order); GL_APICALL void GL_APIENTRY glShadingRateSampleOrderCustomNV (GLenum rate, GLuint samples, const GLint *locations); #endif #endif /* GL_NV_shading_rate_image */ #ifndef GL_NV_shadow_samplers_array #define GL_NV_shadow_samplers_array 1 #define GL_SAMPLER_2D_ARRAY_SHADOW_NV 0x8DC4 #endif /* GL_NV_shadow_samplers_array */ #ifndef GL_NV_shadow_samplers_cube #define GL_NV_shadow_samplers_cube 1 #define GL_SAMPLER_CUBE_SHADOW_NV 0x8DC5 #endif /* GL_NV_shadow_samplers_cube */ #ifndef GL_NV_stereo_view_rendering #define GL_NV_stereo_view_rendering 1 #endif /* GL_NV_stereo_view_rendering */ #ifndef GL_NV_texture_border_clamp #define GL_NV_texture_border_clamp 1 #define GL_TEXTURE_BORDER_COLOR_NV 0x1004 #define GL_CLAMP_TO_BORDER_NV 0x812D #endif /* GL_NV_texture_border_clamp */ #ifndef GL_NV_texture_compression_s3tc_update #define GL_NV_texture_compression_s3tc_update 1 #endif /* GL_NV_texture_compression_s3tc_update */ #ifndef GL_NV_texture_npot_2D_mipmap #define GL_NV_texture_npot_2D_mipmap 1 #endif /* GL_NV_texture_npot_2D_mipmap */ #ifndef GL_NV_timeline_semaphore #define GL_NV_timeline_semaphore 1 #define GL_TIMELINE_SEMAPHORE_VALUE_NV 0x9595 #define GL_SEMAPHORE_TYPE_NV 0x95B3 #define GL_SEMAPHORE_TYPE_BINARY_NV 0x95B4 #define GL_SEMAPHORE_TYPE_TIMELINE_NV 0x95B5 #define GL_MAX_TIMELINE_SEMAPHORE_VALUE_DIFFERENCE_NV 0x95B6 typedef void (GL_APIENTRYP PFNGLCREATESEMAPHORESNVPROC) (GLsizei n, GLuint *semaphores); typedef void (GL_APIENTRYP PFNGLSEMAPHOREPARAMETERIVNVPROC) (GLuint semaphore, GLenum pname, const GLint *params); typedef void (GL_APIENTRYP PFNGLGETSEMAPHOREPARAMETERIVNVPROC) (GLuint semaphore, GLenum pname, GLint *params); #ifdef GL_GLEXT_PROTOTYPES GL_APICALL void GL_APIENTRY glCreateSemaphoresNV (GLsizei n, GLuint *semaphores); GL_APICALL void GL_APIENTRY glSemaphoreParameterivNV (GLuint semaphore, GLenum pname, const GLint *params); GL_APICALL void GL_APIENTRY glGetSemaphoreParameterivNV (GLuint semaphore, GLenum pname, GLint *params); #endif #endif /* GL_NV_timeline_semaphore */ #ifndef GL_NV_viewport_array #define GL_NV_viewport_array 1 #define GL_MAX_VIEWPORTS_NV 0x825B #define GL_VIEWPORT_SUBPIXEL_BITS_NV 0x825C #define GL_VIEWPORT_BOUNDS_RANGE_NV 0x825D #define GL_VIEWPORT_INDEX_PROVOKING_VERTEX_NV 0x825F typedef void (GL_APIENTRYP PFNGLVIEWPORTARRAYVNVPROC) (GLuint first, GLsizei count, const GLfloat *v); typedef void (GL_APIENTRYP PFNGLVIEWPORTINDEXEDFNVPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat w, GLfloat h); typedef void (GL_APIENTRYP PFNGLVIEWPORTINDEXEDFVNVPROC) (GLuint index, const GLfloat *v); typedef void (GL_APIENTRYP PFNGLSCISSORARRAYVNVPROC) (GLuint first, GLsizei count, const GLint *v); typedef void (GL_APIENTRYP PFNGLSCISSORINDEXEDNVPROC) (GLuint index, GLint left, GLint bottom, GLsizei width, GLsizei height); typedef void (GL_APIENTRYP PFNGLSCISSORINDEXEDVNVPROC) (GLuint index, const GLint *v); typedef void (GL_APIENTRYP PFNGLDEPTHRANGEARRAYFVNVPROC) (GLuint first, GLsizei count, const GLfloat *v); typedef void (GL_APIENTRYP PFNGLDEPTHRANGEINDEXEDFNVPROC) (GLuint index, GLfloat n, GLfloat f); typedef void (GL_APIENTRYP PFNGLGETFLOATI_VNVPROC) (GLenum target, GLuint index, GLfloat *data); typedef void (GL_APIENTRYP PFNGLENABLEINVPROC) (GLenum target, GLuint index); typedef void (GL_APIENTRYP PFNGLDISABLEINVPROC) (GLenum target, GLuint index); typedef GLboolean (GL_APIENTRYP PFNGLISENABLEDINVPROC) (GLenum target, GLuint index); #ifdef GL_GLEXT_PROTOTYPES GL_APICALL void GL_APIENTRY glViewportArrayvNV (GLuint first, GLsizei count, const GLfloat *v); GL_APICALL void GL_APIENTRY glViewportIndexedfNV (GLuint index, GLfloat x, GLfloat y, GLfloat w, GLfloat h); GL_APICALL void GL_APIENTRY glViewportIndexedfvNV (GLuint index, const GLfloat *v); GL_APICALL void GL_APIENTRY glScissorArrayvNV (GLuint first, GLsizei count, const GLint *v); GL_APICALL void GL_APIENTRY glScissorIndexedNV (GLuint index, GLint left, GLint bottom, GLsizei width, GLsizei height); GL_APICALL void GL_APIENTRY glScissorIndexedvNV (GLuint index, const GLint *v); GL_APICALL void GL_APIENTRY glDepthRangeArrayfvNV (GLuint first, GLsizei count, const GLfloat *v); GL_APICALL void GL_APIENTRY glDepthRangeIndexedfNV (GLuint index, GLfloat n, GLfloat f); GL_APICALL void GL_APIENTRY glGetFloati_vNV (GLenum target, GLuint index, GLfloat *data); GL_APICALL void GL_APIENTRY glEnableiNV (GLenum target, GLuint index); GL_APICALL void GL_APIENTRY glDisableiNV (GLenum target, GLuint index); GL_APICALL GLboolean GL_APIENTRY glIsEnablediNV (GLenum target, GLuint index); #endif #endif /* GL_NV_viewport_array */ #ifndef GL_NV_viewport_array2 #define GL_NV_viewport_array2 1 #endif /* GL_NV_viewport_array2 */ #ifndef GL_NV_viewport_swizzle #define GL_NV_viewport_swizzle 1 #define GL_VIEWPORT_SWIZZLE_POSITIVE_X_NV 0x9350 #define GL_VIEWPORT_SWIZZLE_NEGATIVE_X_NV 0x9351 #define GL_VIEWPORT_SWIZZLE_POSITIVE_Y_NV 0x9352 #define GL_VIEWPORT_SWIZZLE_NEGATIVE_Y_NV 0x9353 #define GL_VIEWPORT_SWIZZLE_POSITIVE_Z_NV 0x9354 #define GL_VIEWPORT_SWIZZLE_NEGATIVE_Z_NV 0x9355 #define GL_VIEWPORT_SWIZZLE_POSITIVE_W_NV 0x9356 #define GL_VIEWPORT_SWIZZLE_NEGATIVE_W_NV 0x9357 #define GL_VIEWPORT_SWIZZLE_X_NV 0x9358 #define GL_VIEWPORT_SWIZZLE_Y_NV 0x9359 #define GL_VIEWPORT_SWIZZLE_Z_NV 0x935A #define GL_VIEWPORT_SWIZZLE_W_NV 0x935B typedef void (GL_APIENTRYP PFNGLVIEWPORTSWIZZLENVPROC) (GLuint index, GLenum swizzlex, GLenum swizzley, GLenum swizzlez, GLenum swizzlew); #ifdef GL_GLEXT_PROTOTYPES GL_APICALL void GL_APIENTRY glViewportSwizzleNV (GLuint index, GLenum swizzlex, GLenum swizzley, GLenum swizzlez, GLenum swizzlew); #endif #endif /* GL_NV_viewport_swizzle */ #ifndef GL_OVR_multiview #define GL_OVR_multiview 1 #define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_NUM_VIEWS_OVR 0x9630 #define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_BASE_VIEW_INDEX_OVR 0x9632 #define GL_MAX_VIEWS_OVR 0x9631 #define GL_FRAMEBUFFER_INCOMPLETE_VIEW_TARGETS_OVR 0x9633 typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERTEXTUREMULTIVIEWOVRPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint baseViewIndex, GLsizei numViews); #ifdef GL_GLEXT_PROTOTYPES GL_APICALL void GL_APIENTRY glFramebufferTextureMultiviewOVR (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint baseViewIndex, GLsizei numViews); #endif #endif /* GL_OVR_multiview */ #ifndef GL_OVR_multiview2 #define GL_OVR_multiview2 1 #endif /* GL_OVR_multiview2 */ #ifndef GL_OVR_multiview_multisampled_render_to_texture #define GL_OVR_multiview_multisampled_render_to_texture 1 typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERTEXTUREMULTISAMPLEMULTIVIEWOVRPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLsizei samples, GLint baseViewIndex, GLsizei numViews); #ifdef GL_GLEXT_PROTOTYPES GL_APICALL void GL_APIENTRY glFramebufferTextureMultisampleMultiviewOVR (GLenum target, GLenum attachment, GLuint texture, GLint level, GLsizei samples, GLint baseViewIndex, GLsizei numViews); #endif #endif /* GL_OVR_multiview_multisampled_render_to_texture */ #ifndef GL_QCOM_YUV_texture_gather #define GL_QCOM_YUV_texture_gather 1 #endif /* GL_QCOM_YUV_texture_gather */ #ifndef GL_QCOM_alpha_test #define GL_QCOM_alpha_test 1 #define GL_ALPHA_TEST_QCOM 0x0BC0 #define GL_ALPHA_TEST_FUNC_QCOM 0x0BC1 #define GL_ALPHA_TEST_REF_QCOM 0x0BC2 typedef void (GL_APIENTRYP PFNGLALPHAFUNCQCOMPROC) (GLenum func, GLclampf ref); #ifdef GL_GLEXT_PROTOTYPES GL_APICALL void GL_APIENTRY glAlphaFuncQCOM (GLenum func, GLclampf ref); #endif #endif /* GL_QCOM_alpha_test */ #ifndef GL_QCOM_binning_control #define GL_QCOM_binning_control 1 #define GL_BINNING_CONTROL_HINT_QCOM 0x8FB0 #define GL_CPU_OPTIMIZED_QCOM 0x8FB1 #define GL_GPU_OPTIMIZED_QCOM 0x8FB2 #define GL_RENDER_DIRECT_TO_FRAMEBUFFER_QCOM 0x8FB3 #endif /* GL_QCOM_binning_control */ #ifndef GL_QCOM_driver_control #define GL_QCOM_driver_control 1 typedef void (GL_APIENTRYP PFNGLGETDRIVERCONTROLSQCOMPROC) (GLint *num, GLsizei size, GLuint *driverControls); typedef void (GL_APIENTRYP PFNGLGETDRIVERCONTROLSTRINGQCOMPROC) (GLuint driverControl, GLsizei bufSize, GLsizei *length, GLchar *driverControlString); typedef void (GL_APIENTRYP PFNGLENABLEDRIVERCONTROLQCOMPROC) (GLuint driverControl); typedef void (GL_APIENTRYP PFNGLDISABLEDRIVERCONTROLQCOMPROC) (GLuint driverControl); #ifdef GL_GLEXT_PROTOTYPES GL_APICALL void GL_APIENTRY glGetDriverControlsQCOM (GLint *num, GLsizei size, GLuint *driverControls); GL_APICALL void GL_APIENTRY glGetDriverControlStringQCOM (GLuint driverControl, GLsizei bufSize, GLsizei *length, GLchar *driverControlString); GL_APICALL void GL_APIENTRY glEnableDriverControlQCOM (GLuint driverControl); GL_APICALL void GL_APIENTRY glDisableDriverControlQCOM (GLuint driverControl); #endif #endif /* GL_QCOM_driver_control */ #ifndef GL_QCOM_extended_get #define GL_QCOM_extended_get 1 #define GL_TEXTURE_WIDTH_QCOM 0x8BD2 #define GL_TEXTURE_HEIGHT_QCOM 0x8BD3 #define GL_TEXTURE_DEPTH_QCOM 0x8BD4 #define GL_TEXTURE_INTERNAL_FORMAT_QCOM 0x8BD5 #define GL_TEXTURE_FORMAT_QCOM 0x8BD6 #define GL_TEXTURE_TYPE_QCOM 0x8BD7 #define GL_TEXTURE_IMAGE_VALID_QCOM 0x8BD8 #define GL_TEXTURE_NUM_LEVELS_QCOM 0x8BD9 #define GL_TEXTURE_TARGET_QCOM 0x8BDA #define GL_TEXTURE_OBJECT_VALID_QCOM 0x8BDB #define GL_STATE_RESTORE 0x8BDC typedef void (GL_APIENTRYP PFNGLEXTGETTEXTURESQCOMPROC) (GLuint *textures, GLint maxTextures, GLint *numTextures); typedef void (GL_APIENTRYP PFNGLEXTGETBUFFERSQCOMPROC) (GLuint *buffers, GLint maxBuffers, GLint *numBuffers); typedef void (GL_APIENTRYP PFNGLEXTGETRENDERBUFFERSQCOMPROC) (GLuint *renderbuffers, GLint maxRenderbuffers, GLint *numRenderbuffers); typedef void (GL_APIENTRYP PFNGLEXTGETFRAMEBUFFERSQCOMPROC) (GLuint *framebuffers, GLint maxFramebuffers, GLint *numFramebuffers); typedef void (GL_APIENTRYP PFNGLEXTGETTEXLEVELPARAMETERIVQCOMPROC) (GLuint texture, GLenum face, GLint level, GLenum pname, GLint *params); typedef void (GL_APIENTRYP PFNGLEXTTEXOBJECTSTATEOVERRIDEIQCOMPROC) (GLenum target, GLenum pname, GLint param); typedef void (GL_APIENTRYP PFNGLEXTGETTEXSUBIMAGEQCOMPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, void *texels); typedef void (GL_APIENTRYP PFNGLEXTGETBUFFERPOINTERVQCOMPROC) (GLenum target, void **params); #ifdef GL_GLEXT_PROTOTYPES GL_APICALL void GL_APIENTRY glExtGetTexturesQCOM (GLuint *textures, GLint maxTextures, GLint *numTextures); GL_APICALL void GL_APIENTRY glExtGetBuffersQCOM (GLuint *buffers, GLint maxBuffers, GLint *numBuffers); GL_APICALL void GL_APIENTRY glExtGetRenderbuffersQCOM (GLuint *renderbuffers, GLint maxRenderbuffers, GLint *numRenderbuffers); GL_APICALL void GL_APIENTRY glExtGetFramebuffersQCOM (GLuint *framebuffers, GLint maxFramebuffers, GLint *numFramebuffers); GL_APICALL void GL_APIENTRY glExtGetTexLevelParameterivQCOM (GLuint texture, GLenum face, GLint level, GLenum pname, GLint *params); GL_APICALL void GL_APIENTRY glExtTexObjectStateOverrideiQCOM (GLenum target, GLenum pname, GLint param); GL_APICALL void GL_APIENTRY glExtGetTexSubImageQCOM (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, void *texels); GL_APICALL void GL_APIENTRY glExtGetBufferPointervQCOM (GLenum target, void **params); #endif #endif /* GL_QCOM_extended_get */ #ifndef GL_QCOM_extended_get2 #define GL_QCOM_extended_get2 1 typedef void (GL_APIENTRYP PFNGLEXTGETSHADERSQCOMPROC) (GLuint *shaders, GLint maxShaders, GLint *numShaders); typedef void (GL_APIENTRYP PFNGLEXTGETPROGRAMSQCOMPROC) (GLuint *programs, GLint maxPrograms, GLint *numPrograms); typedef GLboolean (GL_APIENTRYP PFNGLEXTISPROGRAMBINARYQCOMPROC) (GLuint program); typedef void (GL_APIENTRYP PFNGLEXTGETPROGRAMBINARYSOURCEQCOMPROC) (GLuint program, GLenum shadertype, GLchar *source, GLint *length); #ifdef GL_GLEXT_PROTOTYPES GL_APICALL void GL_APIENTRY glExtGetShadersQCOM (GLuint *shaders, GLint maxShaders, GLint *numShaders); GL_APICALL void GL_APIENTRY glExtGetProgramsQCOM (GLuint *programs, GLint maxPrograms, GLint *numPrograms); GL_APICALL GLboolean GL_APIENTRY glExtIsProgramBinaryQCOM (GLuint program); GL_APICALL void GL_APIENTRY glExtGetProgramBinarySourceQCOM (GLuint program, GLenum shadertype, GLchar *source, GLint *length); #endif #endif /* GL_QCOM_extended_get2 */ #ifndef GL_QCOM_frame_extrapolation #define GL_QCOM_frame_extrapolation 1 typedef void (GL_APIENTRYP PFNGLEXTRAPOLATETEX2DQCOMPROC) (GLuint src1, GLuint src2, GLuint output, GLfloat scaleFactor); #ifdef GL_GLEXT_PROTOTYPES GL_APICALL void GL_APIENTRY glExtrapolateTex2DQCOM (GLuint src1, GLuint src2, GLuint output, GLfloat scaleFactor); #endif #endif /* GL_QCOM_frame_extrapolation */ #ifndef GL_QCOM_framebuffer_foveated #define GL_QCOM_framebuffer_foveated 1 #define GL_FOVEATION_ENABLE_BIT_QCOM 0x00000001 #define GL_FOVEATION_SCALED_BIN_METHOD_BIT_QCOM 0x00000002 typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERFOVEATIONCONFIGQCOMPROC) (GLuint framebuffer, GLuint numLayers, GLuint focalPointsPerLayer, GLuint requestedFeatures, GLuint *providedFeatures); typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERFOVEATIONPARAMETERSQCOMPROC) (GLuint framebuffer, GLuint layer, GLuint focalPoint, GLfloat focalX, GLfloat focalY, GLfloat gainX, GLfloat gainY, GLfloat foveaArea); #ifdef GL_GLEXT_PROTOTYPES GL_APICALL void GL_APIENTRY glFramebufferFoveationConfigQCOM (GLuint framebuffer, GLuint numLayers, GLuint focalPointsPerLayer, GLuint requestedFeatures, GLuint *providedFeatures); GL_APICALL void GL_APIENTRY glFramebufferFoveationParametersQCOM (GLuint framebuffer, GLuint layer, GLuint focalPoint, GLfloat focalX, GLfloat focalY, GLfloat gainX, GLfloat gainY, GLfloat foveaArea); #endif #endif /* GL_QCOM_framebuffer_foveated */ #ifndef GL_QCOM_motion_estimation #define GL_QCOM_motion_estimation 1 #define GL_MOTION_ESTIMATION_SEARCH_BLOCK_X_QCOM 0x8C90 #define GL_MOTION_ESTIMATION_SEARCH_BLOCK_Y_QCOM 0x8C91 typedef void (GL_APIENTRYP PFNGLTEXESTIMATEMOTIONQCOMPROC) (GLuint ref, GLuint target, GLuint output); typedef void (GL_APIENTRYP PFNGLTEXESTIMATEMOTIONREGIONSQCOMPROC) (GLuint ref, GLuint target, GLuint output, GLuint mask); #ifdef GL_GLEXT_PROTOTYPES GL_APICALL void GL_APIENTRY glTexEstimateMotionQCOM (GLuint ref, GLuint target, GLuint output); GL_APICALL void GL_APIENTRY glTexEstimateMotionRegionsQCOM (GLuint ref, GLuint target, GLuint output, GLuint mask); #endif #endif /* GL_QCOM_motion_estimation */ #ifndef GL_QCOM_perfmon_global_mode #define GL_QCOM_perfmon_global_mode 1 #define GL_PERFMON_GLOBAL_MODE_QCOM 0x8FA0 #endif /* GL_QCOM_perfmon_global_mode */ #ifndef GL_QCOM_render_shared_exponent #define GL_QCOM_render_shared_exponent 1 #endif /* GL_QCOM_render_shared_exponent */ #ifndef GL_QCOM_shader_framebuffer_fetch_noncoherent #define GL_QCOM_shader_framebuffer_fetch_noncoherent 1 #define GL_FRAMEBUFFER_FETCH_NONCOHERENT_QCOM 0x96A2 typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERFETCHBARRIERQCOMPROC) (void); #ifdef GL_GLEXT_PROTOTYPES GL_APICALL void GL_APIENTRY glFramebufferFetchBarrierQCOM (void); #endif #endif /* GL_QCOM_shader_framebuffer_fetch_noncoherent */ #ifndef GL_QCOM_shader_framebuffer_fetch_rate #define GL_QCOM_shader_framebuffer_fetch_rate 1 #endif /* GL_QCOM_shader_framebuffer_fetch_rate */ #ifndef GL_QCOM_shading_rate #define GL_QCOM_shading_rate 1 #define GL_SHADING_RATE_QCOM 0x96A4 #define GL_SHADING_RATE_PRESERVE_ASPECT_RATIO_QCOM 0x96A5 #define GL_SHADING_RATE_1X1_PIXELS_QCOM 0x96A6 #define GL_SHADING_RATE_1X2_PIXELS_QCOM 0x96A7 #define GL_SHADING_RATE_2X1_PIXELS_QCOM 0x96A8 #define GL_SHADING_RATE_2X2_PIXELS_QCOM 0x96A9 #define GL_SHADING_RATE_4X2_PIXELS_QCOM 0x96AC #define GL_SHADING_RATE_4X4_PIXELS_QCOM 0x96AE typedef void (GL_APIENTRYP PFNGLSHADINGRATEQCOMPROC) (GLenum rate); #ifdef GL_GLEXT_PROTOTYPES GL_APICALL void GL_APIENTRY glShadingRateQCOM (GLenum rate); #endif #endif /* GL_QCOM_shading_rate */ #ifndef GL_QCOM_texture_foveated #define GL_QCOM_texture_foveated 1 #define GL_TEXTURE_FOVEATED_FEATURE_BITS_QCOM 0x8BFB #define GL_TEXTURE_FOVEATED_MIN_PIXEL_DENSITY_QCOM 0x8BFC #define GL_TEXTURE_FOVEATED_FEATURE_QUERY_QCOM 0x8BFD #define GL_TEXTURE_FOVEATED_NUM_FOCAL_POINTS_QUERY_QCOM 0x8BFE #define GL_FRAMEBUFFER_INCOMPLETE_FOVEATION_QCOM 0x8BFF typedef void (GL_APIENTRYP PFNGLTEXTUREFOVEATIONPARAMETERSQCOMPROC) (GLuint texture, GLuint layer, GLuint focalPoint, GLfloat focalX, GLfloat focalY, GLfloat gainX, GLfloat gainY, GLfloat foveaArea); #ifdef GL_GLEXT_PROTOTYPES GL_APICALL void GL_APIENTRY glTextureFoveationParametersQCOM (GLuint texture, GLuint layer, GLuint focalPoint, GLfloat focalX, GLfloat focalY, GLfloat gainX, GLfloat gainY, GLfloat foveaArea); #endif #endif /* GL_QCOM_texture_foveated */ #ifndef GL_QCOM_texture_foveated2 #define GL_QCOM_texture_foveated2 1 #define GL_TEXTURE_FOVEATED_CUTOFF_DENSITY_QCOM 0x96A0 #endif /* GL_QCOM_texture_foveated2 */ #ifndef GL_QCOM_texture_foveated_subsampled_layout #define GL_QCOM_texture_foveated_subsampled_layout 1 #define GL_FOVEATION_SUBSAMPLED_LAYOUT_METHOD_BIT_QCOM 0x00000004 #define GL_MAX_SHADER_SUBSAMPLED_IMAGE_UNITS_QCOM 0x8FA1 #endif /* GL_QCOM_texture_foveated_subsampled_layout */ #ifndef GL_QCOM_tiled_rendering #define GL_QCOM_tiled_rendering 1 #define GL_COLOR_BUFFER_BIT0_QCOM 0x00000001 #define GL_COLOR_BUFFER_BIT1_QCOM 0x00000002 #define GL_COLOR_BUFFER_BIT2_QCOM 0x00000004 #define GL_COLOR_BUFFER_BIT3_QCOM 0x00000008 #define GL_COLOR_BUFFER_BIT4_QCOM 0x00000010 #define GL_COLOR_BUFFER_BIT5_QCOM 0x00000020 #define GL_COLOR_BUFFER_BIT6_QCOM 0x00000040 #define GL_COLOR_BUFFER_BIT7_QCOM 0x00000080 #define GL_DEPTH_BUFFER_BIT0_QCOM 0x00000100 #define GL_DEPTH_BUFFER_BIT1_QCOM 0x00000200 #define GL_DEPTH_BUFFER_BIT2_QCOM 0x00000400 #define GL_DEPTH_BUFFER_BIT3_QCOM 0x00000800 #define GL_DEPTH_BUFFER_BIT4_QCOM 0x00001000 #define GL_DEPTH_BUFFER_BIT5_QCOM 0x00002000 #define GL_DEPTH_BUFFER_BIT6_QCOM 0x00004000 #define GL_DEPTH_BUFFER_BIT7_QCOM 0x00008000 #define GL_STENCIL_BUFFER_BIT0_QCOM 0x00010000 #define GL_STENCIL_BUFFER_BIT1_QCOM 0x00020000 #define GL_STENCIL_BUFFER_BIT2_QCOM 0x00040000 #define GL_STENCIL_BUFFER_BIT3_QCOM 0x00080000 #define GL_STENCIL_BUFFER_BIT4_QCOM 0x00100000 #define GL_STENCIL_BUFFER_BIT5_QCOM 0x00200000 #define GL_STENCIL_BUFFER_BIT6_QCOM 0x00400000 #define GL_STENCIL_BUFFER_BIT7_QCOM 0x00800000 #define GL_MULTISAMPLE_BUFFER_BIT0_QCOM 0x01000000 #define GL_MULTISAMPLE_BUFFER_BIT1_QCOM 0x02000000 #define GL_MULTISAMPLE_BUFFER_BIT2_QCOM 0x04000000 #define GL_MULTISAMPLE_BUFFER_BIT3_QCOM 0x08000000 #define GL_MULTISAMPLE_BUFFER_BIT4_QCOM 0x10000000 #define GL_MULTISAMPLE_BUFFER_BIT5_QCOM 0x20000000 #define GL_MULTISAMPLE_BUFFER_BIT6_QCOM 0x40000000 #define GL_MULTISAMPLE_BUFFER_BIT7_QCOM 0x80000000 typedef void (GL_APIENTRYP PFNGLSTARTTILINGQCOMPROC) (GLuint x, GLuint y, GLuint width, GLuint height, GLbitfield preserveMask); typedef void (GL_APIENTRYP PFNGLENDTILINGQCOMPROC) (GLbitfield preserveMask); #ifdef GL_GLEXT_PROTOTYPES GL_APICALL void GL_APIENTRY glStartTilingQCOM (GLuint x, GLuint y, GLuint width, GLuint height, GLbitfield preserveMask); GL_APICALL void GL_APIENTRY glEndTilingQCOM (GLbitfield preserveMask); #endif #endif /* GL_QCOM_tiled_rendering */ #ifndef GL_QCOM_writeonly_rendering #define GL_QCOM_writeonly_rendering 1 #define GL_WRITEONLY_RENDERING_QCOM 0x8823 #endif /* GL_QCOM_writeonly_rendering */ #ifndef GL_VIV_shader_binary #define GL_VIV_shader_binary 1 #define GL_SHADER_BINARY_VIV 0x8FC4 #endif /* GL_VIV_shader_binary */ #ifdef __cplusplus } #endif #endif ================================================ FILE: deps/include/SDL3/SDL_opengles2_gl2platform.h ================================================ #ifndef __gl2platform_h_ #define __gl2platform_h_ /* ** Copyright 2017-2020 The Khronos Group Inc. ** SPDX-License-Identifier: Apache-2.0 */ /* Platform-specific types and definitions for OpenGL ES 2.X gl2.h * * Adopters may modify khrplatform.h and this file to suit their platform. * Please contribute modifications back to Khronos as pull requests on the * public github repository: * https://github.com/KhronosGroup/OpenGL-Registry */ /*#include */ #ifndef GL_APICALL #define GL_APICALL KHRONOS_APICALL #endif #ifndef GL_APIENTRY #define GL_APIENTRY KHRONOS_APIENTRY #endif #endif /* __gl2platform_h_ */ ================================================ FILE: deps/include/SDL3/SDL_opengles2_khrplatform.h ================================================ #ifndef __khrplatform_h_ #define __khrplatform_h_ /* ** Copyright (c) 2008-2018 The Khronos Group Inc. ** ** Permission is hereby granted, free of charge, to any person obtaining a ** copy of this software and/or associated documentation files (the ** "Materials"), to deal in the Materials without restriction, including ** without limitation the rights to use, copy, modify, merge, publish, ** distribute, sublicense, and/or sell copies of the Materials, and to ** permit persons to whom the Materials are 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 Materials. ** ** THE MATERIALS ARE 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 ** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. */ /* Khronos platform-specific types and definitions. * * The master copy of khrplatform.h is maintained in the Khronos EGL * Registry repository at https://github.com/KhronosGroup/EGL-Registry * The last semantic modification to khrplatform.h was at commit ID: * 67a3e0864c2d75ea5287b9f3d2eb74a745936692 * * Adopters may modify this file to suit their platform. Adopters are * encouraged to submit platform specific modifications to the Khronos * group so that they can be included in future versions of this file. * Please submit changes by filing pull requests or issues on * the EGL Registry repository linked above. * * * See the Implementer's Guidelines for information about where this file * should be located on your system and for more details of its use: * http://www.khronos.org/registry/implementers_guide.pdf * * This file should be included as * #include * by Khronos client API header files that use its types and defines. * * The types in khrplatform.h should only be used to define API-specific types. * * Types defined in khrplatform.h: * khronos_int8_t signed 8 bit * khronos_uint8_t unsigned 8 bit * khronos_int16_t signed 16 bit * khronos_uint16_t unsigned 16 bit * khronos_int32_t signed 32 bit * khronos_uint32_t unsigned 32 bit * khronos_int64_t signed 64 bit * khronos_uint64_t unsigned 64 bit * khronos_intptr_t signed same number of bits as a pointer * khronos_uintptr_t unsigned same number of bits as a pointer * khronos_ssize_t signed size * khronos_usize_t unsigned size * khronos_float_t signed 32 bit floating point * khronos_time_ns_t unsigned 64 bit time in nanoseconds * khronos_utime_nanoseconds_t unsigned time interval or absolute time in * nanoseconds * khronos_stime_nanoseconds_t signed time interval in nanoseconds * khronos_boolean_enum_t enumerated boolean type. This should * only be used as a base type when a client API's boolean type is * an enum. Client APIs which use an integer or other type for * booleans cannot use this as the base type for their boolean. * * Tokens defined in khrplatform.h: * * KHRONOS_FALSE, KHRONOS_TRUE Enumerated boolean false/true values. * * KHRONOS_SUPPORT_INT64 is 1 if 64 bit integers are supported; otherwise 0. * KHRONOS_SUPPORT_FLOAT is 1 if floats are supported; otherwise 0. * * Calling convention macros defined in this file: * KHRONOS_APICALL * KHRONOS_APIENTRY * KHRONOS_APIATTRIBUTES * * These may be used in function prototypes as: * * KHRONOS_APICALL void KHRONOS_APIENTRY funcname( * int arg1, * int arg2) KHRONOS_APIATTRIBUTES; */ #if defined(__SCITECH_SNAP__) && !defined(KHRONOS_STATIC) # define KHRONOS_STATIC 1 #endif /*------------------------------------------------------------------------- * Definition of KHRONOS_APICALL *------------------------------------------------------------------------- * This precedes the return type of the function in the function prototype. */ #if defined(KHRONOS_STATIC) /* If the preprocessor constant KHRONOS_STATIC is defined, make the * header compatible with static linking. */ # define KHRONOS_APICALL #elif defined(_WIN32) # define KHRONOS_APICALL __declspec(dllimport) #elif defined (__SYMBIAN32__) # define KHRONOS_APICALL IMPORT_C #elif defined(__ANDROID__) # define KHRONOS_APICALL __attribute__((visibility("default"))) #else # define KHRONOS_APICALL #endif /*------------------------------------------------------------------------- * Definition of KHRONOS_APIENTRY *------------------------------------------------------------------------- * This follows the return type of the function and precedes the function * name in the function prototype. */ #if defined(_WIN32) && !defined(_WIN32_WCE) && !defined(__SCITECH_SNAP__) /* Win32 but not WinCE */ # define KHRONOS_APIENTRY __stdcall #else # define KHRONOS_APIENTRY #endif /*------------------------------------------------------------------------- * Definition of KHRONOS_APIATTRIBUTES *------------------------------------------------------------------------- * This follows the closing parenthesis of the function prototype arguments. */ #if defined (__ARMCC_2__) #define KHRONOS_APIATTRIBUTES __softfp #else #define KHRONOS_APIATTRIBUTES #endif /*------------------------------------------------------------------------- * basic type definitions *-----------------------------------------------------------------------*/ #if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || defined(__GNUC__) || defined(__SCO__) || defined(__USLC__) /* * Using */ #include typedef int32_t khronos_int32_t; typedef uint32_t khronos_uint32_t; typedef int64_t khronos_int64_t; typedef uint64_t khronos_uint64_t; #define KHRONOS_SUPPORT_INT64 1 #define KHRONOS_SUPPORT_FLOAT 1 /* * To support platform where unsigned long cannot be used interchangeably with * inptr_t (e.g. CHERI-extended ISAs), we can use the stdint.h intptr_t. * Ideally, we could just use (u)intptr_t everywhere, but this could result in * ABI breakage if khronos_uintptr_t is changed from unsigned long to * unsigned long long or similar (this results in different C++ name mangling). * To avoid changes for existing platforms, we restrict usage of intptr_t to * platforms where the size of a pointer is larger than the size of long. */ #if defined(__SIZEOF_LONG__) && defined(__SIZEOF_POINTER__) #if __SIZEOF_POINTER__ > __SIZEOF_LONG__ #define KHRONOS_USE_INTPTR_T #endif #endif #elif defined(__VMS ) || defined(__sgi) /* * Using */ #include typedef int32_t khronos_int32_t; typedef uint32_t khronos_uint32_t; typedef int64_t khronos_int64_t; typedef uint64_t khronos_uint64_t; #define KHRONOS_SUPPORT_INT64 1 #define KHRONOS_SUPPORT_FLOAT 1 #elif defined(_WIN32) && !defined(__SCITECH_SNAP__) /* * Win32 */ typedef __int32 khronos_int32_t; typedef unsigned __int32 khronos_uint32_t; typedef __int64 khronos_int64_t; typedef unsigned __int64 khronos_uint64_t; #define KHRONOS_SUPPORT_INT64 1 #define KHRONOS_SUPPORT_FLOAT 1 #elif defined(__sun__) || defined(__digital__) /* * Sun or Digital */ typedef int khronos_int32_t; typedef unsigned int khronos_uint32_t; #if defined(__arch64__) || defined(_LP64) typedef long int khronos_int64_t; typedef unsigned long int khronos_uint64_t; #else typedef long long int khronos_int64_t; typedef unsigned long long int khronos_uint64_t; #endif /* __arch64__ */ #define KHRONOS_SUPPORT_INT64 1 #define KHRONOS_SUPPORT_FLOAT 1 #elif 0 /* * Hypothetical platform with no float or int64 support */ typedef int khronos_int32_t; typedef unsigned int khronos_uint32_t; #define KHRONOS_SUPPORT_INT64 0 #define KHRONOS_SUPPORT_FLOAT 0 #else /* * Generic fallback */ #include typedef int32_t khronos_int32_t; typedef uint32_t khronos_uint32_t; typedef int64_t khronos_int64_t; typedef uint64_t khronos_uint64_t; #define KHRONOS_SUPPORT_INT64 1 #define KHRONOS_SUPPORT_FLOAT 1 #endif /* * Types that are (so far) the same on all platforms */ typedef signed char khronos_int8_t; typedef unsigned char khronos_uint8_t; typedef signed short int khronos_int16_t; typedef unsigned short int khronos_uint16_t; /* * Types that differ between LLP64 and LP64 architectures - in LLP64, * pointers are 64 bits, but 'long' is still 32 bits. Win64 appears * to be the only LLP64 architecture in current use. */ #ifdef KHRONOS_USE_INTPTR_T typedef intptr_t khronos_intptr_t; typedef uintptr_t khronos_uintptr_t; #elif defined(_WIN64) typedef signed long long int khronos_intptr_t; typedef unsigned long long int khronos_uintptr_t; #else typedef signed long int khronos_intptr_t; typedef unsigned long int khronos_uintptr_t; #endif #if defined(_WIN64) typedef signed long long int khronos_ssize_t; typedef unsigned long long int khronos_usize_t; #else typedef signed long int khronos_ssize_t; typedef unsigned long int khronos_usize_t; #endif #if KHRONOS_SUPPORT_FLOAT /* * Float type */ typedef float khronos_float_t; #endif #if KHRONOS_SUPPORT_INT64 /* Time types * * These types can be used to represent a time interval in nanoseconds or * an absolute Unadjusted System Time. Unadjusted System Time is the number * of nanoseconds since some arbitrary system event (e.g. since the last * time the system booted). The Unadjusted System Time is an unsigned * 64 bit value that wraps back to 0 every 584 years. Time intervals * may be either signed or unsigned. */ typedef khronos_uint64_t khronos_utime_nanoseconds_t; typedef khronos_int64_t khronos_stime_nanoseconds_t; #endif /* * Dummy value used to pad enum types to 32 bits. */ #ifndef KHRONOS_MAX_ENUM #define KHRONOS_MAX_ENUM 0x7FFFFFFF #endif /* * Enumerated boolean type * * Values other than zero should be considered to be true. Therefore * comparisons should not be made against KHRONOS_TRUE. */ typedef enum { KHRONOS_FALSE = 0, KHRONOS_TRUE = 1, KHRONOS_BOOLEAN_ENUM_FORCE_SIZE = KHRONOS_MAX_ENUM } khronos_boolean_enum_t; #endif /* __khrplatform_h_ */ ================================================ FILE: deps/include/SDL3/SDL_pen.h ================================================ /* Simple DirectMedia Layer Copyright (C) 1997-2026 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ /** * # CategoryPen * * SDL pen event handling. * * SDL provides an API for pressure-sensitive pen (stylus and/or eraser) * handling, e.g., for input and drawing tablets or suitably equipped mobile / * tablet devices. * * To get started with pens, simply handle pen events: * * - SDL_EVENT_PEN_PROXIMITY_IN, SDL_EVENT_PEN_PROXIMITY_OUT * (SDL_PenProximityEvent) * - SDL_EVENT_PEN_DOWN, SDL_EVENT_PEN_UP (SDL_PenTouchEvent) * - SDL_EVENT_PEN_MOTION (SDL_PenMotionEvent) * - SDL_EVENT_PEN_BUTTON_DOWN, SDL_EVENT_PEN_BUTTON_UP (SDL_PenButtonEvent) * - SDL_EVENT_PEN_AXIS (SDL_PenAxisEvent) * * Pens may provide more than simple touch input; they might have other axes, * such as pressure, tilt, rotation, etc. * * When a pen starts providing input, SDL will assign it a unique SDL_PenID, * which will remain for the life of the process, as long as the pen stays * connected. A pen leaving proximity (being taken far enough away from the * digitizer tablet that it no longer reponds) and then coming back should * fire proximity events, but the SDL_PenID should remain consistent. * Unplugging the digitizer and reconnecting may cause future input to have a * new SDL_PenID, as SDL may not know that this is the same hardware. * * Please note that various platforms vary wildly in how (and how well) they * support pen input. If your pen supports some piece of functionality but SDL * doesn't seem to, it might actually be the operating system's fault. For * example, some platforms can manage multiple devices at the same time, but * others will make any connected pens look like a single logical device, much * how all USB mice connected to a computer will move the same system cursor. * Other platforms might not support pen buttons, or the distance axis, etc. * Very few platforms can even report _what_ functionality the pen supports in * the first place, so best practices is to either build UI to let the user * configure their pens, or be prepared to handle new functionality for a pen * the first time an event is reported. */ #ifndef SDL_pen_h_ #define SDL_pen_h_ #include #include #include #include /* Set up for C function definitions, even when using C++ */ #ifdef __cplusplus extern "C" { #endif /** * SDL pen instance IDs. * * Zero is used to signify an invalid/null device. * * These show up in pen events when SDL sees input from them. They remain * consistent as long as SDL can recognize a tool to be the same pen; but if a * pen's digitizer table is physically detached from the computer, it might * get a new ID when reconnected, as SDL won't know it's the same device. * * These IDs are only stable within a single run of a program; the next time a * program is run, the pen's ID will likely be different, even if the hardware * hasn't been disconnected, etc. * * \since This datatype is available since SDL 3.2.0. */ typedef Uint32 SDL_PenID; /** * The SDL_MouseID for mouse events simulated with pen input. * * \since This macro is available since SDL 3.2.0. */ #define SDL_PEN_MOUSEID ((SDL_MouseID)-2) /** * The SDL_TouchID for touch events simulated with pen input. * * \since This macro is available since SDL 3.2.0. */ #define SDL_PEN_TOUCHID ((SDL_TouchID)-2) /** * Pen input flags, as reported by various pen events' `pen_state` field. * * \since This datatype is available since SDL 3.2.0. */ typedef Uint32 SDL_PenInputFlags; #define SDL_PEN_INPUT_DOWN (1u << 0) /**< pen is pressed down */ #define SDL_PEN_INPUT_BUTTON_1 (1u << 1) /**< button 1 is pressed */ #define SDL_PEN_INPUT_BUTTON_2 (1u << 2) /**< button 2 is pressed */ #define SDL_PEN_INPUT_BUTTON_3 (1u << 3) /**< button 3 is pressed */ #define SDL_PEN_INPUT_BUTTON_4 (1u << 4) /**< button 4 is pressed */ #define SDL_PEN_INPUT_BUTTON_5 (1u << 5) /**< button 5 is pressed */ #define SDL_PEN_INPUT_ERASER_TIP (1u << 30) /**< eraser tip is used */ #define SDL_PEN_INPUT_IN_PROXIMITY (1u << 31) /**< pen is in proximity (since SDL 3.4.0) */ /** * Pen axis indices. * * These are the valid values for the `axis` field in SDL_PenAxisEvent. All * axes are either normalised to 0..1 or report a (positive or negative) angle * in degrees, with 0.0 representing the centre. Not all pens/backends support * all axes: unsupported axes are always zero. * * To convert angles for tilt and rotation into vector representation, use * SDL_sinf on the XTILT, YTILT, or ROTATION component, for example: * * `SDL_sinf(xtilt * SDL_PI_F / 180.0)`. * * \since This enum is available since SDL 3.2.0. */ typedef enum SDL_PenAxis { SDL_PEN_AXIS_PRESSURE, /**< Pen pressure. Unidirectional: 0 to 1.0 */ SDL_PEN_AXIS_XTILT, /**< Pen horizontal tilt angle. Bidirectional: -90.0 to 90.0 (left-to-right). */ SDL_PEN_AXIS_YTILT, /**< Pen vertical tilt angle. Bidirectional: -90.0 to 90.0 (top-to-down). */ SDL_PEN_AXIS_DISTANCE, /**< Pen distance to drawing surface. Unidirectional: 0.0 to 1.0 */ SDL_PEN_AXIS_ROTATION, /**< Pen barrel rotation. Bidirectional: -180 to 179.9 (clockwise, 0 is facing up, -180.0 is facing down). */ SDL_PEN_AXIS_SLIDER, /**< Pen finger wheel or slider (e.g., Airbrush Pen). Unidirectional: 0 to 1.0 */ SDL_PEN_AXIS_TANGENTIAL_PRESSURE, /**< Pressure from squeezing the pen ("barrel pressure"). */ SDL_PEN_AXIS_COUNT /**< Total known pen axis types in this version of SDL. This number may grow in future releases! */ } SDL_PenAxis; /** * An enum that describes the type of a pen device. * * A "direct" device is a pen that touches a graphic display (like an Apple * Pencil on an iPad's screen). "Indirect" devices touch an external tablet * surface that is connected to the machine but is not a display (like a * lower-end Wacom tablet connected over USB). * * Apps may use this information to decide if they should draw a cursor; if * the pen is touching the screen directly, a cursor doesn't make sense and * can be in the way, but becomes necessary for indirect devices to know where * on the display they are interacting. * * \since This enum is available since SDL 3.4.0. */ typedef enum SDL_PenDeviceType { SDL_PEN_DEVICE_TYPE_INVALID = -1, /**< Not a valid pen device. */ SDL_PEN_DEVICE_TYPE_UNKNOWN, /**< Don't know specifics of this pen. */ SDL_PEN_DEVICE_TYPE_DIRECT, /**< Pen touches display. */ SDL_PEN_DEVICE_TYPE_INDIRECT /**< Pen touches something that isn't the display. */ } SDL_PenDeviceType; /** * Get the device type of the given pen. * * Many platforms do not supply this information, so an app must always be * prepared to get an SDL_PEN_DEVICE_TYPE_UNKNOWN result. * * \param instance_id the pen instance ID. * \returns the device type of the given pen, or SDL_PEN_DEVICE_TYPE_INVALID * on failure; call SDL_GetError() for more information. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.4.0. */ extern SDL_DECLSPEC SDL_PenDeviceType SDLCALL SDL_GetPenDeviceType(SDL_PenID instance_id); /* Ends C function definitions when using C++ */ #ifdef __cplusplus } #endif #include #endif /* SDL_pen_h_ */ ================================================ FILE: deps/include/SDL3/SDL_pixels.h ================================================ /* Simple DirectMedia Layer Copyright (C) 1997-2026 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ /** * # CategoryPixels * * SDL offers facilities for pixel management. * * Largely these facilities deal with pixel _format_: what does this set of * bits represent? * * If you mostly want to think of a pixel as some combination of red, green, * blue, and maybe alpha intensities, this is all pretty straightforward, and * in many cases, is enough information to build a perfectly fine game. * * However, the actual definition of a pixel is more complex than that: * * Pixels are a representation of a color in a particular color space. * * The first characteristic of a color space is the color type. SDL * understands two different color types, RGB and YCbCr, or in SDL also * referred to as YUV. * * RGB colors consist of red, green, and blue channels of color that are added * together to represent the colors we see on the screen. * * https://en.wikipedia.org/wiki/RGB_color_model * * YCbCr colors represent colors as a Y luma brightness component and red and * blue chroma color offsets. This color representation takes advantage of the * fact that the human eye is more sensitive to brightness than the color in * an image. The Cb and Cr components are often compressed and have lower * resolution than the luma component. * * https://en.wikipedia.org/wiki/YCbCr * * When the color information in YCbCr is compressed, the Y pixels are left at * full resolution and each Cr and Cb pixel represents an average of the color * information in a block of Y pixels. The chroma location determines where in * that block of pixels the color information is coming from. * * The color range defines how much of the pixel to use when converting a * pixel into a color on the display. When the full color range is used, the * entire numeric range of the pixel bits is significant. When narrow color * range is used, for historical reasons, the pixel uses only a portion of the * numeric range to represent colors. * * The color primaries and white point are a definition of the colors in the * color space relative to the standard XYZ color space. * * https://en.wikipedia.org/wiki/CIE_1931_color_space * * The transfer characteristic, or opto-electrical transfer function (OETF), * is the way a color is converted from mathematically linear space into a * non-linear output signals. * * https://en.wikipedia.org/wiki/Rec._709#Transfer_characteristics * * The matrix coefficients are used to convert between YCbCr and RGB colors. */ #ifndef SDL_pixels_h_ #define SDL_pixels_h_ #include #include #include #include /* Set up for C function definitions, even when using C++ */ #ifdef __cplusplus extern "C" { #endif /** * A fully opaque 8-bit alpha value. * * \since This macro is available since SDL 3.2.0. * * \sa SDL_ALPHA_TRANSPARENT */ #define SDL_ALPHA_OPAQUE 255 /** * A fully opaque floating point alpha value. * * \since This macro is available since SDL 3.2.0. * * \sa SDL_ALPHA_TRANSPARENT_FLOAT */ #define SDL_ALPHA_OPAQUE_FLOAT 1.0f /** * A fully transparent 8-bit alpha value. * * \since This macro is available since SDL 3.2.0. * * \sa SDL_ALPHA_OPAQUE */ #define SDL_ALPHA_TRANSPARENT 0 /** * A fully transparent floating point alpha value. * * \since This macro is available since SDL 3.2.0. * * \sa SDL_ALPHA_OPAQUE_FLOAT */ #define SDL_ALPHA_TRANSPARENT_FLOAT 0.0f /** * Pixel type. * * \since This enum is available since SDL 3.2.0. */ typedef enum SDL_PixelType { SDL_PIXELTYPE_UNKNOWN, SDL_PIXELTYPE_INDEX1, SDL_PIXELTYPE_INDEX4, SDL_PIXELTYPE_INDEX8, SDL_PIXELTYPE_PACKED8, SDL_PIXELTYPE_PACKED16, SDL_PIXELTYPE_PACKED32, SDL_PIXELTYPE_ARRAYU8, SDL_PIXELTYPE_ARRAYU16, SDL_PIXELTYPE_ARRAYU32, SDL_PIXELTYPE_ARRAYF16, SDL_PIXELTYPE_ARRAYF32, /* appended at the end for compatibility with sdl2-compat: */ SDL_PIXELTYPE_INDEX2 } SDL_PixelType; /** * Bitmap pixel order, high bit -> low bit. * * \since This enum is available since SDL 3.2.0. */ typedef enum SDL_BitmapOrder { SDL_BITMAPORDER_NONE, SDL_BITMAPORDER_4321, SDL_BITMAPORDER_1234 } SDL_BitmapOrder; /** * Packed component order, high bit -> low bit. * * \since This enum is available since SDL 3.2.0. */ typedef enum SDL_PackedOrder { SDL_PACKEDORDER_NONE, SDL_PACKEDORDER_XRGB, SDL_PACKEDORDER_RGBX, SDL_PACKEDORDER_ARGB, SDL_PACKEDORDER_RGBA, SDL_PACKEDORDER_XBGR, SDL_PACKEDORDER_BGRX, SDL_PACKEDORDER_ABGR, SDL_PACKEDORDER_BGRA } SDL_PackedOrder; /** * Array component order, low byte -> high byte. * * \since This enum is available since SDL 3.2.0. */ typedef enum SDL_ArrayOrder { SDL_ARRAYORDER_NONE, SDL_ARRAYORDER_RGB, SDL_ARRAYORDER_RGBA, SDL_ARRAYORDER_ARGB, SDL_ARRAYORDER_BGR, SDL_ARRAYORDER_BGRA, SDL_ARRAYORDER_ABGR } SDL_ArrayOrder; /** * Packed component layout. * * \since This enum is available since SDL 3.2.0. */ typedef enum SDL_PackedLayout { SDL_PACKEDLAYOUT_NONE, SDL_PACKEDLAYOUT_332, SDL_PACKEDLAYOUT_4444, SDL_PACKEDLAYOUT_1555, SDL_PACKEDLAYOUT_5551, SDL_PACKEDLAYOUT_565, SDL_PACKEDLAYOUT_8888, SDL_PACKEDLAYOUT_2101010, SDL_PACKEDLAYOUT_1010102 } SDL_PackedLayout; /** * A macro for defining custom FourCC pixel formats. * * For example, defining SDL_PIXELFORMAT_YV12 looks like this: * * ```c * SDL_DEFINE_PIXELFOURCC('Y', 'V', '1', '2') * ``` * * \param A the first character of the FourCC code. * \param B the second character of the FourCC code. * \param C the third character of the FourCC code. * \param D the fourth character of the FourCC code. * \returns a format value in the style of SDL_PixelFormat. * * \threadsafety It is safe to call this macro from any thread. * * \since This macro is available since SDL 3.2.0. */ #define SDL_DEFINE_PIXELFOURCC(A, B, C, D) SDL_FOURCC(A, B, C, D) /** * A macro for defining custom non-FourCC pixel formats. * * For example, defining SDL_PIXELFORMAT_RGBA8888 looks like this: * * ```c * SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_RGBA, SDL_PACKEDLAYOUT_8888, 32, 4) * ``` * * \param type the type of the new format, probably a SDL_PixelType value. * \param order the order of the new format, probably a SDL_BitmapOrder, * SDL_PackedOrder, or SDL_ArrayOrder value. * \param layout the layout of the new format, probably an SDL_PackedLayout * value or zero. * \param bits the number of bits per pixel of the new format. * \param bytes the number of bytes per pixel of the new format. * \returns a format value in the style of SDL_PixelFormat. * * \threadsafety It is safe to call this macro from any thread. * * \since This macro is available since SDL 3.2.0. */ #define SDL_DEFINE_PIXELFORMAT(type, order, layout, bits, bytes) \ ((1 << 28) | ((type) << 24) | ((order) << 20) | ((layout) << 16) | \ ((bits) << 8) | ((bytes) << 0)) /** * A macro to retrieve the flags of an SDL_PixelFormat. * * This macro is generally not needed directly by an app, which should use * specific tests, like SDL_ISPIXELFORMAT_FOURCC, instead. * * \param format an SDL_PixelFormat to check. * \returns the flags of `format`. * * \threadsafety It is safe to call this macro from any thread. * * \since This macro is available since SDL 3.2.0. */ #define SDL_PIXELFLAG(format) (((format) >> 28) & 0x0F) /** * A macro to retrieve the type of an SDL_PixelFormat. * * This is usually a value from the SDL_PixelType enumeration. * * \param format an SDL_PixelFormat to check. * \returns the type of `format`. * * \threadsafety It is safe to call this macro from any thread. * * \since This macro is available since SDL 3.2.0. */ #define SDL_PIXELTYPE(format) (((format) >> 24) & 0x0F) /** * A macro to retrieve the order of an SDL_PixelFormat. * * This is usually a value from the SDL_BitmapOrder, SDL_PackedOrder, or * SDL_ArrayOrder enumerations, depending on the format type. * * \param format an SDL_PixelFormat to check. * \returns the order of `format`. * * \threadsafety It is safe to call this macro from any thread. * * \since This macro is available since SDL 3.2.0. */ #define SDL_PIXELORDER(format) (((format) >> 20) & 0x0F) /** * A macro to retrieve the layout of an SDL_PixelFormat. * * This is usually a value from the SDL_PackedLayout enumeration, or zero if a * layout doesn't make sense for the format type. * * \param format an SDL_PixelFormat to check. * \returns the layout of `format`. * * \threadsafety It is safe to call this macro from any thread. * * \since This macro is available since SDL 3.2.0. */ #define SDL_PIXELLAYOUT(format) (((format) >> 16) & 0x0F) /** * A macro to determine an SDL_PixelFormat's bits per pixel. * * Note that this macro double-evaluates its parameter, so do not use * expressions with side-effects here. * * FourCC formats will report zero here, as it rarely makes sense to measure * them per-pixel. * * \param format an SDL_PixelFormat to check. * \returns the bits-per-pixel of `format`. * * \threadsafety It is safe to call this macro from any thread. * * \since This macro is available since SDL 3.2.0. * * \sa SDL_BYTESPERPIXEL */ #define SDL_BITSPERPIXEL(format) \ (SDL_ISPIXELFORMAT_FOURCC(format) ? 0 : (((format) >> 8) & 0xFF)) /** * A macro to determine an SDL_PixelFormat's bytes per pixel. * * Note that this macro double-evaluates its parameter, so do not use * expressions with side-effects here. * * FourCC formats do their best here, but many of them don't have a meaningful * measurement of bytes per pixel. * * \param format an SDL_PixelFormat to check. * \returns the bytes-per-pixel of `format`. * * \threadsafety It is safe to call this macro from any thread. * * \since This macro is available since SDL 3.2.0. * * \sa SDL_BITSPERPIXEL */ #define SDL_BYTESPERPIXEL(format) \ (SDL_ISPIXELFORMAT_FOURCC(format) ? \ ((((format) == SDL_PIXELFORMAT_YUY2) || \ ((format) == SDL_PIXELFORMAT_UYVY) || \ ((format) == SDL_PIXELFORMAT_YVYU) || \ ((format) == SDL_PIXELFORMAT_P010)) ? 2 : 1) : (((format) >> 0) & 0xFF)) /** * A macro to determine if an SDL_PixelFormat is an indexed format. * * Note that this macro double-evaluates its parameter, so do not use * expressions with side-effects here. * * \param format an SDL_PixelFormat to check. * \returns true if the format is indexed, false otherwise. * * \threadsafety It is safe to call this macro from any thread. * * \since This macro is available since SDL 3.2.0. */ #define SDL_ISPIXELFORMAT_INDEXED(format) \ (!SDL_ISPIXELFORMAT_FOURCC(format) && \ ((SDL_PIXELTYPE(format) == SDL_PIXELTYPE_INDEX1) || \ (SDL_PIXELTYPE(format) == SDL_PIXELTYPE_INDEX2) || \ (SDL_PIXELTYPE(format) == SDL_PIXELTYPE_INDEX4) || \ (SDL_PIXELTYPE(format) == SDL_PIXELTYPE_INDEX8))) /** * A macro to determine if an SDL_PixelFormat is a packed format. * * Note that this macro double-evaluates its parameter, so do not use * expressions with side-effects here. * * \param format an SDL_PixelFormat to check. * \returns true if the format is packed, false otherwise. * * \threadsafety It is safe to call this macro from any thread. * * \since This macro is available since SDL 3.2.0. */ #define SDL_ISPIXELFORMAT_PACKED(format) \ (!SDL_ISPIXELFORMAT_FOURCC(format) && \ ((SDL_PIXELTYPE(format) == SDL_PIXELTYPE_PACKED8) || \ (SDL_PIXELTYPE(format) == SDL_PIXELTYPE_PACKED16) || \ (SDL_PIXELTYPE(format) == SDL_PIXELTYPE_PACKED32))) /** * A macro to determine if an SDL_PixelFormat is an array format. * * Note that this macro double-evaluates its parameter, so do not use * expressions with side-effects here. * * \param format an SDL_PixelFormat to check. * \returns true if the format is an array, false otherwise. * * \threadsafety It is safe to call this macro from any thread. * * \since This macro is available since SDL 3.2.0. */ #define SDL_ISPIXELFORMAT_ARRAY(format) \ (!SDL_ISPIXELFORMAT_FOURCC(format) && \ ((SDL_PIXELTYPE(format) == SDL_PIXELTYPE_ARRAYU8) || \ (SDL_PIXELTYPE(format) == SDL_PIXELTYPE_ARRAYU16) || \ (SDL_PIXELTYPE(format) == SDL_PIXELTYPE_ARRAYU32) || \ (SDL_PIXELTYPE(format) == SDL_PIXELTYPE_ARRAYF16) || \ (SDL_PIXELTYPE(format) == SDL_PIXELTYPE_ARRAYF32))) /** * A macro to determine if an SDL_PixelFormat is a 10-bit format. * * Note that this macro double-evaluates its parameter, so do not use * expressions with side-effects here. * * \param format an SDL_PixelFormat to check. * \returns true if the format is 10-bit, false otherwise. * * \threadsafety It is safe to call this macro from any thread. * * \since This macro is available since SDL 3.2.0. */ #define SDL_ISPIXELFORMAT_10BIT(format) \ (!SDL_ISPIXELFORMAT_FOURCC(format) && \ ((SDL_PIXELTYPE(format) == SDL_PIXELTYPE_PACKED32) && \ (SDL_PIXELLAYOUT(format) == SDL_PACKEDLAYOUT_2101010))) /** * A macro to determine if an SDL_PixelFormat is a floating point format. * * Note that this macro double-evaluates its parameter, so do not use * expressions with side-effects here. * * \param format an SDL_PixelFormat to check. * \returns true if the format is a floating point, false otherwise. * * \threadsafety It is safe to call this macro from any thread. * * \since This macro is available since SDL 3.2.0. */ #define SDL_ISPIXELFORMAT_FLOAT(format) \ (!SDL_ISPIXELFORMAT_FOURCC(format) && \ ((SDL_PIXELTYPE(format) == SDL_PIXELTYPE_ARRAYF16) || \ (SDL_PIXELTYPE(format) == SDL_PIXELTYPE_ARRAYF32))) /** * A macro to determine if an SDL_PixelFormat has an alpha channel. * * Note that this macro double-evaluates its parameter, so do not use * expressions with side-effects here. * * \param format an SDL_PixelFormat to check. * \returns true if the format has alpha, false otherwise. * * \threadsafety It is safe to call this macro from any thread. * * \since This macro is available since SDL 3.2.0. */ #define SDL_ISPIXELFORMAT_ALPHA(format) \ ((SDL_ISPIXELFORMAT_PACKED(format) && \ ((SDL_PIXELORDER(format) == SDL_PACKEDORDER_ARGB) || \ (SDL_PIXELORDER(format) == SDL_PACKEDORDER_RGBA) || \ (SDL_PIXELORDER(format) == SDL_PACKEDORDER_ABGR) || \ (SDL_PIXELORDER(format) == SDL_PACKEDORDER_BGRA))) || \ (SDL_ISPIXELFORMAT_ARRAY(format) && \ ((SDL_PIXELORDER(format) == SDL_ARRAYORDER_ARGB) || \ (SDL_PIXELORDER(format) == SDL_ARRAYORDER_RGBA) || \ (SDL_PIXELORDER(format) == SDL_ARRAYORDER_ABGR) || \ (SDL_PIXELORDER(format) == SDL_ARRAYORDER_BGRA)))) /** * A macro to determine if an SDL_PixelFormat is a "FourCC" format. * * This covers custom and other unusual formats. * * Note that this macro double-evaluates its parameter, so do not use * expressions with side-effects here. * * \param format an SDL_PixelFormat to check. * \returns true if the format has alpha, false otherwise. * * \threadsafety It is safe to call this macro from any thread. * * \since This macro is available since SDL 3.2.0. */ #define SDL_ISPIXELFORMAT_FOURCC(format) /* The flag is set to 1 because 0x1? is not in the printable ASCII range */ \ ((format) && (SDL_PIXELFLAG(format) != 1)) /* Note: If you modify this enum, update SDL_GetPixelFormatName() */ /** * Pixel format. * * SDL's pixel formats have the following naming convention: * * - Names with a list of components and a single bit count, such as RGB24 and * ABGR32, define a platform-independent encoding into bytes in the order * specified. For example, in RGB24 data, each pixel is encoded in 3 bytes * (red, green, blue) in that order, and in ABGR32 data, each pixel is * encoded in 4 bytes (alpha, blue, green, red) in that order. Use these * names if the property of a format that is important to you is the order * of the bytes in memory or on disk. * - Names with a bit count per component, such as ARGB8888 and XRGB1555, are * "packed" into an appropriately-sized integer in the platform's native * endianness. For example, ARGB8888 is a sequence of 32-bit integers; in * each integer, the most significant bits are alpha, and the least * significant bits are blue. On a little-endian CPU such as x86, the least * significant bits of each integer are arranged first in memory, but on a * big-endian CPU such as s390x, the most significant bits are arranged * first. Use these names if the property of a format that is important to * you is the meaning of each bit position within a native-endianness * integer. * - In indexed formats such as INDEX4LSB, each pixel is represented by * encoding an index into the palette into the indicated number of bits, * with multiple pixels packed into each byte if appropriate. In LSB * formats, the first (leftmost) pixel is stored in the least-significant * bits of the byte; in MSB formats, it's stored in the most-significant * bits. INDEX8 does not need LSB/MSB variants, because each pixel exactly * fills one byte. * * The 32-bit byte-array encodings such as RGBA32 are aliases for the * appropriate 8888 encoding for the current platform. For example, RGBA32 is * an alias for ABGR8888 on little-endian CPUs like x86, or an alias for * RGBA8888 on big-endian CPUs. * * \since This enum is available since SDL 3.2.0. */ typedef enum SDL_PixelFormat { SDL_PIXELFORMAT_UNKNOWN = 0, SDL_PIXELFORMAT_INDEX1LSB = 0x11100100u, /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_INDEX1, SDL_BITMAPORDER_4321, 0, 1, 0), */ SDL_PIXELFORMAT_INDEX1MSB = 0x11200100u, /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_INDEX1, SDL_BITMAPORDER_1234, 0, 1, 0), */ SDL_PIXELFORMAT_INDEX2LSB = 0x1c100200u, /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_INDEX2, SDL_BITMAPORDER_4321, 0, 2, 0), */ SDL_PIXELFORMAT_INDEX2MSB = 0x1c200200u, /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_INDEX2, SDL_BITMAPORDER_1234, 0, 2, 0), */ SDL_PIXELFORMAT_INDEX4LSB = 0x12100400u, /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_INDEX4, SDL_BITMAPORDER_4321, 0, 4, 0), */ SDL_PIXELFORMAT_INDEX4MSB = 0x12200400u, /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_INDEX4, SDL_BITMAPORDER_1234, 0, 4, 0), */ SDL_PIXELFORMAT_INDEX8 = 0x13000801u, /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_INDEX8, 0, 0, 8, 1), */ SDL_PIXELFORMAT_RGB332 = 0x14110801u, /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED8, SDL_PACKEDORDER_XRGB, SDL_PACKEDLAYOUT_332, 8, 1), */ SDL_PIXELFORMAT_XRGB4444 = 0x15120c02u, /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_XRGB, SDL_PACKEDLAYOUT_4444, 12, 2), */ SDL_PIXELFORMAT_XBGR4444 = 0x15520c02u, /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_XBGR, SDL_PACKEDLAYOUT_4444, 12, 2), */ SDL_PIXELFORMAT_XRGB1555 = 0x15130f02u, /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_XRGB, SDL_PACKEDLAYOUT_1555, 15, 2), */ SDL_PIXELFORMAT_XBGR1555 = 0x15530f02u, /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_XBGR, SDL_PACKEDLAYOUT_1555, 15, 2), */ SDL_PIXELFORMAT_ARGB4444 = 0x15321002u, /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_ARGB, SDL_PACKEDLAYOUT_4444, 16, 2), */ SDL_PIXELFORMAT_RGBA4444 = 0x15421002u, /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_RGBA, SDL_PACKEDLAYOUT_4444, 16, 2), */ SDL_PIXELFORMAT_ABGR4444 = 0x15721002u, /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_ABGR, SDL_PACKEDLAYOUT_4444, 16, 2), */ SDL_PIXELFORMAT_BGRA4444 = 0x15821002u, /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_BGRA, SDL_PACKEDLAYOUT_4444, 16, 2), */ SDL_PIXELFORMAT_ARGB1555 = 0x15331002u, /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_ARGB, SDL_PACKEDLAYOUT_1555, 16, 2), */ SDL_PIXELFORMAT_RGBA5551 = 0x15441002u, /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_RGBA, SDL_PACKEDLAYOUT_5551, 16, 2), */ SDL_PIXELFORMAT_ABGR1555 = 0x15731002u, /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_ABGR, SDL_PACKEDLAYOUT_1555, 16, 2), */ SDL_PIXELFORMAT_BGRA5551 = 0x15841002u, /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_BGRA, SDL_PACKEDLAYOUT_5551, 16, 2), */ SDL_PIXELFORMAT_RGB565 = 0x15151002u, /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_XRGB, SDL_PACKEDLAYOUT_565, 16, 2), */ SDL_PIXELFORMAT_BGR565 = 0x15551002u, /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_XBGR, SDL_PACKEDLAYOUT_565, 16, 2), */ SDL_PIXELFORMAT_RGB24 = 0x17101803u, /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_ARRAYU8, SDL_ARRAYORDER_RGB, 0, 24, 3), */ SDL_PIXELFORMAT_BGR24 = 0x17401803u, /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_ARRAYU8, SDL_ARRAYORDER_BGR, 0, 24, 3), */ SDL_PIXELFORMAT_XRGB8888 = 0x16161804u, /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_XRGB, SDL_PACKEDLAYOUT_8888, 24, 4), */ SDL_PIXELFORMAT_RGBX8888 = 0x16261804u, /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_RGBX, SDL_PACKEDLAYOUT_8888, 24, 4), */ SDL_PIXELFORMAT_XBGR8888 = 0x16561804u, /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_XBGR, SDL_PACKEDLAYOUT_8888, 24, 4), */ SDL_PIXELFORMAT_BGRX8888 = 0x16661804u, /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_BGRX, SDL_PACKEDLAYOUT_8888, 24, 4), */ SDL_PIXELFORMAT_ARGB8888 = 0x16362004u, /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_ARGB, SDL_PACKEDLAYOUT_8888, 32, 4), */ SDL_PIXELFORMAT_RGBA8888 = 0x16462004u, /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_RGBA, SDL_PACKEDLAYOUT_8888, 32, 4), */ SDL_PIXELFORMAT_ABGR8888 = 0x16762004u, /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_ABGR, SDL_PACKEDLAYOUT_8888, 32, 4), */ SDL_PIXELFORMAT_BGRA8888 = 0x16862004u, /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_BGRA, SDL_PACKEDLAYOUT_8888, 32, 4), */ SDL_PIXELFORMAT_XRGB2101010 = 0x16172004u, /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_XRGB, SDL_PACKEDLAYOUT_2101010, 32, 4), */ SDL_PIXELFORMAT_XBGR2101010 = 0x16572004u, /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_XBGR, SDL_PACKEDLAYOUT_2101010, 32, 4), */ SDL_PIXELFORMAT_ARGB2101010 = 0x16372004u, /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_ARGB, SDL_PACKEDLAYOUT_2101010, 32, 4), */ SDL_PIXELFORMAT_ABGR2101010 = 0x16772004u, /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_ABGR, SDL_PACKEDLAYOUT_2101010, 32, 4), */ SDL_PIXELFORMAT_RGB48 = 0x18103006u, /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_ARRAYU16, SDL_ARRAYORDER_RGB, 0, 48, 6), */ SDL_PIXELFORMAT_BGR48 = 0x18403006u, /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_ARRAYU16, SDL_ARRAYORDER_BGR, 0, 48, 6), */ SDL_PIXELFORMAT_RGBA64 = 0x18204008u, /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_ARRAYU16, SDL_ARRAYORDER_RGBA, 0, 64, 8), */ SDL_PIXELFORMAT_ARGB64 = 0x18304008u, /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_ARRAYU16, SDL_ARRAYORDER_ARGB, 0, 64, 8), */ SDL_PIXELFORMAT_BGRA64 = 0x18504008u, /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_ARRAYU16, SDL_ARRAYORDER_BGRA, 0, 64, 8), */ SDL_PIXELFORMAT_ABGR64 = 0x18604008u, /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_ARRAYU16, SDL_ARRAYORDER_ABGR, 0, 64, 8), */ SDL_PIXELFORMAT_RGB48_FLOAT = 0x1a103006u, /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_ARRAYF16, SDL_ARRAYORDER_RGB, 0, 48, 6), */ SDL_PIXELFORMAT_BGR48_FLOAT = 0x1a403006u, /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_ARRAYF16, SDL_ARRAYORDER_BGR, 0, 48, 6), */ SDL_PIXELFORMAT_RGBA64_FLOAT = 0x1a204008u, /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_ARRAYF16, SDL_ARRAYORDER_RGBA, 0, 64, 8), */ SDL_PIXELFORMAT_ARGB64_FLOAT = 0x1a304008u, /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_ARRAYF16, SDL_ARRAYORDER_ARGB, 0, 64, 8), */ SDL_PIXELFORMAT_BGRA64_FLOAT = 0x1a504008u, /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_ARRAYF16, SDL_ARRAYORDER_BGRA, 0, 64, 8), */ SDL_PIXELFORMAT_ABGR64_FLOAT = 0x1a604008u, /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_ARRAYF16, SDL_ARRAYORDER_ABGR, 0, 64, 8), */ SDL_PIXELFORMAT_RGB96_FLOAT = 0x1b10600cu, /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_ARRAYF32, SDL_ARRAYORDER_RGB, 0, 96, 12), */ SDL_PIXELFORMAT_BGR96_FLOAT = 0x1b40600cu, /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_ARRAYF32, SDL_ARRAYORDER_BGR, 0, 96, 12), */ SDL_PIXELFORMAT_RGBA128_FLOAT = 0x1b208010u, /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_ARRAYF32, SDL_ARRAYORDER_RGBA, 0, 128, 16), */ SDL_PIXELFORMAT_ARGB128_FLOAT = 0x1b308010u, /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_ARRAYF32, SDL_ARRAYORDER_ARGB, 0, 128, 16), */ SDL_PIXELFORMAT_BGRA128_FLOAT = 0x1b508010u, /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_ARRAYF32, SDL_ARRAYORDER_BGRA, 0, 128, 16), */ SDL_PIXELFORMAT_ABGR128_FLOAT = 0x1b608010u, /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_ARRAYF32, SDL_ARRAYORDER_ABGR, 0, 128, 16), */ SDL_PIXELFORMAT_YV12 = 0x32315659u, /**< Planar mode: Y + V + U (3 planes) */ /* SDL_DEFINE_PIXELFOURCC('Y', 'V', '1', '2'), */ SDL_PIXELFORMAT_IYUV = 0x56555949u, /**< Planar mode: Y + U + V (3 planes) */ /* SDL_DEFINE_PIXELFOURCC('I', 'Y', 'U', 'V'), */ SDL_PIXELFORMAT_YUY2 = 0x32595559u, /**< Packed mode: Y0+U0+Y1+V0 (1 plane) */ /* SDL_DEFINE_PIXELFOURCC('Y', 'U', 'Y', '2'), */ SDL_PIXELFORMAT_UYVY = 0x59565955u, /**< Packed mode: U0+Y0+V0+Y1 (1 plane) */ /* SDL_DEFINE_PIXELFOURCC('U', 'Y', 'V', 'Y'), */ SDL_PIXELFORMAT_YVYU = 0x55595659u, /**< Packed mode: Y0+V0+Y1+U0 (1 plane) */ /* SDL_DEFINE_PIXELFOURCC('Y', 'V', 'Y', 'U'), */ SDL_PIXELFORMAT_NV12 = 0x3231564eu, /**< Planar mode: Y + U/V interleaved (2 planes) */ /* SDL_DEFINE_PIXELFOURCC('N', 'V', '1', '2'), */ SDL_PIXELFORMAT_NV21 = 0x3132564eu, /**< Planar mode: Y + V/U interleaved (2 planes) */ /* SDL_DEFINE_PIXELFOURCC('N', 'V', '2', '1'), */ SDL_PIXELFORMAT_P010 = 0x30313050u, /**< Planar mode: Y + U/V interleaved (2 planes) */ /* SDL_DEFINE_PIXELFOURCC('P', '0', '1', '0'), */ SDL_PIXELFORMAT_EXTERNAL_OES = 0x2053454fu, /**< Android video texture format */ /* SDL_DEFINE_PIXELFOURCC('O', 'E', 'S', ' ') */ SDL_PIXELFORMAT_MJPG = 0x47504a4du, /**< Motion JPEG */ /* SDL_DEFINE_PIXELFOURCC('M', 'J', 'P', 'G') */ /* Aliases for RGBA byte arrays of color data, for the current platform */ #if SDL_BYTEORDER == SDL_BIG_ENDIAN SDL_PIXELFORMAT_RGBA32 = SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_ARGB32 = SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_BGRA32 = SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_ABGR32 = SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_RGBX32 = SDL_PIXELFORMAT_RGBX8888, SDL_PIXELFORMAT_XRGB32 = SDL_PIXELFORMAT_XRGB8888, SDL_PIXELFORMAT_BGRX32 = SDL_PIXELFORMAT_BGRX8888, SDL_PIXELFORMAT_XBGR32 = SDL_PIXELFORMAT_XBGR8888 #else SDL_PIXELFORMAT_RGBA32 = SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_ARGB32 = SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_BGRA32 = SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_ABGR32 = SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_RGBX32 = SDL_PIXELFORMAT_XBGR8888, SDL_PIXELFORMAT_XRGB32 = SDL_PIXELFORMAT_BGRX8888, SDL_PIXELFORMAT_BGRX32 = SDL_PIXELFORMAT_XRGB8888, SDL_PIXELFORMAT_XBGR32 = SDL_PIXELFORMAT_RGBX8888 #endif } SDL_PixelFormat; /** * Colorspace color type. * * \since This enum is available since SDL 3.2.0. */ typedef enum SDL_ColorType { SDL_COLOR_TYPE_UNKNOWN = 0, SDL_COLOR_TYPE_RGB = 1, SDL_COLOR_TYPE_YCBCR = 2 } SDL_ColorType; /** * Colorspace color range, as described by * https://www.itu.int/rec/R-REC-BT.2100-2-201807-I/en * * \since This enum is available since SDL 3.2.0. */ typedef enum SDL_ColorRange { SDL_COLOR_RANGE_UNKNOWN = 0, SDL_COLOR_RANGE_LIMITED = 1, /**< Narrow range, e.g. 16-235 for 8-bit RGB and luma, and 16-240 for 8-bit chroma */ SDL_COLOR_RANGE_FULL = 2 /**< Full range, e.g. 0-255 for 8-bit RGB and luma, and 1-255 for 8-bit chroma */ } SDL_ColorRange; /** * Colorspace color primaries, as described by * https://www.itu.int/rec/T-REC-H.273-201612-S/en * * \since This enum is available since SDL 3.2.0. */ typedef enum SDL_ColorPrimaries { SDL_COLOR_PRIMARIES_UNKNOWN = 0, SDL_COLOR_PRIMARIES_BT709 = 1, /**< ITU-R BT.709-6 */ SDL_COLOR_PRIMARIES_UNSPECIFIED = 2, SDL_COLOR_PRIMARIES_BT470M = 4, /**< ITU-R BT.470-6 System M */ SDL_COLOR_PRIMARIES_BT470BG = 5, /**< ITU-R BT.470-6 System B, G / ITU-R BT.601-7 625 */ SDL_COLOR_PRIMARIES_BT601 = 6, /**< ITU-R BT.601-7 525, SMPTE 170M */ SDL_COLOR_PRIMARIES_SMPTE240 = 7, /**< SMPTE 240M, functionally the same as SDL_COLOR_PRIMARIES_BT601 */ SDL_COLOR_PRIMARIES_GENERIC_FILM = 8, /**< Generic film (color filters using Illuminant C) */ SDL_COLOR_PRIMARIES_BT2020 = 9, /**< ITU-R BT.2020-2 / ITU-R BT.2100-0 */ SDL_COLOR_PRIMARIES_XYZ = 10, /**< SMPTE ST 428-1 */ SDL_COLOR_PRIMARIES_SMPTE431 = 11, /**< SMPTE RP 431-2 */ SDL_COLOR_PRIMARIES_SMPTE432 = 12, /**< SMPTE EG 432-1 / DCI P3 */ SDL_COLOR_PRIMARIES_EBU3213 = 22, /**< EBU Tech. 3213-E */ SDL_COLOR_PRIMARIES_CUSTOM = 31 } SDL_ColorPrimaries; /** * Colorspace transfer characteristics. * * These are as described by https://www.itu.int/rec/T-REC-H.273-201612-S/en * * \since This enum is available since SDL 3.2.0. */ typedef enum SDL_TransferCharacteristics { SDL_TRANSFER_CHARACTERISTICS_UNKNOWN = 0, SDL_TRANSFER_CHARACTERISTICS_BT709 = 1, /**< Rec. ITU-R BT.709-6 / ITU-R BT1361 */ SDL_TRANSFER_CHARACTERISTICS_UNSPECIFIED = 2, SDL_TRANSFER_CHARACTERISTICS_GAMMA22 = 4, /**< ITU-R BT.470-6 System M / ITU-R BT1700 625 PAL & SECAM */ SDL_TRANSFER_CHARACTERISTICS_GAMMA28 = 5, /**< ITU-R BT.470-6 System B, G */ SDL_TRANSFER_CHARACTERISTICS_BT601 = 6, /**< SMPTE ST 170M / ITU-R BT.601-7 525 or 625 */ SDL_TRANSFER_CHARACTERISTICS_SMPTE240 = 7, /**< SMPTE ST 240M */ SDL_TRANSFER_CHARACTERISTICS_LINEAR = 8, SDL_TRANSFER_CHARACTERISTICS_LOG100 = 9, SDL_TRANSFER_CHARACTERISTICS_LOG100_SQRT10 = 10, SDL_TRANSFER_CHARACTERISTICS_IEC61966 = 11, /**< IEC 61966-2-4 */ SDL_TRANSFER_CHARACTERISTICS_BT1361 = 12, /**< ITU-R BT1361 Extended Colour Gamut */ SDL_TRANSFER_CHARACTERISTICS_SRGB = 13, /**< IEC 61966-2-1 (sRGB or sYCC) */ SDL_TRANSFER_CHARACTERISTICS_BT2020_10BIT = 14, /**< ITU-R BT2020 for 10-bit system */ SDL_TRANSFER_CHARACTERISTICS_BT2020_12BIT = 15, /**< ITU-R BT2020 for 12-bit system */ SDL_TRANSFER_CHARACTERISTICS_PQ = 16, /**< SMPTE ST 2084 for 10-, 12-, 14- and 16-bit systems */ SDL_TRANSFER_CHARACTERISTICS_SMPTE428 = 17, /**< SMPTE ST 428-1 */ SDL_TRANSFER_CHARACTERISTICS_HLG = 18, /**< ARIB STD-B67, known as "hybrid log-gamma" (HLG) */ SDL_TRANSFER_CHARACTERISTICS_CUSTOM = 31 } SDL_TransferCharacteristics; /** * Colorspace matrix coefficients. * * These are as described by https://www.itu.int/rec/T-REC-H.273-201612-S/en * * \since This enum is available since SDL 3.2.0. */ typedef enum SDL_MatrixCoefficients { SDL_MATRIX_COEFFICIENTS_IDENTITY = 0, SDL_MATRIX_COEFFICIENTS_BT709 = 1, /**< ITU-R BT.709-6 */ SDL_MATRIX_COEFFICIENTS_UNSPECIFIED = 2, SDL_MATRIX_COEFFICIENTS_FCC = 4, /**< US FCC Title 47 */ SDL_MATRIX_COEFFICIENTS_BT470BG = 5, /**< ITU-R BT.470-6 System B, G / ITU-R BT.601-7 625, functionally the same as SDL_MATRIX_COEFFICIENTS_BT601 */ SDL_MATRIX_COEFFICIENTS_BT601 = 6, /**< ITU-R BT.601-7 525 */ SDL_MATRIX_COEFFICIENTS_SMPTE240 = 7, /**< SMPTE 240M */ SDL_MATRIX_COEFFICIENTS_YCGCO = 8, SDL_MATRIX_COEFFICIENTS_BT2020_NCL = 9, /**< ITU-R BT.2020-2 non-constant luminance */ SDL_MATRIX_COEFFICIENTS_BT2020_CL = 10, /**< ITU-R BT.2020-2 constant luminance */ SDL_MATRIX_COEFFICIENTS_SMPTE2085 = 11, /**< SMPTE ST 2085 */ SDL_MATRIX_COEFFICIENTS_CHROMA_DERIVED_NCL = 12, SDL_MATRIX_COEFFICIENTS_CHROMA_DERIVED_CL = 13, SDL_MATRIX_COEFFICIENTS_ICTCP = 14, /**< ITU-R BT.2100-0 ICTCP */ SDL_MATRIX_COEFFICIENTS_CUSTOM = 31 } SDL_MatrixCoefficients; /** * Colorspace chroma sample location. * * \since This enum is available since SDL 3.2.0. */ typedef enum SDL_ChromaLocation { SDL_CHROMA_LOCATION_NONE = 0, /**< RGB, no chroma sampling */ SDL_CHROMA_LOCATION_LEFT = 1, /**< In MPEG-2, MPEG-4, and AVC, Cb and Cr are taken on midpoint of the left-edge of the 2x2 square. In other words, they have the same horizontal location as the top-left pixel, but is shifted one-half pixel down vertically. */ SDL_CHROMA_LOCATION_CENTER = 2, /**< In JPEG/JFIF, H.261, and MPEG-1, Cb and Cr are taken at the center of the 2x2 square. In other words, they are offset one-half pixel to the right and one-half pixel down compared to the top-left pixel. */ SDL_CHROMA_LOCATION_TOPLEFT = 3 /**< In HEVC for BT.2020 and BT.2100 content (in particular on Blu-rays), Cb and Cr are sampled at the same location as the group's top-left Y pixel ("co-sited", "co-located"). */ } SDL_ChromaLocation; /* Colorspace definition */ /** * A macro for defining custom SDL_Colorspace formats. * * For example, defining SDL_COLORSPACE_SRGB looks like this: * * ```c * SDL_DEFINE_COLORSPACE(SDL_COLOR_TYPE_RGB, * SDL_COLOR_RANGE_FULL, * SDL_COLOR_PRIMARIES_BT709, * SDL_TRANSFER_CHARACTERISTICS_SRGB, * SDL_MATRIX_COEFFICIENTS_IDENTITY, * SDL_CHROMA_LOCATION_NONE) * ``` * * \param type the type of the new format, probably an SDL_ColorType value. * \param range the range of the new format, probably a SDL_ColorRange value. * \param primaries the primaries of the new format, probably an * SDL_ColorPrimaries value. * \param transfer the transfer characteristics of the new format, probably an * SDL_TransferCharacteristics value. * \param matrix the matrix coefficients of the new format, probably an * SDL_MatrixCoefficients value. * \param chroma the chroma sample location of the new format, probably an * SDL_ChromaLocation value. * \returns a format value in the style of SDL_Colorspace. * * \threadsafety It is safe to call this macro from any thread. * * \since This macro is available since SDL 3.2.0. */ #define SDL_DEFINE_COLORSPACE(type, range, primaries, transfer, matrix, chroma) \ (((Uint32)(type) << 28) | ((Uint32)(range) << 24) | ((Uint32)(chroma) << 20) | \ ((Uint32)(primaries) << 10) | ((Uint32)(transfer) << 5) | ((Uint32)(matrix) << 0)) /** * A macro to retrieve the type of an SDL_Colorspace. * * \param cspace an SDL_Colorspace to check. * \returns the SDL_ColorType for `cspace`. * * \threadsafety It is safe to call this macro from any thread. * * \since This macro is available since SDL 3.2.0. */ #define SDL_COLORSPACETYPE(cspace) (SDL_ColorType)(((cspace) >> 28) & 0x0F) /** * A macro to retrieve the range of an SDL_Colorspace. * * \param cspace an SDL_Colorspace to check. * \returns the SDL_ColorRange of `cspace`. * * \threadsafety It is safe to call this macro from any thread. * * \since This macro is available since SDL 3.2.0. */ #define SDL_COLORSPACERANGE(cspace) (SDL_ColorRange)(((cspace) >> 24) & 0x0F) /** * A macro to retrieve the chroma sample location of an SDL_Colorspace. * * \param cspace an SDL_Colorspace to check. * \returns the SDL_ChromaLocation of `cspace`. * * \threadsafety It is safe to call this macro from any thread. * * \since This macro is available since SDL 3.2.0. */ #define SDL_COLORSPACECHROMA(cspace) (SDL_ChromaLocation)(((cspace) >> 20) & 0x0F) /** * A macro to retrieve the primaries of an SDL_Colorspace. * * \param cspace an SDL_Colorspace to check. * \returns the SDL_ColorPrimaries of `cspace`. * * \threadsafety It is safe to call this macro from any thread. * * \since This macro is available since SDL 3.2.0. */ #define SDL_COLORSPACEPRIMARIES(cspace) (SDL_ColorPrimaries)(((cspace) >> 10) & 0x1F) /** * A macro to retrieve the transfer characteristics of an SDL_Colorspace. * * \param cspace an SDL_Colorspace to check. * \returns the SDL_TransferCharacteristics of `cspace`. * * \threadsafety It is safe to call this macro from any thread. * * \since This macro is available since SDL 3.2.0. */ #define SDL_COLORSPACETRANSFER(cspace) (SDL_TransferCharacteristics)(((cspace) >> 5) & 0x1F) /** * A macro to retrieve the matrix coefficients of an SDL_Colorspace. * * \param cspace an SDL_Colorspace to check. * \returns the SDL_MatrixCoefficients of `cspace`. * * \threadsafety It is safe to call this macro from any thread. * * \since This macro is available since SDL 3.2.0. */ #define SDL_COLORSPACEMATRIX(cspace) (SDL_MatrixCoefficients)((cspace) & 0x1F) /** * A macro to determine if an SDL_Colorspace uses BT601 (or BT470BG) matrix * coefficients. * * Note that this macro double-evaluates its parameter, so do not use * expressions with side-effects here. * * \param cspace an SDL_Colorspace to check. * \returns true if BT601 or BT470BG, false otherwise. * * \threadsafety It is safe to call this macro from any thread. * * \since This macro is available since SDL 3.2.0. */ #define SDL_ISCOLORSPACE_MATRIX_BT601(cspace) (SDL_COLORSPACEMATRIX(cspace) == SDL_MATRIX_COEFFICIENTS_BT601 || SDL_COLORSPACEMATRIX(cspace) == SDL_MATRIX_COEFFICIENTS_BT470BG) /** * A macro to determine if an SDL_Colorspace uses BT709 matrix coefficients. * * \param cspace an SDL_Colorspace to check. * \returns true if BT709, false otherwise. * * \threadsafety It is safe to call this macro from any thread. * * \since This macro is available since SDL 3.2.0. */ #define SDL_ISCOLORSPACE_MATRIX_BT709(cspace) (SDL_COLORSPACEMATRIX(cspace) == SDL_MATRIX_COEFFICIENTS_BT709) /** * A macro to determine if an SDL_Colorspace uses BT2020_NCL matrix * coefficients. * * \param cspace an SDL_Colorspace to check. * \returns true if BT2020_NCL, false otherwise. * * \threadsafety It is safe to call this macro from any thread. * * \since This macro is available since SDL 3.2.0. */ #define SDL_ISCOLORSPACE_MATRIX_BT2020_NCL(cspace) (SDL_COLORSPACEMATRIX(cspace) == SDL_MATRIX_COEFFICIENTS_BT2020_NCL) /** * A macro to determine if an SDL_Colorspace has a limited range. * * \param cspace an SDL_Colorspace to check. * \returns true if limited range, false otherwise. * * \threadsafety It is safe to call this macro from any thread. * * \since This macro is available since SDL 3.2.0. */ #define SDL_ISCOLORSPACE_LIMITED_RANGE(cspace) (SDL_COLORSPACERANGE(cspace) != SDL_COLOR_RANGE_FULL) /** * A macro to determine if an SDL_Colorspace has a full range. * * \param cspace an SDL_Colorspace to check. * \returns true if full range, false otherwise. * * \threadsafety It is safe to call this macro from any thread. * * \since This macro is available since SDL 3.2.0. */ #define SDL_ISCOLORSPACE_FULL_RANGE(cspace) (SDL_COLORSPACERANGE(cspace) == SDL_COLOR_RANGE_FULL) /** * Colorspace definitions. * * Since similar colorspaces may vary in their details (matrix, transfer * function, etc.), this is not an exhaustive list, but rather a * representative sample of the kinds of colorspaces supported in SDL. * * \since This enum is available since SDL 3.2.0. * * \sa SDL_ColorPrimaries * \sa SDL_ColorRange * \sa SDL_ColorType * \sa SDL_MatrixCoefficients * \sa SDL_TransferCharacteristics */ typedef enum SDL_Colorspace { SDL_COLORSPACE_UNKNOWN = 0, /* sRGB is a gamma corrected colorspace, and the default colorspace for SDL rendering and 8-bit RGB surfaces */ SDL_COLORSPACE_SRGB = 0x120005a0u, /**< Equivalent to DXGI_COLOR_SPACE_RGB_FULL_G22_NONE_P709 */ /* SDL_DEFINE_COLORSPACE(SDL_COLOR_TYPE_RGB, SDL_COLOR_RANGE_FULL, SDL_COLOR_PRIMARIES_BT709, SDL_TRANSFER_CHARACTERISTICS_SRGB, SDL_MATRIX_COEFFICIENTS_IDENTITY, SDL_CHROMA_LOCATION_NONE), */ /* This is a linear colorspace and the default colorspace for floating point surfaces. On Windows this is the scRGB colorspace, and on Apple platforms this is kCGColorSpaceExtendedLinearSRGB for EDR content */ SDL_COLORSPACE_SRGB_LINEAR = 0x12000500u, /**< Equivalent to DXGI_COLOR_SPACE_RGB_FULL_G10_NONE_P709 */ /* SDL_DEFINE_COLORSPACE(SDL_COLOR_TYPE_RGB, SDL_COLOR_RANGE_FULL, SDL_COLOR_PRIMARIES_BT709, SDL_TRANSFER_CHARACTERISTICS_LINEAR, SDL_MATRIX_COEFFICIENTS_IDENTITY, SDL_CHROMA_LOCATION_NONE), */ /* HDR10 is a non-linear HDR colorspace and the default colorspace for 10-bit surfaces */ SDL_COLORSPACE_HDR10 = 0x12002600u, /**< Equivalent to DXGI_COLOR_SPACE_RGB_FULL_G2084_NONE_P2020 */ /* SDL_DEFINE_COLORSPACE(SDL_COLOR_TYPE_RGB, SDL_COLOR_RANGE_FULL, SDL_COLOR_PRIMARIES_BT2020, SDL_TRANSFER_CHARACTERISTICS_PQ, SDL_MATRIX_COEFFICIENTS_IDENTITY, SDL_CHROMA_LOCATION_NONE), */ SDL_COLORSPACE_JPEG = 0x220004c6u, /**< Equivalent to DXGI_COLOR_SPACE_YCBCR_FULL_G22_NONE_P709_X601 */ /* SDL_DEFINE_COLORSPACE(SDL_COLOR_TYPE_YCBCR, SDL_COLOR_RANGE_FULL, SDL_COLOR_PRIMARIES_BT709, SDL_TRANSFER_CHARACTERISTICS_BT601, SDL_MATRIX_COEFFICIENTS_BT601, SDL_CHROMA_LOCATION_NONE), */ SDL_COLORSPACE_BT601_LIMITED = 0x211018c6u, /**< Equivalent to DXGI_COLOR_SPACE_YCBCR_STUDIO_G22_LEFT_P601 */ /* SDL_DEFINE_COLORSPACE(SDL_COLOR_TYPE_YCBCR, SDL_COLOR_RANGE_LIMITED, SDL_COLOR_PRIMARIES_BT601, SDL_TRANSFER_CHARACTERISTICS_BT601, SDL_MATRIX_COEFFICIENTS_BT601, SDL_CHROMA_LOCATION_LEFT), */ SDL_COLORSPACE_BT601_FULL = 0x221018c6u, /**< Equivalent to DXGI_COLOR_SPACE_YCBCR_STUDIO_G22_LEFT_P601 */ /* SDL_DEFINE_COLORSPACE(SDL_COLOR_TYPE_YCBCR, SDL_COLOR_RANGE_FULL, SDL_COLOR_PRIMARIES_BT601, SDL_TRANSFER_CHARACTERISTICS_BT601, SDL_MATRIX_COEFFICIENTS_BT601, SDL_CHROMA_LOCATION_LEFT), */ SDL_COLORSPACE_BT709_LIMITED = 0x21100421u, /**< Equivalent to DXGI_COLOR_SPACE_YCBCR_STUDIO_G22_LEFT_P709 */ /* SDL_DEFINE_COLORSPACE(SDL_COLOR_TYPE_YCBCR, SDL_COLOR_RANGE_LIMITED, SDL_COLOR_PRIMARIES_BT709, SDL_TRANSFER_CHARACTERISTICS_BT709, SDL_MATRIX_COEFFICIENTS_BT709, SDL_CHROMA_LOCATION_LEFT), */ SDL_COLORSPACE_BT709_FULL = 0x22100421u, /**< Equivalent to DXGI_COLOR_SPACE_YCBCR_STUDIO_G22_LEFT_P709 */ /* SDL_DEFINE_COLORSPACE(SDL_COLOR_TYPE_YCBCR, SDL_COLOR_RANGE_FULL, SDL_COLOR_PRIMARIES_BT709, SDL_TRANSFER_CHARACTERISTICS_BT709, SDL_MATRIX_COEFFICIENTS_BT709, SDL_CHROMA_LOCATION_LEFT), */ SDL_COLORSPACE_BT2020_LIMITED = 0x21102609u, /**< Equivalent to DXGI_COLOR_SPACE_YCBCR_STUDIO_G22_LEFT_P2020 */ /* SDL_DEFINE_COLORSPACE(SDL_COLOR_TYPE_YCBCR, SDL_COLOR_RANGE_LIMITED, SDL_COLOR_PRIMARIES_BT2020, SDL_TRANSFER_CHARACTERISTICS_PQ, SDL_MATRIX_COEFFICIENTS_BT2020_NCL, SDL_CHROMA_LOCATION_LEFT), */ SDL_COLORSPACE_BT2020_FULL = 0x22102609u, /**< Equivalent to DXGI_COLOR_SPACE_YCBCR_FULL_G22_LEFT_P2020 */ /* SDL_DEFINE_COLORSPACE(SDL_COLOR_TYPE_YCBCR, SDL_COLOR_RANGE_FULL, SDL_COLOR_PRIMARIES_BT2020, SDL_TRANSFER_CHARACTERISTICS_PQ, SDL_MATRIX_COEFFICIENTS_BT2020_NCL, SDL_CHROMA_LOCATION_LEFT), */ SDL_COLORSPACE_RGB_DEFAULT = SDL_COLORSPACE_SRGB, /**< The default colorspace for RGB surfaces if no colorspace is specified */ SDL_COLORSPACE_YUV_DEFAULT = SDL_COLORSPACE_BT601_LIMITED /**< The default colorspace for YUV surfaces if no colorspace is specified */ } SDL_Colorspace; /** * A structure that represents a color as RGBA components. * * The bits of this structure can be directly reinterpreted as an * integer-packed color which uses the SDL_PIXELFORMAT_RGBA32 format * (SDL_PIXELFORMAT_ABGR8888 on little-endian systems and * SDL_PIXELFORMAT_RGBA8888 on big-endian systems). * * \since This struct is available since SDL 3.2.0. */ typedef struct SDL_Color { Uint8 r; Uint8 g; Uint8 b; Uint8 a; } SDL_Color; /** * The bits of this structure can be directly reinterpreted as a float-packed * color which uses the SDL_PIXELFORMAT_RGBA128_FLOAT format * * \since This struct is available since SDL 3.2.0. */ typedef struct SDL_FColor { float r; float g; float b; float a; } SDL_FColor; /** * A set of indexed colors representing a palette. * * \since This struct is available since SDL 3.2.0. * * \sa SDL_SetPaletteColors */ typedef struct SDL_Palette { int ncolors; /**< number of elements in `colors`. */ SDL_Color *colors; /**< an array of colors, `ncolors` long. */ Uint32 version; /**< internal use only, do not touch. */ int refcount; /**< internal use only, do not touch. */ } SDL_Palette; /** * Details about the format of a pixel. * * \since This struct is available since SDL 3.2.0. */ typedef struct SDL_PixelFormatDetails { SDL_PixelFormat format; Uint8 bits_per_pixel; Uint8 bytes_per_pixel; Uint8 padding[2]; Uint32 Rmask; Uint32 Gmask; Uint32 Bmask; Uint32 Amask; Uint8 Rbits; Uint8 Gbits; Uint8 Bbits; Uint8 Abits; Uint8 Rshift; Uint8 Gshift; Uint8 Bshift; Uint8 Ashift; } SDL_PixelFormatDetails; /** * Get the human readable name of a pixel format. * * \param format the pixel format to query. * \returns the human readable name of the specified pixel format or * "SDL_PIXELFORMAT_UNKNOWN" if the format isn't recognized. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC const char * SDLCALL SDL_GetPixelFormatName(SDL_PixelFormat format); /** * Convert one of the enumerated pixel formats to a bpp value and RGBA masks. * * \param format one of the SDL_PixelFormat values. * \param bpp a bits per pixel value; usually 15, 16, or 32. * \param Rmask a pointer filled in with the red mask for the format. * \param Gmask a pointer filled in with the green mask for the format. * \param Bmask a pointer filled in with the blue mask for the format. * \param Amask a pointer filled in with the alpha mask for the format. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetPixelFormatForMasks */ extern SDL_DECLSPEC bool SDLCALL SDL_GetMasksForPixelFormat(SDL_PixelFormat format, int *bpp, Uint32 *Rmask, Uint32 *Gmask, Uint32 *Bmask, Uint32 *Amask); /** * Convert a bpp value and RGBA masks to an enumerated pixel format. * * This will return `SDL_PIXELFORMAT_UNKNOWN` if the conversion wasn't * possible. * * \param bpp a bits per pixel value; usually 15, 16, or 32. * \param Rmask the red mask for the format. * \param Gmask the green mask for the format. * \param Bmask the blue mask for the format. * \param Amask the alpha mask for the format. * \returns the SDL_PixelFormat value corresponding to the format masks, or * SDL_PIXELFORMAT_UNKNOWN if there isn't a match. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetMasksForPixelFormat */ extern SDL_DECLSPEC SDL_PixelFormat SDLCALL SDL_GetPixelFormatForMasks(int bpp, Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask); /** * Create an SDL_PixelFormatDetails structure corresponding to a pixel format. * * Returned structure may come from a shared global cache (i.e. not newly * allocated), and hence should not be modified, especially the palette. Weird * errors such as `Blit combination not supported` may occur. * * \param format one of the SDL_PixelFormat values. * \returns a pointer to a SDL_PixelFormatDetails structure or NULL on * failure; call SDL_GetError() for more information. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC const SDL_PixelFormatDetails * SDLCALL SDL_GetPixelFormatDetails(SDL_PixelFormat format); /** * Create a palette structure with the specified number of color entries. * * The palette entries are initialized to white. * * \param ncolors represents the number of color entries in the color palette. * \returns a new SDL_Palette structure on success or NULL on failure (e.g. if * there wasn't enough memory); call SDL_GetError() for more * information. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_DestroyPalette * \sa SDL_SetPaletteColors * \sa SDL_SetSurfacePalette */ extern SDL_DECLSPEC SDL_Palette * SDLCALL SDL_CreatePalette(int ncolors); /** * Set a range of colors in a palette. * * \param palette the SDL_Palette structure to modify. * \param colors an array of SDL_Color structures to copy into the palette. * \param firstcolor the index of the first palette entry to modify. * \param ncolors the number of entries to modify. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety It is safe to call this function from any thread, as long as * the palette is not modified or destroyed in another thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC bool SDLCALL SDL_SetPaletteColors(SDL_Palette *palette, const SDL_Color *colors, int firstcolor, int ncolors); /** * Free a palette created with SDL_CreatePalette(). * * \param palette the SDL_Palette structure to be freed. * * \threadsafety It is safe to call this function from any thread, as long as * the palette is not modified or destroyed in another thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_CreatePalette */ extern SDL_DECLSPEC void SDLCALL SDL_DestroyPalette(SDL_Palette *palette); /** * Map an RGB triple to an opaque pixel value for a given pixel format. * * This function maps the RGB color value to the specified pixel format and * returns the pixel value best approximating the given RGB color value for * the given pixel format. * * If the format has a palette (8-bit) the index of the closest matching color * in the palette will be returned. * * If the specified pixel format has an alpha component it will be returned as * all 1 bits (fully opaque). * * If the pixel format bpp (color depth) is less than 32-bpp then the unused * upper bits of the return value can safely be ignored (e.g., with a 16-bpp * format the return value can be assigned to a Uint16, and similarly a Uint8 * for an 8-bpp format). * * \param format a pointer to SDL_PixelFormatDetails describing the pixel * format. * \param palette an optional palette for indexed formats, may be NULL. * \param r the red component of the pixel in the range 0-255. * \param g the green component of the pixel in the range 0-255. * \param b the blue component of the pixel in the range 0-255. * \returns a pixel value. * * \threadsafety It is safe to call this function from any thread, as long as * the palette is not modified. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetPixelFormatDetails * \sa SDL_GetRGB * \sa SDL_MapRGBA * \sa SDL_MapSurfaceRGB */ extern SDL_DECLSPEC Uint32 SDLCALL SDL_MapRGB(const SDL_PixelFormatDetails *format, const SDL_Palette *palette, Uint8 r, Uint8 g, Uint8 b); /** * Map an RGBA quadruple to a pixel value for a given pixel format. * * This function maps the RGBA color value to the specified pixel format and * returns the pixel value best approximating the given RGBA color value for * the given pixel format. * * If the specified pixel format has no alpha component the alpha value will * be ignored (as it will be in formats with a palette). * * If the format has a palette (8-bit) the index of the closest matching color * in the palette will be returned. * * If the pixel format bpp (color depth) is less than 32-bpp then the unused * upper bits of the return value can safely be ignored (e.g., with a 16-bpp * format the return value can be assigned to a Uint16, and similarly a Uint8 * for an 8-bpp format). * * \param format a pointer to SDL_PixelFormatDetails describing the pixel * format. * \param palette an optional palette for indexed formats, may be NULL. * \param r the red component of the pixel in the range 0-255. * \param g the green component of the pixel in the range 0-255. * \param b the blue component of the pixel in the range 0-255. * \param a the alpha component of the pixel in the range 0-255. * \returns a pixel value. * * \threadsafety It is safe to call this function from any thread, as long as * the palette is not modified. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetPixelFormatDetails * \sa SDL_GetRGBA * \sa SDL_MapRGB * \sa SDL_MapSurfaceRGBA */ extern SDL_DECLSPEC Uint32 SDLCALL SDL_MapRGBA(const SDL_PixelFormatDetails *format, const SDL_Palette *palette, Uint8 r, Uint8 g, Uint8 b, Uint8 a); /** * Get RGB values from a pixel in the specified format. * * This function uses the entire 8-bit [0..255] range when converting color * components from pixel formats with less than 8-bits per RGB component * (e.g., a completely white pixel in 16-bit RGB565 format would return [0xff, * 0xff, 0xff] not [0xf8, 0xfc, 0xf8]). * * \param pixelvalue a pixel value. * \param format a pointer to SDL_PixelFormatDetails describing the pixel * format. * \param palette an optional palette for indexed formats, may be NULL. * \param r a pointer filled in with the red component, may be NULL. * \param g a pointer filled in with the green component, may be NULL. * \param b a pointer filled in with the blue component, may be NULL. * * \threadsafety It is safe to call this function from any thread, as long as * the palette is not modified. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetPixelFormatDetails * \sa SDL_GetRGBA * \sa SDL_MapRGB * \sa SDL_MapRGBA */ extern SDL_DECLSPEC void SDLCALL SDL_GetRGB(Uint32 pixelvalue, const SDL_PixelFormatDetails *format, const SDL_Palette *palette, Uint8 *r, Uint8 *g, Uint8 *b); /** * Get RGBA values from a pixel in the specified format. * * This function uses the entire 8-bit [0..255] range when converting color * components from pixel formats with less than 8-bits per RGB component * (e.g., a completely white pixel in 16-bit RGB565 format would return [0xff, * 0xff, 0xff] not [0xf8, 0xfc, 0xf8]). * * If the surface has no alpha component, the alpha will be returned as 0xff * (100% opaque). * * \param pixelvalue a pixel value. * \param format a pointer to SDL_PixelFormatDetails describing the pixel * format. * \param palette an optional palette for indexed formats, may be NULL. * \param r a pointer filled in with the red component, may be NULL. * \param g a pointer filled in with the green component, may be NULL. * \param b a pointer filled in with the blue component, may be NULL. * \param a a pointer filled in with the alpha component, may be NULL. * * \threadsafety It is safe to call this function from any thread, as long as * the palette is not modified. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetPixelFormatDetails * \sa SDL_GetRGB * \sa SDL_MapRGB * \sa SDL_MapRGBA */ extern SDL_DECLSPEC void SDLCALL SDL_GetRGBA(Uint32 pixelvalue, const SDL_PixelFormatDetails *format, const SDL_Palette *palette, Uint8 *r, Uint8 *g, Uint8 *b, Uint8 *a); /* Ends C function definitions when using C++ */ #ifdef __cplusplus } #endif #include #endif /* SDL_pixels_h_ */ ================================================ FILE: deps/include/SDL3/SDL_platform.h ================================================ /* Simple DirectMedia Layer Copyright (C) 1997-2026 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ /** * # CategoryPlatform * * SDL provides a means to identify the app's platform, both at compile time * and runtime. */ #ifndef SDL_platform_h_ #define SDL_platform_h_ #include #include /* Set up for C function definitions, even when using C++ */ #ifdef __cplusplus extern "C" { #endif /** * Get the name of the platform. * * Here are the names returned for some (but not all) supported platforms: * * - "Windows" * - "macOS" * - "Linux" * - "iOS" * - "Android" * * \returns the name of the platform. If the correct platform name is not * available, returns a string beginning with the text "Unknown". * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC const char * SDLCALL SDL_GetPlatform(void); /* Ends C function definitions when using C++ */ #ifdef __cplusplus } #endif #include #endif /* SDL_platform_h_ */ ================================================ FILE: deps/include/SDL3/SDL_platform_defines.h ================================================ /* Simple DirectMedia Layer Copyright (C) 1997-2026 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ /* WIKI CATEGORY: Platform */ /* * SDL_platform_defines.h tries to get a standard set of platform defines. */ #ifndef SDL_platform_defines_h_ #define SDL_platform_defines_h_ #ifdef _AIX /** * A preprocessor macro that is only defined if compiling for AIX. * * \since This macro is available since SDL 3.2.0. */ #define SDL_PLATFORM_AIX 1 #endif #ifdef __HAIKU__ /** * A preprocessor macro that is only defined if compiling for Haiku OS. * * \since This macro is available since SDL 3.2.0. */ #define SDL_PLATFORM_HAIKU 1 #endif #if defined(bsdi) || defined(__bsdi) || defined(__bsdi__) /** * A preprocessor macro that is only defined if compiling for BSDi * * \since This macro is available since SDL 3.2.0. */ #define SDL_PLATFORM_BSDI 1 #endif #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__) /** * A preprocessor macro that is only defined if compiling for FreeBSD. * * \since This macro is available since SDL 3.2.0. */ #define SDL_PLATFORM_FREEBSD 1 #endif #if defined(hpux) || defined(__hpux) || defined(__hpux__) /** * A preprocessor macro that is only defined if compiling for HP-UX. * * \since This macro is available since SDL 3.2.0. */ #define SDL_PLATFORM_HPUX 1 #endif #if defined(sgi) || defined(__sgi) || defined(__sgi__) || defined(_SGI_SOURCE) /** * A preprocessor macro that is only defined if compiling for IRIX. * * \since This macro is available since SDL 3.2.0. */ #define SDL_PLATFORM_IRIX 1 #endif #if (defined(linux) || defined(__linux) || defined(__linux__)) /** * A preprocessor macro that is only defined if compiling for Linux. * * Note that Android, although ostensibly a Linux-based system, will not * define this. It defines SDL_PLATFORM_ANDROID instead. * * \since This macro is available since SDL 3.2.0. */ #define SDL_PLATFORM_LINUX 1 #endif #if defined(ANDROID) || defined(__ANDROID__) /** * A preprocessor macro that is only defined if compiling for Android. * * \since This macro is available since SDL 3.2.0. */ #define SDL_PLATFORM_ANDROID 1 #undef SDL_PLATFORM_LINUX #endif #if defined(__unix__) || defined(__unix) || defined(unix) /** * A preprocessor macro that is only defined if compiling for a Unix-like * system. * * Other platforms, like Linux, might define this in addition to their primary * define. * * \since This macro is available since SDL 3.2.0. */ #define SDL_PLATFORM_UNIX 1 #endif #ifdef __APPLE__ /** * A preprocessor macro that is only defined if compiling for Apple platforms. * * iOS, macOS, etc will additionally define a more specific platform macro. * * \since This macro is available since SDL 3.2.0. * * \sa SDL_PLATFORM_MACOS * \sa SDL_PLATFORM_IOS * \sa SDL_PLATFORM_TVOS * \sa SDL_PLATFORM_VISIONOS */ #define SDL_PLATFORM_APPLE 1 /* lets us know what version of macOS we're compiling on */ #include #ifndef __has_extension /* Older compilers don't support this */ #define __has_extension(x) 0 #include #undef __has_extension #else #include #endif /* Fix building with older SDKs that don't define these See this for more information: https://stackoverflow.com/questions/12132933/preprocessor-macro-for-os-x-targets */ #ifndef TARGET_OS_MACCATALYST #define TARGET_OS_MACCATALYST 0 #endif #ifndef TARGET_OS_IOS #define TARGET_OS_IOS 0 #endif #ifndef TARGET_OS_IPHONE #define TARGET_OS_IPHONE 0 #endif #ifndef TARGET_OS_TV #define TARGET_OS_TV 0 #endif #ifndef TARGET_OS_SIMULATOR #define TARGET_OS_SIMULATOR 0 #endif #ifndef TARGET_OS_VISION #define TARGET_OS_VISION 0 #endif #if TARGET_OS_TV /** * A preprocessor macro that is only defined if compiling for tvOS. * * \since This macro is available since SDL 3.2.0. * * \sa SDL_PLATFORM_APPLE */ #define SDL_PLATFORM_TVOS 1 #endif #if TARGET_OS_VISION /** * A preprocessor macro that is only defined if compiling for visionOS. * * \since This macro is available since SDL 3.2.0. * * \sa SDL_PLATFORM_APPLE */ #define SDL_PLATFORM_VISIONOS 1 #endif #if TARGET_OS_IPHONE /** * A preprocessor macro that is only defined if compiling for iOS or visionOS. * * \since This macro is available since SDL 3.2.0. * * \sa SDL_PLATFORM_APPLE */ #define SDL_PLATFORM_IOS 1 #else /** * A preprocessor macro that is only defined if compiling for macOS. * * \since This macro is available since SDL 3.2.0. * * \sa SDL_PLATFORM_APPLE */ #define SDL_PLATFORM_MACOS 1 #if MAC_OS_X_VERSION_MIN_REQUIRED < 1070 #error SDL for macOS only supports deploying on 10.7 and above. #endif /* MAC_OS_X_VERSION_MIN_REQUIRED < 1070 */ #endif /* TARGET_OS_IPHONE */ #endif /* defined(__APPLE__) */ #ifdef __EMSCRIPTEN__ /** * A preprocessor macro that is only defined if compiling for Emscripten. * * \since This macro is available since SDL 3.2.0. */ #define SDL_PLATFORM_EMSCRIPTEN 1 #endif #ifdef __NetBSD__ /** * A preprocessor macro that is only defined if compiling for NetBSD. * * \since This macro is available since SDL 3.2.0. */ #define SDL_PLATFORM_NETBSD 1 #endif #ifdef __OpenBSD__ /** * A preprocessor macro that is only defined if compiling for OpenBSD. * * \since This macro is available since SDL 3.2.0. */ #define SDL_PLATFORM_OPENBSD 1 #endif #if defined(__OS2__) || defined(__EMX__) /** * A preprocessor macro that is only defined if compiling for OS/2. * * \since This macro is available since SDL 3.2.0. */ #define SDL_PLATFORM_OS2 1 #endif #if defined(osf) || defined(__osf) || defined(__osf__) || defined(_OSF_SOURCE) /** * A preprocessor macro that is only defined if compiling for Tru64 (OSF/1). * * \since This macro is available since SDL 3.2.0. */ #define SDL_PLATFORM_OSF 1 #endif #ifdef __QNXNTO__ /** * A preprocessor macro that is only defined if compiling for QNX Neutrino. * * \since This macro is available since SDL 3.2.0. */ #define SDL_PLATFORM_QNXNTO 1 #endif #if defined(riscos) || defined(__riscos) || defined(__riscos__) /** * A preprocessor macro that is only defined if compiling for RISC OS. * * \since This macro is available since SDL 3.2.0. */ #define SDL_PLATFORM_RISCOS 1 #endif #if defined(__sun) && defined(__SVR4) /** * A preprocessor macro that is only defined if compiling for SunOS/Solaris. * * \since This macro is available since SDL 3.2.0. */ #define SDL_PLATFORM_SOLARIS 1 #endif #if defined(__CYGWIN__) /** * A preprocessor macro that is only defined if compiling for Cygwin. * * \since This macro is available since SDL 3.2.0. */ #define SDL_PLATFORM_CYGWIN 1 #endif #if (defined(_WIN32) || defined(SDL_PLATFORM_CYGWIN)) && !defined(__NGAGE__) /** * A preprocessor macro that is only defined if compiling for Windows. * * This also covers several other platforms, like Microsoft GDK, Xbox, WinRT, * etc. Each will have their own more-specific platform macros, too. * * \since This macro is available since SDL 3.2.0. * * \sa SDL_PLATFORM_WIN32 * \sa SDL_PLATFORM_XBOXONE * \sa SDL_PLATFORM_XBOXSERIES * \sa SDL_PLATFORM_WINGDK * \sa SDL_PLATFORM_GDK */ #define SDL_PLATFORM_WINDOWS 1 /* Try to find out if we're compiling for WinRT, GDK or non-WinRT/GDK */ #if defined(_MSC_VER) && defined(__has_include) #if __has_include() #define HAVE_WINAPIFAMILY_H 1 #else #define HAVE_WINAPIFAMILY_H 0 #endif /* If _USING_V110_SDK71_ is defined it means we are using the Windows XP toolset. */ #elif defined(_MSC_VER) && (_MSC_VER >= 1700 && !_USING_V110_SDK71_) /* _MSC_VER == 1700 for Visual Studio 2012 */ #define HAVE_WINAPIFAMILY_H 1 #else #define HAVE_WINAPIFAMILY_H 0 #endif #if HAVE_WINAPIFAMILY_H #include #define WINAPI_FAMILY_WINRT (!WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) && WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP)) #else #define WINAPI_FAMILY_WINRT 0 #endif /* HAVE_WINAPIFAMILY_H */ #ifdef SDL_WIKI_DOCUMENTATION_SECTION /** * A preprocessor macro that defined to 1 if compiling for Windows Phone. * * \since This macro is available since SDL 3.2.0. */ #define SDL_WINAPI_FAMILY_PHONE (WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP) #elif defined(HAVE_WINAPIFAMILY_H) && HAVE_WINAPIFAMILY_H #define SDL_WINAPI_FAMILY_PHONE (WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP) #else #define SDL_WINAPI_FAMILY_PHONE 0 #endif #if WINAPI_FAMILY_WINRT #error Windows RT/UWP is no longer supported in SDL #elif defined(_GAMING_DESKTOP) /* GDK project configuration always defines _GAMING_XXX */ /** * A preprocessor macro that is only defined if compiling for Microsoft GDK * for Windows. * * \since This macro is available since SDL 3.2.0. */ #define SDL_PLATFORM_WINGDK 1 #elif defined(_GAMING_XBOX_XBOXONE) /** * A preprocessor macro that is only defined if compiling for Xbox One. * * \since This macro is available since SDL 3.2.0. */ #define SDL_PLATFORM_XBOXONE 1 #elif defined(_GAMING_XBOX_SCARLETT) /** * A preprocessor macro that is only defined if compiling for Xbox Series. * * \since This macro is available since SDL 3.2.0. */ #define SDL_PLATFORM_XBOXSERIES 1 #else /** * A preprocessor macro that is only defined if compiling for desktop Windows. * * Despite the "32", this also covers 64-bit Windows; as an informal * convention, its system layer tends to still be referred to as "the Win32 * API." * * \since This macro is available since SDL 3.2.0. */ #define SDL_PLATFORM_WIN32 1 #endif #endif /* defined(_WIN32) || defined(SDL_PLATFORM_CYGWIN) */ /* This is to support generic "any GDK" separate from a platform-specific GDK */ #if defined(SDL_PLATFORM_WINGDK) || defined(SDL_PLATFORM_XBOXONE) || defined(SDL_PLATFORM_XBOXSERIES) /** * A preprocessor macro that is only defined if compiling for Microsoft GDK on * any platform. * * \since This macro is available since SDL 3.2.0. */ #define SDL_PLATFORM_GDK 1 #endif #if defined(__PSP__) || defined(__psp__) /** * A preprocessor macro that is only defined if compiling for Sony PSP. * * \since This macro is available since SDL 3.2.0. */ #define SDL_PLATFORM_PSP 1 #endif #if defined(__PS2__) || defined(PS2) /** * A preprocessor macro that is only defined if compiling for Sony PlayStation * 2. * * \since This macro is available since SDL 3.2.0. */ #define SDL_PLATFORM_PS2 1 #endif #if defined(__vita__) || defined(__psp2__) /** * A preprocessor macro that is only defined if compiling for Sony Vita. * * \since This macro is available since SDL 3.2.0. */ #define SDL_PLATFORM_VITA 1 #endif #ifdef __3DS__ /** * A preprocessor macro that is only defined if compiling for Nintendo 3DS. * * \since This macro is available since SDL 3.2.0. */ #define SDL_PLATFORM_3DS 1 #endif #ifdef __NGAGE__ /** * A preprocessor macro that is only defined if compiling for the Nokia * N-Gage. * * \since This macro is available since SDL 3.4.0. */ #define SDL_PLATFORM_NGAGE 1 #endif #ifdef __GNU__ /** * A preprocessor macro that is only defined if compiling for GNU/Hurd. * * \since This macro is available since SDL 3.4.0. */ #define SDL_PLATFORM_HURD 1 #endif #endif /* SDL_platform_defines_h_ */ ================================================ FILE: deps/include/SDL3/SDL_power.h ================================================ /* Simple DirectMedia Layer Copyright (C) 1997-2026 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ #ifndef SDL_power_h_ #define SDL_power_h_ /** * # CategoryPower * * SDL power management routines. * * There is a single function in this category: SDL_GetPowerInfo(). * * This function is useful for games on the go. This allows an app to know if * it's running on a draining battery, which can be useful if the app wants to * reduce processing, or perhaps framerate, to extend the duration of the * battery's charge. Perhaps the app just wants to show a battery meter when * fullscreen, or alert the user when the power is getting extremely low, so * they can save their game. */ #include #include #include /* Set up for C function definitions, even when using C++ */ #ifdef __cplusplus extern "C" { #endif /** * The basic state for the system's power supply. * * These are results returned by SDL_GetPowerInfo(). * * \since This enum is available since SDL 3.2.0. */ typedef enum SDL_PowerState { SDL_POWERSTATE_ERROR = -1, /**< error determining power status */ SDL_POWERSTATE_UNKNOWN, /**< cannot determine power status */ SDL_POWERSTATE_ON_BATTERY, /**< Not plugged in, running on the battery */ SDL_POWERSTATE_NO_BATTERY, /**< Plugged in, no battery available */ SDL_POWERSTATE_CHARGING, /**< Plugged in, charging battery */ SDL_POWERSTATE_CHARGED /**< Plugged in, battery charged */ } SDL_PowerState; /** * Get the current power supply details. * * You should never take a battery status as absolute truth. Batteries * (especially failing batteries) are delicate hardware, and the values * reported here are best estimates based on what that hardware reports. It's * not uncommon for older batteries to lose stored power much faster than it * reports, or completely drain when reporting it has 20 percent left, etc. * * Battery status can change at any time; if you are concerned with power * state, you should call this function frequently, and perhaps ignore changes * until they seem to be stable for a few seconds. * * It's possible a platform can only report battery percentage or time left * but not both. * * On some platforms, retrieving power supply details might be expensive. If * you want to display continuous status you could call this function every * minute or so. * * \param seconds a pointer filled in with the seconds of battery life left, * or NULL to ignore. This will be filled in with -1 if we * can't determine a value or there is no battery. * \param percent a pointer filled in with the percentage of battery life * left, between 0 and 100, or NULL to ignore. This will be * filled in with -1 when we can't determine a value or there * is no battery. * \returns the current battery state or `SDL_POWERSTATE_ERROR` on failure; * call SDL_GetError() for more information. * * \threadsafety This function is not thread safe. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC SDL_PowerState SDLCALL SDL_GetPowerInfo(int *seconds, int *percent); /* Ends C function definitions when using C++ */ #ifdef __cplusplus } #endif #include #endif /* SDL_power_h_ */ ================================================ FILE: deps/include/SDL3/SDL_process.h ================================================ /* Simple DirectMedia Layer Copyright (C) 1997-2026 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ /** * # CategoryProcess * * Process control support. * * These functions provide a cross-platform way to spawn and manage OS-level * processes. * * You can create a new subprocess with SDL_CreateProcess() and optionally * read and write to it using SDL_ReadProcess() or SDL_GetProcessInput() and * SDL_GetProcessOutput(). If more advanced functionality like chaining input * between processes is necessary, you can use * SDL_CreateProcessWithProperties(). * * You can get the status of a created process with SDL_WaitProcess(), or * terminate the process with SDL_KillProcess(). * * Don't forget to call SDL_DestroyProcess() to clean up, whether the process * process was killed, terminated on its own, or is still running! */ #ifndef SDL_process_h_ #define SDL_process_h_ #include #include #include #include #include /* Set up for C function definitions, even when using C++ */ #ifdef __cplusplus extern "C" { #endif /** * An opaque handle representing a system process. * * \since This datatype is available since SDL 3.2.0. * * \sa SDL_CreateProcess */ typedef struct SDL_Process SDL_Process; /** * Create a new process. * * The path to the executable is supplied in args[0]. args[1..N] are * additional arguments passed on the command line of the new process, and the * argument list should be terminated with a NULL, e.g.: * * ```c * const char *args[] = { "myprogram", "argument", NULL }; * ``` * * Setting pipe_stdio to true is equivalent to setting * `SDL_PROP_PROCESS_CREATE_STDIN_NUMBER` and * `SDL_PROP_PROCESS_CREATE_STDOUT_NUMBER` to `SDL_PROCESS_STDIO_APP`, and * will allow the use of SDL_ReadProcess() or SDL_GetProcessInput() and * SDL_GetProcessOutput(). * * See SDL_CreateProcessWithProperties() for more details. * * \param args the path and arguments for the new process. * \param pipe_stdio true to create pipes to the process's standard input and * from the process's standard output, false for the process * to have no input and inherit the application's standard * output. * \returns the newly created and running process, or NULL if the process * couldn't be created. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_CreateProcessWithProperties * \sa SDL_GetProcessProperties * \sa SDL_ReadProcess * \sa SDL_GetProcessInput * \sa SDL_GetProcessOutput * \sa SDL_KillProcess * \sa SDL_WaitProcess * \sa SDL_DestroyProcess */ extern SDL_DECLSPEC SDL_Process * SDLCALL SDL_CreateProcess(const char * const *args, bool pipe_stdio); /** * Description of where standard I/O should be directed when creating a * process. * * If a standard I/O stream is set to SDL_PROCESS_STDIO_INHERITED, it will go * to the same place as the application's I/O stream. This is the default for * standard output and standard error. * * If a standard I/O stream is set to SDL_PROCESS_STDIO_NULL, it is connected * to `NUL:` on Windows and `/dev/null` on POSIX systems. This is the default * for standard input. * * If a standard I/O stream is set to SDL_PROCESS_STDIO_APP, it is connected * to a new SDL_IOStream that is available to the application. Standard input * will be available as `SDL_PROP_PROCESS_STDIN_POINTER` and allows * SDL_GetProcessInput(), standard output will be available as * `SDL_PROP_PROCESS_STDOUT_POINTER` and allows SDL_ReadProcess() and * SDL_GetProcessOutput(), and standard error will be available as * `SDL_PROP_PROCESS_STDERR_POINTER` in the properties for the created * process. * * If a standard I/O stream is set to SDL_PROCESS_STDIO_REDIRECT, it is * connected to an existing SDL_IOStream provided by the application. Standard * input is provided using `SDL_PROP_PROCESS_CREATE_STDIN_POINTER`, standard * output is provided using `SDL_PROP_PROCESS_CREATE_STDOUT_POINTER`, and * standard error is provided using `SDL_PROP_PROCESS_CREATE_STDERR_POINTER` * in the creation properties. These existing streams should be closed by the * application once the new process is created. * * In order to use an SDL_IOStream with SDL_PROCESS_STDIO_REDIRECT, it must * have `SDL_PROP_IOSTREAM_WINDOWS_HANDLE_POINTER` or * `SDL_PROP_IOSTREAM_FILE_DESCRIPTOR_NUMBER` set. This is true for streams * representing files and process I/O. * * \since This enum is available since SDL 3.2.0. * * \sa SDL_CreateProcessWithProperties * \sa SDL_GetProcessProperties * \sa SDL_ReadProcess * \sa SDL_GetProcessInput * \sa SDL_GetProcessOutput */ typedef enum SDL_ProcessIO { SDL_PROCESS_STDIO_INHERITED, /**< The I/O stream is inherited from the application. */ SDL_PROCESS_STDIO_NULL, /**< The I/O stream is ignored. */ SDL_PROCESS_STDIO_APP, /**< The I/O stream is connected to a new SDL_IOStream that the application can read or write */ SDL_PROCESS_STDIO_REDIRECT /**< The I/O stream is redirected to an existing SDL_IOStream. */ } SDL_ProcessIO; /** * Create a new process with the specified properties. * * These are the supported properties: * * - `SDL_PROP_PROCESS_CREATE_ARGS_POINTER`: an array of strings containing * the program to run, any arguments, and a NULL pointer, e.g. const char * *args[] = { "myprogram", "argument", NULL }. This is a required property. * - `SDL_PROP_PROCESS_CREATE_ENVIRONMENT_POINTER`: an SDL_Environment * pointer. If this property is set, it will be the entire environment for * the process, otherwise the current environment is used. * - `SDL_PROP_PROCESS_CREATE_WORKING_DIRECTORY_STRING`: a UTF-8 encoded * string representing the working directory for the process, defaults to * the current working directory. * - `SDL_PROP_PROCESS_CREATE_STDIN_NUMBER`: an SDL_ProcessIO value describing * where standard input for the process comes from, defaults to * `SDL_PROCESS_STDIO_NULL`. * - `SDL_PROP_PROCESS_CREATE_STDIN_POINTER`: an SDL_IOStream pointer used for * standard input when `SDL_PROP_PROCESS_CREATE_STDIN_NUMBER` is set to * `SDL_PROCESS_STDIO_REDIRECT`. * - `SDL_PROP_PROCESS_CREATE_STDOUT_NUMBER`: an SDL_ProcessIO value * describing where standard output for the process goes to, defaults to * `SDL_PROCESS_STDIO_INHERITED`. * - `SDL_PROP_PROCESS_CREATE_STDOUT_POINTER`: an SDL_IOStream pointer used * for standard output when `SDL_PROP_PROCESS_CREATE_STDOUT_NUMBER` is set * to `SDL_PROCESS_STDIO_REDIRECT`. * - `SDL_PROP_PROCESS_CREATE_STDERR_NUMBER`: an SDL_ProcessIO value * describing where standard error for the process goes to, defaults to * `SDL_PROCESS_STDIO_INHERITED`. * - `SDL_PROP_PROCESS_CREATE_STDERR_POINTER`: an SDL_IOStream pointer used * for standard error when `SDL_PROP_PROCESS_CREATE_STDERR_NUMBER` is set to * `SDL_PROCESS_STDIO_REDIRECT`. * - `SDL_PROP_PROCESS_CREATE_STDERR_TO_STDOUT_BOOLEAN`: true if the error * output of the process should be redirected into the standard output of * the process. This property has no effect if * `SDL_PROP_PROCESS_CREATE_STDERR_NUMBER` is set. * - `SDL_PROP_PROCESS_CREATE_BACKGROUND_BOOLEAN`: true if the process should * run in the background. In this case the default input and output is * `SDL_PROCESS_STDIO_NULL` and the exitcode of the process is not * available, and will always be 0. * - `SDL_PROP_PROCESS_CREATE_CMDLINE_STRING`: a string containing the program * to run and any parameters. This string is passed directly to * `CreateProcess` on Windows, and does nothing on other platforms. This * property is only important if you want to start programs that does * non-standard command-line processing, and in most cases using * `SDL_PROP_PROCESS_CREATE_ARGS_POINTER` is sufficient. * * On POSIX platforms, wait() and waitpid(-1, ...) should not be called, and * SIGCHLD should not be ignored or handled because those would prevent SDL * from properly tracking the lifetime of the underlying process. You should * use SDL_WaitProcess() instead. * * \param props the properties to use. * \returns the newly created and running process, or NULL if the process * couldn't be created. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_CreateProcess * \sa SDL_GetProcessProperties * \sa SDL_ReadProcess * \sa SDL_GetProcessInput * \sa SDL_GetProcessOutput * \sa SDL_KillProcess * \sa SDL_WaitProcess * \sa SDL_DestroyProcess */ extern SDL_DECLSPEC SDL_Process * SDLCALL SDL_CreateProcessWithProperties(SDL_PropertiesID props); #define SDL_PROP_PROCESS_CREATE_ARGS_POINTER "SDL.process.create.args" #define SDL_PROP_PROCESS_CREATE_ENVIRONMENT_POINTER "SDL.process.create.environment" #define SDL_PROP_PROCESS_CREATE_WORKING_DIRECTORY_STRING "SDL.process.create.working_directory" #define SDL_PROP_PROCESS_CREATE_STDIN_NUMBER "SDL.process.create.stdin_option" #define SDL_PROP_PROCESS_CREATE_STDIN_POINTER "SDL.process.create.stdin_source" #define SDL_PROP_PROCESS_CREATE_STDOUT_NUMBER "SDL.process.create.stdout_option" #define SDL_PROP_PROCESS_CREATE_STDOUT_POINTER "SDL.process.create.stdout_source" #define SDL_PROP_PROCESS_CREATE_STDERR_NUMBER "SDL.process.create.stderr_option" #define SDL_PROP_PROCESS_CREATE_STDERR_POINTER "SDL.process.create.stderr_source" #define SDL_PROP_PROCESS_CREATE_STDERR_TO_STDOUT_BOOLEAN "SDL.process.create.stderr_to_stdout" #define SDL_PROP_PROCESS_CREATE_BACKGROUND_BOOLEAN "SDL.process.create.background" #define SDL_PROP_PROCESS_CREATE_CMDLINE_STRING "SDL.process.create.cmdline" /** * Get the properties associated with a process. * * The following read-only properties are provided by SDL: * * - `SDL_PROP_PROCESS_PID_NUMBER`: the process ID of the process. * - `SDL_PROP_PROCESS_STDIN_POINTER`: an SDL_IOStream that can be used to * write input to the process, if it was created with * `SDL_PROP_PROCESS_CREATE_STDIN_NUMBER` set to `SDL_PROCESS_STDIO_APP`. * - `SDL_PROP_PROCESS_STDOUT_POINTER`: a non-blocking SDL_IOStream that can * be used to read output from the process, if it was created with * `SDL_PROP_PROCESS_CREATE_STDOUT_NUMBER` set to `SDL_PROCESS_STDIO_APP`. * - `SDL_PROP_PROCESS_STDERR_POINTER`: a non-blocking SDL_IOStream that can * be used to read error output from the process, if it was created with * `SDL_PROP_PROCESS_CREATE_STDERR_NUMBER` set to `SDL_PROCESS_STDIO_APP`. * - `SDL_PROP_PROCESS_BACKGROUND_BOOLEAN`: true if the process is running in * the background. * * \param process the process to query. * \returns a valid property ID on success or 0 on failure; call * SDL_GetError() for more information. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_CreateProcess * \sa SDL_CreateProcessWithProperties */ extern SDL_DECLSPEC SDL_PropertiesID SDLCALL SDL_GetProcessProperties(SDL_Process *process); #define SDL_PROP_PROCESS_PID_NUMBER "SDL.process.pid" #define SDL_PROP_PROCESS_STDIN_POINTER "SDL.process.stdin" #define SDL_PROP_PROCESS_STDOUT_POINTER "SDL.process.stdout" #define SDL_PROP_PROCESS_STDERR_POINTER "SDL.process.stderr" #define SDL_PROP_PROCESS_BACKGROUND_BOOLEAN "SDL.process.background" /** * Read all the output from a process. * * If a process was created with I/O enabled, you can use this function to * read the output. This function blocks until the process is complete, * capturing all output, and providing the process exit code. * * The data is allocated with a zero byte at the end (null terminated) for * convenience. This extra byte is not included in the value reported via * `datasize`. * * The data should be freed with SDL_free(). * * \param process The process to read. * \param datasize a pointer filled in with the number of bytes read, may be * NULL. * \param exitcode a pointer filled in with the process exit code if the * process has exited, may be NULL. * \returns the data or NULL on failure; call SDL_GetError() for more * information. * * \threadsafety This function is not thread safe. * * \since This function is available since SDL 3.2.0. * * \sa SDL_CreateProcess * \sa SDL_CreateProcessWithProperties * \sa SDL_DestroyProcess */ extern SDL_DECLSPEC void * SDLCALL SDL_ReadProcess(SDL_Process *process, size_t *datasize, int *exitcode); /** * Get the SDL_IOStream associated with process standard input. * * The process must have been created with SDL_CreateProcess() and pipe_stdio * set to true, or with SDL_CreateProcessWithProperties() and * `SDL_PROP_PROCESS_CREATE_STDIN_NUMBER` set to `SDL_PROCESS_STDIO_APP`. * * Writing to this stream can return less data than expected if the process * hasn't read its input. It may be blocked waiting for its output to be read, * if so you may need to call SDL_GetProcessOutput() and read the output in * parallel with writing input. * * \param process The process to get the input stream for. * \returns the input stream or NULL on failure; call SDL_GetError() for more * information. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_CreateProcess * \sa SDL_CreateProcessWithProperties * \sa SDL_GetProcessOutput */ extern SDL_DECLSPEC SDL_IOStream * SDLCALL SDL_GetProcessInput(SDL_Process *process); /** * Get the SDL_IOStream associated with process standard output. * * The process must have been created with SDL_CreateProcess() and pipe_stdio * set to true, or with SDL_CreateProcessWithProperties() and * `SDL_PROP_PROCESS_CREATE_STDOUT_NUMBER` set to `SDL_PROCESS_STDIO_APP`. * * Reading from this stream can return 0 with SDL_GetIOStatus() returning * SDL_IO_STATUS_NOT_READY if no output is available yet. * * \param process The process to get the output stream for. * \returns the output stream or NULL on failure; call SDL_GetError() for more * information. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_CreateProcess * \sa SDL_CreateProcessWithProperties * \sa SDL_GetProcessInput */ extern SDL_DECLSPEC SDL_IOStream * SDLCALL SDL_GetProcessOutput(SDL_Process *process); /** * Stop a process. * * \param process The process to stop. * \param force true to terminate the process immediately, false to try to * stop the process gracefully. In general you should try to stop * the process gracefully first as terminating a process may * leave it with half-written data or in some other unstable * state. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety This function is not thread safe. * * \since This function is available since SDL 3.2.0. * * \sa SDL_CreateProcess * \sa SDL_CreateProcessWithProperties * \sa SDL_WaitProcess * \sa SDL_DestroyProcess */ extern SDL_DECLSPEC bool SDLCALL SDL_KillProcess(SDL_Process *process, bool force); /** * Wait for a process to finish. * * This can be called multiple times to get the status of a process. * * The exit code will be the exit code of the process if it terminates * normally, a negative signal if it terminated due to a signal, or -255 * otherwise. It will not be changed if the process is still running. * * If you create a process with standard output piped to the application * (`pipe_stdio` being true) then you should read all of the process output * before calling SDL_WaitProcess(). If you don't do this the process might be * blocked indefinitely waiting for output to be read and SDL_WaitProcess() * will never return true; * * \param process The process to wait for. * \param block If true, block until the process finishes; otherwise, report * on the process' status. * \param exitcode a pointer filled in with the process exit code if the * process has exited, may be NULL. * \returns true if the process exited, false otherwise. * * \threadsafety This function is not thread safe. * * \since This function is available since SDL 3.2.0. * * \sa SDL_CreateProcess * \sa SDL_CreateProcessWithProperties * \sa SDL_KillProcess * \sa SDL_DestroyProcess */ extern SDL_DECLSPEC bool SDLCALL SDL_WaitProcess(SDL_Process *process, bool block, int *exitcode); /** * Destroy a previously created process object. * * Note that this does not stop the process, just destroys the SDL object used * to track it. If you want to stop the process you should use * SDL_KillProcess(). * * \param process The process object to destroy. * * \threadsafety This function is not thread safe. * * \since This function is available since SDL 3.2.0. * * \sa SDL_CreateProcess * \sa SDL_CreateProcessWithProperties * \sa SDL_KillProcess */ extern SDL_DECLSPEC void SDLCALL SDL_DestroyProcess(SDL_Process *process); /* Ends C function definitions when using C++ */ #ifdef __cplusplus } #endif #include #endif /* SDL_process_h_ */ ================================================ FILE: deps/include/SDL3/SDL_properties.h ================================================ /* Simple DirectMedia Layer Copyright (C) 1997-2026 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ /** * # CategoryProperties * * A property is a variable that can be created and retrieved by name at * runtime. * * All properties are part of a property group (SDL_PropertiesID). A property * group can be created with the SDL_CreateProperties function and destroyed * with the SDL_DestroyProperties function. * * Properties can be added to and retrieved from a property group through the * following functions: * * - SDL_SetPointerProperty and SDL_GetPointerProperty operate on `void*` * pointer types. * - SDL_SetStringProperty and SDL_GetStringProperty operate on string types. * - SDL_SetNumberProperty and SDL_GetNumberProperty operate on signed 64-bit * integer types. * - SDL_SetFloatProperty and SDL_GetFloatProperty operate on floating point * types. * - SDL_SetBooleanProperty and SDL_GetBooleanProperty operate on boolean * types. * * Properties can be removed from a group by using SDL_ClearProperty. */ #ifndef SDL_properties_h_ #define SDL_properties_h_ #include #include #include /* Set up for C function definitions, even when using C++ */ #ifdef __cplusplus extern "C" { #endif /** * An ID that represents a properties set. * * \since This datatype is available since SDL 3.2.0. */ typedef Uint32 SDL_PropertiesID; /** * SDL property type * * \since This enum is available since SDL 3.2.0. */ typedef enum SDL_PropertyType { SDL_PROPERTY_TYPE_INVALID, SDL_PROPERTY_TYPE_POINTER, SDL_PROPERTY_TYPE_STRING, SDL_PROPERTY_TYPE_NUMBER, SDL_PROPERTY_TYPE_FLOAT, SDL_PROPERTY_TYPE_BOOLEAN } SDL_PropertyType; /** * A generic property for naming things. * * This property is intended to be added to any SDL_PropertiesID that needs a * generic name associated with the property set. It is not guaranteed that * any property set will include this key, but it is convenient to have a * standard key that any piece of code could reasonably agree to use. * * For example, the properties associated with an SDL_Texture might have a * name string of "player sprites", or an SDL_AudioStream might have * "background music", etc. This might also be useful for an SDL_IOStream to * list the path to its asset. * * There is no format for the value set with this key; it is expected to be * human-readable and informational in nature, possibly for logging or * debugging purposes. * * SDL does not currently set this property on any objects it creates, but * this may change in later versions; it is currently expected that apps and * external libraries will take advantage of it, when appropriate. * * \since This macro is available since SDL 3.4.0. */ #define SDL_PROP_NAME_STRING "SDL.name" /** * Get the global SDL properties. * * \returns a valid property ID on success or 0 on failure; call * SDL_GetError() for more information. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC SDL_PropertiesID SDLCALL SDL_GetGlobalProperties(void); /** * Create a group of properties. * * All properties are automatically destroyed when SDL_Quit() is called. * * \returns an ID for a new group of properties, or 0 on failure; call * SDL_GetError() for more information. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_DestroyProperties */ extern SDL_DECLSPEC SDL_PropertiesID SDLCALL SDL_CreateProperties(void); /** * Copy a group of properties. * * Copy all the properties from one group of properties to another, with the * exception of properties requiring cleanup (set using * SDL_SetPointerPropertyWithCleanup()), which will not be copied. Any * property that already exists on `dst` will be overwritten. * * \param src the properties to copy. * \param dst the destination properties. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety It is safe to call this function from any thread. This * function acquires simultaneous mutex locks on both the source * and destination property sets. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC bool SDLCALL SDL_CopyProperties(SDL_PropertiesID src, SDL_PropertiesID dst); /** * Lock a group of properties. * * Obtain a multi-threaded lock for these properties. Other threads will wait * while trying to lock these properties until they are unlocked. Properties * must be unlocked before they are destroyed. * * The lock is automatically taken when setting individual properties, this * function is only needed when you want to set several properties atomically * or want to guarantee that properties being queried aren't freed in another * thread. * * \param props the properties to lock. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_UnlockProperties */ extern SDL_DECLSPEC bool SDLCALL SDL_LockProperties(SDL_PropertiesID props); /** * Unlock a group of properties. * * \param props the properties to unlock. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_LockProperties */ extern SDL_DECLSPEC void SDLCALL SDL_UnlockProperties(SDL_PropertiesID props); /** * A callback used to free resources when a property is deleted. * * This should release any resources associated with `value` that are no * longer needed. * * This callback is set per-property. Different properties in the same group * can have different cleanup callbacks. * * This callback will be called _during_ SDL_SetPointerPropertyWithCleanup if * the function fails for any reason. * * \param userdata an app-defined pointer passed to the callback. * \param value the pointer assigned to the property to clean up. * * \threadsafety This callback may fire without any locks held; if this is a * concern, the app should provide its own locking. * * \since This datatype is available since SDL 3.2.0. * * \sa SDL_SetPointerPropertyWithCleanup */ typedef void (SDLCALL *SDL_CleanupPropertyCallback)(void *userdata, void *value); /** * Set a pointer property in a group of properties with a cleanup function * that is called when the property is deleted. * * The cleanup function is also called if setting the property fails for any * reason. * * For simply setting basic data types, like numbers, bools, or strings, use * SDL_SetNumberProperty, SDL_SetBooleanProperty, or SDL_SetStringProperty * instead, as those functions will handle cleanup on your behalf. This * function is only for more complex, custom data. * * \param props the properties to modify. * \param name the name of the property to modify. * \param value the new value of the property, or NULL to delete the property. * \param cleanup the function to call when this property is deleted, or NULL * if no cleanup is necessary. * \param userdata a pointer that is passed to the cleanup function. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetPointerProperty * \sa SDL_SetPointerProperty * \sa SDL_CleanupPropertyCallback */ extern SDL_DECLSPEC bool SDLCALL SDL_SetPointerPropertyWithCleanup(SDL_PropertiesID props, const char *name, void *value, SDL_CleanupPropertyCallback cleanup, void *userdata); /** * Set a pointer property in a group of properties. * * \param props the properties to modify. * \param name the name of the property to modify. * \param value the new value of the property, or NULL to delete the property. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetPointerProperty * \sa SDL_HasProperty * \sa SDL_SetBooleanProperty * \sa SDL_SetFloatProperty * \sa SDL_SetNumberProperty * \sa SDL_SetPointerPropertyWithCleanup * \sa SDL_SetStringProperty */ extern SDL_DECLSPEC bool SDLCALL SDL_SetPointerProperty(SDL_PropertiesID props, const char *name, void *value); /** * Set a string property in a group of properties. * * This function makes a copy of the string; the caller does not have to * preserve the data after this call completes. * * \param props the properties to modify. * \param name the name of the property to modify. * \param value the new value of the property, or NULL to delete the property. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetStringProperty */ extern SDL_DECLSPEC bool SDLCALL SDL_SetStringProperty(SDL_PropertiesID props, const char *name, const char *value); /** * Set an integer property in a group of properties. * * \param props the properties to modify. * \param name the name of the property to modify. * \param value the new value of the property. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetNumberProperty */ extern SDL_DECLSPEC bool SDLCALL SDL_SetNumberProperty(SDL_PropertiesID props, const char *name, Sint64 value); /** * Set a floating point property in a group of properties. * * \param props the properties to modify. * \param name the name of the property to modify. * \param value the new value of the property. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetFloatProperty */ extern SDL_DECLSPEC bool SDLCALL SDL_SetFloatProperty(SDL_PropertiesID props, const char *name, float value); /** * Set a boolean property in a group of properties. * * \param props the properties to modify. * \param name the name of the property to modify. * \param value the new value of the property. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetBooleanProperty */ extern SDL_DECLSPEC bool SDLCALL SDL_SetBooleanProperty(SDL_PropertiesID props, const char *name, bool value); /** * Return whether a property exists in a group of properties. * * \param props the properties to query. * \param name the name of the property to query. * \returns true if the property exists, or false if it doesn't. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetPropertyType */ extern SDL_DECLSPEC bool SDLCALL SDL_HasProperty(SDL_PropertiesID props, const char *name); /** * Get the type of a property in a group of properties. * * \param props the properties to query. * \param name the name of the property to query. * \returns the type of the property, or SDL_PROPERTY_TYPE_INVALID if it is * not set. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_HasProperty */ extern SDL_DECLSPEC SDL_PropertyType SDLCALL SDL_GetPropertyType(SDL_PropertiesID props, const char *name); /** * Get a pointer property from a group of properties. * * By convention, the names of properties that SDL exposes on objects will * start with "SDL.", and properties that SDL uses internally will start with * "SDL.internal.". These should be considered read-only and should not be * modified by applications. * * \param props the properties to query. * \param name the name of the property to query. * \param default_value the default value of the property. * \returns the value of the property, or `default_value` if it is not set or * not a pointer property. * * \threadsafety It is safe to call this function from any thread, although * the data returned is not protected and could potentially be * freed if you call SDL_SetPointerProperty() or * SDL_ClearProperty() on these properties from another thread. * If you need to avoid this, use SDL_LockProperties() and * SDL_UnlockProperties(). * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetBooleanProperty * \sa SDL_GetFloatProperty * \sa SDL_GetNumberProperty * \sa SDL_GetPropertyType * \sa SDL_GetStringProperty * \sa SDL_HasProperty * \sa SDL_SetPointerProperty */ extern SDL_DECLSPEC void * SDLCALL SDL_GetPointerProperty(SDL_PropertiesID props, const char *name, void *default_value); /** * Get a string property from a group of properties. * * \param props the properties to query. * \param name the name of the property to query. * \param default_value the default value of the property. * \returns the value of the property, or `default_value` if it is not set or * not a string property. * * \threadsafety It is safe to call this function from any thread, although * the data returned is not protected and could potentially be * freed if you call SDL_SetStringProperty() or * SDL_ClearProperty() on these properties from another thread. * If you need to avoid this, use SDL_LockProperties() and * SDL_UnlockProperties(). * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetPropertyType * \sa SDL_HasProperty * \sa SDL_SetStringProperty */ extern SDL_DECLSPEC const char * SDLCALL SDL_GetStringProperty(SDL_PropertiesID props, const char *name, const char *default_value); /** * Get a number property from a group of properties. * * You can use SDL_GetPropertyType() to query whether the property exists and * is a number property. * * \param props the properties to query. * \param name the name of the property to query. * \param default_value the default value of the property. * \returns the value of the property, or `default_value` if it is not set or * not a number property. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetPropertyType * \sa SDL_HasProperty * \sa SDL_SetNumberProperty */ extern SDL_DECLSPEC Sint64 SDLCALL SDL_GetNumberProperty(SDL_PropertiesID props, const char *name, Sint64 default_value); /** * Get a floating point property from a group of properties. * * You can use SDL_GetPropertyType() to query whether the property exists and * is a floating point property. * * \param props the properties to query. * \param name the name of the property to query. * \param default_value the default value of the property. * \returns the value of the property, or `default_value` if it is not set or * not a float property. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetPropertyType * \sa SDL_HasProperty * \sa SDL_SetFloatProperty */ extern SDL_DECLSPEC float SDLCALL SDL_GetFloatProperty(SDL_PropertiesID props, const char *name, float default_value); /** * Get a boolean property from a group of properties. * * You can use SDL_GetPropertyType() to query whether the property exists and * is a boolean property. * * \param props the properties to query. * \param name the name of the property to query. * \param default_value the default value of the property. * \returns the value of the property, or `default_value` if it is not set or * not a boolean property. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetPropertyType * \sa SDL_HasProperty * \sa SDL_SetBooleanProperty */ extern SDL_DECLSPEC bool SDLCALL SDL_GetBooleanProperty(SDL_PropertiesID props, const char *name, bool default_value); /** * Clear a property from a group of properties. * * \param props the properties to modify. * \param name the name of the property to clear. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC bool SDLCALL SDL_ClearProperty(SDL_PropertiesID props, const char *name); /** * A callback used to enumerate all the properties in a group of properties. * * This callback is called from SDL_EnumerateProperties(), and is called once * per property in the set. * * \param userdata an app-defined pointer passed to the callback. * \param props the SDL_PropertiesID that is being enumerated. * \param name the next property name in the enumeration. * * \threadsafety SDL_EnumerateProperties holds a lock on `props` during this * callback. * * \since This datatype is available since SDL 3.2.0. * * \sa SDL_EnumerateProperties */ typedef void (SDLCALL *SDL_EnumeratePropertiesCallback)(void *userdata, SDL_PropertiesID props, const char *name); /** * Enumerate the properties contained in a group of properties. * * The callback function is called for each property in the group of * properties. The properties are locked during enumeration. * * \param props the properties to query. * \param callback the function to call for each property. * \param userdata a pointer that is passed to `callback`. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC bool SDLCALL SDL_EnumerateProperties(SDL_PropertiesID props, SDL_EnumeratePropertiesCallback callback, void *userdata); /** * Destroy a group of properties. * * All properties are deleted and their cleanup functions will be called, if * any. * * \param props the properties to destroy. * * \threadsafety This function should not be called while these properties are * locked or other threads might be setting or getting values * from these properties. * * \since This function is available since SDL 3.2.0. * * \sa SDL_CreateProperties */ extern SDL_DECLSPEC void SDLCALL SDL_DestroyProperties(SDL_PropertiesID props); /* Ends C function definitions when using C++ */ #ifdef __cplusplus } #endif #include #endif /* SDL_properties_h_ */ ================================================ FILE: deps/include/SDL3/SDL_rect.h ================================================ /* Simple DirectMedia Layer Copyright (C) 1997-2026 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ /** * # CategoryRect * * Some helper functions for managing rectangles and 2D points, in both * integer and floating point versions. */ #ifndef SDL_rect_h_ #define SDL_rect_h_ #include #include #include /* Set up for C function definitions, even when using C++ */ #ifdef __cplusplus extern "C" { #endif /** * The structure that defines a point (using integers). * * \since This struct is available since SDL 3.2.0. * * \sa SDL_GetRectEnclosingPoints * \sa SDL_PointInRect */ typedef struct SDL_Point { int x; int y; } SDL_Point; /** * The structure that defines a point (using floating point values). * * \since This struct is available since SDL 3.2.0. * * \sa SDL_GetRectEnclosingPointsFloat * \sa SDL_PointInRectFloat */ typedef struct SDL_FPoint { float x; float y; } SDL_FPoint; /** * A rectangle, with the origin at the upper left (using integers). * * \since This struct is available since SDL 3.2.0. * * \sa SDL_RectEmpty * \sa SDL_RectsEqual * \sa SDL_HasRectIntersection * \sa SDL_GetRectIntersection * \sa SDL_GetRectAndLineIntersection * \sa SDL_GetRectUnion * \sa SDL_GetRectEnclosingPoints */ typedef struct SDL_Rect { int x, y; int w, h; } SDL_Rect; /** * A rectangle stored using floating point values. * * The origin of the coordinate space is in the top-left, with increasing * values moving down and right. The properties `x` and `y` represent the * coordinates of the top-left corner of the rectangle. * * \since This struct is available since SDL 3.2.0. * * \sa SDL_RectEmptyFloat * \sa SDL_RectsEqualFloat * \sa SDL_RectsEqualEpsilon * \sa SDL_HasRectIntersectionFloat * \sa SDL_GetRectIntersectionFloat * \sa SDL_GetRectAndLineIntersectionFloat * \sa SDL_GetRectUnionFloat * \sa SDL_GetRectEnclosingPointsFloat * \sa SDL_PointInRectFloat */ typedef struct SDL_FRect { float x; float y; float w; float h; } SDL_FRect; /** * Convert an SDL_Rect to SDL_FRect * * \param rect a pointer to an SDL_Rect. * \param frect a pointer filled in with the floating point representation of * `rect`. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. */ SDL_FORCE_INLINE void SDL_RectToFRect(const SDL_Rect *rect, SDL_FRect *frect) { frect->x = SDL_static_cast(float, rect->x); frect->y = SDL_static_cast(float, rect->y); frect->w = SDL_static_cast(float, rect->w); frect->h = SDL_static_cast(float, rect->h); } /** * Determine whether a point resides inside a rectangle. * * A point is considered part of a rectangle if both `p` and `r` are not NULL, * and `p`'s x and y coordinates are >= to the rectangle's top left corner, * and < the rectangle's x+w and y+h. So a 1x1 rectangle considers point (0,0) * as "inside" and (0,1) as not. * * Note that this is a forced-inline function in a header, and not a public * API function available in the SDL library (which is to say, the code is * embedded in the calling program and the linker and dynamic loader will not * be able to find this function inside SDL itself). * * \param p the point to test. * \param r the rectangle to test. * \returns true if `p` is contained by `r`, false otherwise. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. */ SDL_FORCE_INLINE bool SDL_PointInRect(const SDL_Point *p, const SDL_Rect *r) { return ( p && r && (p->x >= r->x) && (p->x < (r->x + r->w)) && (p->y >= r->y) && (p->y < (r->y + r->h)) ) ? true : false; } /** * Determine whether a rectangle has no area. * * A rectangle is considered "empty" for this function if `r` is NULL, or if * `r`'s width and/or height are <= 0. * * Note that this is a forced-inline function in a header, and not a public * API function available in the SDL library (which is to say, the code is * embedded in the calling program and the linker and dynamic loader will not * be able to find this function inside SDL itself). * * \param r the rectangle to test. * \returns true if the rectangle is "empty", false otherwise. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. */ SDL_FORCE_INLINE bool SDL_RectEmpty(const SDL_Rect *r) { return ((!r) || (r->w <= 0) || (r->h <= 0)) ? true : false; } /** * Determine whether two rectangles are equal. * * Rectangles are considered equal if both are not NULL and each of their x, * y, width and height match. * * Note that this is a forced-inline function in a header, and not a public * API function available in the SDL library (which is to say, the code is * embedded in the calling program and the linker and dynamic loader will not * be able to find this function inside SDL itself). * * \param a the first rectangle to test. * \param b the second rectangle to test. * \returns true if the rectangles are equal, false otherwise. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. */ SDL_FORCE_INLINE bool SDL_RectsEqual(const SDL_Rect *a, const SDL_Rect *b) { return (a && b && (a->x == b->x) && (a->y == b->y) && (a->w == b->w) && (a->h == b->h)) ? true : false; } /** * Determine whether two rectangles intersect. * * If either pointer is NULL the function will return false. * * \param A an SDL_Rect structure representing the first rectangle. * \param B an SDL_Rect structure representing the second rectangle. * \returns true if there is an intersection, false otherwise. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetRectIntersection */ extern SDL_DECLSPEC bool SDLCALL SDL_HasRectIntersection(const SDL_Rect *A, const SDL_Rect *B); /** * Calculate the intersection of two rectangles. * * If `result` is NULL then this function will return false. * * \param A an SDL_Rect structure representing the first rectangle. * \param B an SDL_Rect structure representing the second rectangle. * \param result an SDL_Rect structure filled in with the intersection of * rectangles `A` and `B`. * \returns true if there is an intersection, false otherwise. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_HasRectIntersection */ extern SDL_DECLSPEC bool SDLCALL SDL_GetRectIntersection(const SDL_Rect *A, const SDL_Rect *B, SDL_Rect *result); /** * Calculate the union of two rectangles. * * \param A an SDL_Rect structure representing the first rectangle. * \param B an SDL_Rect structure representing the second rectangle. * \param result an SDL_Rect structure filled in with the union of rectangles * `A` and `B`. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC bool SDLCALL SDL_GetRectUnion(const SDL_Rect *A, const SDL_Rect *B, SDL_Rect *result); /** * Calculate a minimal rectangle enclosing a set of points. * * If `clip` is not NULL then only points inside of the clipping rectangle are * considered. * * \param points an array of SDL_Point structures representing points to be * enclosed. * \param count the number of structures in the `points` array. * \param clip an SDL_Rect used for clipping or NULL to enclose all points. * \param result an SDL_Rect structure filled in with the minimal enclosing * rectangle. * \returns true if any points were enclosed or false if all the points were * outside of the clipping rectangle. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC bool SDLCALL SDL_GetRectEnclosingPoints(const SDL_Point *points, int count, const SDL_Rect *clip, SDL_Rect *result); /** * Calculate the intersection of a rectangle and line segment. * * This function is used to clip a line segment to a rectangle. A line segment * contained entirely within the rectangle or that does not intersect will * remain unchanged. A line segment that crosses the rectangle at either or * both ends will be clipped to the boundary of the rectangle and the new * coordinates saved in `X1`, `Y1`, `X2`, and/or `Y2` as necessary. * * \param rect an SDL_Rect structure representing the rectangle to intersect. * \param X1 a pointer to the starting X-coordinate of the line. * \param Y1 a pointer to the starting Y-coordinate of the line. * \param X2 a pointer to the ending X-coordinate of the line. * \param Y2 a pointer to the ending Y-coordinate of the line. * \returns true if there is an intersection, false otherwise. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC bool SDLCALL SDL_GetRectAndLineIntersection(const SDL_Rect *rect, int *X1, int *Y1, int *X2, int *Y2); /* SDL_FRect versions... */ /** * Determine whether a point resides inside a floating point rectangle. * * A point is considered part of a rectangle if both `p` and `r` are not NULL, * and `p`'s x and y coordinates are >= to the rectangle's top left corner, * and <= the rectangle's x+w and y+h. So a 1x1 rectangle considers point * (0,0) and (0,1) as "inside" and (0,2) as not. * * Note that this is a forced-inline function in a header, and not a public * API function available in the SDL library (which is to say, the code is * embedded in the calling program and the linker and dynamic loader will not * be able to find this function inside SDL itself). * * \param p the point to test. * \param r the rectangle to test. * \returns true if `p` is contained by `r`, false otherwise. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. */ SDL_FORCE_INLINE bool SDL_PointInRectFloat(const SDL_FPoint *p, const SDL_FRect *r) { return ( p && r && (p->x >= r->x) && (p->x <= (r->x + r->w)) && (p->y >= r->y) && (p->y <= (r->y + r->h)) ) ? true : false; } /** * Determine whether a floating point rectangle takes no space. * * A rectangle is considered "empty" for this function if `r` is NULL, or if * `r`'s width and/or height are < 0.0f. * * Note that this is a forced-inline function in a header, and not a public * API function available in the SDL library (which is to say, the code is * embedded in the calling program and the linker and dynamic loader will not * be able to find this function inside SDL itself). * * \param r the rectangle to test. * \returns true if the rectangle is "empty", false otherwise. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. */ SDL_FORCE_INLINE bool SDL_RectEmptyFloat(const SDL_FRect *r) { return ((!r) || (r->w < 0.0f) || (r->h < 0.0f)) ? true : false; } /** * Determine whether two floating point rectangles are equal, within some * given epsilon. * * Rectangles are considered equal if both are not NULL and each of their x, * y, width and height are within `epsilon` of each other. If you don't know * what value to use for `epsilon`, you should call the SDL_RectsEqualFloat * function instead. * * Note that this is a forced-inline function in a header, and not a public * API function available in the SDL library (which is to say, the code is * embedded in the calling program and the linker and dynamic loader will not * be able to find this function inside SDL itself). * * \param a the first rectangle to test. * \param b the second rectangle to test. * \param epsilon the epsilon value for comparison. * \returns true if the rectangles are equal, false otherwise. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_RectsEqualFloat */ SDL_FORCE_INLINE bool SDL_RectsEqualEpsilon(const SDL_FRect *a, const SDL_FRect *b, float epsilon) { return (a && b && ((a == b) || ((SDL_fabsf(a->x - b->x) <= epsilon) && (SDL_fabsf(a->y - b->y) <= epsilon) && (SDL_fabsf(a->w - b->w) <= epsilon) && (SDL_fabsf(a->h - b->h) <= epsilon)))) ? true : false; } /** * Determine whether two floating point rectangles are equal, within a default * epsilon. * * Rectangles are considered equal if both are not NULL and each of their x, * y, width and height are within SDL_FLT_EPSILON of each other. This is often * a reasonable way to compare two floating point rectangles and deal with the * slight precision variations in floating point calculations that tend to pop * up. * * Note that this is a forced-inline function in a header, and not a public * API function available in the SDL library (which is to say, the code is * embedded in the calling program and the linker and dynamic loader will not * be able to find this function inside SDL itself). * * \param a the first rectangle to test. * \param b the second rectangle to test. * \returns true if the rectangles are equal, false otherwise. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_RectsEqualEpsilon */ SDL_FORCE_INLINE bool SDL_RectsEqualFloat(const SDL_FRect *a, const SDL_FRect *b) { return SDL_RectsEqualEpsilon(a, b, SDL_FLT_EPSILON); } /** * Determine whether two rectangles intersect with float precision. * * If either pointer is NULL the function will return false. * * \param A an SDL_FRect structure representing the first rectangle. * \param B an SDL_FRect structure representing the second rectangle. * \returns true if there is an intersection, false otherwise. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetRectIntersectionFloat */ extern SDL_DECLSPEC bool SDLCALL SDL_HasRectIntersectionFloat(const SDL_FRect *A, const SDL_FRect *B); /** * Calculate the intersection of two rectangles with float precision. * * If `result` is NULL then this function will return false. * * \param A an SDL_FRect structure representing the first rectangle. * \param B an SDL_FRect structure representing the second rectangle. * \param result an SDL_FRect structure filled in with the intersection of * rectangles `A` and `B`. * \returns true if there is an intersection, false otherwise. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_HasRectIntersectionFloat */ extern SDL_DECLSPEC bool SDLCALL SDL_GetRectIntersectionFloat(const SDL_FRect *A, const SDL_FRect *B, SDL_FRect *result); /** * Calculate the union of two rectangles with float precision. * * \param A an SDL_FRect structure representing the first rectangle. * \param B an SDL_FRect structure representing the second rectangle. * \param result an SDL_FRect structure filled in with the union of rectangles * `A` and `B`. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC bool SDLCALL SDL_GetRectUnionFloat(const SDL_FRect *A, const SDL_FRect *B, SDL_FRect *result); /** * Calculate a minimal rectangle enclosing a set of points with float * precision. * * If `clip` is not NULL then only points inside of the clipping rectangle are * considered. * * \param points an array of SDL_FPoint structures representing points to be * enclosed. * \param count the number of structures in the `points` array. * \param clip an SDL_FRect used for clipping or NULL to enclose all points. * \param result an SDL_FRect structure filled in with the minimal enclosing * rectangle. * \returns true if any points were enclosed or false if all the points were * outside of the clipping rectangle. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC bool SDLCALL SDL_GetRectEnclosingPointsFloat(const SDL_FPoint *points, int count, const SDL_FRect *clip, SDL_FRect *result); /** * Calculate the intersection of a rectangle and line segment with float * precision. * * This function is used to clip a line segment to a rectangle. A line segment * contained entirely within the rectangle or that does not intersect will * remain unchanged. A line segment that crosses the rectangle at either or * both ends will be clipped to the boundary of the rectangle and the new * coordinates saved in `X1`, `Y1`, `X2`, and/or `Y2` as necessary. * * \param rect an SDL_FRect structure representing the rectangle to intersect. * \param X1 a pointer to the starting X-coordinate of the line. * \param Y1 a pointer to the starting Y-coordinate of the line. * \param X2 a pointer to the ending X-coordinate of the line. * \param Y2 a pointer to the ending Y-coordinate of the line. * \returns true if there is an intersection, false otherwise. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC bool SDLCALL SDL_GetRectAndLineIntersectionFloat(const SDL_FRect *rect, float *X1, float *Y1, float *X2, float *Y2); /* Ends C function definitions when using C++ */ #ifdef __cplusplus } #endif #include #endif /* SDL_rect_h_ */ ================================================ FILE: deps/include/SDL3/SDL_render.h ================================================ /* Simple DirectMedia Layer Copyright (C) 1997-2026 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ /** * # CategoryRender * * Header file for SDL 2D rendering functions. * * This API supports the following features: * * - single pixel points * - single pixel lines * - filled rectangles * - texture images * - 2D polygons * * The primitives may be drawn in opaque, blended, or additive modes. * * The texture images may be drawn in opaque, blended, or additive modes. They * can have an additional color tint or alpha modulation applied to them, and * may also be stretched with linear interpolation. * * This API is designed to accelerate simple 2D operations. You may want more * functionality such as 3D polygons and particle effects, and in that case * you should use SDL's OpenGL/Direct3D support, the SDL3 GPU API, or one of * the many good 3D engines. * * These functions must be called from the main thread. See this bug for * details: https://github.com/libsdl-org/SDL/issues/986 */ #ifndef SDL_render_h_ #define SDL_render_h_ #include #include #include #include #include #include #include #include #include #include #include /* Set up for C function definitions, even when using C++ */ #ifdef __cplusplus extern "C" { #endif /** * The name of the software renderer. * * \since This macro is available since SDL 3.2.0. */ #define SDL_SOFTWARE_RENDERER "software" /** * The name of the GPU renderer. * * \since This macro is available since SDL 3.4.0. */ #define SDL_GPU_RENDERER "gpu" /** * Vertex structure. * * \since This struct is available since SDL 3.2.0. */ typedef struct SDL_Vertex { SDL_FPoint position; /**< Vertex position, in SDL_Renderer coordinates */ SDL_FColor color; /**< Vertex color */ SDL_FPoint tex_coord; /**< Normalized texture coordinates, if needed */ } SDL_Vertex; /** * The access pattern allowed for a texture. * * \since This enum is available since SDL 3.2.0. */ typedef enum SDL_TextureAccess { SDL_TEXTUREACCESS_STATIC, /**< Changes rarely, not lockable */ SDL_TEXTUREACCESS_STREAMING, /**< Changes frequently, lockable */ SDL_TEXTUREACCESS_TARGET /**< Texture can be used as a render target */ } SDL_TextureAccess; /** * The addressing mode for a texture when used in SDL_RenderGeometry(). * * This affects how texture coordinates are interpreted outside of [0, 1] * * Texture wrapping is always supported for power of two texture sizes, and is * supported for other texture sizes if * SDL_PROP_RENDERER_TEXTURE_WRAPPING_BOOLEAN is set to true. * * \since This enum is available since SDL 3.4.0. */ typedef enum SDL_TextureAddressMode { SDL_TEXTURE_ADDRESS_INVALID = -1, SDL_TEXTURE_ADDRESS_AUTO, /**< Wrapping is enabled if texture coordinates are outside [0, 1], this is the default */ SDL_TEXTURE_ADDRESS_CLAMP, /**< Texture coordinates are clamped to the [0, 1] range */ SDL_TEXTURE_ADDRESS_WRAP /**< The texture is repeated (tiled) */ } SDL_TextureAddressMode; /** * How the logical size is mapped to the output. * * \since This enum is available since SDL 3.2.0. */ typedef enum SDL_RendererLogicalPresentation { SDL_LOGICAL_PRESENTATION_DISABLED, /**< There is no logical size in effect */ SDL_LOGICAL_PRESENTATION_STRETCH, /**< The rendered content is stretched to the output resolution */ SDL_LOGICAL_PRESENTATION_LETTERBOX, /**< The rendered content is fit to the largest dimension and the other dimension is letterboxed with the clear color */ SDL_LOGICAL_PRESENTATION_OVERSCAN, /**< The rendered content is fit to the smallest dimension and the other dimension extends beyond the output bounds */ SDL_LOGICAL_PRESENTATION_INTEGER_SCALE /**< The rendered content is scaled up by integer multiples to fit the output resolution */ } SDL_RendererLogicalPresentation; /** * A structure representing rendering state * * \since This struct is available since SDL 3.2.0. */ typedef struct SDL_Renderer SDL_Renderer; #ifndef SDL_INTERNAL /** * An efficient driver-specific representation of pixel data * * \since This struct is available since SDL 3.2.0. * * \sa SDL_CreateTexture * \sa SDL_CreateTextureFromSurface * \sa SDL_CreateTextureWithProperties * \sa SDL_DestroyTexture */ struct SDL_Texture { SDL_PixelFormat format; /**< The format of the texture, read-only */ int w; /**< The width of the texture, read-only. */ int h; /**< The height of the texture, read-only. */ int refcount; /**< Application reference count, used when freeing texture */ }; #endif /* !SDL_INTERNAL */ typedef struct SDL_Texture SDL_Texture; /* Function prototypes */ /** * Get the number of 2D rendering drivers available for the current display. * * A render driver is a set of code that handles rendering and texture * management on a particular display. Normally there is only one, but some * drivers may have several available with different capabilities. * * There may be none if SDL was compiled without render support. * * \returns the number of built in render drivers. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_CreateRenderer * \sa SDL_GetRenderDriver */ extern SDL_DECLSPEC int SDLCALL SDL_GetNumRenderDrivers(void); /** * Use this function to get the name of a built in 2D rendering driver. * * The list of rendering drivers is given in the order that they are normally * initialized by default; the drivers that seem more reasonable to choose * first (as far as the SDL developers believe) are earlier in the list. * * The names of drivers are all simple, low-ASCII identifiers, like "opengl", * "direct3d12" or "metal". These never have Unicode characters, and are not * meant to be proper names. * * \param index the index of the rendering driver; the value ranges from 0 to * SDL_GetNumRenderDrivers() - 1. * \returns the name of the rendering driver at the requested index, or NULL * if an invalid index was specified. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetNumRenderDrivers */ extern SDL_DECLSPEC const char * SDLCALL SDL_GetRenderDriver(int index); /** * Create a window and default renderer. * * \param title the title of the window, in UTF-8 encoding. * \param width the width of the window. * \param height the height of the window. * \param window_flags the flags used to create the window (see * SDL_CreateWindow()). * \param window a pointer filled with the window, or NULL on error. * \param renderer a pointer filled with the renderer, or NULL on error. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_CreateRenderer * \sa SDL_CreateWindow */ extern SDL_DECLSPEC bool SDLCALL SDL_CreateWindowAndRenderer(const char *title, int width, int height, SDL_WindowFlags window_flags, SDL_Window **window, SDL_Renderer **renderer); /** * Create a 2D rendering context for a window. * * If you want a specific renderer, you can specify its name here. A list of * available renderers can be obtained by calling SDL_GetRenderDriver() * multiple times, with indices from 0 to SDL_GetNumRenderDrivers()-1. If you * don't need a specific renderer, specify NULL and SDL will attempt to choose * the best option for you, based on what is available on the user's system. * * If `name` is a comma-separated list, SDL will try each name, in the order * listed, until one succeeds or all of them fail. * * By default the rendering size matches the window size in pixels, but you * can call SDL_SetRenderLogicalPresentation() to change the content size and * scaling options. * * \param window the window where rendering is displayed. * \param name the name of the rendering driver to initialize, or NULL to let * SDL choose one. * \returns a valid rendering context or NULL if there was an error; call * SDL_GetError() for more information. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_CreateRendererWithProperties * \sa SDL_CreateSoftwareRenderer * \sa SDL_DestroyRenderer * \sa SDL_GetNumRenderDrivers * \sa SDL_GetRenderDriver * \sa SDL_GetRendererName */ extern SDL_DECLSPEC SDL_Renderer * SDLCALL SDL_CreateRenderer(SDL_Window *window, const char *name); /** * Create a 2D rendering context for a window, with the specified properties. * * These are the supported properties: * * - `SDL_PROP_RENDERER_CREATE_NAME_STRING`: the name of the rendering driver * to use, if a specific one is desired * - `SDL_PROP_RENDERER_CREATE_WINDOW_POINTER`: the window where rendering is * displayed, required if this isn't a software renderer using a surface * - `SDL_PROP_RENDERER_CREATE_SURFACE_POINTER`: the surface where rendering * is displayed, if you want a software renderer without a window * - `SDL_PROP_RENDERER_CREATE_OUTPUT_COLORSPACE_NUMBER`: an SDL_Colorspace * value describing the colorspace for output to the display, defaults to * SDL_COLORSPACE_SRGB. The direct3d11, direct3d12, and metal renderers * support SDL_COLORSPACE_SRGB_LINEAR, which is a linear color space and * supports HDR output. If you select SDL_COLORSPACE_SRGB_LINEAR, drawing * still uses the sRGB colorspace, but values can go beyond 1.0 and float * (linear) format textures can be used for HDR content. * - `SDL_PROP_RENDERER_CREATE_PRESENT_VSYNC_NUMBER`: non-zero if you want * present synchronized with the refresh rate. This property can take any * value that is supported by SDL_SetRenderVSync() for the renderer. * * With the SDL GPU renderer (since SDL 3.4.0): * * - `SDL_PROP_RENDERER_CREATE_GPU_DEVICE_POINTER`: the device to use with the * renderer, optional. * - `SDL_PROP_RENDERER_CREATE_GPU_SHADERS_SPIRV_BOOLEAN`: the app is able to * provide SPIR-V shaders to SDL_GPURenderState, optional. * - `SDL_PROP_RENDERER_CREATE_GPU_SHADERS_DXIL_BOOLEAN`: the app is able to * provide DXIL shaders to SDL_GPURenderState, optional. * - `SDL_PROP_RENDERER_CREATE_GPU_SHADERS_MSL_BOOLEAN`: the app is able to * provide MSL shaders to SDL_GPURenderState, optional. * * With the vulkan renderer: * * - `SDL_PROP_RENDERER_CREATE_VULKAN_INSTANCE_POINTER`: the VkInstance to use * with the renderer, optional. * - `SDL_PROP_RENDERER_CREATE_VULKAN_SURFACE_NUMBER`: the VkSurfaceKHR to use * with the renderer, optional. * - `SDL_PROP_RENDERER_CREATE_VULKAN_PHYSICAL_DEVICE_POINTER`: the * VkPhysicalDevice to use with the renderer, optional. * - `SDL_PROP_RENDERER_CREATE_VULKAN_DEVICE_POINTER`: the VkDevice to use * with the renderer, optional. * - `SDL_PROP_RENDERER_CREATE_VULKAN_GRAPHICS_QUEUE_FAMILY_INDEX_NUMBER`: the * queue family index used for rendering. * - `SDL_PROP_RENDERER_CREATE_VULKAN_PRESENT_QUEUE_FAMILY_INDEX_NUMBER`: the * queue family index used for presentation. * * \param props the properties to use. * \returns a valid rendering context or NULL if there was an error; call * SDL_GetError() for more information. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_CreateProperties * \sa SDL_CreateRenderer * \sa SDL_CreateSoftwareRenderer * \sa SDL_DestroyRenderer * \sa SDL_GetRendererName */ extern SDL_DECLSPEC SDL_Renderer * SDLCALL SDL_CreateRendererWithProperties(SDL_PropertiesID props); #define SDL_PROP_RENDERER_CREATE_NAME_STRING "SDL.renderer.create.name" #define SDL_PROP_RENDERER_CREATE_WINDOW_POINTER "SDL.renderer.create.window" #define SDL_PROP_RENDERER_CREATE_SURFACE_POINTER "SDL.renderer.create.surface" #define SDL_PROP_RENDERER_CREATE_OUTPUT_COLORSPACE_NUMBER "SDL.renderer.create.output_colorspace" #define SDL_PROP_RENDERER_CREATE_PRESENT_VSYNC_NUMBER "SDL.renderer.create.present_vsync" #define SDL_PROP_RENDERER_CREATE_GPU_DEVICE_POINTER "SDL.renderer.create.gpu.device" #define SDL_PROP_RENDERER_CREATE_GPU_SHADERS_SPIRV_BOOLEAN "SDL.renderer.create.gpu.shaders_spirv" #define SDL_PROP_RENDERER_CREATE_GPU_SHADERS_DXIL_BOOLEAN "SDL.renderer.create.gpu.shaders_dxil" #define SDL_PROP_RENDERER_CREATE_GPU_SHADERS_MSL_BOOLEAN "SDL.renderer.create.gpu.shaders_msl" #define SDL_PROP_RENDERER_CREATE_VULKAN_INSTANCE_POINTER "SDL.renderer.create.vulkan.instance" #define SDL_PROP_RENDERER_CREATE_VULKAN_SURFACE_NUMBER "SDL.renderer.create.vulkan.surface" #define SDL_PROP_RENDERER_CREATE_VULKAN_PHYSICAL_DEVICE_POINTER "SDL.renderer.create.vulkan.physical_device" #define SDL_PROP_RENDERER_CREATE_VULKAN_DEVICE_POINTER "SDL.renderer.create.vulkan.device" #define SDL_PROP_RENDERER_CREATE_VULKAN_GRAPHICS_QUEUE_FAMILY_INDEX_NUMBER "SDL.renderer.create.vulkan.graphics_queue_family_index" #define SDL_PROP_RENDERER_CREATE_VULKAN_PRESENT_QUEUE_FAMILY_INDEX_NUMBER "SDL.renderer.create.vulkan.present_queue_family_index" /** * Create a 2D GPU rendering context. * * The GPU device to use is passed in as a parameter. If this is NULL, then a * device will be created normally and can be retrieved using * SDL_GetGPURendererDevice(). * * The window to use is passed in as a parameter. If this is NULL, then this * will become an offscreen renderer. In that case, you should call * SDL_SetRenderTarget() to setup rendering to a texture, and then call * SDL_RenderPresent() normally to complete drawing a frame. * * \param device the GPU device to use with the renderer, or NULL to create a * device. * \param window the window where rendering is displayed, or NULL to create an * offscreen renderer. * \returns a valid rendering context or NULL if there was an error; call * SDL_GetError() for more information. * * \threadsafety If this function is called with a valid GPU device, it should * be called on the thread that created the device. If this * function is called with a valid window, it should be called * on the thread that created the window. * * \since This function is available since SDL 3.4.0. * * \sa SDL_CreateRendererWithProperties * \sa SDL_GetGPURendererDevice * \sa SDL_CreateGPUShader * \sa SDL_CreateGPURenderState * \sa SDL_SetGPURenderState */ extern SDL_DECLSPEC SDL_Renderer * SDLCALL SDL_CreateGPURenderer(SDL_GPUDevice *device, SDL_Window *window); /** * Return the GPU device used by a renderer. * * \param renderer the rendering context. * \returns the GPU device used by the renderer, or NULL if the renderer is * not a GPU renderer; call SDL_GetError() for more information. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.4.0. */ extern SDL_DECLSPEC SDL_GPUDevice * SDLCALL SDL_GetGPURendererDevice(SDL_Renderer *renderer); /** * Create a 2D software rendering context for a surface. * * Two other API which can be used to create SDL_Renderer: * SDL_CreateRenderer() and SDL_CreateWindowAndRenderer(). These can _also_ * create a software renderer, but they are intended to be used with an * SDL_Window as the final destination and not an SDL_Surface. * * \param surface the SDL_Surface structure representing the surface where * rendering is done. * \returns a valid rendering context or NULL if there was an error; call * SDL_GetError() for more information. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_DestroyRenderer */ extern SDL_DECLSPEC SDL_Renderer * SDLCALL SDL_CreateSoftwareRenderer(SDL_Surface *surface); /** * Get the renderer associated with a window. * * \param window the window to query. * \returns the rendering context on success or NULL on failure; call * SDL_GetError() for more information. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC SDL_Renderer * SDLCALL SDL_GetRenderer(SDL_Window *window); /** * Get the window associated with a renderer. * * \param renderer the renderer to query. * \returns the window on success or NULL on failure; call SDL_GetError() for * more information. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC SDL_Window * SDLCALL SDL_GetRenderWindow(SDL_Renderer *renderer); /** * Get the name of a renderer. * * \param renderer the rendering context. * \returns the name of the selected renderer, or NULL on failure; call * SDL_GetError() for more information. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_CreateRenderer * \sa SDL_CreateRendererWithProperties */ extern SDL_DECLSPEC const char * SDLCALL SDL_GetRendererName(SDL_Renderer *renderer); /** * Get the properties associated with a renderer. * * The following read-only properties are provided by SDL: * * - `SDL_PROP_RENDERER_NAME_STRING`: the name of the rendering driver * - `SDL_PROP_RENDERER_WINDOW_POINTER`: the window where rendering is * displayed, if any * - `SDL_PROP_RENDERER_SURFACE_POINTER`: the surface where rendering is * displayed, if this is a software renderer without a window * - `SDL_PROP_RENDERER_VSYNC_NUMBER`: the current vsync setting * - `SDL_PROP_RENDERER_MAX_TEXTURE_SIZE_NUMBER`: the maximum texture width * and height * - `SDL_PROP_RENDERER_TEXTURE_FORMATS_POINTER`: a (const SDL_PixelFormat *) * array of pixel formats, terminated with SDL_PIXELFORMAT_UNKNOWN, * representing the available texture formats for this renderer. * - `SDL_PROP_RENDERER_TEXTURE_WRAPPING_BOOLEAN`: true if the renderer * supports SDL_TEXTURE_ADDRESS_WRAP on non-power-of-two textures. * - `SDL_PROP_RENDERER_OUTPUT_COLORSPACE_NUMBER`: an SDL_Colorspace value * describing the colorspace for output to the display, defaults to * SDL_COLORSPACE_SRGB. * - `SDL_PROP_RENDERER_HDR_ENABLED_BOOLEAN`: true if the output colorspace is * SDL_COLORSPACE_SRGB_LINEAR and the renderer is showing on a display with * HDR enabled. This property can change dynamically when * SDL_EVENT_WINDOW_HDR_STATE_CHANGED is sent. * - `SDL_PROP_RENDERER_SDR_WHITE_POINT_FLOAT`: the value of SDR white in the * SDL_COLORSPACE_SRGB_LINEAR colorspace. When HDR is enabled, this value is * automatically multiplied into the color scale. This property can change * dynamically when SDL_EVENT_WINDOW_HDR_STATE_CHANGED is sent. * - `SDL_PROP_RENDERER_HDR_HEADROOM_FLOAT`: the additional high dynamic range * that can be displayed, in terms of the SDR white point. When HDR is not * enabled, this will be 1.0. This property can change dynamically when * SDL_EVENT_WINDOW_HDR_STATE_CHANGED is sent. * * With the direct3d renderer: * * - `SDL_PROP_RENDERER_D3D9_DEVICE_POINTER`: the IDirect3DDevice9 associated * with the renderer * * With the direct3d11 renderer: * * - `SDL_PROP_RENDERER_D3D11_DEVICE_POINTER`: the ID3D11Device associated * with the renderer * - `SDL_PROP_RENDERER_D3D11_SWAPCHAIN_POINTER`: the IDXGISwapChain1 * associated with the renderer. This may change when the window is resized. * * With the direct3d12 renderer: * * - `SDL_PROP_RENDERER_D3D12_DEVICE_POINTER`: the ID3D12Device associated * with the renderer * - `SDL_PROP_RENDERER_D3D12_SWAPCHAIN_POINTER`: the IDXGISwapChain4 * associated with the renderer. * - `SDL_PROP_RENDERER_D3D12_COMMAND_QUEUE_POINTER`: the ID3D12CommandQueue * associated with the renderer * * With the vulkan renderer: * * - `SDL_PROP_RENDERER_VULKAN_INSTANCE_POINTER`: the VkInstance associated * with the renderer * - `SDL_PROP_RENDERER_VULKAN_SURFACE_NUMBER`: the VkSurfaceKHR associated * with the renderer * - `SDL_PROP_RENDERER_VULKAN_PHYSICAL_DEVICE_POINTER`: the VkPhysicalDevice * associated with the renderer * - `SDL_PROP_RENDERER_VULKAN_DEVICE_POINTER`: the VkDevice associated with * the renderer * - `SDL_PROP_RENDERER_VULKAN_GRAPHICS_QUEUE_FAMILY_INDEX_NUMBER`: the queue * family index used for rendering * - `SDL_PROP_RENDERER_VULKAN_PRESENT_QUEUE_FAMILY_INDEX_NUMBER`: the queue * family index used for presentation * - `SDL_PROP_RENDERER_VULKAN_SWAPCHAIN_IMAGE_COUNT_NUMBER`: the number of * swapchain images, or potential frames in flight, used by the Vulkan * renderer * * With the gpu renderer: * * - `SDL_PROP_RENDERER_GPU_DEVICE_POINTER`: the SDL_GPUDevice associated with * the renderer * * \param renderer the rendering context. * \returns a valid property ID on success or 0 on failure; call * SDL_GetError() for more information. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC SDL_PropertiesID SDLCALL SDL_GetRendererProperties(SDL_Renderer *renderer); #define SDL_PROP_RENDERER_NAME_STRING "SDL.renderer.name" #define SDL_PROP_RENDERER_WINDOW_POINTER "SDL.renderer.window" #define SDL_PROP_RENDERER_SURFACE_POINTER "SDL.renderer.surface" #define SDL_PROP_RENDERER_VSYNC_NUMBER "SDL.renderer.vsync" #define SDL_PROP_RENDERER_MAX_TEXTURE_SIZE_NUMBER "SDL.renderer.max_texture_size" #define SDL_PROP_RENDERER_TEXTURE_FORMATS_POINTER "SDL.renderer.texture_formats" #define SDL_PROP_RENDERER_TEXTURE_WRAPPING_BOOLEAN "SDL.renderer.texture_wrapping" #define SDL_PROP_RENDERER_OUTPUT_COLORSPACE_NUMBER "SDL.renderer.output_colorspace" #define SDL_PROP_RENDERER_HDR_ENABLED_BOOLEAN "SDL.renderer.HDR_enabled" #define SDL_PROP_RENDERER_SDR_WHITE_POINT_FLOAT "SDL.renderer.SDR_white_point" #define SDL_PROP_RENDERER_HDR_HEADROOM_FLOAT "SDL.renderer.HDR_headroom" #define SDL_PROP_RENDERER_D3D9_DEVICE_POINTER "SDL.renderer.d3d9.device" #define SDL_PROP_RENDERER_D3D11_DEVICE_POINTER "SDL.renderer.d3d11.device" #define SDL_PROP_RENDERER_D3D11_SWAPCHAIN_POINTER "SDL.renderer.d3d11.swap_chain" #define SDL_PROP_RENDERER_D3D12_DEVICE_POINTER "SDL.renderer.d3d12.device" #define SDL_PROP_RENDERER_D3D12_SWAPCHAIN_POINTER "SDL.renderer.d3d12.swap_chain" #define SDL_PROP_RENDERER_D3D12_COMMAND_QUEUE_POINTER "SDL.renderer.d3d12.command_queue" #define SDL_PROP_RENDERER_VULKAN_INSTANCE_POINTER "SDL.renderer.vulkan.instance" #define SDL_PROP_RENDERER_VULKAN_SURFACE_NUMBER "SDL.renderer.vulkan.surface" #define SDL_PROP_RENDERER_VULKAN_PHYSICAL_DEVICE_POINTER "SDL.renderer.vulkan.physical_device" #define SDL_PROP_RENDERER_VULKAN_DEVICE_POINTER "SDL.renderer.vulkan.device" #define SDL_PROP_RENDERER_VULKAN_GRAPHICS_QUEUE_FAMILY_INDEX_NUMBER "SDL.renderer.vulkan.graphics_queue_family_index" #define SDL_PROP_RENDERER_VULKAN_PRESENT_QUEUE_FAMILY_INDEX_NUMBER "SDL.renderer.vulkan.present_queue_family_index" #define SDL_PROP_RENDERER_VULKAN_SWAPCHAIN_IMAGE_COUNT_NUMBER "SDL.renderer.vulkan.swapchain_image_count" #define SDL_PROP_RENDERER_GPU_DEVICE_POINTER "SDL.renderer.gpu.device" /** * Get the output size in pixels of a rendering context. * * This returns the true output size in pixels, ignoring any render targets or * logical size and presentation. * * For the output size of the current rendering target, with logical size * adjustments, use SDL_GetCurrentRenderOutputSize() instead. * * \param renderer the rendering context. * \param w a pointer filled in with the width in pixels. * \param h a pointer filled in with the height in pixels. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetCurrentRenderOutputSize */ extern SDL_DECLSPEC bool SDLCALL SDL_GetRenderOutputSize(SDL_Renderer *renderer, int *w, int *h); /** * Get the current output size in pixels of a rendering context. * * If a rendering target is active, this will return the size of the rendering * target in pixels, otherwise return the value of SDL_GetRenderOutputSize(). * * Rendering target or not, the output will be adjusted by the current logical * presentation state, dictated by SDL_SetRenderLogicalPresentation(). * * \param renderer the rendering context. * \param w a pointer filled in with the current width. * \param h a pointer filled in with the current height. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetRenderOutputSize */ extern SDL_DECLSPEC bool SDLCALL SDL_GetCurrentRenderOutputSize(SDL_Renderer *renderer, int *w, int *h); /** * Create a texture for a rendering context. * * The contents of a texture when first created are not defined. * * \param renderer the rendering context. * \param format one of the enumerated values in SDL_PixelFormat. * \param access one of the enumerated values in SDL_TextureAccess. * \param w the width of the texture in pixels. * \param h the height of the texture in pixels. * \returns the created texture or NULL on failure; call SDL_GetError() for * more information. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_CreateTextureFromSurface * \sa SDL_CreateTextureWithProperties * \sa SDL_DestroyTexture * \sa SDL_GetTextureSize * \sa SDL_UpdateTexture */ extern SDL_DECLSPEC SDL_Texture * SDLCALL SDL_CreateTexture(SDL_Renderer *renderer, SDL_PixelFormat format, SDL_TextureAccess access, int w, int h); /** * Create a texture from an existing surface. * * The surface is not modified or freed by this function. * * The SDL_TextureAccess hint for the created texture is * `SDL_TEXTUREACCESS_STATIC`. * * The pixel format of the created texture may be different from the pixel * format of the surface, and can be queried using the * SDL_PROP_TEXTURE_FORMAT_NUMBER property. * * \param renderer the rendering context. * \param surface the SDL_Surface structure containing pixel data used to fill * the texture. * \returns the created texture or NULL on failure; call SDL_GetError() for * more information. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_CreateTexture * \sa SDL_CreateTextureWithProperties * \sa SDL_DestroyTexture */ extern SDL_DECLSPEC SDL_Texture * SDLCALL SDL_CreateTextureFromSurface(SDL_Renderer *renderer, SDL_Surface *surface); /** * Create a texture for a rendering context with the specified properties. * * These are the supported properties: * * - `SDL_PROP_TEXTURE_CREATE_COLORSPACE_NUMBER`: an SDL_Colorspace value * describing the texture colorspace, defaults to SDL_COLORSPACE_SRGB_LINEAR * for floating point textures, SDL_COLORSPACE_HDR10 for 10-bit textures, * SDL_COLORSPACE_SRGB for other RGB textures and SDL_COLORSPACE_JPEG for * YUV textures. * - `SDL_PROP_TEXTURE_CREATE_FORMAT_NUMBER`: one of the enumerated values in * SDL_PixelFormat, defaults to the best RGBA format for the renderer * - `SDL_PROP_TEXTURE_CREATE_ACCESS_NUMBER`: one of the enumerated values in * SDL_TextureAccess, defaults to SDL_TEXTUREACCESS_STATIC * - `SDL_PROP_TEXTURE_CREATE_WIDTH_NUMBER`: the width of the texture in * pixels, required * - `SDL_PROP_TEXTURE_CREATE_HEIGHT_NUMBER`: the height of the texture in * pixels, required * - `SDL_PROP_TEXTURE_CREATE_PALETTE_POINTER`: an SDL_Palette to use with * palettized texture formats. This can be set later with * SDL_SetTexturePalette() * - `SDL_PROP_TEXTURE_CREATE_SDR_WHITE_POINT_FLOAT`: for HDR10 and floating * point textures, this defines the value of 100% diffuse white, with higher * values being displayed in the High Dynamic Range headroom. This defaults * to 100 for HDR10 textures and 1.0 for floating point textures. * - `SDL_PROP_TEXTURE_CREATE_HDR_HEADROOM_FLOAT`: for HDR10 and floating * point textures, this defines the maximum dynamic range used by the * content, in terms of the SDR white point. This would be equivalent to * maxCLL / SDL_PROP_TEXTURE_CREATE_SDR_WHITE_POINT_FLOAT for HDR10 content. * If this is defined, any values outside the range supported by the display * will be scaled into the available HDR headroom, otherwise they are * clipped. * * With the direct3d11 renderer: * * - `SDL_PROP_TEXTURE_CREATE_D3D11_TEXTURE_POINTER`: the ID3D11Texture2D * associated with the texture, if you want to wrap an existing texture. * - `SDL_PROP_TEXTURE_CREATE_D3D11_TEXTURE_U_POINTER`: the ID3D11Texture2D * associated with the U plane of a YUV texture, if you want to wrap an * existing texture. * - `SDL_PROP_TEXTURE_CREATE_D3D11_TEXTURE_V_POINTER`: the ID3D11Texture2D * associated with the V plane of a YUV texture, if you want to wrap an * existing texture. * * With the direct3d12 renderer: * * - `SDL_PROP_TEXTURE_CREATE_D3D12_TEXTURE_POINTER`: the ID3D12Resource * associated with the texture, if you want to wrap an existing texture. * - `SDL_PROP_TEXTURE_CREATE_D3D12_TEXTURE_U_POINTER`: the ID3D12Resource * associated with the U plane of a YUV texture, if you want to wrap an * existing texture. * - `SDL_PROP_TEXTURE_CREATE_D3D12_TEXTURE_V_POINTER`: the ID3D12Resource * associated with the V plane of a YUV texture, if you want to wrap an * existing texture. * * With the metal renderer: * * - `SDL_PROP_TEXTURE_CREATE_METAL_PIXELBUFFER_POINTER`: the CVPixelBufferRef * associated with the texture, if you want to create a texture from an * existing pixel buffer. * * With the opengl renderer: * * - `SDL_PROP_TEXTURE_CREATE_OPENGL_TEXTURE_NUMBER`: the GLuint texture * associated with the texture, if you want to wrap an existing texture. * - `SDL_PROP_TEXTURE_CREATE_OPENGL_TEXTURE_UV_NUMBER`: the GLuint texture * associated with the UV plane of an NV12 texture, if you want to wrap an * existing texture. * - `SDL_PROP_TEXTURE_CREATE_OPENGL_TEXTURE_U_NUMBER`: the GLuint texture * associated with the U plane of a YUV texture, if you want to wrap an * existing texture. * - `SDL_PROP_TEXTURE_CREATE_OPENGL_TEXTURE_V_NUMBER`: the GLuint texture * associated with the V plane of a YUV texture, if you want to wrap an * existing texture. * * With the opengles2 renderer: * * - `SDL_PROP_TEXTURE_CREATE_OPENGLES2_TEXTURE_NUMBER`: the GLuint texture * associated with the texture, if you want to wrap an existing texture. * - `SDL_PROP_TEXTURE_CREATE_OPENGLES2_TEXTURE_UV_NUMBER`: the GLuint texture * associated with the UV plane of an NV12 texture, if you want to wrap an * existing texture. * - `SDL_PROP_TEXTURE_CREATE_OPENGLES2_TEXTURE_U_NUMBER`: the GLuint texture * associated with the U plane of a YUV texture, if you want to wrap an * existing texture. * - `SDL_PROP_TEXTURE_CREATE_OPENGLES2_TEXTURE_V_NUMBER`: the GLuint texture * associated with the V plane of a YUV texture, if you want to wrap an * existing texture. * * With the vulkan renderer: * * - `SDL_PROP_TEXTURE_CREATE_VULKAN_TEXTURE_NUMBER`: the VkImage associated * with the texture, if you want to wrap an existing texture. * - `SDL_PROP_TEXTURE_CREATE_VULKAN_LAYOUT_NUMBER`: the VkImageLayout for the * VkImage, defaults to VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL. * * With the GPU renderer: * * - `SDL_PROP_TEXTURE_CREATE_GPU_TEXTURE_POINTER`: the SDL_GPUTexture * associated with the texture, if you want to wrap an existing texture. * - `SDL_PROP_TEXTURE_CREATE_GPU_TEXTURE_UV_NUMBER`: the SDL_GPUTexture * associated with the UV plane of an NV12 texture, if you want to wrap an * existing texture. * - `SDL_PROP_TEXTURE_CREATE_GPU_TEXTURE_U_NUMBER`: the SDL_GPUTexture * associated with the U plane of a YUV texture, if you want to wrap an * existing texture. * - `SDL_PROP_TEXTURE_CREATE_GPU_TEXTURE_V_NUMBER`: the SDL_GPUTexture * associated with the V plane of a YUV texture, if you want to wrap an * existing texture. * * \param renderer the rendering context. * \param props the properties to use. * \returns the created texture or NULL on failure; call SDL_GetError() for * more information. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_CreateProperties * \sa SDL_CreateTexture * \sa SDL_CreateTextureFromSurface * \sa SDL_DestroyTexture * \sa SDL_GetTextureSize * \sa SDL_UpdateTexture */ extern SDL_DECLSPEC SDL_Texture * SDLCALL SDL_CreateTextureWithProperties(SDL_Renderer *renderer, SDL_PropertiesID props); #define SDL_PROP_TEXTURE_CREATE_COLORSPACE_NUMBER "SDL.texture.create.colorspace" #define SDL_PROP_TEXTURE_CREATE_FORMAT_NUMBER "SDL.texture.create.format" #define SDL_PROP_TEXTURE_CREATE_ACCESS_NUMBER "SDL.texture.create.access" #define SDL_PROP_TEXTURE_CREATE_WIDTH_NUMBER "SDL.texture.create.width" #define SDL_PROP_TEXTURE_CREATE_HEIGHT_NUMBER "SDL.texture.create.height" #define SDL_PROP_TEXTURE_CREATE_PALETTE_POINTER "SDL.texture.create.palette" #define SDL_PROP_TEXTURE_CREATE_SDR_WHITE_POINT_FLOAT "SDL.texture.create.SDR_white_point" #define SDL_PROP_TEXTURE_CREATE_HDR_HEADROOM_FLOAT "SDL.texture.create.HDR_headroom" #define SDL_PROP_TEXTURE_CREATE_D3D11_TEXTURE_POINTER "SDL.texture.create.d3d11.texture" #define SDL_PROP_TEXTURE_CREATE_D3D11_TEXTURE_U_POINTER "SDL.texture.create.d3d11.texture_u" #define SDL_PROP_TEXTURE_CREATE_D3D11_TEXTURE_V_POINTER "SDL.texture.create.d3d11.texture_v" #define SDL_PROP_TEXTURE_CREATE_D3D12_TEXTURE_POINTER "SDL.texture.create.d3d12.texture" #define SDL_PROP_TEXTURE_CREATE_D3D12_TEXTURE_U_POINTER "SDL.texture.create.d3d12.texture_u" #define SDL_PROP_TEXTURE_CREATE_D3D12_TEXTURE_V_POINTER "SDL.texture.create.d3d12.texture_v" #define SDL_PROP_TEXTURE_CREATE_METAL_PIXELBUFFER_POINTER "SDL.texture.create.metal.pixelbuffer" #define SDL_PROP_TEXTURE_CREATE_OPENGL_TEXTURE_NUMBER "SDL.texture.create.opengl.texture" #define SDL_PROP_TEXTURE_CREATE_OPENGL_TEXTURE_UV_NUMBER "SDL.texture.create.opengl.texture_uv" #define SDL_PROP_TEXTURE_CREATE_OPENGL_TEXTURE_U_NUMBER "SDL.texture.create.opengl.texture_u" #define SDL_PROP_TEXTURE_CREATE_OPENGL_TEXTURE_V_NUMBER "SDL.texture.create.opengl.texture_v" #define SDL_PROP_TEXTURE_CREATE_OPENGLES2_TEXTURE_NUMBER "SDL.texture.create.opengles2.texture" #define SDL_PROP_TEXTURE_CREATE_OPENGLES2_TEXTURE_UV_NUMBER "SDL.texture.create.opengles2.texture_uv" #define SDL_PROP_TEXTURE_CREATE_OPENGLES2_TEXTURE_U_NUMBER "SDL.texture.create.opengles2.texture_u" #define SDL_PROP_TEXTURE_CREATE_OPENGLES2_TEXTURE_V_NUMBER "SDL.texture.create.opengles2.texture_v" #define SDL_PROP_TEXTURE_CREATE_VULKAN_TEXTURE_NUMBER "SDL.texture.create.vulkan.texture" #define SDL_PROP_TEXTURE_CREATE_VULKAN_LAYOUT_NUMBER "SDL.texture.create.vulkan.layout" #define SDL_PROP_TEXTURE_CREATE_GPU_TEXTURE_POINTER "SDL.texture.create.gpu.texture" #define SDL_PROP_TEXTURE_CREATE_GPU_TEXTURE_UV_POINTER "SDL.texture.create.gpu.texture_uv" #define SDL_PROP_TEXTURE_CREATE_GPU_TEXTURE_U_POINTER "SDL.texture.create.gpu.texture_u" #define SDL_PROP_TEXTURE_CREATE_GPU_TEXTURE_V_POINTER "SDL.texture.create.gpu.texture_v" /** * Get the properties associated with a texture. * * The following read-only properties are provided by SDL: * * - `SDL_PROP_TEXTURE_COLORSPACE_NUMBER`: an SDL_Colorspace value describing * the texture colorspace. * - `SDL_PROP_TEXTURE_FORMAT_NUMBER`: one of the enumerated values in * SDL_PixelFormat. * - `SDL_PROP_TEXTURE_ACCESS_NUMBER`: one of the enumerated values in * SDL_TextureAccess. * - `SDL_PROP_TEXTURE_WIDTH_NUMBER`: the width of the texture in pixels. * - `SDL_PROP_TEXTURE_HEIGHT_NUMBER`: the height of the texture in pixels. * - `SDL_PROP_TEXTURE_SDR_WHITE_POINT_FLOAT`: for HDR10 and floating point * textures, this defines the value of 100% diffuse white, with higher * values being displayed in the High Dynamic Range headroom. This defaults * to 100 for HDR10 textures and 1.0 for other textures. * - `SDL_PROP_TEXTURE_HDR_HEADROOM_FLOAT`: for HDR10 and floating point * textures, this defines the maximum dynamic range used by the content, in * terms of the SDR white point. If this is defined, any values outside the * range supported by the display will be scaled into the available HDR * headroom, otherwise they are clipped. This defaults to 1.0 for SDR * textures, 4.0 for HDR10 textures, and no default for floating point * textures. * * With the direct3d11 renderer: * * - `SDL_PROP_TEXTURE_D3D11_TEXTURE_POINTER`: the ID3D11Texture2D associated * with the texture * - `SDL_PROP_TEXTURE_D3D11_TEXTURE_U_POINTER`: the ID3D11Texture2D * associated with the U plane of a YUV texture * - `SDL_PROP_TEXTURE_D3D11_TEXTURE_V_POINTER`: the ID3D11Texture2D * associated with the V plane of a YUV texture * * With the direct3d12 renderer: * * - `SDL_PROP_TEXTURE_D3D12_TEXTURE_POINTER`: the ID3D12Resource associated * with the texture * - `SDL_PROP_TEXTURE_D3D12_TEXTURE_U_POINTER`: the ID3D12Resource associated * with the U plane of a YUV texture * - `SDL_PROP_TEXTURE_D3D12_TEXTURE_V_POINTER`: the ID3D12Resource associated * with the V plane of a YUV texture * * With the vulkan renderer: * * - `SDL_PROP_TEXTURE_VULKAN_TEXTURE_NUMBER`: the VkImage associated with the * texture * * With the opengl renderer: * * - `SDL_PROP_TEXTURE_OPENGL_TEXTURE_NUMBER`: the GLuint texture associated * with the texture * - `SDL_PROP_TEXTURE_OPENGL_TEXTURE_UV_NUMBER`: the GLuint texture * associated with the UV plane of an NV12 texture * - `SDL_PROP_TEXTURE_OPENGL_TEXTURE_U_NUMBER`: the GLuint texture associated * with the U plane of a YUV texture * - `SDL_PROP_TEXTURE_OPENGL_TEXTURE_V_NUMBER`: the GLuint texture associated * with the V plane of a YUV texture * - `SDL_PROP_TEXTURE_OPENGL_TEXTURE_TARGET_NUMBER`: the GLenum for the * texture target (`GL_TEXTURE_2D`, `GL_TEXTURE_RECTANGLE_ARB`, etc) * - `SDL_PROP_TEXTURE_OPENGL_TEX_W_FLOAT`: the texture coordinate width of * the texture (0.0 - 1.0) * - `SDL_PROP_TEXTURE_OPENGL_TEX_H_FLOAT`: the texture coordinate height of * the texture (0.0 - 1.0) * * With the opengles2 renderer: * * - `SDL_PROP_TEXTURE_OPENGLES2_TEXTURE_NUMBER`: the GLuint texture * associated with the texture * - `SDL_PROP_TEXTURE_OPENGLES2_TEXTURE_UV_NUMBER`: the GLuint texture * associated with the UV plane of an NV12 texture * - `SDL_PROP_TEXTURE_OPENGLES2_TEXTURE_U_NUMBER`: the GLuint texture * associated with the U plane of a YUV texture * - `SDL_PROP_TEXTURE_OPENGLES2_TEXTURE_V_NUMBER`: the GLuint texture * associated with the V plane of a YUV texture * - `SDL_PROP_TEXTURE_OPENGLES2_TEXTURE_TARGET_NUMBER`: the GLenum for the * texture target (`GL_TEXTURE_2D`, `GL_TEXTURE_EXTERNAL_OES`, etc) * * With the gpu renderer: * * - `SDL_PROP_TEXTURE_GPU_TEXTURE_POINTER`: the SDL_GPUTexture associated * with the texture * - `SDL_PROP_TEXTURE_GPU_TEXTURE_UV_POINTER`: the SDL_GPUTexture associated * with the UV plane of an NV12 texture * - `SDL_PROP_TEXTURE_GPU_TEXTURE_U_POINTER`: the SDL_GPUTexture associated * with the U plane of a YUV texture * - `SDL_PROP_TEXTURE_GPU_TEXTURE_V_POINTER`: the SDL_GPUTexture associated * with the V plane of a YUV texture * * \param texture the texture to query. * \returns a valid property ID on success or 0 on failure; call * SDL_GetError() for more information. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC SDL_PropertiesID SDLCALL SDL_GetTextureProperties(SDL_Texture *texture); #define SDL_PROP_TEXTURE_COLORSPACE_NUMBER "SDL.texture.colorspace" #define SDL_PROP_TEXTURE_FORMAT_NUMBER "SDL.texture.format" #define SDL_PROP_TEXTURE_ACCESS_NUMBER "SDL.texture.access" #define SDL_PROP_TEXTURE_WIDTH_NUMBER "SDL.texture.width" #define SDL_PROP_TEXTURE_HEIGHT_NUMBER "SDL.texture.height" #define SDL_PROP_TEXTURE_SDR_WHITE_POINT_FLOAT "SDL.texture.SDR_white_point" #define SDL_PROP_TEXTURE_HDR_HEADROOM_FLOAT "SDL.texture.HDR_headroom" #define SDL_PROP_TEXTURE_D3D11_TEXTURE_POINTER "SDL.texture.d3d11.texture" #define SDL_PROP_TEXTURE_D3D11_TEXTURE_U_POINTER "SDL.texture.d3d11.texture_u" #define SDL_PROP_TEXTURE_D3D11_TEXTURE_V_POINTER "SDL.texture.d3d11.texture_v" #define SDL_PROP_TEXTURE_D3D12_TEXTURE_POINTER "SDL.texture.d3d12.texture" #define SDL_PROP_TEXTURE_D3D12_TEXTURE_U_POINTER "SDL.texture.d3d12.texture_u" #define SDL_PROP_TEXTURE_D3D12_TEXTURE_V_POINTER "SDL.texture.d3d12.texture_v" #define SDL_PROP_TEXTURE_OPENGL_TEXTURE_NUMBER "SDL.texture.opengl.texture" #define SDL_PROP_TEXTURE_OPENGL_TEXTURE_UV_NUMBER "SDL.texture.opengl.texture_uv" #define SDL_PROP_TEXTURE_OPENGL_TEXTURE_U_NUMBER "SDL.texture.opengl.texture_u" #define SDL_PROP_TEXTURE_OPENGL_TEXTURE_V_NUMBER "SDL.texture.opengl.texture_v" #define SDL_PROP_TEXTURE_OPENGL_TEXTURE_TARGET_NUMBER "SDL.texture.opengl.target" #define SDL_PROP_TEXTURE_OPENGL_TEX_W_FLOAT "SDL.texture.opengl.tex_w" #define SDL_PROP_TEXTURE_OPENGL_TEX_H_FLOAT "SDL.texture.opengl.tex_h" #define SDL_PROP_TEXTURE_OPENGLES2_TEXTURE_NUMBER "SDL.texture.opengles2.texture" #define SDL_PROP_TEXTURE_OPENGLES2_TEXTURE_UV_NUMBER "SDL.texture.opengles2.texture_uv" #define SDL_PROP_TEXTURE_OPENGLES2_TEXTURE_U_NUMBER "SDL.texture.opengles2.texture_u" #define SDL_PROP_TEXTURE_OPENGLES2_TEXTURE_V_NUMBER "SDL.texture.opengles2.texture_v" #define SDL_PROP_TEXTURE_OPENGLES2_TEXTURE_TARGET_NUMBER "SDL.texture.opengles2.target" #define SDL_PROP_TEXTURE_VULKAN_TEXTURE_NUMBER "SDL.texture.vulkan.texture" #define SDL_PROP_TEXTURE_GPU_TEXTURE_POINTER "SDL.texture.gpu.texture" #define SDL_PROP_TEXTURE_GPU_TEXTURE_UV_POINTER "SDL.texture.gpu.texture_uv" #define SDL_PROP_TEXTURE_GPU_TEXTURE_U_POINTER "SDL.texture.gpu.texture_u" #define SDL_PROP_TEXTURE_GPU_TEXTURE_V_POINTER "SDL.texture.gpu.texture_v" /** * Get the renderer that created an SDL_Texture. * * \param texture the texture to query. * \returns a pointer to the SDL_Renderer that created the texture, or NULL on * failure; call SDL_GetError() for more information. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC SDL_Renderer * SDLCALL SDL_GetRendererFromTexture(SDL_Texture *texture); /** * Get the size of a texture, as floating point values. * * \param texture the texture to query. * \param w a pointer filled in with the width of the texture in pixels. This * argument can be NULL if you don't need this information. * \param h a pointer filled in with the height of the texture in pixels. This * argument can be NULL if you don't need this information. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC bool SDLCALL SDL_GetTextureSize(SDL_Texture *texture, float *w, float *h); /** * Set the palette used by a texture. * * Setting the palette keeps an internal reference to the palette, which can * be safely destroyed afterwards. * * A single palette can be shared with many textures. * * \param texture the texture to update. * \param palette the SDL_Palette structure to use. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.4.0. * * \sa SDL_CreatePalette * \sa SDL_GetTexturePalette */ extern SDL_DECLSPEC bool SDLCALL SDL_SetTexturePalette(SDL_Texture *texture, SDL_Palette *palette); /** * Get the palette used by a texture. * * \param texture the texture to query. * \returns a pointer to the palette used by the texture, or NULL if there is * no palette used. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.4.0. * * \sa SDL_SetTexturePalette */ extern SDL_DECLSPEC SDL_Palette * SDLCALL SDL_GetTexturePalette(SDL_Texture *texture); /** * Set an additional color value multiplied into render copy operations. * * When this texture is rendered, during the copy operation each source color * channel is modulated by the appropriate color value according to the * following formula: * * `srcC = srcC * (color / 255)` * * Color modulation is not always supported by the renderer; it will return * false if color modulation is not supported. * * \param texture the texture to update. * \param r the red color value multiplied into copy operations. * \param g the green color value multiplied into copy operations. * \param b the blue color value multiplied into copy operations. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetTextureColorMod * \sa SDL_SetTextureAlphaMod * \sa SDL_SetTextureColorModFloat */ extern SDL_DECLSPEC bool SDLCALL SDL_SetTextureColorMod(SDL_Texture *texture, Uint8 r, Uint8 g, Uint8 b); /** * Set an additional color value multiplied into render copy operations. * * When this texture is rendered, during the copy operation each source color * channel is modulated by the appropriate color value according to the * following formula: * * `srcC = srcC * color` * * Color modulation is not always supported by the renderer; it will return * false if color modulation is not supported. * * \param texture the texture to update. * \param r the red color value multiplied into copy operations. * \param g the green color value multiplied into copy operations. * \param b the blue color value multiplied into copy operations. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetTextureColorModFloat * \sa SDL_SetTextureAlphaModFloat * \sa SDL_SetTextureColorMod */ extern SDL_DECLSPEC bool SDLCALL SDL_SetTextureColorModFloat(SDL_Texture *texture, float r, float g, float b); /** * Get the additional color value multiplied into render copy operations. * * \param texture the texture to query. * \param r a pointer filled in with the current red color value. * \param g a pointer filled in with the current green color value. * \param b a pointer filled in with the current blue color value. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetTextureAlphaMod * \sa SDL_GetTextureColorModFloat * \sa SDL_SetTextureColorMod */ extern SDL_DECLSPEC bool SDLCALL SDL_GetTextureColorMod(SDL_Texture *texture, Uint8 *r, Uint8 *g, Uint8 *b); /** * Get the additional color value multiplied into render copy operations. * * \param texture the texture to query. * \param r a pointer filled in with the current red color value. * \param g a pointer filled in with the current green color value. * \param b a pointer filled in with the current blue color value. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetTextureAlphaModFloat * \sa SDL_GetTextureColorMod * \sa SDL_SetTextureColorModFloat */ extern SDL_DECLSPEC bool SDLCALL SDL_GetTextureColorModFloat(SDL_Texture *texture, float *r, float *g, float *b); /** * Set an additional alpha value multiplied into render copy operations. * * When this texture is rendered, during the copy operation the source alpha * value is modulated by this alpha value according to the following formula: * * `srcA = srcA * (alpha / 255)` * * Alpha modulation is not always supported by the renderer; it will return * false if alpha modulation is not supported. * * \param texture the texture to update. * \param alpha the source alpha value multiplied into copy operations. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetTextureAlphaMod * \sa SDL_SetTextureAlphaModFloat * \sa SDL_SetTextureColorMod */ extern SDL_DECLSPEC bool SDLCALL SDL_SetTextureAlphaMod(SDL_Texture *texture, Uint8 alpha); /** * Set an additional alpha value multiplied into render copy operations. * * When this texture is rendered, during the copy operation the source alpha * value is modulated by this alpha value according to the following formula: * * `srcA = srcA * alpha` * * Alpha modulation is not always supported by the renderer; it will return * false if alpha modulation is not supported. * * \param texture the texture to update. * \param alpha the source alpha value multiplied into copy operations. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetTextureAlphaModFloat * \sa SDL_SetTextureAlphaMod * \sa SDL_SetTextureColorModFloat */ extern SDL_DECLSPEC bool SDLCALL SDL_SetTextureAlphaModFloat(SDL_Texture *texture, float alpha); /** * Get the additional alpha value multiplied into render copy operations. * * \param texture the texture to query. * \param alpha a pointer filled in with the current alpha value. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetTextureAlphaModFloat * \sa SDL_GetTextureColorMod * \sa SDL_SetTextureAlphaMod */ extern SDL_DECLSPEC bool SDLCALL SDL_GetTextureAlphaMod(SDL_Texture *texture, Uint8 *alpha); /** * Get the additional alpha value multiplied into render copy operations. * * \param texture the texture to query. * \param alpha a pointer filled in with the current alpha value. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetTextureAlphaMod * \sa SDL_GetTextureColorModFloat * \sa SDL_SetTextureAlphaModFloat */ extern SDL_DECLSPEC bool SDLCALL SDL_GetTextureAlphaModFloat(SDL_Texture *texture, float *alpha); /** * Set the blend mode for a texture, used by SDL_RenderTexture(). * * If the blend mode is not supported, the closest supported mode is chosen * and this function returns false. * * \param texture the texture to update. * \param blendMode the SDL_BlendMode to use for texture blending. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetTextureBlendMode */ extern SDL_DECLSPEC bool SDLCALL SDL_SetTextureBlendMode(SDL_Texture *texture, SDL_BlendMode blendMode); /** * Get the blend mode used for texture copy operations. * * \param texture the texture to query. * \param blendMode a pointer filled in with the current SDL_BlendMode. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_SetTextureBlendMode */ extern SDL_DECLSPEC bool SDLCALL SDL_GetTextureBlendMode(SDL_Texture *texture, SDL_BlendMode *blendMode); /** * Set the scale mode used for texture scale operations. * * The default texture scale mode is SDL_SCALEMODE_LINEAR. * * If the scale mode is not supported, the closest supported mode is chosen. * * \param texture the texture to update. * \param scaleMode the SDL_ScaleMode to use for texture scaling. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetTextureScaleMode */ extern SDL_DECLSPEC bool SDLCALL SDL_SetTextureScaleMode(SDL_Texture *texture, SDL_ScaleMode scaleMode); /** * Get the scale mode used for texture scale operations. * * \param texture the texture to query. * \param scaleMode a pointer filled in with the current scale mode. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_SetTextureScaleMode */ extern SDL_DECLSPEC bool SDLCALL SDL_GetTextureScaleMode(SDL_Texture *texture, SDL_ScaleMode *scaleMode); /** * Update the given texture rectangle with new pixel data. * * The pixel data must be in the pixel format of the texture, which can be * queried using the SDL_PROP_TEXTURE_FORMAT_NUMBER property. * * This is a fairly slow function, intended for use with static textures that * do not change often. * * If the texture is intended to be updated often, it is preferred to create * the texture as streaming and use the locking functions referenced below. * While this function will work with streaming textures, for optimization * reasons you may not get the pixels back if you lock the texture afterward. * * \param texture the texture to update. * \param rect an SDL_Rect structure representing the area to update, or NULL * to update the entire texture. * \param pixels the raw pixel data in the format of the texture. * \param pitch the number of bytes in a row of pixel data, including padding * between lines. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_LockTexture * \sa SDL_UnlockTexture * \sa SDL_UpdateNVTexture * \sa SDL_UpdateYUVTexture */ extern SDL_DECLSPEC bool SDLCALL SDL_UpdateTexture(SDL_Texture *texture, const SDL_Rect *rect, const void *pixels, int pitch); /** * Update a rectangle within a planar YV12 or IYUV texture with new pixel * data. * * You can use SDL_UpdateTexture() as long as your pixel data is a contiguous * block of Y and U/V planes in the proper order, but this function is * available if your pixel data is not contiguous. * * \param texture the texture to update. * \param rect a pointer to the rectangle of pixels to update, or NULL to * update the entire texture. * \param Yplane the raw pixel data for the Y plane. * \param Ypitch the number of bytes between rows of pixel data for the Y * plane. * \param Uplane the raw pixel data for the U plane. * \param Upitch the number of bytes between rows of pixel data for the U * plane. * \param Vplane the raw pixel data for the V plane. * \param Vpitch the number of bytes between rows of pixel data for the V * plane. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_UpdateNVTexture * \sa SDL_UpdateTexture */ extern SDL_DECLSPEC bool SDLCALL SDL_UpdateYUVTexture(SDL_Texture *texture, const SDL_Rect *rect, const Uint8 *Yplane, int Ypitch, const Uint8 *Uplane, int Upitch, const Uint8 *Vplane, int Vpitch); /** * Update a rectangle within a planar NV12 or NV21 texture with new pixels. * * You can use SDL_UpdateTexture() as long as your pixel data is a contiguous * block of NV12/21 planes in the proper order, but this function is available * if your pixel data is not contiguous. * * \param texture the texture to update. * \param rect a pointer to the rectangle of pixels to update, or NULL to * update the entire texture. * \param Yplane the raw pixel data for the Y plane. * \param Ypitch the number of bytes between rows of pixel data for the Y * plane. * \param UVplane the raw pixel data for the UV plane. * \param UVpitch the number of bytes between rows of pixel data for the UV * plane. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_UpdateTexture * \sa SDL_UpdateYUVTexture */ extern SDL_DECLSPEC bool SDLCALL SDL_UpdateNVTexture(SDL_Texture *texture, const SDL_Rect *rect, const Uint8 *Yplane, int Ypitch, const Uint8 *UVplane, int UVpitch); /** * Lock a portion of the texture for **write-only** pixel access. * * As an optimization, the pixels made available for editing don't necessarily * contain the old texture data. This is a write-only operation, and if you * need to keep a copy of the texture data you should do that at the * application level. * * You must use SDL_UnlockTexture() to unlock the pixels and apply any * changes. * * \param texture the texture to lock for access, which was created with * `SDL_TEXTUREACCESS_STREAMING`. * \param rect an SDL_Rect structure representing the area to lock for access; * NULL to lock the entire texture. * \param pixels this is filled in with a pointer to the locked pixels, * appropriately offset by the locked area. * \param pitch this is filled in with the pitch of the locked pixels; the * pitch is the length of one row in bytes. * \returns true on success or false if the texture is not valid or was not * created with `SDL_TEXTUREACCESS_STREAMING`; call SDL_GetError() * for more information. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_LockTextureToSurface * \sa SDL_UnlockTexture */ extern SDL_DECLSPEC bool SDLCALL SDL_LockTexture(SDL_Texture *texture, const SDL_Rect *rect, void **pixels, int *pitch); /** * Lock a portion of the texture for **write-only** pixel access, and expose * it as a SDL surface. * * Besides providing an SDL_Surface instead of raw pixel data, this function * operates like SDL_LockTexture. * * As an optimization, the pixels made available for editing don't necessarily * contain the old texture data. This is a write-only operation, and if you * need to keep a copy of the texture data you should do that at the * application level. * * You must use SDL_UnlockTexture() to unlock the pixels and apply any * changes. * * The returned surface is freed internally after calling SDL_UnlockTexture() * or SDL_DestroyTexture(). The caller should not free it. * * \param texture the texture to lock for access, which must be created with * `SDL_TEXTUREACCESS_STREAMING`. * \param rect a pointer to the rectangle to lock for access. If the rect is * NULL, the entire texture will be locked. * \param surface a pointer to an SDL surface of size **rect**. Don't assume * any specific pixel content. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_LockTexture * \sa SDL_UnlockTexture */ extern SDL_DECLSPEC bool SDLCALL SDL_LockTextureToSurface(SDL_Texture *texture, const SDL_Rect *rect, SDL_Surface **surface); /** * Unlock a texture, uploading the changes to video memory, if needed. * * **Warning**: Please note that SDL_LockTexture() is intended to be * write-only; it will not guarantee the previous contents of the texture will * be provided. You must fully initialize any area of a texture that you lock * before unlocking it, as the pixels might otherwise be uninitialized memory. * * Which is to say: locking and immediately unlocking a texture can result in * corrupted textures, depending on the renderer in use. * * \param texture a texture locked by SDL_LockTexture(). * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_LockTexture */ extern SDL_DECLSPEC void SDLCALL SDL_UnlockTexture(SDL_Texture *texture); /** * Set a texture as the current rendering target. * * The default render target is the window for which the renderer was created. * To stop rendering to a texture and render to the window again, call this * function with a NULL `texture`. * * Viewport, cliprect, scale, and logical presentation are unique to each * render target. Get and set functions for these states apply to the current * render target set by this function, and those states persist on each target * when the current render target changes. * * \param renderer the rendering context. * \param texture the targeted texture, which must be created with the * `SDL_TEXTUREACCESS_TARGET` flag, or NULL to render to the * window instead of a texture. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetRenderTarget */ extern SDL_DECLSPEC bool SDLCALL SDL_SetRenderTarget(SDL_Renderer *renderer, SDL_Texture *texture); /** * Get the current render target. * * The default render target is the window for which the renderer was created, * and is reported a NULL here. * * \param renderer the rendering context. * \returns the current render target or NULL for the default render target. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_SetRenderTarget */ extern SDL_DECLSPEC SDL_Texture * SDLCALL SDL_GetRenderTarget(SDL_Renderer *renderer); /** * Set a device-independent resolution and presentation mode for rendering. * * This function sets the width and height of the logical rendering output. * The renderer will act as if the current render target is always the * requested dimensions, scaling to the actual resolution as necessary. * * This can be useful for games that expect a fixed size, but would like to * scale the output to whatever is available, regardless of how a user resizes * a window, or if the display is high DPI. * * Logical presentation can be used with both render target textures and the * renderer's window; the state is unique to each render target, and this * function sets the state for the current render target. It might be useful * to draw to a texture that matches the window dimensions with logical * presentation enabled, and then draw that texture across the entire window * with logical presentation disabled. Be careful not to render both with * logical presentation enabled, however, as this could produce * double-letterboxing, etc. * * You can disable logical coordinates by setting the mode to * SDL_LOGICAL_PRESENTATION_DISABLED, and in that case you get the full pixel * resolution of the render target; it is safe to toggle logical presentation * during the rendering of a frame: perhaps most of the rendering is done to * specific dimensions but to make fonts look sharp, the app turns off logical * presentation while drawing text, for example. * * You can convert coordinates in an event into rendering coordinates using * SDL_ConvertEventToRenderCoordinates(). * * \param renderer the rendering context. * \param w the width of the logical resolution. * \param h the height of the logical resolution. * \param mode the presentation mode used. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_ConvertEventToRenderCoordinates * \sa SDL_GetRenderLogicalPresentation * \sa SDL_GetRenderLogicalPresentationRect */ extern SDL_DECLSPEC bool SDLCALL SDL_SetRenderLogicalPresentation(SDL_Renderer *renderer, int w, int h, SDL_RendererLogicalPresentation mode); /** * Get device independent resolution and presentation mode for rendering. * * This function gets the width and height of the logical rendering output, or * 0 if a logical resolution is not enabled. * * Each render target has its own logical presentation state. This function * gets the state for the current render target. * * \param renderer the rendering context. * \param w an int filled with the logical presentation width. * \param h an int filled with the logical presentation height. * \param mode a variable filled with the logical presentation mode being * used. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_SetRenderLogicalPresentation */ extern SDL_DECLSPEC bool SDLCALL SDL_GetRenderLogicalPresentation(SDL_Renderer *renderer, int *w, int *h, SDL_RendererLogicalPresentation *mode); /** * Get the final presentation rectangle for rendering. * * This function returns the calculated rectangle used for logical * presentation, based on the presentation mode and output size. If logical * presentation is disabled, it will fill the rectangle with the output size, * in pixels. * * Each render target has its own logical presentation state. This function * gets the rectangle for the current render target. * * \param renderer the rendering context. * \param rect a pointer filled in with the final presentation rectangle, may * be NULL. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_SetRenderLogicalPresentation */ extern SDL_DECLSPEC bool SDLCALL SDL_GetRenderLogicalPresentationRect(SDL_Renderer *renderer, SDL_FRect *rect); /** * Get a point in render coordinates when given a point in window coordinates. * * This takes into account several states: * * - The window dimensions. * - The logical presentation settings (SDL_SetRenderLogicalPresentation) * - The scale (SDL_SetRenderScale) * - The viewport (SDL_SetRenderViewport) * * \param renderer the rendering context. * \param window_x the x coordinate in window coordinates. * \param window_y the y coordinate in window coordinates. * \param x a pointer filled with the x coordinate in render coordinates. * \param y a pointer filled with the y coordinate in render coordinates. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_SetRenderLogicalPresentation * \sa SDL_SetRenderScale */ extern SDL_DECLSPEC bool SDLCALL SDL_RenderCoordinatesFromWindow(SDL_Renderer *renderer, float window_x, float window_y, float *x, float *y); /** * Get a point in window coordinates when given a point in render coordinates. * * This takes into account several states: * * - The window dimensions. * - The logical presentation settings (SDL_SetRenderLogicalPresentation) * - The scale (SDL_SetRenderScale) * - The viewport (SDL_SetRenderViewport) * * \param renderer the rendering context. * \param x the x coordinate in render coordinates. * \param y the y coordinate in render coordinates. * \param window_x a pointer filled with the x coordinate in window * coordinates. * \param window_y a pointer filled with the y coordinate in window * coordinates. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_SetRenderLogicalPresentation * \sa SDL_SetRenderScale * \sa SDL_SetRenderViewport */ extern SDL_DECLSPEC bool SDLCALL SDL_RenderCoordinatesToWindow(SDL_Renderer *renderer, float x, float y, float *window_x, float *window_y); /** * Convert the coordinates in an event to render coordinates. * * This takes into account several states: * * - The window dimensions. * - The logical presentation settings (SDL_SetRenderLogicalPresentation) * - The scale (SDL_SetRenderScale) * - The viewport (SDL_SetRenderViewport) * * Various event types are converted with this function: mouse, touch, pen, * etc. * * Touch coordinates are converted from normalized coordinates in the window * to non-normalized rendering coordinates. * * Relative mouse coordinates (xrel and yrel event fields) are _also_ * converted. Applications that do not want these fields converted should use * SDL_RenderCoordinatesFromWindow() on the specific event fields instead of * converting the entire event structure. * * Once converted, coordinates may be outside the rendering area. * * \param renderer the rendering context. * \param event the event to modify. * \returns true if the event is converted or doesn't need conversion, or * false on failure; call SDL_GetError() for more information. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_RenderCoordinatesFromWindow */ extern SDL_DECLSPEC bool SDLCALL SDL_ConvertEventToRenderCoordinates(SDL_Renderer *renderer, SDL_Event *event); /** * Set the drawing area for rendering on the current target. * * Drawing will clip to this area (separately from any clipping done with * SDL_SetRenderClipRect), and the top left of the area will become coordinate * (0, 0) for future drawing commands. * * The area's width and height must be >= 0. * * Each render target has its own viewport. This function sets the viewport * for the current render target. * * \param renderer the rendering context. * \param rect the SDL_Rect structure representing the drawing area, or NULL * to set the viewport to the entire target. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetRenderViewport * \sa SDL_RenderViewportSet */ extern SDL_DECLSPEC bool SDLCALL SDL_SetRenderViewport(SDL_Renderer *renderer, const SDL_Rect *rect); /** * Get the drawing area for the current target. * * Each render target has its own viewport. This function gets the viewport * for the current render target. * * \param renderer the rendering context. * \param rect an SDL_Rect structure filled in with the current drawing area. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_RenderViewportSet * \sa SDL_SetRenderViewport */ extern SDL_DECLSPEC bool SDLCALL SDL_GetRenderViewport(SDL_Renderer *renderer, SDL_Rect *rect); /** * Return whether an explicit rectangle was set as the viewport. * * This is useful if you're saving and restoring the viewport and want to know * whether you should restore a specific rectangle or NULL. * * Each render target has its own viewport. This function checks the viewport * for the current render target. * * \param renderer the rendering context. * \returns true if the viewport was set to a specific rectangle, or false if * it was set to NULL (the entire target). * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetRenderViewport * \sa SDL_SetRenderViewport */ extern SDL_DECLSPEC bool SDLCALL SDL_RenderViewportSet(SDL_Renderer *renderer); /** * Get the safe area for rendering within the current viewport. * * Some devices have portions of the screen which are partially obscured or * not interactive, possibly due to on-screen controls, curved edges, camera * notches, TV overscan, etc. This function provides the area of the current * viewport which is safe to have interactible content. You should continue * rendering into the rest of the render target, but it should not contain * visually important or interactible content. * * \param renderer the rendering context. * \param rect a pointer filled in with the area that is safe for interactive * content. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC bool SDLCALL SDL_GetRenderSafeArea(SDL_Renderer *renderer, SDL_Rect *rect); /** * Set the clip rectangle for rendering on the specified target. * * Each render target has its own clip rectangle. This function sets the * cliprect for the current render target. * * \param renderer the rendering context. * \param rect an SDL_Rect structure representing the clip area, relative to * the viewport, or NULL to disable clipping. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetRenderClipRect * \sa SDL_RenderClipEnabled */ extern SDL_DECLSPEC bool SDLCALL SDL_SetRenderClipRect(SDL_Renderer *renderer, const SDL_Rect *rect); /** * Get the clip rectangle for the current target. * * Each render target has its own clip rectangle. This function gets the * cliprect for the current render target. * * \param renderer the rendering context. * \param rect an SDL_Rect structure filled in with the current clipping area * or an empty rectangle if clipping is disabled. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_RenderClipEnabled * \sa SDL_SetRenderClipRect */ extern SDL_DECLSPEC bool SDLCALL SDL_GetRenderClipRect(SDL_Renderer *renderer, SDL_Rect *rect); /** * Get whether clipping is enabled on the given render target. * * Each render target has its own clip rectangle. This function checks the * cliprect for the current render target. * * \param renderer the rendering context. * \returns true if clipping is enabled or false if not; call SDL_GetError() * for more information. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetRenderClipRect * \sa SDL_SetRenderClipRect */ extern SDL_DECLSPEC bool SDLCALL SDL_RenderClipEnabled(SDL_Renderer *renderer); /** * Set the drawing scale for rendering on the current target. * * The drawing coordinates are scaled by the x/y scaling factors before they * are used by the renderer. This allows resolution independent drawing with a * single coordinate system. * * If this results in scaling or subpixel drawing by the rendering backend, it * will be handled using the appropriate quality hints. For best results use * integer scaling factors. * * Each render target has its own scale. This function sets the scale for the * current render target. * * \param renderer the rendering context. * \param scaleX the horizontal scaling factor. * \param scaleY the vertical scaling factor. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetRenderScale */ extern SDL_DECLSPEC bool SDLCALL SDL_SetRenderScale(SDL_Renderer *renderer, float scaleX, float scaleY); /** * Get the drawing scale for the current target. * * Each render target has its own scale. This function gets the scale for the * current render target. * * \param renderer the rendering context. * \param scaleX a pointer filled in with the horizontal scaling factor. * \param scaleY a pointer filled in with the vertical scaling factor. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_SetRenderScale */ extern SDL_DECLSPEC bool SDLCALL SDL_GetRenderScale(SDL_Renderer *renderer, float *scaleX, float *scaleY); /** * Set the color used for drawing operations. * * Set the color for drawing or filling rectangles, lines, and points, and for * SDL_RenderClear(). * * \param renderer the rendering context. * \param r the red value used to draw on the rendering target. * \param g the green value used to draw on the rendering target. * \param b the blue value used to draw on the rendering target. * \param a the alpha value used to draw on the rendering target; usually * `SDL_ALPHA_OPAQUE` (255). Use SDL_SetRenderDrawBlendMode to * specify how the alpha channel is used. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetRenderDrawColor * \sa SDL_SetRenderDrawColorFloat */ extern SDL_DECLSPEC bool SDLCALL SDL_SetRenderDrawColor(SDL_Renderer *renderer, Uint8 r, Uint8 g, Uint8 b, Uint8 a); /** * Set the color used for drawing operations (Rect, Line and Clear). * * Set the color for drawing or filling rectangles, lines, and points, and for * SDL_RenderClear(). * * \param renderer the rendering context. * \param r the red value used to draw on the rendering target. * \param g the green value used to draw on the rendering target. * \param b the blue value used to draw on the rendering target. * \param a the alpha value used to draw on the rendering target. Use * SDL_SetRenderDrawBlendMode to specify how the alpha channel is * used. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetRenderDrawColorFloat * \sa SDL_SetRenderDrawColor */ extern SDL_DECLSPEC bool SDLCALL SDL_SetRenderDrawColorFloat(SDL_Renderer *renderer, float r, float g, float b, float a); /** * Get the color used for drawing operations (Rect, Line and Clear). * * \param renderer the rendering context. * \param r a pointer filled in with the red value used to draw on the * rendering target. * \param g a pointer filled in with the green value used to draw on the * rendering target. * \param b a pointer filled in with the blue value used to draw on the * rendering target. * \param a a pointer filled in with the alpha value used to draw on the * rendering target; usually `SDL_ALPHA_OPAQUE` (255). * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetRenderDrawColorFloat * \sa SDL_SetRenderDrawColor */ extern SDL_DECLSPEC bool SDLCALL SDL_GetRenderDrawColor(SDL_Renderer *renderer, Uint8 *r, Uint8 *g, Uint8 *b, Uint8 *a); /** * Get the color used for drawing operations (Rect, Line and Clear). * * \param renderer the rendering context. * \param r a pointer filled in with the red value used to draw on the * rendering target. * \param g a pointer filled in with the green value used to draw on the * rendering target. * \param b a pointer filled in with the blue value used to draw on the * rendering target. * \param a a pointer filled in with the alpha value used to draw on the * rendering target. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_SetRenderDrawColorFloat * \sa SDL_GetRenderDrawColor */ extern SDL_DECLSPEC bool SDLCALL SDL_GetRenderDrawColorFloat(SDL_Renderer *renderer, float *r, float *g, float *b, float *a); /** * Set the color scale used for render operations. * * The color scale is an additional scale multiplied into the pixel color * value while rendering. This can be used to adjust the brightness of colors * during HDR rendering, or changing HDR video brightness when playing on an * SDR display. * * The color scale does not affect the alpha channel, only the color * brightness. * * \param renderer the rendering context. * \param scale the color scale value. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetRenderColorScale */ extern SDL_DECLSPEC bool SDLCALL SDL_SetRenderColorScale(SDL_Renderer *renderer, float scale); /** * Get the color scale used for render operations. * * \param renderer the rendering context. * \param scale a pointer filled in with the current color scale value. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_SetRenderColorScale */ extern SDL_DECLSPEC bool SDLCALL SDL_GetRenderColorScale(SDL_Renderer *renderer, float *scale); /** * Set the blend mode used for drawing operations (Fill and Line). * * If the blend mode is not supported, the closest supported mode is chosen. * * \param renderer the rendering context. * \param blendMode the SDL_BlendMode to use for blending. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetRenderDrawBlendMode */ extern SDL_DECLSPEC bool SDLCALL SDL_SetRenderDrawBlendMode(SDL_Renderer *renderer, SDL_BlendMode blendMode); /** * Get the blend mode used for drawing operations. * * \param renderer the rendering context. * \param blendMode a pointer filled in with the current SDL_BlendMode. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_SetRenderDrawBlendMode */ extern SDL_DECLSPEC bool SDLCALL SDL_GetRenderDrawBlendMode(SDL_Renderer *renderer, SDL_BlendMode *blendMode); /** * Clear the current rendering target with the drawing color. * * This function clears the entire rendering target, ignoring the viewport and * the clip rectangle. Note, that clearing will also set/fill all pixels of * the rendering target to current renderer draw color, so make sure to invoke * SDL_SetRenderDrawColor() when needed. * * \param renderer the rendering context. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_SetRenderDrawColor */ extern SDL_DECLSPEC bool SDLCALL SDL_RenderClear(SDL_Renderer *renderer); /** * Draw a point on the current rendering target at subpixel precision. * * \param renderer the renderer which should draw a point. * \param x the x coordinate of the point. * \param y the y coordinate of the point. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_RenderPoints */ extern SDL_DECLSPEC bool SDLCALL SDL_RenderPoint(SDL_Renderer *renderer, float x, float y); /** * Draw multiple points on the current rendering target at subpixel precision. * * \param renderer the renderer which should draw multiple points. * \param points the points to draw. * \param count the number of points to draw. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_RenderPoint */ extern SDL_DECLSPEC bool SDLCALL SDL_RenderPoints(SDL_Renderer *renderer, const SDL_FPoint *points, int count); /** * Draw a line on the current rendering target at subpixel precision. * * \param renderer the renderer which should draw a line. * \param x1 the x coordinate of the start point. * \param y1 the y coordinate of the start point. * \param x2 the x coordinate of the end point. * \param y2 the y coordinate of the end point. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_RenderLines */ extern SDL_DECLSPEC bool SDLCALL SDL_RenderLine(SDL_Renderer *renderer, float x1, float y1, float x2, float y2); /** * Draw a series of connected lines on the current rendering target at * subpixel precision. * * \param renderer the renderer which should draw multiple lines. * \param points the points along the lines. * \param count the number of points, drawing count-1 lines. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_RenderLine */ extern SDL_DECLSPEC bool SDLCALL SDL_RenderLines(SDL_Renderer *renderer, const SDL_FPoint *points, int count); /** * Draw a rectangle on the current rendering target at subpixel precision. * * \param renderer the renderer which should draw a rectangle. * \param rect a pointer to the destination rectangle, or NULL to outline the * entire rendering target. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_RenderRects */ extern SDL_DECLSPEC bool SDLCALL SDL_RenderRect(SDL_Renderer *renderer, const SDL_FRect *rect); /** * Draw some number of rectangles on the current rendering target at subpixel * precision. * * \param renderer the renderer which should draw multiple rectangles. * \param rects a pointer to an array of destination rectangles. * \param count the number of rectangles. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_RenderRect */ extern SDL_DECLSPEC bool SDLCALL SDL_RenderRects(SDL_Renderer *renderer, const SDL_FRect *rects, int count); /** * Fill a rectangle on the current rendering target with the drawing color at * subpixel precision. * * \param renderer the renderer which should fill a rectangle. * \param rect a pointer to the destination rectangle, or NULL for the entire * rendering target. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_RenderFillRects */ extern SDL_DECLSPEC bool SDLCALL SDL_RenderFillRect(SDL_Renderer *renderer, const SDL_FRect *rect); /** * Fill some number of rectangles on the current rendering target with the * drawing color at subpixel precision. * * \param renderer the renderer which should fill multiple rectangles. * \param rects a pointer to an array of destination rectangles. * \param count the number of rectangles. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_RenderFillRect */ extern SDL_DECLSPEC bool SDLCALL SDL_RenderFillRects(SDL_Renderer *renderer, const SDL_FRect *rects, int count); /** * Copy a portion of the texture to the current rendering target at subpixel * precision. * * \param renderer the renderer which should copy parts of a texture. * \param texture the source texture. * \param srcrect a pointer to the source rectangle, or NULL for the entire * texture. * \param dstrect a pointer to the destination rectangle, or NULL for the * entire rendering target. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_RenderTextureRotated * \sa SDL_RenderTextureTiled */ extern SDL_DECLSPEC bool SDLCALL SDL_RenderTexture(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_FRect *srcrect, const SDL_FRect *dstrect); /** * Copy a portion of the source texture to the current rendering target, with * rotation and flipping, at subpixel precision. * * \param renderer the renderer which should copy parts of a texture. * \param texture the source texture. * \param srcrect a pointer to the source rectangle, or NULL for the entire * texture. * \param dstrect a pointer to the destination rectangle, or NULL for the * entire rendering target. * \param angle an angle in degrees that indicates the rotation that will be * applied to dstrect, rotating it in a clockwise direction. * \param center a pointer to a point indicating the point around which * dstrect will be rotated (if NULL, rotation will be done * around dstrect.w/2, dstrect.h/2). * \param flip an SDL_FlipMode value stating which flipping actions should be * performed on the texture. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_RenderTexture */ extern SDL_DECLSPEC bool SDLCALL SDL_RenderTextureRotated(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_FRect *srcrect, const SDL_FRect *dstrect, double angle, const SDL_FPoint *center, SDL_FlipMode flip); /** * Copy a portion of the source texture to the current rendering target, with * affine transform, at subpixel precision. * * \param renderer the renderer which should copy parts of a texture. * \param texture the source texture. * \param srcrect a pointer to the source rectangle, or NULL for the entire * texture. * \param origin a pointer to a point indicating where the top-left corner of * srcrect should be mapped to, or NULL for the rendering * target's origin. * \param right a pointer to a point indicating where the top-right corner of * srcrect should be mapped to, or NULL for the rendering * target's top-right corner. * \param down a pointer to a point indicating where the bottom-left corner of * srcrect should be mapped to, or NULL for the rendering target's * bottom-left corner. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety You may only call this function from the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_RenderTexture */ extern SDL_DECLSPEC bool SDLCALL SDL_RenderTextureAffine(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_FRect *srcrect, const SDL_FPoint *origin, const SDL_FPoint *right, const SDL_FPoint *down); /** * Tile a portion of the texture to the current rendering target at subpixel * precision. * * The pixels in `srcrect` will be repeated as many times as needed to * completely fill `dstrect`. * * \param renderer the renderer which should copy parts of a texture. * \param texture the source texture. * \param srcrect a pointer to the source rectangle, or NULL for the entire * texture. * \param scale the scale used to transform srcrect into the destination * rectangle, e.g. a 32x32 texture with a scale of 2 would fill * 64x64 tiles. * \param dstrect a pointer to the destination rectangle, or NULL for the * entire rendering target. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_RenderTexture */ extern SDL_DECLSPEC bool SDLCALL SDL_RenderTextureTiled(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_FRect *srcrect, float scale, const SDL_FRect *dstrect); /** * Perform a scaled copy using the 9-grid algorithm to the current rendering * target at subpixel precision. * * The pixels in the texture are split into a 3x3 grid, using the different * corner sizes for each corner, and the sides and center making up the * remaining pixels. The corners are then scaled using `scale` and fit into * the corners of the destination rectangle. The sides and center are then * stretched into place to cover the remaining destination rectangle. * * \param renderer the renderer which should copy parts of a texture. * \param texture the source texture. * \param srcrect the SDL_Rect structure representing the rectangle to be used * for the 9-grid, or NULL to use the entire texture. * \param left_width the width, in pixels, of the left corners in `srcrect`. * \param right_width the width, in pixels, of the right corners in `srcrect`. * \param top_height the height, in pixels, of the top corners in `srcrect`. * \param bottom_height the height, in pixels, of the bottom corners in * `srcrect`. * \param scale the scale used to transform the corner of `srcrect` into the * corner of `dstrect`, or 0.0f for an unscaled copy. * \param dstrect a pointer to the destination rectangle, or NULL for the * entire rendering target. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_RenderTexture * \sa SDL_RenderTexture9GridTiled */ extern SDL_DECLSPEC bool SDLCALL SDL_RenderTexture9Grid(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_FRect *srcrect, float left_width, float right_width, float top_height, float bottom_height, float scale, const SDL_FRect *dstrect); /** * Perform a scaled copy using the 9-grid algorithm to the current rendering * target at subpixel precision. * * The pixels in the texture are split into a 3x3 grid, using the different * corner sizes for each corner, and the sides and center making up the * remaining pixels. The corners are then scaled using `scale` and fit into * the corners of the destination rectangle. The sides and center are then * tiled into place to cover the remaining destination rectangle. * * \param renderer the renderer which should copy parts of a texture. * \param texture the source texture. * \param srcrect the SDL_Rect structure representing the rectangle to be used * for the 9-grid, or NULL to use the entire texture. * \param left_width the width, in pixels, of the left corners in `srcrect`. * \param right_width the width, in pixels, of the right corners in `srcrect`. * \param top_height the height, in pixels, of the top corners in `srcrect`. * \param bottom_height the height, in pixels, of the bottom corners in * `srcrect`. * \param scale the scale used to transform the corner of `srcrect` into the * corner of `dstrect`, or 0.0f for an unscaled copy. * \param dstrect a pointer to the destination rectangle, or NULL for the * entire rendering target. * \param tileScale the scale used to transform the borders and center of * `srcrect` into the borders and middle of `dstrect`, or * 1.0f for an unscaled copy. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.4.0. * * \sa SDL_RenderTexture * \sa SDL_RenderTexture9Grid */ extern SDL_DECLSPEC bool SDLCALL SDL_RenderTexture9GridTiled(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_FRect *srcrect, float left_width, float right_width, float top_height, float bottom_height, float scale, const SDL_FRect *dstrect, float tileScale); /** * Render a list of triangles, optionally using a texture and indices into the * vertex array Color and alpha modulation is done per vertex * (SDL_SetTextureColorMod and SDL_SetTextureAlphaMod are ignored). * * \param renderer the rendering context. * \param texture (optional) The SDL texture to use. * \param vertices vertices. * \param num_vertices number of vertices. * \param indices (optional) An array of integer indices into the 'vertices' * array, if NULL all vertices will be rendered in sequential * order. * \param num_indices number of indices. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_RenderGeometryRaw * \sa SDL_SetRenderTextureAddressMode */ extern SDL_DECLSPEC bool SDLCALL SDL_RenderGeometry(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Vertex *vertices, int num_vertices, const int *indices, int num_indices); /** * Render a list of triangles, optionally using a texture and indices into the * vertex arrays Color and alpha modulation is done per vertex * (SDL_SetTextureColorMod and SDL_SetTextureAlphaMod are ignored). * * \param renderer the rendering context. * \param texture (optional) The SDL texture to use. * \param xy vertex positions. * \param xy_stride byte size to move from one element to the next element. * \param color vertex colors (as SDL_FColor). * \param color_stride byte size to move from one element to the next element. * \param uv vertex normalized texture coordinates. * \param uv_stride byte size to move from one element to the next element. * \param num_vertices number of vertices. * \param indices (optional) An array of indices into the 'vertices' arrays, * if NULL all vertices will be rendered in sequential order. * \param num_indices number of indices. * \param size_indices index size: 1 (byte), 2 (short), 4 (int). * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_RenderGeometry * \sa SDL_SetRenderTextureAddressMode */ extern SDL_DECLSPEC bool SDLCALL SDL_RenderGeometryRaw(SDL_Renderer *renderer, SDL_Texture *texture, const float *xy, int xy_stride, const SDL_FColor *color, int color_stride, const float *uv, int uv_stride, int num_vertices, const void *indices, int num_indices, int size_indices); /** * Set the texture addressing mode used in SDL_RenderGeometry(). * * \param renderer the rendering context. * \param u_mode the SDL_TextureAddressMode to use for horizontal texture * coordinates in SDL_RenderGeometry(). * \param v_mode the SDL_TextureAddressMode to use for vertical texture * coordinates in SDL_RenderGeometry(). * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.4.0. * * \sa SDL_RenderGeometry * \sa SDL_RenderGeometryRaw * \sa SDL_GetRenderTextureAddressMode */ extern SDL_DECLSPEC bool SDLCALL SDL_SetRenderTextureAddressMode(SDL_Renderer *renderer, SDL_TextureAddressMode u_mode, SDL_TextureAddressMode v_mode); /** * Get the texture addressing mode used in SDL_RenderGeometry(). * * \param renderer the rendering context. * \param u_mode a pointer filled in with the SDL_TextureAddressMode to use * for horizontal texture coordinates in SDL_RenderGeometry(), * may be NULL. * \param v_mode a pointer filled in with the SDL_TextureAddressMode to use * for vertical texture coordinates in SDL_RenderGeometry(), may * be NULL. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.4.0. * * \sa SDL_SetRenderTextureAddressMode */ extern SDL_DECLSPEC bool SDLCALL SDL_GetRenderTextureAddressMode(SDL_Renderer *renderer, SDL_TextureAddressMode *u_mode, SDL_TextureAddressMode *v_mode); /** * Read pixels from the current rendering target. * * The returned surface contains pixels inside the desired area clipped to the * current viewport, and should be freed with SDL_DestroySurface(). * * Note that this returns the actual pixels on the screen, so if you are using * logical presentation you should use SDL_GetRenderLogicalPresentationRect() * to get the area containing your content. * * **WARNING**: This is a very slow operation, and should not be used * frequently. If you're using this on the main rendering target, it should be * called after rendering and before SDL_RenderPresent(). * * \param renderer the rendering context. * \param rect an SDL_Rect structure representing the area to read, which will * be clipped to the current viewport, or NULL for the entire * viewport. * \returns a new SDL_Surface on success or NULL on failure; call * SDL_GetError() for more information. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC SDL_Surface * SDLCALL SDL_RenderReadPixels(SDL_Renderer *renderer, const SDL_Rect *rect); /** * Update the screen with any rendering performed since the previous call. * * SDL's rendering functions operate on a backbuffer; that is, calling a * rendering function such as SDL_RenderLine() does not directly put a line on * the screen, but rather updates the backbuffer. As such, you compose your * entire scene and *present* the composed backbuffer to the screen as a * complete picture. * * Therefore, when using SDL's rendering API, one does all drawing intended * for the frame, and then calls this function once per frame to present the * final drawing to the user. * * The backbuffer should be considered invalidated after each present; do not * assume that previous contents will exist between frames. You are strongly * encouraged to call SDL_RenderClear() to initialize the backbuffer before * starting each new frame's drawing, even if you plan to overwrite every * pixel. * * Please note, that in case of rendering to a texture - there is **no need** * to call `SDL_RenderPresent` after drawing needed objects to a texture, and * should not be done; you are only required to change back the rendering * target to default via `SDL_SetRenderTarget(renderer, NULL)` afterwards, as * textures by themselves do not have a concept of backbuffers. Calling * SDL_RenderPresent while rendering to a texture will fail. * * \param renderer the rendering context. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_CreateRenderer * \sa SDL_RenderClear * \sa SDL_RenderFillRect * \sa SDL_RenderFillRects * \sa SDL_RenderLine * \sa SDL_RenderLines * \sa SDL_RenderPoint * \sa SDL_RenderPoints * \sa SDL_RenderRect * \sa SDL_RenderRects * \sa SDL_SetRenderDrawBlendMode * \sa SDL_SetRenderDrawColor */ extern SDL_DECLSPEC bool SDLCALL SDL_RenderPresent(SDL_Renderer *renderer); /** * Destroy the specified texture. * * Passing NULL or an otherwise invalid texture will set the SDL error message * to "Invalid texture". * * \param texture the texture to destroy. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_CreateTexture * \sa SDL_CreateTextureFromSurface */ extern SDL_DECLSPEC void SDLCALL SDL_DestroyTexture(SDL_Texture *texture); /** * Destroy the rendering context for a window and free all associated * textures. * * This should be called before destroying the associated window. * * \param renderer the rendering context. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_CreateRenderer */ extern SDL_DECLSPEC void SDLCALL SDL_DestroyRenderer(SDL_Renderer *renderer); /** * Force the rendering context to flush any pending commands and state. * * You do not need to (and in fact, shouldn't) call this function unless you * are planning to call into OpenGL/Direct3D/Metal/whatever directly, in * addition to using an SDL_Renderer. * * This is for a very-specific case: if you are using SDL's render API, and * you plan to make OpenGL/D3D/whatever calls in addition to SDL render API * calls. If this applies, you should call this function between calls to * SDL's render API and the low-level API you're using in cooperation. * * In all other cases, you can ignore this function. * * This call makes SDL flush any pending rendering work it was queueing up to * do later in a single batch, and marks any internal cached state as invalid, * so it'll prepare all its state again later, from scratch. * * This means you do not need to save state in your rendering code to protect * the SDL renderer. However, there lots of arbitrary pieces of Direct3D and * OpenGL state that can confuse things; you should use your best judgment and * be prepared to make changes if specific state needs to be protected. * * \param renderer the rendering context. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC bool SDLCALL SDL_FlushRenderer(SDL_Renderer *renderer); /** * Get the CAMetalLayer associated with the given Metal renderer. * * This function returns `void *`, so SDL doesn't have to include Metal's * headers, but it can be safely cast to a `CAMetalLayer *`. * * \param renderer the renderer to query. * \returns a `CAMetalLayer *` on success, or NULL if the renderer isn't a * Metal renderer. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetRenderMetalCommandEncoder */ extern SDL_DECLSPEC void * SDLCALL SDL_GetRenderMetalLayer(SDL_Renderer *renderer); /** * Get the Metal command encoder for the current frame. * * This function returns `void *`, so SDL doesn't have to include Metal's * headers, but it can be safely cast to an `id`. * * This will return NULL if Metal refuses to give SDL a drawable to render to, * which might happen if the window is hidden/minimized/offscreen. This * doesn't apply to command encoders for render targets, just the window's * backbuffer. Check your return values! * * \param renderer the renderer to query. * \returns an `id` on success, or NULL if the * renderer isn't a Metal renderer or there was an error. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetRenderMetalLayer */ extern SDL_DECLSPEC void * SDLCALL SDL_GetRenderMetalCommandEncoder(SDL_Renderer *renderer); /** * Add a set of synchronization semaphores for the current frame. * * The Vulkan renderer will wait for `wait_semaphore` before submitting * rendering commands and signal `signal_semaphore` after rendering commands * are complete for this frame. * * This should be called each frame that you want semaphore synchronization. * The Vulkan renderer may have multiple frames in flight on the GPU, so you * should have multiple semaphores that are used for synchronization. Querying * SDL_PROP_RENDERER_VULKAN_SWAPCHAIN_IMAGE_COUNT_NUMBER will give you the * maximum number of semaphores you'll need. * * \param renderer the rendering context. * \param wait_stage_mask the VkPipelineStageFlags for the wait. * \param wait_semaphore a VkSempahore to wait on before rendering the current * frame, or 0 if not needed. * \param signal_semaphore a VkSempahore that SDL will signal when rendering * for the current frame is complete, or 0 if not * needed. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety It is **NOT** safe to call this function from two threads at * once. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC bool SDLCALL SDL_AddVulkanRenderSemaphores(SDL_Renderer *renderer, Uint32 wait_stage_mask, Sint64 wait_semaphore, Sint64 signal_semaphore); /** * Toggle VSync of the given renderer. * * When a renderer is created, vsync defaults to SDL_RENDERER_VSYNC_DISABLED. * * The `vsync` parameter can be 1 to synchronize present with every vertical * refresh, 2 to synchronize present with every second vertical refresh, etc., * SDL_RENDERER_VSYNC_ADAPTIVE for late swap tearing (adaptive vsync), or * SDL_RENDERER_VSYNC_DISABLED to disable. Not every value is supported by * every driver, so you should check the return value to see whether the * requested setting is supported. * * \param renderer the renderer to toggle. * \param vsync the vertical refresh sync interval. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetRenderVSync */ extern SDL_DECLSPEC bool SDLCALL SDL_SetRenderVSync(SDL_Renderer *renderer, int vsync); #define SDL_RENDERER_VSYNC_DISABLED 0 #define SDL_RENDERER_VSYNC_ADAPTIVE (-1) /** * Get VSync of the given renderer. * * \param renderer the renderer to toggle. * \param vsync an int filled with the current vertical refresh sync interval. * See SDL_SetRenderVSync() for the meaning of the value. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_SetRenderVSync */ extern SDL_DECLSPEC bool SDLCALL SDL_GetRenderVSync(SDL_Renderer *renderer, int *vsync); /** * The size, in pixels, of a single SDL_RenderDebugText() character. * * The font is monospaced and square, so this applies to all characters. * * \since This macro is available since SDL 3.2.0. * * \sa SDL_RenderDebugText */ #define SDL_DEBUG_TEXT_FONT_CHARACTER_SIZE 8 /** * Draw debug text to an SDL_Renderer. * * This function will render a string of text to an SDL_Renderer. Note that * this is a convenience function for debugging, with severe limitations, and * not intended to be used for production apps and games. * * Among these limitations: * * - It accepts UTF-8 strings, but will only renders ASCII characters. * - It has a single, tiny size (8x8 pixels). You can use logical presentation * or SDL_SetRenderScale() to adjust it. * - It uses a simple, hardcoded bitmap font. It does not allow different font * selections and it does not support truetype, for proper scaling. * - It does no word-wrapping and does not treat newline characters as a line * break. If the text goes out of the window, it's gone. * * For serious text rendering, there are several good options, such as * SDL_ttf, stb_truetype, or other external libraries. * * On first use, this will create an internal texture for rendering glyphs. * This texture will live until the renderer is destroyed. * * The text is drawn in the color specified by SDL_SetRenderDrawColor(). * * \param renderer the renderer which should draw a line of text. * \param x the x coordinate where the top-left corner of the text will draw. * \param y the y coordinate where the top-left corner of the text will draw. * \param str the string to render. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_RenderDebugTextFormat * \sa SDL_DEBUG_TEXT_FONT_CHARACTER_SIZE */ extern SDL_DECLSPEC bool SDLCALL SDL_RenderDebugText(SDL_Renderer *renderer, float x, float y, const char *str); /** * Draw debug text to an SDL_Renderer. * * This function will render a printf()-style format string to a renderer. * Note that this is a convenience function for debugging, with severe * limitations, and is not intended to be used for production apps and games. * * For the full list of limitations and other useful information, see * SDL_RenderDebugText. * * \param renderer the renderer which should draw the text. * \param x the x coordinate where the top-left corner of the text will draw. * \param y the y coordinate where the top-left corner of the text will draw. * \param fmt the format string to draw. * \param ... additional parameters matching % tokens in the `fmt` string, if * any. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_RenderDebugText * \sa SDL_DEBUG_TEXT_FONT_CHARACTER_SIZE */ extern SDL_DECLSPEC bool SDLCALL SDL_RenderDebugTextFormat(SDL_Renderer *renderer, float x, float y, SDL_PRINTF_FORMAT_STRING const char *fmt, ...) SDL_PRINTF_VARARG_FUNC(4); /** * Set default scale mode for new textures for given renderer. * * When a renderer is created, scale_mode defaults to SDL_SCALEMODE_LINEAR. * * \param renderer the renderer to update. * \param scale_mode the scale mode to change to for new textures. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.4.0. * * \sa SDL_GetDefaultTextureScaleMode */ extern SDL_DECLSPEC bool SDLCALL SDL_SetDefaultTextureScaleMode(SDL_Renderer *renderer, SDL_ScaleMode scale_mode); /** * Get default texture scale mode of the given renderer. * * \param renderer the renderer to get data from. * \param scale_mode a SDL_ScaleMode filled with current default scale mode. * See SDL_SetDefaultTextureScaleMode() for the meaning of * the value. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.4.0. * * \sa SDL_SetDefaultTextureScaleMode */ extern SDL_DECLSPEC bool SDLCALL SDL_GetDefaultTextureScaleMode(SDL_Renderer *renderer, SDL_ScaleMode *scale_mode); /** * A structure specifying the parameters of a GPU render state. * * \since This struct is available since SDL 3.4.0. * * \sa SDL_CreateGPURenderState */ typedef struct SDL_GPURenderStateCreateInfo { SDL_GPUShader *fragment_shader; /**< The fragment shader to use when this render state is active */ Sint32 num_sampler_bindings; /**< The number of additional fragment samplers to bind when this render state is active */ const SDL_GPUTextureSamplerBinding *sampler_bindings; /**< Additional fragment samplers to bind when this render state is active */ Sint32 num_storage_textures; /**< The number of storage textures to bind when this render state is active */ SDL_GPUTexture *const *storage_textures; /**< Storage textures to bind when this render state is active */ Sint32 num_storage_buffers; /**< The number of storage buffers to bind when this render state is active */ SDL_GPUBuffer *const *storage_buffers; /**< Storage buffers to bind when this render state is active */ SDL_PropertiesID props; /**< A properties ID for extensions. Should be 0 if no extensions are needed. */ } SDL_GPURenderStateCreateInfo; /** * A custom GPU render state. * * \since This struct is available since SDL 3.4.0. * * \sa SDL_CreateGPURenderState * \sa SDL_SetGPURenderStateFragmentUniforms * \sa SDL_SetGPURenderState * \sa SDL_DestroyGPURenderState */ typedef struct SDL_GPURenderState SDL_GPURenderState; /** * Create custom GPU render state. * * \param renderer the renderer to use. * \param createinfo a struct describing the GPU render state to create. * \returns a custom GPU render state or NULL on failure; call SDL_GetError() * for more information. * * \threadsafety This function should be called on the thread that created the * renderer. * * \since This function is available since SDL 3.4.0. * * \sa SDL_SetGPURenderStateFragmentUniforms * \sa SDL_SetGPURenderState * \sa SDL_DestroyGPURenderState */ extern SDL_DECLSPEC SDL_GPURenderState * SDLCALL SDL_CreateGPURenderState(SDL_Renderer *renderer, const SDL_GPURenderStateCreateInfo *createinfo); /** * Set fragment shader uniform variables in a custom GPU render state. * * The data is copied and will be pushed using * SDL_PushGPUFragmentUniformData() during draw call execution. * * \param state the state to modify. * \param slot_index the fragment uniform slot to push data to. * \param data client data to write. * \param length the length of the data to write. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety This function should be called on the thread that created the * renderer. * * \since This function is available since SDL 3.4.0. */ extern SDL_DECLSPEC bool SDLCALL SDL_SetGPURenderStateFragmentUniforms(SDL_GPURenderState *state, Uint32 slot_index, const void *data, Uint32 length); /** * Set custom GPU render state. * * This function sets custom GPU render state for subsequent draw calls. This * allows using custom shaders with the GPU renderer. * * \param renderer the renderer to use. * \param state the state to to use, or NULL to clear custom GPU render state. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety This function should be called on the thread that created the * renderer. * * \since This function is available since SDL 3.4.0. */ extern SDL_DECLSPEC bool SDLCALL SDL_SetGPURenderState(SDL_Renderer *renderer, SDL_GPURenderState *state); /** * Destroy custom GPU render state. * * \param state the state to destroy. * * \threadsafety This function should be called on the thread that created the * renderer. * * \since This function is available since SDL 3.4.0. * * \sa SDL_CreateGPURenderState */ extern SDL_DECLSPEC void SDLCALL SDL_DestroyGPURenderState(SDL_GPURenderState *state); /* Ends C function definitions when using C++ */ #ifdef __cplusplus } #endif #include #endif /* SDL_render_h_ */ ================================================ FILE: deps/include/SDL3/SDL_revision.h ================================================ /* Simple DirectMedia Layer Copyright (C) 1997-2026 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ /* WIKI CATEGORY: Version */ /* * SDL_revision.h contains the SDL revision, which might be defined on the * compiler command line, or generated right into the header itself by the * build system. */ #ifndef SDL_revision_h_ #define SDL_revision_h_ #define SDL_VENDOR_INFO "libsdl.org" #if defined(SDL_VENDOR_INFO) #define SDL_REVISION "SDL-release-3.4.4-0-g5848e584a (" SDL_VENDOR_INFO ")" #else #define SDL_REVISION "SDL-release-3.4.4-0-g5848e584a" #endif #endif /* SDL_revision_h_ */ ================================================ FILE: deps/include/SDL3/SDL_scancode.h ================================================ /* Simple DirectMedia Layer Copyright (C) 1997-2026 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ /** * # CategoryScancode * * Defines keyboard scancodes. * * Please refer to the Best Keyboard Practices document for details on what * this information means and how best to use it. * * https://wiki.libsdl.org/SDL3/BestKeyboardPractices */ #ifndef SDL_scancode_h_ #define SDL_scancode_h_ #include /** * The SDL keyboard scancode representation. * * An SDL scancode is the physical representation of a key on the keyboard, * independent of language and keyboard mapping. * * Values of this type are used to represent keyboard keys, among other places * in the `scancode` field of the SDL_KeyboardEvent structure. * * The values in this enumeration are based on the USB usage page standard: * https://usb.org/sites/default/files/hut1_5.pdf * * \since This enum is available since SDL 3.2.0. */ typedef enum SDL_Scancode { SDL_SCANCODE_UNKNOWN = 0, /** * \name Usage page 0x07 * * These values are from usage page 0x07 (USB keyboard page). */ /* @{ */ SDL_SCANCODE_A = 4, SDL_SCANCODE_B = 5, SDL_SCANCODE_C = 6, SDL_SCANCODE_D = 7, SDL_SCANCODE_E = 8, SDL_SCANCODE_F = 9, SDL_SCANCODE_G = 10, SDL_SCANCODE_H = 11, SDL_SCANCODE_I = 12, SDL_SCANCODE_J = 13, SDL_SCANCODE_K = 14, SDL_SCANCODE_L = 15, SDL_SCANCODE_M = 16, SDL_SCANCODE_N = 17, SDL_SCANCODE_O = 18, SDL_SCANCODE_P = 19, SDL_SCANCODE_Q = 20, SDL_SCANCODE_R = 21, SDL_SCANCODE_S = 22, SDL_SCANCODE_T = 23, SDL_SCANCODE_U = 24, SDL_SCANCODE_V = 25, SDL_SCANCODE_W = 26, SDL_SCANCODE_X = 27, SDL_SCANCODE_Y = 28, SDL_SCANCODE_Z = 29, SDL_SCANCODE_1 = 30, SDL_SCANCODE_2 = 31, SDL_SCANCODE_3 = 32, SDL_SCANCODE_4 = 33, SDL_SCANCODE_5 = 34, SDL_SCANCODE_6 = 35, SDL_SCANCODE_7 = 36, SDL_SCANCODE_8 = 37, SDL_SCANCODE_9 = 38, SDL_SCANCODE_0 = 39, SDL_SCANCODE_RETURN = 40, SDL_SCANCODE_ESCAPE = 41, SDL_SCANCODE_BACKSPACE = 42, SDL_SCANCODE_TAB = 43, SDL_SCANCODE_SPACE = 44, SDL_SCANCODE_MINUS = 45, SDL_SCANCODE_EQUALS = 46, SDL_SCANCODE_LEFTBRACKET = 47, SDL_SCANCODE_RIGHTBRACKET = 48, SDL_SCANCODE_BACKSLASH = 49, /**< Located at the lower left of the return * key on ISO keyboards and at the right end * of the QWERTY row on ANSI keyboards. * Produces REVERSE SOLIDUS (backslash) and * VERTICAL LINE in a US layout, REVERSE * SOLIDUS and VERTICAL LINE in a UK Mac * layout, NUMBER SIGN and TILDE in a UK * Windows layout, DOLLAR SIGN and POUND SIGN * in a Swiss German layout, NUMBER SIGN and * APOSTROPHE in a German layout, GRAVE * ACCENT and POUND SIGN in a French Mac * layout, and ASTERISK and MICRO SIGN in a * French Windows layout. */ SDL_SCANCODE_NONUSHASH = 50, /**< ISO USB keyboards actually use this code * instead of 49 for the same key, but all * OSes I've seen treat the two codes * identically. So, as an implementor, unless * your keyboard generates both of those * codes and your OS treats them differently, * you should generate SDL_SCANCODE_BACKSLASH * instead of this code. As a user, you * should not rely on this code because SDL * will never generate it with most (all?) * keyboards. */ SDL_SCANCODE_SEMICOLON = 51, SDL_SCANCODE_APOSTROPHE = 52, SDL_SCANCODE_GRAVE = 53, /**< Located in the top left corner (on both ANSI * and ISO keyboards). Produces GRAVE ACCENT and * TILDE in a US Windows layout and in US and UK * Mac layouts on ANSI keyboards, GRAVE ACCENT * and NOT SIGN in a UK Windows layout, SECTION * SIGN and PLUS-MINUS SIGN in US and UK Mac * layouts on ISO keyboards, SECTION SIGN and * DEGREE SIGN in a Swiss German layout (Mac: * only on ISO keyboards), CIRCUMFLEX ACCENT and * DEGREE SIGN in a German layout (Mac: only on * ISO keyboards), SUPERSCRIPT TWO and TILDE in a * French Windows layout, COMMERCIAL AT and * NUMBER SIGN in a French Mac layout on ISO * keyboards, and LESS-THAN SIGN and GREATER-THAN * SIGN in a Swiss German, German, or French Mac * layout on ANSI keyboards. */ SDL_SCANCODE_COMMA = 54, SDL_SCANCODE_PERIOD = 55, SDL_SCANCODE_SLASH = 56, SDL_SCANCODE_CAPSLOCK = 57, SDL_SCANCODE_F1 = 58, SDL_SCANCODE_F2 = 59, SDL_SCANCODE_F3 = 60, SDL_SCANCODE_F4 = 61, SDL_SCANCODE_F5 = 62, SDL_SCANCODE_F6 = 63, SDL_SCANCODE_F7 = 64, SDL_SCANCODE_F8 = 65, SDL_SCANCODE_F9 = 66, SDL_SCANCODE_F10 = 67, SDL_SCANCODE_F11 = 68, SDL_SCANCODE_F12 = 69, SDL_SCANCODE_PRINTSCREEN = 70, SDL_SCANCODE_SCROLLLOCK = 71, SDL_SCANCODE_PAUSE = 72, SDL_SCANCODE_INSERT = 73, /**< insert on PC, help on some Mac keyboards (but does send code 73, not 117) */ SDL_SCANCODE_HOME = 74, SDL_SCANCODE_PAGEUP = 75, SDL_SCANCODE_DELETE = 76, SDL_SCANCODE_END = 77, SDL_SCANCODE_PAGEDOWN = 78, SDL_SCANCODE_RIGHT = 79, SDL_SCANCODE_LEFT = 80, SDL_SCANCODE_DOWN = 81, SDL_SCANCODE_UP = 82, SDL_SCANCODE_NUMLOCKCLEAR = 83, /**< num lock on PC, clear on Mac keyboards */ SDL_SCANCODE_KP_DIVIDE = 84, SDL_SCANCODE_KP_MULTIPLY = 85, SDL_SCANCODE_KP_MINUS = 86, SDL_SCANCODE_KP_PLUS = 87, SDL_SCANCODE_KP_ENTER = 88, SDL_SCANCODE_KP_1 = 89, SDL_SCANCODE_KP_2 = 90, SDL_SCANCODE_KP_3 = 91, SDL_SCANCODE_KP_4 = 92, SDL_SCANCODE_KP_5 = 93, SDL_SCANCODE_KP_6 = 94, SDL_SCANCODE_KP_7 = 95, SDL_SCANCODE_KP_8 = 96, SDL_SCANCODE_KP_9 = 97, SDL_SCANCODE_KP_0 = 98, SDL_SCANCODE_KP_PERIOD = 99, SDL_SCANCODE_NONUSBACKSLASH = 100, /**< This is the additional key that ISO * keyboards have over ANSI ones, * located between left shift and Z. * Produces GRAVE ACCENT and TILDE in a * US or UK Mac layout, REVERSE SOLIDUS * (backslash) and VERTICAL LINE in a * US or UK Windows layout, and * LESS-THAN SIGN and GREATER-THAN SIGN * in a Swiss German, German, or French * layout. */ SDL_SCANCODE_APPLICATION = 101, /**< windows contextual menu, compose */ SDL_SCANCODE_POWER = 102, /**< The USB document says this is a status flag, * not a physical key - but some Mac keyboards * do have a power key. */ SDL_SCANCODE_KP_EQUALS = 103, SDL_SCANCODE_F13 = 104, SDL_SCANCODE_F14 = 105, SDL_SCANCODE_F15 = 106, SDL_SCANCODE_F16 = 107, SDL_SCANCODE_F17 = 108, SDL_SCANCODE_F18 = 109, SDL_SCANCODE_F19 = 110, SDL_SCANCODE_F20 = 111, SDL_SCANCODE_F21 = 112, SDL_SCANCODE_F22 = 113, SDL_SCANCODE_F23 = 114, SDL_SCANCODE_F24 = 115, SDL_SCANCODE_EXECUTE = 116, SDL_SCANCODE_HELP = 117, /**< AL Integrated Help Center */ SDL_SCANCODE_MENU = 118, /**< Menu (show menu) */ SDL_SCANCODE_SELECT = 119, SDL_SCANCODE_STOP = 120, /**< AC Stop */ SDL_SCANCODE_AGAIN = 121, /**< AC Redo/Repeat */ SDL_SCANCODE_UNDO = 122, /**< AC Undo */ SDL_SCANCODE_CUT = 123, /**< AC Cut */ SDL_SCANCODE_COPY = 124, /**< AC Copy */ SDL_SCANCODE_PASTE = 125, /**< AC Paste */ SDL_SCANCODE_FIND = 126, /**< AC Find */ SDL_SCANCODE_MUTE = 127, SDL_SCANCODE_VOLUMEUP = 128, SDL_SCANCODE_VOLUMEDOWN = 129, /* not sure whether there's a reason to enable these */ /* SDL_SCANCODE_LOCKINGCAPSLOCK = 130, */ /* SDL_SCANCODE_LOCKINGNUMLOCK = 131, */ /* SDL_SCANCODE_LOCKINGSCROLLLOCK = 132, */ SDL_SCANCODE_KP_COMMA = 133, SDL_SCANCODE_KP_EQUALSAS400 = 134, SDL_SCANCODE_INTERNATIONAL1 = 135, /**< used on Asian keyboards, see footnotes in USB doc */ SDL_SCANCODE_INTERNATIONAL2 = 136, SDL_SCANCODE_INTERNATIONAL3 = 137, /**< Yen */ SDL_SCANCODE_INTERNATIONAL4 = 138, SDL_SCANCODE_INTERNATIONAL5 = 139, SDL_SCANCODE_INTERNATIONAL6 = 140, SDL_SCANCODE_INTERNATIONAL7 = 141, SDL_SCANCODE_INTERNATIONAL8 = 142, SDL_SCANCODE_INTERNATIONAL9 = 143, SDL_SCANCODE_LANG1 = 144, /**< Hangul/English toggle */ SDL_SCANCODE_LANG2 = 145, /**< Hanja conversion */ SDL_SCANCODE_LANG3 = 146, /**< Katakana */ SDL_SCANCODE_LANG4 = 147, /**< Hiragana */ SDL_SCANCODE_LANG5 = 148, /**< Zenkaku/Hankaku */ SDL_SCANCODE_LANG6 = 149, /**< reserved */ SDL_SCANCODE_LANG7 = 150, /**< reserved */ SDL_SCANCODE_LANG8 = 151, /**< reserved */ SDL_SCANCODE_LANG9 = 152, /**< reserved */ SDL_SCANCODE_ALTERASE = 153, /**< Erase-Eaze */ SDL_SCANCODE_SYSREQ = 154, SDL_SCANCODE_CANCEL = 155, /**< AC Cancel */ SDL_SCANCODE_CLEAR = 156, SDL_SCANCODE_PRIOR = 157, SDL_SCANCODE_RETURN2 = 158, SDL_SCANCODE_SEPARATOR = 159, SDL_SCANCODE_OUT = 160, SDL_SCANCODE_OPER = 161, SDL_SCANCODE_CLEARAGAIN = 162, SDL_SCANCODE_CRSEL = 163, SDL_SCANCODE_EXSEL = 164, SDL_SCANCODE_KP_00 = 176, SDL_SCANCODE_KP_000 = 177, SDL_SCANCODE_THOUSANDSSEPARATOR = 178, SDL_SCANCODE_DECIMALSEPARATOR = 179, SDL_SCANCODE_CURRENCYUNIT = 180, SDL_SCANCODE_CURRENCYSUBUNIT = 181, SDL_SCANCODE_KP_LEFTPAREN = 182, SDL_SCANCODE_KP_RIGHTPAREN = 183, SDL_SCANCODE_KP_LEFTBRACE = 184, SDL_SCANCODE_KP_RIGHTBRACE = 185, SDL_SCANCODE_KP_TAB = 186, SDL_SCANCODE_KP_BACKSPACE = 187, SDL_SCANCODE_KP_A = 188, SDL_SCANCODE_KP_B = 189, SDL_SCANCODE_KP_C = 190, SDL_SCANCODE_KP_D = 191, SDL_SCANCODE_KP_E = 192, SDL_SCANCODE_KP_F = 193, SDL_SCANCODE_KP_XOR = 194, SDL_SCANCODE_KP_POWER = 195, SDL_SCANCODE_KP_PERCENT = 196, SDL_SCANCODE_KP_LESS = 197, SDL_SCANCODE_KP_GREATER = 198, SDL_SCANCODE_KP_AMPERSAND = 199, SDL_SCANCODE_KP_DBLAMPERSAND = 200, SDL_SCANCODE_KP_VERTICALBAR = 201, SDL_SCANCODE_KP_DBLVERTICALBAR = 202, SDL_SCANCODE_KP_COLON = 203, SDL_SCANCODE_KP_HASH = 204, SDL_SCANCODE_KP_SPACE = 205, SDL_SCANCODE_KP_AT = 206, SDL_SCANCODE_KP_EXCLAM = 207, SDL_SCANCODE_KP_MEMSTORE = 208, SDL_SCANCODE_KP_MEMRECALL = 209, SDL_SCANCODE_KP_MEMCLEAR = 210, SDL_SCANCODE_KP_MEMADD = 211, SDL_SCANCODE_KP_MEMSUBTRACT = 212, SDL_SCANCODE_KP_MEMMULTIPLY = 213, SDL_SCANCODE_KP_MEMDIVIDE = 214, SDL_SCANCODE_KP_PLUSMINUS = 215, SDL_SCANCODE_KP_CLEAR = 216, SDL_SCANCODE_KP_CLEARENTRY = 217, SDL_SCANCODE_KP_BINARY = 218, SDL_SCANCODE_KP_OCTAL = 219, SDL_SCANCODE_KP_DECIMAL = 220, SDL_SCANCODE_KP_HEXADECIMAL = 221, SDL_SCANCODE_LCTRL = 224, SDL_SCANCODE_LSHIFT = 225, SDL_SCANCODE_LALT = 226, /**< alt, option */ SDL_SCANCODE_LGUI = 227, /**< windows, command (apple), meta */ SDL_SCANCODE_RCTRL = 228, SDL_SCANCODE_RSHIFT = 229, SDL_SCANCODE_RALT = 230, /**< alt gr, option */ SDL_SCANCODE_RGUI = 231, /**< windows, command (apple), meta */ SDL_SCANCODE_MODE = 257, /**< I'm not sure if this is really not covered * by any of the above, but since there's a * special SDL_KMOD_MODE for it I'm adding it here */ /* @} *//* Usage page 0x07 */ /** * \name Usage page 0x0C * * These values are mapped from usage page 0x0C (USB consumer page). * * There are way more keys in the spec than we can represent in the * current scancode range, so pick the ones that commonly come up in * real world usage. */ /* @{ */ SDL_SCANCODE_SLEEP = 258, /**< Sleep */ SDL_SCANCODE_WAKE = 259, /**< Wake */ SDL_SCANCODE_CHANNEL_INCREMENT = 260, /**< Channel Increment */ SDL_SCANCODE_CHANNEL_DECREMENT = 261, /**< Channel Decrement */ SDL_SCANCODE_MEDIA_PLAY = 262, /**< Play */ SDL_SCANCODE_MEDIA_PAUSE = 263, /**< Pause */ SDL_SCANCODE_MEDIA_RECORD = 264, /**< Record */ SDL_SCANCODE_MEDIA_FAST_FORWARD = 265, /**< Fast Forward */ SDL_SCANCODE_MEDIA_REWIND = 266, /**< Rewind */ SDL_SCANCODE_MEDIA_NEXT_TRACK = 267, /**< Next Track */ SDL_SCANCODE_MEDIA_PREVIOUS_TRACK = 268, /**< Previous Track */ SDL_SCANCODE_MEDIA_STOP = 269, /**< Stop */ SDL_SCANCODE_MEDIA_EJECT = 270, /**< Eject */ SDL_SCANCODE_MEDIA_PLAY_PAUSE = 271, /**< Play / Pause */ SDL_SCANCODE_MEDIA_SELECT = 272, /* Media Select */ SDL_SCANCODE_AC_NEW = 273, /**< AC New */ SDL_SCANCODE_AC_OPEN = 274, /**< AC Open */ SDL_SCANCODE_AC_CLOSE = 275, /**< AC Close */ SDL_SCANCODE_AC_EXIT = 276, /**< AC Exit */ SDL_SCANCODE_AC_SAVE = 277, /**< AC Save */ SDL_SCANCODE_AC_PRINT = 278, /**< AC Print */ SDL_SCANCODE_AC_PROPERTIES = 279, /**< AC Properties */ SDL_SCANCODE_AC_SEARCH = 280, /**< AC Search */ SDL_SCANCODE_AC_HOME = 281, /**< AC Home */ SDL_SCANCODE_AC_BACK = 282, /**< AC Back */ SDL_SCANCODE_AC_FORWARD = 283, /**< AC Forward */ SDL_SCANCODE_AC_STOP = 284, /**< AC Stop */ SDL_SCANCODE_AC_REFRESH = 285, /**< AC Refresh */ SDL_SCANCODE_AC_BOOKMARKS = 286, /**< AC Bookmarks */ /* @} *//* Usage page 0x0C */ /** * \name Mobile keys * * These are values that are often used on mobile phones. */ /* @{ */ SDL_SCANCODE_SOFTLEFT = 287, /**< Usually situated below the display on phones and used as a multi-function feature key for selecting a software defined function shown on the bottom left of the display. */ SDL_SCANCODE_SOFTRIGHT = 288, /**< Usually situated below the display on phones and used as a multi-function feature key for selecting a software defined function shown on the bottom right of the display. */ SDL_SCANCODE_CALL = 289, /**< Used for accepting phone calls. */ SDL_SCANCODE_ENDCALL = 290, /**< Used for rejecting phone calls. */ /* @} *//* Mobile keys */ /* Add any other keys here. */ SDL_SCANCODE_RESERVED = 400, /**< 400-500 reserved for dynamic keycodes */ SDL_SCANCODE_COUNT = 512 /**< not a key, just marks the number of scancodes for array bounds */ } SDL_Scancode; #endif /* SDL_scancode_h_ */ ================================================ FILE: deps/include/SDL3/SDL_sensor.h ================================================ /* Simple DirectMedia Layer Copyright (C) 1997-2026 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ /** * # CategorySensor * * SDL sensor management. * * These APIs grant access to gyros and accelerometers on various platforms. * * In order to use these functions, SDL_Init() must have been called with the * SDL_INIT_SENSOR flag. This causes SDL to scan the system for sensors, and * load appropriate drivers. */ #ifndef SDL_sensor_h_ #define SDL_sensor_h_ #include #include #include #include /* Set up for C function definitions, even when using C++ */ #ifdef __cplusplus /* *INDENT-OFF* */ extern "C" { /* *INDENT-ON* */ #endif /** * The opaque structure used to identify an opened SDL sensor. * * \since This struct is available since SDL 3.2.0. */ typedef struct SDL_Sensor SDL_Sensor; /** * This is a unique ID for a sensor for the time it is connected to the * system, and is never reused for the lifetime of the application. * * The value 0 is an invalid ID. * * \since This datatype is available since SDL 3.2.0. */ typedef Uint32 SDL_SensorID; /** * A constant to represent standard gravity for accelerometer sensors. * * The accelerometer returns the current acceleration in SI meters per second * squared. This measurement includes the force of gravity, so a device at * rest will have an value of SDL_STANDARD_GRAVITY away from the center of the * earth, which is a positive Y value. * * \since This macro is available since SDL 3.2.0. */ #define SDL_STANDARD_GRAVITY 9.80665f /** * The different sensors defined by SDL. * * Additional sensors may be available, using platform dependent semantics. * * Here are the additional Android sensors: * * https://developer.android.com/reference/android/hardware/SensorEvent.html#values * * Accelerometer sensor notes: * * The accelerometer returns the current acceleration in SI meters per second * squared. This measurement includes the force of gravity, so a device at * rest will have an value of SDL_STANDARD_GRAVITY away from the center of the * earth, which is a positive Y value. * * - `values[0]`: Acceleration on the x axis * - `values[1]`: Acceleration on the y axis * - `values[2]`: Acceleration on the z axis * * For phones and tablets held in natural orientation and game controllers * held in front of you, the axes are defined as follows: * * - -X ... +X : left ... right * - -Y ... +Y : bottom ... top * - -Z ... +Z : farther ... closer * * The accelerometer axis data is not changed when the device is rotated. * * Gyroscope sensor notes: * * The gyroscope returns the current rate of rotation in radians per second. * The rotation is positive in the counter-clockwise direction. That is, an * observer looking from a positive location on one of the axes would see * positive rotation on that axis when it appeared to be rotating * counter-clockwise. * * - `values[0]`: Angular speed around the x axis (pitch) * - `values[1]`: Angular speed around the y axis (yaw) * - `values[2]`: Angular speed around the z axis (roll) * * For phones and tablets held in natural orientation and game controllers * held in front of you, the axes are defined as follows: * * - -X ... +X : left ... right * - -Y ... +Y : bottom ... top * - -Z ... +Z : farther ... closer * * The gyroscope axis data is not changed when the device is rotated. * * \since This enum is available since SDL 3.2.0. * * \sa SDL_GetCurrentDisplayOrientation */ typedef enum SDL_SensorType { SDL_SENSOR_INVALID = -1, /**< Returned for an invalid sensor */ SDL_SENSOR_UNKNOWN, /**< Unknown sensor type */ SDL_SENSOR_ACCEL, /**< Accelerometer */ SDL_SENSOR_GYRO, /**< Gyroscope */ SDL_SENSOR_ACCEL_L, /**< Accelerometer for left Joy-Con controller and Wii nunchuk */ SDL_SENSOR_GYRO_L, /**< Gyroscope for left Joy-Con controller */ SDL_SENSOR_ACCEL_R, /**< Accelerometer for right Joy-Con controller */ SDL_SENSOR_GYRO_R, /**< Gyroscope for right Joy-Con controller */ SDL_SENSOR_COUNT } SDL_SensorType; /* Function prototypes */ /** * Get a list of currently connected sensors. * * \param count a pointer filled in with the number of sensors returned, may * be NULL. * \returns a 0 terminated array of sensor instance IDs or NULL on failure; * call SDL_GetError() for more information. This should be freed * with SDL_free() when it is no longer needed. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC SDL_SensorID * SDLCALL SDL_GetSensors(int *count); /** * Get the implementation dependent name of a sensor. * * This can be called before any sensors are opened. * * \param instance_id the sensor instance ID. * \returns the sensor name, or NULL if `instance_id` is not valid. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC const char * SDLCALL SDL_GetSensorNameForID(SDL_SensorID instance_id); /** * Get the type of a sensor. * * This can be called before any sensors are opened. * * \param instance_id the sensor instance ID. * \returns the SDL_SensorType, or `SDL_SENSOR_INVALID` if `instance_id` is * not valid. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC SDL_SensorType SDLCALL SDL_GetSensorTypeForID(SDL_SensorID instance_id); /** * Get the platform dependent type of a sensor. * * This can be called before any sensors are opened. * * \param instance_id the sensor instance ID. * \returns the sensor platform dependent type, or -1 if `instance_id` is not * valid. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC int SDLCALL SDL_GetSensorNonPortableTypeForID(SDL_SensorID instance_id); /** * Open a sensor for use. * * \param instance_id the sensor instance ID. * \returns an SDL_Sensor object or NULL on failure; call SDL_GetError() for * more information. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC SDL_Sensor * SDLCALL SDL_OpenSensor(SDL_SensorID instance_id); /** * Return the SDL_Sensor associated with an instance ID. * * \param instance_id the sensor instance ID. * \returns an SDL_Sensor object or NULL on failure; call SDL_GetError() for * more information. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC SDL_Sensor * SDLCALL SDL_GetSensorFromID(SDL_SensorID instance_id); /** * Get the properties associated with a sensor. * * \param sensor the SDL_Sensor object. * \returns a valid property ID on success or 0 on failure; call * SDL_GetError() for more information. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC SDL_PropertiesID SDLCALL SDL_GetSensorProperties(SDL_Sensor *sensor); /** * Get the implementation dependent name of a sensor. * * \param sensor the SDL_Sensor object. * \returns the sensor name or NULL on failure; call SDL_GetError() for more * information. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC const char * SDLCALL SDL_GetSensorName(SDL_Sensor *sensor); /** * Get the type of a sensor. * * \param sensor the SDL_Sensor object to inspect. * \returns the SDL_SensorType type, or `SDL_SENSOR_INVALID` if `sensor` is * NULL. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC SDL_SensorType SDLCALL SDL_GetSensorType(SDL_Sensor *sensor); /** * Get the platform dependent type of a sensor. * * \param sensor the SDL_Sensor object to inspect. * \returns the sensor platform dependent type, or -1 if `sensor` is NULL. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC int SDLCALL SDL_GetSensorNonPortableType(SDL_Sensor *sensor); /** * Get the instance ID of a sensor. * * \param sensor the SDL_Sensor object to inspect. * \returns the sensor instance ID, or 0 on failure; call SDL_GetError() for * more information. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC SDL_SensorID SDLCALL SDL_GetSensorID(SDL_Sensor *sensor); /** * Get the current state of an opened sensor. * * The number of values and interpretation of the data is sensor dependent. * * \param sensor the SDL_Sensor object to query. * \param data a pointer filled with the current sensor state. * \param num_values the number of values to write to data. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC bool SDLCALL SDL_GetSensorData(SDL_Sensor *sensor, float *data, int num_values); /** * Close a sensor previously opened with SDL_OpenSensor(). * * \param sensor the SDL_Sensor object to close. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC void SDLCALL SDL_CloseSensor(SDL_Sensor *sensor); /** * Update the current state of the open sensors. * * This is called automatically by the event loop if sensor events are * enabled. * * This needs to be called from the thread that initialized the sensor * subsystem. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC void SDLCALL SDL_UpdateSensors(void); /* Ends C function definitions when using C++ */ #ifdef __cplusplus /* *INDENT-OFF* */ } /* *INDENT-ON* */ #endif #include #endif /* SDL_sensor_h_ */ ================================================ FILE: deps/include/SDL3/SDL_stdinc.h ================================================ /* Simple DirectMedia Layer Copyright (C) 1997-2026 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ /** * # CategoryStdinc * * SDL provides its own implementation of some of the most important C runtime * functions. * * Using these functions allows an app to have access to common C * functionality without depending on a specific C runtime (or a C runtime at * all). More importantly, the SDL implementations work identically across * platforms, so apps can avoid surprises like snprintf() behaving differently * between Windows and Linux builds, or itoa() only existing on some * platforms. * * For many of the most common functions, like SDL_memcpy, SDL might just call * through to the usual C runtime behind the scenes, if it makes sense to do * so (if it's faster and always available/reliable on a given platform), * reducing library size and offering the most optimized option. * * SDL also offers other C-runtime-adjacent functionality in this header that * either isn't, strictly speaking, part of any C runtime standards, like * SDL_crc32() and SDL_reinterpret_cast, etc. It also offers a few better * options, like SDL_strlcpy(), which functions as a safer form of strcpy(). */ #ifndef SDL_stdinc_h_ #define SDL_stdinc_h_ #include #include #include #include /* Most everything except Visual Studio 2008 and earlier has stdint.h now */ #if defined(_MSC_VER) && (_MSC_VER < 1600) typedef signed __int8 int8_t; typedef unsigned __int8 uint8_t; typedef signed __int16 int16_t; typedef unsigned __int16 uint16_t; typedef signed __int32 int32_t; typedef unsigned __int32 uint32_t; typedef signed __int64 int64_t; typedef unsigned __int64 uint64_t; #ifndef _INTPTR_T_DEFINED #ifdef _WIN64 typedef __int64 intptr_t; #else typedef int intptr_t; #endif #endif #ifndef _UINTPTR_T_DEFINED #ifdef _WIN64 typedef unsigned __int64 uintptr_t; #else typedef unsigned int uintptr_t; #endif #endif #else #include #endif #if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || \ defined(SDL_INCLUDE_INTTYPES_H) #include #endif #ifndef __cplusplus #if defined(__has_include) && !defined(SDL_INCLUDE_STDBOOL_H) #if __has_include() #define SDL_INCLUDE_STDBOOL_H #endif #endif #if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || \ (defined(_MSC_VER) && (_MSC_VER >= 1910 /* Visual Studio 2017 */)) || \ defined(SDL_INCLUDE_STDBOOL_H) #include #elif !defined(__bool_true_false_are_defined) && !defined(bool) #define bool unsigned char #define false 0 #define true 1 #define __bool_true_false_are_defined 1 #endif #endif /* !__cplusplus */ #ifndef SDL_DISABLE_ALLOCA # ifndef alloca # ifdef HAVE_ALLOCA_H # include # elif defined(SDL_PLATFORM_NETBSD) # if defined(__STRICT_ANSI__) # define SDL_DISABLE_ALLOCA # else # include # endif # elif defined(__GNUC__) # define alloca __builtin_alloca # elif defined(_MSC_VER) # include # define alloca _alloca # elif defined(__WATCOMC__) # include # elif defined(__BORLANDC__) # include # elif defined(__DMC__) # include # elif defined(SDL_PLATFORM_AIX) # pragma alloca # elif defined(__MRC__) void *alloca(unsigned); # else void *alloca(size_t); # endif # endif #endif #ifdef SDL_WIKI_DOCUMENTATION_SECTION /** * Don't let SDL use "long long" C types. * * SDL will define this if it believes the compiler doesn't understand the * "long long" syntax for C datatypes. This can happen on older compilers. * * If _your_ compiler doesn't support "long long" but SDL doesn't know it, it * is safe to define this yourself to build against the SDL headers. * * If this is defined, it will remove access to some C runtime support * functions, like SDL_ulltoa and SDL_strtoll that refer to this datatype * explicitly. The rest of SDL will still be available. * * SDL's own source code cannot be built with a compiler that has this * defined, for various technical reasons. */ #define SDL_NOLONGLONG 1 #elif defined(_MSC_VER) && (_MSC_VER < 1310) /* long long introduced in Visual Studio.NET 2003 */ # define SDL_NOLONGLONG 1 #endif #ifdef SDL_WIKI_DOCUMENTATION_SECTION /** * The largest value that a `size_t` can hold for the target platform. * * `size_t` is generally the same size as a pointer in modern times, but this * can get weird on very old and very esoteric machines. For example, on a * 16-bit Intel 286, you might have a 32-bit "far" pointer (16-bit segment * plus 16-bit offset), but `size_t` is 16 bits, because it can only deal with * the offset into an individual segment. * * In modern times, it's generally expected to cover an entire linear address * space. But be careful! * * \since This macro is available since SDL 3.2.0. */ #define SDL_SIZE_MAX SIZE_MAX #elif defined(SIZE_MAX) # define SDL_SIZE_MAX SIZE_MAX #else # define SDL_SIZE_MAX ((size_t) -1) #endif #ifndef SDL_COMPILE_TIME_ASSERT #ifdef SDL_WIKI_DOCUMENTATION_SECTION /** * A compile-time assertion. * * This can check constant values _known to the compiler at build time_ for * correctness, and end the compile with the error if they fail. * * Often times these are used to verify basic truths, like the size of a * datatype is what is expected: * * ```c * SDL_COMPILE_TIME_ASSERT(uint32_size, sizeof(Uint32) == 4); * ``` * * The `name` parameter must be a valid C symbol, and must be unique across * all compile-time asserts in the same compilation unit (one run of the * compiler), or the build might fail with cryptic errors on some targets. * This is used with a C language trick that works on older compilers that * don't support better assertion techniques. * * If you need an assertion that operates at runtime, on variable data, you * should try SDL_assert instead. * * \param name a unique identifier for this assertion. * \param x the value to test. Must be a boolean value. * * \threadsafety This macro doesn't generate any code to run. * * \since This macro is available since SDL 3.2.0. * * \sa SDL_assert */ #define SDL_COMPILE_TIME_ASSERT(name, x) FailToCompileIf_x_IsFalse(x) #elif defined(__cplusplus) /* Keep C++ case alone: Some versions of gcc will define __STDC_VERSION__ even when compiling in C++ mode. */ #if (__cplusplus >= 201103L) #define SDL_COMPILE_TIME_ASSERT(name, x) static_assert(x, #x) #endif #elif defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 202311L) #define SDL_COMPILE_TIME_ASSERT(name, x) static_assert(x, #x) #elif defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L) #define SDL_COMPILE_TIME_ASSERT(name, x) _Static_assert(x, #x) #endif #endif /* !SDL_COMPILE_TIME_ASSERT */ #ifndef SDL_COMPILE_TIME_ASSERT /* universal, but may trigger -Wunused-local-typedefs */ #define SDL_COMPILE_TIME_ASSERT(name, x) \ typedef int SDL_compile_time_assert_ ## name[(x) * 2 - 1] #endif /** * The number of elements in a static array. * * This will compile but return incorrect results for a pointer to an array; * it has to be an array the compiler knows the size of. * * This macro looks like it double-evaluates the argument, but it does so * inside of `sizeof`, so there are no side-effects here, as expressions do * not actually run any code in these cases. * * \since This macro is available since SDL 3.2.0. */ #define SDL_arraysize(array) (sizeof(array)/sizeof(array[0])) /** * Macro useful for building other macros with strings in them. * * \param arg the text to turn into a string literal. * * \since This macro is available since SDL 3.2.0. */ #define SDL_STRINGIFY_ARG(arg) #arg /** * \name Cast operators * * Use proper C++ casts when compiled as C++ to be compatible with the option * -Wold-style-cast of GCC (and -Werror=old-style-cast in GCC 4.2 and above). */ /* @{ */ #ifdef SDL_WIKI_DOCUMENTATION_SECTION /** * Handle a Reinterpret Cast properly whether using C or C++. * * If compiled as C++, this macro offers a proper C++ reinterpret_cast<>. * * If compiled as C, this macro does a normal C-style cast. * * This is helpful to avoid compiler warnings in C++. * * \param type the type to cast the expression to. * \param expression the expression to cast to a different type. * \returns `expression`, cast to `type`. * * \threadsafety It is safe to call this macro from any thread. * * \since This macro is available since SDL 3.2.0. * * \sa SDL_static_cast * \sa SDL_const_cast */ #define SDL_reinterpret_cast(type, expression) reinterpret_cast(expression) /* or `((type)(expression))` in C */ /** * Handle a Static Cast properly whether using C or C++. * * If compiled as C++, this macro offers a proper C++ static_cast<>. * * If compiled as C, this macro does a normal C-style cast. * * This is helpful to avoid compiler warnings in C++. * * \param type the type to cast the expression to. * \param expression the expression to cast to a different type. * \returns `expression`, cast to `type`. * * \threadsafety It is safe to call this macro from any thread. * * \since This macro is available since SDL 3.2.0. * * \sa SDL_reinterpret_cast * \sa SDL_const_cast */ #define SDL_static_cast(type, expression) static_cast(expression) /* or `((type)(expression))` in C */ /** * Handle a Const Cast properly whether using C or C++. * * If compiled as C++, this macro offers a proper C++ const_cast<>. * * If compiled as C, this macro does a normal C-style cast. * * This is helpful to avoid compiler warnings in C++. * * \param type the type to cast the expression to. * \param expression the expression to cast to a different type. * \returns `expression`, cast to `type`. * * \threadsafety It is safe to call this macro from any thread. * * \since This macro is available since SDL 3.2.0. * * \sa SDL_reinterpret_cast * \sa SDL_static_cast */ #define SDL_const_cast(type, expression) const_cast(expression) /* or `((type)(expression))` in C */ #elif defined(__cplusplus) #define SDL_reinterpret_cast(type, expression) reinterpret_cast(expression) #define SDL_static_cast(type, expression) static_cast(expression) #define SDL_const_cast(type, expression) const_cast(expression) #else #define SDL_reinterpret_cast(type, expression) ((type)(expression)) #define SDL_static_cast(type, expression) ((type)(expression)) #define SDL_const_cast(type, expression) ((type)(expression)) #endif /* @} *//* Cast operators */ /** * Define a four character code as a Uint32. * * \param A the first ASCII character. * \param B the second ASCII character. * \param C the third ASCII character. * \param D the fourth ASCII character. * \returns the four characters converted into a Uint32, one character * per-byte. * * \threadsafety It is safe to call this macro from any thread. * * \since This macro is available since SDL 3.2.0. */ #define SDL_FOURCC(A, B, C, D) \ ((SDL_static_cast(Uint32, SDL_static_cast(Uint8, (A))) << 0) | \ (SDL_static_cast(Uint32, SDL_static_cast(Uint8, (B))) << 8) | \ (SDL_static_cast(Uint32, SDL_static_cast(Uint8, (C))) << 16) | \ (SDL_static_cast(Uint32, SDL_static_cast(Uint8, (D))) << 24)) #ifdef SDL_WIKI_DOCUMENTATION_SECTION /** * Append the 64 bit integer suffix to a signed integer literal. * * This helps compilers that might believe a integer literal larger than * 0xFFFFFFFF is overflowing a 32-bit value. Use `SDL_SINT64_C(0xFFFFFFFF1)` * instead of `0xFFFFFFFF1` by itself. * * \since This macro is available since SDL 3.2.0. * * \sa SDL_UINT64_C */ #define SDL_SINT64_C(c) c ## LL /* or whatever the current compiler uses. */ /** * Append the 64 bit integer suffix to an unsigned integer literal. * * This helps compilers that might believe a integer literal larger than * 0xFFFFFFFF is overflowing a 32-bit value. Use `SDL_UINT64_C(0xFFFFFFFF1)` * instead of `0xFFFFFFFF1` by itself. * * \since This macro is available since SDL 3.2.0. * * \sa SDL_SINT64_C */ #define SDL_UINT64_C(c) c ## ULL /* or whatever the current compiler uses. */ #else /* !SDL_WIKI_DOCUMENTATION_SECTION */ #ifndef SDL_SINT64_C #if defined(INT64_C) #define SDL_SINT64_C(c) INT64_C(c) #elif defined(_MSC_VER) #define SDL_SINT64_C(c) c ## i64 #elif defined(__LP64__) || defined(_LP64) #define SDL_SINT64_C(c) c ## L #else #define SDL_SINT64_C(c) c ## LL #endif #endif /* !SDL_SINT64_C */ #ifndef SDL_UINT64_C #if defined(UINT64_C) #define SDL_UINT64_C(c) UINT64_C(c) #elif defined(_MSC_VER) #define SDL_UINT64_C(c) c ## ui64 #elif defined(__LP64__) || defined(_LP64) #define SDL_UINT64_C(c) c ## UL #else #define SDL_UINT64_C(c) c ## ULL #endif #endif /* !SDL_UINT64_C */ #endif /* !SDL_WIKI_DOCUMENTATION_SECTION */ /** * \name Basic data types */ /* @{ */ /** * A signed 8-bit integer type. * * \since This macro is available since SDL 3.2.0. */ typedef int8_t Sint8; #define SDL_MAX_SINT8 ((Sint8)0x7F) /* 127 */ #define SDL_MIN_SINT8 ((Sint8)(~0x7F)) /* -128 */ /** * An unsigned 8-bit integer type. * * \since This macro is available since SDL 3.2.0. */ typedef uint8_t Uint8; #define SDL_MAX_UINT8 ((Uint8)0xFF) /* 255 */ #define SDL_MIN_UINT8 ((Uint8)0x00) /* 0 */ /** * A signed 16-bit integer type. * * \since This macro is available since SDL 3.2.0. */ typedef int16_t Sint16; #define SDL_MAX_SINT16 ((Sint16)0x7FFF) /* 32767 */ #define SDL_MIN_SINT16 ((Sint16)(~0x7FFF)) /* -32768 */ /** * An unsigned 16-bit integer type. * * \since This macro is available since SDL 3.2.0. */ typedef uint16_t Uint16; #define SDL_MAX_UINT16 ((Uint16)0xFFFF) /* 65535 */ #define SDL_MIN_UINT16 ((Uint16)0x0000) /* 0 */ /** * A signed 32-bit integer type. * * \since This macro is available since SDL 3.2.0. */ typedef int32_t Sint32; #define SDL_MAX_SINT32 ((Sint32)0x7FFFFFFF) /* 2147483647 */ #define SDL_MIN_SINT32 ((Sint32)(~0x7FFFFFFF)) /* -2147483648 */ /** * An unsigned 32-bit integer type. * * \since This macro is available since SDL 3.2.0. */ typedef uint32_t Uint32; #define SDL_MAX_UINT32 ((Uint32)0xFFFFFFFFu) /* 4294967295 */ #define SDL_MIN_UINT32 ((Uint32)0x00000000) /* 0 */ /** * A signed 64-bit integer type. * * \since This macro is available since SDL 3.2.0. * * \sa SDL_SINT64_C */ typedef int64_t Sint64; #define SDL_MAX_SINT64 SDL_SINT64_C(0x7FFFFFFFFFFFFFFF) /* 9223372036854775807 */ #define SDL_MIN_SINT64 ~SDL_SINT64_C(0x7FFFFFFFFFFFFFFF) /* -9223372036854775808 */ /** * An unsigned 64-bit integer type. * * \since This macro is available since SDL 3.2.0. * * \sa SDL_UINT64_C */ typedef uint64_t Uint64; #define SDL_MAX_UINT64 SDL_UINT64_C(0xFFFFFFFFFFFFFFFF) /* 18446744073709551615 */ #define SDL_MIN_UINT64 SDL_UINT64_C(0x0000000000000000) /* 0 */ /** * SDL times are signed, 64-bit integers representing nanoseconds since the * Unix epoch (Jan 1, 1970). * * They can be converted between POSIX time_t values with SDL_NS_TO_SECONDS() * and SDL_SECONDS_TO_NS(), and between Windows FILETIME values with * SDL_TimeToWindows() and SDL_TimeFromWindows(). * * \since This datatype is available since SDL 3.2.0. * * \sa SDL_MAX_SINT64 * \sa SDL_MIN_SINT64 */ typedef Sint64 SDL_Time; #define SDL_MAX_TIME SDL_MAX_SINT64 #define SDL_MIN_TIME SDL_MIN_SINT64 /* @} *//* Basic data types */ /** * \name Floating-point constants */ /* @{ */ #ifdef FLT_EPSILON #define SDL_FLT_EPSILON FLT_EPSILON #else /** * Epsilon constant, used for comparing floating-point numbers. * * Equals by default to platform-defined `FLT_EPSILON`, or * `1.1920928955078125e-07F` if that's not available. * * \since This macro is available since SDL 3.2.0. */ #define SDL_FLT_EPSILON 1.1920928955078125e-07F /* 0x0.000002p0 */ #endif /* @} *//* Floating-point constants */ #ifdef SDL_WIKI_DOCUMENTATION_SECTION /** * A printf-formatting string for an Sint64 value. * * Use it like this: * * ```c * SDL_Log("There are %" SDL_PRIs64 " bottles of beer on the wall.", bottles); * ``` * * \since This macro is available since SDL 3.2.0. */ #define SDL_PRIs64 "lld" /** * A printf-formatting string for a Uint64 value. * * Use it like this: * * ```c * SDL_Log("There are %" SDL_PRIu64 " bottles of beer on the wall.", bottles); * ``` * * \since This macro is available since SDL 3.2.0. */ #define SDL_PRIu64 "llu" /** * A printf-formatting string for a Uint64 value as lower-case hexadecimal. * * Use it like this: * * ```c * SDL_Log("There are %" SDL_PRIx64 " bottles of beer on the wall.", bottles); * ``` * * \since This macro is available since SDL 3.2.0. */ #define SDL_PRIx64 "llx" /** * A printf-formatting string for a Uint64 value as upper-case hexadecimal. * * Use it like this: * * ```c * SDL_Log("There are %" SDL_PRIX64 " bottles of beer on the wall.", bottles); * ``` * * \since This macro is available since SDL 3.2.0. */ #define SDL_PRIX64 "llX" /** * A printf-formatting string for an Sint32 value. * * Use it like this: * * ```c * SDL_Log("There are %" SDL_PRIs32 " bottles of beer on the wall.", bottles); * ``` * * \since This macro is available since SDL 3.2.0. */ #define SDL_PRIs32 "d" /** * A printf-formatting string for a Uint32 value. * * Use it like this: * * ```c * SDL_Log("There are %" SDL_PRIu32 " bottles of beer on the wall.", bottles); * ``` * * \since This macro is available since SDL 3.2.0. */ #define SDL_PRIu32 "u" /** * A printf-formatting string for a Uint32 value as lower-case hexadecimal. * * Use it like this: * * ```c * SDL_Log("There are %" SDL_PRIx32 " bottles of beer on the wall.", bottles); * ``` * * \since This macro is available since SDL 3.2.0. */ #define SDL_PRIx32 "x" /** * A printf-formatting string for a Uint32 value as upper-case hexadecimal. * * Use it like this: * * ```c * SDL_Log("There are %" SDL_PRIX32 " bottles of beer on the wall.", bottles); * ``` * * \since This macro is available since SDL 3.2.0. */ #define SDL_PRIX32 "X" /** * A printf-formatting string prefix for a `long long` value. * * This is just the prefix! You probably actually want SDL_PRILLd, SDL_PRILLu, * SDL_PRILLx, or SDL_PRILLX instead. * * Use it like this: * * ```c * SDL_Log("There are %" SDL_PRILL_PREFIX "d bottles of beer on the wall.", bottles); * ``` * * \since This macro is available since SDL 3.2.0. */ #define SDL_PRILL_PREFIX "ll" /** * A printf-formatting string for a `long long` value. * * Use it like this: * * ```c * SDL_Log("There are %" SDL_PRILLd " bottles of beer on the wall.", bottles); * ``` * * \since This macro is available since SDL 3.2.0. */ #define SDL_PRILLd SDL_PRILL_PREFIX "d" /** * A printf-formatting string for a `unsigned long long` value. * * Use it like this: * * ```c * SDL_Log("There are %" SDL_PRILLu " bottles of beer on the wall.", bottles); * ``` * * \since This macro is available since SDL 3.2.0. */ #define SDL_PRILLu SDL_PRILL_PREFIX "u" /** * A printf-formatting string for an `unsigned long long` value as lower-case * hexadecimal. * * Use it like this: * * ```c * SDL_Log("There are %" SDL_PRILLx " bottles of beer on the wall.", bottles); * ``` * * \since This macro is available since SDL 3.2.0. */ #define SDL_PRILLx SDL_PRILL_PREFIX "x" /** * A printf-formatting string for an `unsigned long long` value as upper-case * hexadecimal. * * Use it like this: * * ```c * SDL_Log("There are %" SDL_PRILLX " bottles of beer on the wall.", bottles); * ``` * * \since This macro is available since SDL 3.2.0. */ #define SDL_PRILLX SDL_PRILL_PREFIX "X" #endif /* SDL_WIKI_DOCUMENTATION_SECTION */ /* Make sure we have macros for printing width-based integers. * should define these but this is not true all platforms. * (for example win32) */ #ifndef SDL_PRIs64 #if defined(SDL_PLATFORM_WINDOWS) #define SDL_PRIs64 "I64d" #elif defined(PRId64) #define SDL_PRIs64 PRId64 #elif defined(__LP64__) && !defined(SDL_PLATFORM_APPLE) && !defined(__EMSCRIPTEN__) #define SDL_PRIs64 "ld" #else #define SDL_PRIs64 "lld" #endif #endif #ifndef SDL_PRIu64 #if defined(SDL_PLATFORM_WINDOWS) #define SDL_PRIu64 "I64u" #elif defined(PRIu64) #define SDL_PRIu64 PRIu64 #elif defined(__LP64__) && !defined(SDL_PLATFORM_APPLE) && !defined(__EMSCRIPTEN__) #define SDL_PRIu64 "lu" #else #define SDL_PRIu64 "llu" #endif #endif #ifndef SDL_PRIx64 #if defined(SDL_PLATFORM_WINDOWS) #define SDL_PRIx64 "I64x" #elif defined(PRIx64) #define SDL_PRIx64 PRIx64 #elif defined(__LP64__) && !defined(SDL_PLATFORM_APPLE) #define SDL_PRIx64 "lx" #else #define SDL_PRIx64 "llx" #endif #endif #ifndef SDL_PRIX64 #if defined(SDL_PLATFORM_WINDOWS) #define SDL_PRIX64 "I64X" #elif defined(PRIX64) #define SDL_PRIX64 PRIX64 #elif defined(__LP64__) && !defined(SDL_PLATFORM_APPLE) #define SDL_PRIX64 "lX" #else #define SDL_PRIX64 "llX" #endif #endif #ifndef SDL_PRIs32 #ifdef PRId32 #define SDL_PRIs32 PRId32 #else #define SDL_PRIs32 "d" #endif #endif #ifndef SDL_PRIu32 #ifdef PRIu32 #define SDL_PRIu32 PRIu32 #else #define SDL_PRIu32 "u" #endif #endif #ifndef SDL_PRIx32 #ifdef PRIx32 #define SDL_PRIx32 PRIx32 #else #define SDL_PRIx32 "x" #endif #endif #ifndef SDL_PRIX32 #ifdef PRIX32 #define SDL_PRIX32 PRIX32 #else #define SDL_PRIX32 "X" #endif #endif /* Specifically for the `long long` -- SDL-specific. */ #ifdef SDL_PLATFORM_WINDOWS #ifndef SDL_NOLONGLONG SDL_COMPILE_TIME_ASSERT(longlong_size64, sizeof(long long) == 8); /* using I64 for windows - make sure `long long` is 64 bits. */ #endif #define SDL_PRILL_PREFIX "I64" #else #define SDL_PRILL_PREFIX "ll" #endif #ifndef SDL_PRILLd #define SDL_PRILLd SDL_PRILL_PREFIX "d" #endif #ifndef SDL_PRILLu #define SDL_PRILLu SDL_PRILL_PREFIX "u" #endif #ifndef SDL_PRILLx #define SDL_PRILLx SDL_PRILL_PREFIX "x" #endif #ifndef SDL_PRILLX #define SDL_PRILLX SDL_PRILL_PREFIX "X" #endif /* Annotations to help code analysis tools */ #ifdef SDL_WIKI_DOCUMENTATION_SECTION /** * Macro that annotates function params with input buffer size. * * If we were to annotate `memcpy`: * * ```c * void *memcpy(void *dst, SDL_IN_BYTECAP(len) const void *src, size_t len); * ``` * * This notes that `src` should be `len` bytes in size and is only read by the * function. The compiler or other analysis tools can warn when this doesn't * appear to be the case. * * On compilers without this annotation mechanism, this is defined to nothing. * * \since This macro is available since SDL 3.2.0. */ #define SDL_IN_BYTECAP(x) _In_bytecount_(x) /** * Macro that annotates function params with input/output string buffer size. * * If we were to annotate `strlcat`: * * ```c * size_t strlcat(SDL_INOUT_Z_CAP(maxlen) char *dst, const char *src, size_t maxlen); * ``` * * This notes that `dst` is a null-terminated C string, should be `maxlen` * bytes in size, and is both read from and written to by the function. The * compiler or other analysis tools can warn when this doesn't appear to be * the case. * * On compilers without this annotation mechanism, this is defined to nothing. * * \since This macro is available since SDL 3.2.0. */ #define SDL_INOUT_Z_CAP(x) _Inout_z_cap_(x) /** * Macro that annotates function params with output string buffer size. * * If we were to annotate `snprintf`: * * ```c * int snprintf(SDL_OUT_Z_CAP(maxlen) char *text, size_t maxlen, const char *fmt, ...); * ``` * * This notes that `text` is a null-terminated C string, should be `maxlen` * bytes in size, and is only written to by the function. The compiler or * other analysis tools can warn when this doesn't appear to be the case. * * On compilers without this annotation mechanism, this is defined to nothing. * * \since This macro is available since SDL 3.2.0. */ #define SDL_OUT_Z_CAP(x) _Out_z_cap_(x) /** * Macro that annotates function params with output buffer size. * * If we were to annotate `wcsncpy`: * * ```c * char *wcscpy(SDL_OUT_CAP(bufsize) wchar_t *dst, const wchar_t *src, size_t bufsize); * ``` * * This notes that `dst` should have a capacity of `bufsize` wchar_t in size, * and is only written to by the function. The compiler or other analysis * tools can warn when this doesn't appear to be the case. * * This operates on counts of objects, not bytes. Use SDL_OUT_BYTECAP for * bytes. * * On compilers without this annotation mechanism, this is defined to nothing. * * \since This macro is available since SDL 3.2.0. */ #define SDL_OUT_CAP(x) _Out_cap_(x) /** * Macro that annotates function params with output buffer size. * * If we were to annotate `memcpy`: * * ```c * void *memcpy(SDL_OUT_BYTECAP(bufsize) void *dst, const void *src, size_t bufsize); * ``` * * This notes that `dst` should have a capacity of `bufsize` bytes in size, * and is only written to by the function. The compiler or other analysis * tools can warn when this doesn't appear to be the case. * * On compilers without this annotation mechanism, this is defined to nothing. * * \since This macro is available since SDL 3.2.0. */ #define SDL_OUT_BYTECAP(x) _Out_bytecap_(x) /** * Macro that annotates function params with output buffer string size. * * If we were to annotate `strcpy`: * * ```c * char *strcpy(SDL_OUT_Z_BYTECAP(bufsize) char *dst, const char *src, size_t bufsize); * ``` * * This notes that `dst` should have a capacity of `bufsize` bytes in size, * and a zero-terminated string is written to it by the function. The compiler * or other analysis tools can warn when this doesn't appear to be the case. * * On compilers without this annotation mechanism, this is defined to nothing. * * \since This macro is available since SDL 3.2.0. */ #define SDL_OUT_Z_BYTECAP(x) _Out_z_bytecap_(x) /** * Macro that annotates function params as printf-style format strings. * * If we were to annotate `fprintf`: * * ```c * int fprintf(FILE *f, SDL_PRINTF_FORMAT_STRING const char *fmt, ...); * ``` * * This notes that `fmt` should be a printf-style format string. The compiler * or other analysis tools can warn when this doesn't appear to be the case. * * On compilers without this annotation mechanism, this is defined to nothing. * * \since This macro is available since SDL 3.2.0. */ #define SDL_PRINTF_FORMAT_STRING _Printf_format_string_ /** * Macro that annotates function params as scanf-style format strings. * * If we were to annotate `fscanf`: * * ```c * int fscanf(FILE *f, SDL_SCANF_FORMAT_STRING const char *fmt, ...); * ``` * * This notes that `fmt` should be a scanf-style format string. The compiler * or other analysis tools can warn when this doesn't appear to be the case. * * On compilers without this annotation mechanism, this is defined to nothing. * * \since This macro is available since SDL 3.2.0. */ #define SDL_SCANF_FORMAT_STRING _Scanf_format_string_impl_ /** * Macro that annotates a vararg function that operates like printf. * * If we were to annotate `fprintf`: * * ```c * int fprintf(FILE *f, const char *fmt, ...) SDL_PRINTF_VARARG_FUNC(2); * ``` * * This notes that the second parameter should be a printf-style format * string, followed by `...`. The compiler or other analysis tools can warn * when this doesn't appear to be the case. * * On compilers without this annotation mechanism, this is defined to nothing. * * This can (and should) be used with SDL_PRINTF_FORMAT_STRING as well, which * between them will cover at least Visual Studio, GCC, and Clang. * * \since This macro is available since SDL 3.2.0. */ #define SDL_PRINTF_VARARG_FUNC( fmtargnumber ) __attribute__ (( format( __printf__, fmtargnumber, fmtargnumber+1 ))) /** * Macro that annotates a va_list function that operates like printf. * * If we were to annotate `vfprintf`: * * ```c * int vfprintf(FILE *f, const char *fmt, va_list ap) SDL_PRINTF_VARARG_FUNCV(2); * ``` * * This notes that the second parameter should be a printf-style format * string, followed by a va_list. The compiler or other analysis tools can * warn when this doesn't appear to be the case. * * On compilers without this annotation mechanism, this is defined to nothing. * * This can (and should) be used with SDL_PRINTF_FORMAT_STRING as well, which * between them will cover at least Visual Studio, GCC, and Clang. * * \since This macro is available since SDL 3.2.0. */ #define SDL_PRINTF_VARARG_FUNCV( fmtargnumber ) __attribute__(( format( __printf__, fmtargnumber, 0 ))) /** * Macro that annotates a vararg function that operates like scanf. * * If we were to annotate `fscanf`: * * ```c * int fscanf(FILE *f, const char *fmt, ...) SDL_PRINTF_VARARG_FUNCV(2); * ``` * * This notes that the second parameter should be a scanf-style format string, * followed by `...`. The compiler or other analysis tools can warn when this * doesn't appear to be the case. * * On compilers without this annotation mechanism, this is defined to nothing. * * This can (and should) be used with SDL_SCANF_FORMAT_STRING as well, which * between them will cover at least Visual Studio, GCC, and Clang. * * \since This macro is available since SDL 3.2.0. */ #define SDL_SCANF_VARARG_FUNC( fmtargnumber ) __attribute__ (( format( __scanf__, fmtargnumber, fmtargnumber+1 ))) /** * Macro that annotates a va_list function that operates like scanf. * * If we were to annotate `vfscanf`: * * ```c * int vfscanf(FILE *f, const char *fmt, va_list ap) SDL_PRINTF_VARARG_FUNCV(2); * ``` * * This notes that the second parameter should be a scanf-style format string, * followed by a va_list. The compiler or other analysis tools can warn when * this doesn't appear to be the case. * * On compilers without this annotation mechanism, this is defined to nothing. * * This can (and should) be used with SDL_SCANF_FORMAT_STRING as well, which * between them will cover at least Visual Studio, GCC, and Clang. * * \since This macro is available since SDL 3.2.0. */ #define SDL_SCANF_VARARG_FUNCV( fmtargnumber ) __attribute__(( format( __scanf__, fmtargnumber, 0 ))) /** * Macro that annotates a vararg function that operates like wprintf. * * If we were to annotate `fwprintf`: * * ```c * int fwprintf(FILE *f, const wchar_t *fmt, ...) SDL_WPRINTF_VARARG_FUNC(2); * ``` * * This notes that the second parameter should be a wprintf-style format wide * string, followed by `...`. The compiler or other analysis tools can warn * when this doesn't appear to be the case. * * On compilers without this annotation mechanism, this is defined to nothing. * * This can (and should) be used with SDL_PRINTF_FORMAT_STRING as well, which * between them will cover at least Visual Studio, GCC, and Clang. * * \since This macro is available since SDL 3.2.0. */ #define SDL_WPRINTF_VARARG_FUNC( fmtargnumber ) /* __attribute__ (( format( __wprintf__, fmtargnumber, fmtargnumber+1 ))) */ /** * Macro that annotates a va_list function that operates like wprintf. * * If we were to annotate `vfwprintf`: * * ```c * int vfwprintf(FILE *f, const wchar_t *fmt, va_list ap) SDL_WPRINTF_VARARG_FUNC(2); * ``` * * This notes that the second parameter should be a wprintf-style format wide * string, followed by a va_list. The compiler or other analysis tools can * warn when this doesn't appear to be the case. * * On compilers without this annotation mechanism, this is defined to nothing. * * This can (and should) be used with SDL_PRINTF_FORMAT_STRING as well, which * between them will cover at least Visual Studio, GCC, and Clang. * * \since This macro is available since SDL 3.2.0. */ #define SDL_WPRINTF_VARARG_FUNCV( fmtargnumber ) /* __attribute__ (( format( __wprintf__, fmtargnumber, 0 ))) */ #elif defined(SDL_DISABLE_ANALYZE_MACROS) #define SDL_IN_BYTECAP(x) #define SDL_INOUT_Z_CAP(x) #define SDL_OUT_Z_CAP(x) #define SDL_OUT_CAP(x) #define SDL_OUT_BYTECAP(x) #define SDL_OUT_Z_BYTECAP(x) #define SDL_PRINTF_FORMAT_STRING #define SDL_SCANF_FORMAT_STRING #define SDL_PRINTF_VARARG_FUNC( fmtargnumber ) #define SDL_PRINTF_VARARG_FUNCV( fmtargnumber ) #define SDL_SCANF_VARARG_FUNC( fmtargnumber ) #define SDL_SCANF_VARARG_FUNCV( fmtargnumber ) #define SDL_WPRINTF_VARARG_FUNC( fmtargnumber ) #define SDL_WPRINTF_VARARG_FUNCV( fmtargnumber ) #else #if defined(_MSC_VER) && (_MSC_VER >= 1600) /* VS 2010 and above */ #include #define SDL_IN_BYTECAP(x) _In_bytecount_(x) #define SDL_INOUT_Z_CAP(x) _Inout_z_cap_(x) #define SDL_OUT_Z_CAP(x) _Out_z_cap_(x) #define SDL_OUT_CAP(x) _Out_cap_(x) #define SDL_OUT_BYTECAP(x) _Out_bytecap_(x) #define SDL_OUT_Z_BYTECAP(x) _Out_z_bytecap_(x) #define SDL_PRINTF_FORMAT_STRING _Printf_format_string_ #define SDL_SCANF_FORMAT_STRING _Scanf_format_string_impl_ #else #define SDL_IN_BYTECAP(x) #define SDL_INOUT_Z_CAP(x) #define SDL_OUT_Z_CAP(x) #define SDL_OUT_CAP(x) #define SDL_OUT_BYTECAP(x) #define SDL_OUT_Z_BYTECAP(x) #define SDL_PRINTF_FORMAT_STRING #define SDL_SCANF_FORMAT_STRING #endif #if defined(__GNUC__) || defined(__clang__) #define SDL_PRINTF_VARARG_FUNC( fmtargnumber ) __attribute__ (( format( __printf__, fmtargnumber, fmtargnumber+1 ))) #define SDL_PRINTF_VARARG_FUNCV( fmtargnumber ) __attribute__(( format( __printf__, fmtargnumber, 0 ))) #define SDL_SCANF_VARARG_FUNC( fmtargnumber ) __attribute__ (( format( __scanf__, fmtargnumber, fmtargnumber+1 ))) #define SDL_SCANF_VARARG_FUNCV( fmtargnumber ) __attribute__(( format( __scanf__, fmtargnumber, 0 ))) #define SDL_WPRINTF_VARARG_FUNC( fmtargnumber ) /* __attribute__ (( format( __wprintf__, fmtargnumber, fmtargnumber+1 ))) */ #define SDL_WPRINTF_VARARG_FUNCV( fmtargnumber ) /* __attribute__ (( format( __wprintf__, fmtargnumber, 0 ))) */ #else #define SDL_PRINTF_VARARG_FUNC( fmtargnumber ) #define SDL_PRINTF_VARARG_FUNCV( fmtargnumber ) #define SDL_SCANF_VARARG_FUNC( fmtargnumber ) #define SDL_SCANF_VARARG_FUNCV( fmtargnumber ) #define SDL_WPRINTF_VARARG_FUNC( fmtargnumber ) #define SDL_WPRINTF_VARARG_FUNCV( fmtargnumber ) #endif #endif /* SDL_DISABLE_ANALYZE_MACROS */ /** \cond */ #ifndef DOXYGEN_SHOULD_IGNORE_THIS SDL_COMPILE_TIME_ASSERT(bool_size, sizeof(bool) == 1); SDL_COMPILE_TIME_ASSERT(uint8_size, sizeof(Uint8) == 1); SDL_COMPILE_TIME_ASSERT(sint8_size, sizeof(Sint8) == 1); SDL_COMPILE_TIME_ASSERT(uint16_size, sizeof(Uint16) == 2); SDL_COMPILE_TIME_ASSERT(sint16_size, sizeof(Sint16) == 2); SDL_COMPILE_TIME_ASSERT(uint32_size, sizeof(Uint32) == 4); SDL_COMPILE_TIME_ASSERT(sint32_size, sizeof(Sint32) == 4); SDL_COMPILE_TIME_ASSERT(uint64_size, sizeof(Uint64) == 8); SDL_COMPILE_TIME_ASSERT(sint64_size, sizeof(Sint64) == 8); #ifndef SDL_NOLONGLONG SDL_COMPILE_TIME_ASSERT(uint64_longlong, sizeof(Uint64) <= sizeof(unsigned long long)); SDL_COMPILE_TIME_ASSERT(size_t_longlong, sizeof(size_t) <= sizeof(unsigned long long)); #endif typedef struct SDL_alignment_test { Uint8 a; void *b; } SDL_alignment_test; SDL_COMPILE_TIME_ASSERT(struct_alignment, sizeof(SDL_alignment_test) == (2 * sizeof(void *))); SDL_COMPILE_TIME_ASSERT(two_s_complement, SDL_static_cast(int, ~SDL_static_cast(int, 0)) == SDL_static_cast(int, -1)); #endif /* DOXYGEN_SHOULD_IGNORE_THIS */ /** \endcond */ /* Check to make sure enums are the size of ints, for structure packing. For both Watcom C/C++ and Borland C/C++ the compiler option that makes enums having the size of an int must be enabled. This is "-b" for Borland C/C++ and "-ei" for Watcom C/C++ (v11). */ /** \cond */ #ifndef DOXYGEN_SHOULD_IGNORE_THIS #if !defined(SDL_PLATFORM_VITA) && !defined(SDL_PLATFORM_3DS) /* TODO: include/SDL_stdinc.h:390: error: size of array 'SDL_dummy_enum' is negative */ typedef enum SDL_DUMMY_ENUM { DUMMY_ENUM_VALUE } SDL_DUMMY_ENUM; SDL_COMPILE_TIME_ASSERT(enum, sizeof(SDL_DUMMY_ENUM) == sizeof(int)); #endif #endif /* DOXYGEN_SHOULD_IGNORE_THIS */ /** \endcond */ #include /* Set up for C function definitions, even when using C++ */ #ifdef __cplusplus extern "C" { #endif /** * A macro to initialize an SDL interface. * * This macro will initialize an SDL interface structure and should be called * before you fill out the fields with your implementation. * * You can use it like this: * * ```c * SDL_IOStreamInterface iface; * * SDL_INIT_INTERFACE(&iface); * * // Fill in the interface function pointers with your implementation * iface.seek = ... * * stream = SDL_OpenIO(&iface, NULL); * ``` * * If you are using designated initializers, you can use the size of the * interface as the version, e.g. * * ```c * SDL_IOStreamInterface iface = { * .version = sizeof(iface), * .seek = ... * }; * stream = SDL_OpenIO(&iface, NULL); * ``` * * \threadsafety It is safe to call this macro from any thread. * * \since This macro is available since SDL 3.2.0. * * \sa SDL_IOStreamInterface * \sa SDL_StorageInterface * \sa SDL_VirtualJoystickDesc */ #define SDL_INIT_INTERFACE(iface) \ do { \ SDL_zerop(iface); \ (iface)->version = sizeof(*(iface)); \ } while (0) #ifdef SDL_WIKI_DOCUMENTATION_SECTION /** * Allocate memory on the stack (maybe). * * If SDL knows how to access alloca() on the current platform, it will use it * to stack-allocate memory here. If it doesn't, it will use SDL_malloc() to * heap-allocate memory. * * Since this might not be stack memory at all, it's important that you check * the returned pointer for NULL, and that you call SDL_stack_free on the * memory when done with it. Since this might be stack memory, it's important * that you don't allocate large amounts of it, or allocate in a loop without * returning from the function, so the stack doesn't overflow. * * \param type the datatype of the memory to allocate. * \param count the number of `type` objects to allocate. * \returns newly-allocated memory, or NULL on failure. * * \threadsafety It is safe to call this macro from any thread. * * \since This macro is available since SDL 3.2.0. * * \sa SDL_stack_free */ #define SDL_stack_alloc(type, count) (type*)alloca(sizeof(type)*(count)) /** * Free memory previously allocated with SDL_stack_alloc. * * If SDL used alloca() to allocate this memory, this macro does nothing and * the allocated memory will be automatically released when the function that * called SDL_stack_alloc() returns. If SDL used SDL_malloc(), it will * SDL_free the memory immediately. * * \param data the pointer, from SDL_stack_alloc(), to free. * * \threadsafety It is safe to call this macro from any thread. * * \since This macro is available since SDL 3.2.0. * * \sa SDL_stack_alloc */ #define SDL_stack_free(data) #elif !defined(SDL_DISABLE_ALLOCA) #define SDL_stack_alloc(type, count) (type*)alloca(sizeof(type)*(count)) #define SDL_stack_free(data) #else #define SDL_stack_alloc(type, count) (type*)SDL_malloc(sizeof(type)*(count)) #define SDL_stack_free(data) SDL_free(data) #endif /** * Allocate uninitialized memory. * * The allocated memory returned by this function must be freed with * SDL_free(). * * If `size` is 0, it will be set to 1. * * If the allocation is successful, the returned pointer is guaranteed to be * aligned to either the *fundamental alignment* (`alignof(max_align_t)` in * C11 and later) or `2 * sizeof(void *)`, whichever is smaller. Use * SDL_aligned_alloc() if you need to allocate memory aligned to an alignment * greater than this guarantee. * * \param size the size to allocate. * \returns a pointer to the allocated memory, or NULL if allocation failed. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_free * \sa SDL_calloc * \sa SDL_realloc * \sa SDL_aligned_alloc */ extern SDL_DECLSPEC SDL_MALLOC void * SDLCALL SDL_malloc(size_t size); /** * Allocate a zero-initialized array. * * The memory returned by this function must be freed with SDL_free(). * * If either of `nmemb` or `size` is 0, they will both be set to 1. * * If the allocation is successful, the returned pointer is guaranteed to be * aligned to either the *fundamental alignment* (`alignof(max_align_t)` in * C11 and later) or `2 * sizeof(void *)`, whichever is smaller. * * \param nmemb the number of elements in the array. * \param size the size of each element of the array. * \returns a pointer to the allocated array, or NULL if allocation failed. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_free * \sa SDL_malloc * \sa SDL_realloc */ extern SDL_DECLSPEC SDL_MALLOC SDL_ALLOC_SIZE2(1, 2) void * SDLCALL SDL_calloc(size_t nmemb, size_t size); /** * Change the size of allocated memory. * * The memory returned by this function must be freed with SDL_free(). * * If `size` is 0, it will be set to 1. Note that this is unlike some other C * runtime `realloc` implementations, which may treat `realloc(mem, 0)` the * same way as `free(mem)`. * * If `mem` is NULL, the behavior of this function is equivalent to * SDL_malloc(). Otherwise, the function can have one of three possible * outcomes: * * - If it returns the same pointer as `mem`, it means that `mem` was resized * in place without freeing. * - If it returns a different non-NULL pointer, it means that `mem` was freed * and cannot be dereferenced anymore. * - If it returns NULL (indicating failure), then `mem` will remain valid and * must still be freed with SDL_free(). * * If the allocation is successfully resized, the returned pointer is * guaranteed to be aligned to either the *fundamental alignment* * (`alignof(max_align_t)` in C11 and later) or `2 * sizeof(void *)`, * whichever is smaller. * * \param mem a pointer to allocated memory to reallocate, or NULL. * \param size the new size of the memory. * \returns a pointer to the newly allocated memory, or NULL if allocation * failed. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_free * \sa SDL_malloc * \sa SDL_calloc */ extern SDL_DECLSPEC SDL_ALLOC_SIZE(2) void * SDLCALL SDL_realloc(void *mem, size_t size); /** * Free allocated memory. * * The pointer is no longer valid after this call and cannot be dereferenced * anymore. * * If `mem` is NULL, this function does nothing. * * \param mem a pointer to allocated memory, or NULL. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_malloc * \sa SDL_calloc * \sa SDL_realloc */ extern SDL_DECLSPEC void SDLCALL SDL_free(void *mem); /** * A callback used to implement SDL_malloc(). * * SDL will always ensure that the passed `size` is greater than 0. * * \param size the size to allocate. * \returns a pointer to the allocated memory, or NULL if allocation failed. * * \threadsafety It should be safe to call this callback from any thread. * * \since This datatype is available since SDL 3.2.0. * * \sa SDL_malloc * \sa SDL_GetOriginalMemoryFunctions * \sa SDL_GetMemoryFunctions * \sa SDL_SetMemoryFunctions */ typedef void *(SDLCALL *SDL_malloc_func)(size_t size); /** * A callback used to implement SDL_calloc(). * * SDL will always ensure that the passed `nmemb` and `size` are both greater * than 0. * * \param nmemb the number of elements in the array. * \param size the size of each element of the array. * \returns a pointer to the allocated array, or NULL if allocation failed. * * \threadsafety It should be safe to call this callback from any thread. * * \since This datatype is available since SDL 3.2.0. * * \sa SDL_calloc * \sa SDL_GetOriginalMemoryFunctions * \sa SDL_GetMemoryFunctions * \sa SDL_SetMemoryFunctions */ typedef void *(SDLCALL *SDL_calloc_func)(size_t nmemb, size_t size); /** * A callback used to implement SDL_realloc(). * * SDL will always ensure that the passed `size` is greater than 0. * * \param mem a pointer to allocated memory to reallocate, or NULL. * \param size the new size of the memory. * \returns a pointer to the newly allocated memory, or NULL if allocation * failed. * * \threadsafety It should be safe to call this callback from any thread. * * \since This datatype is available since SDL 3.2.0. * * \sa SDL_realloc * \sa SDL_GetOriginalMemoryFunctions * \sa SDL_GetMemoryFunctions * \sa SDL_SetMemoryFunctions */ typedef void *(SDLCALL *SDL_realloc_func)(void *mem, size_t size); /** * A callback used to implement SDL_free(). * * SDL will always ensure that the passed `mem` is a non-NULL pointer. * * \param mem a pointer to allocated memory. * * \threadsafety It should be safe to call this callback from any thread. * * \since This datatype is available since SDL 3.2.0. * * \sa SDL_free * \sa SDL_GetOriginalMemoryFunctions * \sa SDL_GetMemoryFunctions * \sa SDL_SetMemoryFunctions */ typedef void (SDLCALL *SDL_free_func)(void *mem); /** * Get the original set of SDL memory functions. * * This is what SDL_malloc and friends will use by default, if there has been * no call to SDL_SetMemoryFunctions. This is not necessarily using the C * runtime's `malloc` functions behind the scenes! Different platforms and * build configurations might do any number of unexpected things. * * \param malloc_func filled with malloc function. * \param calloc_func filled with calloc function. * \param realloc_func filled with realloc function. * \param free_func filled with free function. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC void SDLCALL SDL_GetOriginalMemoryFunctions(SDL_malloc_func *malloc_func, SDL_calloc_func *calloc_func, SDL_realloc_func *realloc_func, SDL_free_func *free_func); /** * Get the current set of SDL memory functions. * * \param malloc_func filled with malloc function. * \param calloc_func filled with calloc function. * \param realloc_func filled with realloc function. * \param free_func filled with free function. * * \threadsafety This does not hold a lock, so do not call this in the * unlikely event of a background thread calling * SDL_SetMemoryFunctions simultaneously. * * \since This function is available since SDL 3.2.0. * * \sa SDL_SetMemoryFunctions * \sa SDL_GetOriginalMemoryFunctions */ extern SDL_DECLSPEC void SDLCALL SDL_GetMemoryFunctions(SDL_malloc_func *malloc_func, SDL_calloc_func *calloc_func, SDL_realloc_func *realloc_func, SDL_free_func *free_func); /** * Replace SDL's memory allocation functions with a custom set. * * It is not safe to call this function once any allocations have been made, * as future calls to SDL_free will use the new allocator, even if they came * from an SDL_malloc made with the old one! * * If used, usually this needs to be the first call made into the SDL library, * if not the very first thing done at program startup time. * * \param malloc_func custom malloc function. * \param calloc_func custom calloc function. * \param realloc_func custom realloc function. * \param free_func custom free function. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety It is safe to call this function from any thread, but one * should not replace the memory functions once any allocations * are made! * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetMemoryFunctions * \sa SDL_GetOriginalMemoryFunctions */ extern SDL_DECLSPEC bool SDLCALL SDL_SetMemoryFunctions(SDL_malloc_func malloc_func, SDL_calloc_func calloc_func, SDL_realloc_func realloc_func, SDL_free_func free_func); /** * Allocate memory aligned to a specific alignment. * * The memory returned by this function must be freed with SDL_aligned_free(), * _not_ SDL_free(). * * If `alignment` is less than the size of `void *`, it will be increased to * match that. * * The returned memory address will be a multiple of the alignment value, and * the size of the memory allocated will be a multiple of the alignment value. * * \param alignment the alignment of the memory. * \param size the size to allocate. * \returns a pointer to the aligned memory, or NULL if allocation failed. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_aligned_free */ extern SDL_DECLSPEC SDL_MALLOC void * SDLCALL SDL_aligned_alloc(size_t alignment, size_t size); /** * Free memory allocated by SDL_aligned_alloc(). * * The pointer is no longer valid after this call and cannot be dereferenced * anymore. * * If `mem` is NULL, this function does nothing. * * \param mem a pointer previously returned by SDL_aligned_alloc(), or NULL. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_aligned_alloc */ extern SDL_DECLSPEC void SDLCALL SDL_aligned_free(void *mem); /** * Get the number of outstanding (unfreed) allocations. * * \returns the number of allocations or -1 if allocation counting is * disabled. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC int SDLCALL SDL_GetNumAllocations(void); /** * A thread-safe set of environment variables * * \since This struct is available since SDL 3.2.0. * * \sa SDL_GetEnvironment * \sa SDL_CreateEnvironment * \sa SDL_GetEnvironmentVariable * \sa SDL_GetEnvironmentVariables * \sa SDL_SetEnvironmentVariable * \sa SDL_UnsetEnvironmentVariable * \sa SDL_DestroyEnvironment */ typedef struct SDL_Environment SDL_Environment; /** * Get the process environment. * * This is initialized at application start and is not affected by setenv() * and unsetenv() calls after that point. Use SDL_SetEnvironmentVariable() and * SDL_UnsetEnvironmentVariable() if you want to modify this environment, or * SDL_setenv_unsafe() or SDL_unsetenv_unsafe() if you want changes to persist * in the C runtime environment after SDL_Quit(). * * \returns a pointer to the environment for the process or NULL on failure; * call SDL_GetError() for more information. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetEnvironmentVariable * \sa SDL_GetEnvironmentVariables * \sa SDL_SetEnvironmentVariable * \sa SDL_UnsetEnvironmentVariable */ extern SDL_DECLSPEC SDL_Environment * SDLCALL SDL_GetEnvironment(void); /** * Create a set of environment variables * * \param populated true to initialize it from the C runtime environment, * false to create an empty environment. * \returns a pointer to the new environment or NULL on failure; call * SDL_GetError() for more information. * * \threadsafety If `populated` is false, it is safe to call this function * from any thread, otherwise it is safe if no other threads are * calling setenv() or unsetenv() * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetEnvironmentVariable * \sa SDL_GetEnvironmentVariables * \sa SDL_SetEnvironmentVariable * \sa SDL_UnsetEnvironmentVariable * \sa SDL_DestroyEnvironment */ extern SDL_DECLSPEC SDL_Environment * SDLCALL SDL_CreateEnvironment(bool populated); /** * Get the value of a variable in the environment. * * \param env the environment to query. * \param name the name of the variable to get. * \returns a pointer to the value of the variable or NULL if it can't be * found. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetEnvironment * \sa SDL_CreateEnvironment * \sa SDL_GetEnvironmentVariables * \sa SDL_SetEnvironmentVariable * \sa SDL_UnsetEnvironmentVariable */ extern SDL_DECLSPEC const char * SDLCALL SDL_GetEnvironmentVariable(SDL_Environment *env, const char *name); /** * Get all variables in the environment. * * \param env the environment to query. * \returns a NULL terminated array of pointers to environment variables in * the form "variable=value" or NULL on failure; call SDL_GetError() * for more information. This is a single allocation that should be * freed with SDL_free() when it is no longer needed. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetEnvironment * \sa SDL_CreateEnvironment * \sa SDL_GetEnvironmentVariables * \sa SDL_SetEnvironmentVariable * \sa SDL_UnsetEnvironmentVariable */ extern SDL_DECLSPEC char ** SDLCALL SDL_GetEnvironmentVariables(SDL_Environment *env); /** * Set the value of a variable in the environment. * * \param env the environment to modify. * \param name the name of the variable to set. * \param value the value of the variable to set. * \param overwrite true to overwrite the variable if it exists, false to * return success without setting the variable if it already * exists. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetEnvironment * \sa SDL_CreateEnvironment * \sa SDL_GetEnvironmentVariable * \sa SDL_GetEnvironmentVariables * \sa SDL_UnsetEnvironmentVariable */ extern SDL_DECLSPEC bool SDLCALL SDL_SetEnvironmentVariable(SDL_Environment *env, const char *name, const char *value, bool overwrite); /** * Clear a variable from the environment. * * \param env the environment to modify. * \param name the name of the variable to unset. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetEnvironment * \sa SDL_CreateEnvironment * \sa SDL_GetEnvironmentVariable * \sa SDL_GetEnvironmentVariables * \sa SDL_SetEnvironmentVariable * \sa SDL_UnsetEnvironmentVariable */ extern SDL_DECLSPEC bool SDLCALL SDL_UnsetEnvironmentVariable(SDL_Environment *env, const char *name); /** * Destroy a set of environment variables. * * \param env the environment to destroy. * * \threadsafety It is safe to call this function from any thread, as long as * the environment is no longer in use. * * \since This function is available since SDL 3.2.0. * * \sa SDL_CreateEnvironment */ extern SDL_DECLSPEC void SDLCALL SDL_DestroyEnvironment(SDL_Environment *env); /** * Get the value of a variable in the environment. * * The name of the variable is case sensitive on all platforms. * * This function uses SDL's cached copy of the environment and is thread-safe. * * \param name the name of the variable to get. * \returns a pointer to the value of the variable or NULL if it can't be * found. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC const char * SDLCALL SDL_getenv(const char *name); /** * Get the value of a variable in the environment. * * This function bypasses SDL's cached copy of the environment and is not * thread-safe. * * On some platforms, this may make case-insensitive matches, while other * platforms are case-sensitive. It is best to be precise with strings used * for queries through this interface. SDL_getenv is always case-sensitive, * however. * * \param name the name of the variable to get. * \returns a pointer to the value of the variable or NULL if it can't be * found. * * \threadsafety This function is not thread safe, consider using SDL_getenv() * instead. * * \since This function is available since SDL 3.2.0. * * \sa SDL_getenv */ extern SDL_DECLSPEC const char * SDLCALL SDL_getenv_unsafe(const char *name); /** * Set the value of a variable in the environment. * * \param name the name of the variable to set. * \param value the value of the variable to set. * \param overwrite 1 to overwrite the variable if it exists, 0 to return * success without setting the variable if it already exists. * \returns 0 on success, -1 on error. * * \threadsafety This function is not thread safe, consider using * SDL_SetEnvironmentVariable() instead. * * \since This function is available since SDL 3.2.0. * * \sa SDL_SetEnvironmentVariable */ extern SDL_DECLSPEC int SDLCALL SDL_setenv_unsafe(const char *name, const char *value, int overwrite); /** * Clear a variable from the environment. * * \param name the name of the variable to unset. * \returns 0 on success, -1 on error. * * \threadsafety This function is not thread safe, consider using * SDL_UnsetEnvironmentVariable() instead. * * \since This function is available since SDL 3.2.0. * * \sa SDL_UnsetEnvironmentVariable */ extern SDL_DECLSPEC int SDLCALL SDL_unsetenv_unsafe(const char *name); /** * A callback used with SDL sorting and binary search functions. * * \param a a pointer to the first element being compared. * \param b a pointer to the second element being compared. * \returns -1 if `a` should be sorted before `b`, 1 if `b` should be sorted * before `a`, 0 if they are equal. If two elements are equal, their * order in the sorted array is undefined. * * \since This callback is available since SDL 3.2.0. * * \sa SDL_bsearch * \sa SDL_qsort */ typedef int (SDLCALL *SDL_CompareCallback)(const void *a, const void *b); /** * Sort an array. * * For example: * * ```c * typedef struct { * int key; * const char *string; * } data; * * int SDLCALL compare(const void *a, const void *b) * { * const data *A = (const data *)a; * const data *B = (const data *)b; * * if (A->n < B->n) { * return -1; * } else if (B->n < A->n) { * return 1; * } else { * return 0; * } * } * * data values[] = { * { 3, "third" }, { 1, "first" }, { 2, "second" } * }; * * SDL_qsort(values, SDL_arraysize(values), sizeof(values[0]), compare); * ``` * * \param base a pointer to the start of the array. * \param nmemb the number of elements in the array. * \param size the size of the elements in the array. * \param compare a function used to compare elements in the array. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_bsearch * \sa SDL_qsort_r */ extern SDL_DECLSPEC void SDLCALL SDL_qsort(void *base, size_t nmemb, size_t size, SDL_CompareCallback compare); /** * Perform a binary search on a previously sorted array. * * For example: * * ```c * typedef struct { * int key; * const char *string; * } data; * * int SDLCALL compare(const void *a, const void *b) * { * const data *A = (const data *)a; * const data *B = (const data *)b; * * if (A->n < B->n) { * return -1; * } else if (B->n < A->n) { * return 1; * } else { * return 0; * } * } * * data values[] = { * { 1, "first" }, { 2, "second" }, { 3, "third" } * }; * data key = { 2, NULL }; * * data *result = SDL_bsearch(&key, values, SDL_arraysize(values), sizeof(values[0]), compare); * ``` * * \param key a pointer to a key equal to the element being searched for. * \param base a pointer to the start of the array. * \param nmemb the number of elements in the array. * \param size the size of the elements in the array. * \param compare a function used to compare elements in the array. * \returns a pointer to the matching element in the array, or NULL if not * found. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_bsearch_r * \sa SDL_qsort */ extern SDL_DECLSPEC void * SDLCALL SDL_bsearch(const void *key, const void *base, size_t nmemb, size_t size, SDL_CompareCallback compare); /** * A callback used with SDL sorting and binary search functions. * * \param userdata the `userdata` pointer passed to the sort function. * \param a a pointer to the first element being compared. * \param b a pointer to the second element being compared. * \returns -1 if `a` should be sorted before `b`, 1 if `b` should be sorted * before `a`, 0 if they are equal. If two elements are equal, their * order in the sorted array is undefined. * * \since This callback is available since SDL 3.2.0. * * \sa SDL_qsort_r * \sa SDL_bsearch_r */ typedef int (SDLCALL *SDL_CompareCallback_r)(void *userdata, const void *a, const void *b); /** * Sort an array, passing a userdata pointer to the compare function. * * For example: * * ```c * typedef enum { * sort_increasing, * sort_decreasing, * } sort_method; * * typedef struct { * int key; * const char *string; * } data; * * int SDLCALL compare(const void *userdata, const void *a, const void *b) * { * sort_method method = (sort_method)(uintptr_t)userdata; * const data *A = (const data *)a; * const data *B = (const data *)b; * * if (A->key < B->key) { * return (method == sort_increasing) ? -1 : 1; * } else if (B->key < A->key) { * return (method == sort_increasing) ? 1 : -1; * } else { * return 0; * } * } * * data values[] = { * { 3, "third" }, { 1, "first" }, { 2, "second" } * }; * * SDL_qsort_r(values, SDL_arraysize(values), sizeof(values[0]), compare, (const void *)(uintptr_t)sort_increasing); * ``` * * \param base a pointer to the start of the array. * \param nmemb the number of elements in the array. * \param size the size of the elements in the array. * \param compare a function used to compare elements in the array. * \param userdata a pointer to pass to the compare function. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_bsearch_r * \sa SDL_qsort */ extern SDL_DECLSPEC void SDLCALL SDL_qsort_r(void *base, size_t nmemb, size_t size, SDL_CompareCallback_r compare, void *userdata); /** * Perform a binary search on a previously sorted array, passing a userdata * pointer to the compare function. * * For example: * * ```c * typedef enum { * sort_increasing, * sort_decreasing, * } sort_method; * * typedef struct { * int key; * const char *string; * } data; * * int SDLCALL compare(const void *userdata, const void *a, const void *b) * { * sort_method method = (sort_method)(uintptr_t)userdata; * const data *A = (const data *)a; * const data *B = (const data *)b; * * if (A->key < B->key) { * return (method == sort_increasing) ? -1 : 1; * } else if (B->key < A->key) { * return (method == sort_increasing) ? 1 : -1; * } else { * return 0; * } * } * * data values[] = { * { 1, "first" }, { 2, "second" }, { 3, "third" } * }; * data key = { 2, NULL }; * * data *result = SDL_bsearch_r(&key, values, SDL_arraysize(values), sizeof(values[0]), compare, (const void *)(uintptr_t)sort_increasing); * ``` * * \param key a pointer to a key equal to the element being searched for. * \param base a pointer to the start of the array. * \param nmemb the number of elements in the array. * \param size the size of the elements in the array. * \param compare a function used to compare elements in the array. * \param userdata a pointer to pass to the compare function. * \returns a pointer to the matching element in the array, or NULL if not * found. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_bsearch * \sa SDL_qsort_r */ extern SDL_DECLSPEC void * SDLCALL SDL_bsearch_r(const void *key, const void *base, size_t nmemb, size_t size, SDL_CompareCallback_r compare, void *userdata); /** * Compute the absolute value of `x`. * * \param x an integer value. * \returns the absolute value of x. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC int SDLCALL SDL_abs(int x); /** * Return the lesser of two values. * * This is a helper macro that might be more clear than writing out the * comparisons directly, and works with any type that can be compared with the * `<` operator. However, it double-evaluates both its parameters, so do not * use expressions with side-effects here. * * \param x the first value to compare. * \param y the second value to compare. * \returns the lesser of `x` and `y`. * * \threadsafety It is safe to call this macro from any thread. * * \since This macro is available since SDL 3.2.0. */ #define SDL_min(x, y) (((x) < (y)) ? (x) : (y)) /** * Return the greater of two values. * * This is a helper macro that might be more clear than writing out the * comparisons directly, and works with any type that can be compared with the * `>` operator. However, it double-evaluates both its parameters, so do not * use expressions with side-effects here. * * \param x the first value to compare. * \param y the second value to compare. * \returns the greater of `x` and `y`. * * \threadsafety It is safe to call this macro from any thread. * * \since This macro is available since SDL 3.2.0. */ #define SDL_max(x, y) (((x) > (y)) ? (x) : (y)) /** * Return a value clamped to a range. * * If `x` is outside the range a values between `a` and `b`, the returned * value will be `a` or `b` as appropriate. Otherwise, `x` is returned. * * This macro will produce incorrect results if `b` is less than `a`. * * This is a helper macro that might be more clear than writing out the * comparisons directly, and works with any type that can be compared with the * `<` and `>` operators. However, it double-evaluates all its parameters, so * do not use expressions with side-effects here. * * \param x the value to compare. * \param a the low end value. * \param b the high end value. * \returns x, clamped between a and b. * * \threadsafety It is safe to call this macro from any thread. * * \since This macro is available since SDL 3.2.0. */ #define SDL_clamp(x, a, b) (((x) < (a)) ? (a) : (((x) > (b)) ? (b) : (x))) /** * Query if a character is alphabetic (a letter). * * **WARNING**: Regardless of system locale, this will only treat ASCII values * for English 'a-z' and 'A-Z' as true. * * \param x character value to check. * \returns non-zero if x falls within the character class, zero otherwise. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC int SDLCALL SDL_isalpha(int x); /** * Query if a character is alphabetic (a letter) or a number. * * **WARNING**: Regardless of system locale, this will only treat ASCII values * for English 'a-z', 'A-Z', and '0-9' as true. * * \param x character value to check. * \returns non-zero if x falls within the character class, zero otherwise. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC int SDLCALL SDL_isalnum(int x); /** * Report if a character is blank (a space or tab). * * **WARNING**: Regardless of system locale, this will only treat ASCII values * 0x20 (space) or 0x9 (tab) as true. * * \param x character value to check. * \returns non-zero if x falls within the character class, zero otherwise. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC int SDLCALL SDL_isblank(int x); /** * Report if a character is a control character. * * **WARNING**: Regardless of system locale, this will only treat ASCII values * 0 through 0x1F, and 0x7F, as true. * * \param x character value to check. * \returns non-zero if x falls within the character class, zero otherwise. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC int SDLCALL SDL_iscntrl(int x); /** * Report if a character is a numeric digit. * * **WARNING**: Regardless of system locale, this will only treat ASCII values * '0' (0x30) through '9' (0x39), as true. * * \param x character value to check. * \returns non-zero if x falls within the character class, zero otherwise. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC int SDLCALL SDL_isdigit(int x); /** * Report if a character is a hexadecimal digit. * * **WARNING**: Regardless of system locale, this will only treat ASCII values * 'A' through 'F', 'a' through 'f', and '0' through '9', as true. * * \param x character value to check. * \returns non-zero if x falls within the character class, zero otherwise. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC int SDLCALL SDL_isxdigit(int x); /** * Report if a character is a punctuation mark. * * **WARNING**: Regardless of system locale, this is equivalent to * `((SDL_isgraph(x)) && (!SDL_isalnum(x)))`. * * \param x character value to check. * \returns non-zero if x falls within the character class, zero otherwise. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_isgraph * \sa SDL_isalnum */ extern SDL_DECLSPEC int SDLCALL SDL_ispunct(int x); /** * Report if a character is whitespace. * * **WARNING**: Regardless of system locale, this will only treat the * following ASCII values as true: * * - space (0x20) * - tab (0x09) * - newline (0x0A) * - vertical tab (0x0B) * - form feed (0x0C) * - return (0x0D) * * \param x character value to check. * \returns non-zero if x falls within the character class, zero otherwise. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC int SDLCALL SDL_isspace(int x); /** * Report if a character is upper case. * * **WARNING**: Regardless of system locale, this will only treat ASCII values * 'A' through 'Z' as true. * * \param x character value to check. * \returns non-zero if x falls within the character class, zero otherwise. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC int SDLCALL SDL_isupper(int x); /** * Report if a character is lower case. * * **WARNING**: Regardless of system locale, this will only treat ASCII values * 'a' through 'z' as true. * * \param x character value to check. * \returns non-zero if x falls within the character class, zero otherwise. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC int SDLCALL SDL_islower(int x); /** * Report if a character is "printable". * * Be advised that "printable" has a definition that goes back to text * terminals from the dawn of computing, making this a sort of special case * function that is not suitable for Unicode (or most any) text management. * * **WARNING**: Regardless of system locale, this will only treat ASCII values * ' ' (0x20) through '~' (0x7E) as true. * * \param x character value to check. * \returns non-zero if x falls within the character class, zero otherwise. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC int SDLCALL SDL_isprint(int x); /** * Report if a character is any "printable" except space. * * Be advised that "printable" has a definition that goes back to text * terminals from the dawn of computing, making this a sort of special case * function that is not suitable for Unicode (or most any) text management. * * **WARNING**: Regardless of system locale, this is equivalent to * `(SDL_isprint(x)) && ((x) != ' ')`. * * \param x character value to check. * \returns non-zero if x falls within the character class, zero otherwise. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_isprint */ extern SDL_DECLSPEC int SDLCALL SDL_isgraph(int x); /** * Convert low-ASCII English letters to uppercase. * * **WARNING**: Regardless of system locale, this will only convert ASCII * values 'a' through 'z' to uppercase. * * This function returns the uppercase equivalent of `x`. If a character * cannot be converted, or is already uppercase, this function returns `x`. * * \param x character value to check. * \returns capitalized version of x, or x if no conversion available. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC int SDLCALL SDL_toupper(int x); /** * Convert low-ASCII English letters to lowercase. * * **WARNING**: Regardless of system locale, this will only convert ASCII * values 'A' through 'Z' to lowercase. * * This function returns the lowercase equivalent of `x`. If a character * cannot be converted, or is already lowercase, this function returns `x`. * * \param x character value to check. * \returns lowercase version of x, or x if no conversion available. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC int SDLCALL SDL_tolower(int x); /** * Calculate a CRC-16 value. * * https://en.wikipedia.org/wiki/Cyclic_redundancy_check * * This function can be called multiple times, to stream data to be * checksummed in blocks. Each call must provide the previous CRC-16 return * value to be updated with the next block. The first call to this function * for a set of blocks should pass in a zero CRC value. * * \param crc the current checksum for this data set, or 0 for a new data set. * \param data a new block of data to add to the checksum. * \param len the size, in bytes, of the new block of data. * \returns a CRC-16 checksum value of all blocks in the data set. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC Uint16 SDLCALL SDL_crc16(Uint16 crc, const void *data, size_t len); /** * Calculate a CRC-32 value. * * https://en.wikipedia.org/wiki/Cyclic_redundancy_check * * This function can be called multiple times, to stream data to be * checksummed in blocks. Each call must provide the previous CRC-32 return * value to be updated with the next block. The first call to this function * for a set of blocks should pass in a zero CRC value. * * \param crc the current checksum for this data set, or 0 for a new data set. * \param data a new block of data to add to the checksum. * \param len the size, in bytes, of the new block of data. * \returns a CRC-32 checksum value of all blocks in the data set. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC Uint32 SDLCALL SDL_crc32(Uint32 crc, const void *data, size_t len); /** * Calculate a 32-bit MurmurHash3 value for a block of data. * * https://en.wikipedia.org/wiki/MurmurHash * * A seed may be specified, which changes the final results consistently, but * this does not work like SDL_crc16 and SDL_crc32: you can't feed a previous * result from this function back into itself as the next seed value to * calculate a hash in chunks; it won't produce the same hash as it would if * the same data was provided in a single call. * * If you aren't sure what to provide for a seed, zero is fine. Murmur3 is not * cryptographically secure, so it shouldn't be used for hashing top-secret * data. * * \param data the data to be hashed. * \param len the size of data, in bytes. * \param seed a value that alters the final hash value. * \returns a Murmur3 32-bit hash value. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC Uint32 SDLCALL SDL_murmur3_32(const void *data, size_t len, Uint32 seed); /** * Copy non-overlapping memory. * * The memory regions must not overlap. If they do, use SDL_memmove() instead. * * \param dst The destination memory region. Must not be NULL, and must not * overlap with `src`. * \param src The source memory region. Must not be NULL, and must not overlap * with `dst`. * \param len The length in bytes of both `dst` and `src`. * \returns `dst`. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_memmove */ extern SDL_DECLSPEC void * SDLCALL SDL_memcpy(SDL_OUT_BYTECAP(len) void *dst, SDL_IN_BYTECAP(len) const void *src, size_t len); /* Take advantage of compiler optimizations for memcpy */ #ifndef SDL_SLOW_MEMCPY #ifdef SDL_memcpy #undef SDL_memcpy #endif #define SDL_memcpy memcpy #endif /** * A macro to copy memory between objects, with basic type checking. * * SDL_memcpy and SDL_memmove do not care where you copy memory to and from, * which can lead to bugs. This macro aims to avoid most of those bugs by * making sure that the source and destination are both pointers to objects * that are the same size. It does not check that the objects are the same * _type_, just that the copy will not overflow either object. * * The size check happens at compile time, and the compiler will throw an * error if the objects are different sizes. * * Generally this is intended to copy a single object, not an array. * * This macro looks like it double-evaluates its parameters, but the extras * them are in `sizeof` sections, which generate no code nor side-effects. * * \param dst a pointer to the destination object. Must not be NULL. * \param src a pointer to the source object. Must not be NULL. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. */ #define SDL_copyp(dst, src) \ { SDL_COMPILE_TIME_ASSERT(SDL_copyp, sizeof (*(dst)) == sizeof (*(src))); } \ SDL_memcpy((dst), (src), sizeof(*(src))) /** * Copy memory ranges that might overlap. * * It is okay for the memory regions to overlap. If you are confident that the * regions never overlap, using SDL_memcpy() may improve performance. * * \param dst The destination memory region. Must not be NULL. * \param src The source memory region. Must not be NULL. * \param len The length in bytes of both `dst` and `src`. * \returns `dst`. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_memcpy */ extern SDL_DECLSPEC void * SDLCALL SDL_memmove(SDL_OUT_BYTECAP(len) void *dst, SDL_IN_BYTECAP(len) const void *src, size_t len); /* Take advantage of compiler optimizations for memmove */ #ifndef SDL_SLOW_MEMMOVE #ifdef SDL_memmove #undef SDL_memmove #endif #define SDL_memmove memmove #endif /** * Initialize all bytes of buffer of memory to a specific value. * * This function will set `len` bytes, pointed to by `dst`, to the value * specified in `c`. * * Despite `c` being an `int` instead of a `char`, this only operates on * bytes; `c` must be a value between 0 and 255, inclusive. * * \param dst the destination memory region. Must not be NULL. * \param c the byte value to set. * \param len the length, in bytes, to set in `dst`. * \returns `dst`. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC void * SDLCALL SDL_memset(SDL_OUT_BYTECAP(len) void *dst, int c, size_t len); /** * Initialize all 32-bit words of buffer of memory to a specific value. * * This function will set a buffer of `dwords` Uint32 values, pointed to by * `dst`, to the value specified in `val`. * * Unlike SDL_memset, this sets 32-bit values, not bytes, so it's not limited * to a range of 0-255. * * \param dst the destination memory region. Must not be NULL. * \param val the Uint32 value to set. * \param dwords the number of Uint32 values to set in `dst`. * \returns `dst`. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC void * SDLCALL SDL_memset4(void *dst, Uint32 val, size_t dwords); /* Take advantage of compiler optimizations for memset */ #ifndef SDL_SLOW_MEMSET #ifdef SDL_memset #undef SDL_memset #endif #define SDL_memset memset #endif /** * Clear an object's memory to zero. * * This is wrapper over SDL_memset that handles calculating the object size, * so there's no chance of copy/paste errors, and the code is cleaner. * * This requires an object, not a pointer to an object, nor an array. * * \param x the object to clear. * * \threadsafety It is safe to call this macro from any thread. * * \since This macro is available since SDL 3.2.0. * * \sa SDL_zerop * \sa SDL_zeroa */ #define SDL_zero(x) SDL_memset(&(x), 0, sizeof((x))) /** * Clear an object's memory to zero, using a pointer. * * This is wrapper over SDL_memset that handles calculating the object size, * so there's no chance of copy/paste errors, and the code is cleaner. * * This requires a pointer to an object, not an object itself, nor an array. * * \param x a pointer to the object to clear. * * \threadsafety It is safe to call this macro from any thread. * * \since This macro is available since SDL 3.2.0. * * \sa SDL_zero * \sa SDL_zeroa */ #define SDL_zerop(x) SDL_memset((x), 0, sizeof(*(x))) /** * Clear an array's memory to zero. * * This is wrapper over SDL_memset that handles calculating the array size, so * there's no chance of copy/paste errors, and the code is cleaner. * * This requires an array, not an object, nor a pointer to an object. * * \param x an array to clear. * * \threadsafety It is safe to call this macro from any thread. * * \since This macro is available since SDL 3.2.0. * * \sa SDL_zero * \sa SDL_zerop */ #define SDL_zeroa(x) SDL_memset((x), 0, sizeof((x))) /** * Compare two buffers of memory. * * \param s1 the first buffer to compare. NULL is not permitted! * \param s2 the second buffer to compare. NULL is not permitted! * \param len the number of bytes to compare between the buffers. * \returns less than zero if s1 is "less than" s2, greater than zero if s1 is * "greater than" s2, and zero if the buffers match exactly for `len` * bytes. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC int SDLCALL SDL_memcmp(const void *s1, const void *s2, size_t len); /** * This works exactly like wcslen() but doesn't require access to a C runtime. * * Counts the number of wchar_t values in `wstr`, excluding the null * terminator. * * Like SDL_strlen only counts bytes and not codepoints in a UTF-8 string, * this counts wchar_t values in a string, even if the string's encoding is of * variable width, like UTF-16. * * Also be aware that wchar_t is different sizes on different platforms (4 * bytes on Linux, 2 on Windows, etc). * * \param wstr The null-terminated wide string to read. Must not be NULL. * \returns the length (in wchar_t values, excluding the null terminator) of * `wstr`. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_wcsnlen * \sa SDL_utf8strlen * \sa SDL_utf8strnlen */ extern SDL_DECLSPEC size_t SDLCALL SDL_wcslen(const wchar_t *wstr); /** * This works exactly like wcsnlen() but doesn't require access to a C * runtime. * * Counts up to a maximum of `maxlen` wchar_t values in `wstr`, excluding the * null terminator. * * Like SDL_strnlen only counts bytes and not codepoints in a UTF-8 string, * this counts wchar_t values in a string, even if the string's encoding is of * variable width, like UTF-16. * * Also be aware that wchar_t is different sizes on different platforms (4 * bytes on Linux, 2 on Windows, etc). * * Also, `maxlen` is a count of wide characters, not bytes! * * \param wstr The null-terminated wide string to read. Must not be NULL. * \param maxlen The maximum amount of wide characters to count. * \returns the length (in wide characters, excluding the null terminator) of * `wstr` but never more than `maxlen`. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_wcslen * \sa SDL_utf8strlen * \sa SDL_utf8strnlen */ extern SDL_DECLSPEC size_t SDLCALL SDL_wcsnlen(const wchar_t *wstr, size_t maxlen); /** * Copy a wide string. * * This function copies `maxlen` - 1 wide characters from `src` to `dst`, then * appends a null terminator. * * `src` and `dst` must not overlap. * * If `maxlen` is 0, no wide characters are copied and no null terminator is * written. * * \param dst The destination buffer. Must not be NULL, and must not overlap * with `src`. * \param src The null-terminated wide string to copy. Must not be NULL, and * must not overlap with `dst`. * \param maxlen The length (in wide characters) of the destination buffer. * \returns the length (in wide characters, excluding the null terminator) of * `src`. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_wcslcat */ extern SDL_DECLSPEC size_t SDLCALL SDL_wcslcpy(SDL_OUT_Z_CAP(maxlen) wchar_t *dst, const wchar_t *src, size_t maxlen); /** * Concatenate wide strings. * * This function appends up to `maxlen` - SDL_wcslen(dst) - 1 wide characters * from `src` to the end of the wide string in `dst`, then appends a null * terminator. * * `src` and `dst` must not overlap. * * If `maxlen` - SDL_wcslen(dst) - 1 is less than or equal to 0, then `dst` is * unmodified. * * \param dst The destination buffer already containing the first * null-terminated wide string. Must not be NULL and must not * overlap with `src`. * \param src The second null-terminated wide string. Must not be NULL, and * must not overlap with `dst`. * \param maxlen The length (in wide characters) of the destination buffer. * \returns the length (in wide characters, excluding the null terminator) of * the string in `dst` plus the length of `src`. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_wcslcpy */ extern SDL_DECLSPEC size_t SDLCALL SDL_wcslcat(SDL_INOUT_Z_CAP(maxlen) wchar_t *dst, const wchar_t *src, size_t maxlen); /** * Allocate a copy of a wide string. * * This allocates enough space for a null-terminated copy of `wstr`, using * SDL_malloc, and then makes a copy of the string into this space. * * The returned string is owned by the caller, and should be passed to * SDL_free when no longer needed. * * \param wstr the string to copy. * \returns a pointer to the newly-allocated wide string. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC wchar_t * SDLCALL SDL_wcsdup(const wchar_t *wstr); /** * Search a wide string for the first instance of a specific substring. * * The search ends once it finds the requested substring, or a null terminator * byte to end the string. * * Note that this looks for strings of _wide characters_, not _codepoints_, so * it's legal to search for malformed and incomplete UTF-16 sequences. * * \param haystack the wide string to search. Must not be NULL. * \param needle the wide string to search for. Must not be NULL. * \returns a pointer to the first instance of `needle` in the string, or NULL * if not found. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC wchar_t * SDLCALL SDL_wcsstr(const wchar_t *haystack, const wchar_t *needle); /** * Search a wide string, up to n wide chars, for the first instance of a * specific substring. * * The search ends once it finds the requested substring, or a null terminator * value to end the string, or `maxlen` wide character have been examined. It * is possible to use this function on a wide string without a null * terminator. * * Note that this looks for strings of _wide characters_, not _codepoints_, so * it's legal to search for malformed and incomplete UTF-16 sequences. * * \param haystack the wide string to search. Must not be NULL. * \param needle the wide string to search for. Must not be NULL. * \param maxlen the maximum number of wide characters to search in * `haystack`. * \returns a pointer to the first instance of `needle` in the string, or NULL * if not found. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC wchar_t * SDLCALL SDL_wcsnstr(const wchar_t *haystack, const wchar_t *needle, size_t maxlen); /** * Compare two null-terminated wide strings. * * This only compares wchar_t values until it hits a null-terminating * character; it does not care if the string is well-formed UTF-16 (or UTF-32, * depending on your platform's wchar_t size), or uses valid Unicode values. * * \param str1 the first string to compare. NULL is not permitted! * \param str2 the second string to compare. NULL is not permitted! * \returns less than zero if str1 is "less than" str2, greater than zero if * str1 is "greater than" str2, and zero if the strings match * exactly. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC int SDLCALL SDL_wcscmp(const wchar_t *str1, const wchar_t *str2); /** * Compare two wide strings up to a number of wchar_t values. * * This only compares wchar_t values; it does not care if the string is * well-formed UTF-16 (or UTF-32, depending on your platform's wchar_t size), * or uses valid Unicode values. * * Note that while this function is intended to be used with UTF-16 (or * UTF-32, depending on your platform's definition of wchar_t), it is * comparing raw wchar_t values and not Unicode codepoints: `maxlen` specifies * a wchar_t limit! If the limit lands in the middle of a multi-wchar UTF-16 * sequence, it will only compare a portion of the final character. * * `maxlen` specifies a maximum number of wchar_t to compare; if the strings * match to this number of wide chars (or both have matched to a * null-terminator character before this count), they will be considered * equal. * * \param str1 the first string to compare. NULL is not permitted! * \param str2 the second string to compare. NULL is not permitted! * \param maxlen the maximum number of wchar_t to compare. * \returns less than zero if str1 is "less than" str2, greater than zero if * str1 is "greater than" str2, and zero if the strings match * exactly. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC int SDLCALL SDL_wcsncmp(const wchar_t *str1, const wchar_t *str2, size_t maxlen); /** * Compare two null-terminated wide strings, case-insensitively. * * This will work with Unicode strings, using a technique called * "case-folding" to handle the vast majority of case-sensitive human * languages regardless of system locale. It can deal with expanding values: a * German Eszett character can compare against two ASCII 's' chars and be * considered a match, for example. A notable exception: it does not handle * the Turkish 'i' character; human language is complicated! * * Depending on your platform, "wchar_t" might be 2 bytes, and expected to be * UTF-16 encoded (like Windows), or 4 bytes in UTF-32 format. Since this * handles Unicode, it expects the string to be well-formed and not a * null-terminated string of arbitrary bytes. Characters that are not valid * UTF-16 (or UTF-32) are treated as Unicode character U+FFFD (REPLACEMENT * CHARACTER), which is to say two strings of random bits may turn out to * match if they convert to the same amount of replacement characters. * * \param str1 the first string to compare. NULL is not permitted! * \param str2 the second string to compare. NULL is not permitted! * \returns less than zero if str1 is "less than" str2, greater than zero if * str1 is "greater than" str2, and zero if the strings match * exactly. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC int SDLCALL SDL_wcscasecmp(const wchar_t *str1, const wchar_t *str2); /** * Compare two wide strings, case-insensitively, up to a number of wchar_t. * * This will work with Unicode strings, using a technique called * "case-folding" to handle the vast majority of case-sensitive human * languages regardless of system locale. It can deal with expanding values: a * German Eszett character can compare against two ASCII 's' chars and be * considered a match, for example. A notable exception: it does not handle * the Turkish 'i' character; human language is complicated! * * Depending on your platform, "wchar_t" might be 2 bytes, and expected to be * UTF-16 encoded (like Windows), or 4 bytes in UTF-32 format. Since this * handles Unicode, it expects the string to be well-formed and not a * null-terminated string of arbitrary bytes. Characters that are not valid * UTF-16 (or UTF-32) are treated as Unicode character U+FFFD (REPLACEMENT * CHARACTER), which is to say two strings of random bits may turn out to * match if they convert to the same amount of replacement characters. * * Note that while this function might deal with variable-sized characters, * `maxlen` specifies a _wchar_ limit! If the limit lands in the middle of a * multi-byte UTF-16 sequence, it may convert a portion of the final character * to one or more Unicode character U+FFFD (REPLACEMENT CHARACTER) so as not * to overflow a buffer. * * `maxlen` specifies a maximum number of wchar_t values to compare; if the * strings match to this number of wchar_t (or both have matched to a * null-terminator character before this number of bytes), they will be * considered equal. * * \param str1 the first string to compare. NULL is not permitted! * \param str2 the second string to compare. NULL is not permitted! * \param maxlen the maximum number of wchar_t values to compare. * \returns less than zero if str1 is "less than" str2, greater than zero if * str1 is "greater than" str2, and zero if the strings match * exactly. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC int SDLCALL SDL_wcsncasecmp(const wchar_t *str1, const wchar_t *str2, size_t maxlen); /** * Parse a `long` from a wide string. * * If `str` starts with whitespace, then those whitespace characters are * skipped before attempting to parse the number. * * If the parsed number does not fit inside a `long`, the result is clamped to * the minimum and maximum representable `long` values. * * \param str The null-terminated wide string to read. Must not be NULL. * \param endp If not NULL, the address of the first invalid wide character * (i.e. the next character after the parsed number) will be * written to this pointer. * \param base The base of the integer to read. Supported values are 0 and 2 * to 36 inclusive. If 0, the base will be inferred from the * number's prefix (0x for hexadecimal, 0 for octal, decimal * otherwise). * \returns the parsed `long`, or 0 if no number could be parsed. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_strtol */ extern SDL_DECLSPEC long SDLCALL SDL_wcstol(const wchar_t *str, wchar_t **endp, int base); /** * This works exactly like strlen() but doesn't require access to a C runtime. * * Counts the bytes in `str`, excluding the null terminator. * * If you need the length of a UTF-8 string, consider using SDL_utf8strlen(). * * \param str The null-terminated string to read. Must not be NULL. * \returns the length (in bytes, excluding the null terminator) of `src`. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_strnlen * \sa SDL_utf8strlen * \sa SDL_utf8strnlen */ extern SDL_DECLSPEC size_t SDLCALL SDL_strlen(const char *str); /** * This works exactly like strnlen() but doesn't require access to a C * runtime. * * Counts up to a maximum of `maxlen` bytes in `str`, excluding the null * terminator. * * If you need the length of a UTF-8 string, consider using SDL_utf8strnlen(). * * \param str The null-terminated string to read. Must not be NULL. * \param maxlen The maximum amount of bytes to count. * \returns the length (in bytes, excluding the null terminator) of `src` but * never more than `maxlen`. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_strlen * \sa SDL_utf8strlen * \sa SDL_utf8strnlen */ extern SDL_DECLSPEC size_t SDLCALL SDL_strnlen(const char *str, size_t maxlen); /** * Copy a string. * * This function copies up to `maxlen` - 1 characters from `src` to `dst`, * then appends a null terminator. * * If `maxlen` is 0, no characters are copied and no null terminator is * written. * * If you want to copy an UTF-8 string but need to ensure that multi-byte * sequences are not truncated, consider using SDL_utf8strlcpy(). * * \param dst The destination buffer. Must not be NULL, and must not overlap * with `src`. * \param src The null-terminated string to copy. Must not be NULL, and must * not overlap with `dst`. * \param maxlen The length (in characters) of the destination buffer. * \returns the length (in characters, excluding the null terminator) of * `src`. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_strlcat * \sa SDL_utf8strlcpy */ extern SDL_DECLSPEC size_t SDLCALL SDL_strlcpy(SDL_OUT_Z_CAP(maxlen) char *dst, const char *src, size_t maxlen); /** * Copy an UTF-8 string. * * This function copies up to `dst_bytes` - 1 bytes from `src` to `dst` while * also ensuring that the string written to `dst` does not end in a truncated * multi-byte sequence. Finally, it appends a null terminator. * * `src` and `dst` must not overlap. * * Note that unlike SDL_strlcpy(), this function returns the number of bytes * written, not the length of `src`. * * \param dst The destination buffer. Must not be NULL, and must not overlap * with `src`. * \param src The null-terminated UTF-8 string to copy. Must not be NULL, and * must not overlap with `dst`. * \param dst_bytes The length (in bytes) of the destination buffer. Must not * be 0. * \returns the number of bytes written, excluding the null terminator. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_strlcpy */ extern SDL_DECLSPEC size_t SDLCALL SDL_utf8strlcpy(SDL_OUT_Z_CAP(dst_bytes) char *dst, const char *src, size_t dst_bytes); /** * Concatenate strings. * * This function appends up to `maxlen` - SDL_strlen(dst) - 1 characters from * `src` to the end of the string in `dst`, then appends a null terminator. * * `src` and `dst` must not overlap. * * If `maxlen` - SDL_strlen(dst) - 1 is less than or equal to 0, then `dst` is * unmodified. * * \param dst The destination buffer already containing the first * null-terminated string. Must not be NULL and must not overlap * with `src`. * \param src The second null-terminated string. Must not be NULL, and must * not overlap with `dst`. * \param maxlen The length (in characters) of the destination buffer. * \returns the length (in characters, excluding the null terminator) of the * string in `dst` plus the length of `src`. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_strlcpy */ extern SDL_DECLSPEC size_t SDLCALL SDL_strlcat(SDL_INOUT_Z_CAP(maxlen) char *dst, const char *src, size_t maxlen); /** * Allocate a copy of a string. * * This allocates enough space for a null-terminated copy of `str`, using * SDL_malloc, and then makes a copy of the string into this space. * * The returned string is owned by the caller, and should be passed to * SDL_free when no longer needed. * * \param str the string to copy. * \returns a pointer to the newly-allocated string. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC SDL_MALLOC char * SDLCALL SDL_strdup(const char *str); /** * Allocate a copy of a string, up to n characters. * * This allocates enough space for a null-terminated copy of `str`, up to * `maxlen` bytes, using SDL_malloc, and then makes a copy of the string into * this space. * * If the string is longer than `maxlen` bytes, the returned string will be * `maxlen` bytes long, plus a null-terminator character that isn't included * in the count. * * The returned string is owned by the caller, and should be passed to * SDL_free when no longer needed. * * \param str the string to copy. * \param maxlen the maximum length of the copied string, not counting the * null-terminator character. * \returns a pointer to the newly-allocated string. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC SDL_MALLOC char * SDLCALL SDL_strndup(const char *str, size_t maxlen); /** * Reverse a string's contents. * * This reverses a null-terminated string in-place. Only the content of the * string is reversed; the null-terminator character remains at the end of the * reversed string. * * **WARNING**: This function reverses the _bytes_ of the string, not the * codepoints. If `str` is a UTF-8 string with Unicode codepoints > 127, this * will ruin the string data. You should only use this function on strings * that are completely comprised of low ASCII characters. * * \param str the string to reverse. * \returns `str`. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC char * SDLCALL SDL_strrev(char *str); /** * Convert a string to uppercase. * * **WARNING**: Regardless of system locale, this will only convert ASCII * values 'A' through 'Z' to uppercase. * * This function operates on a null-terminated string of bytes--even if it is * malformed UTF-8!--and converts ASCII characters 'a' through 'z' to their * uppercase equivalents in-place, returning the original `str` pointer. * * \param str the string to convert in-place. Can not be NULL. * \returns the `str` pointer passed into this function. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_strlwr */ extern SDL_DECLSPEC char * SDLCALL SDL_strupr(char *str); /** * Convert a string to lowercase. * * **WARNING**: Regardless of system locale, this will only convert ASCII * values 'A' through 'Z' to lowercase. * * This function operates on a null-terminated string of bytes--even if it is * malformed UTF-8!--and converts ASCII characters 'A' through 'Z' to their * lowercase equivalents in-place, returning the original `str` pointer. * * \param str the string to convert in-place. Can not be NULL. * \returns the `str` pointer passed into this function. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_strupr */ extern SDL_DECLSPEC char * SDLCALL SDL_strlwr(char *str); /** * Search a string for the first instance of a specific byte. * * The search ends once it finds the requested byte value, or a null * terminator byte to end the string. * * Note that this looks for _bytes_, not _characters_, so you cannot match * against a Unicode codepoint > 255, regardless of character encoding. * * \param str the string to search. Must not be NULL. * \param c the byte value to search for. * \returns a pointer to the first instance of `c` in the string, or NULL if * not found. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC char * SDLCALL SDL_strchr(const char *str, int c); /** * Search a string for the last instance of a specific byte. * * The search must go until it finds a null terminator byte to end the string. * * Note that this looks for _bytes_, not _characters_, so you cannot match * against a Unicode codepoint > 255, regardless of character encoding. * * \param str the string to search. Must not be NULL. * \param c the byte value to search for. * \returns a pointer to the last instance of `c` in the string, or NULL if * not found. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC char * SDLCALL SDL_strrchr(const char *str, int c); /** * Search a string for the first instance of a specific substring. * * The search ends once it finds the requested substring, or a null terminator * byte to end the string. * * Note that this looks for strings of _bytes_, not _characters_, so it's * legal to search for malformed and incomplete UTF-8 sequences. * * \param haystack the string to search. Must not be NULL. * \param needle the string to search for. Must not be NULL. * \returns a pointer to the first instance of `needle` in the string, or NULL * if not found. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC char * SDLCALL SDL_strstr(const char *haystack, const char *needle); /** * Search a string, up to n bytes, for the first instance of a specific * substring. * * The search ends once it finds the requested substring, or a null terminator * byte to end the string, or `maxlen` bytes have been examined. It is * possible to use this function on a string without a null terminator. * * Note that this looks for strings of _bytes_, not _characters_, so it's * legal to search for malformed and incomplete UTF-8 sequences. * * \param haystack the string to search. Must not be NULL. * \param needle the string to search for. Must not be NULL. * \param maxlen the maximum number of bytes to search in `haystack`. * \returns a pointer to the first instance of `needle` in the string, or NULL * if not found. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC char * SDLCALL SDL_strnstr(const char *haystack, const char *needle, size_t maxlen); /** * Search a UTF-8 string for the first instance of a specific substring, * case-insensitively. * * This will work with Unicode strings, using a technique called * "case-folding" to handle the vast majority of case-sensitive human * languages regardless of system locale. It can deal with expanding values: a * German Eszett character can compare against two ASCII 's' chars and be * considered a match, for example. A notable exception: it does not handle * the Turkish 'i' character; human language is complicated! * * Since this handles Unicode, it expects the strings to be well-formed UTF-8 * and not a null-terminated string of arbitrary bytes. Bytes that are not * valid UTF-8 are treated as Unicode character U+FFFD (REPLACEMENT * CHARACTER), which is to say two strings of random bits may turn out to * match if they convert to the same amount of replacement characters. * * \param haystack the string to search. Must not be NULL. * \param needle the string to search for. Must not be NULL. * \returns a pointer to the first instance of `needle` in the string, or NULL * if not found. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC char * SDLCALL SDL_strcasestr(const char *haystack, const char *needle); /** * This works exactly like strtok_r() but doesn't require access to a C * runtime. * * Break a string up into a series of tokens. * * To start tokenizing a new string, `str` should be the non-NULL address of * the string to start tokenizing. Future calls to get the next token from the * same string should specify a NULL. * * Note that this function will overwrite pieces of `str` with null chars to * split it into tokens. This function cannot be used with const/read-only * strings! * * `saveptr` just needs to point to a `char *` that can be overwritten; SDL * will use this to save tokenizing state between calls. It is initialized if * `str` is non-NULL, and used to resume tokenizing when `str` is NULL. * * \param str the string to tokenize, or NULL to continue tokenizing. * \param delim the delimiter string that separates tokens. * \param saveptr pointer to a char *, used for ongoing state. * \returns A pointer to the next token, or NULL if no tokens remain. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC char * SDLCALL SDL_strtok_r(char *str, const char *delim, char **saveptr); /** * Count the number of codepoints in a UTF-8 string. * * Counts the _codepoints_, not _bytes_, in `str`, excluding the null * terminator. * * If you need to count the bytes in a string instead, consider using * SDL_strlen(). * * Since this handles Unicode, it expects the strings to be well-formed UTF-8 * and not a null-terminated string of arbitrary bytes. Bytes that are not * valid UTF-8 are treated as Unicode character U+FFFD (REPLACEMENT * CHARACTER), so a malformed or incomplete UTF-8 sequence might increase the * count by several replacement characters. * * \param str The null-terminated UTF-8 string to read. Must not be NULL. * \returns The length (in codepoints, excluding the null terminator) of * `src`. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_utf8strnlen * \sa SDL_strlen */ extern SDL_DECLSPEC size_t SDLCALL SDL_utf8strlen(const char *str); /** * Count the number of codepoints in a UTF-8 string, up to n bytes. * * Counts the _codepoints_, not _bytes_, in `str`, excluding the null * terminator. * * If you need to count the bytes in a string instead, consider using * SDL_strnlen(). * * The counting stops at `bytes` bytes (not codepoints!). This seems * counterintuitive, but makes it easy to express the total size of the * string's buffer. * * Since this handles Unicode, it expects the strings to be well-formed UTF-8 * and not a null-terminated string of arbitrary bytes. Bytes that are not * valid UTF-8 are treated as Unicode character U+FFFD (REPLACEMENT * CHARACTER), so a malformed or incomplete UTF-8 sequence might increase the * count by several replacement characters. * * \param str The null-terminated UTF-8 string to read. Must not be NULL. * \param bytes The maximum amount of bytes to count. * \returns The length (in codepoints, excluding the null terminator) of `src` * but never more than `maxlen`. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_utf8strlen * \sa SDL_strnlen */ extern SDL_DECLSPEC size_t SDLCALL SDL_utf8strnlen(const char *str, size_t bytes); /** * Convert an integer into a string. * * This requires a radix to specified for string format. Specifying 10 * produces a decimal number, 16 hexadecimal, etc. Must be in the range of 2 * to 36. * * Note that this function will overflow a buffer if `str` is not large enough * to hold the output! It may be safer to use SDL_snprintf to clamp output, or * SDL_asprintf to allocate a buffer. Otherwise, it doesn't hurt to allocate * much more space than you expect to use (and don't forget possible negative * signs, null terminator bytes, etc). * * \param value the integer to convert. * \param str the buffer to write the string into. * \param radix the radix to use for string generation. * \returns `str`. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_uitoa * \sa SDL_ltoa * \sa SDL_lltoa */ extern SDL_DECLSPEC char * SDLCALL SDL_itoa(int value, char *str, int radix); /** * Convert an unsigned integer into a string. * * This requires a radix to specified for string format. Specifying 10 * produces a decimal number, 16 hexadecimal, etc. Must be in the range of 2 * to 36. * * Note that this function will overflow a buffer if `str` is not large enough * to hold the output! It may be safer to use SDL_snprintf to clamp output, or * SDL_asprintf to allocate a buffer. Otherwise, it doesn't hurt to allocate * much more space than you expect to use (and don't forget null terminator * bytes, etc). * * \param value the unsigned integer to convert. * \param str the buffer to write the string into. * \param radix the radix to use for string generation. * \returns `str`. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_itoa * \sa SDL_ultoa * \sa SDL_ulltoa */ extern SDL_DECLSPEC char * SDLCALL SDL_uitoa(unsigned int value, char *str, int radix); /** * Convert a long integer into a string. * * This requires a radix to specified for string format. Specifying 10 * produces a decimal number, 16 hexadecimal, etc. Must be in the range of 2 * to 36. * * Note that this function will overflow a buffer if `str` is not large enough * to hold the output! It may be safer to use SDL_snprintf to clamp output, or * SDL_asprintf to allocate a buffer. Otherwise, it doesn't hurt to allocate * much more space than you expect to use (and don't forget possible negative * signs, null terminator bytes, etc). * * \param value the long integer to convert. * \param str the buffer to write the string into. * \param radix the radix to use for string generation. * \returns `str`. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_ultoa * \sa SDL_itoa * \sa SDL_lltoa */ extern SDL_DECLSPEC char * SDLCALL SDL_ltoa(long value, char *str, int radix); /** * Convert an unsigned long integer into a string. * * This requires a radix to specified for string format. Specifying 10 * produces a decimal number, 16 hexadecimal, etc. Must be in the range of 2 * to 36. * * Note that this function will overflow a buffer if `str` is not large enough * to hold the output! It may be safer to use SDL_snprintf to clamp output, or * SDL_asprintf to allocate a buffer. Otherwise, it doesn't hurt to allocate * much more space than you expect to use (and don't forget null terminator * bytes, etc). * * \param value the unsigned long integer to convert. * \param str the buffer to write the string into. * \param radix the radix to use for string generation. * \returns `str`. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_ltoa * \sa SDL_uitoa * \sa SDL_ulltoa */ extern SDL_DECLSPEC char * SDLCALL SDL_ultoa(unsigned long value, char *str, int radix); #ifndef SDL_NOLONGLONG /** * Convert a long long integer into a string. * * This requires a radix to specified for string format. Specifying 10 * produces a decimal number, 16 hexadecimal, etc. Must be in the range of 2 * to 36. * * Note that this function will overflow a buffer if `str` is not large enough * to hold the output! It may be safer to use SDL_snprintf to clamp output, or * SDL_asprintf to allocate a buffer. Otherwise, it doesn't hurt to allocate * much more space than you expect to use (and don't forget possible negative * signs, null terminator bytes, etc). * * \param value the long long integer to convert. * \param str the buffer to write the string into. * \param radix the radix to use for string generation. * \returns `str`. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_ulltoa * \sa SDL_itoa * \sa SDL_ltoa */ extern SDL_DECLSPEC char * SDLCALL SDL_lltoa(long long value, char *str, int radix); /** * Convert an unsigned long long integer into a string. * * This requires a radix to specified for string format. Specifying 10 * produces a decimal number, 16 hexadecimal, etc. Must be in the range of 2 * to 36. * * Note that this function will overflow a buffer if `str` is not large enough * to hold the output! It may be safer to use SDL_snprintf to clamp output, or * SDL_asprintf to allocate a buffer. Otherwise, it doesn't hurt to allocate * much more space than you expect to use (and don't forget null terminator * bytes, etc). * * \param value the unsigned long long integer to convert. * \param str the buffer to write the string into. * \param radix the radix to use for string generation. * \returns `str`. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_lltoa * \sa SDL_uitoa * \sa SDL_ultoa */ extern SDL_DECLSPEC char * SDLCALL SDL_ulltoa(unsigned long long value, char *str, int radix); #endif /** * Parse an `int` from a string. * * The result of calling `SDL_atoi(str)` is equivalent to * `(int)SDL_strtol(str, NULL, 10)`. * * \param str The null-terminated string to read. Must not be NULL. * \returns the parsed `int`. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_atof * \sa SDL_strtol * \sa SDL_strtoul * \sa SDL_strtoll * \sa SDL_strtoull * \sa SDL_strtod * \sa SDL_itoa */ extern SDL_DECLSPEC int SDLCALL SDL_atoi(const char *str); /** * Parse a `double` from a string. * * The result of calling `SDL_atof(str)` is equivalent to `SDL_strtod(str, * NULL)`. * * \param str The null-terminated string to read. Must not be NULL. * \returns the parsed `double`. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_atoi * \sa SDL_strtol * \sa SDL_strtoul * \sa SDL_strtoll * \sa SDL_strtoull * \sa SDL_strtod */ extern SDL_DECLSPEC double SDLCALL SDL_atof(const char *str); /** * Parse a `long` from a string. * * If `str` starts with whitespace, then those whitespace characters are * skipped before attempting to parse the number. * * If the parsed number does not fit inside a `long`, the result is clamped to * the minimum and maximum representable `long` values. * * \param str The null-terminated string to read. Must not be NULL. * \param endp If not NULL, the address of the first invalid character (i.e. * the next character after the parsed number) will be written to * this pointer. * \param base The base of the integer to read. Supported values are 0 and 2 * to 36 inclusive. If 0, the base will be inferred from the * number's prefix (0x for hexadecimal, 0 for octal, decimal * otherwise). * \returns the parsed `long`, or 0 if no number could be parsed. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_atoi * \sa SDL_atof * \sa SDL_strtoul * \sa SDL_strtoll * \sa SDL_strtoull * \sa SDL_strtod * \sa SDL_ltoa * \sa SDL_wcstol */ extern SDL_DECLSPEC long SDLCALL SDL_strtol(const char *str, char **endp, int base); /** * Parse an `unsigned long` from a string. * * If `str` starts with whitespace, then those whitespace characters are * skipped before attempting to parse the number. * * If the parsed number does not fit inside an `unsigned long`, the result is * clamped to the maximum representable `unsigned long` value. * * \param str The null-terminated string to read. Must not be NULL. * \param endp If not NULL, the address of the first invalid character (i.e. * the next character after the parsed number) will be written to * this pointer. * \param base The base of the integer to read. Supported values are 0 and 2 * to 36 inclusive. If 0, the base will be inferred from the * number's prefix (0x for hexadecimal, 0 for octal, decimal * otherwise). * \returns the parsed `unsigned long`, or 0 if no number could be parsed. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_atoi * \sa SDL_atof * \sa SDL_strtol * \sa SDL_strtoll * \sa SDL_strtoull * \sa SDL_strtod * \sa SDL_ultoa */ extern SDL_DECLSPEC unsigned long SDLCALL SDL_strtoul(const char *str, char **endp, int base); #ifndef SDL_NOLONGLONG /** * Parse a `long long` from a string. * * If `str` starts with whitespace, then those whitespace characters are * skipped before attempting to parse the number. * * If the parsed number does not fit inside a `long long`, the result is * clamped to the minimum and maximum representable `long long` values. * * \param str The null-terminated string to read. Must not be NULL. * \param endp If not NULL, the address of the first invalid character (i.e. * the next character after the parsed number) will be written to * this pointer. * \param base The base of the integer to read. Supported values are 0 and 2 * to 36 inclusive. If 0, the base will be inferred from the * number's prefix (0x for hexadecimal, 0 for octal, decimal * otherwise). * \returns the parsed `long long`, or 0 if no number could be parsed. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_atoi * \sa SDL_atof * \sa SDL_strtol * \sa SDL_strtoul * \sa SDL_strtoull * \sa SDL_strtod * \sa SDL_lltoa */ extern SDL_DECLSPEC long long SDLCALL SDL_strtoll(const char *str, char **endp, int base); /** * Parse an `unsigned long long` from a string. * * If `str` starts with whitespace, then those whitespace characters are * skipped before attempting to parse the number. * * If the parsed number does not fit inside an `unsigned long long`, the * result is clamped to the maximum representable `unsigned long long` value. * * \param str The null-terminated string to read. Must not be NULL. * \param endp If not NULL, the address of the first invalid character (i.e. * the next character after the parsed number) will be written to * this pointer. * \param base The base of the integer to read. Supported values are 0 and 2 * to 36 inclusive. If 0, the base will be inferred from the * number's prefix (0x for hexadecimal, 0 for octal, decimal * otherwise). * \returns the parsed `unsigned long long`, or 0 if no number could be * parsed. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_atoi * \sa SDL_atof * \sa SDL_strtol * \sa SDL_strtoll * \sa SDL_strtoul * \sa SDL_strtod * \sa SDL_ulltoa */ extern SDL_DECLSPEC unsigned long long SDLCALL SDL_strtoull(const char *str, char **endp, int base); #endif /** * Parse a `double` from a string. * * This function makes fewer guarantees than the C runtime `strtod`: * * - Only decimal notation is guaranteed to be supported. The handling of * scientific and hexadecimal notation is unspecified. * - Whether or not INF and NAN can be parsed is unspecified. * - The precision of the result is unspecified. * * \param str the null-terminated string to read. Must not be NULL. * \param endp if not NULL, the address of the first invalid character (i.e. * the next character after the parsed number) will be written to * this pointer. * \returns the parsed `double`, or 0 if no number could be parsed. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_atoi * \sa SDL_atof * \sa SDL_strtol * \sa SDL_strtoll * \sa SDL_strtoul * \sa SDL_strtoull */ extern SDL_DECLSPEC double SDLCALL SDL_strtod(const char *str, char **endp); /** * Compare two null-terminated UTF-8 strings. * * Due to the nature of UTF-8 encoding, this will work with Unicode strings, * since effectively this function just compares bytes until it hits a * null-terminating character. Also due to the nature of UTF-8, this can be * used with SDL_qsort() to put strings in (roughly) alphabetical order. * * \param str1 the first string to compare. NULL is not permitted! * \param str2 the second string to compare. NULL is not permitted! * \returns less than zero if str1 is "less than" str2, greater than zero if * str1 is "greater than" str2, and zero if the strings match * exactly. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC int SDLCALL SDL_strcmp(const char *str1, const char *str2); /** * Compare two UTF-8 strings up to a number of bytes. * * Due to the nature of UTF-8 encoding, this will work with Unicode strings, * since effectively this function just compares bytes until it hits a * null-terminating character. Also due to the nature of UTF-8, this can be * used with SDL_qsort() to put strings in (roughly) alphabetical order. * * Note that while this function is intended to be used with UTF-8, it is * doing a bytewise comparison, and `maxlen` specifies a _byte_ limit! If the * limit lands in the middle of a multi-byte UTF-8 sequence, it will only * compare a portion of the final character. * * `maxlen` specifies a maximum number of bytes to compare; if the strings * match to this number of bytes (or both have matched to a null-terminator * character before this number of bytes), they will be considered equal. * * \param str1 the first string to compare. NULL is not permitted! * \param str2 the second string to compare. NULL is not permitted! * \param maxlen the maximum number of _bytes_ to compare. * \returns less than zero if str1 is "less than" str2, greater than zero if * str1 is "greater than" str2, and zero if the strings match * exactly. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC int SDLCALL SDL_strncmp(const char *str1, const char *str2, size_t maxlen); /** * Compare two null-terminated UTF-8 strings, case-insensitively. * * This will work with Unicode strings, using a technique called * "case-folding" to handle the vast majority of case-sensitive human * languages regardless of system locale. It can deal with expanding values: a * German Eszett character can compare against two ASCII 's' chars and be * considered a match, for example. A notable exception: it does not handle * the Turkish 'i' character; human language is complicated! * * Since this handles Unicode, it expects the string to be well-formed UTF-8 * and not a null-terminated string of arbitrary bytes. Bytes that are not * valid UTF-8 are treated as Unicode character U+FFFD (REPLACEMENT * CHARACTER), which is to say two strings of random bits may turn out to * match if they convert to the same amount of replacement characters. * * \param str1 the first string to compare. NULL is not permitted! * \param str2 the second string to compare. NULL is not permitted! * \returns less than zero if str1 is "less than" str2, greater than zero if * str1 is "greater than" str2, and zero if the strings match * exactly. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC int SDLCALL SDL_strcasecmp(const char *str1, const char *str2); /** * Compare two UTF-8 strings, case-insensitively, up to a number of bytes. * * This will work with Unicode strings, using a technique called * "case-folding" to handle the vast majority of case-sensitive human * languages regardless of system locale. It can deal with expanding values: a * German Eszett character can compare against two ASCII 's' chars and be * considered a match, for example. A notable exception: it does not handle * the Turkish 'i' character; human language is complicated! * * Since this handles Unicode, it expects the string to be well-formed UTF-8 * and not a null-terminated string of arbitrary bytes. Bytes that are not * valid UTF-8 are treated as Unicode character U+FFFD (REPLACEMENT * CHARACTER), which is to say two strings of random bits may turn out to * match if they convert to the same amount of replacement characters. * * Note that while this function is intended to be used with UTF-8, `maxlen` * specifies a _byte_ limit! If the limit lands in the middle of a multi-byte * UTF-8 sequence, it may convert a portion of the final character to one or * more Unicode character U+FFFD (REPLACEMENT CHARACTER) so as not to overflow * a buffer. * * `maxlen` specifies a maximum number of bytes to compare; if the strings * match to this number of bytes (or both have matched to a null-terminator * character before this number of bytes), they will be considered equal. * * \param str1 the first string to compare. NULL is not permitted! * \param str2 the second string to compare. NULL is not permitted! * \param maxlen the maximum number of bytes to compare. * \returns less than zero if str1 is "less than" str2, greater than zero if * str1 is "greater than" str2, and zero if the strings match * exactly. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC int SDLCALL SDL_strncasecmp(const char *str1, const char *str2, size_t maxlen); /** * Searches a string for the first occurrence of any character contained in a * breakset, and returns a pointer from the string to that character. * * \param str The null-terminated string to be searched. Must not be NULL, and * must not overlap with `breakset`. * \param breakset A null-terminated string containing the list of characters * to look for. Must not be NULL, and must not overlap with * `str`. * \returns A pointer to the location, in str, of the first occurrence of a * character present in the breakset, or NULL if none is found. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC char * SDLCALL SDL_strpbrk(const char *str, const char *breakset); /** * The Unicode REPLACEMENT CHARACTER codepoint. * * SDL_StepUTF8() and SDL_StepBackUTF8() report this codepoint when they * encounter a UTF-8 string with encoding errors. * * This tends to render as something like a question mark in most places. * * \since This macro is available since SDL 3.2.0. * * \sa SDL_StepBackUTF8 * \sa SDL_StepUTF8 */ #define SDL_INVALID_UNICODE_CODEPOINT 0xFFFD /** * Decode a UTF-8 string, one Unicode codepoint at a time. * * This will return the first Unicode codepoint in the UTF-8 encoded string in * `*pstr`, and then advance `*pstr` past any consumed bytes before returning. * * It will not access more than `*pslen` bytes from the string. `*pslen` will * be adjusted, as well, subtracting the number of bytes consumed. * * `pslen` is allowed to be NULL, in which case the string _must_ be * NULL-terminated, as the function will blindly read until it sees the NULL * char. * * if `*pslen` is zero, it assumes the end of string is reached and returns a * zero codepoint regardless of the contents of the string buffer. * * If the resulting codepoint is zero (a NULL terminator), or `*pslen` is * zero, it will not advance `*pstr` or `*pslen` at all. * * Generally this function is called in a loop until it returns zero, * adjusting its parameters each iteration. * * If an invalid UTF-8 sequence is encountered, this function returns * SDL_INVALID_UNICODE_CODEPOINT and advances the string/length by one byte * (which is to say, a multibyte sequence might produce several * SDL_INVALID_UNICODE_CODEPOINT returns before it syncs to the next valid * UTF-8 sequence). * * Several things can generate invalid UTF-8 sequences, including overlong * encodings, the use of UTF-16 surrogate values, and truncated data. Please * refer to * [RFC3629](https://www.ietf.org/rfc/rfc3629.txt) * for details. * * \param pstr a pointer to a UTF-8 string pointer to be read and adjusted. * \param pslen a pointer to the number of bytes in the string, to be read and * adjusted. NULL is allowed. * \returns the first Unicode codepoint in the string. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC Uint32 SDLCALL SDL_StepUTF8(const char **pstr, size_t *pslen); /** * Decode a UTF-8 string in reverse, one Unicode codepoint at a time. * * This will go to the start of the previous Unicode codepoint in the string, * move `*pstr` to that location and return that codepoint. * * If `*pstr` is already at the start of the string), it will not advance * `*pstr` at all. * * Generally this function is called in a loop until it returns zero, * adjusting its parameter each iteration. * * If an invalid UTF-8 sequence is encountered, this function returns * SDL_INVALID_UNICODE_CODEPOINT. * * Several things can generate invalid UTF-8 sequences, including overlong * encodings, the use of UTF-16 surrogate values, and truncated data. Please * refer to * [RFC3629](https://www.ietf.org/rfc/rfc3629.txt) * for details. * * \param start a pointer to the beginning of the UTF-8 string. * \param pstr a pointer to a UTF-8 string pointer to be read and adjusted. * \returns the previous Unicode codepoint in the string. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC Uint32 SDLCALL SDL_StepBackUTF8(const char *start, const char **pstr); /** * Convert a single Unicode codepoint to UTF-8. * * The buffer pointed to by `dst` must be at least 4 bytes long, as this * function may generate between 1 and 4 bytes of output. * * This function returns the first byte _after_ the newly-written UTF-8 * sequence, which is useful for encoding multiple codepoints in a loop, or * knowing where to write a NULL-terminator character to end the string (in * either case, plan to have a buffer of _more_ than 4 bytes!). * * If `codepoint` is an invalid value (outside the Unicode range, or a UTF-16 * surrogate value, etc), this will use U+FFFD (REPLACEMENT CHARACTER) for the * codepoint instead, and not set an error. * * If `dst` is NULL, this returns NULL immediately without writing to the * pointer and without setting an error. * * \param codepoint a Unicode codepoint to convert to UTF-8. * \param dst the location to write the encoded UTF-8. Must point to at least * 4 bytes! * \returns the first byte past the newly-written UTF-8 sequence. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC char * SDLCALL SDL_UCS4ToUTF8(Uint32 codepoint, char *dst); /** * This works exactly like sscanf() but doesn't require access to a C runtime. * * Scan a string, matching a format string, converting each '%' item and * storing it to pointers provided through variable arguments. * * \param text the string to scan. Must not be NULL. * \param fmt a printf-style format string. Must not be NULL. * \param ... a list of pointers to values to be filled in with scanned items. * \returns the number of items that matched the format string. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC int SDLCALL SDL_sscanf(const char *text, SDL_SCANF_FORMAT_STRING const char *fmt, ...) SDL_SCANF_VARARG_FUNC(2); /** * This works exactly like vsscanf() but doesn't require access to a C * runtime. * * Functions identically to SDL_sscanf(), except it takes a `va_list` instead * of using `...` variable arguments. * * \param text the string to scan. Must not be NULL. * \param fmt a printf-style format string. Must not be NULL. * \param ap a `va_list` of pointers to values to be filled in with scanned * items. * \returns the number of items that matched the format string. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC int SDLCALL SDL_vsscanf(const char *text, SDL_SCANF_FORMAT_STRING const char *fmt, va_list ap) SDL_SCANF_VARARG_FUNCV(2); /** * This works exactly like snprintf() but doesn't require access to a C * runtime. * * Format a string of up to `maxlen`-1 bytes, converting each '%' item with * values provided through variable arguments. * * While some C runtimes differ on how to deal with too-large strings, this * function null-terminates the output, by treating the null-terminator as * part of the `maxlen` count. Note that if `maxlen` is zero, however, no * bytes will be written at all. * * This function returns the number of _bytes_ (not _characters_) that should * be written, excluding the null-terminator character. If this returns a * number >= `maxlen`, it means the output string was truncated. A negative * return value means an error occurred. * * Referencing the output string's pointer with a format item is undefined * behavior. * * \param text the buffer to write the string into. Must not be NULL. * \param maxlen the maximum bytes to write, including the null-terminator. * \param fmt a printf-style format string. Must not be NULL. * \param ... a list of values to be used with the format string. * \returns the number of bytes that should be written, not counting the * null-terminator char, or a negative value on error. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC int SDLCALL SDL_snprintf(SDL_OUT_Z_CAP(maxlen) char *text, size_t maxlen, SDL_PRINTF_FORMAT_STRING const char *fmt, ...) SDL_PRINTF_VARARG_FUNC(3); /** * This works exactly like swprintf() but doesn't require access to a C * runtime. * * Format a wide string of up to `maxlen`-1 wchar_t values, converting each * '%' item with values provided through variable arguments. * * While some C runtimes differ on how to deal with too-large strings, this * function null-terminates the output, by treating the null-terminator as * part of the `maxlen` count. Note that if `maxlen` is zero, however, no wide * characters will be written at all. * * This function returns the number of _wide characters_ (not _codepoints_) * that should be written, excluding the null-terminator character. If this * returns a number >= `maxlen`, it means the output string was truncated. A * negative return value means an error occurred. * * Referencing the output string's pointer with a format item is undefined * behavior. * * \param text the buffer to write the wide string into. Must not be NULL. * \param maxlen the maximum wchar_t values to write, including the * null-terminator. * \param fmt a printf-style format string. Must not be NULL. * \param ... a list of values to be used with the format string. * \returns the number of wide characters that should be written, not counting * the null-terminator char, or a negative value on error. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC int SDLCALL SDL_swprintf(SDL_OUT_Z_CAP(maxlen) wchar_t *text, size_t maxlen, SDL_PRINTF_FORMAT_STRING const wchar_t *fmt, ...) SDL_WPRINTF_VARARG_FUNC(3); /** * This works exactly like vsnprintf() but doesn't require access to a C * runtime. * * Functions identically to SDL_snprintf(), except it takes a `va_list` * instead of using `...` variable arguments. * * \param text the buffer to write the string into. Must not be NULL. * \param maxlen the maximum bytes to write, including the null-terminator. * \param fmt a printf-style format string. Must not be NULL. * \param ap a `va_list` values to be used with the format string. * \returns the number of bytes that should be written, not counting the * null-terminator char, or a negative value on error. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC int SDLCALL SDL_vsnprintf(SDL_OUT_Z_CAP(maxlen) char *text, size_t maxlen, SDL_PRINTF_FORMAT_STRING const char *fmt, va_list ap) SDL_PRINTF_VARARG_FUNCV(3); /** * This works exactly like vswprintf() but doesn't require access to a C * runtime. * * Functions identically to SDL_swprintf(), except it takes a `va_list` * instead of using `...` variable arguments. * * \param text the buffer to write the string into. Must not be NULL. * \param maxlen the maximum wide characters to write, including the * null-terminator. * \param fmt a printf-style format wide string. Must not be NULL. * \param ap a `va_list` values to be used with the format string. * \returns the number of wide characters that should be written, not counting * the null-terminator char, or a negative value on error. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC int SDLCALL SDL_vswprintf(SDL_OUT_Z_CAP(maxlen) wchar_t *text, size_t maxlen, SDL_PRINTF_FORMAT_STRING const wchar_t *fmt, va_list ap) SDL_WPRINTF_VARARG_FUNCV(3); /** * This works exactly like asprintf() but doesn't require access to a C * runtime. * * Functions identically to SDL_snprintf(), except it allocates a buffer large * enough to hold the output string on behalf of the caller. * * On success, this function returns the number of bytes (not characters) * comprising the output string, not counting the null-terminator character, * and sets `*strp` to the newly-allocated string. * * On error, this function returns a negative number, and the value of `*strp` * is undefined. * * The returned string is owned by the caller, and should be passed to * SDL_free when no longer needed. * * \param strp on output, is set to the new string. Must not be NULL. * \param fmt a printf-style format string. Must not be NULL. * \param ... a list of values to be used with the format string. * \returns the number of bytes in the newly-allocated string, not counting * the null-terminator char, or a negative value on error. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC int SDLCALL SDL_asprintf(char **strp, SDL_PRINTF_FORMAT_STRING const char *fmt, ...) SDL_PRINTF_VARARG_FUNC(2); /** * This works exactly like vasprintf() but doesn't require access to a C * runtime. * * Functions identically to SDL_asprintf(), except it takes a `va_list` * instead of using `...` variable arguments. * * \param strp on output, is set to the new string. Must not be NULL. * \param fmt a printf-style format string. Must not be NULL. * \param ap a `va_list` values to be used with the format string. * \returns the number of bytes in the newly-allocated string, not counting * the null-terminator char, or a negative value on error. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC int SDLCALL SDL_vasprintf(char **strp, SDL_PRINTF_FORMAT_STRING const char *fmt, va_list ap) SDL_PRINTF_VARARG_FUNCV(2); /** * Seeds the pseudo-random number generator. * * Reusing the seed number will cause SDL_rand() to repeat the same stream of * 'random' numbers. * * \param seed the value to use as a random number seed, or 0 to use * SDL_GetPerformanceCounter(). * * \threadsafety This should be called on the same thread that calls * SDL_rand() * * \since This function is available since SDL 3.2.0. * * \sa SDL_rand * \sa SDL_rand_bits * \sa SDL_randf */ extern SDL_DECLSPEC void SDLCALL SDL_srand(Uint64 seed); /** * Generate a pseudo-random number less than n for positive n * * The method used is faster and of better quality than `rand() % n`. Odds are * roughly 99.9% even for n = 1 million. Evenness is better for smaller n, and * much worse as n gets bigger. * * Example: to simulate a d6 use `SDL_rand(6) + 1` The +1 converts 0..5 to * 1..6 * * If you want to generate a pseudo-random number in the full range of Sint32, * you should use: (Sint32)SDL_rand_bits() * * If you want reproducible output, be sure to initialize with SDL_srand() * first. * * There are no guarantees as to the quality of the random sequence produced, * and this should not be used for security (cryptography, passwords) or where * money is on the line (loot-boxes, casinos). There are many random number * libraries available with different characteristics and you should pick one * of those to meet any serious needs. * * \param n the number of possible outcomes. n must be positive. * \returns a random value in the range of [0 .. n-1]. * * \threadsafety All calls should be made from a single thread * * \since This function is available since SDL 3.2.0. * * \sa SDL_srand * \sa SDL_randf */ extern SDL_DECLSPEC Sint32 SDLCALL SDL_rand(Sint32 n); /** * Generate a uniform pseudo-random floating point number less than 1.0 * * If you want reproducible output, be sure to initialize with SDL_srand() * first. * * There are no guarantees as to the quality of the random sequence produced, * and this should not be used for security (cryptography, passwords) or where * money is on the line (loot-boxes, casinos). There are many random number * libraries available with different characteristics and you should pick one * of those to meet any serious needs. * * \returns a random value in the range of [0.0, 1.0). * * \threadsafety All calls should be made from a single thread * * \since This function is available since SDL 3.2.0. * * \sa SDL_srand * \sa SDL_rand */ extern SDL_DECLSPEC float SDLCALL SDL_randf(void); /** * Generate 32 pseudo-random bits. * * You likely want to use SDL_rand() to get a psuedo-random number instead. * * There are no guarantees as to the quality of the random sequence produced, * and this should not be used for security (cryptography, passwords) or where * money is on the line (loot-boxes, casinos). There are many random number * libraries available with different characteristics and you should pick one * of those to meet any serious needs. * * \returns a random value in the range of [0-SDL_MAX_UINT32]. * * \threadsafety All calls should be made from a single thread * * \since This function is available since SDL 3.2.0. * * \sa SDL_rand * \sa SDL_randf * \sa SDL_srand */ extern SDL_DECLSPEC Uint32 SDLCALL SDL_rand_bits(void); /** * Generate a pseudo-random number less than n for positive n * * The method used is faster and of better quality than `rand() % n`. Odds are * roughly 99.9% even for n = 1 million. Evenness is better for smaller n, and * much worse as n gets bigger. * * Example: to simulate a d6 use `SDL_rand_r(state, 6) + 1` The +1 converts * 0..5 to 1..6 * * If you want to generate a pseudo-random number in the full range of Sint32, * you should use: (Sint32)SDL_rand_bits_r(state) * * There are no guarantees as to the quality of the random sequence produced, * and this should not be used for security (cryptography, passwords) or where * money is on the line (loot-boxes, casinos). There are many random number * libraries available with different characteristics and you should pick one * of those to meet any serious needs. * * \param state a pointer to the current random number state, this may not be * NULL. * \param n the number of possible outcomes. n must be positive. * \returns a random value in the range of [0 .. n-1]. * * \threadsafety This function is thread-safe, as long as the state pointer * isn't shared between threads. * * \since This function is available since SDL 3.2.0. * * \sa SDL_rand * \sa SDL_rand_bits_r * \sa SDL_randf_r */ extern SDL_DECLSPEC Sint32 SDLCALL SDL_rand_r(Uint64 *state, Sint32 n); /** * Generate a uniform pseudo-random floating point number less than 1.0 * * If you want reproducible output, be sure to initialize with SDL_srand() * first. * * There are no guarantees as to the quality of the random sequence produced, * and this should not be used for security (cryptography, passwords) or where * money is on the line (loot-boxes, casinos). There are many random number * libraries available with different characteristics and you should pick one * of those to meet any serious needs. * * \param state a pointer to the current random number state, this may not be * NULL. * \returns a random value in the range of [0.0, 1.0). * * \threadsafety This function is thread-safe, as long as the state pointer * isn't shared between threads. * * \since This function is available since SDL 3.2.0. * * \sa SDL_rand_bits_r * \sa SDL_rand_r * \sa SDL_randf */ extern SDL_DECLSPEC float SDLCALL SDL_randf_r(Uint64 *state); /** * Generate 32 pseudo-random bits. * * You likely want to use SDL_rand_r() to get a psuedo-random number instead. * * There are no guarantees as to the quality of the random sequence produced, * and this should not be used for security (cryptography, passwords) or where * money is on the line (loot-boxes, casinos). There are many random number * libraries available with different characteristics and you should pick one * of those to meet any serious needs. * * \param state a pointer to the current random number state, this may not be * NULL. * \returns a random value in the range of [0-SDL_MAX_UINT32]. * * \threadsafety This function is thread-safe, as long as the state pointer * isn't shared between threads. * * \since This function is available since SDL 3.2.0. * * \sa SDL_rand_r * \sa SDL_randf_r */ extern SDL_DECLSPEC Uint32 SDLCALL SDL_rand_bits_r(Uint64 *state); #ifndef SDL_PI_D /** * The value of Pi, as a double-precision floating point literal. * * \since This macro is available since SDL 3.2.0. * * \sa SDL_PI_F */ #define SDL_PI_D 3.141592653589793238462643383279502884 /**< pi (double) */ #endif #ifndef SDL_PI_F /** * The value of Pi, as a single-precision floating point literal. * * \since This macro is available since SDL 3.2.0. * * \sa SDL_PI_D */ #define SDL_PI_F 3.141592653589793238462643383279502884F /**< pi (float) */ #endif /** * Compute the arc cosine of `x`. * * The definition of `y = acos(x)` is `x = cos(y)`. * * Domain: `-1 <= x <= 1` * * Range: `0 <= y <= Pi` * * This function operates on double-precision floating point values, use * SDL_acosf for single-precision floats. * * This function may use a different approximation across different versions, * platforms and configurations. i.e, it can return a different value given * the same input on different machines or operating systems, or if SDL is * updated. * * \param x floating point value. * \returns arc cosine of `x`, in radians. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_acosf * \sa SDL_asin * \sa SDL_cos */ extern SDL_DECLSPEC double SDLCALL SDL_acos(double x); /** * Compute the arc cosine of `x`. * * The definition of `y = acos(x)` is `x = cos(y)`. * * Domain: `-1 <= x <= 1` * * Range: `0 <= y <= Pi` * * This function operates on single-precision floating point values, use * SDL_acos for double-precision floats. * * This function may use a different approximation across different versions, * platforms and configurations. i.e, it can return a different value given * the same input on different machines or operating systems, or if SDL is * updated. * * \param x floating point value. * \returns arc cosine of `x`, in radians. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_acos * \sa SDL_asinf * \sa SDL_cosf */ extern SDL_DECLSPEC float SDLCALL SDL_acosf(float x); /** * Compute the arc sine of `x`. * * The definition of `y = asin(x)` is `x = sin(y)`. * * Domain: `-1 <= x <= 1` * * Range: `-Pi/2 <= y <= Pi/2` * * This function operates on double-precision floating point values, use * SDL_asinf for single-precision floats. * * This function may use a different approximation across different versions, * platforms and configurations. i.e, it can return a different value given * the same input on different machines or operating systems, or if SDL is * updated. * * \param x floating point value. * \returns arc sine of `x`, in radians. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_asinf * \sa SDL_acos * \sa SDL_sin */ extern SDL_DECLSPEC double SDLCALL SDL_asin(double x); /** * Compute the arc sine of `x`. * * The definition of `y = asin(x)` is `x = sin(y)`. * * Domain: `-1 <= x <= 1` * * Range: `-Pi/2 <= y <= Pi/2` * * This function operates on single-precision floating point values, use * SDL_asin for double-precision floats. * * This function may use a different approximation across different versions, * platforms and configurations. i.e, it can return a different value given * the same input on different machines or operating systems, or if SDL is * updated. * * \param x floating point value. * \returns arc sine of `x`, in radians. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_asin * \sa SDL_acosf * \sa SDL_sinf */ extern SDL_DECLSPEC float SDLCALL SDL_asinf(float x); /** * Compute the arc tangent of `x`. * * The definition of `y = atan(x)` is `x = tan(y)`. * * Domain: `-INF <= x <= INF` * * Range: `-Pi/2 <= y <= Pi/2` * * This function operates on double-precision floating point values, use * SDL_atanf for single-precision floats. * * To calculate the arc tangent of y / x, use SDL_atan2. * * This function may use a different approximation across different versions, * platforms and configurations. i.e, it can return a different value given * the same input on different machines or operating systems, or if SDL is * updated. * * \param x floating point value. * \returns arc tangent of of `x` in radians, or 0 if `x = 0`. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_atanf * \sa SDL_atan2 * \sa SDL_tan */ extern SDL_DECLSPEC double SDLCALL SDL_atan(double x); /** * Compute the arc tangent of `x`. * * The definition of `y = atan(x)` is `x = tan(y)`. * * Domain: `-INF <= x <= INF` * * Range: `-Pi/2 <= y <= Pi/2` * * This function operates on single-precision floating point values, use * SDL_atan for dboule-precision floats. * * To calculate the arc tangent of y / x, use SDL_atan2f. * * This function may use a different approximation across different versions, * platforms and configurations. i.e, it can return a different value given * the same input on different machines or operating systems, or if SDL is * updated. * * \param x floating point value. * \returns arc tangent of of `x` in radians, or 0 if `x = 0`. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_atan * \sa SDL_atan2f * \sa SDL_tanf */ extern SDL_DECLSPEC float SDLCALL SDL_atanf(float x); /** * Compute the arc tangent of `y / x`, using the signs of x and y to adjust * the result's quadrant. * * The definition of `z = atan2(x, y)` is `y = x tan(z)`, where the quadrant * of z is determined based on the signs of x and y. * * Domain: `-INF <= x <= INF`, `-INF <= y <= INF` * * Range: `-Pi <= y <= Pi` * * This function operates on double-precision floating point values, use * SDL_atan2f for single-precision floats. * * To calculate the arc tangent of a single value, use SDL_atan. * * This function may use a different approximation across different versions, * platforms and configurations. i.e, it can return a different value given * the same input on different machines or operating systems, or if SDL is * updated. * * \param y floating point value of the numerator (y coordinate). * \param x floating point value of the denominator (x coordinate). * \returns arc tangent of of `y / x` in radians, or, if `x = 0`, either * `-Pi/2`, `0`, or `Pi/2`, depending on the value of `y`. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_atan2f * \sa SDL_atan * \sa SDL_tan */ extern SDL_DECLSPEC double SDLCALL SDL_atan2(double y, double x); /** * Compute the arc tangent of `y / x`, using the signs of x and y to adjust * the result's quadrant. * * The definition of `z = atan2(x, y)` is `y = x tan(z)`, where the quadrant * of z is determined based on the signs of x and y. * * Domain: `-INF <= x <= INF`, `-INF <= y <= INF` * * Range: `-Pi <= y <= Pi` * * This function operates on single-precision floating point values, use * SDL_atan2 for double-precision floats. * * To calculate the arc tangent of a single value, use SDL_atanf. * * This function may use a different approximation across different versions, * platforms and configurations. i.e, it can return a different value given * the same input on different machines or operating systems, or if SDL is * updated. * * \param y floating point value of the numerator (y coordinate). * \param x floating point value of the denominator (x coordinate). * \returns arc tangent of of `y / x` in radians, or, if `x = 0`, either * `-Pi/2`, `0`, or `Pi/2`, depending on the value of `y`. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_atan2 * \sa SDL_atan * \sa SDL_tan */ extern SDL_DECLSPEC float SDLCALL SDL_atan2f(float y, float x); /** * Compute the ceiling of `x`. * * The ceiling of `x` is the smallest integer `y` such that `y >= x`, i.e `x` * rounded up to the nearest integer. * * Domain: `-INF <= x <= INF` * * Range: `-INF <= y <= INF`, y integer * * This function operates on double-precision floating point values, use * SDL_ceilf for single-precision floats. * * \param x floating point value. * \returns the ceiling of `x`. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_ceilf * \sa SDL_floor * \sa SDL_trunc * \sa SDL_round * \sa SDL_lround */ extern SDL_DECLSPEC double SDLCALL SDL_ceil(double x); /** * Compute the ceiling of `x`. * * The ceiling of `x` is the smallest integer `y` such that `y >= x`, i.e `x` * rounded up to the nearest integer. * * Domain: `-INF <= x <= INF` * * Range: `-INF <= y <= INF`, y integer * * This function operates on single-precision floating point values, use * SDL_ceil for double-precision floats. * * \param x floating point value. * \returns the ceiling of `x`. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_ceil * \sa SDL_floorf * \sa SDL_truncf * \sa SDL_roundf * \sa SDL_lroundf */ extern SDL_DECLSPEC float SDLCALL SDL_ceilf(float x); /** * Copy the sign of one floating-point value to another. * * The definition of copysign is that ``copysign(x, y) = abs(x) * sign(y)``. * * Domain: `-INF <= x <= INF`, ``-INF <= y <= f`` * * Range: `-INF <= z <= INF` * * This function operates on double-precision floating point values, use * SDL_copysignf for single-precision floats. * * \param x floating point value to use as the magnitude. * \param y floating point value to use as the sign. * \returns the floating point value with the sign of y and the magnitude of * x. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_copysignf * \sa SDL_fabs */ extern SDL_DECLSPEC double SDLCALL SDL_copysign(double x, double y); /** * Copy the sign of one floating-point value to another. * * The definition of copysign is that ``copysign(x, y) = abs(x) * sign(y)``. * * Domain: `-INF <= x <= INF`, ``-INF <= y <= f`` * * Range: `-INF <= z <= INF` * * This function operates on single-precision floating point values, use * SDL_copysign for double-precision floats. * * \param x floating point value to use as the magnitude. * \param y floating point value to use as the sign. * \returns the floating point value with the sign of y and the magnitude of * x. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_copysign * \sa SDL_fabsf */ extern SDL_DECLSPEC float SDLCALL SDL_copysignf(float x, float y); /** * Compute the cosine of `x`. * * Domain: `-INF <= x <= INF` * * Range: `-1 <= y <= 1` * * This function operates on double-precision floating point values, use * SDL_cosf for single-precision floats. * * This function may use a different approximation across different versions, * platforms and configurations. i.e, it can return a different value given * the same input on different machines or operating systems, or if SDL is * updated. * * \param x floating point value, in radians. * \returns cosine of `x`. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_cosf * \sa SDL_acos * \sa SDL_sin */ extern SDL_DECLSPEC double SDLCALL SDL_cos(double x); /** * Compute the cosine of `x`. * * Domain: `-INF <= x <= INF` * * Range: `-1 <= y <= 1` * * This function operates on single-precision floating point values, use * SDL_cos for double-precision floats. * * This function may use a different approximation across different versions, * platforms and configurations. i.e, it can return a different value given * the same input on different machines or operating systems, or if SDL is * updated. * * \param x floating point value, in radians. * \returns cosine of `x`. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_cos * \sa SDL_acosf * \sa SDL_sinf */ extern SDL_DECLSPEC float SDLCALL SDL_cosf(float x); /** * Compute the exponential of `x`. * * The definition of `y = exp(x)` is `y = e^x`, where `e` is the base of the * natural logarithm. The inverse is the natural logarithm, SDL_log. * * Domain: `-INF <= x <= INF` * * Range: `0 <= y <= INF` * * The output will overflow if `exp(x)` is too large to be represented. * * This function operates on double-precision floating point values, use * SDL_expf for single-precision floats. * * This function may use a different approximation across different versions, * platforms and configurations. i.e, it can return a different value given * the same input on different machines or operating systems, or if SDL is * updated. * * \param x floating point value. * \returns value of `e^x`. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_expf * \sa SDL_log */ extern SDL_DECLSPEC double SDLCALL SDL_exp(double x); /** * Compute the exponential of `x`. * * The definition of `y = exp(x)` is `y = e^x`, where `e` is the base of the * natural logarithm. The inverse is the natural logarithm, SDL_logf. * * Domain: `-INF <= x <= INF` * * Range: `0 <= y <= INF` * * The output will overflow if `exp(x)` is too large to be represented. * * This function operates on single-precision floating point values, use * SDL_exp for double-precision floats. * * This function may use a different approximation across different versions, * platforms and configurations. i.e, it can return a different value given * the same input on different machines or operating systems, or if SDL is * updated. * * \param x floating point value. * \returns value of `e^x`. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_exp * \sa SDL_logf */ extern SDL_DECLSPEC float SDLCALL SDL_expf(float x); /** * Compute the absolute value of `x` * * Domain: `-INF <= x <= INF` * * Range: `0 <= y <= INF` * * This function operates on double-precision floating point values, use * SDL_fabsf for single-precision floats. * * \param x floating point value to use as the magnitude. * \returns the absolute value of `x`. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_fabsf */ extern SDL_DECLSPEC double SDLCALL SDL_fabs(double x); /** * Compute the absolute value of `x` * * Domain: `-INF <= x <= INF` * * Range: `0 <= y <= INF` * * This function operates on single-precision floating point values, use * SDL_fabs for double-precision floats. * * \param x floating point value to use as the magnitude. * \returns the absolute value of `x`. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_fabs */ extern SDL_DECLSPEC float SDLCALL SDL_fabsf(float x); /** * Compute the floor of `x`. * * The floor of `x` is the largest integer `y` such that `y <= x`, i.e `x` * rounded down to the nearest integer. * * Domain: `-INF <= x <= INF` * * Range: `-INF <= y <= INF`, y integer * * This function operates on double-precision floating point values, use * SDL_floorf for single-precision floats. * * \param x floating point value. * \returns the floor of `x`. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_floorf * \sa SDL_ceil * \sa SDL_trunc * \sa SDL_round * \sa SDL_lround */ extern SDL_DECLSPEC double SDLCALL SDL_floor(double x); /** * Compute the floor of `x`. * * The floor of `x` is the largest integer `y` such that `y <= x`, i.e `x` * rounded down to the nearest integer. * * Domain: `-INF <= x <= INF` * * Range: `-INF <= y <= INF`, y integer * * This function operates on single-precision floating point values, use * SDL_floor for double-precision floats. * * \param x floating point value. * \returns the floor of `x`. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_floor * \sa SDL_ceilf * \sa SDL_truncf * \sa SDL_roundf * \sa SDL_lroundf */ extern SDL_DECLSPEC float SDLCALL SDL_floorf(float x); /** * Truncate `x` to an integer. * * Rounds `x` to the next closest integer to 0. This is equivalent to removing * the fractional part of `x`, leaving only the integer part. * * Domain: `-INF <= x <= INF` * * Range: `-INF <= y <= INF`, y integer * * This function operates on double-precision floating point values, use * SDL_truncf for single-precision floats. * * \param x floating point value. * \returns `x` truncated to an integer. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_truncf * \sa SDL_fmod * \sa SDL_ceil * \sa SDL_floor * \sa SDL_round * \sa SDL_lround */ extern SDL_DECLSPEC double SDLCALL SDL_trunc(double x); /** * Truncate `x` to an integer. * * Rounds `x` to the next closest integer to 0. This is equivalent to removing * the fractional part of `x`, leaving only the integer part. * * Domain: `-INF <= x <= INF` * * Range: `-INF <= y <= INF`, y integer * * This function operates on single-precision floating point values, use * SDL_trunc for double-precision floats. * * \param x floating point value. * \returns `x` truncated to an integer. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_trunc * \sa SDL_fmodf * \sa SDL_ceilf * \sa SDL_floorf * \sa SDL_roundf * \sa SDL_lroundf */ extern SDL_DECLSPEC float SDLCALL SDL_truncf(float x); /** * Return the floating-point remainder of `x / y` * * Divides `x` by `y`, and returns the remainder. * * Domain: `-INF <= x <= INF`, `-INF <= y <= INF`, `y != 0` * * Range: `-y <= z <= y` * * This function operates on double-precision floating point values, use * SDL_fmodf for single-precision floats. * * \param x the numerator. * \param y the denominator. Must not be 0. * \returns the remainder of `x / y`. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_fmodf * \sa SDL_modf * \sa SDL_trunc * \sa SDL_ceil * \sa SDL_floor * \sa SDL_round * \sa SDL_lround */ extern SDL_DECLSPEC double SDLCALL SDL_fmod(double x, double y); /** * Return the floating-point remainder of `x / y` * * Divides `x` by `y`, and returns the remainder. * * Domain: `-INF <= x <= INF`, `-INF <= y <= INF`, `y != 0` * * Range: `-y <= z <= y` * * This function operates on single-precision floating point values, use * SDL_fmod for double-precision floats. * * \param x the numerator. * \param y the denominator. Must not be 0. * \returns the remainder of `x / y`. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_fmod * \sa SDL_truncf * \sa SDL_modff * \sa SDL_ceilf * \sa SDL_floorf * \sa SDL_roundf * \sa SDL_lroundf */ extern SDL_DECLSPEC float SDLCALL SDL_fmodf(float x, float y); /** * Return whether the value is infinity. * * \param x double-precision floating point value. * \returns non-zero if the value is infinity, 0 otherwise. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_isinff */ extern SDL_DECLSPEC int SDLCALL SDL_isinf(double x); /** * Return whether the value is infinity. * * \param x floating point value. * \returns non-zero if the value is infinity, 0 otherwise. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_isinf */ extern SDL_DECLSPEC int SDLCALL SDL_isinff(float x); /** * Return whether the value is NaN. * * \param x double-precision floating point value. * \returns non-zero if the value is NaN, 0 otherwise. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_isnanf */ extern SDL_DECLSPEC int SDLCALL SDL_isnan(double x); /** * Return whether the value is NaN. * * \param x floating point value. * \returns non-zero if the value is NaN, 0 otherwise. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_isnan */ extern SDL_DECLSPEC int SDLCALL SDL_isnanf(float x); /** * Compute the natural logarithm of `x`. * * Domain: `0 < x <= INF` * * Range: `-INF <= y <= INF` * * It is an error for `x` to be less than or equal to 0. * * This function operates on double-precision floating point values, use * SDL_logf for single-precision floats. * * This function may use a different approximation across different versions, * platforms and configurations. i.e, it can return a different value given * the same input on different machines or operating systems, or if SDL is * updated. * * \param x floating point value. Must be greater than 0. * \returns the natural logarithm of `x`. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_logf * \sa SDL_log10 * \sa SDL_exp */ extern SDL_DECLSPEC double SDLCALL SDL_log(double x); /** * Compute the natural logarithm of `x`. * * Domain: `0 < x <= INF` * * Range: `-INF <= y <= INF` * * It is an error for `x` to be less than or equal to 0. * * This function operates on single-precision floating point values, use * SDL_log for double-precision floats. * * This function may use a different approximation across different versions, * platforms and configurations. i.e, it can return a different value given * the same input on different machines or operating systems, or if SDL is * updated. * * \param x floating point value. Must be greater than 0. * \returns the natural logarithm of `x`. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_log * \sa SDL_expf */ extern SDL_DECLSPEC float SDLCALL SDL_logf(float x); /** * Compute the base-10 logarithm of `x`. * * Domain: `0 < x <= INF` * * Range: `-INF <= y <= INF` * * It is an error for `x` to be less than or equal to 0. * * This function operates on double-precision floating point values, use * SDL_log10f for single-precision floats. * * This function may use a different approximation across different versions, * platforms and configurations. i.e, it can return a different value given * the same input on different machines or operating systems, or if SDL is * updated. * * \param x floating point value. Must be greater than 0. * \returns the logarithm of `x`. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_log10f * \sa SDL_log * \sa SDL_pow */ extern SDL_DECLSPEC double SDLCALL SDL_log10(double x); /** * Compute the base-10 logarithm of `x`. * * Domain: `0 < x <= INF` * * Range: `-INF <= y <= INF` * * It is an error for `x` to be less than or equal to 0. * * This function operates on single-precision floating point values, use * SDL_log10 for double-precision floats. * * This function may use a different approximation across different versions, * platforms and configurations. i.e, it can return a different value given * the same input on different machines or operating systems, or if SDL is * updated. * * \param x floating point value. Must be greater than 0. * \returns the logarithm of `x`. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_log10 * \sa SDL_logf * \sa SDL_powf */ extern SDL_DECLSPEC float SDLCALL SDL_log10f(float x); /** * Split `x` into integer and fractional parts * * This function operates on double-precision floating point values, use * SDL_modff for single-precision floats. * * \param x floating point value. * \param y output pointer to store the integer part of `x`. * \returns the fractional part of `x`. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_modff * \sa SDL_trunc * \sa SDL_fmod */ extern SDL_DECLSPEC double SDLCALL SDL_modf(double x, double *y); /** * Split `x` into integer and fractional parts * * This function operates on single-precision floating point values, use * SDL_modf for double-precision floats. * * \param x floating point value. * \param y output pointer to store the integer part of `x`. * \returns the fractional part of `x`. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_modf * \sa SDL_truncf * \sa SDL_fmodf */ extern SDL_DECLSPEC float SDLCALL SDL_modff(float x, float *y); /** * Raise `x` to the power `y` * * Domain: `-INF <= x <= INF`, `-INF <= y <= INF` * * Range: `-INF <= z <= INF` * * If `y` is the base of the natural logarithm (e), consider using SDL_exp * instead. * * This function operates on double-precision floating point values, use * SDL_powf for single-precision floats. * * This function may use a different approximation across different versions, * platforms and configurations. i.e, it can return a different value given * the same input on different machines or operating systems, or if SDL is * updated. * * \param x the base. * \param y the exponent. * \returns `x` raised to the power `y`. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_powf * \sa SDL_exp * \sa SDL_log */ extern SDL_DECLSPEC double SDLCALL SDL_pow(double x, double y); /** * Raise `x` to the power `y` * * Domain: `-INF <= x <= INF`, `-INF <= y <= INF` * * Range: `-INF <= z <= INF` * * If `y` is the base of the natural logarithm (e), consider using SDL_exp * instead. * * This function operates on single-precision floating point values, use * SDL_pow for double-precision floats. * * This function may use a different approximation across different versions, * platforms and configurations. i.e, it can return a different value given * the same input on different machines or operating systems, or if SDL is * updated. * * \param x the base. * \param y the exponent. * \returns `x` raised to the power `y`. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_pow * \sa SDL_expf * \sa SDL_logf */ extern SDL_DECLSPEC float SDLCALL SDL_powf(float x, float y); /** * Round `x` to the nearest integer. * * Rounds `x` to the nearest integer. Values halfway between integers will be * rounded away from zero. * * Domain: `-INF <= x <= INF` * * Range: `-INF <= y <= INF`, y integer * * This function operates on double-precision floating point values, use * SDL_roundf for single-precision floats. To get the result as an integer * type, use SDL_lround. * * \param x floating point value. * \returns the nearest integer to `x`. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_roundf * \sa SDL_lround * \sa SDL_floor * \sa SDL_ceil * \sa SDL_trunc */ extern SDL_DECLSPEC double SDLCALL SDL_round(double x); /** * Round `x` to the nearest integer. * * Rounds `x` to the nearest integer. Values halfway between integers will be * rounded away from zero. * * Domain: `-INF <= x <= INF` * * Range: `-INF <= y <= INF`, y integer * * This function operates on single-precision floating point values, use * SDL_round for double-precision floats. To get the result as an integer * type, use SDL_lroundf. * * \param x floating point value. * \returns the nearest integer to `x`. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_round * \sa SDL_lroundf * \sa SDL_floorf * \sa SDL_ceilf * \sa SDL_truncf */ extern SDL_DECLSPEC float SDLCALL SDL_roundf(float x); /** * Round `x` to the nearest integer representable as a long * * Rounds `x` to the nearest integer. Values halfway between integers will be * rounded away from zero. * * Domain: `-INF <= x <= INF` * * Range: `MIN_LONG <= y <= MAX_LONG` * * This function operates on double-precision floating point values, use * SDL_lroundf for single-precision floats. To get the result as a * floating-point type, use SDL_round. * * \param x floating point value. * \returns the nearest integer to `x`. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_lroundf * \sa SDL_round * \sa SDL_floor * \sa SDL_ceil * \sa SDL_trunc */ extern SDL_DECLSPEC long SDLCALL SDL_lround(double x); /** * Round `x` to the nearest integer representable as a long * * Rounds `x` to the nearest integer. Values halfway between integers will be * rounded away from zero. * * Domain: `-INF <= x <= INF` * * Range: `MIN_LONG <= y <= MAX_LONG` * * This function operates on single-precision floating point values, use * SDL_lround for double-precision floats. To get the result as a * floating-point type, use SDL_roundf. * * \param x floating point value. * \returns the nearest integer to `x`. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_lround * \sa SDL_roundf * \sa SDL_floorf * \sa SDL_ceilf * \sa SDL_truncf */ extern SDL_DECLSPEC long SDLCALL SDL_lroundf(float x); /** * Scale `x` by an integer power of two. * * Multiplies `x` by the `n`th power of the floating point radix (always 2). * * Domain: `-INF <= x <= INF`, `n` integer * * Range: `-INF <= y <= INF` * * This function operates on double-precision floating point values, use * SDL_scalbnf for single-precision floats. * * \param x floating point value to be scaled. * \param n integer exponent. * \returns `x * 2^n`. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_scalbnf * \sa SDL_pow */ extern SDL_DECLSPEC double SDLCALL SDL_scalbn(double x, int n); /** * Scale `x` by an integer power of two. * * Multiplies `x` by the `n`th power of the floating point radix (always 2). * * Domain: `-INF <= x <= INF`, `n` integer * * Range: `-INF <= y <= INF` * * This function operates on single-precision floating point values, use * SDL_scalbn for double-precision floats. * * \param x floating point value to be scaled. * \param n integer exponent. * \returns `x * 2^n`. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_scalbn * \sa SDL_powf */ extern SDL_DECLSPEC float SDLCALL SDL_scalbnf(float x, int n); /** * Compute the sine of `x`. * * Domain: `-INF <= x <= INF` * * Range: `-1 <= y <= 1` * * This function operates on double-precision floating point values, use * SDL_sinf for single-precision floats. * * This function may use a different approximation across different versions, * platforms and configurations. i.e, it can return a different value given * the same input on different machines or operating systems, or if SDL is * updated. * * \param x floating point value, in radians. * \returns sine of `x`. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_sinf * \sa SDL_asin * \sa SDL_cos */ extern SDL_DECLSPEC double SDLCALL SDL_sin(double x); /** * Compute the sine of `x`. * * Domain: `-INF <= x <= INF` * * Range: `-1 <= y <= 1` * * This function operates on single-precision floating point values, use * SDL_sin for double-precision floats. * * This function may use a different approximation across different versions, * platforms and configurations. i.e, it can return a different value given * the same input on different machines or operating systems, or if SDL is * updated. * * \param x floating point value, in radians. * \returns sine of `x`. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_sin * \sa SDL_asinf * \sa SDL_cosf */ extern SDL_DECLSPEC float SDLCALL SDL_sinf(float x); /** * Compute the square root of `x`. * * Domain: `0 <= x <= INF` * * Range: `0 <= y <= INF` * * This function operates on double-precision floating point values, use * SDL_sqrtf for single-precision floats. * * This function may use a different approximation across different versions, * platforms and configurations. i.e, it can return a different value given * the same input on different machines or operating systems, or if SDL is * updated. * * \param x floating point value. Must be greater than or equal to 0. * \returns square root of `x`. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_sqrtf */ extern SDL_DECLSPEC double SDLCALL SDL_sqrt(double x); /** * Compute the square root of `x`. * * Domain: `0 <= x <= INF` * * Range: `0 <= y <= INF` * * This function operates on single-precision floating point values, use * SDL_sqrt for double-precision floats. * * This function may use a different approximation across different versions, * platforms and configurations. i.e, it can return a different value given * the same input on different machines or operating systems, or if SDL is * updated. * * \param x floating point value. Must be greater than or equal to 0. * \returns square root of `x`. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_sqrt */ extern SDL_DECLSPEC float SDLCALL SDL_sqrtf(float x); /** * Compute the tangent of `x`. * * Domain: `-INF <= x <= INF` * * Range: `-INF <= y <= INF` * * This function operates on double-precision floating point values, use * SDL_tanf for single-precision floats. * * This function may use a different approximation across different versions, * platforms and configurations. i.e, it can return a different value given * the same input on different machines or operating systems, or if SDL is * updated. * * \param x floating point value, in radians. * \returns tangent of `x`. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_tanf * \sa SDL_sin * \sa SDL_cos * \sa SDL_atan * \sa SDL_atan2 */ extern SDL_DECLSPEC double SDLCALL SDL_tan(double x); /** * Compute the tangent of `x`. * * Domain: `-INF <= x <= INF` * * Range: `-INF <= y <= INF` * * This function operates on single-precision floating point values, use * SDL_tan for double-precision floats. * * This function may use a different approximation across different versions, * platforms and configurations. i.e, it can return a different value given * the same input on different machines or operating systems, or if SDL is * updated. * * \param x floating point value, in radians. * \returns tangent of `x`. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_tan * \sa SDL_sinf * \sa SDL_cosf * \sa SDL_atanf * \sa SDL_atan2f */ extern SDL_DECLSPEC float SDLCALL SDL_tanf(float x); /** * An opaque handle representing string encoding conversion state. * * \since This datatype is available since SDL 3.2.0. * * \sa SDL_iconv_open */ typedef struct SDL_iconv_data_t *SDL_iconv_t; /** * This function allocates a context for the specified character set * conversion. * * \param tocode The target character encoding, must not be NULL. * \param fromcode The source character encoding, must not be NULL. * \returns a handle that must be freed with SDL_iconv_close, or * SDL_ICONV_ERROR on failure. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_iconv * \sa SDL_iconv_close * \sa SDL_iconv_string */ extern SDL_DECLSPEC SDL_iconv_t SDLCALL SDL_iconv_open(const char *tocode, const char *fromcode); /** * This function frees a context used for character set conversion. * * \param cd The character set conversion handle. * \returns 0 on success, or -1 on failure. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_iconv * \sa SDL_iconv_open * \sa SDL_iconv_string */ extern SDL_DECLSPEC int SDLCALL SDL_iconv_close(SDL_iconv_t cd); /** * This function converts text between encodings, reading from and writing to * a buffer. * * It returns the number of successful conversions on success. On error, * SDL_ICONV_E2BIG is returned when the output buffer is too small, or * SDL_ICONV_EILSEQ is returned when an invalid input sequence is encountered, * or SDL_ICONV_EINVAL is returned when an incomplete input sequence is * encountered. * * On exit: * * - inbuf will point to the beginning of the next multibyte sequence. On * error, this is the location of the problematic input sequence. On * success, this is the end of the input sequence. * - inbytesleft will be set to the number of bytes left to convert, which * will be 0 on success. * - outbuf will point to the location where to store the next output byte. * - outbytesleft will be set to the number of bytes left in the output * buffer. * * \param cd The character set conversion context, created in * SDL_iconv_open(). * \param inbuf Address of variable that points to the first character of the * input sequence. * \param inbytesleft The number of bytes in the input buffer. * \param outbuf Address of variable that points to the output buffer. * \param outbytesleft The number of bytes in the output buffer. * \returns the number of conversions on success, or a negative error code. * * \threadsafety Do not use the same SDL_iconv_t from two threads at once. * * \since This function is available since SDL 3.2.0. * * \sa SDL_iconv_open * \sa SDL_iconv_close * \sa SDL_iconv_string */ extern SDL_DECLSPEC size_t SDLCALL SDL_iconv(SDL_iconv_t cd, const char **inbuf, size_t *inbytesleft, char **outbuf, size_t *outbytesleft); #define SDL_ICONV_ERROR (size_t)-1 /**< Generic error. Check SDL_GetError()? */ #define SDL_ICONV_E2BIG (size_t)-2 /**< Output buffer was too small. */ #define SDL_ICONV_EILSEQ (size_t)-3 /**< Invalid input sequence was encountered. */ #define SDL_ICONV_EINVAL (size_t)-4 /**< Incomplete input sequence was encountered. */ /** * Helper function to convert a string's encoding in one call. * * This function converts a buffer or string between encodings in one pass. * * The string does not need to be NULL-terminated; this function operates on * the number of bytes specified in `inbytesleft` whether there is a NULL * character anywhere in the buffer. * * The returned string is owned by the caller, and should be passed to * SDL_free when no longer needed. * * \param tocode the character encoding of the output string. Examples are * "UTF-8", "UCS-4", etc. * \param fromcode the character encoding of data in `inbuf`. * \param inbuf the string to convert to a different encoding. * \param inbytesleft the size of the input string _in bytes_. * \returns a new string, converted to the new encoding, or NULL on error. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_iconv_open * \sa SDL_iconv_close * \sa SDL_iconv */ extern SDL_DECLSPEC char * SDLCALL SDL_iconv_string(const char *tocode, const char *fromcode, const char *inbuf, size_t inbytesleft); /* Some helper macros for common SDL_iconv_string cases... */ /** * Convert a UTF-8 string to the current locale's character encoding. * * This is a helper macro that might be more clear than calling * SDL_iconv_string directly. However, it double-evaluates its parameter, so * do not use an expression with side-effects here. * * \param S the string to convert. * \returns a new string, converted to the new encoding, or NULL on error. * * \threadsafety It is safe to call this macro from any thread. * * \since This macro is available since SDL 3.2.0. */ #define SDL_iconv_utf8_locale(S) SDL_iconv_string("", "UTF-8", S, SDL_strlen(S)+1) /** * Convert a UTF-8 string to UCS-2. * * This is a helper macro that might be more clear than calling * SDL_iconv_string directly. However, it double-evaluates its parameter, so * do not use an expression with side-effects here. * * \param S the string to convert. * \returns a new string, converted to the new encoding, or NULL on error. * * \threadsafety It is safe to call this macro from any thread. * * \since This macro is available since SDL 3.2.0. */ #define SDL_iconv_utf8_ucs2(S) SDL_reinterpret_cast(Uint16 *, SDL_iconv_string("UCS-2", "UTF-8", S, SDL_strlen(S)+1)) /** * Convert a UTF-8 string to UCS-4. * * This is a helper macro that might be more clear than calling * SDL_iconv_string directly. However, it double-evaluates its parameter, so * do not use an expression with side-effects here. * * \param S the string to convert. * \returns a new string, converted to the new encoding, or NULL on error. * * \threadsafety It is safe to call this macro from any thread. * * \since This macro is available since SDL 3.2.0. */ #define SDL_iconv_utf8_ucs4(S) SDL_reinterpret_cast(Uint32 *, SDL_iconv_string("UCS-4", "UTF-8", S, SDL_strlen(S)+1)) /** * Convert a wchar_t string to UTF-8. * * This is a helper macro that might be more clear than calling * SDL_iconv_string directly. However, it double-evaluates its parameter, so * do not use an expression with side-effects here. * * \param S the string to convert. * \returns a new string, converted to the new encoding, or NULL on error. * * \threadsafety It is safe to call this macro from any thread. * * \since This macro is available since SDL 3.2.0. */ #define SDL_iconv_wchar_utf8(S) SDL_iconv_string("UTF-8", "WCHAR_T", SDL_reinterpret_cast(const char *, S), (SDL_wcslen(S)+1)*sizeof(wchar_t)) /* force builds using Clang's static analysis tools to use literal C runtime here, since there are possibly tests that are ineffective otherwise. */ #if defined(__clang_analyzer__) && !defined(SDL_DISABLE_ANALYZE_MACROS) /* The analyzer knows about strlcpy even when the system doesn't provide it */ #if !defined(HAVE_STRLCPY) && !defined(strlcpy) size_t strlcpy(char *dst, const char *src, size_t size); #endif /* The analyzer knows about strlcat even when the system doesn't provide it */ #if !defined(HAVE_STRLCAT) && !defined(strlcat) size_t strlcat(char *dst, const char *src, size_t size); #endif #if !defined(HAVE_WCSLCPY) && !defined(wcslcpy) size_t wcslcpy(wchar_t *dst, const wchar_t *src, size_t size); #endif #if !defined(HAVE_WCSLCAT) && !defined(wcslcat) size_t wcslcat(wchar_t *dst, const wchar_t *src, size_t size); #endif #if !defined(HAVE_STRTOK_R) && !defined(strtok_r) char *strtok_r(char *str, const char *delim, char **saveptr); #endif #ifndef _WIN32 /* strdup is not ANSI but POSIX, and its prototype might be hidden... */ /* not for windows: might conflict with string.h where strdup may have * dllimport attribute: https://github.com/libsdl-org/SDL/issues/12948 */ char *strdup(const char *str); #endif /* Starting LLVM 16, the analyser errors out if these functions do not have their prototype defined (clang-diagnostic-implicit-function-declaration) */ #include #include #define SDL_malloc malloc #define SDL_calloc calloc #define SDL_realloc realloc #define SDL_free free #ifndef SDL_memcpy #define SDL_memcpy memcpy #endif #ifndef SDL_memmove #define SDL_memmove memmove #endif #ifndef SDL_memset #define SDL_memset memset #endif #define SDL_memcmp memcmp #define SDL_strlcpy strlcpy #define SDL_strlcat strlcat #define SDL_strlen strlen #define SDL_wcslen wcslen #define SDL_wcslcpy wcslcpy #define SDL_wcslcat wcslcat #define SDL_strdup strdup #define SDL_wcsdup wcsdup #define SDL_strchr strchr #define SDL_strrchr strrchr #define SDL_strstr strstr #define SDL_wcsstr wcsstr #define SDL_strtok_r strtok_r #define SDL_strcmp strcmp #define SDL_wcscmp wcscmp #define SDL_strncmp strncmp #define SDL_wcsncmp wcsncmp #define SDL_strcasecmp strcasecmp #define SDL_strncasecmp strncasecmp #define SDL_strpbrk strpbrk #define SDL_sscanf sscanf #define SDL_vsscanf vsscanf #define SDL_snprintf snprintf #define SDL_vsnprintf vsnprintf #endif /** * Multiply two integers, checking for overflow. * * If `a * b` would overflow, return false. * * Otherwise store `a * b` via ret and return true. * * \param a the multiplicand. * \param b the multiplier. * \param ret on non-overflow output, stores the multiplication result, may * not be NULL. * \returns false on overflow, true if result is multiplied without overflow. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. */ SDL_FORCE_INLINE bool SDL_size_mul_check_overflow(size_t a, size_t b, size_t *ret) { if (a != 0 && b > SDL_SIZE_MAX / a) { return false; } *ret = a * b; return true; } #ifndef SDL_WIKI_DOCUMENTATION_SECTION #if SDL_HAS_BUILTIN(__builtin_mul_overflow) /* This needs to be wrapped in an inline rather than being a direct #define, * because __builtin_mul_overflow() is type-generic, but we want to be * consistent about interpreting a and b as size_t. */ SDL_FORCE_INLINE bool SDL_size_mul_check_overflow_builtin(size_t a, size_t b, size_t *ret) { return (__builtin_mul_overflow(a, b, ret) == 0); } #define SDL_size_mul_check_overflow(a, b, ret) SDL_size_mul_check_overflow_builtin(a, b, ret) #endif #endif /** * Add two integers, checking for overflow. * * If `a + b` would overflow, return false. * * Otherwise store `a + b` via ret and return true. * * \param a the first addend. * \param b the second addend. * \param ret on non-overflow output, stores the addition result, may not be * NULL. * \returns false on overflow, true if result is added without overflow. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. */ SDL_FORCE_INLINE bool SDL_size_add_check_overflow(size_t a, size_t b, size_t *ret) { if (b > SDL_SIZE_MAX - a) { return false; } *ret = a + b; return true; } #ifndef SDL_WIKI_DOCUMENTATION_SECTION #if SDL_HAS_BUILTIN(__builtin_add_overflow) /* This needs to be wrapped in an inline rather than being a direct #define, * the same as the call to __builtin_mul_overflow() above. */ SDL_FORCE_INLINE bool SDL_size_add_check_overflow_builtin(size_t a, size_t b, size_t *ret) { return (__builtin_add_overflow(a, b, ret) == 0); } #define SDL_size_add_check_overflow(a, b, ret) SDL_size_add_check_overflow_builtin(a, b, ret) #endif #endif /* This is a generic function pointer which should be cast to the type you expect */ #ifdef SDL_WIKI_DOCUMENTATION_SECTION /** * A generic function pointer. * * In theory, generic function pointers should use this, instead of `void *`, * since some platforms could treat code addresses differently than data * addresses. Although in current times no popular platforms make this * distinction, it is more correct and portable to use the correct type for a * generic pointer. * * If for some reason you need to force this typedef to be an actual `void *`, * perhaps to work around a compiler or existing code, you can define * `SDL_FUNCTION_POINTER_IS_VOID_POINTER` before including any SDL headers. * * \since This datatype is available since SDL 3.2.0. */ typedef void (*SDL_FunctionPointer)(void); #elif defined(SDL_FUNCTION_POINTER_IS_VOID_POINTER) typedef void *SDL_FunctionPointer; #else typedef void (*SDL_FunctionPointer)(void); #endif /* Ends C function definitions when using C++ */ #ifdef __cplusplus } #endif #include #endif /* SDL_stdinc_h_ */ ================================================ FILE: deps/include/SDL3/SDL_storage.h ================================================ /* Simple DirectMedia Layer Copyright (C) 1997-2026 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ /** * # CategoryStorage * * The storage API is a high-level API designed to abstract away the * portability issues that come up when using something lower-level (in SDL's * case, this sits on top of the [Filesystem](CategoryFilesystem) and * [IOStream](CategoryIOStream) subsystems). It is significantly more * restrictive than a typical filesystem API, for a number of reasons: * * 1. **What to Access:** A common pitfall with existing filesystem APIs is * the assumption that all storage is monolithic. However, many other * platforms (game consoles in particular) are more strict about what _type_ * of filesystem is being accessed; for example, game content and user data * are usually two separate storage devices with entirely different * characteristics (and possibly different low-level APIs altogether!). * * 2. **How to Access:** Another common mistake is applications assuming that * all storage is universally writeable - again, many platforms treat game * content and user data as two separate storage devices, and only user data * is writeable while game content is read-only. * * 3. **When to Access:** The most common portability issue with filesystem * access is _timing_ - you cannot always assume that the storage device is * always accessible all of the time, nor can you assume that there are no * limits to how long you have access to a particular device. * * Consider the following example: * * ```c * void ReadGameData(void) * { * extern char** fileNames; * extern size_t numFiles; * for (size_t i = 0; i < numFiles; i += 1) { * FILE *data = fopen(fileNames[i], "rwb"); * if (data == NULL) { * // Something bad happened! * } else { * // A bunch of stuff happens here * fclose(data); * } * } * } * * void ReadSave(void) * { * FILE *save = fopen("saves/save0.sav", "rb"); * if (save == NULL) { * // Something bad happened! * } else { * // A bunch of stuff happens here * fclose(save); * } * } * * void WriteSave(void) * { * FILE *save = fopen("saves/save0.sav", "wb"); * if (save == NULL) { * // Something bad happened! * } else { * // A bunch of stuff happens here * fclose(save); * } * } * ``` * * Going over the bullet points again: * * 1. **What to Access:** This code accesses a global filesystem; game data * and saves are all presumed to be in the current working directory (which * may or may not be the game's installation folder!). * * 2. **How to Access:** This code assumes that content paths are writeable, * and that save data is also writeable despite being in the same location as * the game data. * * 3. **When to Access:** This code assumes that they can be called at any * time, since the filesystem is always accessible and has no limits on how * long the filesystem is being accessed. * * Due to these assumptions, the filesystem code is not portable and will fail * under these common scenarios: * * - The game is installed on a device that is read-only, both content loading * and game saves will fail or crash outright * - Game/User storage is not implicitly mounted, so no files will be found * for either scenario when a platform requires explicitly mounting * filesystems * - Save data may not be safe since the I/O is not being flushed or * validated, so an error occurring elsewhere in the program may result in * missing/corrupted save data * * When using SDL_Storage, these types of problems are virtually impossible to * trip over: * * ```c * void ReadGameData(void) * { * extern char** fileNames; * extern size_t numFiles; * * SDL_Storage *title = SDL_OpenTitleStorage(NULL, 0); * if (title == NULL) { * // Something bad happened! * } * while (!SDL_StorageReady(title)) { * SDL_Delay(1); * } * * for (size_t i = 0; i < numFiles; i += 1) { * void* dst; * Uint64 dstLen = 0; * * if (SDL_GetStorageFileSize(title, fileNames[i], &dstLen) && dstLen > 0) { * dst = SDL_malloc(dstLen); * if (SDL_ReadStorageFile(title, fileNames[i], dst, dstLen)) { * // A bunch of stuff happens here * } else { * // Something bad happened! * } * SDL_free(dst); * } else { * // Something bad happened! * } * } * * SDL_CloseStorage(title); * } * * void ReadSave(void) * { * SDL_Storage *user = SDL_OpenUserStorage("libsdl", "Storage Example", 0); * if (user == NULL) { * // Something bad happened! * } * while (!SDL_StorageReady(user)) { * SDL_Delay(1); * } * * Uint64 saveLen = 0; * if (SDL_GetStorageFileSize(user, "save0.sav", &saveLen) && saveLen > 0) { * void* dst = SDL_malloc(saveLen); * if (SDL_ReadStorageFile(user, "save0.sav", dst, saveLen)) { * // A bunch of stuff happens here * } else { * // Something bad happened! * } * SDL_free(dst); * } else { * // Something bad happened! * } * * SDL_CloseStorage(user); * } * * void WriteSave(void) * { * SDL_Storage *user = SDL_OpenUserStorage("libsdl", "Storage Example", 0); * if (user == NULL) { * // Something bad happened! * } * while (!SDL_StorageReady(user)) { * SDL_Delay(1); * } * * extern void *saveData; // A bunch of stuff happened here... * extern Uint64 saveLen; * if (!SDL_WriteStorageFile(user, "save0.sav", saveData, saveLen)) { * // Something bad happened! * } * * SDL_CloseStorage(user); * } * ``` * * Note the improvements that SDL_Storage makes: * * 1. **What to Access:** This code explicitly reads from a title or user * storage device based on the context of the function. * * 2. **How to Access:** This code explicitly uses either a read or write * function based on the context of the function. * * 3. **When to Access:** This code explicitly opens the device when it needs * to, and closes it when it is finished working with the filesystem. * * The result is an application that is significantly more robust against the * increasing demands of platforms and their filesystems! * * A publicly available example of an SDL_Storage backend is the * [Steam Cloud](https://partner.steamgames.com/doc/features/cloud) * backend - you can initialize Steamworks when starting the program, and then * SDL will recognize that Steamworks is initialized and automatically use * ISteamRemoteStorage when the application opens user storage. More * importantly, when you _open_ storage it knows to begin a "batch" of * filesystem operations, and when you _close_ storage it knows to end and * flush the batch. This is used by Steam to support * [Dynamic Cloud Sync](https://steamcommunity.com/groups/steamworks/announcements/detail/3142949576401813670) * ; users can save data on one PC, put the device to sleep, and then continue * playing on another PC (and vice versa) with the save data fully * synchronized across all devices, allowing for a seamless experience without * having to do full restarts of the program. * * ## Notes on valid paths * * All paths in the Storage API use Unix-style path separators ('/'). Using a * different path separator will not work, even if the underlying platform * would otherwise accept it. This is to keep code using the Storage API * portable between platforms and Storage implementations and simplify app * code. * * Paths with relative directories ("." and "..") are forbidden by the Storage * API. * * All valid UTF-8 strings (discounting the NULL terminator character and the * '/' path separator) are usable for filenames, however, an underlying * Storage implementation may not support particularly strange sequences and * refuse to create files with those names, etc. */ #ifndef SDL_storage_h_ #define SDL_storage_h_ #include #include #include #include #include /* Set up for C function definitions, even when using C++ */ #ifdef __cplusplus extern "C" { #endif /** * Function interface for SDL_Storage. * * Apps that want to supply a custom implementation of SDL_Storage will fill * in all the functions in this struct, and then pass it to SDL_OpenStorage to * create a custom SDL_Storage object. * * It is not usually necessary to do this; SDL provides standard * implementations for many things you might expect to do with an SDL_Storage. * * This structure should be initialized using SDL_INIT_INTERFACE() * * \since This struct is available since SDL 3.2.0. * * \sa SDL_INIT_INTERFACE */ typedef struct SDL_StorageInterface { /* The version of this interface */ Uint32 version; /* Called when the storage is closed */ bool (SDLCALL *close)(void *userdata); /* Optional, returns whether the storage is currently ready for access */ bool (SDLCALL *ready)(void *userdata); /* Enumerate a directory, optional for write-only storage */ bool (SDLCALL *enumerate)(void *userdata, const char *path, SDL_EnumerateDirectoryCallback callback, void *callback_userdata); /* Get path information, optional for write-only storage */ bool (SDLCALL *info)(void *userdata, const char *path, SDL_PathInfo *info); /* Read a file from storage, optional for write-only storage */ bool (SDLCALL *read_file)(void *userdata, const char *path, void *destination, Uint64 length); /* Write a file to storage, optional for read-only storage */ bool (SDLCALL *write_file)(void *userdata, const char *path, const void *source, Uint64 length); /* Create a directory, optional for read-only storage */ bool (SDLCALL *mkdir)(void *userdata, const char *path); /* Remove a file or empty directory, optional for read-only storage */ bool (SDLCALL *remove)(void *userdata, const char *path); /* Rename a path, optional for read-only storage */ bool (SDLCALL *rename)(void *userdata, const char *oldpath, const char *newpath); /* Copy a file, optional for read-only storage */ bool (SDLCALL *copy)(void *userdata, const char *oldpath, const char *newpath); /* Get the space remaining, optional for read-only storage */ Uint64 (SDLCALL *space_remaining)(void *userdata); } SDL_StorageInterface; /* Check the size of SDL_StorageInterface * * If this assert fails, either the compiler is padding to an unexpected size, * or the interface has been updated and this should be updated to match and * the code using this interface should be updated to handle the old version. */ SDL_COMPILE_TIME_ASSERT(SDL_StorageInterface_SIZE, (sizeof(void *) == 4 && sizeof(SDL_StorageInterface) == 48) || (sizeof(void *) == 8 && sizeof(SDL_StorageInterface) == 96)); /** * An abstract interface for filesystem access. * * This is an opaque datatype. One can create this object using standard SDL * functions like SDL_OpenTitleStorage or SDL_OpenUserStorage, etc, or create * an object with a custom implementation using SDL_OpenStorage. * * \since This struct is available since SDL 3.2.0. */ typedef struct SDL_Storage SDL_Storage; /** * Opens up a read-only container for the application's filesystem. * * By default, SDL_OpenTitleStorage uses the generic storage implementation. * When the path override is not provided, the generic implementation will use * the output of SDL_GetBasePath as the base path. * * \param override a path to override the backend's default title root. * \param props a property list that may contain backend-specific information. * \returns a title storage container on success or NULL on failure; call * SDL_GetError() for more information. * * \since This function is available since SDL 3.2.0. * * \sa SDL_CloseStorage * \sa SDL_GetStorageFileSize * \sa SDL_OpenUserStorage * \sa SDL_ReadStorageFile */ extern SDL_DECLSPEC SDL_Storage * SDLCALL SDL_OpenTitleStorage(const char *override, SDL_PropertiesID props); /** * Opens up a container for a user's unique read/write filesystem. * * While title storage can generally be kept open throughout runtime, user * storage should only be opened when the client is ready to read/write files. * This allows the backend to properly batch file operations and flush them * when the container has been closed; ensuring safe and optimal save I/O. * * \param org the name of your organization. * \param app the name of your application. * \param props a property list that may contain backend-specific information. * \returns a user storage container on success or NULL on failure; call * SDL_GetError() for more information. * * \since This function is available since SDL 3.2.0. * * \sa SDL_CloseStorage * \sa SDL_GetStorageFileSize * \sa SDL_GetStorageSpaceRemaining * \sa SDL_OpenTitleStorage * \sa SDL_ReadStorageFile * \sa SDL_StorageReady * \sa SDL_WriteStorageFile */ extern SDL_DECLSPEC SDL_Storage * SDLCALL SDL_OpenUserStorage(const char *org, const char *app, SDL_PropertiesID props); /** * Opens up a container for local filesystem storage. * * This is provided for development and tools. Portable applications should * use SDL_OpenTitleStorage() for access to game data and * SDL_OpenUserStorage() for access to user data. * * \param path the base path prepended to all storage paths, or NULL for no * base path. * \returns a filesystem storage container on success or NULL on failure; call * SDL_GetError() for more information. * * \since This function is available since SDL 3.2.0. * * \sa SDL_CloseStorage * \sa SDL_GetStorageFileSize * \sa SDL_GetStorageSpaceRemaining * \sa SDL_OpenTitleStorage * \sa SDL_OpenUserStorage * \sa SDL_ReadStorageFile * \sa SDL_WriteStorageFile */ extern SDL_DECLSPEC SDL_Storage * SDLCALL SDL_OpenFileStorage(const char *path); /** * Opens up a container using a client-provided storage interface. * * Applications do not need to use this function unless they are providing * their own SDL_Storage implementation. If you just need an SDL_Storage, you * should use the built-in implementations in SDL, like SDL_OpenTitleStorage() * or SDL_OpenUserStorage(). * * This function makes a copy of `iface` and the caller does not need to keep * it around after this call. * * \param iface the interface that implements this storage, initialized using * SDL_INIT_INTERFACE(). * \param userdata the pointer that will be passed to the interface functions. * \returns a storage container on success or NULL on failure; call * SDL_GetError() for more information. * * \since This function is available since SDL 3.2.0. * * \sa SDL_CloseStorage * \sa SDL_GetStorageFileSize * \sa SDL_GetStorageSpaceRemaining * \sa SDL_INIT_INTERFACE * \sa SDL_ReadStorageFile * \sa SDL_StorageReady * \sa SDL_WriteStorageFile */ extern SDL_DECLSPEC SDL_Storage * SDLCALL SDL_OpenStorage(const SDL_StorageInterface *iface, void *userdata); /** * Closes and frees a storage container. * * \param storage a storage container to close. * \returns true if the container was freed with no errors, false otherwise; * call SDL_GetError() for more information. Even if the function * returns an error, the container data will be freed; the error is * only for informational purposes. * * \since This function is available since SDL 3.2.0. * * \sa SDL_OpenFileStorage * \sa SDL_OpenStorage * \sa SDL_OpenTitleStorage * \sa SDL_OpenUserStorage */ extern SDL_DECLSPEC bool SDLCALL SDL_CloseStorage(SDL_Storage *storage); /** * Checks if the storage container is ready to use. * * This function should be called in regular intervals until it returns true - * however, it is not recommended to spinwait on this call, as the backend may * depend on a synchronous message loop. You might instead poll this in your * game's main loop while processing events and drawing a loading screen. * * \param storage a storage container to query. * \returns true if the container is ready, false otherwise. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC bool SDLCALL SDL_StorageReady(SDL_Storage *storage); /** * Query the size of a file within a storage container. * * \param storage a storage container to query. * \param path the relative path of the file to query. * \param length a pointer to be filled with the file's length. * \returns true if the file could be queried or false on failure; call * SDL_GetError() for more information. * * \since This function is available since SDL 3.2.0. * * \sa SDL_ReadStorageFile * \sa SDL_StorageReady */ extern SDL_DECLSPEC bool SDLCALL SDL_GetStorageFileSize(SDL_Storage *storage, const char *path, Uint64 *length); /** * Synchronously read a file from a storage container into a client-provided * buffer. * * The value of `length` must match the length of the file exactly; call * SDL_GetStorageFileSize() to get this value. This behavior may be relaxed in * a future release. * * \param storage a storage container to read from. * \param path the relative path of the file to read. * \param destination a client-provided buffer to read the file into. * \param length the length of the destination buffer. * \returns true if the file was read or false on failure; call SDL_GetError() * for more information. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetStorageFileSize * \sa SDL_StorageReady * \sa SDL_WriteStorageFile */ extern SDL_DECLSPEC bool SDLCALL SDL_ReadStorageFile(SDL_Storage *storage, const char *path, void *destination, Uint64 length); /** * Synchronously write a file from client memory into a storage container. * * \param storage a storage container to write to. * \param path the relative path of the file to write. * \param source a client-provided buffer to write from. * \param length the length of the source buffer. * \returns true if the file was written or false on failure; call * SDL_GetError() for more information. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetStorageSpaceRemaining * \sa SDL_ReadStorageFile * \sa SDL_StorageReady */ extern SDL_DECLSPEC bool SDLCALL SDL_WriteStorageFile(SDL_Storage *storage, const char *path, const void *source, Uint64 length); /** * Create a directory in a writable storage container. * * \param storage a storage container. * \param path the path of the directory to create. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \since This function is available since SDL 3.2.0. * * \sa SDL_StorageReady */ extern SDL_DECLSPEC bool SDLCALL SDL_CreateStorageDirectory(SDL_Storage *storage, const char *path); /** * Enumerate a directory in a storage container through a callback function. * * This function provides every directory entry through an app-provided * callback, called once for each directory entry, until all results have been * provided or the callback returns either SDL_ENUM_SUCCESS or * SDL_ENUM_FAILURE. * * This will return false if there was a system problem in general, or if a * callback returns SDL_ENUM_FAILURE. A successful return means a callback * returned SDL_ENUM_SUCCESS to halt enumeration, or all directory entries * were enumerated. * * If `path` is NULL, this is treated as a request to enumerate the root of * the storage container's tree. An empty string also works for this. * * \param storage a storage container. * \param path the path of the directory to enumerate, or NULL for the root. * \param callback a function that is called for each entry in the directory. * \param userdata a pointer that is passed to `callback`. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \since This function is available since SDL 3.2.0. * * \sa SDL_StorageReady */ extern SDL_DECLSPEC bool SDLCALL SDL_EnumerateStorageDirectory(SDL_Storage *storage, const char *path, SDL_EnumerateDirectoryCallback callback, void *userdata); /** * Remove a file or an empty directory in a writable storage container. * * \param storage a storage container. * \param path the path to remove from the filesystem. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \since This function is available since SDL 3.2.0. * * \sa SDL_StorageReady */ extern SDL_DECLSPEC bool SDLCALL SDL_RemoveStoragePath(SDL_Storage *storage, const char *path); /** * Rename a file or directory in a writable storage container. * * \param storage a storage container. * \param oldpath the old path. * \param newpath the new path. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \since This function is available since SDL 3.2.0. * * \sa SDL_StorageReady */ extern SDL_DECLSPEC bool SDLCALL SDL_RenameStoragePath(SDL_Storage *storage, const char *oldpath, const char *newpath); /** * Copy a file in a writable storage container. * * \param storage a storage container. * \param oldpath the old path. * \param newpath the new path. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \since This function is available since SDL 3.2.0. * * \sa SDL_StorageReady */ extern SDL_DECLSPEC bool SDLCALL SDL_CopyStorageFile(SDL_Storage *storage, const char *oldpath, const char *newpath); /** * Get information about a filesystem path in a storage container. * * \param storage a storage container. * \param path the path to query. * \param info a pointer filled in with information about the path, or NULL to * check for the existence of a file. * \returns true on success or false if the file doesn't exist, or another * failure; call SDL_GetError() for more information. * * \since This function is available since SDL 3.2.0. * * \sa SDL_StorageReady */ extern SDL_DECLSPEC bool SDLCALL SDL_GetStoragePathInfo(SDL_Storage *storage, const char *path, SDL_PathInfo *info); /** * Queries the remaining space in a storage container. * * \param storage a storage container to query. * \returns the amount of remaining space, in bytes. * * \since This function is available since SDL 3.2.0. * * \sa SDL_StorageReady * \sa SDL_WriteStorageFile */ extern SDL_DECLSPEC Uint64 SDLCALL SDL_GetStorageSpaceRemaining(SDL_Storage *storage); /** * Enumerate a directory tree, filtered by pattern, and return a list. * * Files are filtered out if they don't match the string in `pattern`, which * may contain wildcard characters `*` (match everything) and `?` (match one * character). If pattern is NULL, no filtering is done and all results are * returned. Subdirectories are permitted, and are specified with a path * separator of '/'. Wildcard characters `*` and `?` never match a path * separator. * * `flags` may be set to SDL_GLOB_CASEINSENSITIVE to make the pattern matching * case-insensitive. * * The returned array is always NULL-terminated, for your iterating * convenience, but if `count` is non-NULL, on return it will contain the * number of items in the array, not counting the NULL terminator. * * If `path` is NULL, this is treated as a request to enumerate the root of * the storage container's tree. An empty string also works for this. * * \param storage a storage container. * \param path the path of the directory to enumerate, or NULL for the root. * \param pattern the pattern that files in the directory must match. Can be * NULL. * \param flags `SDL_GLOB_*` bitflags that affect this search. * \param count on return, will be set to the number of items in the returned * array. Can be NULL. * \returns an array of strings on success or NULL on failure; call * SDL_GetError() for more information. The caller should pass the * returned pointer to SDL_free when done with it. This is a single * allocation that should be freed with SDL_free() when it is no * longer needed. * * \threadsafety It is safe to call this function from any thread, assuming * the `storage` object is thread-safe. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC char ** SDLCALL SDL_GlobStorageDirectory(SDL_Storage *storage, const char *path, const char *pattern, SDL_GlobFlags flags, int *count); /* Ends C function definitions when using C++ */ #ifdef __cplusplus } #endif #include #endif /* SDL_storage_h_ */ ================================================ FILE: deps/include/SDL3/SDL_surface.h ================================================ /* Simple DirectMedia Layer Copyright (C) 1997-2026 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ /** * # CategorySurface * * SDL surfaces are buffers of pixels in system RAM. These are useful for * passing around and manipulating images that are not stored in GPU memory. * * SDL_Surface makes serious efforts to manage images in various formats, and * provides a reasonable toolbox for transforming the data, including copying * between surfaces, filling rectangles in the image data, etc. * * There is also a simple .bmp loader, SDL_LoadBMP(), and a simple .png * loader, SDL_LoadPNG(). SDL itself does not provide loaders for other file * formats, but there are several excellent external libraries that do, * including its own satellite library, * [SDL_image](https://wiki.libsdl.org/SDL3_image) * . * * In general these functions are thread-safe in that they can be called on * different threads with different surfaces. You should not try to modify any * surface from two threads simultaneously. */ #ifndef SDL_surface_h_ #define SDL_surface_h_ #include #include #include #include #include #include #include #include /* Set up for C function definitions, even when using C++ */ #ifdef __cplusplus extern "C" { #endif /** * The flags on an SDL_Surface. * * These are generally considered read-only. * * \since This datatype is available since SDL 3.2.0. */ typedef Uint32 SDL_SurfaceFlags; #define SDL_SURFACE_PREALLOCATED 0x00000001u /**< Surface uses preallocated pixel memory */ #define SDL_SURFACE_LOCK_NEEDED 0x00000002u /**< Surface needs to be locked to access pixels */ #define SDL_SURFACE_LOCKED 0x00000004u /**< Surface is currently locked */ #define SDL_SURFACE_SIMD_ALIGNED 0x00000008u /**< Surface uses pixel memory allocated with SDL_aligned_alloc() */ /** * Evaluates to true if the surface needs to be locked before access. * * \since This macro is available since SDL 3.2.0. */ #define SDL_MUSTLOCK(S) (((S)->flags & SDL_SURFACE_LOCK_NEEDED) == SDL_SURFACE_LOCK_NEEDED) /** * The scaling mode. * * \since This enum is available since SDL 3.2.0. */ typedef enum SDL_ScaleMode { SDL_SCALEMODE_INVALID = -1, SDL_SCALEMODE_NEAREST, /**< nearest pixel sampling */ SDL_SCALEMODE_LINEAR, /**< linear filtering */ SDL_SCALEMODE_PIXELART /**< nearest pixel sampling with improved scaling for pixel art, available since SDL 3.4.0 */ } SDL_ScaleMode; /** * The flip mode. * * \since This enum is available since SDL 3.2.0. */ typedef enum SDL_FlipMode { SDL_FLIP_NONE, /**< Do not flip */ SDL_FLIP_HORIZONTAL, /**< flip horizontally */ SDL_FLIP_VERTICAL, /**< flip vertically */ SDL_FLIP_HORIZONTAL_AND_VERTICAL = (SDL_FLIP_HORIZONTAL | SDL_FLIP_VERTICAL) /**< flip horizontally and vertically (not a diagonal flip) */ } SDL_FlipMode; #ifndef SDL_INTERNAL /** * A collection of pixels used in software blitting. * * Pixels are arranged in memory in rows, with the top row first. Each row * occupies an amount of memory given by the pitch (sometimes known as the row * stride in non-SDL APIs). * * Within each row, pixels are arranged from left to right until the width is * reached. Each pixel occupies a number of bits appropriate for its format, * with most formats representing each pixel as one or more whole bytes (in * some indexed formats, instead multiple pixels are packed into each byte), * and a byte order given by the format. After encoding all pixels, any * remaining bytes to reach the pitch are used as padding to reach a desired * alignment, and have undefined contents. * * When a surface holds YUV format data, the planes are assumed to be * contiguous without padding between them, e.g. a 32x32 surface in NV12 * format with a pitch of 32 would consist of 32x32 bytes of Y plane followed * by 32x16 bytes of UV plane. * * When a surface holds MJPG format data, pixels points at the compressed JPEG * image and pitch is the length of that data. * * \since This struct is available since SDL 3.2.0. * * \sa SDL_CreateSurface * \sa SDL_DestroySurface */ struct SDL_Surface { SDL_SurfaceFlags flags; /**< The flags of the surface, read-only */ SDL_PixelFormat format; /**< The format of the surface, read-only */ int w; /**< The width of the surface, read-only. */ int h; /**< The height of the surface, read-only. */ int pitch; /**< The distance in bytes between rows of pixels, read-only */ void *pixels; /**< A pointer to the pixels of the surface, the pixels are writeable if non-NULL */ int refcount; /**< Application reference count, used when freeing surface */ void *reserved; /**< Reserved for internal use */ }; #endif /* !SDL_INTERNAL */ typedef struct SDL_Surface SDL_Surface; /** * Allocate a new surface with a specific pixel format. * * The pixels of the new surface are initialized to zero. * * \param width the width of the surface. * \param height the height of the surface. * \param format the SDL_PixelFormat for the new surface's pixel format. * \returns the new SDL_Surface structure that is created or NULL on failure; * call SDL_GetError() for more information. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_CreateSurfaceFrom * \sa SDL_DestroySurface */ extern SDL_DECLSPEC SDL_Surface * SDLCALL SDL_CreateSurface(int width, int height, SDL_PixelFormat format); /** * Allocate a new surface with a specific pixel format and existing pixel * data. * * No copy is made of the pixel data. Pixel data is not managed automatically; * you must free the surface before you free the pixel data. * * Pitch is the offset in bytes from one row of pixels to the next, e.g. * `width*4` for `SDL_PIXELFORMAT_RGBA8888`. * * You may pass NULL for pixels and 0 for pitch to create a surface that you * will fill in with valid values later. * * \param width the width of the surface. * \param height the height of the surface. * \param format the SDL_PixelFormat for the new surface's pixel format. * \param pixels a pointer to existing pixel data. * \param pitch the number of bytes between each row, including padding. * \returns the new SDL_Surface structure that is created or NULL on failure; * call SDL_GetError() for more information. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_CreateSurface * \sa SDL_DestroySurface */ extern SDL_DECLSPEC SDL_Surface * SDLCALL SDL_CreateSurfaceFrom(int width, int height, SDL_PixelFormat format, void *pixels, int pitch); /** * Free a surface. * * It is safe to pass NULL to this function. * * \param surface the SDL_Surface to free. * * \threadsafety No other thread should be using the surface when it is freed. * * \since This function is available since SDL 3.2.0. * * \sa SDL_CreateSurface * \sa SDL_CreateSurfaceFrom */ extern SDL_DECLSPEC void SDLCALL SDL_DestroySurface(SDL_Surface *surface); /** * Get the properties associated with a surface. * * The following properties are understood by SDL: * * - `SDL_PROP_SURFACE_SDR_WHITE_POINT_FLOAT`: for HDR10 and floating point * surfaces, this defines the value of 100% diffuse white, with higher * values being displayed in the High Dynamic Range headroom. This defaults * to 203 for HDR10 surfaces and 1.0 for floating point surfaces. * - `SDL_PROP_SURFACE_HDR_HEADROOM_FLOAT`: for HDR10 and floating point * surfaces, this defines the maximum dynamic range used by the content, in * terms of the SDR white point. This defaults to 0.0, which disables tone * mapping. * - `SDL_PROP_SURFACE_TONEMAP_OPERATOR_STRING`: the tone mapping operator * used when compressing from a surface with high dynamic range to another * with lower dynamic range. Currently this supports "chrome", which uses * the same tone mapping that Chrome uses for HDR content, the form "*=N", * where N is a floating point scale factor applied in linear space, and * "none", which disables tone mapping. This defaults to "chrome". * - `SDL_PROP_SURFACE_HOTSPOT_X_NUMBER`: the hotspot pixel offset from the * left edge of the image, if this surface is being used as a cursor. * - `SDL_PROP_SURFACE_HOTSPOT_Y_NUMBER`: the hotspot pixel offset from the * top edge of the image, if this surface is being used as a cursor. * - `SDL_PROP_SURFACE_ROTATION_FLOAT`: the number of degrees a surface's data * is meant to be rotated clockwise to make the image right-side up. Default * 0. This is used by the camera API, if a mobile device is oriented * differently than what its camera provides (i.e. - the camera always * provides portrait images but the phone is being held in landscape * orientation). Since SDL 3.4.0. * * \param surface the SDL_Surface structure to query. * \returns a valid property ID on success or 0 on failure; call * SDL_GetError() for more information. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC SDL_PropertiesID SDLCALL SDL_GetSurfaceProperties(SDL_Surface *surface); #define SDL_PROP_SURFACE_SDR_WHITE_POINT_FLOAT "SDL.surface.SDR_white_point" #define SDL_PROP_SURFACE_HDR_HEADROOM_FLOAT "SDL.surface.HDR_headroom" #define SDL_PROP_SURFACE_TONEMAP_OPERATOR_STRING "SDL.surface.tonemap" #define SDL_PROP_SURFACE_HOTSPOT_X_NUMBER "SDL.surface.hotspot.x" #define SDL_PROP_SURFACE_HOTSPOT_Y_NUMBER "SDL.surface.hotspot.y" #define SDL_PROP_SURFACE_ROTATION_FLOAT "SDL.surface.rotation" /** * Set the colorspace used by a surface. * * Setting the colorspace doesn't change the pixels, only how they are * interpreted in color operations. * * \param surface the SDL_Surface structure to update. * \param colorspace an SDL_Colorspace value describing the surface * colorspace. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety This function can be called on different threads with * different surfaces. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetSurfaceColorspace */ extern SDL_DECLSPEC bool SDLCALL SDL_SetSurfaceColorspace(SDL_Surface *surface, SDL_Colorspace colorspace); /** * Get the colorspace used by a surface. * * The colorspace defaults to SDL_COLORSPACE_SRGB_LINEAR for floating point * formats, SDL_COLORSPACE_HDR10 for 10-bit formats, SDL_COLORSPACE_SRGB for * other RGB surfaces and SDL_COLORSPACE_BT709_FULL for YUV textures. * * \param surface the SDL_Surface structure to query. * \returns the colorspace used by the surface, or SDL_COLORSPACE_UNKNOWN if * the surface is NULL. * * \threadsafety This function can be called on different threads with * different surfaces. * * \since This function is available since SDL 3.2.0. * * \sa SDL_SetSurfaceColorspace */ extern SDL_DECLSPEC SDL_Colorspace SDLCALL SDL_GetSurfaceColorspace(SDL_Surface *surface); /** * Create a palette and associate it with a surface. * * This function creates a palette compatible with the provided surface. The * palette is then returned for you to modify, and the surface will * automatically use the new palette in future operations. You do not need to * destroy the returned palette, it will be freed when the reference count * reaches 0, usually when the surface is destroyed. * * Bitmap surfaces (with format SDL_PIXELFORMAT_INDEX1LSB or * SDL_PIXELFORMAT_INDEX1MSB) will have the palette initialized with 0 as * white and 1 as black. Other surfaces will get a palette initialized with * white in every entry. * * If this function is called for a surface that already has a palette, a new * palette will be created to replace it. * * \param surface the SDL_Surface structure to update. * \returns a new SDL_Palette structure on success or NULL on failure (e.g. if * the surface didn't have an index format); call SDL_GetError() for * more information. * * \threadsafety This function can be called on different threads with * different surfaces. * * \since This function is available since SDL 3.2.0. * * \sa SDL_SetPaletteColors */ extern SDL_DECLSPEC SDL_Palette * SDLCALL SDL_CreateSurfacePalette(SDL_Surface *surface); /** * Set the palette used by a surface. * * Setting the palette keeps an internal reference to the palette, which can * be safely destroyed afterwards. * * A single palette can be shared with many surfaces. * * \param surface the SDL_Surface structure to update. * \param palette the SDL_Palette structure to use. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety This function can be called on different threads with * different surfaces. * * \since This function is available since SDL 3.2.0. * * \sa SDL_CreatePalette * \sa SDL_GetSurfacePalette */ extern SDL_DECLSPEC bool SDLCALL SDL_SetSurfacePalette(SDL_Surface *surface, SDL_Palette *palette); /** * Get the palette used by a surface. * * \param surface the SDL_Surface structure to query. * \returns a pointer to the palette used by the surface, or NULL if there is * no palette used. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_SetSurfacePalette */ extern SDL_DECLSPEC SDL_Palette * SDLCALL SDL_GetSurfacePalette(SDL_Surface *surface); /** * Add an alternate version of a surface. * * This function adds an alternate version of this surface, usually used for * content with high DPI representations like cursors or icons. The size, * format, and content do not need to match the original surface, and these * alternate versions will not be updated when the original surface changes. * * This function adds a reference to the alternate version, so you should call * SDL_DestroySurface() on the image after this call. * * \param surface the SDL_Surface structure to update. * \param image a pointer to an alternate SDL_Surface to associate with this * surface. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety This function can be called on different threads with * different surfaces. * * \since This function is available since SDL 3.2.0. * * \sa SDL_RemoveSurfaceAlternateImages * \sa SDL_GetSurfaceImages * \sa SDL_SurfaceHasAlternateImages */ extern SDL_DECLSPEC bool SDLCALL SDL_AddSurfaceAlternateImage(SDL_Surface *surface, SDL_Surface *image); /** * Return whether a surface has alternate versions available. * * \param surface the SDL_Surface structure to query. * \returns true if alternate versions are available or false otherwise. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_AddSurfaceAlternateImage * \sa SDL_RemoveSurfaceAlternateImages * \sa SDL_GetSurfaceImages */ extern SDL_DECLSPEC bool SDLCALL SDL_SurfaceHasAlternateImages(SDL_Surface *surface); /** * Get an array including all versions of a surface. * * This returns all versions of a surface, with the surface being queried as * the first element in the returned array. * * Freeing the array of surfaces does not affect the surfaces in the array. * They are still referenced by the surface being queried and will be cleaned * up normally. * * \param surface the SDL_Surface structure to query. * \param count a pointer filled in with the number of surface pointers * returned, may be NULL. * \returns a NULL terminated array of SDL_Surface pointers or NULL on * failure; call SDL_GetError() for more information. This should be * freed with SDL_free() when it is no longer needed. * * \threadsafety This function can be called on different threads with * different surfaces. * * \since This function is available since SDL 3.2.0. * * \sa SDL_AddSurfaceAlternateImage * \sa SDL_RemoveSurfaceAlternateImages * \sa SDL_SurfaceHasAlternateImages */ extern SDL_DECLSPEC SDL_Surface ** SDLCALL SDL_GetSurfaceImages(SDL_Surface *surface, int *count); /** * Remove all alternate versions of a surface. * * This function removes a reference from all the alternative versions, * destroying them if this is the last reference to them. * * \param surface the SDL_Surface structure to update. * * \threadsafety This function can be called on different threads with * different surfaces. * * \since This function is available since SDL 3.2.0. * * \sa SDL_AddSurfaceAlternateImage * \sa SDL_GetSurfaceImages * \sa SDL_SurfaceHasAlternateImages */ extern SDL_DECLSPEC void SDLCALL SDL_RemoveSurfaceAlternateImages(SDL_Surface *surface); /** * Set up a surface for directly accessing the pixels. * * Between calls to SDL_LockSurface() / SDL_UnlockSurface(), you can write to * and read from `surface->pixels`, using the pixel format stored in * `surface->format`. Once you are done accessing the surface, you should use * SDL_UnlockSurface() to release it. * * Not all surfaces require locking. If `SDL_MUSTLOCK(surface)` evaluates to * 0, then you can read and write to the surface at any time, and the pixel * format of the surface will not change. * * \param surface the SDL_Surface structure to be locked. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety This function can be called on different threads with * different surfaces. The locking referred to by this function * is making the pixels available for direct access, not * thread-safe locking. * * \since This function is available since SDL 3.2.0. * * \sa SDL_MUSTLOCK * \sa SDL_UnlockSurface */ extern SDL_DECLSPEC bool SDLCALL SDL_LockSurface(SDL_Surface *surface); /** * Release a surface after directly accessing the pixels. * * \param surface the SDL_Surface structure to be unlocked. * * \threadsafety This function is not thread safe. The locking referred to by * this function is making the pixels available for direct * access, not thread-safe locking. * * \since This function is available since SDL 3.2.0. * * \sa SDL_LockSurface */ extern SDL_DECLSPEC void SDLCALL SDL_UnlockSurface(SDL_Surface *surface); /** * Load a BMP or PNG image from a seekable SDL data stream. * * The new surface should be freed with SDL_DestroySurface(). Not doing so * will result in a memory leak. * * \param src the data stream for the surface. * \param closeio if true, calls SDL_CloseIO() on `src` before returning, even * in the case of an error. * \returns a pointer to a new SDL_Surface structure or NULL on failure; call * SDL_GetError() for more information. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.4.0. * * \sa SDL_DestroySurface * \sa SDL_LoadSurface */ extern SDL_DECLSPEC SDL_Surface * SDLCALL SDL_LoadSurface_IO(SDL_IOStream *src, bool closeio); /** * Load a BMP or PNG image from a file. * * The new surface should be freed with SDL_DestroySurface(). Not doing so * will result in a memory leak. * * \param file the file to load. * \returns a pointer to a new SDL_Surface structure or NULL on failure; call * SDL_GetError() for more information. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.4.0. * * \sa SDL_DestroySurface * \sa SDL_LoadSurface_IO */ extern SDL_DECLSPEC SDL_Surface * SDLCALL SDL_LoadSurface(const char *file); /** * Load a BMP image from a seekable SDL data stream. * * The new surface should be freed with SDL_DestroySurface(). Not doing so * will result in a memory leak. * * \param src the data stream for the surface. * \param closeio if true, calls SDL_CloseIO() on `src` before returning, even * in the case of an error. * \returns a pointer to a new SDL_Surface structure or NULL on failure; call * SDL_GetError() for more information. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_DestroySurface * \sa SDL_LoadBMP * \sa SDL_SaveBMP_IO */ extern SDL_DECLSPEC SDL_Surface * SDLCALL SDL_LoadBMP_IO(SDL_IOStream *src, bool closeio); /** * Load a BMP image from a file. * * The new surface should be freed with SDL_DestroySurface(). Not doing so * will result in a memory leak. * * \param file the BMP file to load. * \returns a pointer to a new SDL_Surface structure or NULL on failure; call * SDL_GetError() for more information. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_DestroySurface * \sa SDL_LoadBMP_IO * \sa SDL_SaveBMP */ extern SDL_DECLSPEC SDL_Surface * SDLCALL SDL_LoadBMP(const char *file); /** * Save a surface to a seekable SDL data stream in BMP format. * * Surfaces with a 24-bit, 32-bit and paletted 8-bit format get saved in the * BMP directly. Other RGB formats with 8-bit or higher get converted to a * 24-bit surface or, if they have an alpha mask or a colorkey, to a 32-bit * surface before they are saved. YUV and paletted 1-bit and 4-bit formats are * not supported. * * \param surface the SDL_Surface structure containing the image to be saved. * \param dst a data stream to save to. * \param closeio if true, calls SDL_CloseIO() on `dst` before returning, even * in the case of an error. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety This function can be called on different threads with * different surfaces. * * \since This function is available since SDL 3.2.0. * * \sa SDL_LoadBMP_IO * \sa SDL_SaveBMP */ extern SDL_DECLSPEC bool SDLCALL SDL_SaveBMP_IO(SDL_Surface *surface, SDL_IOStream *dst, bool closeio); /** * Save a surface to a file in BMP format. * * Surfaces with a 24-bit, 32-bit and paletted 8-bit format get saved in the * BMP directly. Other RGB formats with 8-bit or higher get converted to a * 24-bit surface or, if they have an alpha mask or a colorkey, to a 32-bit * surface before they are saved. YUV and paletted 1-bit and 4-bit formats are * not supported. * * \param surface the SDL_Surface structure containing the image to be saved. * \param file a file to save to. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety This function can be called on different threads with * different surfaces. * * \since This function is available since SDL 3.2.0. * * \sa SDL_LoadBMP * \sa SDL_SaveBMP_IO */ extern SDL_DECLSPEC bool SDLCALL SDL_SaveBMP(SDL_Surface *surface, const char *file); /** * Load a PNG image from a seekable SDL data stream. * * This is intended as a convenience function for loading images from trusted * sources. If you want to load arbitrary images you should use libpng or * another image loading library designed with security in mind. * * The new surface should be freed with SDL_DestroySurface(). Not doing so * will result in a memory leak. * * \param src the data stream for the surface. * \param closeio if true, calls SDL_CloseIO() on `src` before returning, even * in the case of an error. * \returns a pointer to a new SDL_Surface structure or NULL on failure; call * SDL_GetError() for more information. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.4.0. * * \sa SDL_DestroySurface * \sa SDL_LoadPNG * \sa SDL_SavePNG_IO */ extern SDL_DECLSPEC SDL_Surface * SDLCALL SDL_LoadPNG_IO(SDL_IOStream *src, bool closeio); /** * Load a PNG image from a file. * * This is intended as a convenience function for loading images from trusted * sources. If you want to load arbitrary images you should use libpng or * another image loading library designed with security in mind. * * The new surface should be freed with SDL_DestroySurface(). Not doing so * will result in a memory leak. * * \param file the PNG file to load. * \returns a pointer to a new SDL_Surface structure or NULL on failure; call * SDL_GetError() for more information. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.4.0. * * \sa SDL_DestroySurface * \sa SDL_LoadPNG_IO * \sa SDL_SavePNG */ extern SDL_DECLSPEC SDL_Surface * SDLCALL SDL_LoadPNG(const char *file); /** * Save a surface to a seekable SDL data stream in PNG format. * * \param surface the SDL_Surface structure containing the image to be saved. * \param dst a data stream to save to. * \param closeio if true, calls SDL_CloseIO() on `dst` before returning, even * in the case of an error. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety This function can be called on different threads with * different surfaces. * * \since This function is available since SDL 3.4.0. * * \sa SDL_LoadPNG_IO * \sa SDL_SavePNG */ extern SDL_DECLSPEC bool SDLCALL SDL_SavePNG_IO(SDL_Surface *surface, SDL_IOStream *dst, bool closeio); /** * Save a surface to a file in PNG format. * * \param surface the SDL_Surface structure containing the image to be saved. * \param file a file to save to. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety This function can be called on different threads with * different surfaces. * * \since This function is available since SDL 3.4.0. * * \sa SDL_LoadPNG * \sa SDL_SavePNG_IO */ extern SDL_DECLSPEC bool SDLCALL SDL_SavePNG(SDL_Surface *surface, const char *file); /** * Set the RLE acceleration hint for a surface. * * If RLE is enabled, color key and alpha blending blits are much faster, but * the surface must be locked before directly accessing the pixels. * * \param surface the SDL_Surface structure to optimize. * \param enabled true to enable RLE acceleration, false to disable it. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety This function can be called on different threads with * different surfaces. * * \since This function is available since SDL 3.2.0. * * \sa SDL_BlitSurface * \sa SDL_LockSurface * \sa SDL_UnlockSurface */ extern SDL_DECLSPEC bool SDLCALL SDL_SetSurfaceRLE(SDL_Surface *surface, bool enabled); /** * Returns whether the surface is RLE enabled. * * It is safe to pass a NULL `surface` here; it will return false. * * \param surface the SDL_Surface structure to query. * \returns true if the surface is RLE enabled, false otherwise. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_SetSurfaceRLE */ extern SDL_DECLSPEC bool SDLCALL SDL_SurfaceHasRLE(SDL_Surface *surface); /** * Set the color key (transparent pixel) in a surface. * * The color key defines a pixel value that will be treated as transparent in * a blit. For example, one can use this to specify that cyan pixels should be * considered transparent, and therefore not rendered. * * It is a pixel of the format used by the surface, as generated by * SDL_MapRGB(). * * \param surface the SDL_Surface structure to update. * \param enabled true to enable color key, false to disable color key. * \param key the transparent pixel. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety This function can be called on different threads with * different surfaces. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetSurfaceColorKey * \sa SDL_SetSurfaceRLE * \sa SDL_SurfaceHasColorKey */ extern SDL_DECLSPEC bool SDLCALL SDL_SetSurfaceColorKey(SDL_Surface *surface, bool enabled, Uint32 key); /** * Returns whether the surface has a color key. * * It is safe to pass a NULL `surface` here; it will return false. * * \param surface the SDL_Surface structure to query. * \returns true if the surface has a color key, false otherwise. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_SetSurfaceColorKey * \sa SDL_GetSurfaceColorKey */ extern SDL_DECLSPEC bool SDLCALL SDL_SurfaceHasColorKey(SDL_Surface *surface); /** * Get the color key (transparent pixel) for a surface. * * The color key is a pixel of the format used by the surface, as generated by * SDL_MapRGB(). * * If the surface doesn't have color key enabled this function returns false. * * \param surface the SDL_Surface structure to query. * \param key a pointer filled in with the transparent pixel. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_SetSurfaceColorKey * \sa SDL_SurfaceHasColorKey */ extern SDL_DECLSPEC bool SDLCALL SDL_GetSurfaceColorKey(SDL_Surface *surface, Uint32 *key); /** * Set an additional color value multiplied into blit operations. * * When this surface is blitted, during the blit operation each source color * channel is modulated by the appropriate color value according to the * following formula: * * `srcC = srcC * (color / 255)` * * \param surface the SDL_Surface structure to update. * \param r the red color value multiplied into blit operations. * \param g the green color value multiplied into blit operations. * \param b the blue color value multiplied into blit operations. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety This function can be called on different threads with * different surfaces. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetSurfaceColorMod * \sa SDL_SetSurfaceAlphaMod */ extern SDL_DECLSPEC bool SDLCALL SDL_SetSurfaceColorMod(SDL_Surface *surface, Uint8 r, Uint8 g, Uint8 b); /** * Get the additional color value multiplied into blit operations. * * \param surface the SDL_Surface structure to query. * \param r a pointer filled in with the current red color value. * \param g a pointer filled in with the current green color value. * \param b a pointer filled in with the current blue color value. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety This function can be called on different threads with * different surfaces. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetSurfaceAlphaMod * \sa SDL_SetSurfaceColorMod */ extern SDL_DECLSPEC bool SDLCALL SDL_GetSurfaceColorMod(SDL_Surface *surface, Uint8 *r, Uint8 *g, Uint8 *b); /** * Set an additional alpha value used in blit operations. * * When this surface is blitted, during the blit operation the source alpha * value is modulated by this alpha value according to the following formula: * * `srcA = srcA * (alpha / 255)` * * \param surface the SDL_Surface structure to update. * \param alpha the alpha value multiplied into blit operations. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety This function can be called on different threads with * different surfaces. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetSurfaceAlphaMod * \sa SDL_SetSurfaceColorMod */ extern SDL_DECLSPEC bool SDLCALL SDL_SetSurfaceAlphaMod(SDL_Surface *surface, Uint8 alpha); /** * Get the additional alpha value used in blit operations. * * \param surface the SDL_Surface structure to query. * \param alpha a pointer filled in with the current alpha value. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetSurfaceColorMod * \sa SDL_SetSurfaceAlphaMod */ extern SDL_DECLSPEC bool SDLCALL SDL_GetSurfaceAlphaMod(SDL_Surface *surface, Uint8 *alpha); /** * Set the blend mode used for blit operations. * * To copy a surface to another surface (or texture) without blending with the * existing data, the blendmode of the SOURCE surface should be set to * `SDL_BLENDMODE_NONE`. * * \param surface the SDL_Surface structure to update. * \param blendMode the SDL_BlendMode to use for blit blending. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety This function can be called on different threads with * different surfaces. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetSurfaceBlendMode */ extern SDL_DECLSPEC bool SDLCALL SDL_SetSurfaceBlendMode(SDL_Surface *surface, SDL_BlendMode blendMode); /** * Get the blend mode used for blit operations. * * \param surface the SDL_Surface structure to query. * \param blendMode a pointer filled in with the current SDL_BlendMode. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_SetSurfaceBlendMode */ extern SDL_DECLSPEC bool SDLCALL SDL_GetSurfaceBlendMode(SDL_Surface *surface, SDL_BlendMode *blendMode); /** * Set the clipping rectangle for a surface. * * When `surface` is the destination of a blit, only the area within the clip * rectangle is drawn into. * * Note that blits are automatically clipped to the edges of the source and * destination surfaces. * * \param surface the SDL_Surface structure to be clipped. * \param rect the SDL_Rect structure representing the clipping rectangle, or * NULL to disable clipping. * \returns true if the rectangle intersects the surface, otherwise false and * blits will be completely clipped. * * \threadsafety This function can be called on different threads with * different surfaces. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetSurfaceClipRect */ extern SDL_DECLSPEC bool SDLCALL SDL_SetSurfaceClipRect(SDL_Surface *surface, const SDL_Rect *rect); /** * Get the clipping rectangle for a surface. * * When `surface` is the destination of a blit, only the area within the clip * rectangle is drawn into. * * \param surface the SDL_Surface structure representing the surface to be * clipped. * \param rect an SDL_Rect structure filled in with the clipping rectangle for * the surface. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety This function can be called on different threads with * different surfaces. * * \since This function is available since SDL 3.2.0. * * \sa SDL_SetSurfaceClipRect */ extern SDL_DECLSPEC bool SDLCALL SDL_GetSurfaceClipRect(SDL_Surface *surface, SDL_Rect *rect); /** * Flip a surface vertically or horizontally. * * \param surface the surface to flip. * \param flip the direction to flip. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety This function can be called on different threads with * different surfaces. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC bool SDLCALL SDL_FlipSurface(SDL_Surface *surface, SDL_FlipMode flip); /** * Return a copy of a surface rotated clockwise a number of degrees. * * The angle of rotation can be negative for counter-clockwise rotation. * * When the rotation isn't a multiple of 90 degrees, the resulting surface is * larger than the original, with the background filled in with the colorkey, * if available, or RGBA 255/255/255/0 if not. * * If `surface` has the SDL_PROP_SURFACE_ROTATION_FLOAT property set on it, * the new copy will have the adjusted value set: if the rotation property is * 90 and `angle` was 30, the new surface will have a property value of 60 * (that is: to be upright vs gravity, this surface needs to rotate 60 more * degrees). However, note that further rotations on the new surface in this * example will produce unexpected results, since the image will have resized * and padded to accommodate the not-90 degree angle. * * \param surface the surface to rotate. * \param angle the rotation angle, in degrees. * \returns a rotated copy of the surface or NULL on failure; call * SDL_GetError() for more information. * * \threadsafety This function can be called on different threads with * different surfaces. * * \since This function is available since SDL 3.4.0. */ extern SDL_DECLSPEC SDL_Surface * SDLCALL SDL_RotateSurface(SDL_Surface *surface, float angle); /** * Creates a new surface identical to the existing surface. * * If the original surface has alternate images, the new surface will have a * reference to them as well. * * The returned surface should be freed with SDL_DestroySurface(). * * \param surface the surface to duplicate. * \returns a copy of the surface or NULL on failure; call SDL_GetError() for * more information. * * \threadsafety This function can be called on different threads with * different surfaces. * * \since This function is available since SDL 3.2.0. * * \sa SDL_DestroySurface */ extern SDL_DECLSPEC SDL_Surface * SDLCALL SDL_DuplicateSurface(SDL_Surface *surface); /** * Creates a new surface identical to the existing surface, scaled to the * desired size. * * The returned surface should be freed with SDL_DestroySurface(). * * \param surface the surface to duplicate and scale. * \param width the width of the new surface. * \param height the height of the new surface. * \param scaleMode the SDL_ScaleMode to be used. * \returns a copy of the surface or NULL on failure; call SDL_GetError() for * more information. * * \threadsafety This function can be called on different threads with * different surfaces. * * \since This function is available since SDL 3.2.0. * * \sa SDL_DestroySurface */ extern SDL_DECLSPEC SDL_Surface * SDLCALL SDL_ScaleSurface(SDL_Surface *surface, int width, int height, SDL_ScaleMode scaleMode); /** * Copy an existing surface to a new surface of the specified format. * * This function is used to optimize images for faster *repeat* blitting. This * is accomplished by converting the original and storing the result as a new * surface. The new, optimized surface can then be used as the source for * future blits, making them faster. * * If you are converting to an indexed surface and want to map colors to a * palette, you can use SDL_ConvertSurfaceAndColorspace() instead. * * If the original surface has alternate images, the new surface will have a * reference to them as well. * * \param surface the existing SDL_Surface structure to convert. * \param format the new pixel format. * \returns the new SDL_Surface structure that is created or NULL on failure; * call SDL_GetError() for more information. * * \threadsafety This function can be called on different threads with * different surfaces. * * \since This function is available since SDL 3.2.0. * * \sa SDL_ConvertSurfaceAndColorspace * \sa SDL_DestroySurface */ extern SDL_DECLSPEC SDL_Surface * SDLCALL SDL_ConvertSurface(SDL_Surface *surface, SDL_PixelFormat format); /** * Copy an existing surface to a new surface of the specified format and * colorspace. * * This function converts an existing surface to a new format and colorspace * and returns the new surface. This will perform any pixel format and * colorspace conversion needed. * * If the original surface has alternate images, the new surface will have a * reference to them as well. * * \param surface the existing SDL_Surface structure to convert. * \param format the new pixel format. * \param palette an optional palette to use for indexed formats, may be NULL. * \param colorspace the new colorspace. * \param props an SDL_PropertiesID with additional color properties, or 0. * \returns the new SDL_Surface structure that is created or NULL on failure; * call SDL_GetError() for more information. * * \threadsafety This function can be called on different threads with * different surfaces. * * \since This function is available since SDL 3.2.0. * * \sa SDL_ConvertSurface * \sa SDL_DestroySurface */ extern SDL_DECLSPEC SDL_Surface * SDLCALL SDL_ConvertSurfaceAndColorspace(SDL_Surface *surface, SDL_PixelFormat format, SDL_Palette *palette, SDL_Colorspace colorspace, SDL_PropertiesID props); /** * Copy a block of pixels of one format to another format. * * \param width the width of the block to copy, in pixels. * \param height the height of the block to copy, in pixels. * \param src_format an SDL_PixelFormat value of the `src` pixels format. * \param src a pointer to the source pixels. * \param src_pitch the pitch of the source pixels, in bytes. * \param dst_format an SDL_PixelFormat value of the `dst` pixels format. * \param dst a pointer to be filled in with new pixel data. * \param dst_pitch the pitch of the destination pixels, in bytes. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety The same destination pixels should not be used from two * threads at once. It is safe to use the same source pixels * from multiple threads. * * \since This function is available since SDL 3.2.0. * * \sa SDL_ConvertPixelsAndColorspace */ extern SDL_DECLSPEC bool SDLCALL SDL_ConvertPixels(int width, int height, SDL_PixelFormat src_format, const void *src, int src_pitch, SDL_PixelFormat dst_format, void *dst, int dst_pitch); /** * Copy a block of pixels of one format and colorspace to another format and * colorspace. * * \param width the width of the block to copy, in pixels. * \param height the height of the block to copy, in pixels. * \param src_format an SDL_PixelFormat value of the `src` pixels format. * \param src_colorspace an SDL_Colorspace value describing the colorspace of * the `src` pixels. * \param src_properties an SDL_PropertiesID with additional source color * properties, or 0. * \param src a pointer to the source pixels. * \param src_pitch the pitch of the source pixels, in bytes. * \param dst_format an SDL_PixelFormat value of the `dst` pixels format. * \param dst_colorspace an SDL_Colorspace value describing the colorspace of * the `dst` pixels. * \param dst_properties an SDL_PropertiesID with additional destination color * properties, or 0. * \param dst a pointer to be filled in with new pixel data. * \param dst_pitch the pitch of the destination pixels, in bytes. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety The same destination pixels should not be used from two * threads at once. It is safe to use the same source pixels * from multiple threads. * * \since This function is available since SDL 3.2.0. * * \sa SDL_ConvertPixels */ extern SDL_DECLSPEC bool SDLCALL SDL_ConvertPixelsAndColorspace(int width, int height, SDL_PixelFormat src_format, SDL_Colorspace src_colorspace, SDL_PropertiesID src_properties, const void *src, int src_pitch, SDL_PixelFormat dst_format, SDL_Colorspace dst_colorspace, SDL_PropertiesID dst_properties, void *dst, int dst_pitch); /** * Premultiply the alpha on a block of pixels. * * This is safe to use with src == dst, but not for other overlapping areas. * * \param width the width of the block to convert, in pixels. * \param height the height of the block to convert, in pixels. * \param src_format an SDL_PixelFormat value of the `src` pixels format. * \param src a pointer to the source pixels. * \param src_pitch the pitch of the source pixels, in bytes. * \param dst_format an SDL_PixelFormat value of the `dst` pixels format. * \param dst a pointer to be filled in with premultiplied pixel data. * \param dst_pitch the pitch of the destination pixels, in bytes. * \param linear true to convert from sRGB to linear space for the alpha * multiplication, false to do multiplication in sRGB space. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety The same destination pixels should not be used from two * threads at once. It is safe to use the same source pixels * from multiple threads. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC bool SDLCALL SDL_PremultiplyAlpha(int width, int height, SDL_PixelFormat src_format, const void *src, int src_pitch, SDL_PixelFormat dst_format, void *dst, int dst_pitch, bool linear); /** * Premultiply the alpha in a surface. * * This is safe to use with src == dst, but not for other overlapping areas. * * \param surface the surface to modify. * \param linear true to convert from sRGB to linear space for the alpha * multiplication, false to do multiplication in sRGB space. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety This function can be called on different threads with * different surfaces. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC bool SDLCALL SDL_PremultiplySurfaceAlpha(SDL_Surface *surface, bool linear); /** * Clear a surface with a specific color, with floating point precision. * * This function handles all surface formats, and ignores any clip rectangle. * * If the surface is YUV, the color is assumed to be in the sRGB colorspace, * otherwise the color is assumed to be in the colorspace of the surface. * * \param surface the SDL_Surface to clear. * \param r the red component of the pixel, normally in the range 0-1. * \param g the green component of the pixel, normally in the range 0-1. * \param b the blue component of the pixel, normally in the range 0-1. * \param a the alpha component of the pixel, normally in the range 0-1. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety This function can be called on different threads with * different surfaces. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC bool SDLCALL SDL_ClearSurface(SDL_Surface *surface, float r, float g, float b, float a); /** * Perform a fast fill of a rectangle with a specific color. * * `color` should be a pixel of the format used by the surface, and can be * generated by SDL_MapRGB() or SDL_MapRGBA(). If the color value contains an * alpha component then the destination is simply filled with that alpha * information, no blending takes place. * * If there is a clip rectangle set on the destination (set via * SDL_SetSurfaceClipRect()), then this function will fill based on the * intersection of the clip rectangle and `rect`. * * \param dst the SDL_Surface structure that is the drawing target. * \param rect the SDL_Rect structure representing the rectangle to fill, or * NULL to fill the entire surface. * \param color the color to fill with. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety This function can be called on different threads with * different surfaces. * * \since This function is available since SDL 3.2.0. * * \sa SDL_FillSurfaceRects */ extern SDL_DECLSPEC bool SDLCALL SDL_FillSurfaceRect(SDL_Surface *dst, const SDL_Rect *rect, Uint32 color); /** * Perform a fast fill of a set of rectangles with a specific color. * * `color` should be a pixel of the format used by the surface, and can be * generated by SDL_MapRGB() or SDL_MapRGBA(). If the color value contains an * alpha component then the destination is simply filled with that alpha * information, no blending takes place. * * If there is a clip rectangle set on the destination (set via * SDL_SetSurfaceClipRect()), then this function will fill based on the * intersection of the clip rectangle and `rect`. * * \param dst the SDL_Surface structure that is the drawing target. * \param rects an array of SDL_Rects representing the rectangles to fill. * \param count the number of rectangles in the array. * \param color the color to fill with. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety This function can be called on different threads with * different surfaces. * * \since This function is available since SDL 3.2.0. * * \sa SDL_FillSurfaceRect */ extern SDL_DECLSPEC bool SDLCALL SDL_FillSurfaceRects(SDL_Surface *dst, const SDL_Rect *rects, int count, Uint32 color); /** * Performs a fast blit from the source surface to the destination surface * with clipping. * * If either `srcrect` or `dstrect` are NULL, the entire surface (`src` or * `dst`) is copied while ensuring clipping to `dst->clip_rect`. * * The blit function should not be called on a locked surface. * * The blit semantics for surfaces with and without blending and colorkey are * defined as follows: * * ``` * RGBA->RGB: * Source surface blend mode set to SDL_BLENDMODE_BLEND: * alpha-blend (using the source alpha-channel and per-surface alpha) * SDL_SRCCOLORKEY ignored. * Source surface blend mode set to SDL_BLENDMODE_NONE: * copy RGB. * if SDL_SRCCOLORKEY set, only copy the pixels that do not match the * RGB values of the source color key, ignoring alpha in the * comparison. * * RGB->RGBA: * Source surface blend mode set to SDL_BLENDMODE_BLEND: * alpha-blend (using the source per-surface alpha) * Source surface blend mode set to SDL_BLENDMODE_NONE: * copy RGB, set destination alpha to source per-surface alpha value. * both: * if SDL_SRCCOLORKEY set, only copy the pixels that do not match the * source color key. * * RGBA->RGBA: * Source surface blend mode set to SDL_BLENDMODE_BLEND: * alpha-blend (using the source alpha-channel and per-surface alpha) * SDL_SRCCOLORKEY ignored. * Source surface blend mode set to SDL_BLENDMODE_NONE: * copy all of RGBA to the destination. * if SDL_SRCCOLORKEY set, only copy the pixels that do not match the * RGB values of the source color key, ignoring alpha in the * comparison. * * RGB->RGB: * Source surface blend mode set to SDL_BLENDMODE_BLEND: * alpha-blend (using the source per-surface alpha) * Source surface blend mode set to SDL_BLENDMODE_NONE: * copy RGB. * both: * if SDL_SRCCOLORKEY set, only copy the pixels that do not match the * source color key. * ``` * * \param src the SDL_Surface structure to be copied from. * \param srcrect the SDL_Rect structure representing the rectangle to be * copied, or NULL to copy the entire surface. * \param dst the SDL_Surface structure that is the blit target. * \param dstrect the SDL_Rect structure representing the x and y position in * the destination surface, or NULL for (0,0). The width and * height are ignored, and are copied from `srcrect`. If you * want a specific width and height, you should use * SDL_BlitSurfaceScaled(). * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety Only one thread should be using the `src` and `dst` surfaces * at any given time. * * \since This function is available since SDL 3.2.0. * * \sa SDL_BlitSurfaceScaled */ extern SDL_DECLSPEC bool SDLCALL SDL_BlitSurface(SDL_Surface *src, const SDL_Rect *srcrect, SDL_Surface *dst, const SDL_Rect *dstrect); /** * Perform low-level surface blitting only. * * This is a semi-private blit function and it performs low-level surface * blitting, assuming the input rectangles have already been clipped. * * \param src the SDL_Surface structure to be copied from. * \param srcrect the SDL_Rect structure representing the rectangle to be * copied, may not be NULL. * \param dst the SDL_Surface structure that is the blit target. * \param dstrect the SDL_Rect structure representing the target rectangle in * the destination surface, may not be NULL. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety Only one thread should be using the `src` and `dst` surfaces * at any given time. * * \since This function is available since SDL 3.2.0. * * \sa SDL_BlitSurface */ extern SDL_DECLSPEC bool SDLCALL SDL_BlitSurfaceUnchecked(SDL_Surface *src, const SDL_Rect *srcrect, SDL_Surface *dst, const SDL_Rect *dstrect); /** * Perform a scaled blit to a destination surface, which may be of a different * format. * * \param src the SDL_Surface structure to be copied from. * \param srcrect the SDL_Rect structure representing the rectangle to be * copied, or NULL to copy the entire surface. * \param dst the SDL_Surface structure that is the blit target. * \param dstrect the SDL_Rect structure representing the target rectangle in * the destination surface, or NULL to fill the entire * destination surface. * \param scaleMode the SDL_ScaleMode to be used. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety Only one thread should be using the `src` and `dst` surfaces * at any given time. * * \since This function is available since SDL 3.2.0. * * \sa SDL_BlitSurface */ extern SDL_DECLSPEC bool SDLCALL SDL_BlitSurfaceScaled(SDL_Surface *src, const SDL_Rect *srcrect, SDL_Surface *dst, const SDL_Rect *dstrect, SDL_ScaleMode scaleMode); /** * Perform low-level surface scaled blitting only. * * This is a semi-private function and it performs low-level surface blitting, * assuming the input rectangles have already been clipped. * * \param src the SDL_Surface structure to be copied from. * \param srcrect the SDL_Rect structure representing the rectangle to be * copied, may not be NULL. * \param dst the SDL_Surface structure that is the blit target. * \param dstrect the SDL_Rect structure representing the target rectangle in * the destination surface, may not be NULL. * \param scaleMode the SDL_ScaleMode to be used. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety Only one thread should be using the `src` and `dst` surfaces * at any given time. * * \since This function is available since SDL 3.2.0. * * \sa SDL_BlitSurfaceScaled */ extern SDL_DECLSPEC bool SDLCALL SDL_BlitSurfaceUncheckedScaled(SDL_Surface *src, const SDL_Rect *srcrect, SDL_Surface *dst, const SDL_Rect *dstrect, SDL_ScaleMode scaleMode); /** * Perform a stretched pixel copy from one surface to another. * * \param src the SDL_Surface structure to be copied from. * \param srcrect the SDL_Rect structure representing the rectangle to be * copied, or NULL to copy the entire surface. * \param dst the SDL_Surface structure that is the blit target. * \param dstrect the SDL_Rect structure representing the target rectangle in * the destination surface, or NULL to fill the entire * destination surface. * \param scaleMode the SDL_ScaleMode to be used. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety Only one thread should be using the `src` and `dst` surfaces * at any given time. * * \since This function is available since SDL 3.4.0. * * \sa SDL_BlitSurfaceScaled */ extern SDL_DECLSPEC bool SDLCALL SDL_StretchSurface(SDL_Surface *src, const SDL_Rect *srcrect, SDL_Surface *dst, const SDL_Rect *dstrect, SDL_ScaleMode scaleMode); /** * Perform a tiled blit to a destination surface, which may be of a different * format. * * The pixels in `srcrect` will be repeated as many times as needed to * completely fill `dstrect`. * * \param src the SDL_Surface structure to be copied from. * \param srcrect the SDL_Rect structure representing the rectangle to be * copied, or NULL to copy the entire surface. * \param dst the SDL_Surface structure that is the blit target. * \param dstrect the SDL_Rect structure representing the target rectangle in * the destination surface, or NULL to fill the entire surface. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety Only one thread should be using the `src` and `dst` surfaces * at any given time. * * \since This function is available since SDL 3.2.0. * * \sa SDL_BlitSurface */ extern SDL_DECLSPEC bool SDLCALL SDL_BlitSurfaceTiled(SDL_Surface *src, const SDL_Rect *srcrect, SDL_Surface *dst, const SDL_Rect *dstrect); /** * Perform a scaled and tiled blit to a destination surface, which may be of a * different format. * * The pixels in `srcrect` will be scaled and repeated as many times as needed * to completely fill `dstrect`. * * \param src the SDL_Surface structure to be copied from. * \param srcrect the SDL_Rect structure representing the rectangle to be * copied, or NULL to copy the entire surface. * \param scale the scale used to transform srcrect into the destination * rectangle, e.g. a 32x32 texture with a scale of 2 would fill * 64x64 tiles. * \param scaleMode scale algorithm to be used. * \param dst the SDL_Surface structure that is the blit target. * \param dstrect the SDL_Rect structure representing the target rectangle in * the destination surface, or NULL to fill the entire surface. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety Only one thread should be using the `src` and `dst` surfaces * at any given time. * * \since This function is available since SDL 3.2.0. * * \sa SDL_BlitSurface */ extern SDL_DECLSPEC bool SDLCALL SDL_BlitSurfaceTiledWithScale(SDL_Surface *src, const SDL_Rect *srcrect, float scale, SDL_ScaleMode scaleMode, SDL_Surface *dst, const SDL_Rect *dstrect); /** * Perform a scaled blit using the 9-grid algorithm to a destination surface, * which may be of a different format. * * The pixels in the source surface are split into a 3x3 grid, using the * different corner sizes for each corner, and the sides and center making up * the remaining pixels. The corners are then scaled using `scale` and fit * into the corners of the destination rectangle. The sides and center are * then stretched into place to cover the remaining destination rectangle. * * \param src the SDL_Surface structure to be copied from. * \param srcrect the SDL_Rect structure representing the rectangle to be used * for the 9-grid, or NULL to use the entire surface. * \param left_width the width, in pixels, of the left corners in `srcrect`. * \param right_width the width, in pixels, of the right corners in `srcrect`. * \param top_height the height, in pixels, of the top corners in `srcrect`. * \param bottom_height the height, in pixels, of the bottom corners in * `srcrect`. * \param scale the scale used to transform the corner of `srcrect` into the * corner of `dstrect`, or 0.0f for an unscaled blit. * \param scaleMode scale algorithm to be used. * \param dst the SDL_Surface structure that is the blit target. * \param dstrect the SDL_Rect structure representing the target rectangle in * the destination surface, or NULL to fill the entire surface. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety Only one thread should be using the `src` and `dst` surfaces * at any given time. * * \since This function is available since SDL 3.2.0. * * \sa SDL_BlitSurface */ extern SDL_DECLSPEC bool SDLCALL SDL_BlitSurface9Grid(SDL_Surface *src, const SDL_Rect *srcrect, int left_width, int right_width, int top_height, int bottom_height, float scale, SDL_ScaleMode scaleMode, SDL_Surface *dst, const SDL_Rect *dstrect); /** * Map an RGB triple to an opaque pixel value for a surface. * * This function maps the RGB color value to the specified pixel format and * returns the pixel value best approximating the given RGB color value for * the given pixel format. * * If the surface has a palette, the index of the closest matching color in * the palette will be returned. * * If the surface pixel format has an alpha component it will be returned as * all 1 bits (fully opaque). * * If the pixel format bpp (color depth) is less than 32-bpp then the unused * upper bits of the return value can safely be ignored (e.g., with a 16-bpp * format the return value can be assigned to a Uint16, and similarly a Uint8 * for an 8-bpp format). * * \param surface the surface to use for the pixel format and palette. * \param r the red component of the pixel in the range 0-255. * \param g the green component of the pixel in the range 0-255. * \param b the blue component of the pixel in the range 0-255. * \returns a pixel value. * * \threadsafety This function can be called on different threads with * different surfaces. * * \since This function is available since SDL 3.2.0. * * \sa SDL_MapSurfaceRGBA */ extern SDL_DECLSPEC Uint32 SDLCALL SDL_MapSurfaceRGB(SDL_Surface *surface, Uint8 r, Uint8 g, Uint8 b); /** * Map an RGBA quadruple to a pixel value for a surface. * * This function maps the RGBA color value to the specified pixel format and * returns the pixel value best approximating the given RGBA color value for * the given pixel format. * * If the surface pixel format has no alpha component the alpha value will be * ignored (as it will be in formats with a palette). * * If the surface has a palette, the index of the closest matching color in * the palette will be returned. * * If the pixel format bpp (color depth) is less than 32-bpp then the unused * upper bits of the return value can safely be ignored (e.g., with a 16-bpp * format the return value can be assigned to a Uint16, and similarly a Uint8 * for an 8-bpp format). * * \param surface the surface to use for the pixel format and palette. * \param r the red component of the pixel in the range 0-255. * \param g the green component of the pixel in the range 0-255. * \param b the blue component of the pixel in the range 0-255. * \param a the alpha component of the pixel in the range 0-255. * \returns a pixel value. * * \threadsafety This function can be called on different threads with * different surfaces. * * \since This function is available since SDL 3.2.0. * * \sa SDL_MapSurfaceRGB */ extern SDL_DECLSPEC Uint32 SDLCALL SDL_MapSurfaceRGBA(SDL_Surface *surface, Uint8 r, Uint8 g, Uint8 b, Uint8 a); /** * Retrieves a single pixel from a surface. * * This function prioritizes correctness over speed: it is suitable for unit * tests, but is not intended for use in a game engine. * * Like SDL_GetRGBA, this uses the entire 0..255 range when converting color * components from pixel formats with less than 8 bits per RGB component. * * \param surface the surface to read. * \param x the horizontal coordinate, 0 <= x < width. * \param y the vertical coordinate, 0 <= y < height. * \param r a pointer filled in with the red channel, 0-255, or NULL to ignore * this channel. * \param g a pointer filled in with the green channel, 0-255, or NULL to * ignore this channel. * \param b a pointer filled in with the blue channel, 0-255, or NULL to * ignore this channel. * \param a a pointer filled in with the alpha channel, 0-255, or NULL to * ignore this channel. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety This function can be called on different threads with * different surfaces. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC bool SDLCALL SDL_ReadSurfacePixel(SDL_Surface *surface, int x, int y, Uint8 *r, Uint8 *g, Uint8 *b, Uint8 *a); /** * Retrieves a single pixel from a surface. * * This function prioritizes correctness over speed: it is suitable for unit * tests, but is not intended for use in a game engine. * * \param surface the surface to read. * \param x the horizontal coordinate, 0 <= x < width. * \param y the vertical coordinate, 0 <= y < height. * \param r a pointer filled in with the red channel, normally in the range * 0-1, or NULL to ignore this channel. * \param g a pointer filled in with the green channel, normally in the range * 0-1, or NULL to ignore this channel. * \param b a pointer filled in with the blue channel, normally in the range * 0-1, or NULL to ignore this channel. * \param a a pointer filled in with the alpha channel, normally in the range * 0-1, or NULL to ignore this channel. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety This function can be called on different threads with * different surfaces. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC bool SDLCALL SDL_ReadSurfacePixelFloat(SDL_Surface *surface, int x, int y, float *r, float *g, float *b, float *a); /** * Writes a single pixel to a surface. * * This function prioritizes correctness over speed: it is suitable for unit * tests, but is not intended for use in a game engine. * * Like SDL_MapRGBA, this uses the entire 0..255 range when converting color * components from pixel formats with less than 8 bits per RGB component. * * \param surface the surface to write. * \param x the horizontal coordinate, 0 <= x < width. * \param y the vertical coordinate, 0 <= y < height. * \param r the red channel value, 0-255. * \param g the green channel value, 0-255. * \param b the blue channel value, 0-255. * \param a the alpha channel value, 0-255. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety This function can be called on different threads with * different surfaces. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC bool SDLCALL SDL_WriteSurfacePixel(SDL_Surface *surface, int x, int y, Uint8 r, Uint8 g, Uint8 b, Uint8 a); /** * Writes a single pixel to a surface. * * This function prioritizes correctness over speed: it is suitable for unit * tests, but is not intended for use in a game engine. * * \param surface the surface to write. * \param x the horizontal coordinate, 0 <= x < width. * \param y the vertical coordinate, 0 <= y < height. * \param r the red channel value, normally in the range 0-1. * \param g the green channel value, normally in the range 0-1. * \param b the blue channel value, normally in the range 0-1. * \param a the alpha channel value, normally in the range 0-1. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety This function can be called on different threads with * different surfaces. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC bool SDLCALL SDL_WriteSurfacePixelFloat(SDL_Surface *surface, int x, int y, float r, float g, float b, float a); /* Ends C function definitions when using C++ */ #ifdef __cplusplus } #endif #include #endif /* SDL_surface_h_ */ ================================================ FILE: deps/include/SDL3/SDL_system.h ================================================ /* Simple DirectMedia Layer Copyright (C) 1997-2026 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ /** * # CategorySystem * * Platform-specific SDL API functions. These are functions that deal with * needs of specific operating systems, that didn't make sense to offer as * platform-independent, generic APIs. * * Most apps can make do without these functions, but they can be useful for * integrating with other parts of a specific system, adding platform-specific * polish to an app, or solving problems that only affect one target. */ #ifndef SDL_system_h_ #define SDL_system_h_ #include #include #include #include #include /* Set up for C function definitions, even when using C++ */ #ifdef __cplusplus extern "C" { #endif /* * Platform specific functions for Windows */ #if defined(SDL_PLATFORM_WINDOWS) typedef struct tagMSG MSG; /** * A callback to be used with SDL_SetWindowsMessageHook. * * This callback may modify the message, and should return true if the message * should continue to be processed, or false to prevent further processing. * * As this is processing a message directly from the Windows event loop, this * callback should do the minimum required work and return quickly. * * \param userdata the app-defined pointer provided to * SDL_SetWindowsMessageHook. * \param msg a pointer to a Win32 event structure to process. * \returns true to let event continue on, false to drop it. * * \threadsafety This may only be called (by SDL) from the thread handling the * Windows event loop. * * \since This datatype is available since SDL 3.2.0. * * \sa SDL_SetWindowsMessageHook * \sa SDL_HINT_WINDOWS_ENABLE_MESSAGELOOP */ typedef bool (SDLCALL *SDL_WindowsMessageHook)(void *userdata, MSG *msg); /** * Set a callback for every Windows message, run before TranslateMessage(). * * The callback may modify the message, and should return true if the message * should continue to be processed, or false to prevent further processing. * * \param callback the SDL_WindowsMessageHook function to call. * \param userdata a pointer to pass to every iteration of `callback`. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_WindowsMessageHook * \sa SDL_HINT_WINDOWS_ENABLE_MESSAGELOOP */ extern SDL_DECLSPEC void SDLCALL SDL_SetWindowsMessageHook(SDL_WindowsMessageHook callback, void *userdata); #endif /* defined(SDL_PLATFORM_WINDOWS) */ #if defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_WINGDK) /** * Get the D3D9 adapter index that matches the specified display. * * The returned adapter index can be passed to `IDirect3D9::CreateDevice` and * controls on which monitor a full screen application will appear. * * \param displayID the instance of the display to query. * \returns the D3D9 adapter index on success or -1 on failure; call * SDL_GetError() for more information. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC int SDLCALL SDL_GetDirect3D9AdapterIndex(SDL_DisplayID displayID); /** * Get the DXGI Adapter and Output indices for the specified display. * * The DXGI Adapter and Output indices can be passed to `EnumAdapters` and * `EnumOutputs` respectively to get the objects required to create a DX10 or * DX11 device and swap chain. * * \param displayID the instance of the display to query. * \param adapterIndex a pointer to be filled in with the adapter index. * \param outputIndex a pointer to be filled in with the output index. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC bool SDLCALL SDL_GetDXGIOutputInfo(SDL_DisplayID displayID, int *adapterIndex, int *outputIndex); #endif /* defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_WINGDK) */ /* * Platform specific functions for UNIX */ /* this is defined in Xlib's headers, just need a simple declaration here. */ typedef union _XEvent XEvent; /** * A callback to be used with SDL_SetX11EventHook. * * This callback may modify the event, and should return true if the event * should continue to be processed, or false to prevent further processing. * * As this is processing an event directly from the X11 event loop, this * callback should do the minimum required work and return quickly. * * \param userdata the app-defined pointer provided to SDL_SetX11EventHook. * \param xevent a pointer to an Xlib XEvent union to process. * \returns true to let event continue on, false to drop it. * * \threadsafety This may only be called (by SDL) from the thread handling the * X11 event loop. * * \since This datatype is available since SDL 3.2.0. * * \sa SDL_SetX11EventHook */ typedef bool (SDLCALL *SDL_X11EventHook)(void *userdata, XEvent *xevent); /** * Set a callback for every X11 event. * * The callback may modify the event, and should return true if the event * should continue to be processed, or false to prevent further processing. * * \param callback the SDL_X11EventHook function to call. * \param userdata a pointer to pass to every iteration of `callback`. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC void SDLCALL SDL_SetX11EventHook(SDL_X11EventHook callback, void *userdata); /* Platform specific functions for Linux*/ #ifdef SDL_PLATFORM_LINUX /** * Sets the UNIX nice value for a thread. * * This uses setpriority() if possible, and RealtimeKit if available. * * \param threadID the Unix thread ID to change priority of. * \param priority the new, Unix-specific, priority value. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC bool SDLCALL SDL_SetLinuxThreadPriority(Sint64 threadID, int priority); /** * Sets the priority (not nice level) and scheduling policy for a thread. * * This uses setpriority() if possible, and RealtimeKit if available. * * \param threadID the Unix thread ID to change priority of. * \param sdlPriority the new SDL_ThreadPriority value. * \param schedPolicy the new scheduling policy (SCHED_FIFO, SCHED_RR, * SCHED_OTHER, etc...). * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC bool SDLCALL SDL_SetLinuxThreadPriorityAndPolicy(Sint64 threadID, int sdlPriority, int schedPolicy); #endif /* SDL_PLATFORM_LINUX */ /* * Platform specific functions for iOS */ #ifdef SDL_PLATFORM_IOS /** * The prototype for an Apple iOS animation callback. * * This datatype is only useful on Apple iOS. * * After passing a function pointer of this type to * SDL_SetiOSAnimationCallback, the system will call that function pointer at * a regular interval. * * \param userdata what was passed as `callbackParam` to * SDL_SetiOSAnimationCallback as `callbackParam`. * * \since This datatype is available since SDL 3.2.0. * * \sa SDL_SetiOSAnimationCallback */ typedef void (SDLCALL *SDL_iOSAnimationCallback)(void *userdata); /** * Use this function to set the animation callback on Apple iOS. * * The function prototype for `callback` is: * * ```c * void callback(void *callbackParam); * ``` * * Where its parameter, `callbackParam`, is what was passed as `callbackParam` * to SDL_SetiOSAnimationCallback(). * * This function is only available on Apple iOS. * * For more information see: * * https://wiki.libsdl.org/SDL3/README-ios * * Note that if you use the "main callbacks" instead of a standard C `main` * function, you don't have to use this API, as SDL will manage this for you. * * Details on main callbacks are here: * * https://wiki.libsdl.org/SDL3/README-main-functions * * \param window the window for which the animation callback should be set. * \param interval the number of frames after which **callback** will be * called. * \param callback the function to call for every frame. * \param callbackParam a pointer that is passed to `callback`. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_SetiOSEventPump */ extern SDL_DECLSPEC bool SDLCALL SDL_SetiOSAnimationCallback(SDL_Window *window, int interval, SDL_iOSAnimationCallback callback, void *callbackParam); /** * Use this function to enable or disable the SDL event pump on Apple iOS. * * This function is only available on Apple iOS. * * \param enabled true to enable the event pump, false to disable it. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_SetiOSAnimationCallback */ extern SDL_DECLSPEC void SDLCALL SDL_SetiOSEventPump(bool enabled); #endif /* SDL_PLATFORM_IOS */ /* * Platform specific functions for Android */ #ifdef SDL_PLATFORM_ANDROID /** * Get the Android Java Native Interface Environment of the current thread. * * This is the JNIEnv one needs to access the Java virtual machine from native * code, and is needed for many Android APIs to be usable from C. * * The prototype of the function in SDL's code actually declare a void* return * type, even if the implementation returns a pointer to a JNIEnv. The * rationale being that the SDL headers can avoid including jni.h. * * \returns a pointer to Java native interface object (JNIEnv) to which the * current thread is attached, or NULL on failure; call * SDL_GetError() for more information. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetAndroidActivity */ extern SDL_DECLSPEC void * SDLCALL SDL_GetAndroidJNIEnv(void); /** * Retrieve the Java instance of the Android activity class. * * The prototype of the function in SDL's code actually declares a void* * return type, even if the implementation returns a jobject. The rationale * being that the SDL headers can avoid including jni.h. * * The jobject returned by the function is a local reference and must be * released by the caller. See the PushLocalFrame() and PopLocalFrame() or * DeleteLocalRef() functions of the Java native interface: * * https://docs.oracle.com/javase/1.5.0/docs/guide/jni/spec/functions.html * * \returns the jobject representing the instance of the Activity class of the * Android application, or NULL on failure; call SDL_GetError() for * more information. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetAndroidJNIEnv */ extern SDL_DECLSPEC void * SDLCALL SDL_GetAndroidActivity(void); /** * Query Android API level of the current device. * * - API level 35: Android 15 (VANILLA_ICE_CREAM) * - API level 34: Android 14 (UPSIDE_DOWN_CAKE) * - API level 33: Android 13 (TIRAMISU) * - API level 32: Android 12L (S_V2) * - API level 31: Android 12 (S) * - API level 30: Android 11 (R) * - API level 29: Android 10 (Q) * - API level 28: Android 9 (P) * - API level 27: Android 8.1 (O_MR1) * - API level 26: Android 8.0 (O) * - API level 25: Android 7.1 (N_MR1) * - API level 24: Android 7.0 (N) * - API level 23: Android 6.0 (M) * - API level 22: Android 5.1 (LOLLIPOP_MR1) * - API level 21: Android 5.0 (LOLLIPOP, L) * - API level 20: Android 4.4W (KITKAT_WATCH) * - API level 19: Android 4.4 (KITKAT) * - API level 18: Android 4.3 (JELLY_BEAN_MR2) * - API level 17: Android 4.2 (JELLY_BEAN_MR1) * - API level 16: Android 4.1 (JELLY_BEAN) * - API level 15: Android 4.0.3 (ICE_CREAM_SANDWICH_MR1) * - API level 14: Android 4.0 (ICE_CREAM_SANDWICH) * - API level 13: Android 3.2 (HONEYCOMB_MR2) * - API level 12: Android 3.1 (HONEYCOMB_MR1) * - API level 11: Android 3.0 (HONEYCOMB) * - API level 10: Android 2.3.3 (GINGERBREAD_MR1) * * \returns the Android API level. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC int SDLCALL SDL_GetAndroidSDKVersion(void); /** * Query if the application is running on a Chromebook. * * \returns true if this is a Chromebook, false otherwise. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC bool SDLCALL SDL_IsChromebook(void); /** * Query if the application is running on a Samsung DeX docking station. * * \returns true if this is a DeX docking station, false otherwise. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC bool SDLCALL SDL_IsDeXMode(void); /** * Trigger the Android system back button behavior. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC void SDLCALL SDL_SendAndroidBackButton(void); /** * See the official Android developer guide for more information: * http://developer.android.com/guide/topics/data/data-storage.html * * \since This macro is available since SDL 3.2.0. */ #define SDL_ANDROID_EXTERNAL_STORAGE_READ 0x01 /** * See the official Android developer guide for more information: * http://developer.android.com/guide/topics/data/data-storage.html * * \since This macro is available since SDL 3.2.0. */ #define SDL_ANDROID_EXTERNAL_STORAGE_WRITE 0x02 /** * Get the path used for internal storage for this Android application. * * This path is unique to your application and cannot be written to by other * applications. * * Your internal storage path is typically: * `/data/data/your.app.package/files`. * * This is a C wrapper over `android.content.Context.getFilesDir()`: * * https://developer.android.com/reference/android/content/Context#getFilesDir() * * \returns the path used for internal storage or NULL on failure; call * SDL_GetError() for more information. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetAndroidExternalStoragePath * \sa SDL_GetAndroidCachePath */ extern SDL_DECLSPEC const char * SDLCALL SDL_GetAndroidInternalStoragePath(void); /** * Get the current state of external storage for this Android application. * * The current state of external storage, a bitmask of these values: * `SDL_ANDROID_EXTERNAL_STORAGE_READ`, `SDL_ANDROID_EXTERNAL_STORAGE_WRITE`. * * If external storage is currently unavailable, this will return 0. * * \returns the current state of external storage, or 0 if external storage is * currently unavailable. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetAndroidExternalStoragePath */ extern SDL_DECLSPEC Uint32 SDLCALL SDL_GetAndroidExternalStorageState(void); /** * Get the path used for external storage for this Android application. * * This path is unique to your application, but is public and can be written * to by other applications. * * Your external storage path is typically: * `/storage/sdcard0/Android/data/your.app.package/files`. * * This is a C wrapper over `android.content.Context.getExternalFilesDir()`: * * https://developer.android.com/reference/android/content/Context#getExternalFilesDir() * * \returns the path used for external storage for this application on success * or NULL on failure; call SDL_GetError() for more information. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetAndroidExternalStorageState * \sa SDL_GetAndroidInternalStoragePath * \sa SDL_GetAndroidCachePath */ extern SDL_DECLSPEC const char * SDLCALL SDL_GetAndroidExternalStoragePath(void); /** * Get the path used for caching data for this Android application. * * This path is unique to your application, but is public and can be written * to by other applications. * * Your cache path is typically: `/data/data/your.app.package/cache/`. * * This is a C wrapper over `android.content.Context.getCacheDir()`: * * https://developer.android.com/reference/android/content/Context#getCacheDir() * * \returns the path used for caches for this application on success or NULL * on failure; call SDL_GetError() for more information. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetAndroidInternalStoragePath * \sa SDL_GetAndroidExternalStoragePath */ extern SDL_DECLSPEC const char * SDLCALL SDL_GetAndroidCachePath(void); /** * Callback that presents a response from a SDL_RequestAndroidPermission call. * * \param userdata an app-controlled pointer that is passed to the callback. * \param permission the Android-specific permission name that was requested. * \param granted true if permission is granted, false if denied. * * \since This datatype is available since SDL 3.2.0. * * \sa SDL_RequestAndroidPermission */ typedef void (SDLCALL *SDL_RequestAndroidPermissionCallback)(void *userdata, const char *permission, bool granted); /** * Request permissions at runtime, asynchronously. * * You do not need to call this for built-in functionality of SDL; recording * from a microphone or reading images from a camera, using standard SDL APIs, * will manage permission requests for you. * * This function never blocks. Instead, the app-supplied callback will be * called when a decision has been made. This callback may happen on a * different thread, and possibly much later, as it might wait on a user to * respond to a system dialog. If permission has already been granted for a * specific entitlement, the callback will still fire, probably on the current * thread and before this function returns. * * If the request submission fails, this function returns -1 and the callback * will NOT be called, but this should only happen in catastrophic conditions, * like memory running out. Normally there will be a yes or no to the request * through the callback. * * For the `permission` parameter, choose a value from here: * * https://developer.android.com/reference/android/Manifest.permission * * \param permission the permission to request. * \param cb the callback to trigger when the request has a response. * \param userdata an app-controlled pointer that is passed to the callback. * \returns true if the request was submitted, false if there was an error * submitting. The result of the request is only ever reported * through the callback, not this return value. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC bool SDLCALL SDL_RequestAndroidPermission(const char *permission, SDL_RequestAndroidPermissionCallback cb, void *userdata); /** * Shows an Android toast notification. * * Toasts are a sort of lightweight notification that are unique to Android. * * https://developer.android.com/guide/topics/ui/notifiers/toasts * * Shows toast in UI thread. * * For the `gravity` parameter, choose a value from here, or -1 if you don't * have a preference: * * https://developer.android.com/reference/android/view/Gravity * * \param message text message to be shown. * \param duration 0=short, 1=long. * \param gravity where the notification should appear on the screen. * \param xoffset set this parameter only when gravity >=0. * \param yoffset set this parameter only when gravity >=0. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC bool SDLCALL SDL_ShowAndroidToast(const char *message, int duration, int gravity, int xoffset, int yoffset); /** * Send a user command to SDLActivity. * * Override "boolean onUnhandledMessage(Message msg)" to handle the message. * * \param command user command that must be greater or equal to 0x8000. * \param param user parameter. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC bool SDLCALL SDL_SendAndroidMessage(Uint32 command, int param); #endif /* SDL_PLATFORM_ANDROID */ /** * Query if the current device is a tablet. * * If SDL can't determine this, it will return false. * * \returns true if the device is a tablet, false otherwise. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC bool SDLCALL SDL_IsTablet(void); /** * Query if the current device is a TV. * * If SDL can't determine this, it will return false. * * \returns true if the device is a TV, false otherwise. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC bool SDLCALL SDL_IsTV(void); /** * Application sandbox environment. * * \since This enum is available since SDL 3.2.0. */ typedef enum SDL_Sandbox { SDL_SANDBOX_NONE = 0, SDL_SANDBOX_UNKNOWN_CONTAINER, SDL_SANDBOX_FLATPAK, SDL_SANDBOX_SNAP, SDL_SANDBOX_MACOS } SDL_Sandbox; /** * Get the application sandbox environment, if any. * * \returns the application sandbox environment or SDL_SANDBOX_NONE if the * application is not running in a sandbox environment. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC SDL_Sandbox SDLCALL SDL_GetSandbox(void); /* Functions used by iOS app delegates to notify SDL about state changes. */ /** * Let iOS apps with external event handling report * onApplicationWillTerminate. * * This functions allows iOS apps that have their own event handling to hook * into SDL to generate SDL events. This maps directly to an iOS-specific * event, but since it doesn't do anything iOS-specific internally, it is * available on all platforms, in case it might be useful for some specific * paradigm. Most apps do not need to use this directly; SDL's internal event * code will handle all this for windows created by SDL_CreateWindow! * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC void SDLCALL SDL_OnApplicationWillTerminate(void); /** * Let iOS apps with external event handling report * onApplicationDidReceiveMemoryWarning. * * This functions allows iOS apps that have their own event handling to hook * into SDL to generate SDL events. This maps directly to an iOS-specific * event, but since it doesn't do anything iOS-specific internally, it is * available on all platforms, in case it might be useful for some specific * paradigm. Most apps do not need to use this directly; SDL's internal event * code will handle all this for windows created by SDL_CreateWindow! * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC void SDLCALL SDL_OnApplicationDidReceiveMemoryWarning(void); /** * Let iOS apps with external event handling report * onApplicationWillResignActive. * * This functions allows iOS apps that have their own event handling to hook * into SDL to generate SDL events. This maps directly to an iOS-specific * event, but since it doesn't do anything iOS-specific internally, it is * available on all platforms, in case it might be useful for some specific * paradigm. Most apps do not need to use this directly; SDL's internal event * code will handle all this for windows created by SDL_CreateWindow! * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC void SDLCALL SDL_OnApplicationWillEnterBackground(void); /** * Let iOS apps with external event handling report * onApplicationDidEnterBackground. * * This functions allows iOS apps that have their own event handling to hook * into SDL to generate SDL events. This maps directly to an iOS-specific * event, but since it doesn't do anything iOS-specific internally, it is * available on all platforms, in case it might be useful for some specific * paradigm. Most apps do not need to use this directly; SDL's internal event * code will handle all this for windows created by SDL_CreateWindow! * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC void SDLCALL SDL_OnApplicationDidEnterBackground(void); /** * Let iOS apps with external event handling report * onApplicationWillEnterForeground. * * This functions allows iOS apps that have their own event handling to hook * into SDL to generate SDL events. This maps directly to an iOS-specific * event, but since it doesn't do anything iOS-specific internally, it is * available on all platforms, in case it might be useful for some specific * paradigm. Most apps do not need to use this directly; SDL's internal event * code will handle all this for windows created by SDL_CreateWindow! * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC void SDLCALL SDL_OnApplicationWillEnterForeground(void); /** * Let iOS apps with external event handling report * onApplicationDidBecomeActive. * * This functions allows iOS apps that have their own event handling to hook * into SDL to generate SDL events. This maps directly to an iOS-specific * event, but since it doesn't do anything iOS-specific internally, it is * available on all platforms, in case it might be useful for some specific * paradigm. Most apps do not need to use this directly; SDL's internal event * code will handle all this for windows created by SDL_CreateWindow! * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC void SDLCALL SDL_OnApplicationDidEnterForeground(void); #ifdef SDL_PLATFORM_IOS /** * Let iOS apps with external event handling report * onApplicationDidChangeStatusBarOrientation. * * This functions allows iOS apps that have their own event handling to hook * into SDL to generate SDL events. This maps directly to an iOS-specific * event, but since it doesn't do anything iOS-specific internally, it is * available on all platforms, in case it might be useful for some specific * paradigm. Most apps do not need to use this directly; SDL's internal event * code will handle all this for windows created by SDL_CreateWindow! * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC void SDLCALL SDL_OnApplicationDidChangeStatusBarOrientation(void); #endif /* * Functions used only by GDK */ #ifdef SDL_PLATFORM_GDK typedef struct XTaskQueueObject *XTaskQueueHandle; typedef struct XUser *XUserHandle; /** * Gets a reference to the global async task queue handle for GDK, * initializing if needed. * * Once you are done with the task queue, you should call * XTaskQueueCloseHandle to reduce the reference count to avoid a resource * leak. * * \param outTaskQueue a pointer to be filled in with task queue handle. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC bool SDLCALL SDL_GetGDKTaskQueue(XTaskQueueHandle *outTaskQueue); /** * Gets a reference to the default user handle for GDK. * * This is effectively a synchronous version of XUserAddAsync, which always * prefers the default user and allows a sign-in UI. * * \param outUserHandle a pointer to be filled in with the default user * handle. * \returns true if success or false on failure; call SDL_GetError() for more * information. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC bool SDLCALL SDL_GetGDKDefaultUser(XUserHandle *outUserHandle); #endif /* Ends C function definitions when using C++ */ #ifdef __cplusplus } #endif #include #endif /* SDL_system_h_ */ ================================================ FILE: deps/include/SDL3/SDL_test.h ================================================ /* Simple DirectMedia Layer Copyright (C) 1997-2026 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ /** * Include file for SDL test framework. * * This code is a part of the SDL test library, not the main SDL library. */ #ifndef SDL_test_h_ #define SDL_test_h_ #include #include #include #include #include #include #include #include #include #include #include #include /* Set up for C function definitions, even when using C++ */ #ifdef __cplusplus extern "C" { #endif /* Global definitions */ /* * Note: Maximum size of SDLTest log message is less than SDL's limit * to ensure we can fit additional information such as the timestamp. */ #define SDLTEST_MAX_LOGMESSAGE_LENGTH 3584 /* Ends C function definitions when using C++ */ #ifdef __cplusplus } #endif #include #endif /* SDL_test_h_ */ ================================================ FILE: deps/include/SDL3/SDL_test_assert.h ================================================ /* Simple DirectMedia Layer Copyright (C) 1997-2026 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ /** * Assertion functions of SDL test framework. * * This code is a part of the SDL test library, not the main SDL library. */ /* * * Assert API for test code and test cases * */ #ifndef SDL_test_assert_h_ #define SDL_test_assert_h_ #include #include /* Set up for C function definitions, even when using C++ */ #ifdef __cplusplus extern "C" { #endif /* Fails the assert. */ #define ASSERT_FAIL 0 /* Passes the assert. */ #define ASSERT_PASS 1 /* * Assert that logs and break execution flow on failures. * * \param assertCondition Evaluated condition or variable to assert; fail (==0) or pass (!=0). * \param assertDescription Message to log with the assert describing it. */ void SDLCALL SDLTest_Assert(int assertCondition, SDL_PRINTF_FORMAT_STRING const char *assertDescription, ...) SDL_PRINTF_VARARG_FUNC(2); /* * Assert for test cases that logs but does not break execution flow on failures. Updates assertion counters. * * \param assertCondition Evaluated condition or variable to assert; fail (==0) or pass (!=0). * \param assertDescription Message to log with the assert describing it. * * \returns the assertCondition so it can be used to externally to break execution flow if desired. */ int SDLCALL SDLTest_AssertCheck(int assertCondition, SDL_PRINTF_FORMAT_STRING const char *assertDescription, ...) SDL_PRINTF_VARARG_FUNC(2); /* * Explicitly pass without checking an assertion condition. Updates assertion counter. * * \param assertDescription Message to log with the assert describing it. */ void SDLCALL SDLTest_AssertPass(SDL_PRINTF_FORMAT_STRING const char *assertDescription, ...) SDL_PRINTF_VARARG_FUNC(1); /* * Resets the assert summary counters to zero. */ void SDLCALL SDLTest_ResetAssertSummary(void); /* * Logs summary of all assertions (total, pass, fail) since last reset as INFO or ERROR. */ void SDLCALL SDLTest_LogAssertSummary(void); /* * Converts the current assert summary state to a test result. * * \returns TEST_RESULT_PASSED, TEST_RESULT_FAILED, or TEST_RESULT_NO_ASSERT */ int SDLCALL SDLTest_AssertSummaryToTestResult(void); #ifdef __cplusplus } #endif #include #endif /* SDL_test_assert_h_ */ ================================================ FILE: deps/include/SDL3/SDL_test_common.h ================================================ /* Simple DirectMedia Layer Copyright (C) 1997-2026 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ /** * Common functions of SDL test framework. * * This code is a part of the SDL test library, not the main SDL library. */ /* Ported from original test/common.h file. */ #ifndef SDL_test_common_h_ #define SDL_test_common_h_ #include #ifdef SDL_PLATFORM_PSP #define DEFAULT_WINDOW_WIDTH 480 #define DEFAULT_WINDOW_HEIGHT 272 #elif defined(SDL_PLATFORM_VITA) #define DEFAULT_WINDOW_WIDTH 960 #define DEFAULT_WINDOW_HEIGHT 544 #else #define DEFAULT_WINDOW_WIDTH 640 #define DEFAULT_WINDOW_HEIGHT 480 #endif typedef Uint32 SDLTest_VerboseFlags; #define VERBOSE_VIDEO 0x00000001 #define VERBOSE_MODES 0x00000002 #define VERBOSE_RENDER 0x00000004 #define VERBOSE_EVENT 0x00000008 #define VERBOSE_AUDIO 0x00000010 #define VERBOSE_MOTION 0x00000020 /* !< Function pointer parsing one argument at argv[index], returning the number of parsed arguments, * or a negative value when the argument is invalid */ typedef int (SDLCALL *SDLTest_ParseArgumentsFp)(void *data, char **argv, int index); /* !< Finalize the argument parser. */ typedef void (SDLCALL *SDLTest_FinalizeArgumentParserFp)(void *arg); typedef struct SDLTest_ArgumentParser { /* !< Parse an argument. */ SDLTest_ParseArgumentsFp parse_arguments; /* !< Finalize this argument parser. Called once before parsing the first argument. */ SDLTest_FinalizeArgumentParserFp finalize; /* !< Null-terminated array of arguments. Printed when running with --help. */ const char **usage; /* !< User data, passed to all callbacks. */ void *data; /* !< Next argument parser. */ struct SDLTest_ArgumentParser *next; } SDLTest_ArgumentParser; typedef struct { /* SDL init flags */ char **argv; SDL_InitFlags flags; SDLTest_VerboseFlags verbose; /* Video info */ const char *videodriver; int display_index; SDL_DisplayID displayID; const char *window_title; const char *window_icon; SDL_WindowFlags window_flags; bool flash_on_focus_loss; int window_x; int window_y; int window_w; int window_h; int window_minW; int window_minH; int window_maxW; int window_maxH; float window_min_aspect; float window_max_aspect; int logical_w; int logical_h; bool auto_scale_content; SDL_RendererLogicalPresentation logical_presentation; float scale; int depth; float refresh_rate; bool fill_usable_bounds; bool fullscreen_exclusive; SDL_DisplayMode fullscreen_mode; int num_windows; SDL_Window **windows; const char *gpudriver; /* Renderer info */ const char *renderdriver; int render_vsync; bool skip_renderer; SDL_Renderer **renderers; SDL_Texture **targets; /* Audio info */ const char *audiodriver; SDL_AudioFormat audio_format; int audio_channels; int audio_freq; SDL_AudioDeviceID audio_id; /* GL settings */ int gl_red_size; int gl_green_size; int gl_blue_size; int gl_alpha_size; int gl_buffer_size; int gl_depth_size; int gl_stencil_size; int gl_double_buffer; int gl_accum_red_size; int gl_accum_green_size; int gl_accum_blue_size; int gl_accum_alpha_size; int gl_stereo; int gl_release_behavior; int gl_multisamplebuffers; int gl_multisamplesamples; int gl_retained_backing; int gl_accelerated; int gl_major_version; int gl_minor_version; int gl_debug; int gl_profile_mask; /* Mouse info */ SDL_Rect confine; bool hide_cursor; /* Misc. */ int quit_after_ms_interval; SDL_TimerID quit_after_ms_timer; /* Options info */ SDLTest_ArgumentParser common_argparser; SDLTest_ArgumentParser video_argparser; SDLTest_ArgumentParser audio_argparser; SDLTest_ArgumentParser *argparser; } SDLTest_CommonState; #include /* Set up for C function definitions, even when using C++ */ #ifdef __cplusplus extern "C" { #endif /* Function prototypes */ /** * Parse command line parameters and create common state. * * \param argv Array of command line parameters * \param flags Flags indicating which subsystem to initialize (i.e. SDL_INIT_VIDEO | SDL_INIT_AUDIO) * * \returns a newly allocated common state object. */ SDLTest_CommonState * SDLCALL SDLTest_CommonCreateState(char **argv, SDL_InitFlags flags); /** * Free the common state object. * * You should call SDL_Quit() before calling this function. * * \param state The common state object to destroy */ void SDLCALL SDLTest_CommonDestroyState(SDLTest_CommonState *state); /** * Process one common argument. * * \param state The common state describing the test window to create. * \param index The index of the argument to process in argv[]. * * \returns the number of arguments processed (i.e. 1 for --fullscreen, 2 for --video [videodriver], or -1 on error. */ int SDLCALL SDLTest_CommonArg(SDLTest_CommonState *state, int index); /** * Logs command line usage info. * * This logs the appropriate command line options for the subsystems in use * plus other common options, and then any application-specific options. * This uses the SDL_Log() function and splits up output to be friendly to * 80-character-wide terminals. * * \param state The common state describing the test window for the app. * \param argv0 argv[0], as passed to main/SDL_main. * \param options an array of strings for application specific options. The last element of the array should be NULL. */ void SDLCALL SDLTest_CommonLogUsage(SDLTest_CommonState *state, const char *argv0, const char **options); /** * Open test window. * * \param state The common state describing the test window to create. * * \returns true if initialization succeeded, false otherwise */ bool SDLCALL SDLTest_CommonInit(SDLTest_CommonState *state); /** * Easy argument handling when test app doesn't need any custom args. * * \param state The common state describing the test window to create. * \param argc argc, as supplied to SDL_main * \param argv argv, as supplied to SDL_main * * \returns false if app should quit, true otherwise. */ bool SDLCALL SDLTest_CommonDefaultArgs(SDLTest_CommonState *state, int argc, char **argv); /** * Print the details of an event. * * This is automatically called by SDLTest_CommonEvent() as needed. * * \param event The event to print. */ void SDLCALL SDLTest_PrintEvent(const SDL_Event *event); /** * Common event handler for test windows if you use a standard SDL_main. * * \param state The common state used to create test window. * \param event The event to handle. * \param done Flag indicating we are done. */ void SDLCALL SDLTest_CommonEvent(SDLTest_CommonState *state, SDL_Event *event, int *done); /** * Common event handler for test windows if you use SDL_AppEvent. * * This does _not_ free anything in `event`. * * \param state The common state used to create test window. * \param event The event to handle. * \returns Value suitable for returning from SDL_AppEvent(). */ SDL_AppResult SDLCALL SDLTest_CommonEventMainCallbacks(SDLTest_CommonState *state, const SDL_Event *event); /** * Close test window. * * \param state The common state used to create test window. * */ void SDLCALL SDLTest_CommonQuit(SDLTest_CommonState *state); /** * Draws various window information (position, size, etc.) to the renderer. * * \param renderer The renderer to draw to. * \param window The window whose information should be displayed. * \param usedHeight Returns the height used, so the caller can draw more below. * */ void SDLCALL SDLTest_CommonDrawWindowInfo(SDL_Renderer *renderer, SDL_Window *window, float *usedHeight); /* Ends C function definitions when using C++ */ #ifdef __cplusplus } #endif #include #endif /* SDL_test_common_h_ */ ================================================ FILE: deps/include/SDL3/SDL_test_compare.h ================================================ /* Simple DirectMedia Layer Copyright (C) 1997-2026 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ /** * Comparison function of SDL test framework. * * This code is a part of the SDL test library, not the main SDL library. */ /* Defines comparison functions (i.e. for surfaces). */ #ifndef SDL_test_compare_h_ #define SDL_test_compare_h_ #include #include /* Set up for C function definitions, even when using C++ */ #ifdef __cplusplus extern "C" { #endif /** * Compares a surface and with reference image data for equality * * \param surface Surface used in comparison * \param referenceSurface Test Surface used in comparison * \param allowable_error Allowable difference (=sum of squared difference for each RGB component) in blending accuracy. * * \returns 0 if comparison succeeded, >0 (=number of pixels for which the comparison failed) if comparison failed, -1 if any of the surfaces were NULL, -2 if the surface sizes differ. */ int SDLCALL SDLTest_CompareSurfaces(SDL_Surface *surface, SDL_Surface *referenceSurface, int allowable_error); int SDLCALL SDLTest_CompareSurfacesIgnoreTransparentPixels(SDL_Surface *surface, SDL_Surface *referenceSurface, int allowable_error); /** * Compares 2 memory blocks for equality * * \param actual Memory used in comparison, displayed on the left * \param size_actual Size of actual in bytes * \param reference Reference memory, displayed on the right * \param size_reference Size of reference in bytes * * \returns 0 if the left and right memory block are equal, non-zero if they are non-equal. * * \since This function is available since SDL 3.2.0. */ int SDLCALL SDLTest_CompareMemory(const void *actual, size_t size_actual, const void *reference, size_t size_reference); /* Ends C function definitions when using C++ */ #ifdef __cplusplus } #endif #include #endif /* SDL_test_compare_h_ */ ================================================ FILE: deps/include/SDL3/SDL_test_crc32.h ================================================ /* Simple DirectMedia Layer Copyright (C) 1997-2026 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ /** * CRC32 functions of SDL test framework. * * This code is a part of the SDL test library, not the main SDL library. */ /* Implements CRC32 calculations (default output is Perl String::CRC32 compatible). */ #ifndef SDL_test_crc32_h_ #define SDL_test_crc32_h_ #include #include /* Set up for C function definitions, even when using C++ */ #ifdef __cplusplus extern "C" { #endif /* ------------ Definitions --------- */ /* Definition shared by all CRC routines */ #ifndef CrcUint32 #define CrcUint32 unsigned int #endif #ifndef CrcUint8 #define CrcUint8 unsigned char #endif #ifdef ORIGINAL_METHOD #define CRC32_POLY 0x04c11db7 /* AUTODIN II, Ethernet, & FDDI */ #else #define CRC32_POLY 0xEDB88320 /* Perl String::CRC32 compatible */ #endif /* * Data structure for CRC32 (checksum) computation */ typedef struct SDLTest_Crc32Context { CrcUint32 crc32_table[256]; /* CRC table */ } SDLTest_Crc32Context; /* ---------- Function Prototypes ------------- */ /* * Initialize the CRC context * * Note: The function initializes the crc table required for all crc calculations. * * \param crcContext pointer to context variable * * \returns true on success or false on failure; call SDL_GetError() * for more information. * */ bool SDLCALL SDLTest_Crc32Init(SDLTest_Crc32Context *crcContext); /* * calculate a crc32 from a data block * * \param crcContext pointer to context variable * \param inBuf input buffer to checksum * \param inLen length of input buffer * \param crc32 pointer to Uint32 to store the final CRC into * * \returns true on success or false on failure; call SDL_GetError() * for more information. * */ bool SDLCALL SDLTest_Crc32Calc(SDLTest_Crc32Context *crcContext, CrcUint8 *inBuf, CrcUint32 inLen, CrcUint32 *crc32); /* Same routine broken down into three steps */ bool SDLCALL SDLTest_Crc32CalcStart(SDLTest_Crc32Context *crcContext, CrcUint32 *crc32); bool SDLCALL SDLTest_Crc32CalcEnd(SDLTest_Crc32Context *crcContext, CrcUint32 *crc32); bool SDLCALL SDLTest_Crc32CalcBuffer(SDLTest_Crc32Context *crcContext, CrcUint8 *inBuf, CrcUint32 inLen, CrcUint32 *crc32); /* * clean up CRC context * * \param crcContext pointer to context variable * * \returns true on success or false on failure; call SDL_GetError() * for more information. * */ bool SDLCALL SDLTest_Crc32Done(SDLTest_Crc32Context *crcContext); /* Ends C function definitions when using C++ */ #ifdef __cplusplus } #endif #include #endif /* SDL_test_crc32_h_ */ ================================================ FILE: deps/include/SDL3/SDL_test_font.h ================================================ /* Simple DirectMedia Layer Copyright (C) 1997-2026 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ /* * Font related functions of SDL test framework. * * This code is a part of the SDL test library, not the main SDL library. */ #ifndef SDL_test_font_h_ #define SDL_test_font_h_ #include #include #include #include /* Set up for C function definitions, even when using C++ */ #ifdef __cplusplus extern "C" { #endif /* Function prototypes */ extern int FONT_CHARACTER_SIZE; #define FONT_LINE_HEIGHT (FONT_CHARACTER_SIZE + 2) /* * Draw a string in the currently set font. * * \param renderer The renderer to draw on. * \param x The X coordinate of the upper left corner of the character. * \param y The Y coordinate of the upper left corner of the character. * \param c The character to draw. * * \returns true on success, false on failure. */ bool SDLCALL SDLTest_DrawCharacter(SDL_Renderer *renderer, float x, float y, Uint32 c); /* * Draw a UTF-8 string in the currently set font. * * The font currently only supports characters in the Basic Latin and Latin-1 Supplement sets. * * \param renderer The renderer to draw on. * \param x The X coordinate of the upper left corner of the string. * \param y The Y coordinate of the upper left corner of the string. * \param s The string to draw. * * \returns true on success, false on failure. */ bool SDLCALL SDLTest_DrawString(SDL_Renderer *renderer, float x, float y, const char *s); /* * Data used for multi-line text output */ typedef struct SDLTest_TextWindow { SDL_FRect rect; int current; int numlines; char **lines; } SDLTest_TextWindow; /* * Create a multi-line text output window * * \param x The X coordinate of the upper left corner of the window. * \param y The Y coordinate of the upper left corner of the window. * \param w The width of the window (currently ignored) * \param h The height of the window (currently ignored) * * \returns the new window, or NULL on failure. * * \since This function is available since SDL 3.2.0. */ SDLTest_TextWindow * SDLCALL SDLTest_TextWindowCreate(float x, float y, float w, float h); /* * Display a multi-line text output window * * This function should be called every frame to display the text * * \param textwin The text output window * \param renderer The renderer to use for display * * \since This function is available since SDL 3.2.0. */ void SDLCALL SDLTest_TextWindowDisplay(SDLTest_TextWindow *textwin, SDL_Renderer *renderer); /* * Add text to a multi-line text output window * * Adds UTF-8 text to the end of the current text. The newline character starts a * new line of text. The backspace character deletes the last character or, if the * line is empty, deletes the line and goes to the end of the previous line. * * \param textwin The text output window * \param fmt A printf() style format string * \param ... additional parameters matching % tokens in the `fmt` string, if any * * \since This function is available since SDL 3.2.0. */ void SDLCALL SDLTest_TextWindowAddText(SDLTest_TextWindow *textwin, SDL_PRINTF_FORMAT_STRING const char *fmt, ...) SDL_PRINTF_VARARG_FUNC(2); /* * Add text to a multi-line text output window * * Adds UTF-8 text to the end of the current text. The newline character starts a * new line of text. The backspace character deletes the last character or, if the * line is empty, deletes the line and goes to the end of the previous line. * * \param textwin The text output window * \param text The text to add to the window * \param len The length, in bytes, of the text to add to the window * * \since This function is available since SDL 3.2.0. */ void SDLCALL SDLTest_TextWindowAddTextWithLength(SDLTest_TextWindow *textwin, const char *text, size_t len); /* * Clear the text in a multi-line text output window * * \param textwin The text output window * * \since This function is available since SDL 3.2.0. */ void SDLCALL SDLTest_TextWindowClear(SDLTest_TextWindow *textwin); /* * Free the storage associated with a multi-line text output window * * \param textwin The text output window * * \since This function is available since SDL 3.2.0. */ void SDLCALL SDLTest_TextWindowDestroy(SDLTest_TextWindow *textwin); /* * Cleanup textures used by font drawing functions. */ void SDLCALL SDLTest_CleanupTextDrawing(void); /* Ends C function definitions when using C++ */ #ifdef __cplusplus } #endif #include #endif /* SDL_test_font_h_ */ ================================================ FILE: deps/include/SDL3/SDL_test_fuzzer.h ================================================ /* Simple DirectMedia Layer Copyright (C) 1997-2026 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ /** * Fuzzer functions of SDL test framework. * * This code is a part of the SDL test library, not the main SDL library. */ /* Data generators for fuzzing test data in a reproducible way. */ #ifndef SDL_test_fuzzer_h_ #define SDL_test_fuzzer_h_ #include #include /* Set up for C function definitions, even when using C++ */ #ifdef __cplusplus extern "C" { #endif /* Based on GSOC code by Markus Kauppila */ /** * Note: The fuzzer implementation uses a static instance of random context * internally which makes it thread-UNsafe. */ /** * Initializes the fuzzer for a test * * \param execKey Execution "Key" that initializes the random number generator uniquely for the test. * */ void SDLCALL SDLTest_FuzzerInit(Uint64 execKey); /** * Returns a random Uint8 * * \returns a generated integer */ Uint8 SDLCALL SDLTest_RandomUint8(void); /** * Returns a random Sint8 * * \returns a generated signed integer */ Sint8 SDLCALL SDLTest_RandomSint8(void); /** * Returns a random Uint16 * * \returns a generated integer */ Uint16 SDLCALL SDLTest_RandomUint16(void); /** * Returns a random Sint16 * * \returns a generated signed integer */ Sint16 SDLCALL SDLTest_RandomSint16(void); /** * Returns a random integer * * \returns a generated integer */ Sint32 SDLCALL SDLTest_RandomSint32(void); /** * Returns a random positive integer * * \returns a generated integer */ Uint32 SDLCALL SDLTest_RandomUint32(void); /** * Returns random Uint64. * * \returns a generated integer */ Uint64 SDLTest_RandomUint64(void); /** * Returns random Sint64. * * \returns a generated signed integer */ Sint64 SDLCALL SDLTest_RandomSint64(void); /** * \returns a random float in range [0.0 - 1.0] */ float SDLCALL SDLTest_RandomUnitFloat(void); /** * \returns a random double in range [0.0 - 1.0] */ double SDLCALL SDLTest_RandomUnitDouble(void); /** * \returns a random float. * */ float SDLCALL SDLTest_RandomFloat(void); /** * \returns a random double. * */ double SDLCALL SDLTest_RandomDouble(void); /** * Returns a random boundary value for Uint8 within the given boundaries. * Boundaries are inclusive, see the usage examples below. If validDomain * is true, the function will only return valid boundaries, otherwise non-valid * boundaries are also possible. * If boundary1 > boundary2, the values are swapped * * Usage examples: * RandomUint8BoundaryValue(10, 20, true) returns 10, 11, 19 or 20 * RandomUint8BoundaryValue(1, 20, false) returns 0 or 21 * RandomUint8BoundaryValue(0, 99, false) returns 100 * RandomUint8BoundaryValue(0, 255, false) returns 0 (error set) * * \param boundary1 Lower boundary limit * \param boundary2 Upper boundary limit * \param validDomain Should the generated boundary be valid (=within the bounds) or not? * * \returns a random boundary value for the given range and domain or 0 with error set */ Uint8 SDLCALL SDLTest_RandomUint8BoundaryValue(Uint8 boundary1, Uint8 boundary2, bool validDomain); /** * Returns a random boundary value for Uint16 within the given boundaries. * Boundaries are inclusive, see the usage examples below. If validDomain * is true, the function will only return valid boundaries, otherwise non-valid * boundaries are also possible. * If boundary1 > boundary2, the values are swapped * * Usage examples: * RandomUint16BoundaryValue(10, 20, true) returns 10, 11, 19 or 20 * RandomUint16BoundaryValue(1, 20, false) returns 0 or 21 * RandomUint16BoundaryValue(0, 99, false) returns 100 * RandomUint16BoundaryValue(0, 0xFFFF, false) returns 0 (error set) * * \param boundary1 Lower boundary limit * \param boundary2 Upper boundary limit * \param validDomain Should the generated boundary be valid (=within the bounds) or not? * * \returns a random boundary value for the given range and domain or 0 with error set */ Uint16 SDLCALL SDLTest_RandomUint16BoundaryValue(Uint16 boundary1, Uint16 boundary2, bool validDomain); /** * Returns a random boundary value for Uint32 within the given boundaries. * Boundaries are inclusive, see the usage examples below. If validDomain * is true, the function will only return valid boundaries, otherwise non-valid * boundaries are also possible. * If boundary1 > boundary2, the values are swapped * * Usage examples: * RandomUint32BoundaryValue(10, 20, true) returns 10, 11, 19 or 20 * RandomUint32BoundaryValue(1, 20, false) returns 0 or 21 * RandomUint32BoundaryValue(0, 99, false) returns 100 * RandomUint32BoundaryValue(0, 0xFFFFFFFF, false) returns 0 (with error set) * * \param boundary1 Lower boundary limit * \param boundary2 Upper boundary limit * \param validDomain Should the generated boundary be valid (=within the bounds) or not? * * \returns a random boundary value for the given range and domain or 0 with error set */ Uint32 SDLCALL SDLTest_RandomUint32BoundaryValue(Uint32 boundary1, Uint32 boundary2, bool validDomain); /** * Returns a random boundary value for Uint64 within the given boundaries. * Boundaries are inclusive, see the usage examples below. If validDomain * is true, the function will only return valid boundaries, otherwise non-valid * boundaries are also possible. * If boundary1 > boundary2, the values are swapped * * Usage examples: * RandomUint64BoundaryValue(10, 20, true) returns 10, 11, 19 or 20 * RandomUint64BoundaryValue(1, 20, false) returns 0 or 21 * RandomUint64BoundaryValue(0, 99, false) returns 100 * RandomUint64BoundaryValue(0, 0xFFFFFFFFFFFFFFFF, false) returns 0 (with error set) * * \param boundary1 Lower boundary limit * \param boundary2 Upper boundary limit * \param validDomain Should the generated boundary be valid (=within the bounds) or not? * * \returns a random boundary value for the given range and domain or 0 with error set */ Uint64 SDLCALL SDLTest_RandomUint64BoundaryValue(Uint64 boundary1, Uint64 boundary2, bool validDomain); /** * Returns a random boundary value for Sint8 within the given boundaries. * Boundaries are inclusive, see the usage examples below. If validDomain * is true, the function will only return valid boundaries, otherwise non-valid * boundaries are also possible. * If boundary1 > boundary2, the values are swapped * * Usage examples: * RandomSint8BoundaryValue(-10, 20, true) returns -11, -10, 19 or 20 * RandomSint8BoundaryValue(-100, -10, false) returns -101 or -9 * RandomSint8BoundaryValue(SINT8_MIN, 99, false) returns 100 * RandomSint8BoundaryValue(SINT8_MIN, SINT8_MAX, false) returns SINT8_MIN (== error value) with error set * * \param boundary1 Lower boundary limit * \param boundary2 Upper boundary limit * \param validDomain Should the generated boundary be valid (=within the bounds) or not? * * \returns a random boundary value for the given range and domain or SINT8_MIN with error set */ Sint8 SDLCALL SDLTest_RandomSint8BoundaryValue(Sint8 boundary1, Sint8 boundary2, bool validDomain); /** * Returns a random boundary value for Sint16 within the given boundaries. * Boundaries are inclusive, see the usage examples below. If validDomain * is true, the function will only return valid boundaries, otherwise non-valid * boundaries are also possible. * If boundary1 > boundary2, the values are swapped * * Usage examples: * RandomSint16BoundaryValue(-10, 20, true) returns -11, -10, 19 or 20 * RandomSint16BoundaryValue(-100, -10, false) returns -101 or -9 * RandomSint16BoundaryValue(SINT16_MIN, 99, false) returns 100 * RandomSint16BoundaryValue(SINT16_MIN, SINT16_MAX, false) returns SINT16_MIN (== error value) with error set * * \param boundary1 Lower boundary limit * \param boundary2 Upper boundary limit * \param validDomain Should the generated boundary be valid (=within the bounds) or not? * * \returns a random boundary value for the given range and domain or SINT16_MIN with error set */ Sint16 SDLCALL SDLTest_RandomSint16BoundaryValue(Sint16 boundary1, Sint16 boundary2, bool validDomain); /** * Returns a random boundary value for Sint32 within the given boundaries. * Boundaries are inclusive, see the usage examples below. If validDomain * is true, the function will only return valid boundaries, otherwise non-valid * boundaries are also possible. * If boundary1 > boundary2, the values are swapped * * Usage examples: * RandomSint32BoundaryValue(-10, 20, true) returns -11, -10, 19 or 20 * RandomSint32BoundaryValue(-100, -10, false) returns -101 or -9 * RandomSint32BoundaryValue(SINT32_MIN, 99, false) returns 100 * RandomSint32BoundaryValue(SINT32_MIN, SINT32_MAX, false) returns SINT32_MIN (== error value) * * \param boundary1 Lower boundary limit * \param boundary2 Upper boundary limit * \param validDomain Should the generated boundary be valid (=within the bounds) or not? * * \returns a random boundary value for the given range and domain or SINT32_MIN with error set */ Sint32 SDLCALL SDLTest_RandomSint32BoundaryValue(Sint32 boundary1, Sint32 boundary2, bool validDomain); /** * Returns a random boundary value for Sint64 within the given boundaries. * Boundaries are inclusive, see the usage examples below. If validDomain * is true, the function will only return valid boundaries, otherwise non-valid * boundaries are also possible. * If boundary1 > boundary2, the values are swapped * * Usage examples: * RandomSint64BoundaryValue(-10, 20, true) returns -11, -10, 19 or 20 * RandomSint64BoundaryValue(-100, -10, false) returns -101 or -9 * RandomSint64BoundaryValue(SINT64_MIN, 99, false) returns 100 * RandomSint64BoundaryValue(SINT64_MIN, SINT64_MAX, false) returns SINT64_MIN (== error value) and error set * * \param boundary1 Lower boundary limit * \param boundary2 Upper boundary limit * \param validDomain Should the generated boundary be valid (=within the bounds) or not? * * \returns a random boundary value for the given range and domain or SINT64_MIN with error set */ Sint64 SDLCALL SDLTest_RandomSint64BoundaryValue(Sint64 boundary1, Sint64 boundary2, bool validDomain); /** * Returns integer in range [min, max] (inclusive). * Min and max values can be negative values. * If Max in smaller than min, then the values are swapped. * Min and max are the same value, that value will be returned. * * \param min Minimum inclusive value of returned random number * \param max Maximum inclusive value of returned random number * * \returns a generated random integer in range */ Sint32 SDLCALL SDLTest_RandomIntegerInRange(Sint32 min, Sint32 max); /** * Generates random null-terminated string. The minimum length for * the string is 1 character, maximum length for the string is 255 * characters and it can contain ASCII characters from 32 to 126. * * Note: Returned string needs to be deallocated. * * \returns a newly allocated random string; or NULL if length was invalid or string could not be allocated. */ char * SDLCALL SDLTest_RandomAsciiString(void); /** * Generates random null-terminated string. The maximum length for * the string is defined by the maxLength parameter. * String can contain ASCII characters from 32 to 126. * * Note: Returned string needs to be deallocated. * * \param maxLength The maximum length of the generated string. * * \returns a newly allocated random string; or NULL if maxLength was invalid or string could not be allocated. */ char * SDLCALL SDLTest_RandomAsciiStringWithMaximumLength(int maxLength); /** * Generates random null-terminated string. The length for * the string is defined by the size parameter. * String can contain ASCII characters from 32 to 126. * * Note: Returned string needs to be deallocated. * * \param size The length of the generated string * * \returns a newly allocated random string; or NULL if size was invalid or string could not be allocated. */ char * SDLCALL SDLTest_RandomAsciiStringOfSize(int size); /** * Get the invocation count for the fuzzer since last ...FuzzerInit. * * \returns the invocation count. */ int SDLCALL SDLTest_GetFuzzerInvocationCount(void); /* Ends C function definitions when using C++ */ #ifdef __cplusplus } #endif #include #endif /* SDL_test_fuzzer_h_ */ ================================================ FILE: deps/include/SDL3/SDL_test_harness.h ================================================ /* Simple DirectMedia Layer Copyright (C) 1997-2026 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ /** * Test suite related functions of SDL test framework. * * This code is a part of the SDL test library, not the main SDL library. */ /* Defines types for test case definitions and the test execution harness API. Based on original GSOC code by Markus Kauppila */ #ifndef SDL_test_h_arness_h #define SDL_test_h_arness_h #include #include /* SDLTest_CommonState */ #include /* Set up for C function definitions, even when using C++ */ #ifdef __cplusplus extern "C" { #endif /* ! Definitions for test case structures */ #define TEST_ENABLED 1 #define TEST_DISABLED 0 /* ! Definition of all the possible test return values of the test case method */ #define TEST_ABORTED -1 #define TEST_STARTED 0 #define TEST_COMPLETED 1 #define TEST_SKIPPED 2 /* ! Definition of all the possible test results for the harness */ #define TEST_RESULT_PASSED 0 #define TEST_RESULT_FAILED 1 #define TEST_RESULT_NO_ASSERT 2 #define TEST_RESULT_SKIPPED 3 #define TEST_RESULT_SETUP_FAILURE 4 /* !< Function pointer to a test case setup function (run before every test) */ typedef void (SDLCALL *SDLTest_TestCaseSetUpFp)(void **arg); /* !< Function pointer to a test case function */ typedef int (SDLCALL *SDLTest_TestCaseFp)(void *arg); /* !< Function pointer to a test case teardown function (run after every test) */ typedef void (SDLCALL *SDLTest_TestCaseTearDownFp)(void *arg); /* * Holds information about a single test case. */ typedef struct SDLTest_TestCaseReference { /* !< Func2Stress */ SDLTest_TestCaseFp testCase; /* !< Short name (or function name) "Func2Stress" */ const char *name; /* !< Long name or full description "This test pushes func2() to the limit." */ const char *description; /* !< Set to TEST_ENABLED or TEST_DISABLED (test won't be run) */ int enabled; } SDLTest_TestCaseReference; /* * Holds information about a test suite (multiple test cases). */ typedef struct SDLTest_TestSuiteReference { /* !< "PlatformSuite" */ const char *name; /* !< The function that is run before each test. NULL skips. */ SDLTest_TestCaseSetUpFp testSetUp; /* !< The test cases that are run as part of the suite. Last item should be NULL. */ const SDLTest_TestCaseReference **testCases; /* !< The function that is run after each test. NULL skips. */ SDLTest_TestCaseTearDownFp testTearDown; } SDLTest_TestSuiteReference; /* * Generates a random run seed string for the harness. The generated seed * will contain alphanumeric characters (0-9A-Z). * * \param buffer Buffer in which to generate the random seed. Must have a capacity of at least length + 1 characters. * \param length Number of alphanumeric characters to write to buffer, must be >0 * * \returns A null-terminated seed string and equal to the in put buffer on success, NULL on failure */ char * SDLCALL SDLTest_GenerateRunSeed(char *buffer, int length); /* * Holds information about the execution of test suites. * */ typedef struct SDLTest_TestSuiteRunner SDLTest_TestSuiteRunner; /* * Create a new test suite runner, that will execute the given test suites. * It will register the harness cli arguments to the common SDL state. * * \param state Common SDL state on which to register CLI arguments. * \param testSuites NULL-terminated test suites containing test cases. * * \returns the test run result: 0 when all tests passed, 1 if any tests failed. */ SDLTest_TestSuiteRunner * SDLCALL SDLTest_CreateTestSuiteRunner(SDLTest_CommonState *state, SDLTest_TestSuiteReference *testSuites[]); /* * Destroy a test suite runner. * It will unregister the harness cli arguments to the common SDL state. * * \param runner The runner that should be destroyed. */ void SDLCALL SDLTest_DestroyTestSuiteRunner(SDLTest_TestSuiteRunner *runner); /* * Execute a test suite, using the configured run seed, execution key, filter, etc. * * \param runner The runner that should be executed. * * \returns the test run result: 0 when all tests passed, 1 if any tests failed. */ int SDLCALL SDLTest_ExecuteTestSuiteRunner(SDLTest_TestSuiteRunner *runner); /* Ends C function definitions when using C++ */ #ifdef __cplusplus } #endif #include #endif /* SDL_test_h_arness_h */ ================================================ FILE: deps/include/SDL3/SDL_test_log.h ================================================ /* Simple DirectMedia Layer Copyright (C) 1997-2026 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ /** * Logging related functions of SDL test framework. * * This code is a part of the SDL test library, not the main SDL library. */ /* * * Wrapper to log in the TEST category * */ #ifndef SDL_test_log_h_ #define SDL_test_log_h_ #include #include /* Set up for C function definitions, even when using C++ */ #ifdef __cplusplus extern "C" { #endif /** * Prints given message with a timestamp in the TEST category and given priority. * * \param priority Priority of the message * \param fmt Message to be logged */ void SDLCALL SDLTest_LogMessage(SDL_LogPriority priority, SDL_PRINTF_FORMAT_STRING const char *fmt, ...); /** * Prints given message with a timestamp in the TEST category and INFO priority. * * \param fmt Message to be logged */ void SDLCALL SDLTest_Log(SDL_PRINTF_FORMAT_STRING const char *fmt, ...) SDL_PRINTF_VARARG_FUNC(1); /** * Prints given prefix and buffer. * Non-printible characters in the raw data are substituted by printible alternatives. * * \param prefix Prefix message. * \param buffer Raw data to be escaped. * \param size Number of bytes in buffer. */ void SDLCALL SDLTest_LogEscapedString(const char *prefix, const void *buffer, size_t size); /** * Prints given message with a timestamp in the TEST category and the ERROR priority. * * \param fmt Message to be logged */ void SDLCALL SDLTest_LogError(SDL_PRINTF_FORMAT_STRING const char *fmt, ...) SDL_PRINTF_VARARG_FUNC(1); /* Ends C function definitions when using C++ */ #ifdef __cplusplus } #endif #include #endif /* SDL_test_log_h_ */ ================================================ FILE: deps/include/SDL3/SDL_test_md5.h ================================================ /* Simple DirectMedia Layer Copyright (C) 1997-2026 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ /** * MD5 related functions of SDL test framework. * * This code is a part of the SDL test library, not the main SDL library. */ /* *********************************************************************** ** Header file for implementation of MD5 ** ** RSA Data Security, Inc. MD5 Message-Digest Algorithm ** ** Created: 2/17/90 RLR ** ** Revised: 12/27/90 SRD,AJ,BSK,JT Reference C version ** ** Revised (for MD5): RLR 4/27/91 ** ** -- G modified to have y&~z instead of y&z ** ** -- FF, GG, HH modified to add in last register done ** ** -- Access pattern: round 2 works mod 5, round 3 works mod 3 ** ** -- distinct additive constant for each step ** ** -- round 4 added, working mod 7 ** *********************************************************************** */ /* *********************************************************************** ** Message-digest routines: ** ** To form the message digest for a message M ** ** (1) Initialize a context buffer mdContext using MD5Init ** ** (2) Call MD5Update on mdContext and M ** ** (3) Call MD5Final on mdContext ** ** The message digest is now in mdContext->digest[0...15] ** *********************************************************************** */ #ifndef SDL_test_md5_h_ #define SDL_test_md5_h_ #include #include /* Set up for C function definitions, even when using C++ */ #ifdef __cplusplus extern "C" { #endif /* ------------ Definitions --------- */ /* typedef a 32-bit type */ typedef Uint32 MD5UINT4; /* Data structure for MD5 (Message-Digest) computation */ typedef struct SDLTest_Md5Context { MD5UINT4 i[2]; /* number of _bits_ handled mod 2^64 */ MD5UINT4 buf[4]; /* scratch buffer */ unsigned char in[64]; /* input buffer */ unsigned char digest[16]; /* actual digest after Md5Final call */ } SDLTest_Md5Context; /* ---------- Function Prototypes ------------- */ /** * initialize the context * * \param mdContext pointer to context variable * * Note: The function initializes the message-digest context * mdContext. Call before each new use of the context - * all fields are set to zero. */ void SDLCALL SDLTest_Md5Init(SDLTest_Md5Context *mdContext); /** * update digest from variable length data * * \param mdContext pointer to context variable * \param inBuf pointer to data array/string * \param inLen length of data array/string * * Note: The function updates the message-digest context to account * for the presence of each of the characters inBuf[0..inLen-1] * in the message whose digest is being computed. */ void SDLCALL SDLTest_Md5Update(SDLTest_Md5Context *mdContext, unsigned char *inBuf, unsigned int inLen); /** * complete digest computation * * \param mdContext pointer to context variable * * Note: The function terminates the message-digest computation and * ends with the desired message digest in mdContext.digest[0..15]. * Always call before using the digest[] variable. */ void SDLCALL SDLTest_Md5Final(SDLTest_Md5Context *mdContext); /* Ends C function definitions when using C++ */ #ifdef __cplusplus } #endif #include #endif /* SDL_test_md5_h_ */ ================================================ FILE: deps/include/SDL3/SDL_test_memory.h ================================================ /* Simple DirectMedia Layer Copyright (C) 1997-2026 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ /** * Memory tracking related functions of SDL test framework. * * This code is a part of the SDL test library, not the main SDL library. */ #ifndef SDL_test_memory_h_ #define SDL_test_memory_h_ #include #include /* Set up for C function definitions, even when using C++ */ #ifdef __cplusplus extern "C" { #endif /** * Start tracking SDL memory allocations * * \note This should be called before any other SDL functions for complete tracking coverage */ void SDLCALL SDLTest_TrackAllocations(void); /** * Fill allocations with random data * * \note This implicitly calls SDLTest_TrackAllocations() */ void SDLCALL SDLTest_RandFillAllocations(void); /** * Print a log of any outstanding allocations * * \note This can be called after SDL_Quit() */ void SDLCALL SDLTest_LogAllocations(void); /* Ends C function definitions when using C++ */ #ifdef __cplusplus } #endif #include #endif /* SDL_test_memory_h_ */ ================================================ FILE: deps/include/SDL3/SDL_thread.h ================================================ /* Simple DirectMedia Layer Copyright (C) 1997-2026 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ #ifndef SDL_thread_h_ #define SDL_thread_h_ /** * # CategoryThread * * SDL offers cross-platform thread management functions. These are mostly * concerned with starting threads, setting their priority, and dealing with * their termination. * * In addition, there is support for Thread Local Storage (data that is unique * to each thread, but accessed from a single key). * * On platforms without thread support (such as Emscripten when built without * pthreads), these functions still exist, but things like SDL_CreateThread() * will report failure without doing anything. * * If you're going to work with threads, you almost certainly need to have a * good understanding of thread safety measures: locking and synchronization * mechanisms are handled by the functions in SDL_mutex.h. */ #include #include #include /* Thread synchronization primitives */ #include #if defined(SDL_PLATFORM_WINDOWS) #include /* _beginthreadex() and _endthreadex() */ #endif #include /* Set up for C function definitions, even when using C++ */ #ifdef __cplusplus extern "C" { #endif /** * The SDL thread object. * * These are opaque data. * * \since This datatype is available since SDL 3.2.0. * * \sa SDL_CreateThread * \sa SDL_WaitThread */ typedef struct SDL_Thread SDL_Thread; /** * A unique numeric ID that identifies a thread. * * These are different from SDL_Thread objects, which are generally what an * application will operate on, but having a way to uniquely identify a thread * can be useful at times. * * \since This datatype is available since SDL 3.2.0. * * \sa SDL_GetThreadID * \sa SDL_GetCurrentThreadID */ typedef Uint64 SDL_ThreadID; /** * Thread local storage ID. * * 0 is the invalid ID. An app can create these and then set data for these * IDs that is unique to each thread. * * \since This datatype is available since SDL 3.2.0. * * \sa SDL_GetTLS * \sa SDL_SetTLS */ typedef SDL_AtomicInt SDL_TLSID; /** * The SDL thread priority. * * SDL will make system changes as necessary in order to apply the thread * priority. Code which attempts to control thread state related to priority * should be aware that calling SDL_SetCurrentThreadPriority may alter such * state. SDL_HINT_THREAD_PRIORITY_POLICY can be used to control aspects of * this behavior. * * \since This enum is available since SDL 3.2.0. */ typedef enum SDL_ThreadPriority { SDL_THREAD_PRIORITY_LOW, SDL_THREAD_PRIORITY_NORMAL, SDL_THREAD_PRIORITY_HIGH, SDL_THREAD_PRIORITY_TIME_CRITICAL } SDL_ThreadPriority; /** * The SDL thread state. * * The current state of a thread can be checked by calling SDL_GetThreadState. * * \since This enum is available since SDL 3.2.0. * * \sa SDL_GetThreadState */ typedef enum SDL_ThreadState { SDL_THREAD_UNKNOWN, /**< The thread is not valid */ SDL_THREAD_ALIVE, /**< The thread is currently running */ SDL_THREAD_DETACHED, /**< The thread is detached and can't be waited on */ SDL_THREAD_COMPLETE /**< The thread has finished and should be cleaned up with SDL_WaitThread() */ } SDL_ThreadState; /** * The function passed to SDL_CreateThread() as the new thread's entry point. * * \param data what was passed as `data` to SDL_CreateThread(). * \returns a value that can be reported through SDL_WaitThread(). * * \since This datatype is available since SDL 3.2.0. */ typedef int (SDLCALL *SDL_ThreadFunction) (void *data); #ifdef SDL_WIKI_DOCUMENTATION_SECTION /* * Note that these aren't the correct function signatures in this block, but * this is what the API reference manual should look like for all intents and * purposes. * * Technical details, not for the wiki (hello, header readers!)... * * On Windows (and maybe other platforms), a program might use a different * C runtime than its libraries. Or, in SDL's case, it might use a C runtime * while SDL uses none at all. * * C runtimes expect to initialize thread-specific details when a new thread * is created, but to do this in SDL_CreateThread would require SDL to know * intimate details about the caller's C runtime, which is not possible. * * So SDL_CreateThread has two extra parameters, which are * hidden at compile time by macros: the C runtime's `_beginthreadex` and * `_endthreadex` entry points. If these are not NULL, they are used to spin * and terminate the new thread; otherwise the standard Win32 `CreateThread` * function is used. When `SDL_CreateThread` is called from a compiler that * needs this C runtime thread init function, macros insert the appropriate * function pointers for SDL_CreateThread's caller (which might be a different * compiler with a different runtime in different calls to SDL_CreateThread!). * * SDL_BeginThreadFunction defaults to `_beginthreadex` on Windows (and NULL * everywhere else), but apps that have extremely specific special needs can * define this to something else and the SDL headers will use it, passing the * app-defined value to SDL_CreateThread calls. Redefine this with caution! * * Platforms that don't need _beginthread stuff (most everything) will fail * SDL_CreateThread with an error if these pointers _aren't_ NULL. * * Unless you are doing something extremely complicated, like perhaps a * language binding, **you should never deal with this directly**. Let SDL's * macros handle this platform-specific detail transparently! */ /** * Create a new thread with a default stack size. * * This is a convenience function, equivalent to calling * SDL_CreateThreadWithProperties with the following properties set: * * - `SDL_PROP_THREAD_CREATE_ENTRY_FUNCTION_POINTER`: `fn` * - `SDL_PROP_THREAD_CREATE_NAME_STRING`: `name` * - `SDL_PROP_THREAD_CREATE_USERDATA_POINTER`: `data` * * Note that this "function" is actually a macro that calls an internal * function with two extra parameters not listed here; they are hidden through * preprocessor macros and are needed to support various C runtimes at the * point of the function call. Language bindings that aren't using the C * headers will need to deal with this. * * Usually, apps should just call this function the same way on every platform * and let the macros hide the details. * * \param fn the SDL_ThreadFunction function to call in the new thread. * \param name the name of the thread. * \param data a pointer that is passed to `fn`. * \returns an opaque pointer to the new thread object on success, NULL if the * new thread could not be created; call SDL_GetError() for more * information. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_CreateThreadWithProperties * \sa SDL_WaitThread */ extern SDL_DECLSPEC SDL_Thread * SDLCALL SDL_CreateThread(SDL_ThreadFunction fn, const char *name, void *data); /** * Create a new thread with with the specified properties. * * These are the supported properties: * * - `SDL_PROP_THREAD_CREATE_ENTRY_FUNCTION_POINTER`: an SDL_ThreadFunction * value that will be called at the start of the new thread's life. * Required. * - `SDL_PROP_THREAD_CREATE_NAME_STRING`: the name of the new thread, which * might be available to debuggers. Optional, defaults to NULL. * - `SDL_PROP_THREAD_CREATE_USERDATA_POINTER`: an arbitrary app-defined * pointer, which is passed to the entry function on the new thread, as its * only parameter. Optional, defaults to NULL. * - `SDL_PROP_THREAD_CREATE_STACKSIZE_NUMBER`: the size, in bytes, of the new * thread's stack. Optional, defaults to 0 (system-defined default). * * SDL makes an attempt to report `SDL_PROP_THREAD_CREATE_NAME_STRING` to the * system, so that debuggers can display it. Not all platforms support this. * * Thread naming is a little complicated: Most systems have very small limits * for the string length (Haiku has 32 bytes, Linux currently has 16, Visual * C++ 6.0 has _nine_!), and possibly other arbitrary rules. You'll have to * see what happens with your system's debugger. The name should be UTF-8 (but * using the naming limits of C identifiers is a better bet). There are no * requirements for thread naming conventions, so long as the string is * null-terminated UTF-8, but these guidelines are helpful in choosing a name: * * https://stackoverflow.com/questions/149932/naming-conventions-for-threads * * If a system imposes requirements, SDL will try to munge the string for it * (truncate, etc), but the original string contents will be available from * SDL_GetThreadName(). * * The size (in bytes) of the new stack can be specified with * `SDL_PROP_THREAD_CREATE_STACKSIZE_NUMBER`. Zero means "use the system * default" which might be wildly different between platforms. x86 Linux * generally defaults to eight megabytes, an embedded device might be a few * kilobytes instead. You generally need to specify a stack that is a multiple * of the system's page size (in many cases, this is 4 kilobytes, but check * your system documentation). * * Note that this "function" is actually a macro that calls an internal * function with two extra parameters not listed here; they are hidden through * preprocessor macros and are needed to support various C runtimes at the * point of the function call. Language bindings that aren't using the C * headers will need to deal with this. * * The actual symbol in SDL is `SDL_CreateThreadWithPropertiesRuntime`, so * there is no symbol clash, but trying to load an SDL shared library and look * for "SDL_CreateThreadWithProperties" will fail. * * Usually, apps should just call this function the same way on every platform * and let the macros hide the details. * * \param props the properties to use. * \returns an opaque pointer to the new thread object on success, NULL if the * new thread could not be created; call SDL_GetError() for more * information. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_CreateThread * \sa SDL_WaitThread */ extern SDL_DECLSPEC SDL_Thread * SDLCALL SDL_CreateThreadWithProperties(SDL_PropertiesID props); #define SDL_PROP_THREAD_CREATE_ENTRY_FUNCTION_POINTER "SDL.thread.create.entry_function" #define SDL_PROP_THREAD_CREATE_NAME_STRING "SDL.thread.create.name" #define SDL_PROP_THREAD_CREATE_USERDATA_POINTER "SDL.thread.create.userdata" #define SDL_PROP_THREAD_CREATE_STACKSIZE_NUMBER "SDL.thread.create.stacksize" /* end wiki documentation for macros that are meant to look like functions. */ #endif /* The real implementation, hidden from the wiki, so it can show this as real functions that don't have macro magic. */ #ifndef SDL_WIKI_DOCUMENTATION_SECTION # if defined(SDL_PLATFORM_WINDOWS) # ifndef SDL_BeginThreadFunction # define SDL_BeginThreadFunction _beginthreadex # endif # ifndef SDL_EndThreadFunction # define SDL_EndThreadFunction _endthreadex # endif # endif #endif /* currently no other platforms than Windows use _beginthreadex/_endthreadex things. */ #ifndef SDL_WIKI_DOCUMENTATION_SECTION # ifndef SDL_BeginThreadFunction # define SDL_BeginThreadFunction NULL # endif #endif #ifndef SDL_WIKI_DOCUMENTATION_SECTION # ifndef SDL_EndThreadFunction # define SDL_EndThreadFunction NULL # endif #endif #ifndef SDL_WIKI_DOCUMENTATION_SECTION /* These are the actual functions exported from SDL! Don't use them directly! Use the SDL_CreateThread and SDL_CreateThreadWithProperties macros! */ /** * The actual entry point for SDL_CreateThread. * * \param fn the SDL_ThreadFunction function to call in the new thread * \param name the name of the thread * \param data a pointer that is passed to `fn` * \param pfnBeginThread the C runtime's _beginthreadex (or whatnot). Can be NULL. * \param pfnEndThread the C runtime's _endthreadex (or whatnot). Can be NULL. * \returns an opaque pointer to the new thread object on success, NULL if the * new thread could not be created; call SDL_GetError() for more * information. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC SDL_Thread * SDLCALL SDL_CreateThreadRuntime(SDL_ThreadFunction fn, const char *name, void *data, SDL_FunctionPointer pfnBeginThread, SDL_FunctionPointer pfnEndThread); /** * The actual entry point for SDL_CreateThreadWithProperties. * * \param props the properties to use * \param pfnBeginThread the C runtime's _beginthreadex (or whatnot). Can be NULL. * \param pfnEndThread the C runtime's _endthreadex (or whatnot). Can be NULL. * \returns an opaque pointer to the new thread object on success, NULL if the * new thread could not be created; call SDL_GetError() for more * information. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC SDL_Thread * SDLCALL SDL_CreateThreadWithPropertiesRuntime(SDL_PropertiesID props, SDL_FunctionPointer pfnBeginThread, SDL_FunctionPointer pfnEndThread); #define SDL_CreateThread(fn, name, data) SDL_CreateThreadRuntime((fn), (name), (data), (SDL_FunctionPointer) (SDL_BeginThreadFunction), (SDL_FunctionPointer) (SDL_EndThreadFunction)) #define SDL_CreateThreadWithProperties(props) SDL_CreateThreadWithPropertiesRuntime((props), (SDL_FunctionPointer) (SDL_BeginThreadFunction), (SDL_FunctionPointer) (SDL_EndThreadFunction)) #define SDL_PROP_THREAD_CREATE_ENTRY_FUNCTION_POINTER "SDL.thread.create.entry_function" #define SDL_PROP_THREAD_CREATE_NAME_STRING "SDL.thread.create.name" #define SDL_PROP_THREAD_CREATE_USERDATA_POINTER "SDL.thread.create.userdata" #define SDL_PROP_THREAD_CREATE_STACKSIZE_NUMBER "SDL.thread.create.stacksize" #endif /** * Get the thread name as it was specified in SDL_CreateThread(). * * \param thread the thread to query. * \returns a pointer to a UTF-8 string that names the specified thread, or * NULL if it doesn't have a name. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC const char * SDLCALL SDL_GetThreadName(SDL_Thread *thread); /** * Get the thread identifier for the current thread. * * This thread identifier is as reported by the underlying operating system. * If SDL is running on a platform that does not support threads the return * value will always be zero. * * This function also returns a valid thread ID when called from the main * thread. * * \returns the ID of the current thread. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetThreadID */ extern SDL_DECLSPEC SDL_ThreadID SDLCALL SDL_GetCurrentThreadID(void); /** * Get the thread identifier for the specified thread. * * This thread identifier is as reported by the underlying operating system. * If SDL is running on a platform that does not support threads the return * value will always be zero. * * \param thread the thread to query. * \returns the ID of the specified thread, or the ID of the current thread if * `thread` is NULL. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetCurrentThreadID */ extern SDL_DECLSPEC SDL_ThreadID SDLCALL SDL_GetThreadID(SDL_Thread *thread); /** * Set the priority for the current thread. * * Note that some platforms will not let you alter the priority (or at least, * promote the thread to a higher priority) at all, and some require you to be * an administrator account. Be prepared for this to fail. * * \param priority the SDL_ThreadPriority to set. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC bool SDLCALL SDL_SetCurrentThreadPriority(SDL_ThreadPriority priority); /** * Wait for a thread to finish. * * Threads that haven't been detached will remain until this function cleans * them up. Not doing so is a resource leak. * * Once a thread has been cleaned up through this function, the SDL_Thread * that references it becomes invalid and should not be referenced again. As * such, only one thread may call SDL_WaitThread() on another. * * The return code from the thread function is placed in the area pointed to * by `status`, if `status` is not NULL. * * You may not wait on a thread that has been used in a call to * SDL_DetachThread(). Use either that function or this one, but not both, or * behavior is undefined. * * It is safe to pass a NULL thread to this function; it is a no-op. * * Note that the thread pointer is freed by this function and is not valid * afterward. * * \param thread the SDL_Thread pointer that was returned from the * SDL_CreateThread() call that started this thread. * \param status a pointer filled in with the value returned from the thread * function by its 'return', or -1 if the thread has been * detached or isn't valid, may be NULL. * * \threadsafety It is safe to call this function from any thread, but only a * single thread can wait any specific thread to finish. * * \since This function is available since SDL 3.2.0. * * \sa SDL_CreateThread * \sa SDL_DetachThread */ extern SDL_DECLSPEC void SDLCALL SDL_WaitThread(SDL_Thread *thread, int *status); /** * Get the current state of a thread. * * \param thread the thread to query. * \returns the current state of a thread, or SDL_THREAD_UNKNOWN if the thread * isn't valid. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_ThreadState */ extern SDL_DECLSPEC SDL_ThreadState SDLCALL SDL_GetThreadState(SDL_Thread *thread); /** * Let a thread clean up on exit without intervention. * * A thread may be "detached" to signify that it should not remain until * another thread has called SDL_WaitThread() on it. Detaching a thread is * useful for long-running threads that nothing needs to synchronize with or * further manage. When a detached thread is done, it simply goes away. * * There is no way to recover the return code of a detached thread. If you * need this, don't detach the thread and instead use SDL_WaitThread(). * * Once a thread is detached, you should usually assume the SDL_Thread isn't * safe to reference again, as it will become invalid immediately upon the * detached thread's exit, instead of remaining until someone has called * SDL_WaitThread() to finally clean it up. As such, don't detach the same * thread more than once. * * If a thread has already exited when passed to SDL_DetachThread(), it will * stop waiting for a call to SDL_WaitThread() and clean up immediately. It is * not safe to detach a thread that might be used with SDL_WaitThread(). * * You may not call SDL_WaitThread() on a thread that has been detached. Use * either that function or this one, but not both, or behavior is undefined. * * It is safe to pass NULL to this function; it is a no-op. * * \param thread the SDL_Thread pointer that was returned from the * SDL_CreateThread() call that started this thread. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_CreateThread * \sa SDL_WaitThread */ extern SDL_DECLSPEC void SDLCALL SDL_DetachThread(SDL_Thread *thread); /** * Get the current thread's value associated with a thread local storage ID. * * \param id a pointer to the thread local storage ID, may not be NULL. * \returns the value associated with the ID for the current thread or NULL if * no value has been set; call SDL_GetError() for more information. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_SetTLS */ extern SDL_DECLSPEC void * SDLCALL SDL_GetTLS(SDL_TLSID *id); /** * The callback used to cleanup data passed to SDL_SetTLS. * * This is called when a thread exits, to allow an app to free any resources. * * \param value a pointer previously handed to SDL_SetTLS. * * \since This datatype is available since SDL 3.2.0. * * \sa SDL_SetTLS */ typedef void (SDLCALL *SDL_TLSDestructorCallback)(void *value); /** * Set the current thread's value associated with a thread local storage ID. * * If the thread local storage ID is not initialized (the value is 0), a new * ID will be created in a thread-safe way, so all calls using a pointer to * the same ID will refer to the same local storage. * * Note that replacing a value from a previous call to this function on the * same thread does _not_ call the previous value's destructor! * * `destructor` can be NULL; it is assumed that `value` does not need to be * cleaned up if so. * * \param id a pointer to the thread local storage ID, may not be NULL. * \param value the value to associate with the ID for the current thread. * \param destructor a function called when the thread exits, to free the * value, may be NULL. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetTLS */ extern SDL_DECLSPEC bool SDLCALL SDL_SetTLS(SDL_TLSID *id, const void *value, SDL_TLSDestructorCallback destructor); /** * Cleanup all TLS data for this thread. * * If you are creating your threads outside of SDL and then calling SDL * functions, you should call this function before your thread exits, to * properly clean up SDL memory. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC void SDLCALL SDL_CleanupTLS(void); /* Ends C function definitions when using C++ */ #ifdef __cplusplus } #endif #include #endif /* SDL_thread_h_ */ ================================================ FILE: deps/include/SDL3/SDL_time.h ================================================ /* Simple DirectMedia Layer Copyright (C) 1997-2026 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ #ifndef SDL_time_h_ #define SDL_time_h_ /** * # CategoryTime * * SDL realtime clock and date/time routines. * * There are two data types that are used in this category: SDL_Time, which * represents the nanoseconds since a specific moment (an "epoch"), and * SDL_DateTime, which breaks time down into human-understandable components: * years, months, days, hours, etc. * * Much of the functionality is involved in converting those two types to * other useful forms. */ #include #include #include /* Set up for C function definitions, even when using C++ */ #ifdef __cplusplus extern "C" { #endif /** * A structure holding a calendar date and time broken down into its * components. * * \since This struct is available since SDL 3.2.0. */ typedef struct SDL_DateTime { int year; /**< Year */ int month; /**< Month [01-12] */ int day; /**< Day of the month [01-31] */ int hour; /**< Hour [0-23] */ int minute; /**< Minute [0-59] */ int second; /**< Seconds [0-60] */ int nanosecond; /**< Nanoseconds [0-999999999] */ int day_of_week; /**< Day of the week [0-6] (0 being Sunday) */ int utc_offset; /**< Seconds east of UTC */ } SDL_DateTime; /** * The preferred date format of the current system locale. * * \since This enum is available since SDL 3.2.0. * * \sa SDL_GetDateTimeLocalePreferences */ typedef enum SDL_DateFormat { SDL_DATE_FORMAT_YYYYMMDD = 0, /**< Year/Month/Day */ SDL_DATE_FORMAT_DDMMYYYY = 1, /**< Day/Month/Year */ SDL_DATE_FORMAT_MMDDYYYY = 2 /**< Month/Day/Year */ } SDL_DateFormat; /** * The preferred time format of the current system locale. * * \since This enum is available since SDL 3.2.0. * * \sa SDL_GetDateTimeLocalePreferences */ typedef enum SDL_TimeFormat { SDL_TIME_FORMAT_24HR = 0, /**< 24 hour time */ SDL_TIME_FORMAT_12HR = 1 /**< 12 hour time */ } SDL_TimeFormat; /** * Gets the current preferred date and time format for the system locale. * * This might be a "slow" call that has to query the operating system. It's * best to ask for this once and save the results. However, the preferred * formats can change, usually because the user has changed a system * preference outside of your program. * * \param dateFormat a pointer to the SDL_DateFormat to hold the returned date * format, may be NULL. * \param timeFormat a pointer to the SDL_TimeFormat to hold the returned time * format, may be NULL. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety This function is not thread safe. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC bool SDLCALL SDL_GetDateTimeLocalePreferences(SDL_DateFormat *dateFormat, SDL_TimeFormat *timeFormat); /** * Gets the current value of the system realtime clock in nanoseconds since * Jan 1, 1970 in Universal Coordinated Time (UTC). * * \param ticks the SDL_Time to hold the returned tick count. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC bool SDLCALL SDL_GetCurrentTime(SDL_Time *ticks); /** * Converts an SDL_Time in nanoseconds since the epoch to a calendar time in * the SDL_DateTime format. * * \param ticks the SDL_Time to be converted. * \param dt the resulting SDL_DateTime. * \param localTime the resulting SDL_DateTime will be expressed in local time * if true, otherwise it will be in Universal Coordinated * Time (UTC). * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC bool SDLCALL SDL_TimeToDateTime(SDL_Time ticks, SDL_DateTime *dt, bool localTime); /** * Converts a calendar time to an SDL_Time in nanoseconds since the epoch. * * This function ignores the day_of_week member of the SDL_DateTime struct, so * it may remain unset. * * \param dt the source SDL_DateTime. * \param ticks the resulting SDL_Time. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC bool SDLCALL SDL_DateTimeToTime(const SDL_DateTime *dt, SDL_Time *ticks); /** * Converts an SDL time into a Windows FILETIME (100-nanosecond intervals * since January 1, 1601). * * This function fills in the two 32-bit values of the FILETIME structure. * * \param ticks the time to convert. * \param dwLowDateTime a pointer filled in with the low portion of the * Windows FILETIME value. * \param dwHighDateTime a pointer filled in with the high portion of the * Windows FILETIME value. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC void SDLCALL SDL_TimeToWindows(SDL_Time ticks, Uint32 *dwLowDateTime, Uint32 *dwHighDateTime); /** * Converts a Windows FILETIME (100-nanosecond intervals since January 1, * 1601) to an SDL time. * * This function takes the two 32-bit values of the FILETIME structure as * parameters. * * \param dwLowDateTime the low portion of the Windows FILETIME value. * \param dwHighDateTime the high portion of the Windows FILETIME value. * \returns the converted SDL time. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC SDL_Time SDLCALL SDL_TimeFromWindows(Uint32 dwLowDateTime, Uint32 dwHighDateTime); /** * Get the number of days in a month for a given year. * * \param year the year. * \param month the month [1-12]. * \returns the number of days in the requested month or -1 on failure; call * SDL_GetError() for more information. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC int SDLCALL SDL_GetDaysInMonth(int year, int month); /** * Get the day of year for a calendar date. * * \param year the year component of the date. * \param month the month component of the date. * \param day the day component of the date. * \returns the day of year [0-365] if the date is valid or -1 on failure; * call SDL_GetError() for more information. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC int SDLCALL SDL_GetDayOfYear(int year, int month, int day); /** * Get the day of week for a calendar date. * * \param year the year component of the date. * \param month the month component of the date. * \param day the day component of the date. * \returns a value between 0 and 6 (0 being Sunday) if the date is valid or * -1 on failure; call SDL_GetError() for more information. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC int SDLCALL SDL_GetDayOfWeek(int year, int month, int day); /* Ends C function definitions when using C++ */ #ifdef __cplusplus } #endif #include #endif /* SDL_time_h_ */ ================================================ FILE: deps/include/SDL3/SDL_timer.h ================================================ /* Simple DirectMedia Layer Copyright (C) 1997-2026 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ #ifndef SDL_timer_h_ #define SDL_timer_h_ /** * # CategoryTimer * * SDL provides time management functionality. It is useful for dealing with * (usually) small durations of time. * * This is not to be confused with _calendar time_ management, which is * provided by [CategoryTime](CategoryTime). * * This category covers measuring time elapsed (SDL_GetTicks(), * SDL_GetPerformanceCounter()), putting a thread to sleep for a certain * amount of time (SDL_Delay(), SDL_DelayNS(), SDL_DelayPrecise()), and firing * a callback function after a certain amount of time has elapsed * (SDL_AddTimer(), etc). * * There are also useful macros to convert between time units, like * SDL_SECONDS_TO_NS() and such. */ #include #include #include /* Set up for C function definitions, even when using C++ */ #ifdef __cplusplus extern "C" { #endif /* SDL time constants */ /** * Number of milliseconds in a second. * * This is always 1000. * * \since This macro is available since SDL 3.2.0. */ #define SDL_MS_PER_SECOND 1000 /** * Number of microseconds in a second. * * This is always 1000000. * * \since This macro is available since SDL 3.2.0. */ #define SDL_US_PER_SECOND 1000000 /** * Number of nanoseconds in a second. * * This is always 1000000000. * * \since This macro is available since SDL 3.2.0. */ #define SDL_NS_PER_SECOND 1000000000LL /** * Number of nanoseconds in a millisecond. * * This is always 1000000. * * \since This macro is available since SDL 3.2.0. */ #define SDL_NS_PER_MS 1000000 /** * Number of nanoseconds in a microsecond. * * This is always 1000. * * \since This macro is available since SDL 3.2.0. */ #define SDL_NS_PER_US 1000 /** * Convert seconds to nanoseconds. * * This only converts whole numbers, not fractional seconds. * * \param S the number of seconds to convert. * \returns S, expressed in nanoseconds. * * \threadsafety It is safe to call this macro from any thread. * * \since This macro is available since SDL 3.2.0. */ #define SDL_SECONDS_TO_NS(S) (((Uint64)(S)) * SDL_NS_PER_SECOND) /** * Convert nanoseconds to seconds. * * This performs a division, so the results can be dramatically different if * `NS` is an integer or floating point value. * * \param NS the number of nanoseconds to convert. * \returns NS, expressed in seconds. * * \threadsafety It is safe to call this macro from any thread. * * \since This macro is available since SDL 3.2.0. */ #define SDL_NS_TO_SECONDS(NS) ((NS) / SDL_NS_PER_SECOND) /** * Convert milliseconds to nanoseconds. * * This only converts whole numbers, not fractional milliseconds. * * \param MS the number of milliseconds to convert. * \returns MS, expressed in nanoseconds. * * \threadsafety It is safe to call this macro from any thread. * * \since This macro is available since SDL 3.2.0. */ #define SDL_MS_TO_NS(MS) (((Uint64)(MS)) * SDL_NS_PER_MS) /** * Convert nanoseconds to milliseconds. * * This performs a division, so the results can be dramatically different if * `NS` is an integer or floating point value. * * \param NS the number of nanoseconds to convert. * \returns NS, expressed in milliseconds. * * \threadsafety It is safe to call this macro from any thread. * * \since This macro is available since SDL 3.2.0. */ #define SDL_NS_TO_MS(NS) ((NS) / SDL_NS_PER_MS) /** * Convert microseconds to nanoseconds. * * This only converts whole numbers, not fractional microseconds. * * \param US the number of microseconds to convert. * \returns US, expressed in nanoseconds. * * \threadsafety It is safe to call this macro from any thread. * * \since This macro is available since SDL 3.2.0. */ #define SDL_US_TO_NS(US) (((Uint64)(US)) * SDL_NS_PER_US) /** * Convert nanoseconds to microseconds. * * This performs a division, so the results can be dramatically different if * `NS` is an integer or floating point value. * * \param NS the number of nanoseconds to convert. * \returns NS, expressed in microseconds. * * \threadsafety It is safe to call this macro from any thread. * * \since This macro is available since SDL 3.2.0. */ #define SDL_NS_TO_US(NS) ((NS) / SDL_NS_PER_US) /** * Get the number of milliseconds that have elapsed since the SDL library * initialization. * * \returns an unsigned 64‑bit integer that represents the number of * milliseconds that have elapsed since the SDL library was * initialized (typically via a call to SDL_Init). * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetTicksNS */ extern SDL_DECLSPEC Uint64 SDLCALL SDL_GetTicks(void); /** * Get the number of nanoseconds since SDL library initialization. * * \returns an unsigned 64-bit value representing the number of nanoseconds * since the SDL library initialized. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC Uint64 SDLCALL SDL_GetTicksNS(void); /** * Get the current value of the high resolution counter. * * This function is typically used for profiling. * * The counter values are only meaningful relative to each other. Differences * between values can be converted to times by using * SDL_GetPerformanceFrequency(). * * \returns the current counter value. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetPerformanceFrequency */ extern SDL_DECLSPEC Uint64 SDLCALL SDL_GetPerformanceCounter(void); /** * Get the count per second of the high resolution counter. * * \returns a platform-specific count per second. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetPerformanceCounter */ extern SDL_DECLSPEC Uint64 SDLCALL SDL_GetPerformanceFrequency(void); /** * Wait a specified number of milliseconds before returning. * * This function waits a specified number of milliseconds before returning. It * waits at least the specified time, but possibly longer due to OS * scheduling. * * \param ms the number of milliseconds to delay. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_DelayNS * \sa SDL_DelayPrecise */ extern SDL_DECLSPEC void SDLCALL SDL_Delay(Uint32 ms); /** * Wait a specified number of nanoseconds before returning. * * This function waits a specified number of nanoseconds before returning. It * waits at least the specified time, but possibly longer due to OS * scheduling. * * \param ns the number of nanoseconds to delay. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_Delay * \sa SDL_DelayPrecise */ extern SDL_DECLSPEC void SDLCALL SDL_DelayNS(Uint64 ns); /** * Wait a specified number of nanoseconds before returning. * * This function waits a specified number of nanoseconds before returning. It * will attempt to wait as close to the requested time as possible, busy * waiting if necessary, but could return later due to OS scheduling. * * \param ns the number of nanoseconds to delay. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_Delay * \sa SDL_DelayNS */ extern SDL_DECLSPEC void SDLCALL SDL_DelayPrecise(Uint64 ns); /** * Definition of the timer ID type. * * \since This datatype is available since SDL 3.2.0. */ typedef Uint32 SDL_TimerID; /** * Function prototype for the millisecond timer callback function. * * The callback function is passed the current timer interval and returns the * next timer interval, in milliseconds. If the returned value is the same as * the one passed in, the periodic alarm continues, otherwise a new alarm is * scheduled. If the callback returns 0, the periodic alarm is canceled and * will be removed. * * \param userdata an arbitrary pointer provided by the app through * SDL_AddTimer, for its own use. * \param timerID the current timer being processed. * \param interval the current callback time interval. * \returns the new callback time interval, or 0 to disable further runs of * the callback. * * \threadsafety SDL may call this callback at any time from a background * thread; the application is responsible for locking resources * the callback touches that need to be protected. * * \since This datatype is available since SDL 3.2.0. * * \sa SDL_AddTimer */ typedef Uint32 (SDLCALL *SDL_TimerCallback)(void *userdata, SDL_TimerID timerID, Uint32 interval); /** * Call a callback function at a future time. * * The callback function is passed the current timer interval and the user * supplied parameter from the SDL_AddTimer() call and should return the next * timer interval. If the value returned from the callback is 0, the timer is * canceled and will be removed. * * The callback is run on a separate thread, and for short timeouts can * potentially be called before this function returns. * * Timers take into account the amount of time it took to execute the * callback. For example, if the callback took 250 ms to execute and returned * 1000 (ms), the timer would only wait another 750 ms before its next * iteration. * * Timing may be inexact due to OS scheduling. Be sure to note the current * time with SDL_GetTicksNS() or SDL_GetPerformanceCounter() in case your * callback needs to adjust for variances. * * \param interval the timer delay, in milliseconds, passed to `callback`. * \param callback the SDL_TimerCallback function to call when the specified * `interval` elapses. * \param userdata a pointer that is passed to `callback`. * \returns a timer ID or 0 on failure; call SDL_GetError() for more * information. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_AddTimerNS * \sa SDL_RemoveTimer */ extern SDL_DECLSPEC SDL_TimerID SDLCALL SDL_AddTimer(Uint32 interval, SDL_TimerCallback callback, void *userdata); /** * Function prototype for the nanosecond timer callback function. * * The callback function is passed the current timer interval and returns the * next timer interval, in nanoseconds. If the returned value is the same as * the one passed in, the periodic alarm continues, otherwise a new alarm is * scheduled. If the callback returns 0, the periodic alarm is canceled and * will be removed. * * \param userdata an arbitrary pointer provided by the app through * SDL_AddTimer, for its own use. * \param timerID the current timer being processed. * \param interval the current callback time interval. * \returns the new callback time interval, or 0 to disable further runs of * the callback. * * \threadsafety SDL may call this callback at any time from a background * thread; the application is responsible for locking resources * the callback touches that need to be protected. * * \since This datatype is available since SDL 3.2.0. * * \sa SDL_AddTimerNS */ typedef Uint64 (SDLCALL *SDL_NSTimerCallback)(void *userdata, SDL_TimerID timerID, Uint64 interval); /** * Call a callback function at a future time. * * The callback function is passed the current timer interval and the user * supplied parameter from the SDL_AddTimerNS() call and should return the * next timer interval. If the value returned from the callback is 0, the * timer is canceled and will be removed. * * The callback is run on a separate thread, and for short timeouts can * potentially be called before this function returns. * * Timers take into account the amount of time it took to execute the * callback. For example, if the callback took 250 ns to execute and returned * 1000 (ns), the timer would only wait another 750 ns before its next * iteration. * * Timing may be inexact due to OS scheduling. Be sure to note the current * time with SDL_GetTicksNS() or SDL_GetPerformanceCounter() in case your * callback needs to adjust for variances. * * \param interval the timer delay, in nanoseconds, passed to `callback`. * \param callback the SDL_TimerCallback function to call when the specified * `interval` elapses. * \param userdata a pointer that is passed to `callback`. * \returns a timer ID or 0 on failure; call SDL_GetError() for more * information. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_AddTimer * \sa SDL_RemoveTimer */ extern SDL_DECLSPEC SDL_TimerID SDLCALL SDL_AddTimerNS(Uint64 interval, SDL_NSTimerCallback callback, void *userdata); /** * Remove a timer created with SDL_AddTimer(). * * \param id the ID of the timer to remove. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_AddTimer */ extern SDL_DECLSPEC bool SDLCALL SDL_RemoveTimer(SDL_TimerID id); /* Ends C function definitions when using C++ */ #ifdef __cplusplus } #endif #include #endif /* SDL_timer_h_ */ ================================================ FILE: deps/include/SDL3/SDL_touch.h ================================================ /* Simple DirectMedia Layer Copyright (C) 1997-2026 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ /** * # CategoryTouch * * SDL offers touch input, on platforms that support it. It can manage * multiple touch devices and track multiple fingers on those devices. * * Touches are mostly dealt with through the event system, in the * SDL_EVENT_FINGER_DOWN, SDL_EVENT_FINGER_MOTION, and SDL_EVENT_FINGER_UP * events, but there are also functions to query for hardware details, etc. * * The touch system, by default, will also send virtual mouse events; this can * be useful for making a some desktop apps work on a phone without * significant changes. For apps that care about mouse and touch input * separately, they should ignore mouse events that have a `which` field of * SDL_TOUCH_MOUSEID. */ #ifndef SDL_touch_h_ #define SDL_touch_h_ #include #include #include #include /* Set up for C function definitions, even when using C++ */ #ifdef __cplusplus extern "C" { #endif /** * A unique ID for a touch device. * * This ID is valid for the time the device is connected to the system, and is * never reused for the lifetime of the application. * * The value 0 is an invalid ID. * * \since This datatype is available since SDL 3.2.0. */ typedef Uint64 SDL_TouchID; /** * A unique ID for a single finger on a touch device. * * This ID is valid for the time the finger (stylus, etc) is touching and will * be unique for all fingers currently in contact, so this ID tracks the * lifetime of a single continuous touch. This value may represent an index, a * pointer, or some other unique ID, depending on the platform. * * The value 0 is an invalid ID. * * \since This datatype is available since SDL 3.2.0. */ typedef Uint64 SDL_FingerID; /** * An enum that describes the type of a touch device. * * \since This enum is available since SDL 3.2.0. */ typedef enum SDL_TouchDeviceType { SDL_TOUCH_DEVICE_INVALID = -1, SDL_TOUCH_DEVICE_DIRECT, /**< touch screen with window-relative coordinates */ SDL_TOUCH_DEVICE_INDIRECT_ABSOLUTE, /**< trackpad with absolute device coordinates */ SDL_TOUCH_DEVICE_INDIRECT_RELATIVE /**< trackpad with screen cursor-relative coordinates */ } SDL_TouchDeviceType; /** * Data about a single finger in a multitouch event. * * Each touch event is a collection of fingers that are simultaneously in * contact with the touch device (so a "touch" can be a "multitouch," in * reality), and this struct reports details of the specific fingers. * * \since This struct is available since SDL 3.2.0. * * \sa SDL_GetTouchFingers */ typedef struct SDL_Finger { SDL_FingerID id; /**< the finger ID */ float x; /**< the x-axis location of the touch event, normalized (0...1) */ float y; /**< the y-axis location of the touch event, normalized (0...1) */ float pressure; /**< the quantity of pressure applied, normalized (0...1) */ } SDL_Finger; /** * The SDL_MouseID for mouse events simulated with touch input. * * \since This macro is available since SDL 3.2.0. */ #define SDL_TOUCH_MOUSEID ((SDL_MouseID)-1) /** * The SDL_TouchID for touch events simulated with mouse input. * * \since This macro is available since SDL 3.2.0. */ #define SDL_MOUSE_TOUCHID ((SDL_TouchID)-1) /** * Get a list of registered touch devices. * * On some platforms SDL first sees the touch device if it was actually used. * Therefore the returned list might be empty, although devices are available. * After using all devices at least once the number will be correct. * * \param count a pointer filled in with the number of devices returned, may * be NULL. * \returns a 0 terminated array of touch device IDs or NULL on failure; call * SDL_GetError() for more information. This should be freed with * SDL_free() when it is no longer needed. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC SDL_TouchID * SDLCALL SDL_GetTouchDevices(int *count); /** * Get the touch device name as reported from the driver. * * \param touchID the touch device instance ID. * \returns touch device name, or NULL on failure; call SDL_GetError() for * more information. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC const char * SDLCALL SDL_GetTouchDeviceName(SDL_TouchID touchID); /** * Get the type of the given touch device. * * \param touchID the ID of a touch device. * \returns touch device type. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC SDL_TouchDeviceType SDLCALL SDL_GetTouchDeviceType(SDL_TouchID touchID); /** * Get a list of active fingers for a given touch device. * * \param touchID the ID of a touch device. * \param count a pointer filled in with the number of fingers returned, can * be NULL. * \returns a NULL terminated array of SDL_Finger pointers or NULL on failure; * call SDL_GetError() for more information. This is a single * allocation that should be freed with SDL_free() when it is no * longer needed. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC SDL_Finger ** SDLCALL SDL_GetTouchFingers(SDL_TouchID touchID, int *count); /* Ends C function definitions when using C++ */ #ifdef __cplusplus } #endif #include #endif /* SDL_touch_h_ */ ================================================ FILE: deps/include/SDL3/SDL_tray.h ================================================ /* Simple DirectMedia Layer Copyright (C) 1997-2026 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ /** * # CategoryTray * * SDL offers a way to add items to the "system tray" (more correctly called * the "notification area" on Windows). On platforms that offer this concept, * an SDL app can add a tray icon, submenus, checkboxes, and clickable * entries, and register a callback that is fired when the user clicks on * these pieces. */ #ifndef SDL_tray_h_ #define SDL_tray_h_ #include #include #include #include #include /* Set up for C function definitions, even when using C++ */ #ifdef __cplusplus extern "C" { #endif /** * An opaque handle representing a toplevel system tray object. * * \since This struct is available since SDL 3.2.0. */ typedef struct SDL_Tray SDL_Tray; /** * An opaque handle representing a menu/submenu on a system tray object. * * \since This struct is available since SDL 3.2.0. */ typedef struct SDL_TrayMenu SDL_TrayMenu; /** * An opaque handle representing an entry on a system tray object. * * \since This struct is available since SDL 3.2.0. */ typedef struct SDL_TrayEntry SDL_TrayEntry; /** * Flags that control the creation of system tray entries. * * Some of these flags are required; exactly one of them must be specified at * the time a tray entry is created. Other flags are optional; zero or more of * those can be OR'ed together with the required flag. * * \since This datatype is available since SDL 3.2.0. * * \sa SDL_InsertTrayEntryAt */ typedef Uint32 SDL_TrayEntryFlags; #define SDL_TRAYENTRY_BUTTON 0x00000001u /**< Make the entry a simple button. Required. */ #define SDL_TRAYENTRY_CHECKBOX 0x00000002u /**< Make the entry a checkbox. Required. */ #define SDL_TRAYENTRY_SUBMENU 0x00000004u /**< Prepare the entry to have a submenu. Required */ #define SDL_TRAYENTRY_DISABLED 0x80000000u /**< Make the entry disabled. Optional. */ #define SDL_TRAYENTRY_CHECKED 0x40000000u /**< Make the entry checked. This is valid only for checkboxes. Optional. */ /** * A callback that is invoked when a tray entry is selected. * * \param userdata an optional pointer to pass extra data to the callback when * it will be invoked. * \param entry the tray entry that was selected. * * \since This datatype is available since SDL 3.2.0. * * \sa SDL_SetTrayEntryCallback */ typedef void (SDLCALL *SDL_TrayCallback)(void *userdata, SDL_TrayEntry *entry); /** * Create an icon to be placed in the operating system's tray, or equivalent. * * Many platforms advise not using a system tray unless persistence is a * necessary feature. Avoid needlessly creating a tray icon, as the user may * feel like it clutters their interface. * * Using tray icons require the video subsystem. * * \param icon a surface to be used as icon. May be NULL. * \param tooltip a tooltip to be displayed when the mouse hovers the icon in * UTF-8 encoding. Not supported on all platforms. May be NULL. * \returns The newly created system tray icon. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_CreateTrayMenu * \sa SDL_GetTrayMenu * \sa SDL_DestroyTray */ extern SDL_DECLSPEC SDL_Tray * SDLCALL SDL_CreateTray(SDL_Surface *icon, const char *tooltip); /** * Updates the system tray icon's icon. * * \param tray the tray icon to be updated. * \param icon the new icon. May be NULL. * * \threadsafety This function should be called on the thread that created the * tray. * * \since This function is available since SDL 3.2.0. * * \sa SDL_CreateTray */ extern SDL_DECLSPEC void SDLCALL SDL_SetTrayIcon(SDL_Tray *tray, SDL_Surface *icon); /** * Updates the system tray icon's tooltip. * * \param tray the tray icon to be updated. * \param tooltip the new tooltip in UTF-8 encoding. May be NULL. * * \threadsafety This function should be called on the thread that created the * tray. * * \since This function is available since SDL 3.2.0. * * \sa SDL_CreateTray */ extern SDL_DECLSPEC void SDLCALL SDL_SetTrayTooltip(SDL_Tray *tray, const char *tooltip); /** * Create a menu for a system tray. * * This should be called at most once per tray icon. * * This function does the same thing as SDL_CreateTraySubmenu(), except that * it takes a SDL_Tray instead of a SDL_TrayEntry. * * A menu does not need to be destroyed; it will be destroyed with the tray. * * \param tray the tray to bind the menu to. * \returns the newly created menu. * * \threadsafety This function should be called on the thread that created the * tray. * * \since This function is available since SDL 3.2.0. * * \sa SDL_CreateTray * \sa SDL_GetTrayMenu * \sa SDL_GetTrayMenuParentTray */ extern SDL_DECLSPEC SDL_TrayMenu * SDLCALL SDL_CreateTrayMenu(SDL_Tray *tray); /** * Create a submenu for a system tray entry. * * This should be called at most once per tray entry. * * This function does the same thing as SDL_CreateTrayMenu, except that it * takes a SDL_TrayEntry instead of a SDL_Tray. * * A menu does not need to be destroyed; it will be destroyed with the tray. * * \param entry the tray entry to bind the menu to. * \returns the newly created menu. * * \threadsafety This function should be called on the thread that created the * tray. * * \since This function is available since SDL 3.2.0. * * \sa SDL_InsertTrayEntryAt * \sa SDL_GetTraySubmenu * \sa SDL_GetTrayMenuParentEntry */ extern SDL_DECLSPEC SDL_TrayMenu * SDLCALL SDL_CreateTraySubmenu(SDL_TrayEntry *entry); /** * Gets a previously created tray menu. * * You should have called SDL_CreateTrayMenu() on the tray object. This * function allows you to fetch it again later. * * This function does the same thing as SDL_GetTraySubmenu(), except that it * takes a SDL_Tray instead of a SDL_TrayEntry. * * A menu does not need to be destroyed; it will be destroyed with the tray. * * \param tray the tray entry to bind the menu to. * \returns the newly created menu. * * \threadsafety This function should be called on the thread that created the * tray. * * \since This function is available since SDL 3.2.0. * * \sa SDL_CreateTray * \sa SDL_CreateTrayMenu */ extern SDL_DECLSPEC SDL_TrayMenu * SDLCALL SDL_GetTrayMenu(SDL_Tray *tray); /** * Gets a previously created tray entry submenu. * * You should have called SDL_CreateTraySubmenu() on the entry object. This * function allows you to fetch it again later. * * This function does the same thing as SDL_GetTrayMenu(), except that it * takes a SDL_TrayEntry instead of a SDL_Tray. * * A menu does not need to be destroyed; it will be destroyed with the tray. * * \param entry the tray entry to bind the menu to. * \returns the newly created menu. * * \threadsafety This function should be called on the thread that created the * tray. * * \since This function is available since SDL 3.2.0. * * \sa SDL_InsertTrayEntryAt * \sa SDL_CreateTraySubmenu */ extern SDL_DECLSPEC SDL_TrayMenu * SDLCALL SDL_GetTraySubmenu(SDL_TrayEntry *entry); /** * Returns a list of entries in the menu, in order. * * \param menu The menu to get entries from. * \param count An optional pointer to obtain the number of entries in the * menu. * \returns a NULL-terminated list of entries within the given menu. The * pointer becomes invalid when any function that inserts or deletes * entries in the menu is called. * * \threadsafety This function should be called on the thread that created the * tray. * * \since This function is available since SDL 3.2.0. * * \sa SDL_RemoveTrayEntry * \sa SDL_InsertTrayEntryAt */ extern SDL_DECLSPEC const SDL_TrayEntry ** SDLCALL SDL_GetTrayEntries(SDL_TrayMenu *menu, int *count); /** * Removes a tray entry. * * \param entry The entry to be deleted. * * \threadsafety This function should be called on the thread that created the * tray. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetTrayEntries * \sa SDL_InsertTrayEntryAt */ extern SDL_DECLSPEC void SDLCALL SDL_RemoveTrayEntry(SDL_TrayEntry *entry); /** * Insert a tray entry at a given position. * * If label is NULL, the entry will be a separator. Many functions won't work * for an entry that is a separator. * * An entry does not need to be destroyed; it will be destroyed with the tray. * * \param menu the menu to append the entry to. * \param pos the desired position for the new entry. Entries at or following * this place will be moved. If pos is -1, the entry is appended. * \param label the text to be displayed on the entry, in UTF-8 encoding, or * NULL for a separator. * \param flags a combination of flags, some of which are mandatory. * \returns the newly created entry, or NULL if pos is out of bounds. * * \threadsafety This function should be called on the thread that created the * tray. * * \since This function is available since SDL 3.2.0. * * \sa SDL_TrayEntryFlags * \sa SDL_GetTrayEntries * \sa SDL_RemoveTrayEntry * \sa SDL_GetTrayEntryParent */ extern SDL_DECLSPEC SDL_TrayEntry * SDLCALL SDL_InsertTrayEntryAt(SDL_TrayMenu *menu, int pos, const char *label, SDL_TrayEntryFlags flags); /** * Sets the label of an entry. * * An entry cannot change between a separator and an ordinary entry; that is, * it is not possible to set a non-NULL label on an entry that has a NULL * label (separators), or to set a NULL label to an entry that has a non-NULL * label. The function will silently fail if that happens. * * \param entry the entry to be updated. * \param label the new label for the entry in UTF-8 encoding. * * \threadsafety This function should be called on the thread that created the * tray. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetTrayEntries * \sa SDL_InsertTrayEntryAt * \sa SDL_GetTrayEntryLabel */ extern SDL_DECLSPEC void SDLCALL SDL_SetTrayEntryLabel(SDL_TrayEntry *entry, const char *label); /** * Gets the label of an entry. * * If the returned value is NULL, the entry is a separator. * * \param entry the entry to be read. * \returns the label of the entry in UTF-8 encoding. * * \threadsafety This function should be called on the thread that created the * tray. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetTrayEntries * \sa SDL_InsertTrayEntryAt * \sa SDL_SetTrayEntryLabel */ extern SDL_DECLSPEC const char * SDLCALL SDL_GetTrayEntryLabel(SDL_TrayEntry *entry); /** * Sets whether or not an entry is checked. * * The entry must have been created with the SDL_TRAYENTRY_CHECKBOX flag. * * \param entry the entry to be updated. * \param checked true if the entry should be checked; false otherwise. * * \threadsafety This function should be called on the thread that created the * tray. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetTrayEntries * \sa SDL_InsertTrayEntryAt * \sa SDL_GetTrayEntryChecked */ extern SDL_DECLSPEC void SDLCALL SDL_SetTrayEntryChecked(SDL_TrayEntry *entry, bool checked); /** * Gets whether or not an entry is checked. * * The entry must have been created with the SDL_TRAYENTRY_CHECKBOX flag. * * \param entry the entry to be read. * \returns true if the entry is checked; false otherwise. * * \threadsafety This function should be called on the thread that created the * tray. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetTrayEntries * \sa SDL_InsertTrayEntryAt * \sa SDL_SetTrayEntryChecked */ extern SDL_DECLSPEC bool SDLCALL SDL_GetTrayEntryChecked(SDL_TrayEntry *entry); /** * Sets whether or not an entry is enabled. * * \param entry the entry to be updated. * \param enabled true if the entry should be enabled; false otherwise. * * \threadsafety This function should be called on the thread that created the * tray. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetTrayEntries * \sa SDL_InsertTrayEntryAt * \sa SDL_GetTrayEntryEnabled */ extern SDL_DECLSPEC void SDLCALL SDL_SetTrayEntryEnabled(SDL_TrayEntry *entry, bool enabled); /** * Gets whether or not an entry is enabled. * * \param entry the entry to be read. * \returns true if the entry is enabled; false otherwise. * * \threadsafety This function should be called on the thread that created the * tray. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetTrayEntries * \sa SDL_InsertTrayEntryAt * \sa SDL_SetTrayEntryEnabled */ extern SDL_DECLSPEC bool SDLCALL SDL_GetTrayEntryEnabled(SDL_TrayEntry *entry); /** * Sets a callback to be invoked when the entry is selected. * * \param entry the entry to be updated. * \param callback a callback to be invoked when the entry is selected. * \param userdata an optional pointer to pass extra data to the callback when * it will be invoked. * * \threadsafety This function should be called on the thread that created the * tray. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetTrayEntries * \sa SDL_InsertTrayEntryAt */ extern SDL_DECLSPEC void SDLCALL SDL_SetTrayEntryCallback(SDL_TrayEntry *entry, SDL_TrayCallback callback, void *userdata); /** * Simulate a click on a tray entry. * * \param entry The entry to activate. * * \threadsafety This function should be called on the thread that created the * tray. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC void SDLCALL SDL_ClickTrayEntry(SDL_TrayEntry *entry); /** * Destroys a tray object. * * This also destroys all associated menus and entries. * * \param tray the tray icon to be destroyed. * * \threadsafety This function should be called on the thread that created the * tray. * * \since This function is available since SDL 3.2.0. * * \sa SDL_CreateTray */ extern SDL_DECLSPEC void SDLCALL SDL_DestroyTray(SDL_Tray *tray); /** * Gets the menu containing a certain tray entry. * * \param entry the entry for which to get the parent menu. * \returns the parent menu. * * \threadsafety This function should be called on the thread that created the * tray. * * \since This function is available since SDL 3.2.0. * * \sa SDL_InsertTrayEntryAt */ extern SDL_DECLSPEC SDL_TrayMenu * SDLCALL SDL_GetTrayEntryParent(SDL_TrayEntry *entry); /** * Gets the entry for which the menu is a submenu, if the current menu is a * submenu. * * Either this function or SDL_GetTrayMenuParentTray() will return non-NULL * for any given menu. * * \param menu the menu for which to get the parent entry. * \returns the parent entry, or NULL if this menu is not a submenu. * * \threadsafety This function should be called on the thread that created the * tray. * * \since This function is available since SDL 3.2.0. * * \sa SDL_CreateTraySubmenu * \sa SDL_GetTrayMenuParentTray */ extern SDL_DECLSPEC SDL_TrayEntry * SDLCALL SDL_GetTrayMenuParentEntry(SDL_TrayMenu *menu); /** * Gets the tray for which this menu is the first-level menu, if the current * menu isn't a submenu. * * Either this function or SDL_GetTrayMenuParentEntry() will return non-NULL * for any given menu. * * \param menu the menu for which to get the parent enttrayry. * \returns the parent tray, or NULL if this menu is a submenu. * * \threadsafety This function should be called on the thread that created the * tray. * * \since This function is available since SDL 3.2.0. * * \sa SDL_CreateTrayMenu * \sa SDL_GetTrayMenuParentEntry */ extern SDL_DECLSPEC SDL_Tray * SDLCALL SDL_GetTrayMenuParentTray(SDL_TrayMenu *menu); /** * Update the trays. * * This is called automatically by the event loop and is only needed if you're * using trays but aren't handling SDL events. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC void SDLCALL SDL_UpdateTrays(void); /* Ends C function definitions when using C++ */ #ifdef __cplusplus } #endif #include #endif /* SDL_tray_h_ */ ================================================ FILE: deps/include/SDL3/SDL_version.h ================================================ /* Simple DirectMedia Layer Copyright (C) 1997-2026 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ /** * # CategoryVersion * * Functionality to query the current SDL version, both as headers the app was * compiled against, and a library the app is linked to. */ #ifndef SDL_version_h_ #define SDL_version_h_ #include #include /* Set up for C function definitions, even when using C++ */ #ifdef __cplusplus extern "C" { #endif /** * The current major version of SDL headers. * * If this were SDL version 3.2.1, this value would be 3. * * \since This macro is available since SDL 3.2.0. */ #define SDL_MAJOR_VERSION 3 /** * The current minor version of the SDL headers. * * If this were SDL version 3.2.1, this value would be 2. * * \since This macro is available since SDL 3.2.0. */ #define SDL_MINOR_VERSION 4 /** * The current micro (or patchlevel) version of the SDL headers. * * If this were SDL version 3.2.1, this value would be 1. * * \since This macro is available since SDL 3.2.0. */ #define SDL_MICRO_VERSION 4 /** * This macro turns the version numbers into a numeric value. * * (1,2,3) becomes 1002003. * * \param major the major version number. * \param minor the minorversion number. * \param patch the patch version number. * * \since This macro is available since SDL 3.2.0. */ #define SDL_VERSIONNUM(major, minor, patch) \ ((major) * 1000000 + (minor) * 1000 + (patch)) /** * This macro extracts the major version from a version number * * 1002003 becomes 1. * * \param version the version number. * * \threadsafety It is safe to call this macro from any thread. * * \since This macro is available since SDL 3.2.0. */ #define SDL_VERSIONNUM_MAJOR(version) ((version) / 1000000) /** * This macro extracts the minor version from a version number * * 1002003 becomes 2. * * \param version the version number. * * \threadsafety It is safe to call this macro from any thread. * * \since This macro is available since SDL 3.2.0. */ #define SDL_VERSIONNUM_MINOR(version) (((version) / 1000) % 1000) /** * This macro extracts the micro version from a version number * * 1002003 becomes 3. * * \param version the version number. * * \threadsafety It is safe to call this macro from any thread. * * \since This macro is available since SDL 3.2.0. */ #define SDL_VERSIONNUM_MICRO(version) ((version) % 1000) /** * This is the version number macro for the current SDL version. * * \threadsafety It is safe to call this macro from any thread. * * \since This macro is available since SDL 3.2.0. * * \sa SDL_GetVersion */ #define SDL_VERSION \ SDL_VERSIONNUM(SDL_MAJOR_VERSION, SDL_MINOR_VERSION, SDL_MICRO_VERSION) /** * This macro will evaluate to true if compiled with SDL at least X.Y.Z. * * \threadsafety It is safe to call this macro from any thread. * * \since This macro is available since SDL 3.2.0. */ #define SDL_VERSION_ATLEAST(X, Y, Z) \ (SDL_VERSION >= SDL_VERSIONNUM(X, Y, Z)) /** * Get the version of SDL that is linked against your program. * * If you are linking to SDL dynamically, then it is possible that the current * version will be different than the version you compiled against. This * function returns the current version, while SDL_VERSION is the version you * compiled with. * * This function may be called safely at any time, even before SDL_Init(). * * \returns the version of the linked library. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetRevision */ extern SDL_DECLSPEC int SDLCALL SDL_GetVersion(void); /** * Get the code revision of the SDL library that is linked against your * program. * * This value is the revision of the code you are linking against and may be * different from the code you are compiling with, which is found in the * constant SDL_REVISION if you explicitly include SDL_revision.h * * The revision is an arbitrary string (a hash value) uniquely identifying the * exact revision of the SDL library in use, and is only useful in comparing * against other revisions. It is NOT an incrementing number. * * If SDL wasn't built from a git repository with the appropriate tools, this * will return an empty string. * * You shouldn't use this function for anything but logging it for debugging * purposes. The string is not intended to be reliable in any way. * * \returns an arbitrary string, uniquely identifying the exact revision of * the SDL library in use. * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetVersion */ extern SDL_DECLSPEC const char * SDLCALL SDL_GetRevision(void); /* Ends C function definitions when using C++ */ #ifdef __cplusplus } #endif #include #endif /* SDL_version_h_ */ ================================================ FILE: deps/include/SDL3/SDL_video.h ================================================ /* Simple DirectMedia Layer Copyright (C) 1997-2026 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ /** * # CategoryVideo * * SDL's video subsystem is largely interested in abstracting window * management from the underlying operating system. You can create windows, * manage them in various ways, set them fullscreen, and get events when * interesting things happen with them, such as the mouse or keyboard * interacting with a window. * * The video subsystem is also interested in abstracting away some * platform-specific differences in OpenGL: context creation, swapping * buffers, etc. This may be crucial to your app, but also you are not * required to use OpenGL at all. In fact, SDL can provide rendering to those * windows as well, either with an easy-to-use * [2D API](https://wiki.libsdl.org/SDL3/CategoryRender) * or with a more-powerful * [GPU API](https://wiki.libsdl.org/SDL3/CategoryGPU) * . Of course, it can simply get out of your way and give you the window * handles you need to use Vulkan, Direct3D, Metal, or whatever else you like * directly, too. * * The video subsystem covers a lot of functionality, out of necessity, so it * is worth perusing the list of functions just to see what's available, but * most apps can get by with simply creating a window and listening for * events, so start with SDL_CreateWindow() and SDL_PollEvent(). */ #ifndef SDL_video_h_ #define SDL_video_h_ #include #include #include #include #include #include #include /* Set up for C function definitions, even when using C++ */ #ifdef __cplusplus extern "C" { #endif /** * This is a unique ID for a display for the time it is connected to the * system, and is never reused for the lifetime of the application. * * If the display is disconnected and reconnected, it will get a new ID. * * The value 0 is an invalid ID. * * \since This datatype is available since SDL 3.2.0. */ typedef Uint32 SDL_DisplayID; /** * This is a unique ID for a window. * * The value 0 is an invalid ID. * * \since This datatype is available since SDL 3.2.0. */ typedef Uint32 SDL_WindowID; /* Global video properties... */ /** * The pointer to the global `wl_display` object used by the Wayland video * backend. * * Can be set before the video subsystem is initialized to import an external * `wl_display` object from an application or toolkit for use in SDL, or read * after initialization to export the `wl_display` used by the Wayland video * backend. Setting this property after the video subsystem has been * initialized has no effect, and reading it when the video subsystem is * uninitialized will either return the user provided value, if one was set * prior to initialization, or NULL. See docs/README-wayland.md for more * information. * * \since This macro is available since SDL 3.2.0. */ #define SDL_PROP_GLOBAL_VIDEO_WAYLAND_WL_DISPLAY_POINTER "SDL.video.wayland.wl_display" /** * System theme. * * \since This enum is available since SDL 3.2.0. */ typedef enum SDL_SystemTheme { SDL_SYSTEM_THEME_UNKNOWN, /**< Unknown system theme */ SDL_SYSTEM_THEME_LIGHT, /**< Light colored system theme */ SDL_SYSTEM_THEME_DARK /**< Dark colored system theme */ } SDL_SystemTheme; /** * Internal display mode data. * * This lives as a field in SDL_DisplayMode, as opaque data. * * \since This struct is available since SDL 3.2.0. * * \sa SDL_DisplayMode */ typedef struct SDL_DisplayModeData SDL_DisplayModeData; /** * The structure that defines a display mode. * * \since This struct is available since SDL 3.2.0. * * \sa SDL_GetFullscreenDisplayModes * \sa SDL_GetDesktopDisplayMode * \sa SDL_GetCurrentDisplayMode * \sa SDL_SetWindowFullscreenMode * \sa SDL_GetWindowFullscreenMode */ typedef struct SDL_DisplayMode { SDL_DisplayID displayID; /**< the display this mode is associated with */ SDL_PixelFormat format; /**< pixel format */ int w; /**< width */ int h; /**< height */ float pixel_density; /**< scale converting size to pixels (e.g. a 1920x1080 mode with 2.0 scale would have 3840x2160 pixels) */ float refresh_rate; /**< refresh rate (or 0.0f for unspecified) */ int refresh_rate_numerator; /**< precise refresh rate numerator (or 0 for unspecified) */ int refresh_rate_denominator; /**< precise refresh rate denominator */ SDL_DisplayModeData *internal; /**< Private */ } SDL_DisplayMode; /** * Display orientation values; the way a display is rotated. * * \since This enum is available since SDL 3.2.0. */ typedef enum SDL_DisplayOrientation { SDL_ORIENTATION_UNKNOWN, /**< The display orientation can't be determined */ SDL_ORIENTATION_LANDSCAPE, /**< The display is in landscape mode, with the right side up, relative to portrait mode */ SDL_ORIENTATION_LANDSCAPE_FLIPPED, /**< The display is in landscape mode, with the left side up, relative to portrait mode */ SDL_ORIENTATION_PORTRAIT, /**< The display is in portrait mode */ SDL_ORIENTATION_PORTRAIT_FLIPPED /**< The display is in portrait mode, upside down */ } SDL_DisplayOrientation; /** * The struct used as an opaque handle to a window. * * \since This struct is available since SDL 3.2.0. * * \sa SDL_CreateWindow */ typedef struct SDL_Window SDL_Window; /** * The flags on a window. * * These cover a lot of true/false, or on/off, window state. Some of it is * immutable after being set through SDL_CreateWindow(), some of it can be * changed on existing windows by the app, and some of it might be altered by * the user or system outside of the app's control. * * When creating windows with `SDL_WINDOW_RESIZABLE`, SDL will constrain * resizable windows to the dimensions recommended by the compositor to fit it * within the usable desktop space, although some compositors will do this * automatically without intervention as well. Use `SDL_SetWindowResizable` * after creation instead if you wish to create a window with a specific size. * * \since This datatype is available since SDL 3.2.0. * * \sa SDL_GetWindowFlags */ typedef Uint64 SDL_WindowFlags; #define SDL_WINDOW_FULLSCREEN SDL_UINT64_C(0x0000000000000001) /**< window is in fullscreen mode */ #define SDL_WINDOW_OPENGL SDL_UINT64_C(0x0000000000000002) /**< window usable with OpenGL context */ #define SDL_WINDOW_OCCLUDED SDL_UINT64_C(0x0000000000000004) /**< window is occluded */ #define SDL_WINDOW_HIDDEN SDL_UINT64_C(0x0000000000000008) /**< window is neither mapped onto the desktop nor shown in the taskbar/dock/window list; SDL_ShowWindow() is required for it to become visible */ #define SDL_WINDOW_BORDERLESS SDL_UINT64_C(0x0000000000000010) /**< no window decoration */ #define SDL_WINDOW_RESIZABLE SDL_UINT64_C(0x0000000000000020) /**< window can be resized */ #define SDL_WINDOW_MINIMIZED SDL_UINT64_C(0x0000000000000040) /**< window is minimized */ #define SDL_WINDOW_MAXIMIZED SDL_UINT64_C(0x0000000000000080) /**< window is maximized */ #define SDL_WINDOW_MOUSE_GRABBED SDL_UINT64_C(0x0000000000000100) /**< window has grabbed mouse input */ #define SDL_WINDOW_INPUT_FOCUS SDL_UINT64_C(0x0000000000000200) /**< window has input focus */ #define SDL_WINDOW_MOUSE_FOCUS SDL_UINT64_C(0x0000000000000400) /**< window has mouse focus */ #define SDL_WINDOW_EXTERNAL SDL_UINT64_C(0x0000000000000800) /**< window not created by SDL */ #define SDL_WINDOW_MODAL SDL_UINT64_C(0x0000000000001000) /**< window is modal */ #define SDL_WINDOW_HIGH_PIXEL_DENSITY SDL_UINT64_C(0x0000000000002000) /**< window uses high pixel density back buffer if possible */ #define SDL_WINDOW_MOUSE_CAPTURE SDL_UINT64_C(0x0000000000004000) /**< window has mouse captured (unrelated to MOUSE_GRABBED) */ #define SDL_WINDOW_MOUSE_RELATIVE_MODE SDL_UINT64_C(0x0000000000008000) /**< window has relative mode enabled */ #define SDL_WINDOW_ALWAYS_ON_TOP SDL_UINT64_C(0x0000000000010000) /**< window should always be above others */ #define SDL_WINDOW_UTILITY SDL_UINT64_C(0x0000000000020000) /**< window should be treated as a utility window, not showing in the task bar and window list */ #define SDL_WINDOW_TOOLTIP SDL_UINT64_C(0x0000000000040000) /**< window should be treated as a tooltip and does not get mouse or keyboard focus, requires a parent window */ #define SDL_WINDOW_POPUP_MENU SDL_UINT64_C(0x0000000000080000) /**< window should be treated as a popup menu, requires a parent window */ #define SDL_WINDOW_KEYBOARD_GRABBED SDL_UINT64_C(0x0000000000100000) /**< window has grabbed keyboard input */ #define SDL_WINDOW_FILL_DOCUMENT SDL_UINT64_C(0x0000000000200000) /**< window is in fill-document mode (Emscripten only), since SDL 3.4.0 */ #define SDL_WINDOW_VULKAN SDL_UINT64_C(0x0000000010000000) /**< window usable for Vulkan surface */ #define SDL_WINDOW_METAL SDL_UINT64_C(0x0000000020000000) /**< window usable for Metal view */ #define SDL_WINDOW_TRANSPARENT SDL_UINT64_C(0x0000000040000000) /**< window with transparent buffer */ #define SDL_WINDOW_NOT_FOCUSABLE SDL_UINT64_C(0x0000000080000000) /**< window should not be focusable */ /** * A magic value used with SDL_WINDOWPOS_UNDEFINED. * * Generally this macro isn't used directly, but rather through * SDL_WINDOWPOS_UNDEFINED or SDL_WINDOWPOS_UNDEFINED_DISPLAY. * * \since This macro is available since SDL 3.2.0. * * \sa SDL_SetWindowPosition */ #define SDL_WINDOWPOS_UNDEFINED_MASK 0x1FFF0000u /** * Used to indicate that you don't care what the window position is. * * If you _really_ don't care, SDL_WINDOWPOS_UNDEFINED is the same, but always * uses the primary display instead of specifying one. * * \param X the SDL_DisplayID of the display to use. * * \since This macro is available since SDL 3.2.0. * * \sa SDL_SetWindowPosition */ #define SDL_WINDOWPOS_UNDEFINED_DISPLAY(X) (SDL_WINDOWPOS_UNDEFINED_MASK|(X)) /** * Used to indicate that you don't care what the window position/display is. * * This always uses the primary display. * * \since This macro is available since SDL 3.2.0. * * \sa SDL_SetWindowPosition */ #define SDL_WINDOWPOS_UNDEFINED SDL_WINDOWPOS_UNDEFINED_DISPLAY(0) /** * A macro to test if the window position is marked as "undefined." * * \param X the window position value. * * \since This macro is available since SDL 3.2.0. * * \sa SDL_SetWindowPosition */ #define SDL_WINDOWPOS_ISUNDEFINED(X) (((X)&0xFFFF0000) == SDL_WINDOWPOS_UNDEFINED_MASK) /** * A magic value used with SDL_WINDOWPOS_CENTERED. * * Generally this macro isn't used directly, but rather through * SDL_WINDOWPOS_CENTERED or SDL_WINDOWPOS_CENTERED_DISPLAY. * * \since This macro is available since SDL 3.2.0. * * \sa SDL_SetWindowPosition */ #define SDL_WINDOWPOS_CENTERED_MASK 0x2FFF0000u /** * Used to indicate that the window position should be centered. * * SDL_WINDOWPOS_CENTERED is the same, but always uses the primary display * instead of specifying one. * * \param X the SDL_DisplayID of the display to use. * * \since This macro is available since SDL 3.2.0. * * \sa SDL_SetWindowPosition */ #define SDL_WINDOWPOS_CENTERED_DISPLAY(X) (SDL_WINDOWPOS_CENTERED_MASK|(X)) /** * Used to indicate that the window position should be centered. * * This always uses the primary display. * * \since This macro is available since SDL 3.2.0. * * \sa SDL_SetWindowPosition */ #define SDL_WINDOWPOS_CENTERED SDL_WINDOWPOS_CENTERED_DISPLAY(0) /** * A macro to test if the window position is marked as "centered." * * \param X the window position value. * * \since This macro is available since SDL 3.2.0. * * \sa SDL_GetWindowPosition */ #define SDL_WINDOWPOS_ISCENTERED(X) \ (((X)&0xFFFF0000) == SDL_WINDOWPOS_CENTERED_MASK) /** * Window flash operation. * * \since This enum is available since SDL 3.2.0. */ typedef enum SDL_FlashOperation { SDL_FLASH_CANCEL, /**< Cancel any window flash state */ SDL_FLASH_BRIEFLY, /**< Flash the window briefly to get attention */ SDL_FLASH_UNTIL_FOCUSED /**< Flash the window until it gets focus */ } SDL_FlashOperation; /** * Window progress state * * \since This enum is available since SDL 3.2.8. */ typedef enum SDL_ProgressState { SDL_PROGRESS_STATE_INVALID = -1, /**< An invalid progress state indicating an error; check SDL_GetError() */ SDL_PROGRESS_STATE_NONE, /**< No progress bar is shown */ SDL_PROGRESS_STATE_INDETERMINATE, /**< The progress bar is shown in a indeterminate state */ SDL_PROGRESS_STATE_NORMAL, /**< The progress bar is shown in a normal state */ SDL_PROGRESS_STATE_PAUSED, /**< The progress bar is shown in a paused state */ SDL_PROGRESS_STATE_ERROR /**< The progress bar is shown in a state indicating the application had an error */ } SDL_ProgressState; /** * An opaque handle to an OpenGL context. * * \since This datatype is available since SDL 3.2.0. * * \sa SDL_GL_CreateContext * \sa SDL_GL_SetAttribute * \sa SDL_GL_MakeCurrent * \sa SDL_GL_DestroyContext */ typedef struct SDL_GLContextState *SDL_GLContext; /** * Opaque type for an EGL display. * * \since This datatype is available since SDL 3.2.0. */ typedef void *SDL_EGLDisplay; /** * Opaque type for an EGL config. * * \since This datatype is available since SDL 3.2.0. */ typedef void *SDL_EGLConfig; /** * Opaque type for an EGL surface. * * \since This datatype is available since SDL 3.2.0. */ typedef void *SDL_EGLSurface; /** * An EGL attribute, used when creating an EGL context. * * \since This datatype is available since SDL 3.2.0. */ typedef intptr_t SDL_EGLAttrib; /** * An EGL integer attribute, used when creating an EGL surface. * * \since This datatype is available since SDL 3.2.0. */ typedef int SDL_EGLint; /** * EGL platform attribute initialization callback. * * This is called when SDL is attempting to create an EGL context, to let the * app add extra attributes to its eglGetPlatformDisplay() call. * * The callback should return a pointer to an EGL attribute array terminated * with `EGL_NONE`. If this function returns NULL, the SDL_CreateWindow * process will fail gracefully. * * The returned pointer should be allocated with SDL_malloc() and will be * passed to SDL_free(). * * The arrays returned by each callback will be appended to the existing * attribute arrays defined by SDL. * * \param userdata an app-controlled pointer that is passed to the callback. * \returns a newly-allocated array of attributes, terminated with `EGL_NONE`. * * \since This datatype is available since SDL 3.2.0. * * \sa SDL_EGL_SetAttributeCallbacks */ typedef SDL_EGLAttrib *(SDLCALL *SDL_EGLAttribArrayCallback)(void *userdata); /** * EGL surface/context attribute initialization callback types. * * This is called when SDL is attempting to create an EGL surface, to let the * app add extra attributes to its eglCreateWindowSurface() or * eglCreateContext calls. * * For convenience, the EGLDisplay and EGLConfig to use are provided to the * callback. * * The callback should return a pointer to an EGL attribute array terminated * with `EGL_NONE`. If this function returns NULL, the SDL_CreateWindow * process will fail gracefully. * * The returned pointer should be allocated with SDL_malloc() and will be * passed to SDL_free(). * * The arrays returned by each callback will be appended to the existing * attribute arrays defined by SDL. * * \param userdata an app-controlled pointer that is passed to the callback. * \param display the EGL display to be used. * \param config the EGL config to be used. * \returns a newly-allocated array of attributes, terminated with `EGL_NONE`. * * \since This datatype is available since SDL 3.2.0. * * \sa SDL_EGL_SetAttributeCallbacks */ typedef SDL_EGLint *(SDLCALL *SDL_EGLIntArrayCallback)(void *userdata, SDL_EGLDisplay display, SDL_EGLConfig config); /** * An enumeration of OpenGL configuration attributes. * * While you can set most OpenGL attributes normally, the attributes listed * above must be known before SDL creates the window that will be used with * the OpenGL context. These attributes are set and read with * SDL_GL_SetAttribute() and SDL_GL_GetAttribute(). * * In some cases, these attributes are minimum requests; the GL does not * promise to give you exactly what you asked for. It's possible to ask for a * 16-bit depth buffer and get a 24-bit one instead, for example, or to ask * for no stencil buffer and still have one available. Context creation should * fail if the GL can't provide your requested attributes at a minimum, but * you should check to see exactly what you got. * * \since This enum is available since SDL 3.2.0. */ typedef enum SDL_GLAttr { SDL_GL_RED_SIZE, /**< the minimum number of bits for the red channel of the color buffer; defaults to 8. */ SDL_GL_GREEN_SIZE, /**< the minimum number of bits for the green channel of the color buffer; defaults to 8. */ SDL_GL_BLUE_SIZE, /**< the minimum number of bits for the blue channel of the color buffer; defaults to 8. */ SDL_GL_ALPHA_SIZE, /**< the minimum number of bits for the alpha channel of the color buffer; defaults to 8. */ SDL_GL_BUFFER_SIZE, /**< the minimum number of bits for frame buffer size; defaults to 0. */ SDL_GL_DOUBLEBUFFER, /**< whether the output is single or double buffered; defaults to double buffering on. */ SDL_GL_DEPTH_SIZE, /**< the minimum number of bits in the depth buffer; defaults to 16. */ SDL_GL_STENCIL_SIZE, /**< the minimum number of bits in the stencil buffer; defaults to 0. */ SDL_GL_ACCUM_RED_SIZE, /**< the minimum number of bits for the red channel of the accumulation buffer; defaults to 0. */ SDL_GL_ACCUM_GREEN_SIZE, /**< the minimum number of bits for the green channel of the accumulation buffer; defaults to 0. */ SDL_GL_ACCUM_BLUE_SIZE, /**< the minimum number of bits for the blue channel of the accumulation buffer; defaults to 0. */ SDL_GL_ACCUM_ALPHA_SIZE, /**< the minimum number of bits for the alpha channel of the accumulation buffer; defaults to 0. */ SDL_GL_STEREO, /**< whether the output is stereo 3D; defaults to off. */ SDL_GL_MULTISAMPLEBUFFERS, /**< the number of buffers used for multisample anti-aliasing; defaults to 0. */ SDL_GL_MULTISAMPLESAMPLES, /**< the number of samples used around the current pixel used for multisample anti-aliasing. */ SDL_GL_ACCELERATED_VISUAL, /**< set to 1 to require hardware acceleration, set to 0 to force software rendering; defaults to allow either. */ SDL_GL_RETAINED_BACKING, /**< not used (deprecated). */ SDL_GL_CONTEXT_MAJOR_VERSION, /**< OpenGL context major version. */ SDL_GL_CONTEXT_MINOR_VERSION, /**< OpenGL context minor version. */ SDL_GL_CONTEXT_FLAGS, /**< some combination of 0 or more of elements of the SDL_GLContextFlag enumeration; defaults to 0. */ SDL_GL_CONTEXT_PROFILE_MASK, /**< type of GL context (Core, Compatibility, ES). See SDL_GLProfile; default value depends on platform. */ SDL_GL_SHARE_WITH_CURRENT_CONTEXT, /**< OpenGL context sharing; defaults to 0. */ SDL_GL_FRAMEBUFFER_SRGB_CAPABLE, /**< requests sRGB-capable visual if 1. Defaults to -1 ("don't care"). This is a request; GL drivers might not comply! */ SDL_GL_CONTEXT_RELEASE_BEHAVIOR, /**< sets context the release behavior. See SDL_GLContextReleaseFlag; defaults to FLUSH. */ SDL_GL_CONTEXT_RESET_NOTIFICATION, /**< set context reset notification. See SDL_GLContextResetNotification; defaults to NO_NOTIFICATION. */ SDL_GL_CONTEXT_NO_ERROR, SDL_GL_FLOATBUFFERS, SDL_GL_EGL_PLATFORM } SDL_GLAttr; /** * Possible values to be set for the SDL_GL_CONTEXT_PROFILE_MASK attribute. * * \since This datatype is available since SDL 3.2.0. */ typedef Uint32 SDL_GLProfile; #define SDL_GL_CONTEXT_PROFILE_CORE 0x0001 /**< OpenGL Core Profile context */ #define SDL_GL_CONTEXT_PROFILE_COMPATIBILITY 0x0002 /**< OpenGL Compatibility Profile context */ #define SDL_GL_CONTEXT_PROFILE_ES 0x0004 /**< GLX_CONTEXT_ES2_PROFILE_BIT_EXT */ /** * Possible flags to be set for the SDL_GL_CONTEXT_FLAGS attribute. * * \since This datatype is available since SDL 3.2.0. */ typedef Uint32 SDL_GLContextFlag; #define SDL_GL_CONTEXT_DEBUG_FLAG 0x0001 #define SDL_GL_CONTEXT_FORWARD_COMPATIBLE_FLAG 0x0002 #define SDL_GL_CONTEXT_ROBUST_ACCESS_FLAG 0x0004 #define SDL_GL_CONTEXT_RESET_ISOLATION_FLAG 0x0008 /** * Possible values to be set for the SDL_GL_CONTEXT_RELEASE_BEHAVIOR * attribute. * * \since This datatype is available since SDL 3.2.0. */ typedef Uint32 SDL_GLContextReleaseFlag; #define SDL_GL_CONTEXT_RELEASE_BEHAVIOR_NONE 0x0000 #define SDL_GL_CONTEXT_RELEASE_BEHAVIOR_FLUSH 0x0001 /** * Possible values to be set SDL_GL_CONTEXT_RESET_NOTIFICATION attribute. * * \since This datatype is available since SDL 3.2.0. */ typedef Uint32 SDL_GLContextResetNotification; #define SDL_GL_CONTEXT_RESET_NO_NOTIFICATION 0x0000 #define SDL_GL_CONTEXT_RESET_LOSE_CONTEXT 0x0001 /* Function prototypes */ /** * Get the number of video drivers compiled into SDL. * * \returns the number of built in video drivers. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetVideoDriver */ extern SDL_DECLSPEC int SDLCALL SDL_GetNumVideoDrivers(void); /** * Get the name of a built in video driver. * * The video drivers are presented in the order in which they are normally * checked during initialization. * * The names of drivers are all simple, low-ASCII identifiers, like "cocoa", * "x11" or "windows". These never have Unicode characters, and are not meant * to be proper names. * * \param index the index of a video driver. * \returns the name of the video driver with the given **index**, or NULL if * index is out of bounds. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetNumVideoDrivers */ extern SDL_DECLSPEC const char * SDLCALL SDL_GetVideoDriver(int index); /** * Get the name of the currently initialized video driver. * * The names of drivers are all simple, low-ASCII identifiers, like "cocoa", * "x11" or "windows". These never have Unicode characters, and are not meant * to be proper names. * * \returns the name of the current video driver or NULL if no driver has been * initialized. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetNumVideoDrivers * \sa SDL_GetVideoDriver */ extern SDL_DECLSPEC const char * SDLCALL SDL_GetCurrentVideoDriver(void); /** * Get the current system theme. * * \returns the current system theme, light, dark, or unknown. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC SDL_SystemTheme SDLCALL SDL_GetSystemTheme(void); /** * Get a list of currently connected displays. * * \param count a pointer filled in with the number of displays returned, may * be NULL. * \returns a 0 terminated array of display instance IDs or NULL on failure; * call SDL_GetError() for more information. This should be freed * with SDL_free() when it is no longer needed. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC SDL_DisplayID * SDLCALL SDL_GetDisplays(int *count); /** * Return the primary display. * * \returns the instance ID of the primary display on success or 0 on failure; * call SDL_GetError() for more information. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetDisplays */ extern SDL_DECLSPEC SDL_DisplayID SDLCALL SDL_GetPrimaryDisplay(void); /** * Get the properties associated with a display. * * The following read-only properties are provided by SDL: * * - `SDL_PROP_DISPLAY_HDR_ENABLED_BOOLEAN`: true if the display has HDR * headroom above the SDR white point. This is for informational and * diagnostic purposes only, as not all platforms provide this information * at the display level. * * On KMS/DRM: * * - `SDL_PROP_DISPLAY_KMSDRM_PANEL_ORIENTATION_NUMBER`: the "panel * orientation" property for the display in degrees of clockwise rotation. * Note that this is provided only as a hint, and the application is * responsible for any coordinate transformations needed to conform to the * requested display orientation. * * On Wayland: * * - `SDL_PROP_DISPLAY_WAYLAND_WL_OUTPUT_POINTER`: the wl_output associated * with the display * * On Windows: * * - `SDL_PROP_DISPLAY_WINDOWS_HMONITOR_POINTER`: the monitor handle * (HMONITOR) associated with the display * * \param displayID the instance ID of the display to query. * \returns a valid property ID on success or 0 on failure; call * SDL_GetError() for more information. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC SDL_PropertiesID SDLCALL SDL_GetDisplayProperties(SDL_DisplayID displayID); #define SDL_PROP_DISPLAY_HDR_ENABLED_BOOLEAN "SDL.display.HDR_enabled" #define SDL_PROP_DISPLAY_KMSDRM_PANEL_ORIENTATION_NUMBER "SDL.display.KMSDRM.panel_orientation" #define SDL_PROP_DISPLAY_WAYLAND_WL_OUTPUT_POINTER "SDL.display.wayland.wl_output" #define SDL_PROP_DISPLAY_WINDOWS_HMONITOR_POINTER "SDL.display.windows.hmonitor" /** * Get the name of a display in UTF-8 encoding. * * \param displayID the instance ID of the display to query. * \returns the name of a display or NULL on failure; call SDL_GetError() for * more information. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetDisplays */ extern SDL_DECLSPEC const char * SDLCALL SDL_GetDisplayName(SDL_DisplayID displayID); /** * Get the desktop area represented by a display. * * The primary display is often located at (0,0), but may be placed at a * different location depending on monitor layout. * * \param displayID the instance ID of the display to query. * \param rect the SDL_Rect structure filled in with the display bounds. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetDisplayUsableBounds * \sa SDL_GetDisplays */ extern SDL_DECLSPEC bool SDLCALL SDL_GetDisplayBounds(SDL_DisplayID displayID, SDL_Rect *rect); /** * Get the usable desktop area represented by a display, in screen * coordinates. * * This is the same area as SDL_GetDisplayBounds() reports, but with portions * reserved by the system removed. For example, on Apple's macOS, this * subtracts the area occupied by the menu bar and dock. * * Setting a window to be fullscreen generally bypasses these unusable areas, * so these are good guidelines for the maximum space available to a * non-fullscreen window. * * \param displayID the instance ID of the display to query. * \param rect the SDL_Rect structure filled in with the display bounds. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetDisplayBounds * \sa SDL_GetDisplays */ extern SDL_DECLSPEC bool SDLCALL SDL_GetDisplayUsableBounds(SDL_DisplayID displayID, SDL_Rect *rect); /** * Get the orientation of a display when it is unrotated. * * \param displayID the instance ID of the display to query. * \returns the SDL_DisplayOrientation enum value of the display, or * `SDL_ORIENTATION_UNKNOWN` if it isn't available. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetDisplays */ extern SDL_DECLSPEC SDL_DisplayOrientation SDLCALL SDL_GetNaturalDisplayOrientation(SDL_DisplayID displayID); /** * Get the orientation of a display. * * \param displayID the instance ID of the display to query. * \returns the SDL_DisplayOrientation enum value of the display, or * `SDL_ORIENTATION_UNKNOWN` if it isn't available. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetDisplays */ extern SDL_DECLSPEC SDL_DisplayOrientation SDLCALL SDL_GetCurrentDisplayOrientation(SDL_DisplayID displayID); /** * Get the content scale of a display. * * The content scale is the expected scale for content based on the DPI * settings of the display. For example, a 4K display might have a 2.0 (200%) * display scale, which means that the user expects UI elements to be twice as * big on this display, to aid in readability. * * After window creation, SDL_GetWindowDisplayScale() should be used to query * the content scale factor for individual windows instead of querying the * display for a window and calling this function, as the per-window content * scale factor may differ from the base value of the display it is on, * particularly on high-DPI and/or multi-monitor desktop configurations. * * \param displayID the instance ID of the display to query. * \returns the content scale of the display, or 0.0f on failure; call * SDL_GetError() for more information. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetWindowDisplayScale * \sa SDL_GetDisplays */ extern SDL_DECLSPEC float SDLCALL SDL_GetDisplayContentScale(SDL_DisplayID displayID); /** * Get a list of fullscreen display modes available on a display. * * The display modes are sorted in this priority: * * - w -> largest to smallest * - h -> largest to smallest * - bits per pixel -> more colors to fewer colors * - packed pixel layout -> largest to smallest * - refresh rate -> highest to lowest * - pixel density -> lowest to highest * * \param displayID the instance ID of the display to query. * \param count a pointer filled in with the number of display modes returned, * may be NULL. * \returns a NULL terminated array of display mode pointers or NULL on * failure; call SDL_GetError() for more information. This is a * single allocation that should be freed with SDL_free() when it is * no longer needed. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetDisplays */ extern SDL_DECLSPEC SDL_DisplayMode ** SDLCALL SDL_GetFullscreenDisplayModes(SDL_DisplayID displayID, int *count); /** * Get the closest match to the requested display mode. * * The available display modes are scanned and `closest` is filled in with the * closest mode matching the requested mode and returned. The mode format and * refresh rate default to the desktop mode if they are set to 0. The modes * are scanned with size being first priority, format being second priority, * and finally checking the refresh rate. If all the available modes are too * small, then false is returned. * * \param displayID the instance ID of the display to query. * \param w the width in pixels of the desired display mode. * \param h the height in pixels of the desired display mode. * \param refresh_rate the refresh rate of the desired display mode, or 0.0f * for the desktop refresh rate. * \param include_high_density_modes boolean to include high density modes in * the search. * \param closest a pointer filled in with the closest display mode equal to * or larger than the desired mode. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetDisplays * \sa SDL_GetFullscreenDisplayModes */ extern SDL_DECLSPEC bool SDLCALL SDL_GetClosestFullscreenDisplayMode(SDL_DisplayID displayID, int w, int h, float refresh_rate, bool include_high_density_modes, SDL_DisplayMode *closest); /** * Get information about the desktop's display mode. * * There's a difference between this function and SDL_GetCurrentDisplayMode() * when SDL runs fullscreen and has changed the resolution. In that case this * function will return the previous native display mode, and not the current * display mode. * * \param displayID the instance ID of the display to query. * \returns a pointer to the desktop display mode or NULL on failure; call * SDL_GetError() for more information. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetCurrentDisplayMode * \sa SDL_GetDisplays */ extern SDL_DECLSPEC const SDL_DisplayMode * SDLCALL SDL_GetDesktopDisplayMode(SDL_DisplayID displayID); /** * Get information about the current display mode. * * There's a difference between this function and SDL_GetDesktopDisplayMode() * when SDL runs fullscreen and has changed the resolution. In that case this * function will return the current display mode, and not the previous native * display mode. * * \param displayID the instance ID of the display to query. * \returns a pointer to the desktop display mode or NULL on failure; call * SDL_GetError() for more information. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetDesktopDisplayMode * \sa SDL_GetDisplays */ extern SDL_DECLSPEC const SDL_DisplayMode * SDLCALL SDL_GetCurrentDisplayMode(SDL_DisplayID displayID); /** * Get the display containing a point. * * \param point the point to query. * \returns the instance ID of the display containing the point or 0 on * failure; call SDL_GetError() for more information. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetDisplayBounds * \sa SDL_GetDisplays */ extern SDL_DECLSPEC SDL_DisplayID SDLCALL SDL_GetDisplayForPoint(const SDL_Point *point); /** * Get the display primarily containing a rect. * * \param rect the rect to query. * \returns the instance ID of the display entirely containing the rect or * closest to the center of the rect on success or 0 on failure; call * SDL_GetError() for more information. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetDisplayBounds * \sa SDL_GetDisplays */ extern SDL_DECLSPEC SDL_DisplayID SDLCALL SDL_GetDisplayForRect(const SDL_Rect *rect); /** * Get the display associated with a window. * * \param window the window to query. * \returns the instance ID of the display containing the center of the window * on success or 0 on failure; call SDL_GetError() for more * information. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetDisplayBounds * \sa SDL_GetDisplays */ extern SDL_DECLSPEC SDL_DisplayID SDLCALL SDL_GetDisplayForWindow(SDL_Window *window); /** * Get the pixel density of a window. * * This is a ratio of pixel size to window size. For example, if the window is * 1920x1080 and it has a high density back buffer of 3840x2160 pixels, it * would have a pixel density of 2.0. * * \param window the window to query. * \returns the pixel density or 0.0f on failure; call SDL_GetError() for more * information. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetWindowDisplayScale */ extern SDL_DECLSPEC float SDLCALL SDL_GetWindowPixelDensity(SDL_Window *window); /** * Get the content display scale relative to a window's pixel size. * * This is a combination of the window pixel density and the display content * scale, and is the expected scale for displaying content in this window. For * example, if a 3840x2160 window had a display scale of 2.0, the user expects * the content to take twice as many pixels and be the same physical size as * if it were being displayed in a 1920x1080 window with a display scale of * 1.0. * * Conceptually this value corresponds to the scale display setting, and is * updated when that setting is changed, or the window moves to a display with * a different scale setting. * * \param window the window to query. * \returns the display scale, or 0.0f on failure; call SDL_GetError() for * more information. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC float SDLCALL SDL_GetWindowDisplayScale(SDL_Window *window); /** * Set the display mode to use when a window is visible and fullscreen. * * This only affects the display mode used when the window is fullscreen. To * change the window size when the window is not fullscreen, use * SDL_SetWindowSize(). * * If the window is currently in the fullscreen state, this request is * asynchronous on some windowing systems and the new mode dimensions may not * be applied immediately upon the return of this function. If an immediate * change is required, call SDL_SyncWindow() to block until the changes have * taken effect. * * When the new mode takes effect, an SDL_EVENT_WINDOW_RESIZED and/or an * SDL_EVENT_WINDOW_PIXEL_SIZE_CHANGED event will be emitted with the new mode * dimensions. * * \param window the window to affect. * \param mode a pointer to the display mode to use, which can be NULL for * borderless fullscreen desktop mode, or one of the fullscreen * modes returned by SDL_GetFullscreenDisplayModes() to set an * exclusive fullscreen mode. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetWindowFullscreenMode * \sa SDL_SetWindowFullscreen * \sa SDL_SyncWindow */ extern SDL_DECLSPEC bool SDLCALL SDL_SetWindowFullscreenMode(SDL_Window *window, const SDL_DisplayMode *mode); /** * Query the display mode to use when a window is visible at fullscreen. * * \param window the window to query. * \returns a pointer to the exclusive fullscreen mode to use or NULL for * borderless fullscreen desktop mode. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_SetWindowFullscreenMode * \sa SDL_SetWindowFullscreen */ extern SDL_DECLSPEC const SDL_DisplayMode * SDLCALL SDL_GetWindowFullscreenMode(SDL_Window *window); /** * Get the raw ICC profile data for the screen the window is currently on. * * \param window the window to query. * \param size the size of the ICC profile. * \returns the raw ICC profile data on success or NULL on failure; call * SDL_GetError() for more information. This should be freed with * SDL_free() when it is no longer needed. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC void * SDLCALL SDL_GetWindowICCProfile(SDL_Window *window, size_t *size); /** * Get the pixel format associated with the window. * * \param window the window to query. * \returns the pixel format of the window on success or * SDL_PIXELFORMAT_UNKNOWN on failure; call SDL_GetError() for more * information. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC SDL_PixelFormat SDLCALL SDL_GetWindowPixelFormat(SDL_Window *window); /** * Get a list of valid windows. * * \param count a pointer filled in with the number of windows returned, may * be NULL. * \returns a NULL terminated array of SDL_Window pointers or NULL on failure; * call SDL_GetError() for more information. This is a single * allocation that should be freed with SDL_free() when it is no * longer needed. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC SDL_Window ** SDLCALL SDL_GetWindows(int *count); /** * Create a window with the specified dimensions and flags. * * The window size is a request and may be different than expected based on * the desktop layout and window manager policies. Your application should be * prepared to handle a window of any size. * * `flags` may be any of the following OR'd together: * * - `SDL_WINDOW_FULLSCREEN`: fullscreen window at desktop resolution * - `SDL_WINDOW_OPENGL`: window usable with an OpenGL context * - `SDL_WINDOW_HIDDEN`: window is not visible * - `SDL_WINDOW_BORDERLESS`: no window decoration * - `SDL_WINDOW_RESIZABLE`: window can be resized * - `SDL_WINDOW_MINIMIZED`: window is minimized * - `SDL_WINDOW_MAXIMIZED`: window is maximized * - `SDL_WINDOW_MOUSE_GRABBED`: window has grabbed mouse focus * - `SDL_WINDOW_INPUT_FOCUS`: window has input focus * - `SDL_WINDOW_MOUSE_FOCUS`: window has mouse focus * - `SDL_WINDOW_EXTERNAL`: window not created by SDL * - `SDL_WINDOW_MODAL`: window is modal * - `SDL_WINDOW_HIGH_PIXEL_DENSITY`: window uses high pixel density back * buffer if possible * - `SDL_WINDOW_MOUSE_CAPTURE`: window has mouse captured (unrelated to * MOUSE_GRABBED) * - `SDL_WINDOW_ALWAYS_ON_TOP`: window should always be above others * - `SDL_WINDOW_UTILITY`: window should be treated as a utility window, not * showing in the task bar and window list * - `SDL_WINDOW_TOOLTIP`: window should be treated as a tooltip and does not * get mouse or keyboard focus, requires a parent window * - `SDL_WINDOW_POPUP_MENU`: window should be treated as a popup menu, * requires a parent window * - `SDL_WINDOW_KEYBOARD_GRABBED`: window has grabbed keyboard input * - `SDL_WINDOW_VULKAN`: window usable with a Vulkan instance * - `SDL_WINDOW_METAL`: window usable with a Metal instance * - `SDL_WINDOW_TRANSPARENT`: window with transparent buffer * - `SDL_WINDOW_NOT_FOCUSABLE`: window should not be focusable * * The SDL_Window will be shown if SDL_WINDOW_HIDDEN is not set. If hidden at * creation time, SDL_ShowWindow() can be used to show it later. * * On Apple's macOS, you **must** set the NSHighResolutionCapable Info.plist * property to YES, otherwise you will not receive a High-DPI OpenGL canvas. * * The window pixel size may differ from its window coordinate size if the * window is on a high pixel density display. Use SDL_GetWindowSize() to query * the client area's size in window coordinates, and * SDL_GetWindowSizeInPixels() or SDL_GetRenderOutputSize() to query the * drawable size in pixels. Note that the drawable size can vary after the * window is created and should be queried again if you get an * SDL_EVENT_WINDOW_PIXEL_SIZE_CHANGED event. * * If the window is created with any of the SDL_WINDOW_OPENGL or * SDL_WINDOW_VULKAN flags, then the corresponding LoadLibrary function * (SDL_GL_LoadLibrary or SDL_Vulkan_LoadLibrary) is called and the * corresponding UnloadLibrary function is called by SDL_DestroyWindow(). * * If SDL_WINDOW_VULKAN is specified and there isn't a working Vulkan driver, * SDL_CreateWindow() will fail, because SDL_Vulkan_LoadLibrary() will fail. * * If SDL_WINDOW_METAL is specified on an OS that does not support Metal, * SDL_CreateWindow() will fail. * * If you intend to use this window with an SDL_Renderer, you should use * SDL_CreateWindowAndRenderer() instead of this function, to avoid window * flicker. * * On non-Apple devices, SDL requires you to either not link to the Vulkan * loader or link to a dynamic library version. This limitation may be removed * in a future version of SDL. * * \param title the title of the window, in UTF-8 encoding. * \param w the width of the window. * \param h the height of the window. * \param flags 0, or one or more SDL_WindowFlags OR'd together. * \returns the window that was created or NULL on failure; call * SDL_GetError() for more information. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_CreateWindowAndRenderer * \sa SDL_CreatePopupWindow * \sa SDL_CreateWindowWithProperties * \sa SDL_DestroyWindow */ extern SDL_DECLSPEC SDL_Window * SDLCALL SDL_CreateWindow(const char *title, int w, int h, SDL_WindowFlags flags); /** * Create a child popup window of the specified parent window. * * The window size is a request and may be different than expected based on * the desktop layout and window manager policies. Your application should be * prepared to handle a window of any size. * * The flags parameter **must** contain at least one of the following: * * - `SDL_WINDOW_TOOLTIP`: The popup window is a tooltip and will not pass any * input events. * - `SDL_WINDOW_POPUP_MENU`: The popup window is a popup menu. The topmost * popup menu will implicitly gain the keyboard focus. * * The following flags are not relevant to popup window creation and will be * ignored: * * - `SDL_WINDOW_MINIMIZED` * - `SDL_WINDOW_MAXIMIZED` * - `SDL_WINDOW_FULLSCREEN` * - `SDL_WINDOW_BORDERLESS` * * The following flags are incompatible with popup window creation and will * cause it to fail: * * - `SDL_WINDOW_UTILITY` * - `SDL_WINDOW_MODAL` * * The parent parameter **must** be non-null and a valid window. The parent of * a popup window can be either a regular, toplevel window, or another popup * window. * * Popup windows cannot be minimized, maximized, made fullscreen, raised, * flash, be made a modal window, be the parent of a toplevel window, or grab * the mouse and/or keyboard. Attempts to do so will fail. * * Popup windows implicitly do not have a border/decorations and do not appear * on the taskbar/dock or in lists of windows such as alt-tab menus. * * By default, popup window positions will automatically be constrained to * keep the entire window within display bounds. This can be overridden with * the `SDL_PROP_WINDOW_CREATE_CONSTRAIN_POPUP_BOOLEAN` property. * * By default, popup menus will automatically grab keyboard focus from the * parent when shown. This behavior can be overridden by setting the * `SDL_WINDOW_NOT_FOCUSABLE` flag, setting the * `SDL_PROP_WINDOW_CREATE_FOCUSABLE_BOOLEAN` property to false, or toggling * it after creation via the `SDL_SetWindowFocusable()` function. * * If a parent window is hidden or destroyed, any child popup windows will be * recursively hidden or destroyed as well. Child popup windows not explicitly * hidden will be restored when the parent is shown. * * \param parent the parent of the window, must not be NULL. * \param offset_x the x position of the popup window relative to the origin * of the parent. * \param offset_y the y position of the popup window relative to the origin * of the parent window. * \param w the width of the window. * \param h the height of the window. * \param flags SDL_WINDOW_TOOLTIP or SDL_WINDOW_POPUP_MENU, and zero or more * additional SDL_WindowFlags OR'd together. * \returns the window that was created or NULL on failure; call * SDL_GetError() for more information. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_CreateWindow * \sa SDL_CreateWindowWithProperties * \sa SDL_DestroyWindow * \sa SDL_GetWindowParent */ extern SDL_DECLSPEC SDL_Window * SDLCALL SDL_CreatePopupWindow(SDL_Window *parent, int offset_x, int offset_y, int w, int h, SDL_WindowFlags flags); /** * Create a window with the specified properties. * * The window size is a request and may be different than expected based on * the desktop layout and window manager policies. Your application should be * prepared to handle a window of any size. * * These are the supported properties: * * - `SDL_PROP_WINDOW_CREATE_ALWAYS_ON_TOP_BOOLEAN`: true if the window should * be always on top * - `SDL_PROP_WINDOW_CREATE_BORDERLESS_BOOLEAN`: true if the window has no * window decoration * - `SDL_PROP_WINDOW_CREATE_CONSTRAIN_POPUP_BOOLEAN`: true if the "tooltip" * and "menu" window types should be automatically constrained to be * entirely within display bounds (default), false if no constraints on the * position are desired. * - `SDL_PROP_WINDOW_CREATE_EXTERNAL_GRAPHICS_CONTEXT_BOOLEAN`: true if the * window will be used with an externally managed graphics context. * - `SDL_PROP_WINDOW_CREATE_FOCUSABLE_BOOLEAN`: true if the window should * accept keyboard input (defaults true) * - `SDL_PROP_WINDOW_CREATE_FULLSCREEN_BOOLEAN`: true if the window should * start in fullscreen mode at desktop resolution * - `SDL_PROP_WINDOW_CREATE_HEIGHT_NUMBER`: the height of the window * - `SDL_PROP_WINDOW_CREATE_HIDDEN_BOOLEAN`: true if the window should start * hidden * - `SDL_PROP_WINDOW_CREATE_HIGH_PIXEL_DENSITY_BOOLEAN`: true if the window * uses a high pixel density buffer if possible * - `SDL_PROP_WINDOW_CREATE_MAXIMIZED_BOOLEAN`: true if the window should * start maximized * - `SDL_PROP_WINDOW_CREATE_MENU_BOOLEAN`: true if the window is a popup menu * - `SDL_PROP_WINDOW_CREATE_METAL_BOOLEAN`: true if the window will be used * with Metal rendering * - `SDL_PROP_WINDOW_CREATE_MINIMIZED_BOOLEAN`: true if the window should * start minimized * - `SDL_PROP_WINDOW_CREATE_MODAL_BOOLEAN`: true if the window is modal to * its parent * - `SDL_PROP_WINDOW_CREATE_MOUSE_GRABBED_BOOLEAN`: true if the window starts * with grabbed mouse focus * - `SDL_PROP_WINDOW_CREATE_OPENGL_BOOLEAN`: true if the window will be used * with OpenGL rendering * - `SDL_PROP_WINDOW_CREATE_PARENT_POINTER`: an SDL_Window that will be the * parent of this window, required for windows with the "tooltip", "menu", * and "modal" properties * - `SDL_PROP_WINDOW_CREATE_RESIZABLE_BOOLEAN`: true if the window should be * resizable * - `SDL_PROP_WINDOW_CREATE_TITLE_STRING`: the title of the window, in UTF-8 * encoding * - `SDL_PROP_WINDOW_CREATE_TRANSPARENT_BOOLEAN`: true if the window show * transparent in the areas with alpha of 0 * - `SDL_PROP_WINDOW_CREATE_TOOLTIP_BOOLEAN`: true if the window is a tooltip * - `SDL_PROP_WINDOW_CREATE_UTILITY_BOOLEAN`: true if the window is a utility * window, not showing in the task bar and window list * - `SDL_PROP_WINDOW_CREATE_VULKAN_BOOLEAN`: true if the window will be used * with Vulkan rendering * - `SDL_PROP_WINDOW_CREATE_WIDTH_NUMBER`: the width of the window * - `SDL_PROP_WINDOW_CREATE_X_NUMBER`: the x position of the window, or * `SDL_WINDOWPOS_CENTERED`, defaults to `SDL_WINDOWPOS_UNDEFINED`. This is * relative to the parent for windows with the "tooltip" or "menu" property * set. * - `SDL_PROP_WINDOW_CREATE_Y_NUMBER`: the y position of the window, or * `SDL_WINDOWPOS_CENTERED`, defaults to `SDL_WINDOWPOS_UNDEFINED`. This is * relative to the parent for windows with the "tooltip" or "menu" property * set. * * These are additional supported properties on macOS: * * - `SDL_PROP_WINDOW_CREATE_COCOA_WINDOW_POINTER`: the * `(__unsafe_unretained)` NSWindow associated with the window, if you want * to wrap an existing window. * - `SDL_PROP_WINDOW_CREATE_COCOA_VIEW_POINTER`: the `(__unsafe_unretained)` * NSView associated with the window, defaults to `[window contentView]` * * These are additional supported properties on iOS, tvOS, and visionOS: * * - `SDL_PROP_WINDOW_CREATE_WINDOWSCENE_POINTER`: the `(__unsafe_unretained)` * UIWindowScene associated with the window, defaults to the active window * scene. * * These are additional supported properties on Wayland: * * - `SDL_PROP_WINDOW_CREATE_WAYLAND_SURFACE_ROLE_CUSTOM_BOOLEAN` - true if * the application wants to use the Wayland surface for a custom role and * does not want it attached to an XDG toplevel window. See * [README-wayland](README-wayland) for more information on using custom * surfaces. * - `SDL_PROP_WINDOW_CREATE_WAYLAND_CREATE_EGL_WINDOW_BOOLEAN` - true if the * application wants an associated `wl_egl_window` object to be created and * attached to the window, even if the window does not have the OpenGL * property or `SDL_WINDOW_OPENGL` flag set. * - `SDL_PROP_WINDOW_CREATE_WAYLAND_WL_SURFACE_POINTER` - the wl_surface * associated with the window, if you want to wrap an existing window. See * [README-wayland](README-wayland) for more information. * * These are additional supported properties on Windows: * * - `SDL_PROP_WINDOW_CREATE_WIN32_HWND_POINTER`: the HWND associated with the * window, if you want to wrap an existing window. * - `SDL_PROP_WINDOW_CREATE_WIN32_PIXEL_FORMAT_HWND_POINTER`: optional, * another window to share pixel format with, useful for OpenGL windows * * These are additional supported properties with X11: * * - `SDL_PROP_WINDOW_CREATE_X11_WINDOW_NUMBER`: the X11 Window associated * with the window, if you want to wrap an existing window. * * The window is implicitly shown if the "hidden" property is not set. * * These are additional supported properties with Emscripten: * * - `SDL_PROP_WINDOW_CREATE_EMSCRIPTEN_CANVAS_ID_STRING`: the id given to the * canvas element. This should start with a '#' sign * - `SDL_PROP_WINDOW_CREATE_EMSCRIPTEN_KEYBOARD_ELEMENT_STRING`: override the * binding element for keyboard inputs for this canvas. The variable can be * one of: * - "#window": the javascript window object (default) * - "#document": the javascript document object * - "#screen": the javascript window.screen object * - "#canvas": the WebGL canvas element * - "#none": Don't bind anything at all * - any other string without a leading # sign applies to the element on the * page with that ID. Windows with the "tooltip" and "menu" properties are * popup windows and have the behaviors and guidelines outlined in * SDL_CreatePopupWindow(). * * If this window is being created to be used with an SDL_Renderer, you should * not add a graphics API specific property * (`SDL_PROP_WINDOW_CREATE_OPENGL_BOOLEAN`, etc), as SDL will handle that * internally when it chooses a renderer. However, SDL might need to recreate * your window at that point, which may cause the window to appear briefly, * and then flicker as it is recreated. The correct approach to this is to * create the window with the `SDL_PROP_WINDOW_CREATE_HIDDEN_BOOLEAN` property * set to true, then create the renderer, then show the window with * SDL_ShowWindow(). * * \param props the properties to use. * \returns the window that was created or NULL on failure; call * SDL_GetError() for more information. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_CreateProperties * \sa SDL_CreateWindow * \sa SDL_DestroyWindow */ extern SDL_DECLSPEC SDL_Window * SDLCALL SDL_CreateWindowWithProperties(SDL_PropertiesID props); #define SDL_PROP_WINDOW_CREATE_ALWAYS_ON_TOP_BOOLEAN "SDL.window.create.always_on_top" #define SDL_PROP_WINDOW_CREATE_BORDERLESS_BOOLEAN "SDL.window.create.borderless" #define SDL_PROP_WINDOW_CREATE_CONSTRAIN_POPUP_BOOLEAN "SDL.window.create.constrain_popup" #define SDL_PROP_WINDOW_CREATE_FOCUSABLE_BOOLEAN "SDL.window.create.focusable" #define SDL_PROP_WINDOW_CREATE_EXTERNAL_GRAPHICS_CONTEXT_BOOLEAN "SDL.window.create.external_graphics_context" #define SDL_PROP_WINDOW_CREATE_FLAGS_NUMBER "SDL.window.create.flags" #define SDL_PROP_WINDOW_CREATE_FULLSCREEN_BOOLEAN "SDL.window.create.fullscreen" #define SDL_PROP_WINDOW_CREATE_HEIGHT_NUMBER "SDL.window.create.height" #define SDL_PROP_WINDOW_CREATE_HIDDEN_BOOLEAN "SDL.window.create.hidden" #define SDL_PROP_WINDOW_CREATE_HIGH_PIXEL_DENSITY_BOOLEAN "SDL.window.create.high_pixel_density" #define SDL_PROP_WINDOW_CREATE_MAXIMIZED_BOOLEAN "SDL.window.create.maximized" #define SDL_PROP_WINDOW_CREATE_MENU_BOOLEAN "SDL.window.create.menu" #define SDL_PROP_WINDOW_CREATE_METAL_BOOLEAN "SDL.window.create.metal" #define SDL_PROP_WINDOW_CREATE_MINIMIZED_BOOLEAN "SDL.window.create.minimized" #define SDL_PROP_WINDOW_CREATE_MODAL_BOOLEAN "SDL.window.create.modal" #define SDL_PROP_WINDOW_CREATE_MOUSE_GRABBED_BOOLEAN "SDL.window.create.mouse_grabbed" #define SDL_PROP_WINDOW_CREATE_OPENGL_BOOLEAN "SDL.window.create.opengl" #define SDL_PROP_WINDOW_CREATE_PARENT_POINTER "SDL.window.create.parent" #define SDL_PROP_WINDOW_CREATE_RESIZABLE_BOOLEAN "SDL.window.create.resizable" #define SDL_PROP_WINDOW_CREATE_TITLE_STRING "SDL.window.create.title" #define SDL_PROP_WINDOW_CREATE_TRANSPARENT_BOOLEAN "SDL.window.create.transparent" #define SDL_PROP_WINDOW_CREATE_TOOLTIP_BOOLEAN "SDL.window.create.tooltip" #define SDL_PROP_WINDOW_CREATE_UTILITY_BOOLEAN "SDL.window.create.utility" #define SDL_PROP_WINDOW_CREATE_VULKAN_BOOLEAN "SDL.window.create.vulkan" #define SDL_PROP_WINDOW_CREATE_WIDTH_NUMBER "SDL.window.create.width" #define SDL_PROP_WINDOW_CREATE_X_NUMBER "SDL.window.create.x" #define SDL_PROP_WINDOW_CREATE_Y_NUMBER "SDL.window.create.y" #define SDL_PROP_WINDOW_CREATE_COCOA_WINDOW_POINTER "SDL.window.create.cocoa.window" #define SDL_PROP_WINDOW_CREATE_COCOA_VIEW_POINTER "SDL.window.create.cocoa.view" #define SDL_PROP_WINDOW_CREATE_WINDOWSCENE_POINTER "SDL.window.create.uikit.windowscene" #define SDL_PROP_WINDOW_CREATE_WAYLAND_SURFACE_ROLE_CUSTOM_BOOLEAN "SDL.window.create.wayland.surface_role_custom" #define SDL_PROP_WINDOW_CREATE_WAYLAND_CREATE_EGL_WINDOW_BOOLEAN "SDL.window.create.wayland.create_egl_window" #define SDL_PROP_WINDOW_CREATE_WAYLAND_WL_SURFACE_POINTER "SDL.window.create.wayland.wl_surface" #define SDL_PROP_WINDOW_CREATE_WIN32_HWND_POINTER "SDL.window.create.win32.hwnd" #define SDL_PROP_WINDOW_CREATE_WIN32_PIXEL_FORMAT_HWND_POINTER "SDL.window.create.win32.pixel_format_hwnd" #define SDL_PROP_WINDOW_CREATE_X11_WINDOW_NUMBER "SDL.window.create.x11.window" #define SDL_PROP_WINDOW_CREATE_EMSCRIPTEN_CANVAS_ID_STRING "SDL.window.create.emscripten.canvas_id" #define SDL_PROP_WINDOW_CREATE_EMSCRIPTEN_KEYBOARD_ELEMENT_STRING "SDL.window.create.emscripten.keyboard_element" /** * Get the numeric ID of a window. * * The numeric ID is what SDL_WindowEvent references, and is necessary to map * these events to specific SDL_Window objects. * * \param window the window to query. * \returns the ID of the window on success or 0 on failure; call * SDL_GetError() for more information. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetWindowFromID */ extern SDL_DECLSPEC SDL_WindowID SDLCALL SDL_GetWindowID(SDL_Window *window); /** * Get a window from a stored ID. * * The numeric ID is what SDL_WindowEvent references, and is necessary to map * these events to specific SDL_Window objects. * * \param id the ID of the window. * \returns the window associated with `id` or NULL if it doesn't exist; call * SDL_GetError() for more information. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetWindowID */ extern SDL_DECLSPEC SDL_Window * SDLCALL SDL_GetWindowFromID(SDL_WindowID id); /** * Get parent of a window. * * \param window the window to query. * \returns the parent of the window on success or NULL if the window has no * parent. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_CreatePopupWindow */ extern SDL_DECLSPEC SDL_Window * SDLCALL SDL_GetWindowParent(SDL_Window *window); /** * Get the properties associated with a window. * * The following read-only properties are provided by SDL: * * - `SDL_PROP_WINDOW_SHAPE_POINTER`: the surface associated with a shaped * window * - `SDL_PROP_WINDOW_HDR_ENABLED_BOOLEAN`: true if the window has HDR * headroom above the SDR white point. This property can change dynamically * when SDL_EVENT_WINDOW_HDR_STATE_CHANGED is sent. * - `SDL_PROP_WINDOW_SDR_WHITE_LEVEL_FLOAT`: the value of SDR white in the * SDL_COLORSPACE_SRGB_LINEAR colorspace. On Windows this corresponds to the * SDR white level in scRGB colorspace, and on Apple platforms this is * always 1.0 for EDR content. This property can change dynamically when * SDL_EVENT_WINDOW_HDR_STATE_CHANGED is sent. * - `SDL_PROP_WINDOW_HDR_HEADROOM_FLOAT`: the additional high dynamic range * that can be displayed, in terms of the SDR white point. When HDR is not * enabled, this will be 1.0. This property can change dynamically when * SDL_EVENT_WINDOW_HDR_STATE_CHANGED is sent. * * On Android: * * - `SDL_PROP_WINDOW_ANDROID_WINDOW_POINTER`: the ANativeWindow associated * with the window * - `SDL_PROP_WINDOW_ANDROID_SURFACE_POINTER`: the EGLSurface associated with * the window * * On iOS: * * - `SDL_PROP_WINDOW_UIKIT_WINDOW_POINTER`: the `(__unsafe_unretained)` * UIWindow associated with the window * - `SDL_PROP_WINDOW_UIKIT_METAL_VIEW_TAG_NUMBER`: the NSInteger tag * associated with metal views on the window * - `SDL_PROP_WINDOW_UIKIT_OPENGL_FRAMEBUFFER_NUMBER`: the OpenGL view's * framebuffer object. It must be bound when rendering to the screen using * OpenGL. * - `SDL_PROP_WINDOW_UIKIT_OPENGL_RENDERBUFFER_NUMBER`: the OpenGL view's * renderbuffer object. It must be bound when SDL_GL_SwapWindow is called. * - `SDL_PROP_WINDOW_UIKIT_OPENGL_RESOLVE_FRAMEBUFFER_NUMBER`: the OpenGL * view's resolve framebuffer, when MSAA is used. * * On KMS/DRM: * * - `SDL_PROP_WINDOW_KMSDRM_DEVICE_INDEX_NUMBER`: the device index associated * with the window (e.g. the X in /dev/dri/cardX) * - `SDL_PROP_WINDOW_KMSDRM_DRM_FD_NUMBER`: the DRM FD associated with the * window * - `SDL_PROP_WINDOW_KMSDRM_GBM_DEVICE_POINTER`: the GBM device associated * with the window * * On macOS: * * - `SDL_PROP_WINDOW_COCOA_WINDOW_POINTER`: the `(__unsafe_unretained)` * NSWindow associated with the window * - `SDL_PROP_WINDOW_COCOA_METAL_VIEW_TAG_NUMBER`: the NSInteger tag * associated with metal views on the window * * On OpenVR: * * - `SDL_PROP_WINDOW_OPENVR_OVERLAY_ID_NUMBER`: the OpenVR Overlay Handle ID * for the associated overlay window. * * On Vivante: * * - `SDL_PROP_WINDOW_VIVANTE_DISPLAY_POINTER`: the EGLNativeDisplayType * associated with the window * - `SDL_PROP_WINDOW_VIVANTE_WINDOW_POINTER`: the EGLNativeWindowType * associated with the window * - `SDL_PROP_WINDOW_VIVANTE_SURFACE_POINTER`: the EGLSurface associated with * the window * * On Windows: * * - `SDL_PROP_WINDOW_WIN32_HWND_POINTER`: the HWND associated with the window * - `SDL_PROP_WINDOW_WIN32_HDC_POINTER`: the HDC associated with the window * - `SDL_PROP_WINDOW_WIN32_INSTANCE_POINTER`: the HINSTANCE associated with * the window * * On Wayland: * * Note: The `xdg_*` window objects do not internally persist across window * show/hide calls. They will be null if the window is hidden and must be * queried each time it is shown. * * - `SDL_PROP_WINDOW_WAYLAND_DISPLAY_POINTER`: the wl_display associated with * the window * - `SDL_PROP_WINDOW_WAYLAND_SURFACE_POINTER`: the wl_surface associated with * the window * - `SDL_PROP_WINDOW_WAYLAND_VIEWPORT_POINTER`: the wp_viewport associated * with the window * - `SDL_PROP_WINDOW_WAYLAND_EGL_WINDOW_POINTER`: the wl_egl_window * associated with the window * - `SDL_PROP_WINDOW_WAYLAND_XDG_SURFACE_POINTER`: the xdg_surface associated * with the window * - `SDL_PROP_WINDOW_WAYLAND_XDG_TOPLEVEL_POINTER`: the xdg_toplevel role * associated with the window * - 'SDL_PROP_WINDOW_WAYLAND_XDG_TOPLEVEL_EXPORT_HANDLE_STRING': the export * handle associated with the window * - `SDL_PROP_WINDOW_WAYLAND_XDG_POPUP_POINTER`: the xdg_popup role * associated with the window * - `SDL_PROP_WINDOW_WAYLAND_XDG_POSITIONER_POINTER`: the xdg_positioner * associated with the window, in popup mode * * On X11: * * - `SDL_PROP_WINDOW_X11_DISPLAY_POINTER`: the X11 Display associated with * the window * - `SDL_PROP_WINDOW_X11_SCREEN_NUMBER`: the screen number associated with * the window * - `SDL_PROP_WINDOW_X11_WINDOW_NUMBER`: the X11 Window associated with the * window * * On Emscripten: * * - `SDL_PROP_WINDOW_EMSCRIPTEN_CANVAS_ID_STRING`: the id the canvas element * will have * - `SDL_PROP_WINDOW_EMSCRIPTEN_KEYBOARD_ELEMENT_STRING`: the keyboard * element that associates keyboard events to this window * * \param window the window to query. * \returns a valid property ID on success or 0 on failure; call * SDL_GetError() for more information. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC SDL_PropertiesID SDLCALL SDL_GetWindowProperties(SDL_Window *window); #define SDL_PROP_WINDOW_SHAPE_POINTER "SDL.window.shape" #define SDL_PROP_WINDOW_HDR_ENABLED_BOOLEAN "SDL.window.HDR_enabled" #define SDL_PROP_WINDOW_SDR_WHITE_LEVEL_FLOAT "SDL.window.SDR_white_level" #define SDL_PROP_WINDOW_HDR_HEADROOM_FLOAT "SDL.window.HDR_headroom" #define SDL_PROP_WINDOW_ANDROID_WINDOW_POINTER "SDL.window.android.window" #define SDL_PROP_WINDOW_ANDROID_SURFACE_POINTER "SDL.window.android.surface" #define SDL_PROP_WINDOW_UIKIT_WINDOW_POINTER "SDL.window.uikit.window" #define SDL_PROP_WINDOW_UIKIT_METAL_VIEW_TAG_NUMBER "SDL.window.uikit.metal_view_tag" #define SDL_PROP_WINDOW_UIKIT_OPENGL_FRAMEBUFFER_NUMBER "SDL.window.uikit.opengl.framebuffer" #define SDL_PROP_WINDOW_UIKIT_OPENGL_RENDERBUFFER_NUMBER "SDL.window.uikit.opengl.renderbuffer" #define SDL_PROP_WINDOW_UIKIT_OPENGL_RESOLVE_FRAMEBUFFER_NUMBER "SDL.window.uikit.opengl.resolve_framebuffer" #define SDL_PROP_WINDOW_KMSDRM_DEVICE_INDEX_NUMBER "SDL.window.kmsdrm.dev_index" #define SDL_PROP_WINDOW_KMSDRM_DRM_FD_NUMBER "SDL.window.kmsdrm.drm_fd" #define SDL_PROP_WINDOW_KMSDRM_GBM_DEVICE_POINTER "SDL.window.kmsdrm.gbm_dev" #define SDL_PROP_WINDOW_COCOA_WINDOW_POINTER "SDL.window.cocoa.window" #define SDL_PROP_WINDOW_COCOA_METAL_VIEW_TAG_NUMBER "SDL.window.cocoa.metal_view_tag" #define SDL_PROP_WINDOW_OPENVR_OVERLAY_ID_NUMBER "SDL.window.openvr.overlay_id" #define SDL_PROP_WINDOW_VIVANTE_DISPLAY_POINTER "SDL.window.vivante.display" #define SDL_PROP_WINDOW_VIVANTE_WINDOW_POINTER "SDL.window.vivante.window" #define SDL_PROP_WINDOW_VIVANTE_SURFACE_POINTER "SDL.window.vivante.surface" #define SDL_PROP_WINDOW_WIN32_HWND_POINTER "SDL.window.win32.hwnd" #define SDL_PROP_WINDOW_WIN32_HDC_POINTER "SDL.window.win32.hdc" #define SDL_PROP_WINDOW_WIN32_INSTANCE_POINTER "SDL.window.win32.instance" #define SDL_PROP_WINDOW_WAYLAND_DISPLAY_POINTER "SDL.window.wayland.display" #define SDL_PROP_WINDOW_WAYLAND_SURFACE_POINTER "SDL.window.wayland.surface" #define SDL_PROP_WINDOW_WAYLAND_VIEWPORT_POINTER "SDL.window.wayland.viewport" #define SDL_PROP_WINDOW_WAYLAND_EGL_WINDOW_POINTER "SDL.window.wayland.egl_window" #define SDL_PROP_WINDOW_WAYLAND_XDG_SURFACE_POINTER "SDL.window.wayland.xdg_surface" #define SDL_PROP_WINDOW_WAYLAND_XDG_TOPLEVEL_POINTER "SDL.window.wayland.xdg_toplevel" #define SDL_PROP_WINDOW_WAYLAND_XDG_TOPLEVEL_EXPORT_HANDLE_STRING "SDL.window.wayland.xdg_toplevel_export_handle" #define SDL_PROP_WINDOW_WAYLAND_XDG_POPUP_POINTER "SDL.window.wayland.xdg_popup" #define SDL_PROP_WINDOW_WAYLAND_XDG_POSITIONER_POINTER "SDL.window.wayland.xdg_positioner" #define SDL_PROP_WINDOW_X11_DISPLAY_POINTER "SDL.window.x11.display" #define SDL_PROP_WINDOW_X11_SCREEN_NUMBER "SDL.window.x11.screen" #define SDL_PROP_WINDOW_X11_WINDOW_NUMBER "SDL.window.x11.window" #define SDL_PROP_WINDOW_EMSCRIPTEN_CANVAS_ID_STRING "SDL.window.emscripten.canvas_id" #define SDL_PROP_WINDOW_EMSCRIPTEN_KEYBOARD_ELEMENT_STRING "SDL.window.emscripten.keyboard_element" /** * Get the window flags. * * \param window the window to query. * \returns a mask of the SDL_WindowFlags associated with `window`. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_CreateWindow * \sa SDL_HideWindow * \sa SDL_MaximizeWindow * \sa SDL_MinimizeWindow * \sa SDL_SetWindowFullscreen * \sa SDL_SetWindowMouseGrab * \sa SDL_SetWindowFillDocument * \sa SDL_ShowWindow */ extern SDL_DECLSPEC SDL_WindowFlags SDLCALL SDL_GetWindowFlags(SDL_Window *window); /** * Set the title of a window. * * This string is expected to be in UTF-8 encoding. * * \param window the window to change. * \param title the desired window title in UTF-8 format. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetWindowTitle */ extern SDL_DECLSPEC bool SDLCALL SDL_SetWindowTitle(SDL_Window *window, const char *title); /** * Get the title of a window. * * \param window the window to query. * \returns the title of the window in UTF-8 format or "" if there is no * title. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_SetWindowTitle */ extern SDL_DECLSPEC const char * SDLCALL SDL_GetWindowTitle(SDL_Window *window); /** * Set the icon for a window. * * If this function is passed a surface with alternate representations added * using SDL_AddSurfaceAlternateImage(), the surface will be interpreted as * the content to be used for 100% display scale, and the alternate * representations will be used for high DPI situations. For example, if the * original surface is 32x32, then on a 2x macOS display or 200% display scale * on Windows, a 64x64 version of the image will be used, if available. If a * matching version of the image isn't available, the closest larger size * image will be downscaled to the appropriate size and be used instead, if * available. Otherwise, the closest smaller image will be upscaled and be * used instead. * * \param window the window to change. * \param icon an SDL_Surface structure containing the icon for the window. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_AddSurfaceAlternateImage */ extern SDL_DECLSPEC bool SDLCALL SDL_SetWindowIcon(SDL_Window *window, SDL_Surface *icon); /** * Request that the window's position be set. * * If the window is in an exclusive fullscreen or maximized state, this * request has no effect. * * This can be used to reposition fullscreen-desktop windows onto a different * display, however, as exclusive fullscreen windows are locked to a specific * display, they can only be repositioned programmatically via * SDL_SetWindowFullscreenMode(). * * On some windowing systems this request is asynchronous and the new * coordinates may not have have been applied immediately upon the return of * this function. If an immediate change is required, call SDL_SyncWindow() to * block until the changes have taken effect. * * When the window position changes, an SDL_EVENT_WINDOW_MOVED event will be * emitted with the window's new coordinates. Note that the new coordinates * may not match the exact coordinates requested, as some windowing systems * can restrict the position of the window in certain scenarios (e.g. * constraining the position so the window is always within desktop bounds). * Additionally, as this is just a request, it can be denied by the windowing * system. * * \param window the window to reposition. * \param x the x coordinate of the window, or `SDL_WINDOWPOS_CENTERED` or * `SDL_WINDOWPOS_UNDEFINED`. * \param y the y coordinate of the window, or `SDL_WINDOWPOS_CENTERED` or * `SDL_WINDOWPOS_UNDEFINED`. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetWindowPosition * \sa SDL_SyncWindow */ extern SDL_DECLSPEC bool SDLCALL SDL_SetWindowPosition(SDL_Window *window, int x, int y); /** * Get the position of a window. * * This is the current position of the window as last reported by the * windowing system. * * If you do not need the value for one of the positions a NULL may be passed * in the `x` or `y` parameter. * * \param window the window to query. * \param x a pointer filled in with the x position of the window, may be * NULL. * \param y a pointer filled in with the y position of the window, may be * NULL. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_SetWindowPosition */ extern SDL_DECLSPEC bool SDLCALL SDL_GetWindowPosition(SDL_Window *window, int *x, int *y); /** * Request that the size of a window's client area be set. * * If the window is in a fullscreen or maximized state, this request has no * effect. * * To change the exclusive fullscreen mode of a window, use * SDL_SetWindowFullscreenMode(). * * On some windowing systems, this request is asynchronous and the new window * size may not have have been applied immediately upon the return of this * function. If an immediate change is required, call SDL_SyncWindow() to * block until the changes have taken effect. * * When the window size changes, an SDL_EVENT_WINDOW_RESIZED event will be * emitted with the new window dimensions. Note that the new dimensions may * not match the exact size requested, as some windowing systems can restrict * the window size in certain scenarios (e.g. constraining the size of the * content area to remain within the usable desktop bounds). Additionally, as * this is just a request, it can be denied by the windowing system. * * \param window the window to change. * \param w the width of the window, must be > 0. * \param h the height of the window, must be > 0. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetWindowSize * \sa SDL_SetWindowFullscreenMode * \sa SDL_SyncWindow */ extern SDL_DECLSPEC bool SDLCALL SDL_SetWindowSize(SDL_Window *window, int w, int h); /** * Get the size of a window's client area. * * The window pixel size may differ from its window coordinate size if the * window is on a high pixel density display. Use SDL_GetWindowSizeInPixels() * or SDL_GetRenderOutputSize() to get the real client area size in pixels. * * \param window the window to query the width and height from. * \param w a pointer filled in with the width of the window, may be NULL. * \param h a pointer filled in with the height of the window, may be NULL. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetRenderOutputSize * \sa SDL_GetWindowSizeInPixels * \sa SDL_SetWindowSize * \sa SDL_EVENT_WINDOW_RESIZED */ extern SDL_DECLSPEC bool SDLCALL SDL_GetWindowSize(SDL_Window *window, int *w, int *h); /** * Get the safe area for this window. * * Some devices have portions of the screen which are partially obscured or * not interactive, possibly due to on-screen controls, curved edges, camera * notches, TV overscan, etc. This function provides the area of the window * which is safe to have interactable content. You should continue rendering * into the rest of the window, but it should not contain visually important * or interactable content. * * \param window the window to query. * \param rect a pointer filled in with the client area that is safe for * interactive content. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC bool SDLCALL SDL_GetWindowSafeArea(SDL_Window *window, SDL_Rect *rect); /** * Request that the aspect ratio of a window's client area be set. * * The aspect ratio is the ratio of width divided by height, e.g. 2560x1600 * would be 1.6. Larger aspect ratios are wider and smaller aspect ratios are * narrower. * * If, at the time of this request, the window in a fixed-size state, such as * maximized or fullscreen, the request will be deferred until the window * exits this state and becomes resizable again. * * On some windowing systems, this request is asynchronous and the new window * aspect ratio may not have have been applied immediately upon the return of * this function. If an immediate change is required, call SDL_SyncWindow() to * block until the changes have taken effect. * * When the window size changes, an SDL_EVENT_WINDOW_RESIZED event will be * emitted with the new window dimensions. Note that the new dimensions may * not match the exact aspect ratio requested, as some windowing systems can * restrict the window size in certain scenarios (e.g. constraining the size * of the content area to remain within the usable desktop bounds). * Additionally, as this is just a request, it can be denied by the windowing * system. * * \param window the window to change. * \param min_aspect the minimum aspect ratio of the window, or 0.0f for no * limit. * \param max_aspect the maximum aspect ratio of the window, or 0.0f for no * limit. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetWindowAspectRatio * \sa SDL_SyncWindow */ extern SDL_DECLSPEC bool SDLCALL SDL_SetWindowAspectRatio(SDL_Window *window, float min_aspect, float max_aspect); /** * Get the aspect ratio of a window's client area. * * \param window the window to query the width and height from. * \param min_aspect a pointer filled in with the minimum aspect ratio of the * window, may be NULL. * \param max_aspect a pointer filled in with the maximum aspect ratio of the * window, may be NULL. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_SetWindowAspectRatio */ extern SDL_DECLSPEC bool SDLCALL SDL_GetWindowAspectRatio(SDL_Window *window, float *min_aspect, float *max_aspect); /** * Get the size of a window's borders (decorations) around the client area. * * Note: If this function fails (returns false), the size values will be * initialized to 0, 0, 0, 0 (if a non-NULL pointer is provided), as if the * window in question was borderless. * * Note: This function may fail on systems where the window has not yet been * decorated by the display server (for example, immediately after calling * SDL_CreateWindow). It is recommended that you wait at least until the * window has been presented and composited, so that the window system has a * chance to decorate the window and provide the border dimensions to SDL. * * This function also returns false if getting the information is not * supported. * * \param window the window to query the size values of the border * (decorations) from. * \param top pointer to variable for storing the size of the top border; NULL * is permitted. * \param left pointer to variable for storing the size of the left border; * NULL is permitted. * \param bottom pointer to variable for storing the size of the bottom * border; NULL is permitted. * \param right pointer to variable for storing the size of the right border; * NULL is permitted. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetWindowSize */ extern SDL_DECLSPEC bool SDLCALL SDL_GetWindowBordersSize(SDL_Window *window, int *top, int *left, int *bottom, int *right); /** * Get the size of a window's client area, in pixels. * * \param window the window from which the drawable size should be queried. * \param w a pointer to variable for storing the width in pixels, may be * NULL. * \param h a pointer to variable for storing the height in pixels, may be * NULL. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_CreateWindow * \sa SDL_GetWindowSize */ extern SDL_DECLSPEC bool SDLCALL SDL_GetWindowSizeInPixels(SDL_Window *window, int *w, int *h); /** * Set the minimum size of a window's client area. * * \param window the window to change. * \param min_w the minimum width of the window, or 0 for no limit. * \param min_h the minimum height of the window, or 0 for no limit. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetWindowMinimumSize * \sa SDL_SetWindowMaximumSize */ extern SDL_DECLSPEC bool SDLCALL SDL_SetWindowMinimumSize(SDL_Window *window, int min_w, int min_h); /** * Get the minimum size of a window's client area. * * \param window the window to query. * \param w a pointer filled in with the minimum width of the window, may be * NULL. * \param h a pointer filled in with the minimum height of the window, may be * NULL. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetWindowMaximumSize * \sa SDL_SetWindowMinimumSize */ extern SDL_DECLSPEC bool SDLCALL SDL_GetWindowMinimumSize(SDL_Window *window, int *w, int *h); /** * Set the maximum size of a window's client area. * * \param window the window to change. * \param max_w the maximum width of the window, or 0 for no limit. * \param max_h the maximum height of the window, or 0 for no limit. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetWindowMaximumSize * \sa SDL_SetWindowMinimumSize */ extern SDL_DECLSPEC bool SDLCALL SDL_SetWindowMaximumSize(SDL_Window *window, int max_w, int max_h); /** * Get the maximum size of a window's client area. * * \param window the window to query. * \param w a pointer filled in with the maximum width of the window, may be * NULL. * \param h a pointer filled in with the maximum height of the window, may be * NULL. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetWindowMinimumSize * \sa SDL_SetWindowMaximumSize */ extern SDL_DECLSPEC bool SDLCALL SDL_GetWindowMaximumSize(SDL_Window *window, int *w, int *h); /** * Set the border state of a window. * * This will add or remove the window's `SDL_WINDOW_BORDERLESS` flag and add * or remove the border from the actual window. This is a no-op if the * window's border already matches the requested state. * * You can't change the border state of a fullscreen window. * * \param window the window of which to change the border state. * \param bordered false to remove border, true to add border. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetWindowFlags */ extern SDL_DECLSPEC bool SDLCALL SDL_SetWindowBordered(SDL_Window *window, bool bordered); /** * Set the user-resizable state of a window. * * This will add or remove the window's `SDL_WINDOW_RESIZABLE` flag and * allow/disallow user resizing of the window. This is a no-op if the window's * resizable state already matches the requested state. * * You can't change the resizable state of a fullscreen window. * * \param window the window of which to change the resizable state. * \param resizable true to allow resizing, false to disallow. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetWindowFlags */ extern SDL_DECLSPEC bool SDLCALL SDL_SetWindowResizable(SDL_Window *window, bool resizable); /** * Set the window to always be above the others. * * This will add or remove the window's `SDL_WINDOW_ALWAYS_ON_TOP` flag. This * will bring the window to the front and keep the window above the rest. * * \param window the window of which to change the always on top state. * \param on_top true to set the window always on top, false to disable. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetWindowFlags */ extern SDL_DECLSPEC bool SDLCALL SDL_SetWindowAlwaysOnTop(SDL_Window *window, bool on_top); /** * Set the window to fill the current document space (Emscripten only). * * This will add or remove the window's `SDL_WINDOW_FILL_DOCUMENT` flag. * * Currently this flag only applies to the Emscripten target. * * When enabled, the canvas element fills the entire document. Resize events * will be generated as the browser window is resized, as that will adjust the * canvas size as well. The canvas will cover anything else on the page, * including any controls provided by Emscripten in its generated HTML file * (in fact, any elements on the page that aren't the canvas will be moved * into a hidden `div` element). * * Often times this is desirable for a browser-based game, but it means * several things that we expect of an SDL window on other platforms might not * work as expected, such as minimum window sizes and aspect ratios. * * \param window the window of which to change the fill-document state. * \param fill true to set the window to fill the document, false to disable. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.4.0. * * \sa SDL_GetWindowFlags */ extern SDL_DECLSPEC bool SDLCALL SDL_SetWindowFillDocument(SDL_Window *window, bool fill); /** * Show a window. * * \param window the window to show. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_HideWindow * \sa SDL_RaiseWindow */ extern SDL_DECLSPEC bool SDLCALL SDL_ShowWindow(SDL_Window *window); /** * Hide a window. * * \param window the window to hide. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_ShowWindow * \sa SDL_WINDOW_HIDDEN */ extern SDL_DECLSPEC bool SDLCALL SDL_HideWindow(SDL_Window *window); /** * Request that a window be raised above other windows and gain the input * focus. * * The result of this request is subject to desktop window manager policy, * particularly if raising the requested window would result in stealing focus * from another application. If the window is successfully raised and gains * input focus, an SDL_EVENT_WINDOW_FOCUS_GAINED event will be emitted, and * the window will have the SDL_WINDOW_INPUT_FOCUS flag set. * * \param window the window to raise. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC bool SDLCALL SDL_RaiseWindow(SDL_Window *window); /** * Request that the window be made as large as possible. * * Non-resizable windows can't be maximized. The window must have the * SDL_WINDOW_RESIZABLE flag set, or this will have no effect. * * On some windowing systems this request is asynchronous and the new window * state may not have have been applied immediately upon the return of this * function. If an immediate change is required, call SDL_SyncWindow() to * block until the changes have taken effect. * * When the window state changes, an SDL_EVENT_WINDOW_MAXIMIZED event will be * emitted. Note that, as this is just a request, the windowing system can * deny the state change. * * When maximizing a window, whether the constraints set via * SDL_SetWindowMaximumSize() are honored depends on the policy of the window * manager. Win32 and macOS enforce the constraints when maximizing, while X11 * and Wayland window managers may vary. * * \param window the window to maximize. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_MinimizeWindow * \sa SDL_RestoreWindow * \sa SDL_SyncWindow */ extern SDL_DECLSPEC bool SDLCALL SDL_MaximizeWindow(SDL_Window *window); /** * Request that the window be minimized to an iconic representation. * * If the window is in a fullscreen state, this request has no direct effect. * It may alter the state the window is returned to when leaving fullscreen. * * On some windowing systems this request is asynchronous and the new window * state may not have been applied immediately upon the return of this * function. If an immediate change is required, call SDL_SyncWindow() to * block until the changes have taken effect. * * When the window state changes, an SDL_EVENT_WINDOW_MINIMIZED event will be * emitted. Note that, as this is just a request, the windowing system can * deny the state change. * * \param window the window to minimize. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_MaximizeWindow * \sa SDL_RestoreWindow * \sa SDL_SyncWindow */ extern SDL_DECLSPEC bool SDLCALL SDL_MinimizeWindow(SDL_Window *window); /** * Request that the size and position of a minimized or maximized window be * restored. * * If the window is in a fullscreen state, this request has no direct effect. * It may alter the state the window is returned to when leaving fullscreen. * * On some windowing systems this request is asynchronous and the new window * state may not have have been applied immediately upon the return of this * function. If an immediate change is required, call SDL_SyncWindow() to * block until the changes have taken effect. * * When the window state changes, an SDL_EVENT_WINDOW_RESTORED event will be * emitted. Note that, as this is just a request, the windowing system can * deny the state change. * * \param window the window to restore. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_MaximizeWindow * \sa SDL_MinimizeWindow * \sa SDL_SyncWindow */ extern SDL_DECLSPEC bool SDLCALL SDL_RestoreWindow(SDL_Window *window); /** * Request that the window's fullscreen state be changed. * * By default a window in fullscreen state uses borderless fullscreen desktop * mode, but a specific exclusive display mode can be set using * SDL_SetWindowFullscreenMode(). * * On some windowing systems this request is asynchronous and the new * fullscreen state may not have have been applied immediately upon the return * of this function. If an immediate change is required, call SDL_SyncWindow() * to block until the changes have taken effect. * * When the window state changes, an SDL_EVENT_WINDOW_ENTER_FULLSCREEN or * SDL_EVENT_WINDOW_LEAVE_FULLSCREEN event will be emitted. Note that, as this * is just a request, it can be denied by the windowing system. * * \param window the window to change. * \param fullscreen true for fullscreen mode, false for windowed mode. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetWindowFullscreenMode * \sa SDL_SetWindowFullscreenMode * \sa SDL_SyncWindow * \sa SDL_WINDOW_FULLSCREEN */ extern SDL_DECLSPEC bool SDLCALL SDL_SetWindowFullscreen(SDL_Window *window, bool fullscreen); /** * Block until any pending window state is finalized. * * On asynchronous windowing systems, this acts as a synchronization barrier * for pending window state. It will attempt to wait until any pending window * state has been applied and is guaranteed to return within finite time. Note * that for how long it can potentially block depends on the underlying window * system, as window state changes may involve somewhat lengthy animations * that must complete before the window is in its final requested state. * * On windowing systems where changes are immediate, this does nothing. * * \param window the window for which to wait for the pending state to be * applied. * \returns true on success or false if the operation timed out before the * window was in the requested state. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_SetWindowSize * \sa SDL_SetWindowPosition * \sa SDL_SetWindowFullscreen * \sa SDL_MinimizeWindow * \sa SDL_MaximizeWindow * \sa SDL_RestoreWindow * \sa SDL_HINT_VIDEO_SYNC_WINDOW_OPERATIONS */ extern SDL_DECLSPEC bool SDLCALL SDL_SyncWindow(SDL_Window *window); /** * Return whether the window has a surface associated with it. * * \param window the window to query. * \returns true if there is a surface associated with the window, or false * otherwise. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetWindowSurface */ extern SDL_DECLSPEC bool SDLCALL SDL_WindowHasSurface(SDL_Window *window); /** * Get the SDL surface associated with the window. * * A new surface will be created with the optimal format for the window, if * necessary. This surface will be freed when the window is destroyed. Do not * free this surface. * * This surface will be invalidated if the window is resized. After resizing a * window this function must be called again to return a valid surface. * * You may not combine this with 3D or the rendering API on this window. * * This function is affected by `SDL_HINT_FRAMEBUFFER_ACCELERATION`. * * \param window the window to query. * \returns the surface associated with the window, or NULL on failure; call * SDL_GetError() for more information. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_DestroyWindowSurface * \sa SDL_WindowHasSurface * \sa SDL_UpdateWindowSurface * \sa SDL_UpdateWindowSurfaceRects */ extern SDL_DECLSPEC SDL_Surface * SDLCALL SDL_GetWindowSurface(SDL_Window *window); /** * Toggle VSync for the window surface. * * When a window surface is created, vsync defaults to * SDL_WINDOW_SURFACE_VSYNC_DISABLED. * * The `vsync` parameter can be 1 to synchronize present with every vertical * refresh, 2 to synchronize present with every second vertical refresh, etc., * SDL_WINDOW_SURFACE_VSYNC_ADAPTIVE for late swap tearing (adaptive vsync), * or SDL_WINDOW_SURFACE_VSYNC_DISABLED to disable. Not every value is * supported by every driver, so you should check the return value to see * whether the requested setting is supported. * * \param window the window. * \param vsync the vertical refresh sync interval. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetWindowSurfaceVSync */ extern SDL_DECLSPEC bool SDLCALL SDL_SetWindowSurfaceVSync(SDL_Window *window, int vsync); #define SDL_WINDOW_SURFACE_VSYNC_DISABLED 0 #define SDL_WINDOW_SURFACE_VSYNC_ADAPTIVE (-1) /** * Get VSync for the window surface. * * \param window the window to query. * \param vsync an int filled with the current vertical refresh sync interval. * See SDL_SetWindowSurfaceVSync() for the meaning of the value. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_SetWindowSurfaceVSync */ extern SDL_DECLSPEC bool SDLCALL SDL_GetWindowSurfaceVSync(SDL_Window *window, int *vsync); /** * Copy the window surface to the screen. * * This is the function you use to reflect any changes to the surface on the * screen. * * This function is equivalent to the SDL 1.2 API SDL_Flip(). * * \param window the window to update. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetWindowSurface * \sa SDL_UpdateWindowSurfaceRects */ extern SDL_DECLSPEC bool SDLCALL SDL_UpdateWindowSurface(SDL_Window *window); /** * Copy areas of the window surface to the screen. * * This is the function you use to reflect changes to portions of the surface * on the screen. * * This function is equivalent to the SDL 1.2 API SDL_UpdateRects(). * * Note that this function will update _at least_ the rectangles specified, * but this is only intended as an optimization; in practice, this might * update more of the screen (or all of the screen!), depending on what method * SDL uses to send pixels to the system. * * \param window the window to update. * \param rects an array of SDL_Rect structures representing areas of the * surface to copy, in pixels. * \param numrects the number of rectangles. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetWindowSurface * \sa SDL_UpdateWindowSurface */ extern SDL_DECLSPEC bool SDLCALL SDL_UpdateWindowSurfaceRects(SDL_Window *window, const SDL_Rect *rects, int numrects); /** * Destroy the surface associated with the window. * * \param window the window to update. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetWindowSurface * \sa SDL_WindowHasSurface */ extern SDL_DECLSPEC bool SDLCALL SDL_DestroyWindowSurface(SDL_Window *window); /** * Set a window's keyboard grab mode. * * Keyboard grab enables capture of system keyboard shortcuts like Alt+Tab or * the Meta/Super key. Note that not all system keyboard shortcuts can be * captured by applications (one example is Ctrl+Alt+Del on Windows). * * This is primarily intended for specialized applications such as VNC clients * or VM frontends. Normal games should not use keyboard grab. * * When keyboard grab is enabled, SDL will continue to handle Alt+Tab when the * window is full-screen to ensure the user is not trapped in your * application. If you have a custom keyboard shortcut to exit fullscreen * mode, you may suppress this behavior with * `SDL_HINT_ALLOW_ALT_TAB_WHILE_GRABBED`. * * If the caller enables a grab while another window is currently grabbed, the * other window loses its grab in favor of the caller's window. * * \param window the window for which the keyboard grab mode should be set. * \param grabbed this is true to grab keyboard, and false to release. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetWindowKeyboardGrab * \sa SDL_SetWindowMouseGrab */ extern SDL_DECLSPEC bool SDLCALL SDL_SetWindowKeyboardGrab(SDL_Window *window, bool grabbed); /** * Set a window's mouse grab mode. * * Mouse grab confines the mouse cursor to the window. * * \param window the window for which the mouse grab mode should be set. * \param grabbed this is true to grab mouse, and false to release. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetWindowMouseRect * \sa SDL_SetWindowMouseRect * \sa SDL_SetWindowKeyboardGrab */ extern SDL_DECLSPEC bool SDLCALL SDL_SetWindowMouseGrab(SDL_Window *window, bool grabbed); /** * Get a window's keyboard grab mode. * * \param window the window to query. * \returns true if keyboard is grabbed, and false otherwise. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_SetWindowKeyboardGrab */ extern SDL_DECLSPEC bool SDLCALL SDL_GetWindowKeyboardGrab(SDL_Window *window); /** * Get a window's mouse grab mode. * * \param window the window to query. * \returns true if mouse is grabbed, and false otherwise. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetWindowMouseRect * \sa SDL_SetWindowMouseRect * \sa SDL_SetWindowMouseGrab * \sa SDL_SetWindowKeyboardGrab */ extern SDL_DECLSPEC bool SDLCALL SDL_GetWindowMouseGrab(SDL_Window *window); /** * Get the window that currently has an input grab enabled. * * \returns the window if input is grabbed or NULL otherwise. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_SetWindowMouseGrab * \sa SDL_SetWindowKeyboardGrab */ extern SDL_DECLSPEC SDL_Window * SDLCALL SDL_GetGrabbedWindow(void); /** * Confines the cursor to the specified area of a window. * * Note that this does NOT grab the cursor, it only defines the area a cursor * is restricted to when the window has mouse focus. * * \param window the window that will be associated with the barrier. * \param rect a rectangle area in window-relative coordinates. If NULL the * barrier for the specified window will be destroyed. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetWindowMouseRect * \sa SDL_GetWindowMouseGrab * \sa SDL_SetWindowMouseGrab */ extern SDL_DECLSPEC bool SDLCALL SDL_SetWindowMouseRect(SDL_Window *window, const SDL_Rect *rect); /** * Get the mouse confinement rectangle of a window. * * \param window the window to query. * \returns a pointer to the mouse confinement rectangle of a window, or NULL * if there isn't one. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_SetWindowMouseRect * \sa SDL_GetWindowMouseGrab * \sa SDL_SetWindowMouseGrab */ extern SDL_DECLSPEC const SDL_Rect * SDLCALL SDL_GetWindowMouseRect(SDL_Window *window); /** * Set the opacity for a window. * * The parameter `opacity` will be clamped internally between 0.0f * (transparent) and 1.0f (opaque). * * This function also returns false if setting the opacity isn't supported. * * \param window the window which will be made transparent or opaque. * \param opacity the opacity value (0.0f - transparent, 1.0f - opaque). * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetWindowOpacity */ extern SDL_DECLSPEC bool SDLCALL SDL_SetWindowOpacity(SDL_Window *window, float opacity); /** * Get the opacity of a window. * * If transparency isn't supported on this platform, opacity will be returned * as 1.0f without error. * * \param window the window to get the current opacity value from. * \returns the opacity, (0.0f - transparent, 1.0f - opaque), or -1.0f on * failure; call SDL_GetError() for more information. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_SetWindowOpacity */ extern SDL_DECLSPEC float SDLCALL SDL_GetWindowOpacity(SDL_Window *window); /** * Set the window as a child of a parent window. * * If the window is already the child of an existing window, it will be * reparented to the new owner. Setting the parent window to NULL unparents * the window and removes child window status. * * If a parent window is hidden or destroyed, the operation will be * recursively applied to child windows. Child windows hidden with the parent * that did not have their hidden status explicitly set will be restored when * the parent is shown. * * Attempting to set the parent of a window that is currently in the modal * state will fail. Use SDL_SetWindowModal() to cancel the modal status before * attempting to change the parent. * * Popup windows cannot change parents and attempts to do so will fail. * * Setting a parent window that is currently the sibling or descendent of the * child window results in undefined behavior. * * \param window the window that should become the child of a parent. * \param parent the new parent window for the child window. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_SetWindowModal */ extern SDL_DECLSPEC bool SDLCALL SDL_SetWindowParent(SDL_Window *window, SDL_Window *parent); /** * Toggle the state of the window as modal. * * To enable modal status on a window, the window must currently be the child * window of a parent, or toggling modal status on will fail. * * \param window the window on which to set the modal state. * \param modal true to toggle modal status on, false to toggle it off. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_SetWindowParent * \sa SDL_WINDOW_MODAL */ extern SDL_DECLSPEC bool SDLCALL SDL_SetWindowModal(SDL_Window *window, bool modal); /** * Set whether the window may have input focus. * * \param window the window to set focusable state. * \param focusable true to allow input focus, false to not allow input focus. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC bool SDLCALL SDL_SetWindowFocusable(SDL_Window *window, bool focusable); /** * Display the system-level window menu. * * This default window menu is provided by the system and on some platforms * provides functionality for setting or changing privileged state on the * window, such as moving it between workspaces or displays, or toggling the * always-on-top property. * * On platforms or desktops where this is unsupported, this function does * nothing. * * \param window the window for which the menu will be displayed. * \param x the x coordinate of the menu, relative to the origin (top-left) of * the client area. * \param y the y coordinate of the menu, relative to the origin (top-left) of * the client area. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC bool SDLCALL SDL_ShowWindowSystemMenu(SDL_Window *window, int x, int y); /** * Possible return values from the SDL_HitTest callback. * * \threadsafety This function should only be called on the main thread. * * \since This enum is available since SDL 3.2.0. * * \sa SDL_HitTest */ typedef enum SDL_HitTestResult { SDL_HITTEST_NORMAL, /**< Region is normal. No special properties. */ SDL_HITTEST_DRAGGABLE, /**< Region can drag entire window. */ SDL_HITTEST_RESIZE_TOPLEFT, /**< Region is the resizable top-left corner border. */ SDL_HITTEST_RESIZE_TOP, /**< Region is the resizable top border. */ SDL_HITTEST_RESIZE_TOPRIGHT, /**< Region is the resizable top-right corner border. */ SDL_HITTEST_RESIZE_RIGHT, /**< Region is the resizable right border. */ SDL_HITTEST_RESIZE_BOTTOMRIGHT, /**< Region is the resizable bottom-right corner border. */ SDL_HITTEST_RESIZE_BOTTOM, /**< Region is the resizable bottom border. */ SDL_HITTEST_RESIZE_BOTTOMLEFT, /**< Region is the resizable bottom-left corner border. */ SDL_HITTEST_RESIZE_LEFT /**< Region is the resizable left border. */ } SDL_HitTestResult; /** * Callback used for hit-testing. * * \param win the SDL_Window where hit-testing was set on. * \param area an SDL_Point which should be hit-tested. * \param data what was passed as `callback_data` to SDL_SetWindowHitTest(). * \returns an SDL_HitTestResult value. * * \sa SDL_SetWindowHitTest */ typedef SDL_HitTestResult (SDLCALL *SDL_HitTest)(SDL_Window *win, const SDL_Point *area, void *data); /** * Provide a callback that decides if a window region has special properties. * * Normally windows are dragged and resized by decorations provided by the * system window manager (a title bar, borders, etc), but for some apps, it * makes sense to drag them from somewhere else inside the window itself; for * example, one might have a borderless window that wants to be draggable from * any part, or simulate its own title bar, etc. * * This function lets the app provide a callback that designates pieces of a * given window as special. This callback is run during event processing if we * need to tell the OS to treat a region of the window specially; the use of * this callback is known as "hit testing." * * Mouse input may not be delivered to your application if it is within a * special area; the OS will often apply that input to moving the window or * resizing the window and not deliver it to the application. * * Specifying NULL for a callback disables hit-testing. Hit-testing is * disabled by default. * * Platforms that don't support this functionality will return false * unconditionally, even if you're attempting to disable hit-testing. * * Your callback may fire at any time, and its firing does not indicate any * specific behavior (for example, on Windows, this certainly might fire when * the OS is deciding whether to drag your window, but it fires for lots of * other reasons, too, some unrelated to anything you probably care about _and * when the mouse isn't actually at the location it is testing_). Since this * can fire at any time, you should try to keep your callback efficient, * devoid of allocations, etc. * * \param window the window to set hit-testing on. * \param callback the function to call when doing a hit-test. * \param callback_data an app-defined void pointer passed to **callback**. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC bool SDLCALL SDL_SetWindowHitTest(SDL_Window *window, SDL_HitTest callback, void *callback_data); /** * Set the shape of a transparent window. * * This sets the alpha channel of a transparent window and any fully * transparent areas are also transparent to mouse clicks. If you are using * something besides the SDL render API, then you are responsible for drawing * the alpha channel of the window to match the shape alpha channel to get * consistent cross-platform results. * * The shape is copied inside this function, so you can free it afterwards. If * your shape surface changes, you should call SDL_SetWindowShape() again to * update the window. This is an expensive operation, so should be done * sparingly. * * The window must have been created with the SDL_WINDOW_TRANSPARENT flag. * * \param window the window. * \param shape the surface representing the shape of the window, or NULL to * remove any current shape. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC bool SDLCALL SDL_SetWindowShape(SDL_Window *window, SDL_Surface *shape); /** * Request a window to demand attention from the user. * * \param window the window to be flashed. * \param operation the operation to perform. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC bool SDLCALL SDL_FlashWindow(SDL_Window *window, SDL_FlashOperation operation); /** * Sets the state of the progress bar for the given window’s taskbar icon. * * \param window the window whose progress state is to be modified. * \param state the progress state. `SDL_PROGRESS_STATE_NONE` stops displaying * the progress bar. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.4.0. */ extern SDL_DECLSPEC bool SDLCALL SDL_SetWindowProgressState(SDL_Window *window, SDL_ProgressState state); /** * Get the state of the progress bar for the given window’s taskbar icon. * * \param window the window to get the current progress state from. * \returns the progress state, or `SDL_PROGRESS_STATE_INVALID` on failure; * call SDL_GetError() for more information. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.4.0. */ extern SDL_DECLSPEC SDL_ProgressState SDLCALL SDL_GetWindowProgressState(SDL_Window *window); /** * Sets the value of the progress bar for the given window’s taskbar icon. * * \param window the window whose progress value is to be modified. * \param value the progress value in the range of [0.0f - 1.0f]. If the value * is outside the valid range, it gets clamped. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.4.0. */ extern SDL_DECLSPEC bool SDLCALL SDL_SetWindowProgressValue(SDL_Window *window, float value); /** * Get the value of the progress bar for the given window’s taskbar icon. * * \param window the window to get the current progress value from. * \returns the progress value in the range of [0.0f - 1.0f], or -1.0f on * failure; call SDL_GetError() for more information. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.4.0. */ extern SDL_DECLSPEC float SDLCALL SDL_GetWindowProgressValue(SDL_Window *window); /** * Destroy a window. * * Any child windows owned by the window will be recursively destroyed as * well. * * Note that on some platforms, the visible window may not actually be removed * from the screen until the SDL event loop is pumped again, even though the * SDL_Window is no longer valid after this call. * * \param window the window to destroy. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_CreatePopupWindow * \sa SDL_CreateWindow * \sa SDL_CreateWindowWithProperties */ extern SDL_DECLSPEC void SDLCALL SDL_DestroyWindow(SDL_Window *window); /** * Check whether the screensaver is currently enabled. * * The screensaver is disabled by default. * * The default can also be changed using `SDL_HINT_VIDEO_ALLOW_SCREENSAVER`. * * \returns true if the screensaver is enabled, false if it is disabled. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_DisableScreenSaver * \sa SDL_EnableScreenSaver */ extern SDL_DECLSPEC bool SDLCALL SDL_ScreenSaverEnabled(void); /** * Allow the screen to be blanked by a screen saver. * * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_DisableScreenSaver * \sa SDL_ScreenSaverEnabled */ extern SDL_DECLSPEC bool SDLCALL SDL_EnableScreenSaver(void); /** * Prevent the screen from being blanked by a screen saver. * * If you disable the screensaver, it is automatically re-enabled when SDL * quits. * * The screensaver is disabled by default, but this may by changed by * SDL_HINT_VIDEO_ALLOW_SCREENSAVER. * * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_EnableScreenSaver * \sa SDL_ScreenSaverEnabled */ extern SDL_DECLSPEC bool SDLCALL SDL_DisableScreenSaver(void); /** * \name OpenGL support functions */ /* @{ */ /** * Dynamically load an OpenGL library. * * This should be done after initializing the video driver, but before * creating any OpenGL windows. If no OpenGL library is loaded, the default * library will be loaded upon creation of the first OpenGL window. * * If you do this, you need to retrieve all of the GL functions used in your * program from the dynamic library using SDL_GL_GetProcAddress(). * * \param path the platform dependent OpenGL library name, or NULL to open the * default OpenGL library. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GL_GetProcAddress * \sa SDL_GL_UnloadLibrary */ extern SDL_DECLSPEC bool SDLCALL SDL_GL_LoadLibrary(const char *path); /** * Get an OpenGL function by name. * * If the GL library is loaded at runtime with SDL_GL_LoadLibrary(), then all * GL functions must be retrieved this way. Usually this is used to retrieve * function pointers to OpenGL extensions. * * There are some quirks to looking up OpenGL functions that require some * extra care from the application. If you code carefully, you can handle * these quirks without any platform-specific code, though: * * - On Windows, function pointers are specific to the current GL context; * this means you need to have created a GL context and made it current * before calling SDL_GL_GetProcAddress(). If you recreate your context or * create a second context, you should assume that any existing function * pointers aren't valid to use with it. This is (currently) a * Windows-specific limitation, and in practice lots of drivers don't suffer * this limitation, but it is still the way the wgl API is documented to * work and you should expect crashes if you don't respect it. Store a copy * of the function pointers that comes and goes with context lifespan. * - On X11, function pointers returned by this function are valid for any * context, and can even be looked up before a context is created at all. * This means that, for at least some common OpenGL implementations, if you * look up a function that doesn't exist, you'll get a non-NULL result that * is _NOT_ safe to call. You must always make sure the function is actually * available for a given GL context before calling it, by checking for the * existence of the appropriate extension with SDL_GL_ExtensionSupported(), * or verifying that the version of OpenGL you're using offers the function * as core functionality. * - Some OpenGL drivers, on all platforms, *will* return NULL if a function * isn't supported, but you can't count on this behavior. Check for * extensions you use, and if you get a NULL anyway, act as if that * extension wasn't available. This is probably a bug in the driver, but you * can code defensively for this scenario anyhow. * - Just because you're on Linux/Unix, don't assume you'll be using X11. * Next-gen display servers are waiting to replace it, and may or may not * make the same promises about function pointers. * - OpenGL function pointers must be declared `APIENTRY` as in the example * code. This will ensure the proper calling convention is followed on * platforms where this matters (Win32) thereby avoiding stack corruption. * * \param proc the name of an OpenGL function. * \returns a pointer to the named OpenGL function. The returned pointer * should be cast to the appropriate function signature. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GL_ExtensionSupported * \sa SDL_GL_LoadLibrary * \sa SDL_GL_UnloadLibrary */ extern SDL_DECLSPEC SDL_FunctionPointer SDLCALL SDL_GL_GetProcAddress(const char *proc); /** * Get an EGL library function by name. * * If an EGL library is loaded, this function allows applications to get entry * points for EGL functions. This is useful to provide to an EGL API and * extension loader. * * \param proc the name of an EGL function. * \returns a pointer to the named EGL function. The returned pointer should * be cast to the appropriate function signature. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_EGL_GetCurrentDisplay */ extern SDL_DECLSPEC SDL_FunctionPointer SDLCALL SDL_EGL_GetProcAddress(const char *proc); /** * Unload the OpenGL library previously loaded by SDL_GL_LoadLibrary(). * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GL_LoadLibrary */ extern SDL_DECLSPEC void SDLCALL SDL_GL_UnloadLibrary(void); /** * Check if an OpenGL extension is supported for the current context. * * This function operates on the current GL context; you must have created a * context and it must be current before calling this function. Do not assume * that all contexts you create will have the same set of extensions * available, or that recreating an existing context will offer the same * extensions again. * * While it's probably not a massive overhead, this function is not an O(1) * operation. Check the extensions you care about after creating the GL * context and save that information somewhere instead of calling the function * every time you need to know. * * \param extension the name of the extension to check. * \returns true if the extension is supported, false otherwise. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC bool SDLCALL SDL_GL_ExtensionSupported(const char *extension); /** * Reset all previously set OpenGL context attributes to their default values. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GL_GetAttribute * \sa SDL_GL_SetAttribute */ extern SDL_DECLSPEC void SDLCALL SDL_GL_ResetAttributes(void); /** * Set an OpenGL window attribute before window creation. * * This function sets the OpenGL attribute `attr` to `value`. The requested * attributes should be set before creating an OpenGL window. You should use * SDL_GL_GetAttribute() to check the values after creating the OpenGL * context, since the values obtained can differ from the requested ones. * * \param attr an enum value specifying the OpenGL attribute to set. * \param value the desired value for the attribute. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GL_CreateContext * \sa SDL_GL_GetAttribute * \sa SDL_GL_ResetAttributes */ extern SDL_DECLSPEC bool SDLCALL SDL_GL_SetAttribute(SDL_GLAttr attr, int value); /** * Get the actual value for an attribute from the current context. * * \param attr an SDL_GLAttr enum value specifying the OpenGL attribute to * get. * \param value a pointer filled in with the current value of `attr`. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GL_ResetAttributes * \sa SDL_GL_SetAttribute */ extern SDL_DECLSPEC bool SDLCALL SDL_GL_GetAttribute(SDL_GLAttr attr, int *value); /** * Create an OpenGL context for an OpenGL window, and make it current. * * The OpenGL context will be created with the current states set through * SDL_GL_SetAttribute(). * * The SDL_Window specified must have been created with the SDL_WINDOW_OPENGL * flag, or context creation will fail. * * Windows users new to OpenGL should note that, for historical reasons, GL * functions added after OpenGL version 1.1 are not available by default. * Those functions must be loaded at run-time, either with an OpenGL * extension-handling library or with SDL_GL_GetProcAddress() and its related * functions. * * SDL_GLContext is opaque to the application. * * \param window the window to associate with the context. * \returns the OpenGL context associated with `window` or NULL on failure; * call SDL_GetError() for more information. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GL_DestroyContext * \sa SDL_GL_MakeCurrent */ extern SDL_DECLSPEC SDL_GLContext SDLCALL SDL_GL_CreateContext(SDL_Window *window); /** * Set up an OpenGL context for rendering into an OpenGL window. * * The context must have been created with a compatible window. * * \param window the window to associate with the context. * \param context the OpenGL context to associate with the window. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GL_CreateContext */ extern SDL_DECLSPEC bool SDLCALL SDL_GL_MakeCurrent(SDL_Window *window, SDL_GLContext context); /** * Get the currently active OpenGL window. * * \returns the currently active OpenGL window on success or NULL on failure; * call SDL_GetError() for more information. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC SDL_Window * SDLCALL SDL_GL_GetCurrentWindow(void); /** * Get the currently active OpenGL context. * * \returns the currently active OpenGL context or NULL on failure; call * SDL_GetError() for more information. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GL_MakeCurrent */ extern SDL_DECLSPEC SDL_GLContext SDLCALL SDL_GL_GetCurrentContext(void); /** * Get the currently active EGL display. * * \returns the currently active EGL display or NULL on failure; call * SDL_GetError() for more information. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC SDL_EGLDisplay SDLCALL SDL_EGL_GetCurrentDisplay(void); /** * Get the currently active EGL config. * * \returns the currently active EGL config or NULL on failure; call * SDL_GetError() for more information. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC SDL_EGLConfig SDLCALL SDL_EGL_GetCurrentConfig(void); /** * Get the EGL surface associated with the window. * * \param window the window to query. * \returns the EGLSurface pointer associated with the window, or NULL on * failure. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC SDL_EGLSurface SDLCALL SDL_EGL_GetWindowSurface(SDL_Window *window); /** * Sets the callbacks for defining custom EGLAttrib arrays for EGL * initialization. * * Callbacks that aren't needed can be set to NULL. * * NOTE: These callback pointers will be reset after SDL_GL_ResetAttributes. * * \param platformAttribCallback callback for attributes to pass to * eglGetPlatformDisplay. May be NULL. * \param surfaceAttribCallback callback for attributes to pass to * eglCreateSurface. May be NULL. * \param contextAttribCallback callback for attributes to pass to * eglCreateContext. May be NULL. * \param userdata a pointer that is passed to the callbacks. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC void SDLCALL SDL_EGL_SetAttributeCallbacks(SDL_EGLAttribArrayCallback platformAttribCallback, SDL_EGLIntArrayCallback surfaceAttribCallback, SDL_EGLIntArrayCallback contextAttribCallback, void *userdata); /** * Set the swap interval for the current OpenGL context. * * Some systems allow specifying -1 for the interval, to enable adaptive * vsync. Adaptive vsync works the same as vsync, but if you've already missed * the vertical retrace for a given frame, it swaps buffers immediately, which * might be less jarring for the user during occasional framerate drops. If an * application requests adaptive vsync and the system does not support it, * this function will fail and return false. In such a case, you should * probably retry the call with 1 for the interval. * * Adaptive vsync is implemented for some glX drivers with * GLX_EXT_swap_control_tear, and for some Windows drivers with * WGL_EXT_swap_control_tear. * * Read more on the Khronos wiki: * https://www.khronos.org/opengl/wiki/Swap_Interval#Adaptive_Vsync * * \param interval 0 for immediate updates, 1 for updates synchronized with * the vertical retrace, -1 for adaptive vsync. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GL_GetSwapInterval */ extern SDL_DECLSPEC bool SDLCALL SDL_GL_SetSwapInterval(int interval); /** * Get the swap interval for the current OpenGL context. * * If the system can't determine the swap interval, or there isn't a valid * current context, this function will set *interval to 0 as a safe default. * * \param interval output interval value. 0 if there is no vertical retrace * synchronization, 1 if the buffer swap is synchronized with * the vertical retrace, and -1 if late swaps happen * immediately instead of waiting for the next retrace. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GL_SetSwapInterval */ extern SDL_DECLSPEC bool SDLCALL SDL_GL_GetSwapInterval(int *interval); /** * Update a window with OpenGL rendering. * * This is used with double-buffered OpenGL contexts, which are the default. * * On macOS, make sure you bind 0 to the draw framebuffer before swapping the * window, otherwise nothing will happen. If you aren't using * glBindFramebuffer(), this is the default and you won't have to do anything * extra. * * \param window the window to change. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC bool SDLCALL SDL_GL_SwapWindow(SDL_Window *window); /** * Delete an OpenGL context. * * \param context the OpenGL context to be deleted. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_GL_CreateContext */ extern SDL_DECLSPEC bool SDLCALL SDL_GL_DestroyContext(SDL_GLContext context); /* @} *//* OpenGL support functions */ /* Ends C function definitions when using C++ */ #ifdef __cplusplus } #endif #include #endif /* SDL_video_h_ */ ================================================ FILE: deps/include/SDL3/SDL_vulkan.h ================================================ /* Simple DirectMedia Layer Copyright (C) 2017, Mark Callow This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ /** * # CategoryVulkan * * Functions for creating Vulkan surfaces on SDL windows. * * For the most part, Vulkan operates independent of SDL, but it benefits from * a little support during setup. * * Use SDL_Vulkan_GetInstanceExtensions() to get platform-specific bits for * creating a VkInstance, then SDL_Vulkan_GetVkGetInstanceProcAddr() to get * the appropriate function for querying Vulkan entry points. Then * SDL_Vulkan_CreateSurface() will get you the final pieces you need to * prepare for rendering into an SDL_Window with Vulkan. * * Unlike OpenGL, most of the details of "context" creation and window buffer * swapping are handled by the Vulkan API directly, so SDL doesn't provide * Vulkan equivalents of SDL_GL_SwapWindow(), etc; they aren't necessary. */ #ifndef SDL_vulkan_h_ #define SDL_vulkan_h_ #include #include #include #include /* Set up for C function definitions, even when using C++ */ #ifdef __cplusplus extern "C" { #endif /* Avoid including vulkan_core.h, don't define VkInstance if it's already included */ #ifdef VULKAN_CORE_H_ #define NO_SDL_VULKAN_TYPEDEFS #endif #ifndef NO_SDL_VULKAN_TYPEDEFS #define VK_DEFINE_HANDLE(object) typedef struct object##_T* object; #if defined(__LP64__) || defined(_WIN64) || (defined(__x86_64__) && !defined(__ILP32__)) || defined(_M_X64) || defined(__ia64) || defined (_M_IA64) || defined(__aarch64__) || defined(__powerpc64__) || (defined(__riscv) && __riscv_xlen == 64) #define VK_DEFINE_NON_DISPATCHABLE_HANDLE(object) typedef struct object##_T *object; #else #define VK_DEFINE_NON_DISPATCHABLE_HANDLE(object) typedef uint64_t object; #endif VK_DEFINE_HANDLE(VkInstance) VK_DEFINE_HANDLE(VkPhysicalDevice) VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkSurfaceKHR) struct VkAllocationCallbacks; /* Make sure to undef to avoid issues in case of later vulkan include */ #undef VK_DEFINE_HANDLE #undef VK_DEFINE_NON_DISPATCHABLE_HANDLE #endif /* !NO_SDL_VULKAN_TYPEDEFS */ /** * \name Vulkan support functions */ /* @{ */ /** * Dynamically load the Vulkan loader library. * * This should be called after initializing the video driver, but before * creating any Vulkan windows. If no Vulkan loader library is loaded, the * default library will be loaded upon creation of the first Vulkan window. * * SDL keeps a counter of how many times this function has been successfully * called, so it is safe to call this function multiple times, so long as it * is eventually paired with an equivalent number of calls to * SDL_Vulkan_UnloadLibrary. The `path` argument is ignored unless there is no * library currently loaded, and and the library isn't actually unloaded until * there have been an equivalent number of calls to SDL_Vulkan_UnloadLibrary. * * It is fairly common for Vulkan applications to link with libvulkan instead * of explicitly loading it at run time. This will work with SDL provided the * application links to a dynamic library and both it and SDL use the same * search path. * * If you specify a non-NULL `path`, an application should retrieve all of the * Vulkan functions it uses from the dynamic library using * SDL_Vulkan_GetVkGetInstanceProcAddr unless you can guarantee `path` points * to the same vulkan loader library the application linked to. * * On Apple devices, if `path` is NULL, SDL will attempt to find the * `vkGetInstanceProcAddr` address within all the Mach-O images of the current * process. This is because it is fairly common for Vulkan applications to * link with libvulkan (and historically MoltenVK was provided as a static * library). If it is not found, on macOS, SDL will attempt to load * `vulkan.framework/vulkan`, `libvulkan.1.dylib`, * `MoltenVK.framework/MoltenVK`, and `libMoltenVK.dylib`, in that order. On * iOS, SDL will attempt to load `libMoltenVK.dylib`. Applications using a * dynamic framework or .dylib must ensure it is included in its application * bundle. * * On non-Apple devices, application linking with a static libvulkan is not * supported. Either do not link to the Vulkan loader or link to a dynamic * library version. * * \param path the platform dependent Vulkan loader library name or NULL. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \threadsafety This function is not thread safe. * * \since This function is available since SDL 3.2.0. * * \sa SDL_Vulkan_GetVkGetInstanceProcAddr * \sa SDL_Vulkan_UnloadLibrary */ extern SDL_DECLSPEC bool SDLCALL SDL_Vulkan_LoadLibrary(const char *path); /** * Get the address of the `vkGetInstanceProcAddr` function. * * This should be called after either calling SDL_Vulkan_LoadLibrary() or * creating an SDL_Window with the `SDL_WINDOW_VULKAN` flag. * * The actual type of the returned function pointer is * PFN_vkGetInstanceProcAddr, but that isn't available because the Vulkan * headers are not included here. You should cast the return value of this * function to that type, e.g. * * `vkGetInstanceProcAddr = * (PFN_vkGetInstanceProcAddr)SDL_Vulkan_GetVkGetInstanceProcAddr();` * * \returns the function pointer for `vkGetInstanceProcAddr` or NULL on * failure; call SDL_GetError() for more information. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC SDL_FunctionPointer SDLCALL SDL_Vulkan_GetVkGetInstanceProcAddr(void); /** * Unload the Vulkan library previously loaded by SDL_Vulkan_LoadLibrary(). * * SDL keeps a counter of how many times this function has been called, so it * is safe to call this function multiple times, so long as it is paired with * an equivalent number of calls to SDL_Vulkan_LoadLibrary. The library isn't * actually unloaded until there have been an equivalent number of calls to * SDL_Vulkan_UnloadLibrary. * * Once the library has actually been unloaded, if any Vulkan instances * remain, they will likely crash the program. Clean up any existing Vulkan * resources, and destroy appropriate windows, renderers and GPU devices * before calling this function. * * \threadsafety This function is not thread safe. * * \since This function is available since SDL 3.2.0. * * \sa SDL_Vulkan_LoadLibrary */ extern SDL_DECLSPEC void SDLCALL SDL_Vulkan_UnloadLibrary(void); /** * Get the Vulkan instance extensions needed for vkCreateInstance. * * This should be called after either calling SDL_Vulkan_LoadLibrary() or * creating an SDL_Window with the `SDL_WINDOW_VULKAN` flag. * * On return, the variable pointed to by `count` will be set to the number of * elements returned, suitable for using with * VkInstanceCreateInfo::enabledExtensionCount, and the returned array can be * used with VkInstanceCreateInfo::ppEnabledExtensionNames, for calling * Vulkan's vkCreateInstance API. * * You should not free the returned array; it is owned by SDL. * * \param count a pointer filled in with the number of extensions returned. * \returns an array of extension name strings on success, NULL on failure; * call SDL_GetError() for more information. * * \since This function is available since SDL 3.2.0. * * \sa SDL_Vulkan_CreateSurface */ extern SDL_DECLSPEC char const * const * SDLCALL SDL_Vulkan_GetInstanceExtensions(Uint32 *count); /** * Create a Vulkan rendering surface for a window. * * The `window` must have been created with the `SDL_WINDOW_VULKAN` flag and * `instance` must have been created with extensions returned by * SDL_Vulkan_GetInstanceExtensions() enabled. * * If `allocator` is NULL, Vulkan will use the system default allocator. This * argument is passed directly to Vulkan and isn't used by SDL itself. * * \param window the window to which to attach the Vulkan surface. * \param instance the Vulkan instance handle. * \param allocator a VkAllocationCallbacks struct, which lets the app set the * allocator that creates the surface. Can be NULL. * \param surface a pointer to a VkSurfaceKHR handle to output the newly * created surface. * \returns true on success or false on failure; call SDL_GetError() for more * information. * * \since This function is available since SDL 3.2.0. * * \sa SDL_Vulkan_GetInstanceExtensions * \sa SDL_Vulkan_DestroySurface */ extern SDL_DECLSPEC bool SDLCALL SDL_Vulkan_CreateSurface(SDL_Window *window, VkInstance instance, const struct VkAllocationCallbacks *allocator, VkSurfaceKHR *surface); /** * Destroy the Vulkan rendering surface of a window. * * This should be called before SDL_DestroyWindow, if SDL_Vulkan_CreateSurface * was called after SDL_CreateWindow. * * The `instance` must have been created with extensions returned by * SDL_Vulkan_GetInstanceExtensions() enabled and `surface` must have been * created successfully by an SDL_Vulkan_CreateSurface() call. * * If `allocator` is NULL, Vulkan will use the system default allocator. This * argument is passed directly to Vulkan and isn't used by SDL itself. * * \param instance the Vulkan instance handle. * \param surface vkSurfaceKHR handle to destroy. * \param allocator a VkAllocationCallbacks struct, which lets the app set the * allocator that destroys the surface. Can be NULL. * * \since This function is available since SDL 3.2.0. * * \sa SDL_Vulkan_GetInstanceExtensions * \sa SDL_Vulkan_CreateSurface */ extern SDL_DECLSPEC void SDLCALL SDL_Vulkan_DestroySurface(VkInstance instance, VkSurfaceKHR surface, const struct VkAllocationCallbacks *allocator); /** * Query support for presentation via a given physical device and queue * family. * * The `instance` must have been created with extensions returned by * SDL_Vulkan_GetInstanceExtensions() enabled. * * \param instance the Vulkan instance handle. * \param physicalDevice a valid Vulkan physical device handle. * \param queueFamilyIndex a valid queue family index for the given physical * device. * \returns true if supported, false if unsupported or an error occurred. * * \since This function is available since SDL 3.2.0. * * \sa SDL_Vulkan_GetInstanceExtensions */ extern SDL_DECLSPEC bool SDLCALL SDL_Vulkan_GetPresentationSupport(VkInstance instance, VkPhysicalDevice physicalDevice, Uint32 queueFamilyIndex); /* @} *//* Vulkan support functions */ /* Ends C function definitions when using C++ */ #ifdef __cplusplus } #endif #include #endif /* SDL_vulkan_h_ */ ================================================ FILE: deps/include/TinySoundFont/tml.h ================================================ /* TinyMidiLoader - v0.7 - Minimalistic midi parsing library - https://github.com/schellingb/TinySoundFont no warranty implied; use at your own risk Do this: #define TML_IMPLEMENTATION before you include this file in *one* C or C++ file to create the implementation. // i.e. it should look like this: #include ... #include ... #define TML_IMPLEMENTATION #include "tml.h" [OPTIONAL] #define TML_NO_STDIO to remove stdio dependency [OPTIONAL] #define TML_MALLOC, TML_REALLOC, and TML_FREE to avoid stdlib.h [OPTIONAL] #define TML_MEMCPY to avoid string.h LICENSE (ZLIB) Copyright (C) 2017, 2018 Bernhard Schelling This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ #ifndef TML_INCLUDE_TML_INL #define TML_INCLUDE_TML_INL #ifdef __cplusplus extern "C" { #endif // Define this if you want the API functions to be static #ifdef TML_STATIC #define TMLDEF static #else #define TMLDEF extern #endif // Channel message type enum TMLMessageType { TML_NOTE_OFF = 0x80, TML_NOTE_ON = 0x90, TML_KEY_PRESSURE = 0xA0, TML_CONTROL_CHANGE = 0xB0, TML_PROGRAM_CHANGE = 0xC0, TML_CHANNEL_PRESSURE = 0xD0, TML_PITCH_BEND = 0xE0, TML_SET_TEMPO = 0x51 }; // Midi controller numbers enum TMLController { TML_BANK_SELECT_MSB, TML_MODULATIONWHEEL_MSB, TML_BREATH_MSB, TML_FOOT_MSB = 4, TML_PORTAMENTO_TIME_MSB, TML_DATA_ENTRY_MSB, TML_VOLUME_MSB, TML_BALANCE_MSB, TML_PAN_MSB = 10, TML_EXPRESSION_MSB, TML_EFFECTS1_MSB, TML_EFFECTS2_MSB, TML_GPC1_MSB = 16, TML_GPC2_MSB, TML_GPC3_MSB, TML_GPC4_MSB, TML_BANK_SELECT_LSB = 32, TML_MODULATIONWHEEL_LSB, TML_BREATH_LSB, TML_FOOT_LSB = 36, TML_PORTAMENTO_TIME_LSB, TML_DATA_ENTRY_LSB, TML_VOLUME_LSB, TML_BALANCE_LSB, TML_PAN_LSB = 42, TML_EXPRESSION_LSB, TML_EFFECTS1_LSB, TML_EFFECTS2_LSB, TML_GPC1_LSB = 48, TML_GPC2_LSB, TML_GPC3_LSB, TML_GPC4_LSB, TML_SUSTAIN_SWITCH = 64, TML_PORTAMENTO_SWITCH, TML_SOSTENUTO_SWITCH, TML_SOFT_PEDAL_SWITCH, TML_LEGATO_SWITCH, TML_HOLD2_SWITCH, TML_SOUND_CTRL1, TML_SOUND_CTRL2, TML_SOUND_CTRL3, TML_SOUND_CTRL4, TML_SOUND_CTRL5, TML_SOUND_CTRL6, TML_SOUND_CTRL7, TML_SOUND_CTRL8, TML_SOUND_CTRL9, TML_SOUND_CTRL10, TML_GPC5, TML_GPC6, TML_GPC7, TML_GPC8, TML_PORTAMENTO_CTRL, TML_FX_REVERB = 91, TML_FX_TREMOLO, TML_FX_CHORUS, TML_FX_CELESTE_DETUNE, TML_FX_PHASER, TML_DATA_ENTRY_INCR, TML_DATA_ENTRY_DECR, TML_NRPN_LSB, TML_NRPN_MSB, TML_RPN_LSB, TML_RPN_MSB, TML_ALL_SOUND_OFF = 120, TML_ALL_CTRL_OFF, TML_LOCAL_CONTROL, TML_ALL_NOTES_OFF, TML_OMNI_OFF, TML_OMNI_ON, TML_POLY_OFF, TML_POLY_ON }; // A single MIDI message linked to the next message in time typedef struct tml_message { // Time of the message in milliseconds unsigned int time; // Type (see TMLMessageType) and channel number unsigned char type, channel; // 2 byte of parameter data based on the type: // - key, velocity for TML_NOTE_ON and TML_NOTE_OFF messages // - key, key_pressure for TML_KEY_PRESSURE messages // - control, control_value for TML_CONTROL_CHANGE messages (see TMLController) // - program for TML_PROGRAM_CHANGE messages // - channel_pressure for TML_CHANNEL_PRESSURE messages // - pitch_bend for TML_PITCH_BEND messages union { struct { union { char key, control, program, channel_pressure; }; union { char velocity, key_pressure, control_value; }; }; struct { unsigned short pitch_bend; }; }; // The pointer to the next message in time following this event struct tml_message* next; } tml_message; // The load functions will return a pointer to a struct tml_message. // Normally the linked list gets traversed by following the next pointers. // Make sure to keep the pointer to the first message to free the memory. // On error the tml_load* functions will return NULL most likely due to an // invalid MIDI stream (or if the file did not exist in tml_load_filename). #ifndef TML_NO_STDIO // Directly load a MIDI file from a .mid file path TMLDEF tml_message* tml_load_filename(const char* filename); #endif // Load a MIDI file from a block of memory TMLDEF tml_message* tml_load_memory(const void* buffer, int size); // Get infos about this loaded MIDI file, returns the note count // NULL can be passed for any output value pointer if not needed. // used_channels: Will be set to how many channels play notes // (i.e. 1 if channel 15 is used but no other) // used_programs: Will be set to how many different programs are used // total_notes: Will be set to the total number of note on messages // time_first_note: Will be set to the time of the first note on message // time_length: Will be set to the total time in milliseconds TMLDEF int tml_get_info(tml_message* first_message, int* used_channels, int* used_programs, int* total_notes, unsigned int* time_first_note, unsigned int* time_length); // Read the tempo (microseconds per quarter note) value from a message with the type TML_SET_TEMPO TMLDEF int tml_get_tempo_value(tml_message* set_tempo_message); // Free all the memory of the linked message list (can also call free() manually) TMLDEF void tml_free(tml_message* f); // Stream structure for the generic loading struct tml_stream { // Custom data given to the functions as the first parameter void* data; // Function pointer will be called to read 'size' bytes into ptr (returns number of read bytes) int (*read)(void* data, void* ptr, unsigned int size); }; // Generic Midi loading method using the stream structure above TMLDEF tml_message* tml_load(struct tml_stream* stream); TMLDEF tml_message* tml_load_tsf_stream(struct tsf_stream* stream); #ifdef __cplusplus } #endif // end header // --------------------------------------------------------------------------------------------------------- #endif //TML_INCLUDE_TML_INL #ifdef TML_IMPLEMENTATION #if !defined(TML_MALLOC) || !defined(TML_FREE) || !defined(TML_REALLOC) # include # define TML_MALLOC malloc # define TML_FREE free # define TML_REALLOC realloc #endif #if !defined(TML_MEMCPY) # include # define TML_MEMCPY memcpy #endif #ifndef TML_NO_STDIO # include #endif #define TML_NULL 0 ////crash on errors and warnings to find broken midi files while debugging //#define TML_ERROR(msg) *(int*)0 = 0xbad; //#define TML_WARN(msg) *(int*)0 = 0xf00d; ////print errors and warnings //#define TML_ERROR(msg) printf("ERROR: %s\n", msg); //#define TML_WARN(msg) printf("WARNING: %s\n", msg); #ifndef TML_ERROR #define TML_ERROR(msg) #endif #ifndef TML_WARN #define TML_WARN(msg) #endif #ifdef __cplusplus extern "C" { #endif #ifndef TML_NO_STDIO static int tml_stream_stdio_read(FILE* f, void* ptr, unsigned int size) { return (int)fread(ptr, 1, size, f); } TMLDEF tml_message* tml_load_filename(const char* filename) { struct tml_message* res; struct tml_stream stream = { TML_NULL, (int(*)(void*,void*,unsigned int))&tml_stream_stdio_read }; #if __STDC_WANT_SECURE_LIB__ FILE* f = TML_NULL; fopen_s(&f, filename, "rb"); #else FILE* f = fopen(filename, "rb"); #endif if (!f) { TML_ERROR("File not found"); return 0; } stream.data = f; res = tml_load(&stream); fclose(f); return res; } #endif struct tml_stream_memory { const char* buffer; unsigned int total, pos; }; static int tml_stream_memory_read(struct tml_stream_memory* m, void* ptr, unsigned int size) { if (size > m->total - m->pos) size = m->total - m->pos; TML_MEMCPY(ptr, m->buffer+m->pos, size); m->pos += size; return size; } TMLDEF struct tml_message* tml_load_memory(const void* buffer, int size) { struct tml_stream stream = { TML_NULL, (int(*)(void*,void*,unsigned int))&tml_stream_memory_read }; struct tml_stream_memory f = { 0, 0, 0 }; f.buffer = (const char*)buffer; f.total = size; stream.data = &f; return tml_load(&stream); } struct tml_track { unsigned int Idx, End, Ticks; }; struct tml_tempomsg { unsigned int time; unsigned char type, Tempo[3]; tml_message* next; }; struct tml_parser { unsigned char *buf, *buf_end; int last_status, message_array_size, message_count; }; enum TMLSystemType { TML_TEXT = 0x01, TML_COPYRIGHT = 0x02, TML_TRACK_NAME = 0x03, TML_INST_NAME = 0x04, TML_LYRIC = 0x05, TML_MARKER = 0x06, TML_CUE_POINT = 0x07, TML_EOT = 0x2f, TML_SMPTE_OFFSET = 0x54, TML_TIME_SIGNATURE = 0x58, TML_KEY_SIGNATURE = 0x59, TML_SEQUENCER_EVENT = 0x7f, TML_SYSEX = 0xf0, TML_TIME_CODE = 0xf1, TML_SONG_POSITION = 0xf2, TML_SONG_SELECT = 0xf3, TML_TUNE_REQUEST = 0xf6, TML_EOX = 0xf7, TML_SYNC = 0xf8, TML_TICK = 0xf9, TML_START = 0xfa, TML_CONTINUE = 0xfb, TML_STOP = 0xfc, TML_ACTIVE_SENSING = 0xfe, TML_SYSTEM_RESET = 0xff }; static int tml_readbyte(struct tml_parser* p) { return (p->buf == p->buf_end ? -1 : *(p->buf++)); } static int tml_readvariablelength(struct tml_parser* p) { unsigned int res = 0, i = 0; unsigned char c; for (; i != 4; i++) { if (p->buf == p->buf_end) { TML_WARN("Unexpected end of file"); return -1; } c = *(p->buf++); if (c & 0x80) res = ((res | (c & 0x7F)) << 7); else return (int)(res | c); } TML_WARN("Invalid variable length byte count"); return -1; } static int tml_parsemessage(tml_message** f, struct tml_parser* p) { int deltatime = tml_readvariablelength(p), status = tml_readbyte(p); tml_message* evt; if (deltatime & 0xFFF00000) deltatime = 0; //throw away delays that are insanely high for malformatted midis if (status < 0) { TML_WARN("Unexpected end of file"); return -1; } if ((status & 0x80) == 0) { // Invalid, use same status as before if ((p->last_status & 0x80) == 0) { TML_WARN("Undefined status and invalid running status"); return -1; } p->buf--; status = p->last_status; } else p->last_status = status; if (p->message_array_size == p->message_count) { //start allocated memory size of message array at 64, double each time until 8192, then add 1024 entries until done p->message_array_size += (!p->message_array_size ? 64 : (p->message_array_size > 4096 ? 1024 : p->message_array_size)); *f = (tml_message*)TML_REALLOC(*f, p->message_array_size * sizeof(tml_message)); if (!*f) { TML_ERROR("Out of memory"); return -1; } } evt = *f + p->message_count; //check what message we have if ((status == TML_SYSEX) || (status == TML_EOX)) //sysex { //sysex messages are not handled p->buf += tml_readvariablelength(p); if (p->buf > p->buf_end) { TML_WARN("Unexpected end of file"); p->buf = p->buf_end; return -1; } evt->type = 0; } else if (status == 0xFF) //meta events { int meta_type = tml_readbyte(p), buflen = tml_readvariablelength(p); unsigned char* metadata = p->buf; if (meta_type < 0) { TML_WARN("Unexpected end of file"); return -1; } if (buflen > 0 && (p->buf += buflen) > p->buf_end) { TML_WARN("Unexpected end of file"); p->buf = p->buf_end; return -1; } switch (meta_type) { case TML_EOT: if (buflen != 0) { TML_WARN("Invalid length for EndOfTrack event"); return -1; } if (!deltatime) return TML_EOT; //no need to store this message evt->type = TML_EOT; break; case TML_SET_TEMPO: if (buflen != 3) { TML_WARN("Invalid length for SetTempo meta event"); return -1; } evt->type = TML_SET_TEMPO; ((struct tml_tempomsg*)evt)->Tempo[0] = metadata[0]; ((struct tml_tempomsg*)evt)->Tempo[1] = metadata[1]; ((struct tml_tempomsg*)evt)->Tempo[2] = metadata[2]; break; default: evt->type = 0; } } else //channel message { int param; if ((param = tml_readbyte(p)) < 0) { TML_WARN("Unexpected end of file"); return -1; } evt->key = (param & 0x7f); evt->channel = (status & 0x0f); switch (evt->type = (status & 0xf0)) { case TML_NOTE_OFF: case TML_NOTE_ON: case TML_KEY_PRESSURE: case TML_CONTROL_CHANGE: if ((param = tml_readbyte(p)) < 0) { TML_WARN("Unexpected end of file"); return -1; } evt->velocity = (param & 0x7f); break; case TML_PITCH_BEND: if ((param = tml_readbyte(p)) < 0) { TML_WARN("Unexpected end of file"); return -1; } evt->pitch_bend = ((param & 0x7f) << 7) | evt->key; break; case TML_PROGRAM_CHANGE: case TML_CHANNEL_PRESSURE: evt->velocity = 0; break; default: //ignore system/manufacture messages evt->type = 0; break; } } if (deltatime || evt->type) { evt->time = deltatime; p->message_count++; } return evt->type; } TMLDEF tml_message* tml_load(struct tml_stream* stream) { int num_tracks, division, trackbufsize = 0; unsigned char midi_header[14], *trackbuf = TML_NULL; struct tml_message* messages = TML_NULL; struct tml_track *tracks, *t, *tracksEnd; struct tml_parser p = { TML_NULL, TML_NULL, 0, 0, 0 }; // Parse MIDI header if (stream->read(stream->data, midi_header, 14) != 14) { TML_ERROR("Unexpected end of file"); return messages; } if (midi_header[0] != 'M' || midi_header[1] != 'T' || midi_header[2] != 'h' || midi_header[3] != 'd' || midi_header[7] != 6 || midi_header[9] > 2) { TML_ERROR("Doesn't look like a MIDI file: invalid MThd header"); return messages; } if (midi_header[12] & 0x80) { TML_ERROR("File uses unsupported SMPTE timing"); return messages; } num_tracks = (int)(midi_header[10] << 8) | midi_header[11]; division = (int)(midi_header[12] << 8) | midi_header[13]; //division is ticks per beat (quarter-note) if (num_tracks <= 0 && division <= 0) { TML_ERROR("Doesn't look like a MIDI file: invalid track or division values"); return messages; } // Allocate temporary tracks array for parsing tracks = (struct tml_track*)TML_MALLOC(sizeof(struct tml_track) * num_tracks); tracksEnd = &tracks[num_tracks]; for (t = tracks; t != tracksEnd; t++) t->Idx = t->End = t->Ticks = 0; // Read all messages for all tracks for (t = tracks; t != tracksEnd; t++) { unsigned char track_header[8]; int track_length; if (stream->read(stream->data, track_header, 8) != 8) { TML_WARN("Unexpected end of file"); break; } if (track_header[0] != 'M' || track_header[1] != 'T' || track_header[2] != 'r' || track_header[3] != 'k') { TML_WARN("Invalid MTrk header"); break; } // Get size of track data and read into buffer (allocate bigger buffer if needed) track_length = track_header[7] | (track_header[6] << 8) | (track_header[5] << 16) | (track_header[4] << 24); if (track_length < 0) { TML_WARN("Invalid MTrk header"); break; } if (trackbufsize < track_length) { TML_FREE(trackbuf); trackbuf = (unsigned char*)TML_MALLOC(trackbufsize = track_length); } if (stream->read(stream->data, trackbuf, track_length) != track_length) { TML_WARN("Unexpected end of file"); break; } t->Idx = p.message_count; for (p.buf_end = (p.buf = trackbuf) + track_length; p.buf != p.buf_end;) { int type = tml_parsemessage(&messages, &p); if (type == TML_EOT || type < 0) break; //file end or illegal data encountered } if (p.buf != p.buf_end) { TML_WARN( "Track length did not match data length"); } t->End = p.message_count; } TML_FREE(trackbuf); // Change message time signature from delta ticks to actual msec values and link messages ordered by time if (p.message_count) { tml_message *PrevMessage = TML_NULL, *Msg, *MsgEnd, Swap; unsigned int ticks = 0, tempo_ticks = 0; //tick counter and value at last tempo change int step_smallest, msec, tempo_msec = 0; //msec value at last tempo change double ticks2time = 500000 / (1000.0 * division); //milliseconds per tick // Loop through all messages over all tracks ordered by time for (step_smallest = 0; step_smallest != 0x7fffffff; ticks += step_smallest) { step_smallest = 0x7fffffff; msec = tempo_msec + (int)((ticks - tempo_ticks) * ticks2time); for (t = tracks; t != tracksEnd; t++) { if (t->Idx == t->End) continue; for (Msg = &messages[t->Idx], MsgEnd = &messages[t->End]; Msg != MsgEnd && t->Ticks + Msg->time == ticks; Msg++, t->Idx++) { t->Ticks += Msg->time; if (Msg->type == TML_SET_TEMPO) { unsigned char* Tempo = ((struct tml_tempomsg*)Msg)->Tempo; ticks2time = ((Tempo[0]<<16)|(Tempo[1]<<8)|Tempo[2])/(1000.0 * division); tempo_msec = msec; tempo_ticks = ticks; } if (Msg->type) { Msg->time = msec; if (PrevMessage) { PrevMessage->next = Msg; PrevMessage = Msg; } else { Swap = *Msg; *Msg = *messages; *messages = Swap; PrevMessage = messages; } } } if (Msg != MsgEnd && t->Ticks + Msg->time > ticks) { int step = (int)(t->Ticks + Msg->time - ticks); if (step < step_smallest) step_smallest = step; } } } if (PrevMessage) PrevMessage->next = TML_NULL; else p.message_count = 0; } TML_FREE(tracks); if (p.message_count == 0) { TML_FREE(messages); messages = TML_NULL; } return messages; } TMLDEF tml_message* tml_load_tsf_stream(struct tsf_stream* stream) { return tml_load((struct tml_stream*)stream); } TMLDEF int tml_get_info(tml_message* Msg, int* out_used_channels, int* out_used_programs, int* out_total_notes, unsigned int* out_time_first_note, unsigned int* out_time_length) { int used_programs = 0, used_channels = 0, total_notes = 0; unsigned int time_first_note = 0xffffffff, time_length = 0; unsigned char channels[16] = { 0 }, programs[128] = { 0 }; for (;Msg; Msg = Msg->next) { time_length = Msg->time; if (Msg->type == TML_PROGRAM_CHANGE && !programs[(int)Msg->program]) { programs[(int)Msg->program] = 1; used_programs++; } if (Msg->type != TML_NOTE_ON) continue; if (time_first_note == 0xffffffff) time_first_note = time_length; if (!channels[Msg->channel]) { channels[Msg->channel] = 1; used_channels++; } total_notes++; } if (time_first_note == 0xffffffff) time_first_note = 0; if (out_used_channels ) *out_used_channels = used_channels; if (out_used_programs ) *out_used_programs = used_programs; if (out_total_notes ) *out_total_notes = total_notes; if (out_time_first_note) *out_time_first_note = time_first_note; if (out_time_length ) *out_time_length = time_length; return total_notes; } TMLDEF int tml_get_tempo_value(tml_message* msg) { unsigned char* Tempo; if (!msg || msg->type != TML_SET_TEMPO) return 0; Tempo = ((struct tml_tempomsg*)msg)->Tempo; return ((Tempo[0]<<16)|(Tempo[1]<<8)|Tempo[2]); } TMLDEF void tml_free(tml_message* f) { TML_FREE(f); } #ifdef __cplusplus } #endif #endif //TML_IMPLEMENTATION ================================================ FILE: deps/include/TinySoundFont/tsf.h ================================================ /* TinySoundFont - v0.8 - SoundFont2 synthesizer - https://github.com/schellingb/TinySoundFont no warranty implied; use at your own risk Do this: #define TSF_IMPLEMENTATION before you include this file in *one* C or C++ file to create the implementation. // i.e. it should look like this: #include ... #include ... #define TSF_IMPLEMENTATION #include "tsf.h" [OPTIONAL] #define TSF_NO_STDIO to remove stdio dependency [OPTIONAL] #define TSF_MALLOC, TSF_REALLOC, and TSF_FREE to avoid stdlib.h [OPTIONAL] #define TSF_MEMCPY, TSF_MEMSET to avoid string.h [OPTIONAL] #define TSF_POW, TSF_POWF, TSF_EXPF, TSF_LOG, TSF_TAN, TSF_LOG10, TSF_SQRT to avoid math.h NOT YET IMPLEMENTED - Support for ChorusEffectsSend and ReverbEffectsSend generators - Better low-pass filter without lowering performance too much - Support for modulators LICENSE (MIT) Copyright (C) 2017, 2018 Bernhard Schelling Based on SFZero, Copyright (C) 2012 Steve Folta (https://github.com/stevefolta/SFZero) 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. 3 Sept 2019 Modified by Alejandro Coto - @acoto87 Set a boolean parameter to the function `tsf_note_off_all` that if true, internally will use the `tsf_voice_endquick` instead of `tsf_voice_end`. This will allow shorter times on the release segment, ending the notes quicker. */ #ifndef TSF_INCLUDE_TSF_INL #define TSF_INCLUDE_TSF_INL #ifdef __cplusplus extern "C" { # define CPP_DEFAULT0 = 0 #else # define CPP_DEFAULT0 #endif //define this if you want the API functions to be static #ifdef TSF_STATIC #define TSFDEF static #else #define TSFDEF extern #endif // The load functions will return a pointer to a struct tsf which all functions // thereafter take as the first parameter. // On error the tsf_load* functions will return NULL most likely due to invalid // data (or if the file did not exist in tsf_load_filename). typedef struct tsf tsf; #ifndef TSF_NO_STDIO // Directly load a SoundFont from a .sf2 file path TSFDEF tsf* tsf_load_filename(const char* filename); #endif // Load a SoundFont from a block of memory TSFDEF tsf* tsf_load_memory(const void* buffer, int size); // Stream structure for the generic loading struct tsf_stream { // Custom data given to the functions as the first parameter void* data; // Function pointer will be called to read 'size' bytes into ptr (returns number of read bytes) int (*read)(void* data, void* ptr, unsigned int size); // Function pointer will be called to skip ahead over 'count' bytes (returns 1 on success, 0 on error) int (*skip)(void* data, unsigned int count); }; // Generic SoundFont loading method using the stream structure above TSFDEF tsf* tsf_load(struct tsf_stream* stream); // Free the memory related to this tsf instance TSFDEF void tsf_close(tsf* f); // Stop all playing notes immediatly and reset all channel parameters TSFDEF void tsf_reset(tsf* f); // Returns the preset index from a bank and preset number, or -1 if it does not exist in the loaded SoundFont TSFDEF int tsf_get_presetindex(const tsf* f, int bank, int preset_number); // Returns the number of presets in the loaded SoundFont TSFDEF int tsf_get_presetcount(const tsf* f); // Returns the name of a preset index >= 0 and < tsf_get_presetcount() TSFDEF const char* tsf_get_presetname(const tsf* f, int preset_index); // Returns the name of a preset by bank and preset number TSFDEF const char* tsf_bank_get_presetname(const tsf* f, int bank, int preset_number); // Supported output modes by the render methods enum TSFOutputMode { // Two channels with single left/right samples one after another TSF_STEREO_INTERLEAVED, // Two channels with all samples for the left channel first then right TSF_STEREO_UNWEAVED, // A single channel (stereo instruments are mixed into center) TSF_MONO, }; // Thread safety: // Your audio output which calls the tsf_render* functions will most likely // run on a different thread than where the playback tsf_note* functions // are called. In which case some sort of concurrency control like a // mutex needs to be used so they are not called at the same time. // Setup the parameters for the voice render methods // outputmode: if mono or stereo and how stereo channel data is ordered // samplerate: the number of samples per second (output frequency) // global_gain_db: volume gain in decibels (>0 means higher, <0 means lower) TSFDEF void tsf_set_output(tsf* f, enum TSFOutputMode outputmode, int samplerate, float global_gain_db CPP_DEFAULT0); // Start playing a note // preset_index: preset index >= 0 and < tsf_get_presetcount() // key: note value between 0 and 127 (60 being middle C) // vel: velocity as a float between 0.0 (equal to note off) and 1.0 (full) // bank: instrument bank number (alternative to preset_index) // preset_number: preset number (alternative to preset_index) // (bank_note_on returns 0 if preset does not exist, otherwise 1) TSFDEF void tsf_note_on(tsf* f, int preset_index, int key, float vel); TSFDEF int tsf_bank_note_on(tsf* f, int bank, int preset_number, int key, float vel); // Stop playing a note // (bank_note_off returns 0 if preset does not exist, otherwise 1) TSFDEF void tsf_note_off(tsf* f, int preset_index, int key); TSFDEF int tsf_bank_note_off(tsf* f, int bank, int preset_number, int key); // Stop playing all notes (end with sustain and release) TSFDEF void tsf_note_off_all(tsf* f, int quick); // Returns the number of active voices TSFDEF int tsf_active_voice_count(tsf* f); // Render output samples into a buffer // You can either render as signed 16-bit values (tsf_render_short) or // as 32-bit float values (tsf_render_float) // buffer: target buffer of size samples * output_channels * sizeof(type) // samples: number of samples to render // flag_mixing: if 0 clear the buffer first, otherwise mix into existing data TSFDEF void tsf_render_short(tsf* f, short* buffer, int samples, int flag_mixing CPP_DEFAULT0); TSFDEF void tsf_render_float(tsf* f, float* buffer, int samples, int flag_mixing CPP_DEFAULT0); // Higher level channel based functions, set up channel parameters // channel: channel number // preset_index: preset index >= 0 and < tsf_get_presetcount() // preset_number: preset number (alternative to preset_index) // flag_mididrums: 0 for normal channels, otherwise apply MIDI drum channel rules // bank: instrument bank number (alternative to preset_index) // pan: stereo panning value from 0.0 (left) to 1.0 (right) (default 0.5 center) // volume: linear volume scale factor (default 1.0 full) // pitch_wheel: pitch wheel position 0 to 16383 (default 8192 unpitched) // pitch_range: range of the pitch wheel in semitones (default 2.0, total +/- 2 semitones) // tuning: tuning of all playing voices in semitones (default 0.0, standard (A440) tuning) // (set_preset_number and set_bank_preset return 0 if preset does not exist, otherwise 1) TSFDEF void tsf_channel_set_presetindex(tsf* f, int channel, int preset_index); TSFDEF int tsf_channel_set_presetnumber(tsf* f, int channel, int preset_number, int flag_mididrums CPP_DEFAULT0); TSFDEF void tsf_channel_set_bank(tsf* f, int channel, int bank); TSFDEF int tsf_channel_set_bank_preset(tsf* f, int channel, int bank, int preset_number); TSFDEF void tsf_channel_set_pan(tsf* f, int channel, float pan); TSFDEF void tsf_channel_set_volume(tsf* f, int channel, float volume); TSFDEF void tsf_channel_set_pitchwheel(tsf* f, int channel, int pitch_wheel); TSFDEF void tsf_channel_set_pitchrange(tsf* f, int channel, float pitch_range); TSFDEF void tsf_channel_set_tuning(tsf* f, int channel, float tuning); // Start or stop playing notes on a channel (needs channel preset to be set) // channel: channel number // key: note value between 0 and 127 (60 being middle C) // vel: velocity as a float between 0.0 (equal to note off) and 1.0 (full) TSFDEF void tsf_channel_note_on(tsf* f, int channel, int key, float vel); TSFDEF void tsf_channel_note_off(tsf* f, int channel, int key); TSFDEF void tsf_channel_note_off_all(tsf* f, int channel); //end with sustain and release TSFDEF void tsf_channel_sounds_off_all(tsf* f, int channel); //end immediatly // Apply a MIDI control change to the channel (not all controllers are supported!) TSFDEF void tsf_channel_midi_control(tsf* f, int channel, int controller, int control_value); // Get current values set on the channels TSFDEF int tsf_channel_get_preset_index(tsf* f, int channel); TSFDEF int tsf_channel_get_preset_bank(tsf* f, int channel); TSFDEF int tsf_channel_get_preset_number(tsf* f, int channel); TSFDEF float tsf_channel_get_pan(tsf* f, int channel); TSFDEF float tsf_channel_get_volume(tsf* f, int channel); TSFDEF int tsf_channel_get_pitchwheel(tsf* f, int channel); TSFDEF float tsf_channel_get_pitchrange(tsf* f, int channel); TSFDEF float tsf_channel_get_tuning(tsf* f, int channel); #ifdef __cplusplus # undef CPP_DEFAULT0 } #endif // end header // --------------------------------------------------------------------------------------------------------- #endif //TSF_INCLUDE_TSF_INL #ifdef TSF_IMPLEMENTATION // The lower this block size is the more accurate the effects are. // Increasing the value significantly lowers the CPU usage of the voice rendering. // If LFO affects the low-pass filter it can be hearable even as low as 8. #ifndef TSF_RENDER_EFFECTSAMPLEBLOCK #define TSF_RENDER_EFFECTSAMPLEBLOCK 64 #endif // Grace release time for quick voice off (avoid clicking noise) #define TSF_FASTRELEASETIME 0.01f #if !defined(TSF_MALLOC) || !defined(TSF_FREE) || !defined(TSF_REALLOC) # include # define TSF_MALLOC malloc # define TSF_FREE free # define TSF_REALLOC realloc #endif #if !defined(TSF_MEMCPY) || !defined(TSF_MEMSET) # include # define TSF_MEMCPY memcpy # define TSF_MEMSET memset #endif #if !defined(TSF_POW) || !defined(TSF_POWF) || !defined(TSF_EXPF) || !defined(TSF_LOG) || !defined(TSF_TAN) || !defined(TSF_LOG10) || !defined(TSF_SQRT) # include # if !defined(__cplusplus) && !defined(NAN) && !defined(powf) && !defined(expf) && !defined(sqrtf) # define powf (float)pow // deal with old math.h # define expf (float)exp // files that come without # define sqrtf (float)sqrt // powf, expf and sqrtf # endif # define TSF_POW pow # define TSF_POWF powf # define TSF_EXPF expf # define TSF_LOG log # define TSF_TAN tan # define TSF_LOG10 log10 # define TSF_SQRTF sqrtf #endif #ifndef TSF_NO_STDIO # include #endif #define TSF_TRUE 1 #define TSF_FALSE 0 #define TSF_BOOL char #define TSF_PI 3.14159265358979323846264338327950288 #define TSF_NULL 0 #ifdef __cplusplus extern "C" { #endif typedef char tsf_fourcc[4]; typedef signed char tsf_s8; typedef unsigned char tsf_u8; typedef unsigned short tsf_u16; typedef signed short tsf_s16; typedef unsigned int tsf_u32; typedef char tsf_char20[20]; #define TSF_FourCCEquals(value1, value2) (value1[0] == value2[0] && value1[1] == value2[1] && value1[2] == value2[2] && value1[3] == value2[3]) struct tsf { struct tsf_preset* presets; float* fontSamples; struct tsf_voice* voices; struct tsf_channels* channels; float* outputSamples; int presetNum; int voiceNum; int outputSampleSize; unsigned int voicePlayIndex; enum TSFOutputMode outputmode; float outSampleRate; float globalGainDB; }; #ifndef TSF_NO_STDIO static int tsf_stream_stdio_read(FILE* f, void* ptr, unsigned int size) { return (int)fread(ptr, 1, size, f); } static int tsf_stream_stdio_skip(FILE* f, unsigned int count) { return !fseek(f, count, SEEK_CUR); } TSFDEF tsf* tsf_load_filename(const char* filename) { tsf* res; struct tsf_stream stream = { TSF_NULL, (int(*)(void*,void*,unsigned int))&tsf_stream_stdio_read, (int(*)(void*,unsigned int))&tsf_stream_stdio_skip }; #if __STDC_WANT_SECURE_LIB__ FILE* f = TSF_NULL; fopen_s(&f, filename, "rb"); #else FILE* f = fopen(filename, "rb"); #endif if (!f) { //if (e) *e = TSF_FILENOTFOUND; return TSF_NULL; } stream.data = f; res = tsf_load(&stream); fclose(f); return res; } #endif struct tsf_stream_memory { const char* buffer; unsigned int total, pos; }; static int tsf_stream_memory_read(struct tsf_stream_memory* m, void* ptr, unsigned int size) { if (size > m->total - m->pos) size = m->total - m->pos; TSF_MEMCPY(ptr, m->buffer+m->pos, size); m->pos += size; return size; } static int tsf_stream_memory_skip(struct tsf_stream_memory* m, unsigned int count) { if (m->pos + count > m->total) return 0; m->pos += count; return 1; } TSFDEF tsf* tsf_load_memory(const void* buffer, int size) { struct tsf_stream stream = { TSF_NULL, (int(*)(void*,void*,unsigned int))&tsf_stream_memory_read, (int(*)(void*,unsigned int))&tsf_stream_memory_skip }; struct tsf_stream_memory f = { 0, 0, 0 }; f.buffer = (const char*)buffer; f.total = size; stream.data = &f; return tsf_load(&stream); } enum { TSF_LOOPMODE_NONE, TSF_LOOPMODE_CONTINUOUS, TSF_LOOPMODE_SUSTAIN }; enum { TSF_SEGMENT_NONE, TSF_SEGMENT_DELAY, TSF_SEGMENT_ATTACK, TSF_SEGMENT_HOLD, TSF_SEGMENT_DECAY, TSF_SEGMENT_SUSTAIN, TSF_SEGMENT_RELEASE, TSF_SEGMENT_DONE }; struct tsf_hydra { struct tsf_hydra_phdr *phdrs; struct tsf_hydra_pbag *pbags; struct tsf_hydra_pmod *pmods; struct tsf_hydra_pgen *pgens; struct tsf_hydra_inst *insts; struct tsf_hydra_ibag *ibags; struct tsf_hydra_imod *imods; struct tsf_hydra_igen *igens; struct tsf_hydra_shdr *shdrs; int phdrNum, pbagNum, pmodNum, pgenNum, instNum, ibagNum, imodNum, igenNum, shdrNum; }; union tsf_hydra_genamount { struct { tsf_u8 lo, hi; } range; tsf_s16 shortAmount; tsf_u16 wordAmount; }; struct tsf_hydra_phdr { tsf_char20 presetName; tsf_u16 preset, bank, presetBagNdx; tsf_u32 library, genre, morphology; }; struct tsf_hydra_pbag { tsf_u16 genNdx, modNdx; }; struct tsf_hydra_pmod { tsf_u16 modSrcOper, modDestOper; tsf_s16 modAmount; tsf_u16 modAmtSrcOper, modTransOper; }; struct tsf_hydra_pgen { tsf_u16 genOper; union tsf_hydra_genamount genAmount; }; struct tsf_hydra_inst { tsf_char20 instName; tsf_u16 instBagNdx; }; struct tsf_hydra_ibag { tsf_u16 instGenNdx, instModNdx; }; struct tsf_hydra_imod { tsf_u16 modSrcOper, modDestOper; tsf_s16 modAmount; tsf_u16 modAmtSrcOper, modTransOper; }; struct tsf_hydra_igen { tsf_u16 genOper; union tsf_hydra_genamount genAmount; }; struct tsf_hydra_shdr { tsf_char20 sampleName; tsf_u32 start, end, startLoop, endLoop, sampleRate; tsf_u8 originalPitch; tsf_s8 pitchCorrection; tsf_u16 sampleLink, sampleType; }; #define TSFR(FIELD) stream->read(stream->data, &i->FIELD, sizeof(i->FIELD)); static void tsf_hydra_read_phdr(struct tsf_hydra_phdr* i, struct tsf_stream* stream) { TSFR(presetName) TSFR(preset) TSFR(bank) TSFR(presetBagNdx) TSFR(library) TSFR(genre) TSFR(morphology) } static void tsf_hydra_read_pbag(struct tsf_hydra_pbag* i, struct tsf_stream* stream) { TSFR(genNdx) TSFR(modNdx) } static void tsf_hydra_read_pmod(struct tsf_hydra_pmod* i, struct tsf_stream* stream) { TSFR(modSrcOper) TSFR(modDestOper) TSFR(modAmount) TSFR(modAmtSrcOper) TSFR(modTransOper) } static void tsf_hydra_read_pgen(struct tsf_hydra_pgen* i, struct tsf_stream* stream) { TSFR(genOper) TSFR(genAmount) } static void tsf_hydra_read_inst(struct tsf_hydra_inst* i, struct tsf_stream* stream) { TSFR(instName) TSFR(instBagNdx) } static void tsf_hydra_read_ibag(struct tsf_hydra_ibag* i, struct tsf_stream* stream) { TSFR(instGenNdx) TSFR(instModNdx) } static void tsf_hydra_read_imod(struct tsf_hydra_imod* i, struct tsf_stream* stream) { TSFR(modSrcOper) TSFR(modDestOper) TSFR(modAmount) TSFR(modAmtSrcOper) TSFR(modTransOper) } static void tsf_hydra_read_igen(struct tsf_hydra_igen* i, struct tsf_stream* stream) { TSFR(genOper) TSFR(genAmount) } static void tsf_hydra_read_shdr(struct tsf_hydra_shdr* i, struct tsf_stream* stream) { TSFR(sampleName) TSFR(start) TSFR(end) TSFR(startLoop) TSFR(endLoop) TSFR(sampleRate) TSFR(originalPitch) TSFR(pitchCorrection) TSFR(sampleLink) TSFR(sampleType) } #undef TSFR struct tsf_riffchunk { tsf_fourcc id; tsf_u32 size; }; struct tsf_envelope { float delay, attack, hold, decay, sustain, release, keynumToHold, keynumToDecay; }; struct tsf_voice_envelope { float level, slope; int samplesUntilNextSegment; short segment, midiVelocity; struct tsf_envelope parameters; TSF_BOOL segmentIsExponential, isAmpEnv; }; struct tsf_voice_lowpass { double QInv, a0, a1, b1, b2, z1, z2; TSF_BOOL active; }; struct tsf_voice_lfo { int samplesUntil; float level, delta; }; struct tsf_region { int loop_mode; unsigned int sample_rate; unsigned char lokey, hikey, lovel, hivel; unsigned int group, offset, end, loop_start, loop_end; int transpose, tune, pitch_keycenter, pitch_keytrack; float attenuation, pan; struct tsf_envelope ampenv, modenv; int initialFilterQ, initialFilterFc; int modEnvToPitch, modEnvToFilterFc, modLfoToFilterFc, modLfoToVolume; float delayModLFO; int freqModLFO, modLfoToPitch; float delayVibLFO; int freqVibLFO, vibLfoToPitch; }; struct tsf_preset { tsf_char20 presetName; tsf_u16 preset, bank; struct tsf_region* regions; int regionNum; }; struct tsf_voice { int playingPreset, playingKey, playingChannel; struct tsf_region* region; double pitchInputTimecents, pitchOutputFactor; double sourceSamplePosition; float noteGainDB, panFactorLeft, panFactorRight; unsigned int playIndex, loopStart, loopEnd; struct tsf_voice_envelope ampenv, modenv; struct tsf_voice_lowpass lowpass; struct tsf_voice_lfo modlfo, viblfo; }; struct tsf_channel { unsigned short presetIndex, bank, pitchWheel, midiPan, midiVolume, midiExpression, midiRPN, midiData; float panOffset, gainDB, pitchRange, tuning; }; struct tsf_channels { void (*setupVoice)(tsf* f, struct tsf_voice* voice); struct tsf_channel* channels; int channelNum, activeChannel; }; static double tsf_timecents2Secsd(double timecents) { return TSF_POW(2.0, timecents / 1200.0); } static float tsf_timecents2Secsf(float timecents) { return TSF_POWF(2.0f, timecents / 1200.0f); } static float tsf_cents2Hertz(float cents) { return 8.176f * TSF_POWF(2.0f, cents / 1200.0f); } static float tsf_decibelsToGain(float db) { return (db > -100.f ? TSF_POWF(10.0f, db * 0.05f) : 0); } static float tsf_gainToDecibels(float gain) { return (gain <= .00001f ? -100.f : (float)(20.0 * TSF_LOG10(gain))); } static TSF_BOOL tsf_riffchunk_read(struct tsf_riffchunk* parent, struct tsf_riffchunk* chunk, struct tsf_stream* stream) { TSF_BOOL IsRiff, IsList; if (parent && sizeof(tsf_fourcc) + sizeof(tsf_u32) > parent->size) return TSF_FALSE; if (!stream->read(stream->data, &chunk->id, sizeof(tsf_fourcc)) || *chunk->id <= ' ' || *chunk->id >= 'z') return TSF_FALSE; if (!stream->read(stream->data, &chunk->size, sizeof(tsf_u32))) return TSF_FALSE; if (parent && sizeof(tsf_fourcc) + sizeof(tsf_u32) + chunk->size > parent->size) return TSF_FALSE; if (parent) parent->size -= sizeof(tsf_fourcc) + sizeof(tsf_u32) + chunk->size; IsRiff = TSF_FourCCEquals(chunk->id, "RIFF"), IsList = TSF_FourCCEquals(chunk->id, "LIST"); if (IsRiff && parent) return TSF_FALSE; //not allowed if (!IsRiff && !IsList) return TSF_TRUE; //custom type without sub type if (!stream->read(stream->data, &chunk->id, sizeof(tsf_fourcc)) || *chunk->id <= ' ' || *chunk->id >= 'z') return TSF_FALSE; chunk->size -= sizeof(tsf_fourcc); return TSF_TRUE; } static void tsf_region_clear(struct tsf_region* i, TSF_BOOL for_relative) { TSF_MEMSET(i, 0, sizeof(struct tsf_region)); i->hikey = i->hivel = 127; i->pitch_keycenter = 60; // C4 if (for_relative) return; i->pitch_keytrack = 100; i->pitch_keycenter = -1; // SF2 defaults in timecents. i->ampenv.delay = i->ampenv.attack = i->ampenv.hold = i->ampenv.decay = i->ampenv.release = -12000.0f; i->modenv.delay = i->modenv.attack = i->modenv.hold = i->modenv.decay = i->modenv.release = -12000.0f; i->initialFilterFc = 13500; i->delayModLFO = -12000.0f; i->delayVibLFO = -12000.0f; } static void tsf_region_operator(struct tsf_region* region, tsf_u16 genOper, union tsf_hydra_genamount* amount) { enum { StartAddrsOffset, EndAddrsOffset, StartloopAddrsOffset, EndloopAddrsOffset, StartAddrsCoarseOffset, ModLfoToPitch, VibLfoToPitch, ModEnvToPitch, InitialFilterFc, InitialFilterQ, ModLfoToFilterFc, ModEnvToFilterFc, EndAddrsCoarseOffset, ModLfoToVolume, Unused1, ChorusEffectsSend, ReverbEffectsSend, Pan, Unused2, Unused3, Unused4, DelayModLFO, FreqModLFO, DelayVibLFO, FreqVibLFO, DelayModEnv, AttackModEnv, HoldModEnv, DecayModEnv, SustainModEnv, ReleaseModEnv, KeynumToModEnvHold, KeynumToModEnvDecay, DelayVolEnv, AttackVolEnv, HoldVolEnv, DecayVolEnv, SustainVolEnv, ReleaseVolEnv, KeynumToVolEnvHold, KeynumToVolEnvDecay, Instrument, Reserved1, KeyRange, VelRange, StartloopAddrsCoarseOffset, Keynum, Velocity, InitialAttenuation, Reserved2, EndloopAddrsCoarseOffset, CoarseTune, FineTune, SampleID, SampleModes, Reserved3, ScaleTuning, ExclusiveClass, OverridingRootKey, Unused5, EndOper }; switch (genOper) { case StartAddrsOffset: region->offset += amount->shortAmount; break; case EndAddrsOffset: region->end += amount->shortAmount; break; case StartloopAddrsOffset: region->loop_start += amount->shortAmount; break; case EndloopAddrsOffset: region->loop_end += amount->shortAmount; break; case StartAddrsCoarseOffset: region->offset += amount->shortAmount * 32768; break; case ModLfoToPitch: region->modLfoToPitch = amount->shortAmount; break; case VibLfoToPitch: region->vibLfoToPitch = amount->shortAmount; break; case ModEnvToPitch: region->modEnvToPitch = amount->shortAmount; break; case InitialFilterFc: region->initialFilterFc = amount->shortAmount; break; case InitialFilterQ: region->initialFilterQ = amount->shortAmount; break; case ModLfoToFilterFc: region->modLfoToFilterFc = amount->shortAmount; break; case ModEnvToFilterFc: region->modEnvToFilterFc = amount->shortAmount; break; case EndAddrsCoarseOffset: region->end += amount->shortAmount * 32768; break; case ModLfoToVolume: region->modLfoToVolume = amount->shortAmount; break; case Pan: region->pan = amount->shortAmount / 1000.0f; break; case DelayModLFO: region->delayModLFO = amount->shortAmount; break; case FreqModLFO: region->freqModLFO = amount->shortAmount; break; case DelayVibLFO: region->delayVibLFO = amount->shortAmount; break; case FreqVibLFO: region->freqVibLFO = amount->shortAmount; break; case DelayModEnv: region->modenv.delay = amount->shortAmount; break; case AttackModEnv: region->modenv.attack = amount->shortAmount; break; case HoldModEnv: region->modenv.hold = amount->shortAmount; break; case DecayModEnv: region->modenv.decay = amount->shortAmount; break; case SustainModEnv: region->modenv.sustain = amount->shortAmount; break; case ReleaseModEnv: region->modenv.release = amount->shortAmount; break; case KeynumToModEnvHold: region->modenv.keynumToHold = amount->shortAmount; break; case KeynumToModEnvDecay: region->modenv.keynumToDecay = amount->shortAmount; break; case DelayVolEnv: region->ampenv.delay = amount->shortAmount; break; case AttackVolEnv: region->ampenv.attack = amount->shortAmount; break; case HoldVolEnv: region->ampenv.hold = amount->shortAmount; break; case DecayVolEnv: region->ampenv.decay = amount->shortAmount; break; case SustainVolEnv: region->ampenv.sustain = amount->shortAmount; break; case ReleaseVolEnv: region->ampenv.release = amount->shortAmount; break; case KeynumToVolEnvHold: region->ampenv.keynumToHold = amount->shortAmount; break; case KeynumToVolEnvDecay: region->ampenv.keynumToDecay = amount->shortAmount; break; case KeyRange: region->lokey = amount->range.lo; region->hikey = amount->range.hi; break; case VelRange: region->lovel = amount->range.lo; region->hivel = amount->range.hi; break; case StartloopAddrsCoarseOffset: region->loop_start += amount->shortAmount * 32768; break; case InitialAttenuation: region->attenuation += amount->shortAmount * 0.1f; break; case EndloopAddrsCoarseOffset: region->loop_end += amount->shortAmount * 32768; break; case CoarseTune: region->transpose += amount->shortAmount; break; case FineTune: region->tune += amount->shortAmount; break; case SampleModes: region->loop_mode = ((amount->wordAmount&3) == 3 ? TSF_LOOPMODE_SUSTAIN : ((amount->wordAmount&3) == 1 ? TSF_LOOPMODE_CONTINUOUS : TSF_LOOPMODE_NONE)); break; case ScaleTuning: region->pitch_keytrack = amount->shortAmount; break; case ExclusiveClass: region->group = amount->wordAmount; break; case OverridingRootKey: region->pitch_keycenter = amount->shortAmount; break; //case gen_endOper: break; // Ignore. //default: addUnsupportedOpcode(generator_name); } } static void tsf_region_envtosecs(struct tsf_envelope* p, TSF_BOOL sustainIsGain) { // EG times need to be converted from timecents to seconds. // Pin very short EG segments. Timecents don't get to zero, and our EG is // happier with zero values. p->delay = (p->delay < -11950.0f ? 0.0f : tsf_timecents2Secsf(p->delay)); p->attack = (p->attack < -11950.0f ? 0.0f : tsf_timecents2Secsf(p->attack)); p->release = (p->release < -11950.0f ? 0.0f : tsf_timecents2Secsf(p->release)); // If we have dynamic hold or decay times depending on key number we need // to keep the values in timecents so we can calculate it during startNote if (!p->keynumToHold) p->hold = (p->hold < -11950.0f ? 0.0f : tsf_timecents2Secsf(p->hold)); if (!p->keynumToDecay) p->decay = (p->decay < -11950.0f ? 0.0f : tsf_timecents2Secsf(p->decay)); if (p->sustain < 0.0f) p->sustain = 0.0f; else if (sustainIsGain) p->sustain = tsf_decibelsToGain(-p->sustain / 10.0f); else p->sustain = 1.0f - (p->sustain / 1000.0f); } static void tsf_load_presets(tsf* res, struct tsf_hydra *hydra, unsigned int fontSampleCount) { enum { GenInstrument = 41, GenKeyRange = 43, GenVelRange = 44, GenSampleID = 53 }; // Read each preset. struct tsf_hydra_phdr *pphdr, *pphdrMax; for (pphdr = hydra->phdrs, pphdrMax = pphdr + hydra->phdrNum - 1; pphdr != pphdrMax; pphdr++) { int sortedIndex = 0, region_index = 0; struct tsf_hydra_phdr *otherphdr; struct tsf_preset* preset; struct tsf_hydra_pbag *ppbag, *ppbagEnd; struct tsf_region globalRegion; for (otherphdr = hydra->phdrs; otherphdr != pphdrMax; otherphdr++) { if (otherphdr == pphdr || otherphdr->bank > pphdr->bank) continue; else if (otherphdr->bank < pphdr->bank) sortedIndex++; else if (otherphdr->preset > pphdr->preset) continue; else if (otherphdr->preset < pphdr->preset) sortedIndex++; else if (otherphdr < pphdr) sortedIndex++; } preset = &res->presets[sortedIndex]; TSF_MEMCPY(preset->presetName, pphdr->presetName, sizeof(preset->presetName)); preset->presetName[sizeof(preset->presetName)-1] = '\0'; //should be zero terminated in source file but make sure preset->bank = pphdr->bank; preset->preset = pphdr->preset; preset->regionNum = 0; //count regions covered by this preset for (ppbag = hydra->pbags + pphdr->presetBagNdx, ppbagEnd = hydra->pbags + pphdr[1].presetBagNdx; ppbag != ppbagEnd; ppbag++) { unsigned char plokey = 0, phikey = 127, plovel = 0, phivel = 127; struct tsf_hydra_pgen *ppgen, *ppgenEnd; struct tsf_hydra_inst *pinst; struct tsf_hydra_ibag *pibag, *pibagEnd; struct tsf_hydra_igen *pigen, *pigenEnd; for (ppgen = hydra->pgens + ppbag->genNdx, ppgenEnd = hydra->pgens + ppbag[1].genNdx; ppgen != ppgenEnd; ppgen++) { if (ppgen->genOper == GenKeyRange) { plokey = ppgen->genAmount.range.lo; phikey = ppgen->genAmount.range.hi; continue; } if (ppgen->genOper == GenVelRange) { plovel = ppgen->genAmount.range.lo; phivel = ppgen->genAmount.range.hi; continue; } if (ppgen->genOper != GenInstrument) continue; if (ppgen->genAmount.wordAmount >= hydra->instNum) continue; pinst = hydra->insts + ppgen->genAmount.wordAmount; for (pibag = hydra->ibags + pinst->instBagNdx, pibagEnd = hydra->ibags + pinst[1].instBagNdx; pibag != pibagEnd; pibag++) { unsigned char ilokey = 0, ihikey = 127, ilovel = 0, ihivel = 127; for (pigen = hydra->igens + pibag->instGenNdx, pigenEnd = hydra->igens + pibag[1].instGenNdx; pigen != pigenEnd; pigen++) { if (pigen->genOper == GenKeyRange) { ilokey = pigen->genAmount.range.lo; ihikey = pigen->genAmount.range.hi; continue; } if (pigen->genOper == GenVelRange) { ilovel = pigen->genAmount.range.lo; ihivel = pigen->genAmount.range.hi; continue; } if (pigen->genOper == GenSampleID && ihikey >= plokey && ilokey <= phikey && ihivel >= plovel && ilovel <= phivel) preset->regionNum++; } } } } preset->regions = (struct tsf_region*)TSF_MALLOC(preset->regionNum * sizeof(struct tsf_region)); tsf_region_clear(&globalRegion, TSF_TRUE); // Zones. for (ppbag = hydra->pbags + pphdr->presetBagNdx, ppbagEnd = hydra->pbags + pphdr[1].presetBagNdx; ppbag != ppbagEnd; ppbag++) { struct tsf_hydra_pgen *ppgen, *ppgenEnd; struct tsf_hydra_inst *pinst; struct tsf_hydra_ibag *pibag, *pibagEnd; struct tsf_hydra_igen *pigen, *pigenEnd; struct tsf_region presetRegion = globalRegion; int hadGenInstrument = 0; // Generators. for (ppgen = hydra->pgens + ppbag->genNdx, ppgenEnd = hydra->pgens + ppbag[1].genNdx; ppgen != ppgenEnd; ppgen++) { // Instrument. if (ppgen->genOper == GenInstrument) { struct tsf_region instRegion; tsf_u16 whichInst = ppgen->genAmount.wordAmount; if (whichInst >= hydra->instNum) continue; tsf_region_clear(&instRegion, TSF_FALSE); pinst = &hydra->insts[whichInst]; for (pibag = hydra->ibags + pinst->instBagNdx, pibagEnd = hydra->ibags + pinst[1].instBagNdx; pibag != pibagEnd; pibag++) { // Generators. struct tsf_region zoneRegion = instRegion; int hadSampleID = 0; for (pigen = hydra->igens + pibag->instGenNdx, pigenEnd = hydra->igens + pibag[1].instGenNdx; pigen != pigenEnd; pigen++) { if (pigen->genOper == GenSampleID) { struct tsf_hydra_shdr* pshdr; //preset region key and vel ranges are a filter for the zone regions if (zoneRegion.hikey < presetRegion.lokey || zoneRegion.lokey > presetRegion.hikey) continue; if (zoneRegion.hivel < presetRegion.lovel || zoneRegion.lovel > presetRegion.hivel) continue; if (presetRegion.lokey > zoneRegion.lokey) zoneRegion.lokey = presetRegion.lokey; if (presetRegion.hikey < zoneRegion.hikey) zoneRegion.hikey = presetRegion.hikey; if (presetRegion.lovel > zoneRegion.lovel) zoneRegion.lovel = presetRegion.lovel; if (presetRegion.hivel < zoneRegion.hivel) zoneRegion.hivel = presetRegion.hivel; //sum regions zoneRegion.offset += presetRegion.offset; zoneRegion.end += presetRegion.end; zoneRegion.loop_start += presetRegion.loop_start; zoneRegion.loop_end += presetRegion.loop_end; zoneRegion.transpose += presetRegion.transpose; zoneRegion.tune += presetRegion.tune; zoneRegion.pitch_keytrack += presetRegion.pitch_keytrack; zoneRegion.attenuation += presetRegion.attenuation; zoneRegion.pan += presetRegion.pan; zoneRegion.ampenv.delay += presetRegion.ampenv.delay; zoneRegion.ampenv.attack += presetRegion.ampenv.attack; zoneRegion.ampenv.hold += presetRegion.ampenv.hold; zoneRegion.ampenv.decay += presetRegion.ampenv.decay; zoneRegion.ampenv.sustain += presetRegion.ampenv.sustain; zoneRegion.ampenv.release += presetRegion.ampenv.release; zoneRegion.modenv.delay += presetRegion.modenv.delay; zoneRegion.modenv.attack += presetRegion.modenv.attack; zoneRegion.modenv.hold += presetRegion.modenv.hold; zoneRegion.modenv.decay += presetRegion.modenv.decay; zoneRegion.modenv.sustain += presetRegion.modenv.sustain; zoneRegion.modenv.release += presetRegion.modenv.release; zoneRegion.initialFilterQ += presetRegion.initialFilterQ; zoneRegion.initialFilterFc += presetRegion.initialFilterFc; zoneRegion.modEnvToPitch += presetRegion.modEnvToPitch; zoneRegion.modEnvToFilterFc += presetRegion.modEnvToFilterFc; zoneRegion.delayModLFO += presetRegion.delayModLFO; zoneRegion.freqModLFO += presetRegion.freqModLFO; zoneRegion.modLfoToPitch += presetRegion.modLfoToPitch; zoneRegion.modLfoToFilterFc += presetRegion.modLfoToFilterFc; zoneRegion.modLfoToVolume += presetRegion.modLfoToVolume; zoneRegion.delayVibLFO += presetRegion.delayVibLFO; zoneRegion.freqVibLFO += presetRegion.freqVibLFO; zoneRegion.vibLfoToPitch += presetRegion.vibLfoToPitch; // EG times need to be converted from timecents to seconds. tsf_region_envtosecs(&zoneRegion.ampenv, TSF_TRUE); tsf_region_envtosecs(&zoneRegion.modenv, TSF_FALSE); // LFO times need to be converted from timecents to seconds. zoneRegion.delayModLFO = (zoneRegion.delayModLFO < -11950.0f ? 0.0f : tsf_timecents2Secsf(zoneRegion.delayModLFO)); zoneRegion.delayVibLFO = (zoneRegion.delayVibLFO < -11950.0f ? 0.0f : tsf_timecents2Secsf(zoneRegion.delayVibLFO)); // Pin values to their ranges. if (zoneRegion.pan < -0.5f) zoneRegion.pan = -0.5f; else if (zoneRegion.pan > 0.5f) zoneRegion.pan = 0.5f; if (zoneRegion.initialFilterQ < 1500 || zoneRegion.initialFilterQ > 13500) zoneRegion.initialFilterQ = 0; pshdr = &hydra->shdrs[pigen->genAmount.wordAmount]; zoneRegion.offset += pshdr->start; zoneRegion.end += pshdr->end; zoneRegion.loop_start += pshdr->startLoop; zoneRegion.loop_end += pshdr->endLoop; if (pshdr->endLoop > 0) zoneRegion.loop_end -= 1; if (zoneRegion.pitch_keycenter == -1) zoneRegion.pitch_keycenter = pshdr->originalPitch; zoneRegion.tune += pshdr->pitchCorrection; zoneRegion.sample_rate = pshdr->sampleRate; if (zoneRegion.end && zoneRegion.end < fontSampleCount) zoneRegion.end++; else zoneRegion.end = fontSampleCount; preset->regions[region_index] = zoneRegion; region_index++; hadSampleID = 1; } else tsf_region_operator(&zoneRegion, pigen->genOper, &pigen->genAmount); } // Handle instrument's global zone. if (pibag == hydra->ibags + pinst->instBagNdx && !hadSampleID) instRegion = zoneRegion; // Modulators (TODO) //if (ibag->instModNdx < ibag[1].instModNdx) addUnsupportedOpcode("any modulator"); } hadGenInstrument = 1; } else tsf_region_operator(&presetRegion, ppgen->genOper, &ppgen->genAmount); } // Modulators (TODO) //if (pbag->modNdx < pbag[1].modNdx) addUnsupportedOpcode("any modulator"); // Handle preset's global zone. if (ppbag == hydra->pbags + pphdr->presetBagNdx && !hadGenInstrument) globalRegion = presetRegion; } } } static void tsf_load_samples(float** fontSamples, unsigned int* fontSampleCount, struct tsf_riffchunk *chunkSmpl, struct tsf_stream* stream) { // Read sample data into float format buffer. float* out; unsigned int samplesLeft, samplesToRead, samplesToConvert; samplesLeft = *fontSampleCount = chunkSmpl->size / sizeof(short); out = *fontSamples = (float*)TSF_MALLOC(samplesLeft * sizeof(float)); for (; samplesLeft; samplesLeft -= samplesToRead) { short sampleBuffer[1024], *in = sampleBuffer;; samplesToRead = (samplesLeft > 1024 ? 1024 : samplesLeft); stream->read(stream->data, sampleBuffer, samplesToRead * sizeof(short)); // Convert from signed 16-bit to float. for (samplesToConvert = samplesToRead; samplesToConvert > 0; --samplesToConvert) // If we ever need to compile for big-endian platforms, we'll need to byte-swap here. *out++ = (float)(*in++ / 32767.0); } } static void tsf_voice_envelope_nextsegment(struct tsf_voice_envelope* e, short active_segment, float outSampleRate) { switch (active_segment) { case TSF_SEGMENT_NONE: e->samplesUntilNextSegment = (int)(e->parameters.delay * outSampleRate); if (e->samplesUntilNextSegment > 0) { e->segment = TSF_SEGMENT_DELAY; e->segmentIsExponential = TSF_FALSE; e->level = 0.0; e->slope = 0.0; return; } /* fall through */ case TSF_SEGMENT_DELAY: e->samplesUntilNextSegment = (int)(e->parameters.attack * outSampleRate); if (e->samplesUntilNextSegment > 0) { if (!e->isAmpEnv) { //mod env attack duration scales with velocity (velocity of 1 is full duration, max velocity is 0.125 times duration) e->samplesUntilNextSegment = (int)(e->parameters.attack * ((145 - e->midiVelocity) / 144.0f) * outSampleRate); } e->segment = TSF_SEGMENT_ATTACK; e->segmentIsExponential = TSF_FALSE; e->level = 0.0f; e->slope = 1.0f / e->samplesUntilNextSegment; return; } /* fall through */ case TSF_SEGMENT_ATTACK: e->samplesUntilNextSegment = (int)(e->parameters.hold * outSampleRate); if (e->samplesUntilNextSegment > 0) { e->segment = TSF_SEGMENT_HOLD; e->segmentIsExponential = TSF_FALSE; e->level = 1.0f; e->slope = 0.0f; return; } /* fall through */ case TSF_SEGMENT_HOLD: e->samplesUntilNextSegment = (int)(e->parameters.decay * outSampleRate); if (e->samplesUntilNextSegment > 0) { e->segment = TSF_SEGMENT_DECAY; e->level = 1.0f; if (e->isAmpEnv) { // I don't truly understand this; just following what LinuxSampler does. float mysterySlope = -9.226f / e->samplesUntilNextSegment; e->slope = TSF_EXPF(mysterySlope); e->segmentIsExponential = TSF_TRUE; if (e->parameters.sustain > 0.0f) { // Again, this is following LinuxSampler's example, which is similar to // SF2-style decay, where "decay" specifies the time it would take to // get to zero, not to the sustain level. The SFZ spec is not that // specific about what "decay" means, so perhaps it's really supposed // to specify the time to reach the sustain level. e->samplesUntilNextSegment = (int)(TSF_LOG(e->parameters.sustain) / mysterySlope); } } else { e->slope = -1.0f / e->samplesUntilNextSegment; e->samplesUntilNextSegment = (int)(e->parameters.decay * (1.0f - e->parameters.sustain) * outSampleRate); e->segmentIsExponential = TSF_FALSE; } return; } /* fall through */ case TSF_SEGMENT_DECAY: e->segment = TSF_SEGMENT_SUSTAIN; e->level = e->parameters.sustain; e->slope = 0.0f; e->samplesUntilNextSegment = 0x7FFFFFFF; e->segmentIsExponential = TSF_FALSE; return; case TSF_SEGMENT_SUSTAIN: e->segment = TSF_SEGMENT_RELEASE; e->samplesUntilNextSegment = (int)((e->parameters.release <= 0 ? TSF_FASTRELEASETIME : e->parameters.release) * outSampleRate); if (e->isAmpEnv) { // I don't truly understand this; just following what LinuxSampler does. float mysterySlope = -9.226f / e->samplesUntilNextSegment; e->slope = TSF_EXPF(mysterySlope); e->segmentIsExponential = TSF_TRUE; } else { e->slope = -e->level / e->samplesUntilNextSegment; e->segmentIsExponential = TSF_FALSE; } return; case TSF_SEGMENT_RELEASE: default: e->segment = TSF_SEGMENT_DONE; e->segmentIsExponential = TSF_FALSE; e->level = e->slope = 0.0f; e->samplesUntilNextSegment = 0x7FFFFFF; } } static void tsf_voice_envelope_setup(struct tsf_voice_envelope* e, struct tsf_envelope* new_parameters, int midiNoteNumber, short midiVelocity, TSF_BOOL isAmpEnv, float outSampleRate) { e->parameters = *new_parameters; if (e->parameters.keynumToHold) { e->parameters.hold += e->parameters.keynumToHold * (60.0f - midiNoteNumber); e->parameters.hold = (e->parameters.hold < -10000.0f ? 0.0f : tsf_timecents2Secsf(e->parameters.hold)); } if (e->parameters.keynumToDecay) { e->parameters.decay += e->parameters.keynumToDecay * (60.0f - midiNoteNumber); e->parameters.decay = (e->parameters.decay < -10000.0f ? 0.0f : tsf_timecents2Secsf(e->parameters.decay)); } e->midiVelocity = midiVelocity; e->isAmpEnv = isAmpEnv; tsf_voice_envelope_nextsegment(e, TSF_SEGMENT_NONE, outSampleRate); } static void tsf_voice_envelope_process(struct tsf_voice_envelope* e, int numSamples, float outSampleRate) { if (e->slope) { if (e->segmentIsExponential) e->level *= TSF_POWF(e->slope, (float)numSamples); else e->level += (e->slope * numSamples); } if ((e->samplesUntilNextSegment -= numSamples) <= 0) tsf_voice_envelope_nextsegment(e, e->segment, outSampleRate); } static void tsf_voice_lowpass_setup(struct tsf_voice_lowpass* e, float Fc) { // Lowpass filter from http://www.earlevel.com/main/2012/11/26/biquad-c-source-code/ double K = TSF_TAN(TSF_PI * Fc), KK = K * K; double norm = 1 / (1 + K * e->QInv + KK); e->a0 = KK * norm; e->a1 = 2 * e->a0; e->b1 = 2 * (KK - 1) * norm; e->b2 = (1 - K * e->QInv + KK) * norm; } static float tsf_voice_lowpass_process(struct tsf_voice_lowpass* e, double In) { double Out = In * e->a0 + e->z1; e->z1 = In * e->a1 + e->z2 - e->b1 * Out; e->z2 = In * e->a0 - e->b2 * Out; return (float)Out; } static void tsf_voice_lfo_setup(struct tsf_voice_lfo* e, float delay, int freqCents, float outSampleRate) { e->samplesUntil = (int)(delay * outSampleRate); e->delta = (4.0f * tsf_cents2Hertz((float)freqCents) / outSampleRate); e->level = 0; } static void tsf_voice_lfo_process(struct tsf_voice_lfo* e, int blockSamples) { if (e->samplesUntil > blockSamples) { e->samplesUntil -= blockSamples; return; } e->level += e->delta * blockSamples; if (e->level > 1.0f) { e->delta = -e->delta; e->level = 2.0f - e->level; } else if (e->level < -1.0f) { e->delta = -e->delta; e->level = -2.0f - e->level; } } static void tsf_voice_kill(struct tsf_voice* v) { v->playingPreset = -1; } static void tsf_voice_end(struct tsf_voice* v, float outSampleRate) { tsf_voice_envelope_nextsegment(&v->ampenv, TSF_SEGMENT_SUSTAIN, outSampleRate); tsf_voice_envelope_nextsegment(&v->modenv, TSF_SEGMENT_SUSTAIN, outSampleRate); if (v->region->loop_mode == TSF_LOOPMODE_SUSTAIN) { // Continue playing, but stop looping. v->loopEnd = v->loopStart; } } static void tsf_voice_endquick(struct tsf_voice* v, float outSampleRate) { v->ampenv.parameters.release = 0.0f; tsf_voice_envelope_nextsegment(&v->ampenv, TSF_SEGMENT_SUSTAIN, outSampleRate); v->modenv.parameters.release = 0.0f; tsf_voice_envelope_nextsegment(&v->modenv, TSF_SEGMENT_SUSTAIN, outSampleRate); } static void tsf_voice_calcpitchratio(struct tsf_voice* v, float pitchShift, float outSampleRate) { double note = v->playingKey + v->region->transpose + v->region->tune / 100.0; double adjustedPitch = v->region->pitch_keycenter + (note - v->region->pitch_keycenter) * (v->region->pitch_keytrack / 100.0); if (pitchShift) adjustedPitch += pitchShift; v->pitchInputTimecents = adjustedPitch * 100.0; v->pitchOutputFactor = v->region->sample_rate / (tsf_timecents2Secsd(v->region->pitch_keycenter * 100.0) * outSampleRate); } static void tsf_voice_render(tsf* f, struct tsf_voice* v, float* outputBuffer, int numSamples) { struct tsf_region* region = v->region; float* input = f->fontSamples; float* outL = outputBuffer; float* outR = (f->outputmode == TSF_STEREO_UNWEAVED ? outL + numSamples : TSF_NULL); // Cache some values, to give them at least some chance of ending up in registers. TSF_BOOL updateModEnv = (region->modEnvToPitch || region->modEnvToFilterFc); TSF_BOOL updateModLFO = (v->modlfo.delta && (region->modLfoToPitch || region->modLfoToFilterFc || region->modLfoToVolume)); TSF_BOOL updateVibLFO = (v->viblfo.delta && (region->vibLfoToPitch)); TSF_BOOL isLooping = (v->loopStart < v->loopEnd); unsigned int tmpLoopStart = v->loopStart, tmpLoopEnd = v->loopEnd; double tmpSampleEndDbl = (double)region->end, tmpLoopEndDbl = (double)tmpLoopEnd + 1.0; double tmpSourceSamplePosition = v->sourceSamplePosition; struct tsf_voice_lowpass tmpLowpass = v->lowpass; TSF_BOOL dynamicLowpass = (region->modLfoToFilterFc || region->modEnvToFilterFc); float tmpSampleRate, tmpInitialFilterFc, tmpModLfoToFilterFc, tmpModEnvToFilterFc; TSF_BOOL dynamicPitchRatio = (region->modLfoToPitch || region->modEnvToPitch || region->vibLfoToPitch); double pitchRatio; float tmpModLfoToPitch, tmpVibLfoToPitch, tmpModEnvToPitch; TSF_BOOL dynamicGain = (region->modLfoToVolume != 0); float noteGain = 0, tmpModLfoToVolume; if (dynamicLowpass) tmpSampleRate = f->outSampleRate, tmpInitialFilterFc = (float)region->initialFilterFc, tmpModLfoToFilterFc = (float)region->modLfoToFilterFc, tmpModEnvToFilterFc = (float)region->modEnvToFilterFc; else tmpSampleRate = 0, tmpInitialFilterFc = 0, tmpModLfoToFilterFc = 0, tmpModEnvToFilterFc = 0; if (dynamicPitchRatio) pitchRatio = 0, tmpModLfoToPitch = (float)region->modLfoToPitch, tmpVibLfoToPitch = (float)region->vibLfoToPitch, tmpModEnvToPitch = (float)region->modEnvToPitch; else pitchRatio = tsf_timecents2Secsd(v->pitchInputTimecents) * v->pitchOutputFactor, tmpModLfoToPitch = 0, tmpVibLfoToPitch = 0, tmpModEnvToPitch = 0; if (dynamicGain) tmpModLfoToVolume = (float)region->modLfoToVolume * 0.1f; else noteGain = tsf_decibelsToGain(v->noteGainDB), tmpModLfoToVolume = 0; while (numSamples) { float gainMono, gainLeft, gainRight; int blockSamples = (numSamples > TSF_RENDER_EFFECTSAMPLEBLOCK ? TSF_RENDER_EFFECTSAMPLEBLOCK : numSamples); numSamples -= blockSamples; if (dynamicLowpass) { float fres = tmpInitialFilterFc + v->modlfo.level * tmpModLfoToFilterFc + v->modenv.level * tmpModEnvToFilterFc; tmpLowpass.active = (fres <= 13500.0f); if (tmpLowpass.active) tsf_voice_lowpass_setup(&tmpLowpass, tsf_cents2Hertz(fres) / tmpSampleRate); } if (dynamicPitchRatio) pitchRatio = tsf_timecents2Secsd(v->pitchInputTimecents + (v->modlfo.level * tmpModLfoToPitch + v->viblfo.level * tmpVibLfoToPitch + v->modenv.level * tmpModEnvToPitch)) * v->pitchOutputFactor; if (dynamicGain) noteGain = tsf_decibelsToGain(v->noteGainDB + (v->modlfo.level * tmpModLfoToVolume)); gainMono = noteGain * v->ampenv.level; // Update EG. tsf_voice_envelope_process(&v->ampenv, blockSamples, f->outSampleRate); if (updateModEnv) tsf_voice_envelope_process(&v->modenv, blockSamples, f->outSampleRate); // Update LFOs. if (updateModLFO) tsf_voice_lfo_process(&v->modlfo, blockSamples); if (updateVibLFO) tsf_voice_lfo_process(&v->viblfo, blockSamples); switch (f->outputmode) { case TSF_STEREO_INTERLEAVED: gainLeft = gainMono * v->panFactorLeft, gainRight = gainMono * v->panFactorRight; while (blockSamples-- && tmpSourceSamplePosition < tmpSampleEndDbl) { unsigned int pos = (unsigned int)tmpSourceSamplePosition, nextPos = (pos >= tmpLoopEnd && isLooping ? tmpLoopStart : pos + 1); // Simple linear interpolation. float alpha = (float)(tmpSourceSamplePosition - pos), val = (input[pos] * (1.0f - alpha) + input[nextPos] * alpha); // Low-pass filter. if (tmpLowpass.active) val = tsf_voice_lowpass_process(&tmpLowpass, val); *outL++ += val * gainLeft; *outL++ += val * gainRight; // Next sample. tmpSourceSamplePosition += pitchRatio; if (tmpSourceSamplePosition >= tmpLoopEndDbl && isLooping) tmpSourceSamplePosition -= (tmpLoopEnd - tmpLoopStart + 1.0); } break; case TSF_STEREO_UNWEAVED: gainLeft = gainMono * v->panFactorLeft, gainRight = gainMono * v->panFactorRight; while (blockSamples-- && tmpSourceSamplePosition < tmpSampleEndDbl) { unsigned int pos = (unsigned int)tmpSourceSamplePosition, nextPos = (pos >= tmpLoopEnd && isLooping ? tmpLoopStart : pos + 1); // Simple linear interpolation. float alpha = (float)(tmpSourceSamplePosition - pos), val = (input[pos] * (1.0f - alpha) + input[nextPos] * alpha); // Low-pass filter. if (tmpLowpass.active) val = tsf_voice_lowpass_process(&tmpLowpass, val); *outL++ += val * gainLeft; *outR++ += val * gainRight; // Next sample. tmpSourceSamplePosition += pitchRatio; if (tmpSourceSamplePosition >= tmpLoopEndDbl && isLooping) tmpSourceSamplePosition -= (tmpLoopEnd - tmpLoopStart + 1.0); } break; case TSF_MONO: while (blockSamples-- && tmpSourceSamplePosition < tmpSampleEndDbl) { unsigned int pos = (unsigned int)tmpSourceSamplePosition, nextPos = (pos >= tmpLoopEnd && isLooping ? tmpLoopStart : pos + 1); // Simple linear interpolation. float alpha = (float)(tmpSourceSamplePosition - pos), val = (input[pos] * (1.0f - alpha) + input[nextPos] * alpha); // Low-pass filter. if (tmpLowpass.active) val = tsf_voice_lowpass_process(&tmpLowpass, val); *outL++ += val * gainMono; // Next sample. tmpSourceSamplePosition += pitchRatio; if (tmpSourceSamplePosition >= tmpLoopEndDbl && isLooping) tmpSourceSamplePosition -= (tmpLoopEnd - tmpLoopStart + 1.0); } break; } if (tmpSourceSamplePosition >= tmpSampleEndDbl || v->ampenv.segment == TSF_SEGMENT_DONE) { tsf_voice_kill(v); return; } } v->sourceSamplePosition = tmpSourceSamplePosition; if (tmpLowpass.active || dynamicLowpass) v->lowpass = tmpLowpass; } TSFDEF tsf* tsf_load(struct tsf_stream* stream) { tsf* res = TSF_NULL; struct tsf_riffchunk chunkHead; struct tsf_riffchunk chunkList; struct tsf_hydra hydra; float* fontSamples = TSF_NULL; unsigned int fontSampleCount = 0; if (!tsf_riffchunk_read(TSF_NULL, &chunkHead, stream) || !TSF_FourCCEquals(chunkHead.id, "sfbk")) { //if (e) *e = TSF_INVALID_NOSF2HEADER; return res; } // Read hydra and locate sample data. TSF_MEMSET(&hydra, 0, sizeof(hydra)); while (tsf_riffchunk_read(&chunkHead, &chunkList, stream)) { struct tsf_riffchunk chunk; if (TSF_FourCCEquals(chunkList.id, "pdta")) { while (tsf_riffchunk_read(&chunkList, &chunk, stream)) { #define HandleChunk(chunkName) (TSF_FourCCEquals(chunk.id, #chunkName) && !(chunk.size % chunkName##SizeInFile)) \ { \ int num = chunk.size / chunkName##SizeInFile, i; \ hydra.chunkName##Num = num; \ hydra.chunkName##s = (struct tsf_hydra_##chunkName*)TSF_MALLOC(num * sizeof(struct tsf_hydra_##chunkName)); \ for (i = 0; i < num; ++i) tsf_hydra_read_##chunkName(&hydra.chunkName##s[i], stream); \ } enum { phdrSizeInFile = 38, pbagSizeInFile = 4, pmodSizeInFile = 10, pgenSizeInFile = 4, instSizeInFile = 22, ibagSizeInFile = 4, imodSizeInFile = 10, igenSizeInFile = 4, shdrSizeInFile = 46 }; if HandleChunk(phdr) else if HandleChunk(pbag) else if HandleChunk(pmod) else if HandleChunk(pgen) else if HandleChunk(inst) else if HandleChunk(ibag) else if HandleChunk(imod) else if HandleChunk(igen) else if HandleChunk(shdr) else stream->skip(stream->data, chunk.size); #undef HandleChunk } } else if (TSF_FourCCEquals(chunkList.id, "sdta")) { while (tsf_riffchunk_read(&chunkList, &chunk, stream)) { if (TSF_FourCCEquals(chunk.id, "smpl")) { tsf_load_samples(&fontSamples, &fontSampleCount, &chunk, stream); } else stream->skip(stream->data, chunk.size); } } else stream->skip(stream->data, chunkList.size); } if (!hydra.phdrs || !hydra.pbags || !hydra.pmods || !hydra.pgens || !hydra.insts || !hydra.ibags || !hydra.imods || !hydra.igens || !hydra.shdrs) { //if (e) *e = TSF_INVALID_INCOMPLETE; } else if (fontSamples == TSF_NULL) { //if (e) *e = TSF_INVALID_NOSAMPLEDATA; } else { res = (tsf*)TSF_MALLOC(sizeof(tsf)); TSF_MEMSET(res, 0, sizeof(tsf)); res->presetNum = hydra.phdrNum - 1; res->presets = (struct tsf_preset*)TSF_MALLOC(res->presetNum * sizeof(struct tsf_preset)); res->fontSamples = fontSamples; res->outSampleRate = 44100.0f; fontSamples = TSF_NULL; //don't free below tsf_load_presets(res, &hydra, fontSampleCount); } TSF_FREE(hydra.phdrs); TSF_FREE(hydra.pbags); TSF_FREE(hydra.pmods); TSF_FREE(hydra.pgens); TSF_FREE(hydra.insts); TSF_FREE(hydra.ibags); TSF_FREE(hydra.imods); TSF_FREE(hydra.igens); TSF_FREE(hydra.shdrs); TSF_FREE(fontSamples); return res; } TSFDEF void tsf_close(tsf* f) { struct tsf_preset *preset, *presetEnd; if (!f) return; for (preset = f->presets, presetEnd = preset + f->presetNum; preset != presetEnd; preset++) TSF_FREE(preset->regions); TSF_FREE(f->presets); TSF_FREE(f->fontSamples); TSF_FREE(f->voices); if (f->channels) { TSF_FREE(f->channels->channels); TSF_FREE(f->channels); } TSF_FREE(f->outputSamples); TSF_FREE(f); } TSFDEF void tsf_reset(tsf* f) { struct tsf_voice *v = f->voices, *vEnd = v + f->voiceNum; for (; v != vEnd; v++) if (v->playingPreset != -1 && (v->ampenv.segment < TSF_SEGMENT_RELEASE || v->ampenv.parameters.release)) tsf_voice_endquick(v, f->outSampleRate); if (f->channels) { TSF_FREE(f->channels->channels); TSF_FREE(f->channels); f->channels = TSF_NULL; } } TSFDEF int tsf_get_presetindex(const tsf* f, int bank, int preset_number) { const struct tsf_preset *presets; int i, iMax; for (presets = f->presets, i = 0, iMax = f->presetNum; i < iMax; i++) if (presets[i].preset == preset_number && presets[i].bank == bank) return i; return -1; } TSFDEF int tsf_get_presetcount(const tsf* f) { return f->presetNum; } TSFDEF const char* tsf_get_presetname(const tsf* f, int preset) { return (preset < 0 || preset >= f->presetNum ? TSF_NULL : f->presets[preset].presetName); } TSFDEF const char* tsf_bank_get_presetname(const tsf* f, int bank, int preset_number) { return tsf_get_presetname(f, tsf_get_presetindex(f, bank, preset_number)); } TSFDEF void tsf_set_output(tsf* f, enum TSFOutputMode outputmode, int samplerate, float global_gain_db) { f->outputmode = outputmode; f->outSampleRate = (float)(samplerate >= 1 ? samplerate : 44100.0f); f->globalGainDB = global_gain_db; } TSFDEF void tsf_note_on(tsf* f, int preset_index, int key, float vel) { short midiVelocity = (short)(vel * 127); int voicePlayIndex; struct tsf_region *region, *regionEnd; if (preset_index < 0 || preset_index >= f->presetNum) return; if (vel <= 0.0f) { tsf_note_off(f, preset_index, key); return; } // Play all matching regions. voicePlayIndex = f->voicePlayIndex++; for (region = f->presets[preset_index].regions, regionEnd = region + f->presets[preset_index].regionNum; region != regionEnd; region++) { struct tsf_voice *voice, *v, *vEnd; TSF_BOOL doLoop; float filterQDB; if (key < region->lokey || key > region->hikey || midiVelocity < region->lovel || midiVelocity > region->hivel) continue; voice = TSF_NULL, v = f->voices, vEnd = v + f->voiceNum; if (region->group) { for (; v != vEnd; v++) if (v->playingPreset == preset_index && v->region->group == region->group) tsf_voice_endquick(v, f->outSampleRate); else if (v->playingPreset == -1 && !voice) voice = v; } else for (; v != vEnd; v++) if (v->playingPreset == -1) { voice = v; break; } if (!voice) { f->voiceNum += 4; f->voices = (struct tsf_voice*)TSF_REALLOC(f->voices, f->voiceNum * sizeof(struct tsf_voice)); voice = &f->voices[f->voiceNum - 4]; voice[1].playingPreset = voice[2].playingPreset = voice[3].playingPreset = -1; } voice->region = region; voice->playingPreset = preset_index; voice->playingKey = key; voice->playIndex = voicePlayIndex; voice->noteGainDB = f->globalGainDB - region->attenuation - tsf_gainToDecibels(1.0f / vel); if (f->channels) { f->channels->setupVoice(f, voice); } else { tsf_voice_calcpitchratio(voice, 0, f->outSampleRate); // The SFZ spec is silent about the pan curve, but a 3dB pan law seems common. This sqrt() curve matches what Dimension LE does; Alchemy Free seems closer to sin(adjustedPan * pi/2). voice->panFactorLeft = TSF_SQRTF(0.5f - region->pan); voice->panFactorRight = TSF_SQRTF(0.5f + region->pan); } // Offset/end. voice->sourceSamplePosition = region->offset; // Loop. doLoop = (region->loop_mode != TSF_LOOPMODE_NONE && region->loop_start < region->loop_end); voice->loopStart = (doLoop ? region->loop_start : 0); voice->loopEnd = (doLoop ? region->loop_end : 0); // Setup envelopes. tsf_voice_envelope_setup(&voice->ampenv, ®ion->ampenv, key, midiVelocity, TSF_TRUE, f->outSampleRate); tsf_voice_envelope_setup(&voice->modenv, ®ion->modenv, key, midiVelocity, TSF_FALSE, f->outSampleRate); // Setup lowpass filter. filterQDB = region->initialFilterQ / 10.0f; voice->lowpass.QInv = 1.0 / TSF_POW(10.0, (filterQDB / 20.0)); voice->lowpass.z1 = voice->lowpass.z2 = 0; voice->lowpass.active = (region->initialFilterFc <= 13500); if (voice->lowpass.active) tsf_voice_lowpass_setup(&voice->lowpass, tsf_cents2Hertz((float)region->initialFilterFc) / f->outSampleRate); // Setup LFO filters. tsf_voice_lfo_setup(&voice->modlfo, region->delayModLFO, region->freqModLFO, f->outSampleRate); tsf_voice_lfo_setup(&voice->viblfo, region->delayVibLFO, region->freqVibLFO, f->outSampleRate); } } TSFDEF int tsf_bank_note_on(tsf* f, int bank, int preset_number, int key, float vel) { int preset_index = tsf_get_presetindex(f, bank, preset_number); if (preset_index == -1) return 0; tsf_note_on(f, preset_index, key, vel); return 1; } TSFDEF void tsf_note_off(tsf* f, int preset_index, int key) { struct tsf_voice *v = f->voices, *vEnd = v + f->voiceNum, *vMatchFirst = TSF_NULL, *vMatchLast = TSF_NULL; for (; v != vEnd; v++) { //Find the first and last entry in the voices list with matching preset, key and look up the smallest play index if (v->playingPreset != preset_index || v->playingKey != key || v->ampenv.segment >= TSF_SEGMENT_RELEASE) continue; else if (!vMatchFirst || v->playIndex < vMatchFirst->playIndex) vMatchFirst = vMatchLast = v; else if (v->playIndex == vMatchFirst->playIndex) vMatchLast = v; } if (!vMatchFirst) return; for (v = vMatchFirst; v <= vMatchLast; v++) { //Stop all voices with matching preset, key and the smallest play index which was enumerated above if (v != vMatchFirst && v != vMatchLast && (v->playIndex != vMatchFirst->playIndex || v->playingPreset != preset_index || v->playingKey != key || v->ampenv.segment >= TSF_SEGMENT_RELEASE)) continue; tsf_voice_end(v, f->outSampleRate); } } TSFDEF int tsf_bank_note_off(tsf* f, int bank, int preset_number, int key) { int preset_index = tsf_get_presetindex(f, bank, preset_number); if (preset_index == -1) return 0; tsf_note_off(f, preset_index, key); return 1; } TSFDEF void tsf_note_off_all(tsf* f, int quick) { struct tsf_voice *v = f->voices, *vEnd = v + f->voiceNum; if (quick) { for (; v != vEnd; v++) if (v->playingPreset != -1 && v->ampenv.segment < TSF_SEGMENT_RELEASE) tsf_voice_endquick(v, f->outSampleRate); } else { for (; v != vEnd; v++) if (v->playingPreset != -1 && v->ampenv.segment < TSF_SEGMENT_RELEASE) tsf_voice_end(v, f->outSampleRate); } } TSFDEF int tsf_active_voice_count(tsf* f) { int count = 0; struct tsf_voice *v = f->voices, *vEnd = v + f->voiceNum; for (; v != vEnd; v++) if (v->playingPreset != -1) count++; return count; } TSFDEF void tsf_render_short(tsf* f, short* buffer, int samples, int flag_mixing) { float *floatSamples; int channelSamples = (f->outputmode == TSF_MONO ? 1 : 2) * samples, floatBufferSize = channelSamples * sizeof(float); short* bufferEnd = buffer + channelSamples; if (floatBufferSize > f->outputSampleSize) { TSF_FREE(f->outputSamples); f->outputSamples = (float*)TSF_MALLOC(floatBufferSize); f->outputSampleSize = floatBufferSize; } tsf_render_float(f, f->outputSamples, samples, TSF_FALSE); floatSamples = f->outputSamples; if (flag_mixing) while (buffer != bufferEnd) { float v = *floatSamples++; int vi = *buffer + (v < -1.00004566f ? (int)-32768 : (v > 1.00001514f ? (int)32767 : (int)(v * 32767.5f))); *buffer++ = (vi < -32768 ? (short)-32768 : (vi > 32767 ? (short)32767 : (short)vi)); } else while (buffer != bufferEnd) { float v = *floatSamples++; *buffer++ = (v < -1.00004566f ? (short)-32768 : (v > 1.00001514f ? (short)32767 : (short)(v * 32767.5f))); } } TSFDEF void tsf_render_float(tsf* f, float* buffer, int samples, int flag_mixing) { struct tsf_voice *v = f->voices, *vEnd = v + f->voiceNum; if (!flag_mixing) TSF_MEMSET(buffer, 0, (f->outputmode == TSF_MONO ? 1 : 2) * sizeof(float) * samples); for (; v != vEnd; v++) if (v->playingPreset != -1) tsf_voice_render(f, v, buffer, samples); } static void tsf_channel_setup_voice(tsf* f, struct tsf_voice* v) { struct tsf_channel* c = &f->channels->channels[f->channels->activeChannel]; float newpan = v->region->pan + c->panOffset; v->playingChannel = f->channels->activeChannel; v->noteGainDB += c->gainDB; tsf_voice_calcpitchratio(v, (c->pitchWheel == 8192 ? c->tuning : ((c->pitchWheel / 16383.0f * c->pitchRange * 2.0f) - c->pitchRange + c->tuning)), f->outSampleRate); if (newpan <= -0.5f) { v->panFactorLeft = 1.0f; v->panFactorRight = 0.0f; } else if (newpan >= 0.5f) { v->panFactorLeft = 0.0f; v->panFactorRight = 1.0f; } else { v->panFactorLeft = TSF_SQRTF(0.5f - newpan); v->panFactorRight = TSF_SQRTF(0.5f + newpan); } } static struct tsf_channel* tsf_channel_init(tsf* f, int channel) { int i; if (f->channels && channel < f->channels->channelNum) return &f->channels->channels[channel]; if (!f->channels) { f->channels = (struct tsf_channels*)TSF_MALLOC(sizeof(struct tsf_channels)); f->channels->setupVoice = &tsf_channel_setup_voice; f->channels->channels = NULL; f->channels->channelNum = 0; f->channels->activeChannel = 0; } i = f->channels->channelNum; f->channels->channelNum = channel + 1; f->channels->channels = (struct tsf_channel*)TSF_REALLOC(f->channels->channels, f->channels->channelNum * sizeof(struct tsf_channel)); for (; i <= channel; i++) { struct tsf_channel* c = &f->channels->channels[i]; c->presetIndex = c->bank = 0; c->pitchWheel = c->midiPan = 8192; c->midiVolume = c->midiExpression = 16383; c->midiRPN = 0xFFFF; c->midiData = 0; c->panOffset = 0.0f; c->gainDB = 0.0f; c->pitchRange = 2.0f; c->tuning = 0.0f; } return &f->channels->channels[channel]; } static void tsf_channel_applypitch(tsf* f, int channel, struct tsf_channel* c) { struct tsf_voice *v, *vEnd; float pitchShift = (c->pitchWheel == 8192 ? c->tuning : ((c->pitchWheel / 16383.0f * c->pitchRange * 2.0f) - c->pitchRange + c->tuning)); for (v = f->voices, vEnd = v + f->voiceNum; v != vEnd; v++) if (v->playingChannel == channel && v->playingPreset != -1) tsf_voice_calcpitchratio(v, pitchShift, f->outSampleRate); } TSFDEF void tsf_channel_set_presetindex(tsf* f, int channel, int preset_index) { tsf_channel_init(f, channel)->presetIndex = (unsigned short)preset_index; } TSFDEF int tsf_channel_set_presetnumber(tsf* f, int channel, int preset_number, int flag_mididrums) { struct tsf_channel *c = tsf_channel_init(f, channel); int preset_index; if (flag_mididrums) { preset_index = tsf_get_presetindex(f, 128 | (c->bank & 0x7FFF), preset_number); if (preset_index == -1) preset_index = tsf_get_presetindex(f, 128, preset_number); if (preset_index == -1) preset_index = tsf_get_presetindex(f, 128, 0); if (preset_index == -1) preset_index = tsf_get_presetindex(f, (c->bank & 0x7FFF), preset_number); } else preset_index = tsf_get_presetindex(f, (c->bank & 0x7FFF), preset_number); if (preset_index == -1) preset_index = tsf_get_presetindex(f, 0, preset_number); if (preset_index != -1) { c->presetIndex = (unsigned short)preset_index; return 1; } return 0; } TSFDEF void tsf_channel_set_bank(tsf* f, int channel, int bank) { tsf_channel_init(f, channel)->bank = (unsigned short)bank; } TSFDEF int tsf_channel_set_bank_preset(tsf* f, int channel, int bank, int preset_number) { struct tsf_channel *c = tsf_channel_init(f, channel); int preset_index = tsf_get_presetindex(f, bank, preset_number); if (preset_index == -1) return 0; c->presetIndex = (unsigned short)preset_index; c->bank = (unsigned short)bank; return 1; } TSFDEF void tsf_channel_set_pan(tsf* f, int channel, float pan) { struct tsf_voice *v, *vEnd; for (v = f->voices, vEnd = v + f->voiceNum; v != vEnd; v++) if (v->playingChannel == channel && v->playingPreset != -1) { float newpan = v->region->pan + pan - 0.5f; if (newpan <= -0.5f) { v->panFactorLeft = 1.0f; v->panFactorRight = 0.0f; } else if (newpan >= 0.5f) { v->panFactorLeft = 0.0f; v->panFactorRight = 1.0f; } else { v->panFactorLeft = TSF_SQRTF(0.5f - newpan); v->panFactorRight = TSF_SQRTF(0.5f + newpan); } } tsf_channel_init(f, channel)->panOffset = pan - 0.5f; } TSFDEF void tsf_channel_set_volume(tsf* f, int channel, float volume) { struct tsf_channel *c = tsf_channel_init(f, channel); float gainDB = tsf_gainToDecibels(volume), gainDBChange = gainDB - c->gainDB; struct tsf_voice *v, *vEnd; if (gainDBChange == 0) return; for (v = f->voices, vEnd = v + f->voiceNum; v != vEnd; v++) if (v->playingChannel == channel && v->playingPreset != -1) v->noteGainDB += gainDBChange; c->gainDB = gainDB; } TSFDEF void tsf_channel_set_pitchwheel(tsf* f, int channel, int pitch_wheel) { struct tsf_channel *c = tsf_channel_init(f, channel); if (c->pitchWheel == pitch_wheel) return; c->pitchWheel = (unsigned short)pitch_wheel; tsf_channel_applypitch(f, channel, c); } TSFDEF void tsf_channel_set_pitchrange(tsf* f, int channel, float pitch_range) { struct tsf_channel *c = tsf_channel_init(f, channel); if (c->pitchRange == pitch_range) return; c->pitchRange = pitch_range; if (c->pitchWheel != 8192) tsf_channel_applypitch(f, channel, c); } TSFDEF void tsf_channel_set_tuning(tsf* f, int channel, float tuning) { struct tsf_channel *c = tsf_channel_init(f, channel); if (c->tuning == tuning) return; c->tuning = tuning; tsf_channel_applypitch(f, channel, c); } TSFDEF void tsf_channel_note_on(tsf* f, int channel, int key, float vel) { if (!f->channels || channel >= f->channels->channelNum) return; f->channels->activeChannel = channel; tsf_note_on(f, f->channels->channels[channel].presetIndex, key, vel); } TSFDEF void tsf_channel_note_off(tsf* f, int channel, int key) { struct tsf_voice *v = f->voices, *vEnd = v + f->voiceNum, *vMatchFirst = TSF_NULL, *vMatchLast = TSF_NULL; for (; v != vEnd; v++) { //Find the first and last entry in the voices list with matching channel, key and look up the smallest play index if (v->playingPreset == -1 || v->playingChannel != channel || v->playingKey != key || v->ampenv.segment >= TSF_SEGMENT_RELEASE) continue; else if (!vMatchFirst || v->playIndex < vMatchFirst->playIndex) vMatchFirst = vMatchLast = v; else if (v->playIndex == vMatchFirst->playIndex) vMatchLast = v; } if (!vMatchFirst) return; for (v = vMatchFirst; v <= vMatchLast; v++) { //Stop all voices with matching channel, key and the smallest play index which was enumerated above if (v != vMatchFirst && v != vMatchLast && (v->playIndex != vMatchFirst->playIndex || v->playingPreset == -1 || v->playingChannel != channel || v->playingKey != key || v->ampenv.segment >= TSF_SEGMENT_RELEASE)) continue; tsf_voice_end(v, f->outSampleRate); } } TSFDEF void tsf_channel_note_off_all(tsf* f, int channel) { struct tsf_voice *v = f->voices, *vEnd = v + f->voiceNum; for (; v != vEnd; v++) if (v->playingPreset != -1 && v->playingChannel == channel && v->ampenv.segment < TSF_SEGMENT_RELEASE) tsf_voice_end(v, f->outSampleRate); } TSFDEF void tsf_channel_sounds_off_all(tsf* f, int channel) { struct tsf_voice *v = f->voices, *vEnd = v + f->voiceNum; for (; v != vEnd; v++) if (v->playingPreset != -1 && v->playingChannel == channel && (v->ampenv.segment < TSF_SEGMENT_RELEASE || v->ampenv.parameters.release)) tsf_voice_endquick(v, f->outSampleRate); } TSFDEF void tsf_channel_midi_control(tsf* f, int channel, int controller, int control_value) { struct tsf_channel* c = tsf_channel_init(f, channel); switch (controller) { case 7 /*VOLUME_MSB*/ : c->midiVolume = (unsigned short)((c->midiVolume & 0x7F ) | (control_value << 7)); goto TCMC_SET_VOLUME; case 39 /*VOLUME_LSB*/ : c->midiVolume = (unsigned short)((c->midiVolume & 0x3F80) | control_value); goto TCMC_SET_VOLUME; case 11 /*EXPRESSION_MSB*/ : c->midiExpression = (unsigned short)((c->midiExpression & 0x7F ) | (control_value << 7)); goto TCMC_SET_VOLUME; case 43 /*EXPRESSION_LSB*/ : c->midiExpression = (unsigned short)((c->midiExpression & 0x3F80) | control_value); goto TCMC_SET_VOLUME; case 10 /*PAN_MSB*/ : c->midiPan = (unsigned short)((c->midiPan & 0x7F ) | (control_value << 7)); goto TCMC_SET_PAN; case 42 /*PAN_LSB*/ : c->midiPan = (unsigned short)((c->midiPan & 0x3F80) | control_value); goto TCMC_SET_PAN; case 6 /*DATA_ENTRY_MSB*/ : c->midiData = (unsigned short)((c->midiData & 0x7F) | (control_value << 7)); goto TCMC_SET_DATA; case 38 /*DATA_ENTRY_LSB*/ : c->midiData = (unsigned short)((c->midiData & 0x3F80) | control_value); goto TCMC_SET_DATA; case 0 /*BANK_SELECT_MSB*/ : c->bank = (unsigned short)(0x8000 | control_value); return; //bank select MSB alone acts like LSB case 32 /*BANK_SELECT_LSB*/ : c->bank = (unsigned short)((c->bank & 0x8000 ? ((c->bank & 0x7F) << 7) : 0) | control_value); return; case 101 /*RPN_MSB*/ : c->midiRPN = (unsigned short)(((c->midiRPN == 0xFFFF ? 0 : c->midiRPN) & 0x7F ) | (control_value << 7)); return; case 100 /*RPN_LSB*/ : c->midiRPN = (unsigned short)(((c->midiRPN == 0xFFFF ? 0 : c->midiRPN) & 0x3F80) | control_value); return; case 98 /*NRPN_LSB*/ : c->midiRPN = 0xFFFF; return; case 99 /*NRPN_MSB*/ : c->midiRPN = 0xFFFF; return; case 120 /*ALL_SOUND_OFF*/ : tsf_channel_sounds_off_all(f, channel); return; case 123 /*ALL_NOTES_OFF*/ : tsf_channel_note_off_all(f, channel); return; case 121 /*ALL_CTRL_OFF*/ : c->midiVolume = c->midiExpression = 16383; c->midiPan = 8192; c->bank = 0; tsf_channel_set_volume(f, channel, 1.0f); tsf_channel_set_pan(f, channel, 0.5f); tsf_channel_set_pitchrange(f, channel, 2.0f); return; } return; TCMC_SET_VOLUME: //Raising to the power of 3 seems to result in a decent sounding volume curve for MIDI tsf_channel_set_volume(f, channel, TSF_POWF((c->midiVolume / 16383.0f) * (c->midiExpression / 16383.0f), 3.0f)); return; TCMC_SET_PAN: tsf_channel_set_pan(f, channel, c->midiPan / 16383.0f); return; TCMC_SET_DATA: if (c->midiRPN == 0) tsf_channel_set_pitchrange(f, channel, (c->midiData >> 7) + 0.01f * (c->midiData & 0x7F)); else if (c->midiRPN == 1) tsf_channel_set_tuning(f, channel, (int)c->tuning + ((float)c->midiData - 8192.0f) / 8192.0f); //fine tune else if (c->midiRPN == 2 && controller == 6) tsf_channel_set_tuning(f, channel, ((float)control_value - 64.0f) + (c->tuning - (int)c->tuning)); //coarse tune return; } TSFDEF int tsf_channel_get_preset_index(tsf* f, int channel) { return (f->channels && channel < f->channels->channelNum ? f->channels->channels[channel].presetIndex : 0); } TSFDEF int tsf_channel_get_preset_bank(tsf* f, int channel) { return (f->channels && channel < f->channels->channelNum ? (f->channels->channels[channel].bank & 0x7FFF) : 0); } TSFDEF int tsf_channel_get_preset_number(tsf* f, int channel) { return (f->channels && channel < f->channels->channelNum ? f->presets[f->channels->channels[channel].presetIndex].preset : 0); } TSFDEF float tsf_channel_get_pan(tsf* f, int channel) { return (f->channels && channel < f->channels->channelNum ? f->channels->channels[channel].panOffset - 0.5f : 0.5f); } TSFDEF float tsf_channel_get_volume(tsf* f, int channel) { return (f->channels && channel < f->channels->channelNum ? tsf_decibelsToGain(f->channels->channels[channel].gainDB) : 1.0f); } TSFDEF int tsf_channel_get_pitchwheel(tsf* f, int channel) { return (f->channels && channel < f->channels->channelNum ? f->channels->channels[channel].pitchWheel : 8192); } TSFDEF float tsf_channel_get_pitchrange(tsf* f, int channel) { return (f->channels && channel < f->channels->channelNum ? f->channels->channels[channel].pitchRange : 2.0f); } TSFDEF float tsf_channel_get_tuning(tsf* f, int channel) { return (f->channels && channel < f->channels->channelNum ? f->channels->channels[channel].tuning : 0.0f); } #ifdef __cplusplus } #endif #endif //TSF_IMPLEMENTATION ================================================ FILE: deps/include/TracyC.h ================================================ #ifndef __TRACYC_HPP__ #define __TRACYC_HPP__ #include #include // Inlined from TracyApi.h // On Windows, when Tracy is enabled and we are not building the DLL itself, // default to __declspec(dllimport) so the pre-built Tracy.dll is used correctly. #if defined _WIN32 # if defined TRACY_EXPORTS # define TRACY_API __declspec(dllexport) # elif defined TRACY_ENABLE && !defined TRACY_STATIC_LINK # define TRACY_API __declspec(dllimport) # else # define TRACY_API # endif #else # define TRACY_API __attribute__((visibility("default"))) #endif #ifdef __cplusplus extern "C" { #endif enum TracyPlotFormatEnum { TracyPlotFormatNumber, TracyPlotFormatMemory, TracyPlotFormatPercentage, TracyPlotFormatWatt }; TRACY_API void ___tracy_set_thread_name( const char* name ); #define TracyCSetThreadName( name ) ___tracy_set_thread_name( name ); #ifndef TracyFunction # define TracyFunction __FUNCTION__ #endif #ifndef TracyFile # define TracyFile __FILE__ #endif #ifndef TracyLine # define TracyLine __LINE__ #endif #ifndef TRACY_ENABLE typedef const void* TracyCZoneCtx; typedef const void* TracyCLockCtx; #define TracyCZone(c,x) #define TracyCZoneN(c,x,y) #define TracyCZoneC(c,x,y) #define TracyCZoneNC(c,x,y,z) #define TracyCZoneEnd(c) #define TracyCZoneText(c,x,y) #define TracyCZoneName(c,x,y) #define TracyCZoneColor(c,x) #define TracyCZoneValue(c,x) #define TracyCAlloc(x,y) #define TracyCFree(x) #define TracyCMemoryDiscard(x) #define TracyCSecureAlloc(x,y) #define TracyCSecureFree(x) #define TracyCSecureMemoryDiscard(x) #define TracyCAllocN(x,y,z) #define TracyCFreeN(x,y) #define TracyCSecureAllocN(x,y,z) #define TracyCSecureFreeN(x,y) #define TracyCFrameMark #define TracyCFrameMarkNamed(x) #define TracyCFrameMarkStart(x) #define TracyCFrameMarkEnd(x) #define TracyCFrameImage(x,y,z,w,a) #define TracyCPlot(x,y) #define TracyCPlotF(x,y) #define TracyCPlotI(x,y) #define TracyCPlotConfig(x,y,z,w,a) #define TracyCMessage(x,y) #define TracyCMessageL(x) #define TracyCMessageC(x,y,z) #define TracyCMessageLC(x,y) #define TracyCAppInfo(x,y) #define TracyCZoneS(x,y,z) #define TracyCZoneNS(x,y,z,w) #define TracyCZoneCS(x,y,z,w) #define TracyCZoneNCS(x,y,z,w,a) #define TracyCAllocS(x,y,z) #define TracyCFreeS(x,y) #define TracyCMemoryDiscardS(x,y) #define TracyCSecureAllocS(x,y,z) #define TracyCSecureFreeS(x,y) #define TracyCSecureMemoryDiscardS(x,y) #define TracyCAllocNS(x,y,z,w) #define TracyCFreeNS(x,y,z) #define TracyCSecureAllocNS(x,y,z,w) #define TracyCSecureFreeNS(x,y,z) #define TracyCMessageS(x,y,z) #define TracyCMessageLS(x,y) #define TracyCMessageCS(x,y,z,w) #define TracyCMessageLCS(x,y,z) #define TracyCLockCtx(l) #define TracyCLockAnnounce(l) #define TracyCLockTerminate(l) #define TracyCLockBeforeLock(l) #define TracyCLockAfterLock(l) #define TracyCLockAfterUnlock(l) #define TracyCLockAfterTryLock(l,x) #define TracyCLockMark(l) #define TracyCLockCustomName(l,x,y) #define TracyCIsConnected 0 #define TracyCIsStarted 0 #define TracyCBeginSamplingProfiling() 0 #define TracyCEndSamplingProfiling() #ifdef TRACY_FIBERS # define TracyCFiberEnter(fiber) # define TracyCFiberLeave #endif #else #ifndef TracyConcat # define TracyConcat(x,y) TracyConcatIndirect(x,y) #endif #ifndef TracyConcatIndirect # define TracyConcatIndirect(x,y) x##y #endif struct ___tracy_source_location_data { const char* name; const char* function; const char* file; uint32_t line; uint32_t color; }; struct ___tracy_c_zone_context { uint32_t id; int32_t active; }; struct ___tracy_gpu_time_data { int64_t gpuTime; uint16_t queryId; uint8_t context; }; struct ___tracy_gpu_zone_begin_data { uint64_t srcloc; uint16_t queryId; uint8_t context; }; struct ___tracy_gpu_zone_begin_callstack_data { uint64_t srcloc; int32_t depth; uint16_t queryId; uint8_t context; }; struct ___tracy_gpu_zone_end_data { uint16_t queryId; uint8_t context; }; struct ___tracy_gpu_new_context_data { int64_t gpuTime; float period; uint8_t context; uint8_t flags; uint8_t type; }; struct ___tracy_gpu_context_name_data { uint8_t context; const char* name; uint16_t len; }; struct ___tracy_gpu_calibration_data { int64_t gpuTime; int64_t cpuDelta; uint8_t context; }; struct ___tracy_gpu_time_sync_data { int64_t gpuTime; uint8_t context; }; struct __tracy_lockable_context_data; // Some containers don't support storing const types. // This struct, as visible to user, is immutable, so treat it as if const was declared here. typedef /*const*/ struct ___tracy_c_zone_context TracyCZoneCtx; typedef struct __tracy_lockable_context_data* TracyCLockCtx; #ifdef TRACY_MANUAL_LIFETIME TRACY_API void ___tracy_startup_profiler(void); TRACY_API void ___tracy_shutdown_profiler(void); TRACY_API int32_t ___tracy_profiler_started(void); # define TracyCIsStarted ___tracy_profiler_started() #else # define TracyCIsStarted 1 #endif TRACY_API uint64_t ___tracy_alloc_srcloc( uint32_t line, const char* source, size_t sourceSz, const char* function, size_t functionSz, uint32_t color ); TRACY_API uint64_t ___tracy_alloc_srcloc_name( uint32_t line, const char* source, size_t sourceSz, const char* function, size_t functionSz, const char* name, size_t nameSz, uint32_t color ); TRACY_API TracyCZoneCtx ___tracy_emit_zone_begin( const struct ___tracy_source_location_data* srcloc, int32_t active ); TRACY_API TracyCZoneCtx ___tracy_emit_zone_begin_callstack( const struct ___tracy_source_location_data* srcloc, int32_t depth, int32_t active ); TRACY_API TracyCZoneCtx ___tracy_emit_zone_begin_alloc( uint64_t srcloc, int32_t active ); TRACY_API TracyCZoneCtx ___tracy_emit_zone_begin_alloc_callstack( uint64_t srcloc, int32_t depth, int32_t active ); TRACY_API void ___tracy_emit_zone_end( TracyCZoneCtx ctx ); TRACY_API void ___tracy_emit_zone_text( TracyCZoneCtx ctx, const char* txt, size_t size ); TRACY_API void ___tracy_emit_zone_name( TracyCZoneCtx ctx, const char* txt, size_t size ); TRACY_API void ___tracy_emit_zone_color( TracyCZoneCtx ctx, uint32_t color ); TRACY_API void ___tracy_emit_zone_value( TracyCZoneCtx ctx, uint64_t value ); TRACY_API void ___tracy_emit_gpu_zone_begin( const struct ___tracy_gpu_zone_begin_data ); TRACY_API void ___tracy_emit_gpu_zone_begin_callstack( const struct ___tracy_gpu_zone_begin_callstack_data ); TRACY_API void ___tracy_emit_gpu_zone_begin_alloc( const struct ___tracy_gpu_zone_begin_data ); TRACY_API void ___tracy_emit_gpu_zone_begin_alloc_callstack( const struct ___tracy_gpu_zone_begin_callstack_data ); TRACY_API void ___tracy_emit_gpu_zone_end( const struct ___tracy_gpu_zone_end_data data ); TRACY_API void ___tracy_emit_gpu_time( const struct ___tracy_gpu_time_data ); TRACY_API void ___tracy_emit_gpu_new_context( const struct ___tracy_gpu_new_context_data ); TRACY_API void ___tracy_emit_gpu_context_name( const struct ___tracy_gpu_context_name_data ); TRACY_API void ___tracy_emit_gpu_calibration( const struct ___tracy_gpu_calibration_data ); TRACY_API void ___tracy_emit_gpu_time_sync( const struct ___tracy_gpu_time_sync_data ); TRACY_API void ___tracy_emit_gpu_zone_begin_serial( const struct ___tracy_gpu_zone_begin_data ); TRACY_API void ___tracy_emit_gpu_zone_begin_callstack_serial( const struct ___tracy_gpu_zone_begin_callstack_data ); TRACY_API void ___tracy_emit_gpu_zone_begin_alloc_serial( const struct ___tracy_gpu_zone_begin_data ); TRACY_API void ___tracy_emit_gpu_zone_begin_alloc_callstack_serial( const struct ___tracy_gpu_zone_begin_callstack_data ); TRACY_API void ___tracy_emit_gpu_zone_end_serial( const struct ___tracy_gpu_zone_end_data data ); TRACY_API void ___tracy_emit_gpu_time_serial( const struct ___tracy_gpu_time_data ); TRACY_API void ___tracy_emit_gpu_new_context_serial( const struct ___tracy_gpu_new_context_data ); TRACY_API void ___tracy_emit_gpu_context_name_serial( const struct ___tracy_gpu_context_name_data ); TRACY_API void ___tracy_emit_gpu_calibration_serial( const struct ___tracy_gpu_calibration_data ); TRACY_API void ___tracy_emit_gpu_time_sync_serial( const struct ___tracy_gpu_time_sync_data ); TRACY_API int32_t ___tracy_connected(void); #ifndef TRACY_CALLSTACK #define TRACY_CALLSTACK 0 #endif #define TracyCZone( ctx, active ) static const struct ___tracy_source_location_data TracyConcat(__tracy_source_location,TracyLine) = { NULL, __func__, TracyFile, (uint32_t)TracyLine, 0 }; TracyCZoneCtx ctx = ___tracy_emit_zone_begin_callstack( &TracyConcat(__tracy_source_location,TracyLine), TRACY_CALLSTACK, active ); #define TracyCZoneN( ctx, name, active ) static const struct ___tracy_source_location_data TracyConcat(__tracy_source_location,TracyLine) = { name, __func__, TracyFile, (uint32_t)TracyLine, 0 }; TracyCZoneCtx ctx = ___tracy_emit_zone_begin_callstack( &TracyConcat(__tracy_source_location,TracyLine), TRACY_CALLSTACK, active ); #define TracyCZoneC( ctx, color, active ) static const struct ___tracy_source_location_data TracyConcat(__tracy_source_location,TracyLine) = { NULL, __func__, TracyFile, (uint32_t)TracyLine, color }; TracyCZoneCtx ctx = ___tracy_emit_zone_begin_callstack( &TracyConcat(__tracy_source_location,TracyLine), TRACY_CALLSTACK, active ); #define TracyCZoneNC( ctx, name, color, active ) static const struct ___tracy_source_location_data TracyConcat(__tracy_source_location,TracyLine) = { name, __func__, TracyFile, (uint32_t)TracyLine, color }; TracyCZoneCtx ctx = ___tracy_emit_zone_begin_callstack( &TracyConcat(__tracy_source_location,TracyLine), TRACY_CALLSTACK, active ); #define TracyCZoneEnd( ctx ) ___tracy_emit_zone_end( ctx ); #define TracyCZoneText( ctx, txt, size ) ___tracy_emit_zone_text( ctx, txt, size ); #define TracyCZoneName( ctx, txt, size ) ___tracy_emit_zone_name( ctx, txt, size ); #define TracyCZoneColor( ctx, color ) ___tracy_emit_zone_color( ctx, color ); #define TracyCZoneValue( ctx, value ) ___tracy_emit_zone_value( ctx, value ); TRACY_API void ___tracy_emit_memory_alloc( const void* ptr, size_t size, int32_t secure ); TRACY_API void ___tracy_emit_memory_alloc_callstack( const void* ptr, size_t size, int32_t depth, int32_t secure ); TRACY_API void ___tracy_emit_memory_free( const void* ptr, int32_t secure ); TRACY_API void ___tracy_emit_memory_free_callstack( const void* ptr, int32_t depth, int32_t secure ); TRACY_API void ___tracy_emit_memory_alloc_named( const void* ptr, size_t size, int32_t secure, const char* name ); TRACY_API void ___tracy_emit_memory_alloc_callstack_named( const void* ptr, size_t size, int32_t depth, int32_t secure, const char* name ); TRACY_API void ___tracy_emit_memory_free_named( const void* ptr, int32_t secure, const char* name ); TRACY_API void ___tracy_emit_memory_free_callstack_named( const void* ptr, int32_t depth, int32_t secure, const char* name ); TRACY_API void ___tracy_emit_memory_discard( const char* name, int32_t secure ); TRACY_API void ___tracy_emit_memory_discard_callstack( const char* name, int32_t secure, int32_t depth ); TRACY_API void ___tracy_emit_message( const char* txt, size_t size, int32_t callstack_depth ); TRACY_API void ___tracy_emit_messageL( const char* txt, int32_t callstack_depth ); TRACY_API void ___tracy_emit_messageC( const char* txt, size_t size, uint32_t color, int32_t callstack_depth ); TRACY_API void ___tracy_emit_messageLC( const char* txt, uint32_t color, int32_t callstack_depth ); #define TracyCAlloc( ptr, size ) ___tracy_emit_memory_alloc_callstack( ptr, size, TRACY_CALLSTACK, 0 ) #define TracyCFree( ptr ) ___tracy_emit_memory_free_callstack( ptr, TRACY_CALLSTACK, 0 ) #define TracyCMemoryDiscard( name ) ___tracy_emit_memory_discard_callstack( name, 0, TRACY_CALLSTACK ); #define TracyCSecureAlloc( ptr, size ) ___tracy_emit_memory_alloc_callstack( ptr, size, TRACY_CALLSTACK, 1 ) #define TracyCSecureFree( ptr ) ___tracy_emit_memory_free_callstack( ptr, TRACY_CALLSTACK, 1 ) #define TracyCSecureMemoryDiscard( name ) ___tracy_emit_memory_discard_callstack( name, 1, TRACY_CALLSTACK ); #define TracyCAllocN( ptr, size, name ) ___tracy_emit_memory_alloc_callstack_named( ptr, size, TRACY_CALLSTACK, 0, name ) #define TracyCFreeN( ptr, name ) ___tracy_emit_memory_free_callstack_named( ptr, TRACY_CALLSTACK, 0, name ) #define TracyCSecureAllocN( ptr, size, name ) ___tracy_emit_memory_alloc_callstack_named( ptr, size, TRACY_CALLSTACK, 1, name ) #define TracyCSecureFreeN( ptr, name ) ___tracy_emit_memory_free_callstack_named( ptr, TRACY_CALLSTACK, 1, name ) #define TracyCMessage( txt, size ) ___tracy_emit_message( txt, size, TRACY_CALLSTACK ); #define TracyCMessageL( txt ) ___tracy_emit_messageL( txt, TRACY_CALLSTACK ); #define TracyCMessageC( txt, size, color ) ___tracy_emit_messageC( txt, size, color, TRACY_CALLSTACK ); #define TracyCMessageLC( txt, color ) ___tracy_emit_messageLC( txt, color, TRACY_CALLSTACK ); TRACY_API void ___tracy_emit_frame_mark( const char* name ); TRACY_API void ___tracy_emit_frame_mark_start( const char* name ); TRACY_API void ___tracy_emit_frame_mark_end( const char* name ); TRACY_API void ___tracy_emit_frame_image( const void* image, uint16_t w, uint16_t h, uint8_t offset, int32_t flip ); #define TracyCFrameMark ___tracy_emit_frame_mark( 0 ); #define TracyCFrameMarkNamed( name ) ___tracy_emit_frame_mark( name ); #define TracyCFrameMarkStart( name ) ___tracy_emit_frame_mark_start( name ); #define TracyCFrameMarkEnd( name ) ___tracy_emit_frame_mark_end( name ); #define TracyCFrameImage( image, width, height, offset, flip ) ___tracy_emit_frame_image( image, width, height, offset, flip ); TRACY_API void ___tracy_emit_plot( const char* name, double val ); TRACY_API void ___tracy_emit_plot_float( const char* name, float val ); TRACY_API void ___tracy_emit_plot_int( const char* name, int64_t val ); TRACY_API void ___tracy_emit_plot_config( const char* name, int32_t type, int32_t step, int32_t fill, uint32_t color ); TRACY_API void ___tracy_emit_message_appinfo( const char* txt, size_t size ); #define TracyCPlot( name, val ) ___tracy_emit_plot( name, val ); #define TracyCPlotF( name, val ) ___tracy_emit_plot_float( name, val ); #define TracyCPlotI( name, val ) ___tracy_emit_plot_int( name, val ); #define TracyCPlotConfig( name, type, step, fill, color ) ___tracy_emit_plot_config( name, type, step, fill, color ); #define TracyCAppInfo( txt, size ) ___tracy_emit_message_appinfo( txt, size ); #define TracyCZoneS( ctx, depth, active ) static const struct ___tracy_source_location_data TracyConcat(__tracy_source_location,TracyLine) = { NULL, __func__, TracyFile, (uint32_t)TracyLine, 0 }; TracyCZoneCtx ctx = ___tracy_emit_zone_begin_callstack( &TracyConcat(__tracy_source_location,TracyLine), depth, active ); #define TracyCZoneNS( ctx, name, depth, active ) static const struct ___tracy_source_location_data TracyConcat(__tracy_source_location,TracyLine) = { name, __func__, TracyFile, (uint32_t)TracyLine, 0 }; TracyCZoneCtx ctx = ___tracy_emit_zone_begin_callstack( &TracyConcat(__tracy_source_location,TracyLine), depth, active ); #define TracyCZoneCS( ctx, color, depth, active ) static const struct ___tracy_source_location_data TracyConcat(__tracy_source_location,TracyLine) = { NULL, __func__, TracyFile, (uint32_t)TracyLine, color }; TracyCZoneCtx ctx = ___tracy_emit_zone_begin_callstack( &TracyConcat(__tracy_source_location,TracyLine), depth, active ); #define TracyCZoneNCS( ctx, name, color, depth, active ) static const struct ___tracy_source_location_data TracyConcat(__tracy_source_location,TracyLine) = { name, __func__, TracyFile, (uint32_t)TracyLine, color }; TracyCZoneCtx ctx = ___tracy_emit_zone_begin_callstack( &TracyConcat(__tracy_source_location,TracyLine), depth, active ); #define TracyCAllocS( ptr, size, depth ) ___tracy_emit_memory_alloc_callstack( ptr, size, depth, 0 ) #define TracyCFreeS( ptr, depth ) ___tracy_emit_memory_free_callstack( ptr, depth, 0 ) #define TracyCMemoryDiscardS( name, depth ) ___tracy_emit_memory_discard_callstack( name, 0, depth ) #define TracyCSecureAllocS( ptr, size, depth ) ___tracy_emit_memory_alloc_callstack( ptr, size, depth, 1 ) #define TracyCSecureFreeS( ptr, depth ) ___tracy_emit_memory_free_callstack( ptr, depth, 1 ) #define TracyCSecureMemoryDiscardS( name, depth ) ___tracy_emit_memory_discard_callstack( name, 1, depth ) #define TracyCAllocNS( ptr, size, depth, name ) ___tracy_emit_memory_alloc_callstack_named( ptr, size, depth, 0, name ) #define TracyCFreeNS( ptr, depth, name ) ___tracy_emit_memory_free_callstack_named( ptr, depth, 0, name ) #define TracyCSecureAllocNS( ptr, size, depth, name ) ___tracy_emit_memory_alloc_callstack_named( ptr, size, depth, 1, name ) #define TracyCSecureFreeNS( ptr, depth, name ) ___tracy_emit_memory_free_callstack_named( ptr, depth, 1, name ) #define TracyCMessageS( txt, size, depth ) ___tracy_emit_message( txt, size, depth ); #define TracyCMessageLS( txt, depth ) ___tracy_emit_messageL( txt, depth ); #define TracyCMessageCS( txt, size, color, depth ) ___tracy_emit_messageC( txt, size, color, depth ); #define TracyCMessageLCS( txt, color, depth ) ___tracy_emit_messageLC( txt, color, depth ); TRACY_API struct __tracy_lockable_context_data* ___tracy_announce_lockable_ctx( const struct ___tracy_source_location_data* srcloc ); TRACY_API void ___tracy_terminate_lockable_ctx( struct __tracy_lockable_context_data* lockdata ); TRACY_API int32_t ___tracy_before_lock_lockable_ctx( struct __tracy_lockable_context_data* lockdata ); TRACY_API void ___tracy_after_lock_lockable_ctx( struct __tracy_lockable_context_data* lockdata ); TRACY_API void ___tracy_after_unlock_lockable_ctx( struct __tracy_lockable_context_data* lockdata ); TRACY_API void ___tracy_after_try_lock_lockable_ctx( struct __tracy_lockable_context_data* lockdata, int32_t acquired ); TRACY_API void ___tracy_mark_lockable_ctx( struct __tracy_lockable_context_data* lockdata, const struct ___tracy_source_location_data* srcloc ); TRACY_API void ___tracy_custom_name_lockable_ctx( struct __tracy_lockable_context_data* lockdata, const char* name, size_t nameSz ); #define TracyCLockAnnounce( lock ) static const struct ___tracy_source_location_data TracyConcat(__tracy_source_location,TracyLine) = { NULL, __func__, TracyFile, (uint32_t)TracyLine, 0 }; lock = ___tracy_announce_lockable_ctx( &TracyConcat(__tracy_source_location,TracyLine) ); #define TracyCLockTerminate( lock ) ___tracy_terminate_lockable_ctx( lock ); #define TracyCLockBeforeLock( lock ) ___tracy_before_lock_lockable_ctx( lock ); #define TracyCLockAfterLock( lock ) ___tracy_after_lock_lockable_ctx( lock ); #define TracyCLockAfterUnlock( lock ) ___tracy_after_unlock_lockable_ctx( lock ); #define TracyCLockAfterTryLock( lock, acquired ) ___tracy_after_try_lock_lockable_ctx( lock, acquired ); #define TracyCLockMark( lock ) static const struct ___tracy_source_location_data TracyConcat(__tracy_source_location,TracyLine) = { NULL, __func__, TracyFile, (uint32_t)TracyLine, 0 }; ___tracy_mark_lockable_ctx( lock, &TracyConcat(__tracy_source_location,TracyLine) ); #define TracyCLockCustomName( lock, name, nameSz ) ___tracy_custom_name_lockable_ctx( lock, name, nameSz ); #define TracyCIsConnected ___tracy_connected() TRACY_API int ___tracy_begin_sampling_profiler( void ); TRACY_API void ___tracy_end_sampling_profiler( void ); #define TracyCBeginSamplingProfiling() ___tracy_begin_sampling_profiling() #define TracyCEndSamplingProfiling() ___tracy_end_sampling_profiling() #ifdef TRACY_FIBERS TRACY_API void ___tracy_fiber_enter( const char* fiber ); TRACY_API void ___tracy_fiber_leave( void ); # define TracyCFiberEnter( fiber ) ___tracy_fiber_enter( fiber ); # define TracyCFiberLeave ___tracy_fiber_leave(); #endif #endif #ifdef __cplusplus } #endif #endif ================================================ FILE: deps/include/shl/array.h ================================================ /* array.h - acoto87 (acoto87@gmail.com) MIT License Copyright (c) 2018 Alejandro Coto Gutiérrez 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. Single-header macro helpers for creating and freeing strongly typed 2D arrays backed by one contiguous allocation plus row pointers. USAGE Include this header wherever the declarations are needed. In exactly one translation unit, use shlDeclareCreateArray(prefix, itemType) and shlDefineCreateArray(prefix, itemType) to generate the creator, and pair shlDeclareFreeArray(prefix, itemType) with shlDefineFreeArray(prefix, itemType) if you also want the matching free helper. CUSTOMISATION Choose a unique prefix and the element type you want stored. The generated array uses one contiguous allocation for values plus a separate row-pointer table, so row access stays simple while the data remains cache-friendly. NOTES CreateArray allocates both the backing values block and the row table. FreeArray expects the pointer returned by CreateArray and releases both allocations. */ #ifndef SHL_ARRAY_H #define SHL_ARRAY_H #include #include #define shlDeclareCreateArray(prefix, itemType) \ itemType** prefix ## CreateArray(int32_t n, int32_t m); #define shlDefineCreateArray(prefix, itemType) \ itemType** prefix ## CreateArray(int32_t n, int32_t m) \ { \ itemType* values = (itemType*)calloc(m * n, sizeof(itemType)); \ itemType** rows = (itemType**)malloc(n * sizeof(itemType*)); \ for (int i = 0; i < n; ++i) \ { \ rows[i] = values + i * m; \ } \ return rows; \ } #define shlDeclareFreeArray(prefix, itemType) \ void prefix ## FreeArray(itemType** arr); #define shlDefineFreeArray(prefix, itemType) \ void prefix ## FreeArray(itemType** arr) \ { \ free(*arr); \ free(arr); \ } #endif // SHL_ARRAY_H ================================================ FILE: deps/include/shl/binary_heap.h ================================================ /* binary_heap.h - acoto87 (acoto87@gmail.com) MIT License Copyright (c) 2018 Alejandro Coto Gutiérrez 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. Single-header macro library to declare and define strongly typed binary heaps backed by a dynamically resized array. USAGE Declare a heap type with shlDeclareBinaryHeap(name, type), then define it once with shlDefineBinaryHeap(name, type) in a C source file. CUSTOMISATION Provide a compare function that orders items, an equality function for lookups, a default value for empty reads, and an optional free function for owned values. Items are stored by copy. NOTES This implementation behaves as a min-heap according to compareFn. Push, Pop, and Update all restore heap order automatically. Call Free to release internal storage and Clear to dispose of retained items. */ #ifndef SHL_HEAP_H #define SHL_HEAP_H #include "shl_internal.h" #define shlDeclareBinaryHeap(typeName, itemType) \ typedef struct \ { \ itemType defaultValue; \ bool (*equalsFn)(const itemType item1, const itemType item2); \ int32_t (*compareFn)(const itemType item1, const itemType item2); \ void (*freeFn)(itemType item); \ } typeName ## Options; \ \ typedef struct \ { \ int32_t count; \ int32_t capacity; \ bool (*equalsFn)(const itemType item1, const itemType item2); \ int32_t (*compareFn)(const itemType item1, const itemType item2); \ void (*freeFn)(itemType item); \ itemType defaultValue; \ itemType* items; \ } typeName; \ \ void typeName ## Init(typeName* heap, typeName ## Options options); \ void typeName ## Free(typeName* heap); \ void typeName ## Push(typeName* heap, itemType value); \ itemType typeName ## Peek(typeName* heap); \ itemType typeName ## Pop(typeName* heap); \ int32_t typeName ## IndexOf(typeName* heap, itemType value); \ bool typeName ## Contains(typeName* heap, itemType value); \ void typeName ## Update(typeName* heap, int32_t index, itemType newValue); \ void typeName ## Clear(typeName* heap); #define shlDefineBinaryHeap(typeName, itemType) \ void typeName ## __heapUp(typeName* heap, int32_t index) \ { \ int32_t pindex = (index - 1) >> 1; \ while (index > 0 && heap->compareFn(heap->items[index], heap->items[pindex]) < 0) \ { \ itemType tmp = heap->items[index]; \ heap->items[index] = heap->items[pindex]; \ heap->items[pindex] = tmp; \ \ index = pindex; \ pindex = (index - 1) >> 1; \ } \ } \ \ void typeName ## __heapDown(typeName* heap, int32_t index) \ { \ while (index < heap->count) \ { \ itemType value = heap->items[index]; \ \ int32_t leftIndex = 2 * index + 1; \ if (leftIndex >= heap->count) \ break; \ \ int32_t minIndex = leftIndex; \ itemType minValue = heap->items[minIndex]; \ \ int32_t rightIndex = 2 * index + 2; \ if (rightIndex < heap->count) \ { \ itemType rightValue = heap->items[rightIndex]; \ if (heap->compareFn(rightValue, minValue) < 0) \ { \ minIndex = rightIndex; \ minValue = rightValue; \ } \ } \ \ if (heap->compareFn(minValue, value) >= 0) \ break; \ \ itemType tmp = heap->items[index]; \ heap->items[index] = heap->items[minIndex]; \ heap->items[minIndex] = tmp; \ \ index = minIndex; \ } \ } \ \ void typeName ## Init(typeName* heap, typeName ## Options options) \ { \ heap->capacity = SHL__INITIAL_CAPACITY; \ heap->defaultValue = options.defaultValue; \ heap->equalsFn = options.equalsFn; \ heap->compareFn = options.compareFn; \ heap->freeFn = options.freeFn; \ heap->count = 0; \ heap->items = (itemType *)SHL_MALLOC((size_t)heap->capacity * sizeof(itemType)); \ } \ \ void typeName ## Free(typeName* heap) \ { \ if (!heap->items) \ return; \ \ typeName ## Clear(heap); \ \ SHL_FREE(heap->items); \ heap->items = 0; \ } \ \ void typeName ## Push(typeName* heap, itemType value) \ { \ if (!heap->items) \ return; \ \ if (heap->count + 1 >= heap->capacity) \ shl__resizeArray((void**)&heap->items, &heap->capacity, heap->count + 1, sizeof(itemType)); \ \ int32_t index = heap->count; \ heap->items[index] = value; \ \ typeName ## __heapUp(heap, index); \ heap->count++; \ } \ \ itemType typeName ## Peek(typeName* heap) \ { \ if (!heap->items) \ return heap->defaultValue; \ \ if (heap->count == 0) \ return heap->defaultValue; \ \ return heap->items[0]; \ } \ \ itemType typeName ## Pop(typeName* heap) \ { \ if (!heap->items) \ return heap->defaultValue; \ \ if (heap->count == 0) \ return heap->defaultValue; \ \ itemType returnValue = heap->items[0]; \ \ heap->items[0] = heap->items[heap->count - 1]; \ heap->count--; \ typeName ## __heapDown(heap, 0); \ \ return returnValue; \ } \ \ int32_t typeName ## IndexOf(typeName* heap, itemType value) \ { \ if (!heap->items) \ return -1; \ \ if (!heap->equalsFn) \ return -1; \ \ for(int32_t i = 0; i < heap->count; i++) \ { \ if (heap->equalsFn(heap->items[i], value)) \ return i; \ } \ \ return -1; \ } \ \ bool typeName ## Contains(typeName* heap, itemType value) \ { \ return typeName ## IndexOf(heap, value) >= 0; \ } \ \ void typeName ## Update(typeName* heap, int32_t index, itemType newValue) \ { \ if (!heap->items) \ return; \ \ if (!heap->compareFn) \ return; \ \ if (index < 0 || index >= heap->count) \ return; \ \ itemType oldValue = heap->items[index]; \ heap->items[index] = newValue; \ int32_t cmpValue = heap->compareFn(newValue, oldValue); \ if (cmpValue < 0) \ typeName ## __heapUp(heap, index); \ else if (cmpValue > 0) \ typeName ## __heapDown(heap, index); \ } \ \ void typeName ## Clear(typeName* heap) \ { \ if (!heap->items) \ return; \ \ if (heap->freeFn) \ { \ for(int32_t i = 0; i < heap->count; i++) \ heap->freeFn(heap->items[i]); \ } \ \ heap->count = 0; \ } #endif // SHL_HEAP_H ================================================ FILE: deps/include/shl/flic.h ================================================ /* flic.h - acoto87 (acoto87@gmail.com) MIT License Copyright (c) 2018 Alejandro Coto Gutiérrez 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. Single-header reader for Autodesk Animator FLI/FLC animation files. This implementation is a C port of David Capello's Aseprite FLIC library: https://github.com/aseprite/flic USAGE Include this header in all translation units that need the declarations. Define SHL_FLIC_IMPLEMENTATION in exactly one translation unit before the include to compile the implementation: #define SHL_FLIC_IMPLEMENTATION #include "flic.h" Include the header without that define everywhere else: #include "flic.h" CUSTOMISATION The reader is self-contained and does not expose allocator or I/O hooks. If you need different file handling or memory behavior, adjust the implementation section directly. NOTES flicOpen initializes a Flic from a file on disk, flicReadFrame decodes the next frame into caller-provided buffers, and flicClose releases file-backed resources when you are done. */ #ifndef SHL_FLIC_H #define SHL_FLIC_H #include #include #include #ifdef __cplusplus extern "C" { #endif #define FLI_MAGIC_NUMBER 0xAF11 #define FLC_MAGIC_NUMBER 0xAF12 #define FLI_FRAME_MAGIC_NUMBER 0xF1FA #define FLI_COLOR_256_CHUNK 4 #define FLI_DELTA_CHUNK 7 #define FLI_COLOR_64_CHUNK 11 #define FLI_LC_CHUNK 12 #define FLI_BLACK_CHUNK 13 #define FLI_BRUN_CHUNK 15 #define FLI_COPY_CHUNK 16 #define FLI_COLORS_SIZE 768 // 256 * 3 #define FLI_PXL_CHANGE 0x100 #define FLI_PXL_INDEX 0xFF typedef struct _Flic { uint16_t frames; uint16_t width; uint16_t height; uint16_t speed; uint32_t oframe1; uint32_t oframe2; FILE* file; uint32_t currentFrame; } Flic; typedef struct _FlicFrame { uint16_t* pixels; uint32_t rowStride; uint8_t colors[FLI_COLORS_SIZE]; } FlicFrame; bool flicOpen(Flic* flic, const char* filename); bool flicReadFrame(Flic* flic, FlicFrame* frame); void flicMakeImage(Flic* flic, FlicFrame* frame, uint8_t* image); void flicClose(Flic* flic); #ifdef __cplusplus } #endif #ifdef SHL_FLIC_IMPLEMENTATION #include static inline uint8_t flic__read8(FILE* file) { return fgetc(file); } static inline void flic__write8(FILE* file, uint8_t value) { fputc(value, file); } static inline uint16_t flic__read16(FILE* file) { int c1 = fgetc(file); if (c1 == EOF) return 0; int c2 = fgetc(file); if (c2 == EOF) return 0; return (uint16_t)((unsigned char)c2 << 8 | (unsigned char)c1); } static inline uint32_t flic__read32(FILE* file) { int c1 = fgetc(file); if (c1 == EOF) return 0; int c2 = fgetc(file); if (c2 == EOF) return 0; int c3 = fgetc(file); if (c3 == EOF) return 0; int c4 = fgetc(file); if (c4 == EOF) return 0; return ((uint32_t)(unsigned char)c4 << 24) | ((uint32_t)(unsigned char)c3 << 16) | ((uint32_t)(unsigned char)c2 << 8) | (uint32_t)(unsigned char)c1; } static inline size_t flic__tell(FILE* file) { return ftell(file); } static inline void flic__seek(FILE* file, size_t pos) { fseek(file, pos, SEEK_SET); } static void flic__readBlackChunk(Flic* flic, FlicFrame* frame) { memset(frame->pixels, FLI_PXL_CHANGE, frame->rowStride * flic->height); } static void flic__readCopyChunk(Flic* flic, FlicFrame* frame) { for (int32_t y = 0; y < flic->height; ++y) { uint16_t* row = frame->pixels + frame->rowStride * y; for (int32_t x = 0; x < flic->width; ++x) row[x] = flic__read8(flic->file) | FLI_PXL_CHANGE; } } static void flic__readColorChunk(Flic* flic, FlicFrame* frame, bool is64ColorMap) { uint16_t npackets = flic__read16(flic->file); uint8_t i = 0; while (npackets--) { i += flic__read8(flic->file); // Colors to skip uint16_t colors = (uint16_t)flic__read8(flic->file); if (colors == 0) colors = FLI_COLORS_SIZE / 3; for (int32_t j = 0; j < colors; ++j) { uint8_t r = flic__read8(flic->file); uint8_t g = flic__read8(flic->file); uint8_t b = flic__read8(flic->file); if (is64ColorMap) { r = (uint8_t)(255 * ((float)r / 63)); g = (uint8_t)(255 * ((float)g / 63)); b = (uint8_t)(255 * ((float)b / 63)); } frame->colors[(i + j) * 3 + 0] = r; frame->colors[(i + j) * 3 + 1] = g; frame->colors[(i + j) * 3 + 2] = b; } } } static void flic__readBrunChunk(Flic* flic, FlicFrame* frame) { for (int32_t y = 0; y < flic->height; ++y) { uint16_t* row = frame->pixels + frame->rowStride * y; int32_t x = 0; flic__read8(flic->file); // Ignore number of packets (we read until x == m_width) while (x < flic->width) { int8_t count = (int8_t)flic__read8(flic->file); if (count >= 0) { uint8_t color = flic__read8(flic->file); while (count-- && x < flic->width) row[x++] = color | FLI_PXL_CHANGE; } else { count = -count; while (count--) row[x++] = flic__read8(flic->file) | FLI_PXL_CHANGE; } } } } static void flic__readLcChunk(Flic* flic, FlicFrame* frame) { uint16_t skipLines = flic__read16(flic->file); uint16_t nlines = flic__read16(flic->file); for (int32_t y = skipLines; y < skipLines + nlines; ++y) { uint16_t* row = frame->pixels + frame->rowStride * y; int32_t x = 0; uint8_t npackets = flic__read8(flic->file); while (npackets-- && x < flic->width) { uint8_t skip = flic__read8(flic->file); x += skip; int8_t count = (int8_t)flic__read8(flic->file); if (count >= 0) { while (count--) row[x++] = flic__read8(flic->file) | FLI_PXL_CHANGE; } else { count = -count; uint8_t color = flic__read8(flic->file); while (count-- && x < flic->width) row[x++] = color | FLI_PXL_CHANGE; } } } } static void flic__readDeltaChunk(Flic* flic, FlicFrame* frame) { uint16_t nlines = flic__read16(flic->file); int32_t y = 0; while (nlines--) { int16_t word = (int16_t)flic__read16(flic->file); while (word < 0) { if (word & 0x4000) // Has bit 14 (0x4000) { y += -word; // Skip lines } else // Only last pixel has changed { if (y >= 0 && y < flic->height) { uint16_t* row = frame->pixels + frame->rowStride * y; row[flic->width - 1] = (word & 0xff) | FLI_PXL_CHANGE; } ++y; if (nlines-- == 0) return; } word = (int16_t)flic__read16(flic->file); } uint16_t npackets = (uint16_t)word; int32_t x = 0; while (npackets--) { x += flic__read8(flic->file); // Skip pixels int8_t count = (int8_t)flic__read8(flic->file); // Number of words uint16_t* row = frame->pixels + frame->rowStride * y; if (count >= 0) { while (count-- && x < flic->width) { uint8_t color1 = flic__read8(flic->file); uint8_t color2 = flic__read8(flic->file); row[x++] = color1 | FLI_PXL_CHANGE; if (x < flic->width) row[x++] = color2 | FLI_PXL_CHANGE; } } else { count = -count; uint8_t color1 = flic__read8(flic->file); uint8_t color2 = flic__read8(flic->file); while (count-- && x < flic->width) { row[x++] = color1 | FLI_PXL_CHANGE; if (x < flic->width) row[x++] = color2 | FLI_PXL_CHANGE; } } } ++y; } } static void flic__readChunk(Flic* flic, FlicFrame* frame) { uint32_t chunkStartPos = flic__tell(flic->file); uint32_t chunkSize = flic__read32(flic->file); uint16_t type = flic__read16(flic->file); switch (type) { case FLI_COLOR_256_CHUNK: flic__readColorChunk(flic, frame, false); break; case FLI_DELTA_CHUNK: flic__readDeltaChunk(flic, frame); break; case FLI_COLOR_64_CHUNK: flic__readColorChunk(flic, frame, true); break; case FLI_LC_CHUNK: flic__readLcChunk(flic, frame); break; case FLI_BLACK_CHUNK: flic__readBlackChunk(flic, frame); break; case FLI_BRUN_CHUNK: flic__readBrunChunk(flic, frame); break; case FLI_COPY_CHUNK: flic__readCopyChunk(flic, frame); break; default: // Ignore all other kind of chunks break; } flic__seek(flic->file, chunkStartPos + chunkSize); } bool flicOpen(Flic* flic, const char* filename) { memset(flic, 0, sizeof(Flic)); flic->file = fopen(filename, "rb"); if (!flic->file) return false; flic__read32(flic->file); // file size uint16_t magic = flic__read16(flic->file); if (magic != FLI_MAGIC_NUMBER && magic != FLC_MAGIC_NUMBER) { fclose(flic->file); flic->file = NULL; return false; } flic->frames = flic__read16(flic->file); flic->width = flic__read16(flic->file); flic->height = flic__read16(flic->file); flic__read16(flic->file); // Color depth (it is interpreted as 8bpp anyway) flic__read16(flic->file); // Skip flags flic->speed = flic__read32(flic->file); if (magic == FLI_MAGIC_NUMBER) { if (flic->speed == 0) flic->speed = 70; else flic->speed = 1000 * flic->speed / 70; } if (magic == FLC_MAGIC_NUMBER) { // Offset to the first and second frame header values flic__seek(flic->file, 80); flic->oframe1 = flic__read32(flic->file); flic->oframe2 = flic__read32(flic->file); } if (flic->width == 0) flic->width = 320; if (flic->height == 0) flic->height = 200; // Skip padding flic__seek(flic->file, 128); return true; } void flicClose(Flic* flic) { if (flic->file) { fclose(flic->file); flic->file = NULL; } } bool flicReadFrame(Flic* flic, FlicFrame* frame) { switch (flic->currentFrame) { case 0: { if (flic->oframe1) flic__seek(flic->file, flic->oframe1); break; } case 1: { if (flic->oframe2) flic__seek(flic->file, flic->oframe2); break; } } uint32_t frameStartPos = flic__tell(flic->file); uint32_t frameSize = flic__read32(flic->file); uint16_t magic = flic__read16(flic->file); if (magic != FLI_FRAME_MAGIC_NUMBER) return false; uint16_t chunks = flic__read16(flic->file); for (int32_t i = 0; i < 8; ++i) // Padding flic__read8(flic->file); for (int32_t i = 0; i < chunks; ++i) flic__readChunk(flic, frame); flic__seek(flic->file, frameStartPos + frameSize); flic->currentFrame++; return true; } void flicMakeImage(Flic* flic, FlicFrame* frame, uint8_t* image) { for (int32_t k = 0; k < flic->width * flic->height; k++) { if (frame->pixels[k] & FLI_PXL_CHANGE) { uint8_t index = frame->pixels[k] & FLI_PXL_INDEX; image[k * 3 + 0] = frame->colors[index * 3 + 0]; image[k * 3 + 1] = frame->colors[index * 3 + 1]; image[k * 3 + 2] = frame->colors[index * 3 + 2]; } } } #endif // SHL_FLIC_IMPLEMENTATION #endif // SHL_FLIC_H ================================================ FILE: deps/include/shl/list.h ================================================ /* list.h - acoto87 (acoto87@gmail.com) MIT License Copyright (c) 2018 Alejandro Coto Gutiérrez 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. Single-header macro library to declare and define strongly typed dynamic lists with indexed access plus search, sort, and range operations. USAGE Include this header in one or more C translation units, then use shlDeclareList(name, type) in a header and shlDefineList(name, type) in a single C file. CUSTOMISATION Provide a default value for out-of-range reads, an equality function for search-related helpers, and a free function when the item type owns resources. The generated list stores values by copy. NOTES The implementation is header-only and uses dynamic allocation internally. Call Free when finished with a list instance, and prefer AddRange or InsertRange for bulk operations. */ #ifndef SHL_LIST_H #define SHL_LIST_H #include "shl_internal.h" #define shlDeclareList(typeName, itemType) \ typedef struct \ { \ itemType defaultValue; \ bool (*equalsFn)(const itemType item1, const itemType item2); \ void (*freeFn)(itemType item); \ } typeName ## Options; \ \ typedef struct \ { \ int32_t count; \ int32_t capacity; \ bool (*equalsFn)(const itemType item1, const itemType item2); \ void (*freeFn)(itemType item); \ itemType defaultValue; \ itemType* items; \ } typeName; \ \ void typeName ## Init(typeName* list, typeName ## Options options); \ void typeName ## Free(typeName* list); \ void typeName ## Add(typeName* list, itemType value); \ void typeName ## AddRange(typeName* list, int32_t count, itemType value[]); \ void typeName ## Insert(typeName* list, int32_t index, itemType value); \ void typeName ## InsertRange(typeName* list, int32_t index, int32_t count, itemType values[]); \ int32_t typeName ## IndexOf(typeName* list, itemType value); \ itemType typeName ## Get(typeName* list, int32_t index); \ void typeName ## Set(typeName* list, int32_t index, itemType value); \ bool typeName ## Contains(typeName* list, itemType value); \ void typeName ## Remove(typeName* list, itemType value); \ void typeName ## RemoveAt(typeName* list, int32_t index); \ void typeName ## RemoveAtRange(typeName* list, int32_t index, int32_t count); \ void typeName ## Clear(typeName* list); \ void typeName ## Reverse(typeName* list); \ void typeName ## Sort(typeName* list, int32_t (*compareFn)(const itemType item1, const itemType item2, void* userdata), void* userdata); \ void typeName ## CopyTo(typeName* list, itemType array[], int32_t index); \ itemType* typeName ## ToArray(typeName* list); \ #define shlDefineList(typeName, itemType) \ void typeName ## __qsort(typeName* list, int32_t left, int32_t right, int32_t (*compareFn)(const itemType item1, const itemType item2, void* userdata), void* userdata) \ { \ if (left >= right) \ return; \ \ int32_t middle = left + ((right - left) >> 1); \ itemType p = list->items[middle]; \ \ int32_t i = left - 1; \ int32_t j = right + 1; \ \ while (i < j) \ { \ do { i++; } while (compareFn(list->items[i], p, userdata) < 0); \ do { j--; } while (compareFn(list->items[j], p, userdata) > 0); \ \ if (i >= j) \ break; \ \ itemType tmp = list->items[i]; \ list->items[i] = list->items[j]; \ list->items[j] = tmp; \ } \ \ typeName ## __qsort(list, left, j, compareFn, userdata); \ typeName ## __qsort(list, j + 1, right, compareFn, userdata); \ } \ \ void typeName ## Init(typeName* list, typeName ## Options options) \ { \ list->defaultValue = options.defaultValue; \ list->equalsFn = options.equalsFn; \ list->freeFn = options.freeFn; \ list->capacity = SHL__INITIAL_CAPACITY; \ list->count = 0; \ list->items = (itemType *)SHL_MALLOC((size_t)list->capacity * sizeof(itemType)); \ } \ \ void typeName ## Free(typeName* list) \ { \ if (!list->items) \ return; \ \ typeName ## Clear(list); \ \ SHL_FREE(list->items); \ list->items = 0; \ } \ \ void typeName ## InsertRange(typeName* list, int32_t index, int32_t count, itemType values[]) \ { \ if (!list->items) \ return; \ \ if (index < 0 || index > list->count) \ return; \ \ if (list->count + count >= list->capacity) \ shl__resizeArray((void**)&list->items, &list->capacity, list->count + count, sizeof(itemType)); \ \ memmove(list->items + index + count, list->items + index, (list->count - index) * sizeof(itemType)); \ memcpy(list->items + index, values, count * sizeof(itemType)); \ list->count += count; \ } \ \ void typeName ## Insert(typeName* list, int32_t index, itemType value) \ { \ typeName ## InsertRange(list, index, 1, &value); \ } \ \ void typeName ## Add(typeName* list, itemType value) \ { \ typeName ## Insert(list, list->count, value); \ } \ \ void typeName ## AddRange(typeName* list, int32_t count, itemType values[]) \ { \ typeName ## InsertRange(list, list->count, count, values); \ } \ \ int32_t typeName ## IndexOf(typeName* list, itemType value) \ { \ if (!list->items) \ return -1; \ \ if (!list->equalsFn) \ return -1; \ \ for(int32_t i = 0; i < list->count; i++) \ { \ if (list->equalsFn(list->items[i], value)) \ return i; \ } \ \ return -1; \ } \ \ bool typeName ## Contains(typeName* list, itemType value) \ { \ return typeName ## IndexOf(list, value) >= 0; \ } \ \ itemType typeName ## Get(typeName* list, int32_t index) \ { \ if (!list->items) \ return list->defaultValue; \ \ if (index < 0 || index >= list->count) \ return list->defaultValue; \ \ return list->items[index]; \ } \ \ void typeName ## Set(typeName *list, int32_t index, itemType value) \ { \ if (!list->items) \ return; \ \ if (index < 0 || index >= list->count) \ return; \ \ itemType currentValue = list->items[index]; \ if (list->freeFn) \ list->freeFn(currentValue); \ \ list->items[index] = value; \ } \ \ void typeName ## RemoveAtRange(typeName *list, int32_t index, int32_t count) \ { \ if (!list->items) \ return; \ \ if (index < 0 || index >= list->count) \ return; \ \ if (index + count > list->count) \ return; \ \ if (list->freeFn) \ { \ for(int32_t i = 0; i < count; i++) \ list->freeFn(list->items[index + i]); \ } \ \ memmove(list->items + index, list->items + index + count, (list->count - index - count) * sizeof(itemType)); \ list->count -= count; \ } \ \ void typeName ## RemoveAt(typeName *list, int32_t index) \ { \ typeName ## RemoveAtRange(list, index, 1); \ } \ \ void typeName ## Remove(typeName *list, itemType value) \ { \ int32_t index = typeName ## IndexOf(list, value); \ if (index >= 0) \ typeName ## RemoveAt(list, index); \ } \ \ void typeName ## Clear(typeName* list) \ { \ if (!list->items) \ return; \ \ if (list->freeFn) \ { \ for(int32_t i = 0; i < list->count; i++) \ list->freeFn(list->items[i]); \ } \ \ list->count = 0; \ } \ \ void typeName ## Reverse(typeName *list) \ { \ if (!list->items) \ return; \ \ int32_t count = list->count; \ for(int32_t i = 0; i < count / 2; i++) \ { \ itemType tmp = list->items[i]; \ list->items[i] = list->items[count - i - 1]; \ list->items[count - i - 1] = tmp; \ } \ } \ void typeName ## Sort(typeName* list, int32_t (*compareFn)(const itemType item1, const itemType item2, void* userdata), void* userdata) \ { \ typeName ## __qsort(list, 0, list->count - 1, compareFn, userdata); \ } \ \ void typeName ## CopyTo(typeName* list, itemType array[], int32_t index) \ { \ if (!list->items) \ return; \ \ if (index >= 0) \ memcpy(array + index, list->items, list->count * sizeof(itemType)); \ } \ \ itemType* typeName ## ToArray(typeName* list) \ { \ if (!list->items) \ return 0; \ \ itemType* array = (itemType*)malloc(list->count * sizeof(itemType)); \ memcpy(array, list->items, list->count * sizeof(itemType)); \ return array; \ } #endif // SHL_LIST_H ================================================ FILE: deps/include/shl/map.h ================================================ /* map.h - acoto87 (acoto87@gmail.com) MIT License Copyright (c) 2018 Alejandro Coto Gutiérrez 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. Single-header macro library to declare and define strongly typed hash maps. Callers provide hash and equality hooks for the generated key type. USAGE Declare a concrete map type with shlDeclareMap(name, keyType, valueType), then place shlDefineMap(name, keyType, valueType) in exactly one C file. CUSTOMISATION Supply a hash function and equality function for the key type, plus a default value for failed lookups and an optional free function for owned values. Keys and values are stored by copy. NOTES This map uses open addressing with linked collision chains stored inside the entry array. Call Free to release internal storage. Remove and Clear invoke the value free hook when one is configured. This implementation of the macro is a variant of: https://github.com/mystborn/GenericMap to make a closed implementation of the map data structure, where each collision is resolved by keeping the index of the next element in the array of cells, and not by merely iterate until we find an empty cell. A detailed explanation of the hash function can be found here: https://probablydance.com/2018/06/16/fibonacci-hashing-the-optimization-that-the-world-forgot-or-a-better-alternative-to-integer-modulo/ The specific constant was found here: http://book.huihoo.com/data-structures-and-algorithms-with-object-oriented-design-patterns-in-c++/html/page214.html */ #ifndef SHL_MAP_H #define SHL_MAP_H #include "shl_internal.h" #define shlDeclareMap(typeName, keyType, valueType) \ typedef struct \ { \ valueType defaultValue; \ uint32_t (*hashFn)(keyType key); \ bool (*equalsFn)(keyType item1, keyType item2); \ void (*freeFn)(valueType item); \ } typeName ## Options; \ \ typedef struct { \ bool active; \ uint32_t hash; \ int32_t next; \ keyType key; \ valueType value; \ } typeName ## __Entry__; \ \ typedef struct { \ int32_t count; \ int32_t capacity; \ int32_t loadFactor; \ int32_t shift; \ uint32_t (*hashFn)(keyType key); \ bool (*equalsFn)(keyType item1, keyType item2); \ void (*freeFn)(valueType item); \ valueType defaultValue; \ typeName ## __Entry__* entries; \ } typeName; \ \ void typeName ## Init(typeName* map, typeName ## Options options); \ void typeName ## Free(typeName* map); \ bool typeName ## Contains(typeName* map, keyType key); \ valueType typeName ## Get(typeName* map, keyType key); \ void typeName ## Set(typeName* map, keyType key, valueType value); \ void typeName ## Remove(typeName* map, keyType key); \ void typeName ## Clear(typeName* map); #define shlDefineMap(typeName, keyType, valueType) \ static void typeName ## __resize(typeName* map); \ \ static void typeName ## __insert(typeName* map, keyType key, valueType value) \ { \ uint32_t hash; \ int32_t index; \ int32_t next; \ hash = index = shl__fibHash(map->hashFn(key), map->shift); \ \ while (map->entries[index].active && map->entries[index].next >= 0) \ { \ if(map->entries[index].hash == hash && map->equalsFn(map->entries[index].key, key)) \ { \ valueType currentValue = map->entries[index].value; \ map->entries[index].value = value; \ \ if (map->freeFn) \ map->freeFn(currentValue); \ \ return; \ } \ \ index = map->entries[index].next; \ } \ \ if (map->entries[index].active) \ { \ if(map->entries[index].hash == hash && map->equalsFn(map->entries[index].key, key)) \ { \ valueType currentValue = map->entries[index].value; \ map->entries[index].value = value; \ \ if (map->freeFn) \ map->freeFn(currentValue); \ \ return; \ } \ } \ \ next = shl__findEmptyBucket(map->entries, map->capacity, index, sizeof(typeName ## __Entry__), offsetof(typeName ## __Entry__, active)); \ if (next < 0) \ { \ typeName ## __resize(map); \ typeName ## __insert(map, key, value); \ return; \ } \ if (index != next) \ map->entries[index].next = next; \ \ map->entries[next].active = true; \ map->entries[next].key = key; \ map->entries[next].value = value; \ map->entries[next].hash = hash; \ map->entries[next].next = -1; \ map->count++; \ } \ \ static void typeName ## __resize(typeName* map) \ { \ int32_t oldCapacity = map->capacity; \ typeName ## __Entry__* old = map->entries; \ \ map->loadFactor = oldCapacity; \ map->capacity = 1 << (32 - (--map->shift)); \ map->entries = (typeName ## __Entry__*)calloc(map->capacity, sizeof(typeName ## __Entry__)); \ map->count = 0; \ \ for(int32_t i = 0; i < oldCapacity; i++) \ { \ if(old[i].active) \ typeName ## __insert(map, old[i].key, old[i].value); \ } \ SHL_FREE(old); \ } \ \ void typeName ## Init(typeName* map, typeName ## Options options) \ { \ map->defaultValue = options.defaultValue; \ map->hashFn = options.hashFn; \ map->equalsFn = options.equalsFn; \ map->freeFn = options.freeFn; \ map->shift = SHL__INITIAL_HASH_SHIFT; \ map->capacity = SHL__INITIAL_CAPACITY; \ map->loadFactor = SHL__INITIAL_HASH_LOAD_FACTOR; \ map->count = 0; \ map->entries = (typeName ## __Entry__ *)SHL_CALLOC((size_t)map->capacity, sizeof(typeName ## __Entry__)); \ } \ \ void typeName ## Free(typeName* map) \ { \ if (!map->entries) \ return; \ \ typeName ## Clear(map); \ \ SHL_FREE(map->entries); \ map->entries = 0; \ } \ \ bool typeName ## Contains(typeName* map, keyType key) \ { \ if (!map->entries) \ return false; \ \ int32_t index; \ uint32_t hash; \ hash = index = shl__fibHash(map->hashFn(key), map->shift); \ \ bool found = false; \ \ while (map->entries[index].active) \ { \ if(map->entries[index].hash == hash && map->equalsFn(map->entries[index].key, key)) \ { \ found = true; \ break; \ } \ \ if (map->entries[index].next < 0) \ { \ break; \ } \ \ index = map->entries[index].next; \ } \ \ return found; \ } \ \ valueType typeName ## Get(typeName* map, keyType key) \ { \ if (!map->entries) \ return map->defaultValue; \ \ int32_t index; \ uint32_t hash; \ hash = index = shl__fibHash(map->hashFn(key), map->shift); \ \ valueType value = map->defaultValue; \ \ while (map->entries[index].active) \ { \ if(map->entries[index].hash == hash && map->equalsFn(map->entries[index].key, key)) \ { \ value = map->entries[index].value; \ break; \ } \ \ if (map->entries[index].next < 0) \ { \ break; \ } \ \ index = map->entries[index].next; \ } \ \ return value; \ } \ \ void typeName ## Set(typeName* map, keyType key, valueType value) \ { \ if (!map->entries) \ return; \ \ if(map->count == map->loadFactor) \ typeName ## __resize(map); \ \ typeName ## __insert(map, key, value); \ } \ \ void typeName ## Remove(typeName* map, keyType key) \ { \ if (!map->entries) \ return; \ \ int32_t prevIndex, index; \ uint32_t hash; \ hash = prevIndex = index = shl__fibHash(map->hashFn(key), map->shift); \ \ while (map->entries[index].active) \ { \ if(map->entries[index].hash == hash && map->equalsFn(map->entries[index].key, key)) \ { \ valueType value = map->entries[index].value; \ int32_t nextIndex = map->entries[index].next; \ if (nextIndex >= 0) \ { \ map->entries[index] = map->entries[nextIndex]; \ map->entries[nextIndex].value = map->defaultValue; \ map->entries[nextIndex].next = -1; \ map->entries[nextIndex].active = false; \ } \ else \ { \ if (prevIndex != index) \ map->entries[prevIndex].next = -1; \ map->entries[index].value = map->defaultValue; \ map->entries[index].next = -1; \ map->entries[index].active = false; \ } \ \ if (map->freeFn) \ map->freeFn(value); \ \ map->count--; \ \ break; \ } \ \ if (map->entries[index].next < 0) \ { \ break; \ } \ \ prevIndex = index; \ index = map->entries[index].next; \ } \ } \ \ void typeName ## Clear(typeName* map) \ { \ if (!map->entries) \ return; \ \ for(int32_t i = 0; i < map->capacity; i++) \ { \ if (map->entries[i].active) \ { \ if (map->freeFn) \ map->freeFn(map->entries[i].value); \ \ map->entries[i].value = map->defaultValue; \ map->entries[i].next = -1; \ map->entries[i].active = false; \ } \ } \ \ map->count = 0; \ } #endif //SHL_MAP_H ================================================ FILE: deps/include/shl/memory_buffer.h ================================================ /* memory_buffer.h - acoto87 (acoto87@gmail.com) MIT License Copyright (c) 2018 Alejandro Coto Gutiérrez 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. Single-header in-memory byte buffer with sequential reads, random access seeking, automatic growth on writes, and endian-aware integer helpers. USAGE Include this header in all translation units that need the declarations. Define SHL_MEMORY_BUFFER_IMPLEMENTATION in exactly one translation unit before the include to compile the implementation: #define SHL_MEMORY_BUFFER_IMPLEMENTATION #include "memory_buffer.h" Include the header without that define everywhere else: #include "memory_buffer.h" CUSTOMISATION The implementation is self-contained and uses the standard C allocator directly. If you need different allocation behavior, adjust the implementation section itself. NOTES The buffer tracks a current read/write cursor, can grow automatically when seeking or writing past the current end, and provides helpers for endian- aware primitive reads and writes. */ #ifndef SHL_MEMORY_BUFFER_H #define SHL_MEMORY_BUFFER_H #include #include #include #include #include #ifdef __cplusplus extern "C" { #endif typedef struct _memory_buffer_t memory_buffer_t; #define mb_end(buffer) ((buffer)->data + (buffer)->length) #define mb_position(buffer) ((buffer)->_pointer - (buffer)->data) void mb_initEmpty(memory_buffer_t* buffer); void mb_initFromMemory(memory_buffer_t* buffer, uint8_t* data, size_t length); void mb_free(memory_buffer_t* buffer); uint8_t* mb_data(memory_buffer_t* buffer, size_t* length); bool mb_seek(memory_buffer_t* buffer, uint32_t position); bool mb_skip(memory_buffer_t* buffer, int32_t distance); bool mb_scanTo(memory_buffer_t* buffer, const void* data, size_t length); bool mb_read(memory_buffer_t* buffer, uint8_t* value); bool mb_readBytes(memory_buffer_t* buffer, uint8_t* value, size_t count); bool mb_readString(memory_buffer_t* buffer, char* str, size_t count); bool mb_readInt16LE(memory_buffer_t* buffer, int16_t* value); bool mb_readInt16BE(memory_buffer_t* buffer, int16_t* value); bool mb_readUInt16LE(memory_buffer_t* buffer, uint16_t* value); bool mb_readUInt16BE(memory_buffer_t* buffer, uint16_t* value); bool mb_readInt24LE(memory_buffer_t* buffer, int32_t* value); bool mb_readInt24BE(memory_buffer_t* buffer, int32_t* value); bool mb_readUInt24LE(memory_buffer_t* buffer, uint32_t* value); bool mb_readUInt24BE(memory_buffer_t* buffer, uint32_t* value); bool mb_readInt32LE(memory_buffer_t* buffer, int32_t* value); bool mb_readInt32BE(memory_buffer_t* buffer, int32_t* value); bool mb_readUInt32LE(memory_buffer_t* buffer, uint32_t* value); bool mb_readUInt32BE(memory_buffer_t* buffer, uint32_t* value); bool mb_write(memory_buffer_t* buffer, uint8_t value); bool mb_writeBytes(memory_buffer_t* buffer, uint8_t values[], size_t count); bool mb_writeString(memory_buffer_t* buffer, const char* str, size_t count); bool mb_writeInt16LE(memory_buffer_t* buffer, int16_t value); bool mb_writeInt16BE(memory_buffer_t* buffer, int16_t value); bool mb_writeUInt16LE(memory_buffer_t* buffer, uint16_t value); bool mb_writeUInt16BE(memory_buffer_t* buffer, uint16_t value); bool mb_writeInt24LE(memory_buffer_t* buffer, int32_t value); bool mb_writeInt24BE(memory_buffer_t* buffer, int32_t value); bool mb_writeUInt24LE(memory_buffer_t* buffer, uint32_t value); bool mb_writeUInt24BE(memory_buffer_t* buffer, uint32_t value); bool mb_writeInt32LE(memory_buffer_t* buffer, int32_t value); bool mb_writeInt32BE(memory_buffer_t* buffer, int32_t value); bool mb_writeUInt32LE(memory_buffer_t* buffer, uint32_t value); bool mb_writeUInt32BE(memory_buffer_t* buffer, uint32_t value); bool mb_isEOF(memory_buffer_t* buffer); #ifdef __cplusplus } #endif #ifdef SHL_MEMORY_BUFFER_IMPLEMENTATION struct _memory_buffer_t { uint8_t* data; size_t length; uint8_t* _pointer; }; static bool mb__realloc(memory_buffer_t* buffer, size_t newLength) { if(newLength <= buffer->length) { buffer->length = newLength; return true; } uint8_t* oldData = buffer->data; uint8_t* newData = (uint8_t*)calloc(newLength, sizeof(uint8_t)); if (!newData) { return false; } size_t count = newLength > buffer->length ? buffer->length : newLength; memcpy(newData, buffer->data, count); buffer->_pointer = newData + mb_position(buffer); buffer->data = newData; buffer->length = newLength; free(oldData); return true; } void mb_initEmpty(memory_buffer_t* buffer) { buffer->data = (uint8_t*)calloc(0, sizeof(uint8_t)); buffer->length = 0; buffer->_pointer = buffer->data; } void mb_initFromMemory(memory_buffer_t* buffer, uint8_t* data, size_t length) { buffer->data = data; buffer->length = length; buffer->_pointer = buffer->data; } void mb_free(memory_buffer_t* buffer) { if (buffer->data) free((void*)buffer->data); buffer->data = NULL; buffer->length = 0; buffer->_pointer = NULL; } uint8_t* mb_data(memory_buffer_t* buffer, size_t* length) { uint8_t* data = (uint8_t*)malloc(buffer->length); memcpy(data, buffer->data, buffer->length); *length = buffer->length; return data; } bool mb_seek(memory_buffer_t* buffer, uint32_t position) { if (buffer->data + position > mb_end(buffer)) { if (!mb__realloc(buffer, position)) return false; } buffer->_pointer = buffer->data + position; return true; } bool mb_skip(memory_buffer_t* buffer, int32_t distance) { if (distance < 0) { if (buffer->_pointer + distance < buffer->data) return false; } int64_t position = mb_position(buffer) + distance; if (position < 0 || position > UINT32_MAX) return false; return mb_seek(buffer, (uint32_t)position); } bool mb_scanTo(memory_buffer_t* buffer, const void* data, size_t length) { while (buffer->_pointer + length <= mb_end(buffer)) { // printf("%s\n", buffer->_pointer); if(memcmp(buffer->_pointer, data, length) == 0) return true; buffer->_pointer++; } return false; } bool mb_read(memory_buffer_t* buffer, uint8_t* value) { return mb_readBytes(buffer, value, 1); } bool mb_readBytes(memory_buffer_t* buffer, uint8_t* values, size_t count) { if (buffer->_pointer + count > mb_end(buffer)) return false; memcpy(values, buffer->_pointer, count); buffer->_pointer += count; return true; } bool mb_readString(memory_buffer_t* buffer, char* str, size_t count) { return mb_readBytes(buffer, (uint8_t*)str, count); } bool mb_readInt16LE(memory_buffer_t* buffer, int16_t* value) { uint8_t byte0, byte1; if(mb_read(buffer, &byte0) && mb_read(buffer, &byte1)) { *value = (byte1 << 8) | byte0; return true; } return false; } bool mb_readInt16BE(memory_buffer_t* buffer, int16_t* value) { uint8_t byte0, byte1; if(mb_read(buffer, &byte0) && mb_read(buffer, &byte1)) { *value = (byte0 << 8) | byte1; return true; } return false; } bool mb_readUInt16LE(memory_buffer_t* buffer, uint16_t* value) { uint8_t byte0, byte1; if(mb_read(buffer, &byte0) && mb_read(buffer, &byte1)) { *value = (byte1 << 8) | byte0; return true; } return false; } bool mb_readUInt16BE(memory_buffer_t* buffer, uint16_t* value) { uint8_t byte0, byte1; if(mb_read(buffer, &byte0) && mb_read(buffer, &byte1)) { *value = (byte0 << 8) | byte1; return true; } return false; } bool mb_readInt24LE(memory_buffer_t* buffer, int32_t* value) { uint8_t byte0, byte1, byte2; if(mb_read(buffer, &byte0) && mb_read(buffer, &byte1) && mb_read(buffer, &byte2)) { *value = (byte2 << 16) | (byte1 << 8) | byte0; return true; } return false; } bool mb_readInt24BE(memory_buffer_t* buffer, int32_t* value) { uint8_t byte0, byte1, byte2; if(mb_read(buffer, &byte0) && mb_read(buffer, &byte1) && mb_read(buffer, &byte2)) { *value = (byte0 << 16) | (byte1 << 8) | byte2; return true; } return false; } bool mb_readUInt24LE(memory_buffer_t* buffer, uint32_t* value) { uint8_t byte0, byte1, byte2; if(mb_read(buffer, &byte0) && mb_read(buffer, &byte1) && mb_read(buffer, &byte2)) { *value = (byte2 << 16) | (byte1 << 8) | byte0; return true; } return false; } bool mb_readUInt24BE(memory_buffer_t* buffer, uint32_t* value) { uint8_t byte0, byte1, byte2; if(mb_read(buffer, &byte0) && mb_read(buffer, &byte1) && mb_read(buffer, &byte2)) { *value = (byte0 << 16) | (byte1 << 8) | byte2; return true; } return false; } bool mb_readInt32LE(memory_buffer_t* buffer, int32_t* value) { uint8_t byte0, byte1, byte2, byte3; if(mb_read(buffer, &byte0) && mb_read(buffer, &byte1) && mb_read(buffer, &byte2) && mb_read(buffer, &byte3)) { *value = (byte3 << 24) | (byte2 << 16) | (byte1 << 8) | byte0; return true; } return false; } bool mb_readInt32BE(memory_buffer_t* buffer, int32_t* value) { uint8_t byte0, byte1, byte2, byte3; if(mb_read(buffer, &byte0) && mb_read(buffer, &byte1) && mb_read(buffer, &byte2) && mb_read(buffer, &byte3)) { *value = (byte0 << 24) | (byte1 << 16) | (byte2 << 8) | byte3; return true; } return false; } bool mb_readUInt32LE(memory_buffer_t* buffer, uint32_t* value) { uint8_t byte0, byte1, byte2, byte3; if(mb_read(buffer, &byte0) && mb_read(buffer, &byte1) && mb_read(buffer, &byte2) && mb_read(buffer, &byte3)) { *value = (byte3 << 24) | (byte2 << 16) | (byte1 << 8) | byte0; return true; } return false; } bool mb_readUInt32BE(memory_buffer_t* buffer, uint32_t* value) { uint8_t byte0, byte1, byte2, byte3; if(mb_read(buffer, &byte0) && mb_read(buffer, &byte1) && mb_read(buffer, &byte2) && mb_read(buffer, &byte3)) { *value = (byte0 << 24) | (byte1 << 16) | (byte2 << 8) | byte3; return true; } return false; } bool mb_write(memory_buffer_t* buffer, uint8_t value) { return mb_writeBytes(buffer, &value, 1); } bool mb_writeBytes(memory_buffer_t* buffer, uint8_t values[], size_t count) { if (buffer->_pointer + count >= mb_end(buffer)) { if (!mb__realloc(buffer, mb_position(buffer) + count)) return false; } memcpy(buffer->_pointer, values, count); buffer->_pointer += count; return true; } bool mb_writeString(memory_buffer_t* buffer, const char* str, size_t count) { return mb_writeBytes(buffer, (uint8_t*)str, count); } bool mb_writeInt16LE(memory_buffer_t* buffer, int16_t value) { return mb_writeBytes( buffer, (uint8_t[]) { (uint8_t)value, (uint8_t)(value >> 8) }, sizeof(int16_t)); } bool mb_writeInt16BE(memory_buffer_t* buffer, int16_t value) { return mb_writeBytes( buffer, (uint8_t[]) { (uint8_t)(value >> 8), (uint8_t)value }, sizeof(int16_t)); } bool mb_writeUInt16LE(memory_buffer_t* buffer, uint16_t value) { return mb_writeBytes( buffer, (uint8_t[]) { (uint8_t)value, (uint8_t)(value >> 8) }, sizeof(uint16_t)); } bool mb_writeUInt16BE(memory_buffer_t* buffer, uint16_t value) { return mb_writeBytes( buffer, (uint8_t[]) { (uint8_t)(value >> 8), (uint8_t)value }, sizeof(uint16_t)); } bool mb_writeInt24LE(memory_buffer_t* buffer, int32_t value) { return mb_writeBytes( buffer, (uint8_t[]) { (uint8_t)value, (uint8_t)(value >> 8), (uint8_t)(value >> 16) }, 3); } bool mb_writeInt24BE(memory_buffer_t* buffer, int32_t value) { return mb_writeBytes( buffer, (uint8_t[]) { (uint8_t)(value >> 16), (uint8_t)(value >> 8), (uint8_t)value }, 3); } bool mb_writeUInt24LE(memory_buffer_t* buffer, uint32_t value) { return mb_writeBytes( buffer, (uint8_t[]) { (uint8_t)value, (uint8_t)(value >> 8), (uint8_t)(value >> 16) }, 3); } bool mb_writeUInt24BE(memory_buffer_t* buffer, uint32_t value) { return mb_writeBytes( buffer, (uint8_t[]) { (uint8_t)(value >> 16), (uint8_t)(value >> 8), (uint8_t)value }, 3); } bool mb_writeInt32LE(memory_buffer_t* buffer, int32_t value) { return mb_writeBytes( buffer, (uint8_t[]) { (uint8_t)value, (uint8_t)(value >> 8), (uint8_t)(value >> 16), (uint8_t)(value >> 24) }, sizeof(int32_t)); } bool mb_writeInt32BE(memory_buffer_t* buffer, int32_t value) { return mb_writeBytes( buffer, (uint8_t[]) { (uint8_t)(value >> 24), (uint8_t)(value >> 16), (uint8_t)(value >> 8), (uint8_t)value }, sizeof(int32_t)); } bool mb_writeUInt32LE(memory_buffer_t* buffer, uint32_t value) { return mb_writeBytes( buffer, (uint8_t[]) { (uint8_t)value, (uint8_t)(value >> 8), (uint8_t)(value >> 16), (uint8_t)(value >> 24) }, sizeof(uint32_t)); } bool mb_writeUInt32BE(memory_buffer_t* buffer, uint32_t value) { return mb_writeBytes( buffer, (uint8_t[]) { (uint8_t)(value >> 24), (uint8_t)(value >> 16), (uint8_t)(value >> 8), (uint8_t)value }, sizeof(uint32_t)); } bool mb_isEOF(memory_buffer_t* buffer) { return buffer->_pointer == mb_end(buffer); } #endif // SHL_MEMORY_BUFFER_IMPLEMENTATION #endif // SHL_MEMORY_BUFFER_H ================================================ FILE: deps/include/shl/memzone.h ================================================ /* memzone.h - acoto87 (acoto87@gmail.com) MIT License Copyright (c) 2018 Alejandro Coto Gutiérrez 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. Single-header memory zone allocator with stable pointers, optional aligned allocations, structural validation helpers, and configurable diagnostics. USAGE Include this header in all translation units that need the declarations. Define SHL_MZ_IMPLEMENTATION in exactly one translation unit before the include to compile the implementation: #define SHL_MZ_IMPLEMENTATION #include "memzone.h" Include the header without that define everywhere else: #include "memzone.h" CUSTOMISATION Override SHL_MZ_MALLOC and SHL_MZ_FREE before the implementation include if you need custom allocation. Optional hooks include SHL_MZ_ASSERT, SHL_MZ_DEBUG, and SHL_MZ_PRIVATE_API for diagnostics and internal-structure exposure. AUDIT For per-zone audit logging (every alloc/free written to a structured text file), include the companion header memzone_audit.h in your implementation translation unit alongside this file. See memzone_audit.h for details. NOTES The allocator returns stable pointers until the zone is reset or destroyed. Use mz_setReporter to install custom diagnostics, mz_validate to sanity- check the zone, and mz_free only with pointers that came from the zone. See memzone.md file for more information about memory layout for each allocation/deallocation. */ #ifndef SHL_MZ_H #define SHL_MZ_H #ifdef __cplusplus extern "C" { #endif typedef struct memzone_s memzone_t; typedef enum { MZ_REPORT_ALLOCATION_FAILURE, MZ_REPORT_INVALID_FREE, MZ_REPORT_VALIDATION_FAILURE } mz_report_t; typedef void (*mz_reporter_t)(const memzone_t* zone, mz_report_t report, const void* context, const char* message, void* userData); #if defined(SHL_MZ_PRIVATE_API) typedef struct memblock_s { size_t size; // size of the block void* user; // a pointer to the pointer returned to the user struct memblock_s *next, *prev; // pointers to next and prev in the block list } memblock_t; struct memzone_s { size_t usedSize; // how much space is used without including blocks data size_t maxSize; // the max allowed size that can be allocated memblock_t* rover; // a pointer to a free block that is used when allocating mz_reporter_t reporter; // optional runtime diagnostics hook, defaults to stderr void* reporterUserData; // user data passed to the diagnostics hook memblock_t blockList; // list of blocks, here is where the requested memory begins }; #endif size_t mz_alignment(void); size_t mz_maxSize(const memzone_t* zone); size_t mz_usedSize(const memzone_t* zone); memzone_t* mz_init(size_t maxSize); void mz_destroy(memzone_t* zone); void mz_reset(memzone_t* zone); void* mz_alloc(memzone_t* zone, size_t size); void* mz_allocAligned(memzone_t* zone, size_t size, size_t alignment); void mz_setReporter(memzone_t* zone, mz_reporter_t reporter, void* userData); void mz_free(memzone_t* zone, void* p); void* mz_realloc(memzone_t* zone, void* p, size_t size); bool mz_contains(const memzone_t* zone, const void* p); size_t mz_allocationSize(const memzone_t* zone, const void* p); bool mz_validate(const memzone_t* zone); int32_t mz_blockCount(const memzone_t* zone); size_t mz_usableFreeSize(const memzone_t* zone); float mz_fragmentation(const memzone_t* zone); #ifdef __cplusplus } #endif #ifdef SHL_MZ_IMPLEMENTATION #include #include #include #include #include #include #include #include #ifndef SHL_MZ_MALLOC #define SHL_MZ_MALLOC(sz) malloc(sz) #endif #ifndef SHL_MZ_FREE #define SHL_MZ_FREE(p) free(p) #endif #if defined(SHL_MZ_DEBUG) && !defined(SHL_MZ_ASSERT) #include #define SHL_MZ_ASSERT(expr) assert(expr) #endif #ifndef SHL_MZ_ASSERT #define SHL_MZ_ASSERT(expr) ((void)0) #endif #if !defined(SHL_MZ_PRIVATE_API) typedef struct memblock_s { size_t size; // size of the block void* user; // a pointer to the pointer returned to the user struct memblock_s *next, *prev; // pointers to next and prev in the block list } memblock_t; struct memzone_s { size_t usedSize; // how much space is used without including blocks data size_t maxSize; // the max allowed size that can be allocated memblock_t* rover; // a pointer to a free block that is used when allocating mz_reporter_t reporter; // optional runtime diagnostics hook, defaults to stderr void* reporterUserData; // user data passed to the diagnostics hook memblock_t blockList; // list of blocks, here is where the requested memory begins }; #endif #define MZ__POINTER_OFFSET(t, p, o) ((t*)((uint8_t*)(p) + (o))) #define MZ__ALIGNOF(type) alignof(type) #define MZ__MAX(a, b) ((a) > (b) ? (a) : (b)) #define MZ__DEFAULT_ALIGNMENT MZ__MAX(MZ__ALIGNOF(memblock_t), MZ__MAX(MZ__ALIGNOF(void*), MZ__ALIGNOF(size_t))) #define MZ__IS_BLOCK_EMPTY(block) ((block)->user == NULL) static bool mz__alignUp(size_t value, size_t alignment, size_t* alignedValue) { if (alignedValue == NULL) { return false; } if (alignment == 0) { *alignedValue = value; return true; } size_t remainder = value % alignment; if (remainder == 0) { *alignedValue = value; return true; } size_t padding = alignment - remainder; if (value > ((size_t)-1) - padding) { return false; } *alignedValue = value + padding; return true; } static bool mz__isPowerOfTwo(size_t value) { return value != 0 && (value & (value - 1)) == 0; } static bool mz__isSupportedAlignment(size_t alignment) { if (!mz__isPowerOfTwo(alignment) || alignment < mz_alignment()) { return false; } if ((alignment % mz_alignment()) != 0) { return false; } return alignment == mz_alignment() || alignment == 16 || alignment == 32 || alignment == 64; } static const char* mz__reportName(mz_report_t report) { switch (report) { case MZ_REPORT_ALLOCATION_FAILURE: return "allocation failure"; case MZ_REPORT_INVALID_FREE: return "invalid free"; case MZ_REPORT_VALIDATION_FAILURE: return "validation failure"; default: return "unknown report"; } } static void mz__stderrReporter(const memzone_t* zone, mz_report_t report, const void* context, const char* message, void* userData) { (void)userData; fprintf(stderr, "memzone %s", mz__reportName(report)); if (zone != NULL) { fprintf(stderr, " [zone=%p]", (const void*)zone); } if (context != NULL) { fprintf(stderr, " [context=%p]", context); } if (message != NULL && message[0] != '\0') { fprintf(stderr, ": %s", message); } fputc('\n', stderr); } static void mz__report(const memzone_t* zone, mz_report_t report, const void* context, const char* message) { if (zone == NULL || zone->reporter == NULL) { return; } zone->reporter(zone, report, context, message, zone->reporterUserData); } static bool mz__validationFailure(const memzone_t* zone, const void* context, const char* message) { mz__report(zone, MZ_REPORT_VALIDATION_FAILURE, context, message); return false; } static void mz__debugAssertValid(const memzone_t* zone) { #if defined(SHL_MZ_DEBUG) SHL_MZ_ASSERT(mz_validate(zone)); #else (void)zone; #endif } static size_t mz__headerSize(void) { size_t headerSize = sizeof(memblock_t); size_t alignedHeaderSize = headerSize; (void)mz__alignUp(headerSize, mz_alignment(), &alignedHeaderSize); return alignedHeaderSize; } static size_t mz__zoneBaseSize(void) { return offsetof(memzone_t, blockList) + mz__headerSize(); } static size_t mz__payloadSize(const memblock_t* block) { return block->size - mz__headerSize(); } static void* mz__payloadPointer(memblock_t* block) { return MZ__POINTER_OFFSET(void, block, mz__headerSize()); } static size_t mz__allocationSize(const memblock_t* block) { if (block == NULL || block->user == NULL) { return 0; } return (size_t)(((const uint8_t*)block + block->size) - (const uint8_t*)block->user); } static bool mz__isNextBlockAdjacent(const memblock_t* block) { return MZ__POINTER_OFFSET(const uint8_t, block, block->size) == (const uint8_t*)block->next; } static bool mz__isPrevBlockAdjacent(const memblock_t* block) { return MZ__POINTER_OFFSET(const uint8_t, block->prev, block->prev->size) == (const uint8_t*)block; } static const memblock_t* mz__findBlock(const memzone_t* zone, const void* p) { if (zone == NULL || p == NULL) { return NULL; } const memblock_t* rover = &zone->blockList; do { if (rover->user == p) { return rover; } rover = rover->next; } while (rover != &zone->blockList); return NULL; } size_t mz_alignment(void) { return MZ__DEFAULT_ALIGNMENT; } size_t mz_maxSize(const memzone_t* zone) { return zone != NULL ? zone->maxSize : 0; } size_t mz_usedSize(const memzone_t* zone) { return zone != NULL ? zone->usedSize : 0; } memzone_t* mz_init(size_t maxSize) { if (maxSize < mz__zoneBaseSize()) { fprintf(stderr, "You need to allocate memory for at least %llu bytes.\n", (unsigned long long)mz__zoneBaseSize()); return NULL; } uint8_t* rawZone = (uint8_t*)SHL_MZ_MALLOC(maxSize); memzone_t* zone = (memzone_t*)rawZone; if (!zone) { fprintf(stderr, "The system couldn't allocate memory for %llu bytes.\n", (unsigned long long)maxSize); return NULL; } zone->usedSize = mz__zoneBaseSize(); zone->maxSize = maxSize; zone->reporter = mz__stderrReporter; zone->reporterUserData = NULL; zone->blockList = (memblock_t){0}; zone->blockList.size = maxSize - offsetof(memzone_t, blockList); zone->blockList.user = NULL; zone->blockList.next = &zone->blockList; zone->blockList.prev = &zone->blockList; zone->rover = &zone->blockList; mz__debugAssertValid(zone); return zone; } void mz_destroy(memzone_t* zone) { SHL_MZ_FREE(zone); } void mz_reset(memzone_t* zone) { if (zone == NULL) { return; } zone->usedSize = mz__zoneBaseSize(); zone->blockList = (memblock_t){0}; zone->blockList.size = zone->maxSize - offsetof(memzone_t, blockList); zone->blockList.user = NULL; zone->blockList.next = &zone->blockList; zone->blockList.prev = &zone->blockList; zone->rover = &zone->blockList; mz__debugAssertValid(zone); } void* mz_alloc(memzone_t* zone, size_t size) { return mz_allocAligned(zone, size, mz_alignment()); } void mz_setReporter(memzone_t* zone, mz_reporter_t reporter, void* userData) { if (zone == NULL) { return; } zone->reporter = reporter; zone->reporterUserData = userData; } void* mz_allocAligned(memzone_t* zone, size_t size, size_t alignment) { if (zone == NULL || size == 0) { return NULL; } if (!mz__isSupportedAlignment(alignment)) { char message[160]; snprintf(message, sizeof(message), "unsupported alignment %llu, expected %llu, 16, 32, or 64 bytes", (unsigned long long)alignment, (unsigned long long)mz_alignment()); mz__report(zone, MZ_REPORT_ALLOCATION_FAILURE, NULL, message); return NULL; } size_t alignedSize = 0; if (!mz__alignUp(size, mz_alignment(), &alignedSize)) { char message[160]; snprintf(message, sizeof(message), "requested allocation size %llu bytes is too large", (unsigned long long)size); mz__report(zone, MZ_REPORT_ALLOCATION_FAILURE, NULL, message); return NULL; } size_t headerSize = mz__headerSize(); if (alignedSize > zone->maxSize - zone->usedSize) { char message[160]; snprintf(message, sizeof(message), "not enough free memory to allocate %llu bytes", (unsigned long long)size); mz__report(zone, MZ_REPORT_ALLOCATION_FAILURE, NULL, message); return NULL; } memblock_t* start = zone->rover != NULL ? zone->rover : &zone->blockList; memblock_t* rover = start; size_t padding = 0; size_t sizeToAlloc = 0; bool found = false; do { if (MZ__IS_BLOCK_EMPTY(rover)) { uintptr_t payloadAddress = (uintptr_t)mz__payloadPointer(rover); size_t currentPadding = 0; size_t remainder = payloadAddress % alignment; if (remainder != 0) { currentPadding = alignment - remainder; } if (currentPadding <= mz__payloadSize(rover) && alignedSize <= mz__payloadSize(rover) - currentPadding) { size_t currentSizeToAlloc = headerSize + currentPadding; if (alignedSize <= ((size_t)-1) - currentSizeToAlloc) { currentSizeToAlloc += alignedSize; if (rover->size >= currentSizeToAlloc) { padding = currentPadding; sizeToAlloc = currentSizeToAlloc; found = true; break; } } } } rover = rover->next; } while (rover != start); if (!found) { char message[160]; snprintf(message, sizeof(message), "free memory exists for %llu bytes but no suitably aligned block is large enough", (unsigned long long)size); mz__report(zone, MZ_REPORT_ALLOCATION_FAILURE, NULL, message); return NULL; } size_t usedPayloadSize = mz__payloadSize(rover); size_t remainingSize = rover->size - sizeToAlloc; if (remainingSize >= headerSize + mz_alignment()) { // create a new empty block with the remaining free space memblock_t* newBlock = MZ__POINTER_OFFSET(memblock_t, rover, sizeToAlloc); newBlock->size = remainingSize; newBlock->user = NULL; newBlock->prev = rover; newBlock->next = rover->next; // set the next block to point to the new one rover->next->prev = newBlock; rover->next = newBlock; rover->size = sizeToAlloc; // update the zone rover with the new free block created zone->rover = newBlock; zone->usedSize += headerSize; usedPayloadSize = padding + alignedSize; } else { // rover->next may be allocated; advance to the next free block // (falls back to the sentinel if no free blocks remain) memblock_t* next = rover->next; while (next != &zone->blockList && !MZ__IS_BLOCK_EMPTY(next)) { next = next->next; } zone->rover = next; } zone->usedSize += usedPayloadSize; rover->user = MZ__POINTER_OFFSET(void, mz__payloadPointer(rover), padding); memset(rover->user, 0, alignedSize); mz__debugAssertValid(zone); return rover->user; } void mz_free(memzone_t* zone, void* p) { if (zone == NULL || p == NULL) { return; } memblock_t* rover = (memblock_t*)mz__findBlock(zone, p); if (rover == NULL) { mz__report(zone, MZ_REPORT_INVALID_FREE, p, "pointer does not reference a live allocation in this zone"); return; } rover->user = NULL; zone->rover = rover; zone->usedSize -= mz__payloadSize(rover); // merge with next block if empty if (rover->next != rover && MZ__IS_BLOCK_EMPTY(rover->next) && mz__isNextBlockAdjacent(rover)) { memblock_t* next = rover->next; rover->size += next->size; rover->next = next->next; rover->next->prev = rover; zone->usedSize -= mz__headerSize(); if (zone->rover == next) { zone->rover = rover; } } // merge with previous if empty if (rover->prev != rover && MZ__IS_BLOCK_EMPTY(rover->prev) && mz__isPrevBlockAdjacent(rover)) { memblock_t* prev = rover->prev; prev->size += rover->size; prev->next = rover->next; prev->next->prev = prev; zone->usedSize -= mz__headerSize(); zone->rover = prev; } mz__debugAssertValid(zone); } void* mz_realloc(memzone_t* zone, void* p, size_t size) { if (zone == NULL) { return NULL; } if (p == NULL) { return mz_alloc(zone, size); } if (size == 0) { mz_free(zone, p); return NULL; } memblock_t* block = (memblock_t*)mz__findBlock(zone, p); if (block == NULL) { mz__report(zone, MZ_REPORT_INVALID_FREE, p, "pointer does not reference a live allocation in this zone"); return NULL; } size_t alignedSize = 0; if (!mz__alignUp(size, mz_alignment(), &alignedSize)) { char message[160]; snprintf(message, sizeof(message), "requested reallocation size %llu bytes is too large", (unsigned long long)size); mz__report(zone, MZ_REPORT_ALLOCATION_FAILURE, NULL, message); return NULL; } size_t currentAllocSize = mz__allocationSize(block); size_t headerSize = mz__headerSize(); // Case 1: block already has sufficient capacity if (currentAllocSize >= alignedSize) { return p; } // Case 2: adjacent next block is empty and combined capacity is sufficient — merge in place memblock_t* next = block->next; if (next != block && MZ__IS_BLOCK_EMPTY(next) && mz__isNextBlockAdjacent(block)) { size_t extraNeeded = alignedSize - currentAllocSize; if (next->size >= extraNeeded) { size_t remainingSize = next->size - extraNeeded; if (remainingSize >= headerSize + mz_alignment()) { memblock_t* newBlock = MZ__POINTER_OFFSET(memblock_t, next, extraNeeded); /* Read next->next before writing any newBlock field: when extraNeeded is less than sizeof(memblock_t), newBlock overlaps with next's header and writes to newBlock->size/user would corrupt next->next before it is read. */ memblock_t* nextNext = next->next; newBlock->size = remainingSize; newBlock->user = NULL; newBlock->prev = block; newBlock->next = nextNext; nextNext->prev = newBlock; block->size += extraNeeded; block->next = newBlock; zone->usedSize += extraNeeded; zone->rover = newBlock; } else { size_t nextSize = next->size; block->size += nextSize; block->next = next->next; block->next->prev = block; zone->usedSize += nextSize - mz__headerSize(); if (zone->rover == next) { zone->rover = block->next; } } mz__debugAssertValid(zone); return p; } } // Case 3: allocate new block, copy data, free old block void* newP = mz_alloc(zone, size); if (newP == NULL) { return NULL; } memcpy(newP, p, currentAllocSize); mz_free(zone, p); return newP; } bool mz_contains(const memzone_t* zone, const void* p) { return mz__findBlock(zone, p) != NULL; } size_t mz_allocationSize(const memzone_t* zone, const void* p) { const memblock_t* block = mz__findBlock(zone, p); return mz__allocationSize(block); } bool mz_validate(const memzone_t* zone) { if (zone == NULL || zone->rover == NULL) { return mz__validationFailure(zone, zone != NULL ? (const void*)zone->rover : NULL, "zone or rover pointer is null"); } const uint8_t* zoneStart = (const uint8_t*)zone; const uint8_t* zoneEnd = zoneStart + zone->maxSize; const uint8_t* firstBlockStart = zoneStart + offsetof(memzone_t, blockList); const size_t headerSize = mz__headerSize(); const uint8_t* expectedBlockStart = firstBlockStart; if (zone->maxSize < mz__zoneBaseSize()) { return mz__validationFailure(zone, zone, "zone max size is smaller than allocator base size"); } if (zone->usedSize > zone->maxSize) { return mz__validationFailure(zone, zone, "used size exceeds zone size"); } size_t totalBlockSize = 0; size_t totalAllocatedPayload = 0; int32_t blockCount = 0; bool roverFound = false; const memblock_t* previousBlock = NULL; const memblock_t* rover = &zone->blockList; do { const uint8_t* blockStart = (const uint8_t*)rover; const uint8_t* blockEnd = blockStart + rover->size; if (blockStart != expectedBlockStart) { return mz__validationFailure(zone, rover, "there is a gap or overlap between consecutive blocks"); } if (blockStart < firstBlockStart || blockEnd > zoneEnd || rover->size < headerSize) { return mz__validationFailure(zone, rover, "block bounds are outside the zone or smaller than the header"); } if (rover->next == NULL || rover->prev == NULL) { return mz__validationFailure(zone, rover, "block links contain a null pointer"); } if (previousBlock != NULL && rover->prev != previousBlock) { return mz__validationFailure(zone, rover, "block links are not bidirectionally consistent"); } if (((uintptr_t)blockStart % mz_alignment()) != 0) { return mz__validationFailure(zone, rover, "block header is not aligned to the allocator alignment"); } if (rover->next != &zone->blockList) { if (blockEnd != (const uint8_t*)rover->next) { return mz__validationFailure(zone, rover, "there is a gap or overlap between consecutive blocks"); } if (MZ__IS_BLOCK_EMPTY(rover) && MZ__IS_BLOCK_EMPTY(rover->next)) { return mz__validationFailure(zone, rover, "two adjacent free blocks should have been coalesced"); } } if (!MZ__IS_BLOCK_EMPTY(rover)) { const uint8_t* payloadStart = (const uint8_t*)mz__payloadPointer((memblock_t*)rover); if ((const uint8_t*)rover->user < payloadStart || (const uint8_t*)rover->user >= blockEnd) { return mz__validationFailure(zone, rover, "user pointer is outside the owning block payload range"); } if (((uintptr_t)rover->user % mz_alignment()) != 0) { return mz__validationFailure(zone, rover, "user pointer is not aligned to the allocator alignment"); } totalAllocatedPayload += mz__payloadSize(rover); } if (rover == zone->rover) { roverFound = true; } previousBlock = rover; totalBlockSize += rover->size; blockCount++; expectedBlockStart = blockEnd; rover = rover->next; } while (rover != &zone->blockList); if (zone->blockList.prev != previousBlock) { return mz__validationFailure(zone, &zone->blockList, "block links are not bidirectionally consistent"); } if (!roverFound) { return mz__validationFailure(zone, zone->rover, "rover does not point at a block in the circular list"); } if (zone->rover != &zone->blockList && !MZ__IS_BLOCK_EMPTY(zone->rover)) { return mz__validationFailure(zone, zone->rover, "rover points to an allocated block"); } if (totalBlockSize != zone->maxSize - offsetof(memzone_t, blockList)) { return mz__validationFailure(zone, &zone->blockList, "total block size does not match the zone payload span"); } if (expectedBlockStart != zoneEnd) { return mz__validationFailure(zone, &zone->blockList, "the block list does not cover the full zone payload span"); } if (zone->usedSize != mz__zoneBaseSize() + totalAllocatedPayload + (size_t)(blockCount - 1) * headerSize) { return mz__validationFailure(zone, zone, "used size does not match allocated payload plus allocator metadata"); } return true; } int32_t mz_blockCount(const memzone_t* zone) { if (zone == NULL) { return 0; } int32_t numberOfBlocks = 0; const memblock_t* rover = &zone->blockList; do { numberOfBlocks++; rover = rover->next; } while (rover != &zone->blockList); return numberOfBlocks; } size_t mz_usableFreeSize(const memzone_t* zone) { if (zone == NULL) { return 0; } size_t usableFreeSize = 0; const memblock_t* rover = &zone->blockList; do { if (!rover->user) { usableFreeSize += mz__payloadSize(rover); } rover = rover->next; } while (rover != &zone->blockList); return usableFreeSize; } float mz_fragmentation(const memzone_t* zone) { if (zone == NULL) { return 0.0f; } /** * (free - freemax) * ---------------- x 100% (or 100% for free=0) * free * where * free = total number of bytes free * freemax = size of largest free block */ size_t free = 0; size_t freeMax = 0; const memblock_t* rover = &zone->blockList; do { if (!rover->user) { size_t freeSizeOnBlock = mz__payloadSize(rover); free += freeSizeOnBlock; if (freeSizeOnBlock > freeMax) freeMax = freeSizeOnBlock; } rover = rover->next; } while (rover != &zone->blockList); return free > 0 ? ((float)(free - freeMax) / free) * 100 : 0; } #endif // SHL_MZ_IMPLEMENTATION #endif // SHL_MZ_H ================================================ FILE: deps/include/shl/memzone_audit.h ================================================ /* memzone_audit.h - companion header for memzone.h MIT License Copyright (c) 2018 Alejandro Coto Gutiérrez Provides per-zone audit logging for memzone_t: every alloc, free, realloc, reset and destroy is recorded to a structured text file with a timestamp, call-site (file + line), the result, and a snapshot of zone state. USAGE In exactly one translation unit define both implementation guards before including this header: #define SHL_MZ_IMPLEMENTATION #define SHL_MZ_AUDIT_IMPLEMENTATION #include "memzone_audit.h" In all other translation units include without the guards (or include memzone.h directly if audit is not needed in that TU): #include "memzone_audit.h" This header includes memzone.h internally; you do not need to include it separately. PUBLIC API Once this header is included, the following new symbols become available: mz_audit_format_t — SHL_MZ_AUDIT_FORMAT_VERBOSE or _COMPACT mz_initAudit(size, fmt, path) — create zone and begin logging immediately mz_auditConfigure(z, fmt, path) — attach / reconfigure audit on existing zone mz_auditFlush(z) — flush without closing the log mz_auditClose(z) — flush and close the log The standard mutating API (mz_init, mz_destroy, mz_alloc, mz_free, mz_realloc, mz_allocAligned, mz_reset) is transparently redirected through the audit layer via macros so every call site's file and line number are captured without any source changes. OPTIONAL COMPILE-TIME KNOBS SHL_MZ_AUDIT_VERBOSE — emit a block-list dump after each logged event SHL_MZ_AUDIT_APPEND — open log files in append mode (default: truncate) SHL_MZ_AUDIT_FILE — default log path (default: "memzone_audit.log") SHL_MZ_AUDIT_MAX_ZONES — max concurrent audited zones (default: 64) DESIGN NOTES Audit state is kept in a fixed external table (mz__audit_table) rather than embedded in memzone_t, so memzone.h itself remains unmodified and audit-free. SHL_MZ_AUDIT_IMPLEMENTATION must be compiled in the same translation unit as SHL_MZ_IMPLEMENTATION because the realloc wrapper inspects private internals (memblock_t, mz__findBlock, mz__allocationSize, etc.) that are only visible there. */ #ifndef SHL_MZ_AUDIT_H #define SHL_MZ_AUDIT_H #include "memzone.h" #include #include #ifdef __cplusplus extern "C" { #endif /* ------------------------------------------------------------------------- Format selector ---------------------------------------------------------------------- */ typedef enum { SHL_MZ_AUDIT_FORMAT_VERBOSE, SHL_MZ_AUDIT_FORMAT_COMPACT } mz_audit_format_t; /* ------------------------------------------------------------------------- Public control functions (not intercepted by macros) ---------------------------------------------------------------------- */ /* * mz_auditConfigure — attach or reconfigure audit logging on an existing zone. * Any previously open log file is closed first. No INIT event is logged. * filepath=NULL uses the SHL_MZ_AUDIT_FILE default. */ void mz_auditConfigure(memzone_t* zone, mz_audit_format_t format, const char* filepath); /* Flush the zone's log without closing it. */ void mz_auditFlush(memzone_t* zone); /* Flush and close the zone's log. Safe to call on a zone with no active log. */ void mz_auditClose(memzone_t* zone); /* ------------------------------------------------------------------------- Internal wrappers — invoked through the macros below; do not call directly ---------------------------------------------------------------------- */ memzone_t* mz__audit_init(size_t maxSize, const char* file, int line); memzone_t* mz__audit_initWithLog(size_t maxSize, mz_audit_format_t format, const char* filepath, const char* file, int line); void mz__audit_destroy(memzone_t* zone, const char* file, int line); void mz__audit_reset(memzone_t* zone, const char* file, int line); void* mz__audit_alloc(memzone_t* zone, size_t size, const char* file, int line); void* mz__audit_allocAligned(memzone_t* zone, size_t size, size_t alignment, const char* file, int line); void mz__audit_free(memzone_t* zone, void* p, const char* file, int line); void* mz__audit_realloc(memzone_t* zone, void* p, size_t size, const char* file, int line); #ifdef __cplusplus } #endif /* ------------------------------------------------------------------------- Macro redirections — must be outside extern "C" Intercept every mutating public API call to capture file + line. ---------------------------------------------------------------------- */ #define mz_initAudit(sz, fmt, path) \ mz__audit_initWithLog((sz), (fmt), (path), __FILE__, __LINE__) #define mz_init(s) mz__audit_init((s), __FILE__, __LINE__) #define mz_destroy(z) mz__audit_destroy((z), __FILE__, __LINE__) #define mz_reset(z) mz__audit_reset((z), __FILE__, __LINE__) #define mz_alloc(z, s) mz__audit_alloc((z), (s), __FILE__, __LINE__) #define mz_allocAligned(z, s, a) mz__audit_allocAligned((z), (s), (a), __FILE__, __LINE__) #define mz_free(z, p) mz__audit_free((z), (p), __FILE__, __LINE__) #define mz_realloc(z, p, s) mz__audit_realloc((z), (p), (s), __FILE__, __LINE__) /* ========================================================================= Implementation — compiled only when SHL_MZ_AUDIT_IMPLEMENTATION is defined ========================================================================= */ #ifdef SHL_MZ_AUDIT_IMPLEMENTATION #ifndef SHL_MZ_IMPLEMENTATION # error "SHL_MZ_AUDIT_IMPLEMENTATION requires SHL_MZ_IMPLEMENTATION in the same translation unit" #endif #include #ifndef SHL_MZ_AUDIT_FILE # define SHL_MZ_AUDIT_FILE "memzone_audit.log" #endif #ifndef SHL_MZ_AUDIT_MAX_ZONES # define SHL_MZ_AUDIT_MAX_ZONES 64 #endif /* ------------------------------------------------------------------------- External state table — no fields added to memzone_t ---------------------------------------------------------------------- */ typedef struct { memzone_t* zone; FILE* fp; uint32_t seq; mz_audit_format_t fmt; char filepath[512]; } mz__audit_state_t; static mz__audit_state_t mz__audit_table[SHL_MZ_AUDIT_MAX_ZONES]; static mz__audit_state_t* mz__audit_find(const memzone_t* zone) { int i; for (i = 0; i < SHL_MZ_AUDIT_MAX_ZONES; i++) if (mz__audit_table[i].zone == zone) return &mz__audit_table[i]; return NULL; } /* Acquire a slot for zone (reusing an existing slot if already registered). */ static mz__audit_state_t* mz__audit_acquire(memzone_t* zone, mz_audit_format_t fmt, const char* filepath) { mz__audit_state_t* s = mz__audit_find(zone); if (s != NULL) { /* Close any open log before reconfiguring. */ if (s->fp != NULL) { fflush(s->fp); fclose(s->fp); s->fp = NULL; } } else { int i; for (i = 0; i < SHL_MZ_AUDIT_MAX_ZONES; i++) { if (mz__audit_table[i].zone == NULL) { s = &mz__audit_table[i]; break; } } } if (s == NULL) { return NULL; } /* table full */ { const char* path = (filepath != NULL) ? filepath : SHL_MZ_AUDIT_FILE; size_t len = strlen(path); size_t maxLen = sizeof(s->filepath) - 1; if (len > maxLen) { len = maxLen; } memcpy(s->filepath, path, len); s->filepath[len] = '\0'; } s->zone = zone; s->seq = 0; s->fmt = fmt; s->fp = NULL; return s; } static void mz__audit_release(mz__audit_state_t* s) { if (s == NULL) { return; } if (s->fp != NULL) { fflush(s->fp); fclose(s->fp); s->fp = NULL; } s->zone = NULL; } /* ------------------------------------------------------------------------- Undef macro redirections so the wrapper functions below can call the real base API without recursing back through the audit layer. ---------------------------------------------------------------------- */ #undef mz_initAudit #undef mz_init #undef mz_destroy #undef mz_reset #undef mz_alloc #undef mz_allocAligned #undef mz_free #undef mz_realloc /* ------------------------------------------------------------------------- Helpers ---------------------------------------------------------------------- */ static void mz__audit_timestamp(char* buf, size_t sz) { #if defined(_WIN32) || __STDC_VERSION__ >= 201112L struct timespec ts; if (timespec_get(&ts, TIME_UTC) != 0) { time_t sec = ts.tv_sec; struct tm* tm_info = localtime(&sec); if (tm_info != NULL) { char base[32]; strftime(base, sizeof(base), "%Y-%m-%d %H:%M:%S", tm_info); snprintf(buf, sz, "%s.%03d", base, (int)(ts.tv_nsec / 1000000)); return; } } #endif { time_t t = time(NULL); struct tm* tm_info = localtime(&t); if (tm_info != NULL) strftime(buf, sz, "%Y-%m-%d %H:%M:%S.000", tm_info); else snprintf(buf, sz, "0000-00-00 00:00:00.000"); } } /* Opens the log file for state s and writes the file header. Does nothing if the file is already open. */ static void mz__audit_open(mz__audit_state_t* s) { if (s == NULL || s->fp != NULL) { return; } #ifdef SHL_MZ_AUDIT_APPEND s->fp = fopen(s->filepath, "a"); #else s->fp = fopen(s->filepath, "w"); #endif if (s->fp == NULL) { fprintf(stderr, "memzone audit: could not open '%s' for writing\n", s->filepath); return; } { char ts[32]; mz__audit_timestamp(ts, sizeof(ts)); fprintf(s->fp, "# memzone audit log\n" "# started : %s\n" "# format : %s\n" "# mode : %s\n" "\n", ts, s->fmt == SHL_MZ_AUDIT_FORMAT_COMPACT ? "compact" : "verbose", #ifdef SHL_MZ_AUDIT_APPEND "append" #else "truncate" #endif ); } fflush(s->fp); } static void mz__audit_zone_state(const memzone_t* zone, char* buf, size_t sz) { if (zone == NULL) { snprintf(buf, sz, "(null zone)"); return; } { int32_t blocks = mz_blockCount(zone); float frag = mz_fragmentation(zone); size_t used = mz_usedSize(zone); size_t max = mz_maxSize(zone); float pctFull = max > 0 ? ((float)used / (float)max) * 100.0f : 0.0f; snprintf(buf, sz, "used=%llu, max=%llu (%.2f%% full), blocks=%d, frag=%.2f%%, free=%llu bytes, rover=%p", (unsigned long long)used, (unsigned long long)max, pctFull, blocks, frag, (unsigned long long)(max - used), (const void*)zone->rover); } } /* Counts live (non-free) blocks. Requires private struct visibility. */ static int32_t mz__audit_live_count(const memzone_t* zone) { int32_t count = 0; const memblock_t* rover; if (zone == NULL) { return 0; } rover = &zone->blockList; do { if (!MZ__IS_BLOCK_EMPTY(rover)) { count++; } rover = rover->next; } while (rover != &zone->blockList); return count; } #ifdef SHL_MZ_AUDIT_VERBOSE static void mz__audit_block_list(FILE* fp, const memzone_t* zone) { int32_t idx = 0; const memblock_t* rover; if (fp == NULL || zone == NULL) { return; } fprintf(fp, " Block list :\n"); rover = &zone->blockList; do { if (!MZ__IS_BLOCK_EMPTY(rover)) fprintf(fp, " [%03d] block=%p size=%-8llu user=%p next=%p prev=%p\n", idx, (const void*)rover, (unsigned long long)rover->size, (void*)rover->user, (const void*)rover->next, (const void*)rover->prev); else fprintf(fp, " [%03d] block=%p size=%-8llu FREE next=%p prev=%p\n", idx, (const void*)rover, (unsigned long long)rover->size, (const void*)rover->next, (const void*)rover->prev); idx++; rover = rover->next; } while (rover != &zone->blockList); } #else # define mz__audit_block_list(fp, zone) ((void)0) #endif /* SHL_MZ_AUDIT_VERBOSE */ /* ------------------------------------------------------------------------- Verbose-format event helpers ---------------------------------------------------------------------- */ static void mz__audit_verbose_sep(FILE* fp) { fprintf(fp, "================================================================================\n"); } static void mz__audit_verbose_div(FILE* fp) { fprintf(fp, "--------------------------------------------------------------------------------\n"); } static void mz__audit_verbose_open(FILE* fp, uint32_t seq, const char* op, const char* ts, const char* file, int line) { mz__audit_verbose_sep(fp); fprintf(fp, "EVENT #%04u %-16s %s %s:%d\n", seq, op, ts, file, line); mz__audit_verbose_div(fp); } static void mz__audit_verbose_close(FILE* fp, const memzone_t* zone) { if (zone != NULL) { char state[256]; mz__audit_zone_state(zone, state, sizeof(state)); fprintf(fp, " Zone after : %s\n", state); mz__audit_block_list(fp, zone); } mz__audit_verbose_sep(fp); fputc('\n', fp); } /* ------------------------------------------------------------------------- Wrapper functions ---------------------------------------------------------------------- */ memzone_t* mz__audit_init(size_t maxSize, const char* file, int line) { (void)file; (void)line; return mz_init(maxSize); } memzone_t* mz__audit_initWithLog(size_t maxSize, mz_audit_format_t format, const char* filepath, const char* file, int line) { memzone_t* zone = mz_init(maxSize); if (zone == NULL) { return NULL; } { mz__audit_state_t* s = mz__audit_acquire(zone, format, filepath); if (s == NULL) { return zone; } mz__audit_open(s); if (s->fp == NULL) { return zone; } { char ts[32]; mz__audit_timestamp(ts, sizeof(ts)); s->seq++; if (s->fmt == SHL_MZ_AUDIT_FORMAT_COMPACT) { char state[256] = ""; mz__audit_zone_state(zone, state, sizeof(state)); fprintf(s->fp, "#%04u INIT ts=%s site=%s:%d zone=%p maxSize=%llu result=OK %s\n", s->seq, ts, file, line, (void*)zone, (unsigned long long)maxSize, state); } else { mz__audit_verbose_open(s->fp, s->seq, "INIT", ts, file, line); fprintf(s->fp, " Zone : %p\n", (void*)zone); fprintf(s->fp, " Max size : %llu bytes\n", (unsigned long long)maxSize); fprintf(s->fp, " Result : [OK]\n"); mz__audit_verbose_close(s->fp, zone); } fflush(s->fp); } } return zone; } void mz__audit_destroy(memzone_t* zone, const char* file, int line) { mz__audit_state_t* s = mz__audit_find(zone); if (s != NULL && s->fp != NULL) { FILE* fp = s->fp; mz_audit_format_t fmt = s->fmt; uint32_t seq = ++s->seq; int32_t liveAllocs = mz__audit_live_count(zone); char ts[32]; mz__audit_timestamp(ts, sizeof(ts)); if (fmt == SHL_MZ_AUDIT_FORMAT_COMPACT) { char state[256] = ""; mz__audit_zone_state(zone, state, sizeof(state)); fprintf(fp, "#%04u DESTROY ts=%s site=%s:%d zone=%p %s live_allocs=%d\n", seq, ts, file, line, (void*)zone, state, liveAllocs); } else { char state[256]; mz__audit_verbose_open(fp, seq, "DESTROY", ts, file, line); fprintf(fp, " Zone : %p\n", (void*)zone); mz__audit_zone_state(zone, state, sizeof(state)); fprintf(fp, " Zone final : %s\n", state); fprintf(fp, " Live allocs: %d\n", liveAllocs); mz__audit_block_list(fp, zone); mz__audit_verbose_sep(fp); fputc('\n', fp); } fflush(fp); fclose(fp); s->fp = NULL; } if (s != NULL) { mz__audit_release(s); } mz_destroy(zone); } void mz__audit_reset(memzone_t* zone, const char* file, int line) { mz__audit_state_t* s = mz__audit_find(zone); if (s == NULL || s->fp == NULL) { mz_reset(zone); return; } { char ts[32]; char stateBefore[256] = "(null zone)"; mz__audit_timestamp(ts, sizeof(ts)); s->seq++; mz__audit_zone_state(zone, stateBefore, sizeof(stateBefore)); mz_reset(zone); if (s->fmt == SHL_MZ_AUDIT_FORMAT_COMPACT) { char stateAfter[256] = "(null zone)"; mz__audit_zone_state(zone, stateAfter, sizeof(stateAfter)); fprintf(s->fp, "#%04u RESET ts=%s site=%s:%d zone=%p before=[%s] after=[%s]\n", s->seq, ts, file, line, (void*)zone, stateBefore, stateAfter); } else { mz__audit_verbose_open(s->fp, s->seq, "RESET", ts, file, line); fprintf(s->fp, " Zone : %p\n", (void*)zone); fprintf(s->fp, " Zone before: %s\n", stateBefore); mz__audit_verbose_close(s->fp, zone); } fflush(s->fp); } } void* mz__audit_alloc(memzone_t* zone, size_t size, const char* file, int line) { void* result = mz_alloc(zone, size); { mz__audit_state_t* s = mz__audit_find(zone); if (s != NULL && s->fp != NULL) { char ts[32]; size_t alignment = mz_alignment(); mz__audit_timestamp(ts, sizeof(ts)); s->seq++; if (s->fmt == SHL_MZ_AUDIT_FORMAT_COMPACT) { char state[256] = ""; mz__audit_zone_state(zone, state, sizeof(state)); fprintf(s->fp, "#%04u ALLOC ts=%s site=%s:%d zone=%p size=%llu align=%llu ptr=%p result=%s %s\n", s->seq, ts, file, line, (void*)zone, (unsigned long long)size, (unsigned long long)alignment, result, result != NULL ? "OK" : "FAIL", state); } else { mz__audit_verbose_open(s->fp, s->seq, "ALLOC", ts, file, line); fprintf(s->fp, " Zone : %p\n", (void*)zone); fprintf(s->fp, " Request : size=%llu bytes, alignment=%llu bytes\n", (unsigned long long)size, (unsigned long long)alignment); if (result != NULL) fprintf(s->fp, " Result : ptr=%p [OK]\n", result); else fprintf(s->fp, " Result : ptr=NULL [FAIL]\n"); mz__audit_verbose_close(s->fp, zone); } fflush(s->fp); } } return result; } void* mz__audit_allocAligned(memzone_t* zone, size_t size, size_t alignment, const char* file, int line) { void* result = mz_allocAligned(zone, size, alignment); { mz__audit_state_t* s = mz__audit_find(zone); if (s != NULL && s->fp != NULL) { char ts[32]; mz__audit_timestamp(ts, sizeof(ts)); s->seq++; if (s->fmt == SHL_MZ_AUDIT_FORMAT_COMPACT) { char state[256] = ""; mz__audit_zone_state(zone, state, sizeof(state)); fprintf(s->fp, "#%04u ALLOC_ALIGNED ts=%s site=%s:%d zone=%p size=%llu align=%llu ptr=%p result=%s %s\n", s->seq, ts, file, line, (void*)zone, (unsigned long long)size, (unsigned long long)alignment, result, result != NULL ? "OK" : "FAIL", state); } else { mz__audit_verbose_open(s->fp, s->seq, "ALLOC_ALIGNED", ts, file, line); fprintf(s->fp, " Zone : %p\n", (void*)zone); fprintf(s->fp, " Request : size=%llu bytes, alignment=%llu bytes\n", (unsigned long long)size, (unsigned long long)alignment); if (result != NULL) fprintf(s->fp, " Result : ptr=%p [OK]\n", result); else fprintf(s->fp, " Result : ptr=NULL [FAIL]\n"); mz__audit_verbose_close(s->fp, zone); } fflush(s->fp); } } return result; } void mz__audit_free(memzone_t* zone, void* p, const char* file, int line) { size_t allocSz = 0; bool validPtr = false; if (zone != NULL && p != NULL) { allocSz = mz_allocationSize(zone, p); validPtr = mz_contains(zone, p); } mz_free(zone, p); { mz__audit_state_t* s = mz__audit_find(zone); if (s != NULL && s->fp != NULL) { char ts[32]; mz__audit_timestamp(ts, sizeof(ts)); s->seq++; if (s->fmt == SHL_MZ_AUDIT_FORMAT_COMPACT) { char state[256] = ""; mz__audit_zone_state(zone, state, sizeof(state)); fprintf(s->fp, "#%04u FREE ts=%s site=%s:%d zone=%p ptr=%p alloc_size=%llu result=%s %s\n", s->seq, ts, file, line, (void*)zone, p, (unsigned long long)allocSz, validPtr ? "OK" : "INVALID", state); } else { mz__audit_verbose_open(s->fp, s->seq, "FREE", ts, file, line); fprintf(s->fp, " Zone : %p\n", (void*)zone); if (validPtr) fprintf(s->fp, " Pointer : %p, alloc_size=%llu bytes\n", p, (unsigned long long)allocSz); else fprintf(s->fp, " Pointer : %p [INVALID - not a live allocation in this zone]\n", p); mz__audit_verbose_close(s->fp, zone); } fflush(s->fp); } } } void* mz__audit_realloc(memzone_t* zone, void* p, size_t size, const char* file, int line) { size_t oldAllocSz = 0; const char* strategy = "unknown"; void* result; if (p == NULL) { strategy = "equivalent to alloc (old ptr is NULL)"; } else if (size == 0) { strategy = "equivalent to free (new size is 0)"; } else if (zone != NULL) { const memblock_t* block = mz__findBlock(zone, p); if (block == NULL) { strategy = "invalid pointer"; } else { size_t alignedSize = 0; oldAllocSz = mz__allocationSize(block); (void)mz__alignUp(size, mz_alignment(), &alignedSize); if (oldAllocSz >= alignedSize) { strategy = "no-op (block already has sufficient capacity)"; } else { const memblock_t* next = block->next; bool canExpand = (next != block) && MZ__IS_BLOCK_EMPTY(next) && mz__isNextBlockAdjacent(block) && (next->size >= (alignedSize - oldAllocSz)); strategy = canExpand ? "in-place expand (absorbed adjacent free block)" : "alloc + copy + free (no usable adjacent space)"; } } } result = mz_realloc(zone, p, size); { mz__audit_state_t* s = mz__audit_find(zone); if (s != NULL && s->fp != NULL) { char ts[32]; bool ok = (result != NULL || size == 0); mz__audit_timestamp(ts, sizeof(ts)); s->seq++; if (s->fmt == SHL_MZ_AUDIT_FORMAT_COMPACT) { char state[256] = ""; mz__audit_zone_state(zone, state, sizeof(state)); fprintf(s->fp, "#%04u REALLOC ts=%s site=%s:%d zone=%p old_ptr=%p old_size=%llu" " new_size=%llu strategy=%s ptr=%p result=%s %s\n", s->seq, ts, file, line, (void*)zone, p, (unsigned long long)oldAllocSz, (unsigned long long)size, strategy, result, ok ? "OK" : "FAIL", state); } else { mz__audit_verbose_open(s->fp, s->seq, "REALLOC", ts, file, line); fprintf(s->fp, " Zone : %p\n", (void*)zone); fprintf(s->fp, " Old ptr : %p, old_size=%llu bytes\n", p, (unsigned long long)oldAllocSz); fprintf(s->fp, " Request : new_size=%llu bytes\n", (unsigned long long)size); fprintf(s->fp, " Strategy : %s\n", strategy); if (ok) { if (result == p) fprintf(s->fp, " Result : ptr=%p [OK] (same address)\n", result); else if (result != NULL) fprintf(s->fp, " Result : ptr=%p [OK] (new address)\n", result); else fprintf(s->fp, " Result : ptr=NULL [OK] (freed, size was 0)\n"); } else { fprintf(s->fp, " Result : ptr=NULL [FAIL]\n"); } mz__audit_verbose_close(s->fp, zone); } fflush(s->fp); } } return result; } /* ------------------------------------------------------------------------- Public audit control functions ---------------------------------------------------------------------- */ void mz_auditConfigure(memzone_t* zone, mz_audit_format_t format, const char* filepath) { mz__audit_state_t* s; if (zone == NULL) { return; } s = mz__audit_acquire(zone, format, filepath); if (s == NULL) { return; } mz__audit_open(s); } void mz_auditFlush(memzone_t* zone) { mz__audit_state_t* s = mz__audit_find(zone); if (s != NULL && s->fp != NULL) fflush(s->fp); } void mz_auditClose(memzone_t* zone) { mz__audit_state_t* s = mz__audit_find(zone); if (s != NULL && s->fp != NULL) { fflush(s->fp); fclose(s->fp); s->fp = NULL; } } /* Restore macro redirections so user code in the same TU (after the implementation block) still routes through the audit layer. */ #define mz_initAudit(sz, fmt, path) \ mz__audit_initWithLog((sz), (fmt), (path), __FILE__, __LINE__) #define mz_init(s) mz__audit_init((s), __FILE__, __LINE__) #define mz_destroy(z) mz__audit_destroy((z), __FILE__, __LINE__) #define mz_reset(z) mz__audit_reset((z), __FILE__, __LINE__) #define mz_alloc(z, s) mz__audit_alloc((z), (s), __FILE__, __LINE__) #define mz_allocAligned(z, s, a) mz__audit_allocAligned((z), (s), (a), __FILE__, __LINE__) #define mz_free(z, p) mz__audit_free((z), (p), __FILE__, __LINE__) #define mz_realloc(z, p, s) mz__audit_realloc((z), (p), (s), __FILE__, __LINE__) #endif /* SHL_MZ_AUDIT_IMPLEMENTATION */ #endif /* SHL_MZ_AUDIT_H */ ================================================ FILE: deps/include/shl/queue.h ================================================ /* queue.h - acoto87 (acoto87@gmail.com) MIT License Copyright (c) 2018 Alejandro Coto Gutiérrez 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. Single-header macro library to declare and define strongly typed queues implemented as dynamically resized circular buffers. USAGE Declare a queue type with shlDeclareQueue(name, type), then define it once with shlDefineQueue(name, type) in a C source file. CUSTOMISATION Provide a default value for empty reads, an equality function for Contains, and a free function if queue elements own resources. Values are stored by copy in a resizable circular buffer. NOTES Push appends to the tail, Pop removes from the head, and Peek returns the next item without removing it. Clear releases per-item resources when a free hook is configured. */ #ifndef SHL_QUEUE_H #define SHL_QUEUE_H #include "shl_internal.h" #define shlDeclareQueue(typeName, itemType) \ typedef struct \ { \ itemType defaultValue; \ bool (*equalsFn)(const itemType item1, const itemType item2); \ void (*freeFn)(itemType item); \ } typeName ## Options; \ \ typedef struct \ { \ int32_t head; \ int32_t tail; \ int32_t count; \ int32_t capacity; \ bool (*equalsFn)(const itemType item1, const itemType item2); \ void (*freeFn)(itemType item); \ itemType defaultValue; \ itemType *items; \ } typeName; \ \ void typeName ## Init(typeName* queue, typeName ## Options options); \ void typeName ## Free(typeName* queue); \ void typeName ## Push(typeName* queue, itemType value); \ itemType typeName ## Peek(typeName* queue); \ itemType typeName ## Pop(typeName* queue); \ bool typeName ## Contains(typeName* queue, itemType value); \ void typeName ## Clear(typeName* queue); #define shlDefineQueue(typeName, itemType) \ void typeName ## Init(typeName *queue, typeName ## Options options) \ { \ queue->defaultValue = options.defaultValue; \ queue->equalsFn = options.equalsFn; \ queue->freeFn = options.freeFn; \ queue->capacity = SHL__INITIAL_CAPACITY; \ queue->count = 0; \ queue->head = 0; \ queue->tail = 0; \ queue->items = (itemType *)SHL_CALLOC((size_t)queue->capacity, sizeof(itemType)); \ } \ \ void typeName ## Free(typeName *queue) \ { \ if (!queue->items) \ return; \ \ typeName ## Clear(queue); \ \ SHL_FREE(queue->items); \ queue->items = 0; \ } \ \ void typeName ## Push(typeName *queue, itemType value) \ { \ if (!queue->items) \ return; \ \ if (queue->count == queue->capacity) \ shl__resizeCircularArray((void**)&queue->items, &queue->capacity, &queue->head, &queue->tail, queue->count, sizeof(itemType)); \ \ queue->items[queue->tail] = value; \ queue->tail = (queue->tail + 1) % queue->capacity; \ queue->count++; \ } \ \ itemType typeName ## Peek(typeName *queue) \ { \ if (!queue->items || queue->count == 0) \ return queue->defaultValue; \ \ return queue->items[queue->head]; \ } \ \ itemType typeName ## Pop(typeName *queue) \ { \ if (!queue->items || queue->count == 0) \ return queue->defaultValue; \ \ itemType value = queue->items[queue->head]; \ queue->items[queue->head] = queue->defaultValue; \ queue->head = (queue->head + 1) % queue->capacity; \ queue->count--; \ return value; \ } \ \ bool typeName ## Contains(typeName *queue, itemType value) \ { \ if (!queue->items) \ return false; \ \ if (!queue->equalsFn) \ return false; \ \ for(int32_t i = 0; i < queue->count; i++) \ { \ if (queue->equalsFn(queue->items[(queue->head + i) % queue->capacity], value)) \ return true; \ } \ \ return false; \ } \ void typeName ## Clear(typeName* queue) \ { \ if (!queue->items) \ return; \ \ if (queue->freeFn) \ { \ for(int32_t i = 0; i < queue->count; i++) \ { \ int32_t index = (queue->head + i) % queue->capacity; \ queue->freeFn(queue->items[index]); \ queue->items[index] = queue->defaultValue; \ } \ } \ \ queue->count = 0; \ queue->head = 0; \ queue->tail = 0; \ } #endif // SHL_QUEUE_H ================================================ FILE: deps/include/shl/set.h ================================================ /* set.h - acoto87 (acoto87@gmail.com) MIT License Copyright (c) 2018 Alejandro Coto Gutiérrez 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. Single-header macro library to declare and define strongly typed hash sets. Callers provide hash and equality hooks for the generated item type. USAGE Declare a set type with shlDeclareSet(name, type), then define it once with shlDefineSet(name, type) in a C source file. CUSTOMISATION Provide a hash function and equality function for the item type, plus a default value and optional free function for owned items. Items are stored by copy. NOTES This set uses hash buckets with collision chains stored inside the entry array. Add returns false when the item is already present. Call Free to release internal storage. */ #ifndef SHL_SET_H #define SHL_SET_H #include "shl_internal.h" #define shlDeclareSet(typeName, itemType) \ typedef struct \ { \ itemType defaultValue; \ uint32_t (*hashFn)(const itemType item); \ bool (*equalsFn)(const itemType item1, const itemType item2); \ void (*freeFn)(itemType item); \ } typeName ## Options; \ \ typedef struct { \ bool active; \ uint32_t hash; \ int32_t next; \ itemType item; \ } typeName ## __Entry__; \ \ typedef struct { \ int32_t count; \ int32_t capacity; \ int32_t loadFactor; \ int32_t shift; \ uint32_t (*hashFn)(const itemType item); \ bool (*equalsFn)(const itemType item1, const itemType item2); \ void (*freeFn)(itemType item); \ itemType defaultValue; \ typeName ## __Entry__* entries; \ } typeName; \ \ void typeName ## Init(typeName* map, typeName ## Options options); \ void typeName ## Free(typeName* map); \ bool typeName ## Add(typeName* set, itemType item); \ bool typeName ## Contains(typeName* set, itemType item); \ void typeName ## Remove(typeName* set, itemType item); \ void typeName ## Clear(typeName* set); \ #define shlDefineSet(typeName, itemType) \ static void typeName ## __resize(typeName* set); \ \ static void typeName ## __resize(typeName* set) \ { \ int32_t oldCapacity = set->capacity; \ typeName ## __Entry__* old = set->entries; \ \ set->loadFactor = oldCapacity; \ set->capacity = 1 << (32 - (--set->shift)); \ set->entries = (typeName ## __Entry__*)calloc(set->capacity, sizeof(typeName ## __Entry__)); \ set->count = 0; \ \ for(int32_t i = 0; i < oldCapacity; i++) \ { \ if(old[i].active) \ typeName ## Add(set, old[i].item); \ } \ SHL_FREE(old); \ } \ \ void typeName ## Init(typeName* set, typeName ## Options options) \ { \ set->defaultValue = options.defaultValue; \ set->hashFn = options.hashFn; \ set->equalsFn = options.equalsFn; \ set->freeFn = options.freeFn; \ set->shift = SHL__INITIAL_HASH_SHIFT; \ set->capacity = SHL__INITIAL_CAPACITY; \ set->loadFactor = SHL__INITIAL_HASH_LOAD_FACTOR; \ set->count = 0; \ set->entries = (typeName ## __Entry__ *)SHL_CALLOC((size_t)set->capacity, sizeof(typeName ## __Entry__)); \ } \ \ void typeName ## Free(typeName* set) \ { \ if (!set->entries) \ return; \ \ typeName ## Clear(set); \ \ SHL_FREE(set->entries); \ set->entries = 0; \ } \ \ bool typeName ## Add(typeName* set, itemType item) \ { \ if (!set->entries) \ return false; \ \ if(set->count == set->loadFactor) \ typeName ## __resize(set); \ \ uint32_t hash; \ int32_t index; \ int32_t next; \ hash = index = shl__fibHash(set->hashFn(item), set->shift); \ \ while (set->entries[index].active) \ { \ if(set->entries[index].hash == hash && set->equalsFn(set->entries[index].item, item)) \ return false; \ \ if (set->entries[index].next < 0) \ break; \ \ index = set->entries[index].next; \ } \ \ next = shl__findEmptyBucket(set->entries, set->capacity, index, sizeof(typeName ## __Entry__), offsetof(typeName ## __Entry__, active)); \ if (next < 0) \ { \ typeName ## __resize(set); \ return typeName ## Add(set, item); \ } \ if (index != next) \ set->entries[index].next = next; \ \ set->entries[next].active = true; \ set->entries[next].item = item; \ set->entries[next].hash = hash; \ set->entries[next].next = -1; \ set->count++; \ return true; \ } \ \ bool typeName ## Contains(typeName* set, itemType item) \ { \ if (!set->entries) \ return false; \ \ int32_t index; \ uint32_t hash; \ hash = index = shl__fibHash(set->hashFn(item), set->shift); \ \ bool found = false; \ \ while (set->entries[index].active) \ { \ if(set->entries[index].hash == hash && set->equalsFn(set->entries[index].item, item)) \ { \ found = true; \ break; \ } \ \ if (set->entries[index].next < 0) \ break; \ \ index = set->entries[index].next; \ } \ \ return found; \ } \ \ void typeName ## Remove(typeName* set, itemType item) \ { \ if (!set->entries) \ return; \ \ int32_t prevIndex, index; \ uint32_t hash; \ hash = prevIndex = index = shl__fibHash(set->hashFn(item), set->shift); \ \ while (set->entries[index].active) \ { \ if(set->entries[index].hash == hash && set->equalsFn(set->entries[index].item, item)) \ { \ itemType oldItem = set->entries[index].item; \ int32_t nextIndex = set->entries[index].next; \ if (nextIndex >= 0) \ { \ set->entries[index] = set->entries[nextIndex]; \ set->entries[nextIndex].item = set->defaultValue; \ set->entries[nextIndex].next = -1; \ set->entries[nextIndex].active = false; \ } \ else \ { \ if (prevIndex != index) \ set->entries[prevIndex].next = -1; \ set->entries[index].item = set->defaultValue; \ set->entries[index].next = -1; \ set->entries[index].active = false; \ } \ \ if (set->freeFn) \ set->freeFn(oldItem); \ \ set->count--; \ \ break; \ } \ \ if (set->entries[index].next < 0) \ break; \ \ prevIndex = index; \ index = set->entries[index].next; \ } \ } \ \ void typeName ## Clear(typeName* set) \ { \ if (!set->entries) \ return; \ \ for(int32_t i = 0; i < set->capacity; i++) \ { \ if (set->entries[i].active) \ { \ if (set->freeFn) \ set->freeFn(set->entries[i].item); \ \ set->entries[i].item = set->defaultValue; \ set->entries[i].next = -1; \ set->entries[i].active = false; \ } \ } \ \ set->count = 0; \ } #endif //SHL_SET_H ================================================ FILE: deps/include/shl/shl_internal.h ================================================ /* shl_internal.h - shared internal helpers for SHL collection headers. This file is not part of the public API surface. */ #ifndef SHL_INTERNAL_H #define SHL_INTERNAL_H #include #include #include #include #include #ifndef SHL_MALLOC #define SHL_MALLOC(sz) malloc(sz) #endif #ifndef SHL_CALLOC #define SHL_CALLOC(n, sz) calloc((n), (sz)) #endif #ifndef SHL_REALLOC #define SHL_REALLOC(ptr, sz) realloc((ptr), (sz)) #endif #ifndef SHL_FREE #define SHL_FREE(ptr) free(ptr) #endif #define SHL__INITIAL_CAPACITY 8 #define SHL__INITIAL_HASH_SHIFT 29 #define SHL__INITIAL_HASH_LOAD_FACTOR 6 static inline int32_t shl__grownCapacity(int32_t currentCapacity, int32_t minSize) { int32_t newCapacity = currentCapacity > 0 ? (currentCapacity << 1) : SHL__INITIAL_CAPACITY; if (newCapacity < minSize) newCapacity = minSize; return newCapacity; } static inline void shl__resizeArray(void** items, int32_t* capacity, int32_t minSize, size_t itemSize) { *capacity = shl__grownCapacity(*capacity, minSize); *items = SHL_REALLOC(*items, (size_t)(*capacity) * itemSize); } static inline void shl__resizeCircularArray(void** items, int32_t* capacity, int32_t* head, int32_t* tail, int32_t count, size_t itemSize) { int32_t oldCapacity = *capacity; unsigned char* oldItems = (unsigned char*)*items; unsigned char* newItems; *capacity = shl__grownCapacity(*capacity, *capacity + 1); newItems = (unsigned char*)SHL_CALLOC((size_t)(*capacity), itemSize); if (count > 0) { if (*head >= *tail) { size_t firstCopySize = (size_t)(oldCapacity - *head) * itemSize; size_t secondCopySize = (size_t)((*head + count) % oldCapacity) * itemSize; memcpy(newItems, oldItems + (size_t)(*head) * itemSize, firstCopySize); memcpy(newItems + firstCopySize, oldItems, secondCopySize); } else { memcpy(newItems, oldItems + (size_t)(*head) * itemSize, (size_t)count * itemSize); } } *head = 0; *tail = count; SHL_FREE(*items); *items = newItems; } static inline int32_t shl__fibHash(uint32_t hash, int32_t shift) { const uint32_t hashConstant = 2654435769u; return (int32_t)((hash * hashConstant) >> shift); } static inline int32_t shl__findEmptyBucket(const void* entries, int32_t capacity, int32_t startIndex, size_t entrySize, size_t activeOffset) { const unsigned char* bytes = (const unsigned char*)entries; for (int32_t i = 0; i < capacity; i++) { int32_t currentIndex = (startIndex + i) % capacity; bool active = false; memcpy(&active, bytes + (size_t)currentIndex * entrySize + activeOffset, sizeof(active)); if (!active) return currentIndex; } return -1; } #endif // SHL_INTERNAL_H ================================================ FILE: deps/include/shl/stack.h ================================================ /* stack.h - acoto87 (acoto87@gmail.com) MIT License Copyright (c) 2018 Alejandro Coto Gutiérrez 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. Single-header macro library to declare and define strongly typed stacks backed by dynamically resized arrays. USAGE Declare a stack type with shlDeclareStack(name, type), then define it once with shlDefineStack(name, type) in a C source file. CUSTOMISATION Provide a default value for empty reads, an equality function for Contains, and a free function if stored values own resources. Values are stored by copy in a dynamically resized array. NOTES Push appends to the top of the stack, Pop removes the most recent item, and Peek reads without removing. Call Free when the stack is no longer needed. */ #ifndef SHL_STACK_H #define SHL_STACK_H #include "shl_internal.h" #define shlDeclareStack(typeName, itemType) \ typedef struct \ { \ itemType defaultValue; \ bool (*equalsFn)(const itemType item1, const itemType item2); \ void (*freeFn)(itemType item); \ } typeName ## Options; \ \ typedef struct \ { \ int32_t count; \ int32_t capacity; \ bool (*equalsFn)(const itemType item1, const itemType item2); \ void (*freeFn)(itemType item); \ itemType defaultValue; \ itemType *items; \ } typeName; \ \ void typeName ## Init(typeName *stack, typeName ## Options options); \ void typeName ## Free(typeName *stack); \ void typeName ## Push(typeName *stack, itemType value); \ bool typeName ## Contains(typeName *stack, itemType value); \ itemType typeName ## Peek(typeName *stack); \ itemType typeName ## Pop(typeName *stack); \ void typeName ## Clear(typeName *stack); #define shlDefineStack(typeName, itemType) \ void typeName ## Init(typeName *stack, typeName ## Options options) \ { \ stack->defaultValue = options.defaultValue; \ stack->equalsFn = options.equalsFn; \ stack->freeFn = options.freeFn; \ stack->capacity = SHL__INITIAL_CAPACITY; \ stack->count = 0; \ stack->items = (itemType *)SHL_CALLOC((size_t)stack->capacity, sizeof(itemType)); \ } \ \ void typeName ## Free(typeName *stack) \ { \ if (!stack->items) \ return; \ \ typeName ## Clear(stack); \ \ SHL_FREE(stack->items); \ stack->items = 0; \ } \ \ void typeName ## Push(typeName *stack, itemType value) \ { \ if (!stack->items) \ return; \ \ if (stack->count == stack->capacity) \ shl__resizeArray((void**)&stack->items, &stack->capacity, stack->count + 1, sizeof(itemType)); \ \ stack->items[stack->count] = value; \ stack->count++; \ } \ \ itemType typeName ## Peek(typeName *stack) \ { \ if (!stack->items || stack->count == 0) \ return stack->defaultValue; \ \ return stack->items[stack->count - 1]; \ } \ \ itemType typeName ## Pop(typeName *stack) \ { \ if (!stack->items || stack->count == 0) \ return stack->defaultValue; \ \ itemType item = stack->items[stack->count - 1]; \ stack->count--; \ return item; \ } \ \ bool typeName ## Contains(typeName *stack, itemType value) \ { \ if (!stack->items) \ return false; \ \ if (!stack->equalsFn) \ return false; \ \ for(int32_t i = 0; i < stack->count; i++) \ { \ if (stack->equalsFn(stack->items[i], value)) \ return true; \ } \ \ return false; \ } \ \ void typeName ## Clear(typeName* stack) \ { \ if (!stack->items) \ return; \ \ if (stack->freeFn) \ { \ for(int32_t i = 0; i < stack->count; i++) \ stack->freeFn(stack->items[i]); \ } \ \ stack->count = 0; \ } #endif // SHL_STACK_H ================================================ FILE: deps/include/shl/wav.h ================================================ /* wav.h - based on Wave_Writer by Shay Green MIT License Copyright (C) 2003-2005 Shay Green 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. Single-header WAVE file writer for streaming 16-bit PCM samples to disk. The API uses the wav_ prefix and writes the final RIFF/WAVE header when the file is flushed and closed. USAGE Include this header in all translation units that need the declarations. Define SHL_WAV_IMPLEMENTATION in exactly one translation unit before the include to compile the implementation: #define SHL_WAV_IMPLEMENTATION #include "wav.h" Include the header without that define everywhere else: #include "wav.h" CUSTOMISATION The sample type and internal buffer size are controlled by compile-time macros near the top of the implementation. If you need different buffering or output behavior, adjust those constants or the implementation section. NOTES wav_init opens the output file and prepares the buffer, wav_write streams 16-bit samples into it, and wav_flush writes the final header before optionally closing the file handle. */ #ifndef SHL_WAVE_WRITER_H #define SHL_WAVE_WRITER_H #include #include #include #include #include #ifdef __cplusplus extern "C" { #endif typedef short wav_sample_t; typedef struct _wav_file_t wav_file_t; #define WAV_BUFFER_SIZE (32768 * 2) #define WAV_HEADER_SIZE 0x2C #define WAV_U8_CAST(x) ((unsigned char)(x)) bool wav_init(wav_file_t* waveFile, long sampleRate, const char* filename); void wav_stereo(wav_file_t* waveFile, bool stereo); long wav_sampleCount(wav_file_t* waveFile); bool wav_write(wav_file_t* waveFile, const wav_sample_t* in, long count, int skip); bool wav_flush(wav_file_t* waveFile, bool closeFile); #ifdef __cplusplus } #endif #ifdef SHL_WAV_IMPLEMENTATION #include #include struct _wav_file_t { FILE* _file; unsigned char* _buffer; long sampleRate; long _sampleCount; long _bufferPos; int channelCount; }; static bool wav__flushBuffer(wav_file_t* waveFile) { if (waveFile->_bufferPos && !fwrite(waveFile->_buffer, waveFile->_bufferPos, 1, waveFile->_file)) { return false; } waveFile->_bufferPos = 0; return true; } bool wav_init(wav_file_t* waveFile, long sampleRate, const char* filename) { waveFile->_buffer = (unsigned char*) calloc(WAV_BUFFER_SIZE, sizeof(unsigned char)); if (!waveFile->_buffer) { return false; } waveFile->_file = NULL; waveFile->_file = fopen(filename, "wb"); if (!waveFile->_file) { free(waveFile->_buffer); waveFile->_buffer = NULL; return false; } waveFile->sampleRate = sampleRate; waveFile->channelCount = 1; waveFile->_sampleCount = 0; waveFile->_bufferPos = WAV_HEADER_SIZE; return true; } void wav_stereo(wav_file_t* waveFile, bool stereo) { waveFile->channelCount = stereo ? 2 : 1; } long wav_sampleCount(wav_file_t* waveFile) { return waveFile->_sampleCount; } bool wav_write(wav_file_t* waveFile, const wav_sample_t* in, long count, int skip) { waveFile->_sampleCount += count; while (count) { if (waveFile->_bufferPos >= WAV_BUFFER_SIZE) { if (!wav__flushBuffer(waveFile)) { return false; } } long n = (unsigned long) (WAV_BUFFER_SIZE - waveFile->_bufferPos) / sizeof (wav_sample_t); if (n > count) n = count; count -= n; // convert to lsb first format unsigned char* p = &waveFile->_buffer[waveFile->_bufferPos]; while (n--) { int s = *in; in += skip; *p++ = (unsigned char) s; *p++ = (unsigned char) (s >> 8); } assert(p - waveFile->_buffer <= LONG_MAX); waveFile->_bufferPos = (long)(p - waveFile->_buffer); } return true; } bool wav_flush(wav_file_t* waveFile, bool closeFile) { if (!wav__flushBuffer(waveFile)) { return false; } if (closeFile) { // generate header long sample_rate = waveFile->sampleRate; int channel_count = waveFile->channelCount; long ds = waveFile->_sampleCount * sizeof (wav_sample_t); long rs = WAV_HEADER_SIZE - 8 + ds; int frame_size = channel_count * sizeof (wav_sample_t); long bps = sample_rate * frame_size; unsigned char header[WAV_HEADER_SIZE] = { 'R','I','F','F', WAV_U8_CAST(rs), WAV_U8_CAST(rs >> 8), // length of rest of file WAV_U8_CAST(rs >> 16), WAV_U8_CAST(rs >> 24), 'W','A','V','E', 'f','m','t',' ', 0x10, 0, 0, 0, // size of fmt chunk 1, 0, // uncompressed format WAV_U8_CAST(channel_count), 0, // channel count WAV_U8_CAST(sample_rate), WAV_U8_CAST(sample_rate >> 8), // sample rate WAV_U8_CAST(sample_rate >> 16), WAV_U8_CAST(sample_rate >> 24), WAV_U8_CAST(bps), WAV_U8_CAST(bps >> 8), // bytes per second WAV_U8_CAST(bps >> 16), WAV_U8_CAST(bps >> 24), WAV_U8_CAST(frame_size), 0, // bytes per sample frame 16, 0, // bits per sample 'd','a','t','a', WAV_U8_CAST(ds), WAV_U8_CAST(ds >> 8), // size of sample data WAV_U8_CAST(ds >> 16), WAV_U8_CAST(ds >> 24) // ... // sample data }; // write header if (fseek(waveFile->_file, 0, SEEK_SET)) { return false; } if (!fwrite(header, sizeof header, 1, waveFile->_file)) { return false; } if (fclose(waveFile->_file)) { return false; } free(waveFile->_buffer); waveFile->_buffer = NULL; waveFile->_file = NULL; } return true; } #endif // SHL_WAV_IMPLEMENTATION #endif // SHL_WAVE_WRITER_H ================================================ FILE: deps/include/shl/wstr.h ================================================ /* wstr.h - acoto87 (acoto87@gmail.com) MIT License Copyright (c) 2018 Alejandro Coto Gutiérrez 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. Single-header string library providing two complementary types: StringView - a non-owning, read-only view into an existing character buffer (wsv_* functions; prefix stands for "wstr view") String - a heap-allocated, null-terminated, mutable string (wstr_* functions) USAGE Include this header in all translation units that need the declarations. Define SHL_WSTR_IMPLEMENTATION in exactly one translation unit before the include to compile the implementation: #define SHL_WSTR_IMPLEMENTATION #include "wstr.h" Include the header without that define everywhere else: #include "wstr.h" CUSTOMISATION Override the allocation hooks before the implementation include if you need custom memory management: #define WSTR_MALLOC(sz) my_malloc(sz) #define WSTR_REALLOC(p, sz) my_realloc(p, sz) #define WSTR_FREE(p) my_free(p) #define SHL_WSTR_IMPLEMENTATION #include "wstr.h" NOTES StringView never owns memory and always refers to external storage. String owns its buffer, keeps it null-terminated, and must be released with wstr_free or wstr_freePtr when no longer needed. Functions that mutate a String may reallocate its buffer. */ #ifndef SHL_WSTR_H #define SHL_WSTR_H #include #include #include #include #ifdef __cplusplus extern "C" { #endif /* ========================================================================= Sentinel value returned by search functions when nothing is found ========================================================================= */ #define WSV_NPOS ((size_t)-1) /* ========================================================================= Compile-time literal helper ========================================================================= */ #define WSV_LITERAL(text) ((StringView){(text), sizeof(text) - 1}) /* ========================================================================= Types ========================================================================= */ typedef struct { const char* data; size_t length; } StringView; typedef struct { char* data; size_t length; size_t capacity; } String; /* ========================================================================= StringView API (wsv_*) ========================================================================= */ StringView wsv_empty(void); StringView wsv_fromCString(const char* text); StringView wsv_fromParts(const char* text, size_t length); StringView wsv_fromRange(const char* begin, const char* end); StringView wsv_fromString(const String* string); bool wsv_isEmpty(StringView view); const char* wsv_data(StringView view); size_t wsv_length(StringView view); StringView wsv_slice(StringView view, size_t index, size_t length); StringView wsv_subview(StringView view, size_t index); StringView wsv_trimLeft(StringView view); StringView wsv_trimRight(StringView view); StringView wsv_trim(StringView view); bool wsv_equals(StringView left, StringView right); bool wsv_equalsIgnoreCase(StringView left, StringView right); bool wsv_startsWith(StringView view, StringView prefix); bool wsv_startsWithIgnoreCase(StringView view, StringView prefix); size_t wsv_findChar(StringView view, char c); size_t wsv_find(StringView view, StringView needle); size_t wsv_findAny(StringView view, StringView chars); StringView wsv_skipChars(StringView view, StringView chars); StringView wsv_takeUntilAny(StringView view, StringView chars); bool wsv_splitOnce(StringView view, StringView separator, StringView* left, StringView* right); StringView wsv_chopByDelimiter(StringView* remaining, char delimiter); bool wsv_nextToken(StringView* remaining, StringView separators, StringView* token); uint32_t wsv_hashFNV32(StringView view); int32_t wsv_parseS32(StringView view); bool wsv_tryParseS32(StringView view, int32_t* value); int64_t wsv_parseS64(StringView view); bool wsv_tryParseS64(StringView view, int64_t* value); bool wsv_copyToBuffer(StringView view, char* buffer, size_t capacity); StringView wsv_fromCStringFormat (char* buffer, size_t capacity, const char* fmt, ...); StringView wsv_fromCStringFormatv(char* buffer, size_t capacity, const char* fmt, va_list args); String wsv_toString(StringView view); /* ========================================================================= String API (wstr_*) ========================================================================= */ String wstr_make(void); String wstr_withCapacity(size_t capacity); String wstr_fromCString(const char* text); String wstr_fromCStringFormat(const char* textFormat, ...); String wstr_fromCStringFormatv(const char* textFormat, va_list args); String wstr_fromView(StringView view); String wstr_concat(StringView left, StringView right); String wstr_adopt(char* buffer, size_t length, size_t capacity); void wstr_freePtr(String* string); void wstr_free(String string); void wstr_clear(String* string); StringView wstr_view(const String* string); const char* wstr_cstr(const String* string); bool wstr_isEmpty(const String* string); bool wstr_reserve(String* string, size_t capacity); bool wstr_resize(String* string, size_t length); String wstr_copy(const String* string); bool wstr_assign(String* string, StringView view); bool wstr_assignCString(String* string, const char* text); bool wstr_assignCStringFormat(String* string, const char* textFormat, ...); bool wstr_assignCStringFormatv(String* string, const char* textFormat, va_list args); bool wstr_append(String* string, StringView view); bool wstr_appendCString(String* string, const char* text); bool wstr_appendCStringFormat(String* string, const char* textFormat, ...); bool wstr_appendCStringFormatv(String* string, const char* textFormat, va_list args); bool wstr_appendChar(String* string, char c); bool wstr_insert(String* string, size_t index, StringView view); bool wstr_removeRange(String* string, size_t index, size_t length); bool wstr_setFormat(String* string, const char* fmt, ...); bool wstr_setFormatv(String* string, const char* fmt, va_list args); bool wstr_appendFormat(String* string, const char* fmt, ...); bool wstr_appendFormatv(String* string, const char* fmt, va_list args); #ifdef __cplusplus } #endif /* ========================================================================= Implementation ========================================================================= */ #ifdef SHL_WSTR_IMPLEMENTATION #include #include #include #include #include #ifndef WSTR_MALLOC #define WSTR_MALLOC(sz) malloc(sz) #endif #ifndef WSTR_REALLOC #define WSTR_REALLOC(p, sz) realloc((p), (sz)) #endif #ifndef WSTR_FREE #define WSTR_FREE(p) free(p) #endif #ifndef FNV_PRIME_32 #define FNV_PRIME_32 0x01000193u #endif #ifndef FNV_OFFSET_32 #define FNV_OFFSET_32 0x811c9dc5u #endif /* ----- internal helpers -------------------------------------------------- */ static char wstr__toLowerAscii(char c) { return (char)tolower((unsigned char)c); } static bool wsv__containsChar(StringView chars, char c) { for (size_t i = 0; i < chars.length; i++) { if (chars.data[i] == c) { return true; } } return false; } static bool wstr__isAliased(const String* string, StringView view) { if (string == NULL || string->data == NULL || view.data == NULL || view.length == 0) { return false; } const char* begin = string->data; const char* end = string->data + string->length; return view.data >= begin && view.data <= end; } static bool wstr__grow(String* string, size_t minCapacity) { if (string == NULL) { return false; } if (minCapacity <= string->capacity) { return true; } if (minCapacity == (size_t)-1) { return false; } size_t nextCapacity = string->capacity > 0 ? string->capacity : 16; while (nextCapacity < minCapacity) { size_t doubled = nextCapacity * 2; if (doubled <= nextCapacity) { nextCapacity = minCapacity; break; } nextCapacity = doubled; } if (nextCapacity + 1 < nextCapacity) { return false; } char* data = string->data != NULL ? (char*)WSTR_REALLOC(string->data, nextCapacity + 1) : (char*)WSTR_MALLOC(nextCapacity + 1); if (data == NULL) { return false; } string->data = data; string->capacity = nextCapacity; string->data[string->length] = 0; return true; } static bool wstr__appendFormatAt(String* string, size_t offset, const char* fmt, va_list args) { if (string == NULL || fmt == NULL) { return false; } if (!wstr__grow(string, offset + 1)) { return false; } for (;;) { size_t available = string->capacity - offset; va_list argsCopy; va_copy(argsCopy, args); int required = vsnprintf(string->data + offset, available + 1, fmt, argsCopy); va_end(argsCopy); if (required >= 0 && (size_t)required <= available) { string->length = offset + (size_t)required; return true; } size_t needed = required >= 0 ? offset + (size_t)required : (string->capacity * 2); if (needed < offset + 32) { needed = offset + 32; } if (!wstr__grow(string, needed)) { return false; } } } static bool wsv__tryParseInteger(StringView view, int64_t minValue, int64_t maxValue, int64_t* value) { if (value == NULL) { return false; } view = wsv_trim(view); if (view.length == 0) { return false; } size_t index = 0; bool negative = false; if (view.data[index] == '+' || view.data[index] == '-') { negative = view.data[index] == '-'; index++; } if (index >= view.length) { return false; } int base = 10; if (view.data[index] == '0' && (index + 1) < view.length) { char next = view.data[index + 1]; if (next == 'x' || next == 'X') { base = 16; index += 2; } else { base = 8; } } if (index >= view.length) { return false; } uint64_t limit = negative ? (uint64_t)LLONG_MAX + 1ull : (uint64_t)LLONG_MAX; uint64_t result = 0; bool hasDigits = false; for (; index < view.length; index++) { unsigned char c = (unsigned char)view.data[index]; int digit; if (c >= '0' && c <= '9') { digit = c - '0'; } else if (c >= 'a' && c <= 'f') { digit = 10 + (c - 'a'); } else if (c >= 'A' && c <= 'F') { digit = 10 + (c - 'A'); } else { return false; } if (digit >= base) { return false; } if (result > (limit - (uint64_t)digit) / (uint64_t)base) { return false; } result = result * (uint64_t)base + (uint64_t)digit; hasDigits = true; } if (!hasDigits) { return false; } int64_t signedValue; if (negative) { if (result == (uint64_t)LLONG_MAX + 1ull) { signedValue = LLONG_MIN; } else { signedValue = -(int64_t)result; } } else { signedValue = (int64_t)result; } if (signedValue < minValue || signedValue > maxValue) { return false; } *value = signedValue; return true; } /* ----- StringView implementation ----------------------------------------- */ StringView wsv_empty(void) { return (StringView){0}; } StringView wsv_fromCString(const char* text) { if (text == NULL) { return wsv_empty(); } return wsv_fromParts(text, strlen(text)); } StringView wsv_fromParts(const char* text, size_t length) { if (text == NULL && length == 0) { return wsv_empty(); } return (StringView){text, length}; } StringView wsv_fromRange(const char* begin, const char* end) { if (begin == NULL || end == NULL || end < begin) { return wsv_empty(); } return wsv_fromParts(begin, (size_t)(end - begin)); } StringView wsv_fromString(const String* string) { if (string == NULL) { return wsv_empty(); } return wsv_fromParts(string->data, string->length); } bool wsv_isEmpty(StringView view) { return view.length == 0; } const char* wsv_data(StringView view) { return view.data != NULL ? view.data : ""; } size_t wsv_length(StringView view) { return view.length; } StringView wsv_slice(StringView view, size_t index, size_t length) { if (index >= view.length) { return wsv_empty(); } size_t available = view.length - index; if (length > available) { length = available; } return wsv_fromParts(view.data + index, length); } StringView wsv_subview(StringView view, size_t index) { if (index >= view.length) { return wsv_empty(); } return wsv_fromParts(view.data + index, view.length - index); } StringView wsv_trimLeft(StringView view) { size_t index = 0; while (index < view.length && isspace((unsigned char)view.data[index])) { index++; } return wsv_subview(view, index); } StringView wsv_trimRight(StringView view) { while (view.length > 0 && isspace((unsigned char)view.data[view.length - 1])) { view.length--; } return view; } StringView wsv_trim(StringView view) { return wsv_trimRight(wsv_trimLeft(view)); } bool wsv_equals(StringView left, StringView right) { if (left.length != right.length) { return false; } if (left.length == 0) { return true; } return memcmp(left.data, right.data, left.length) == 0; } bool wsv_equalsIgnoreCase(StringView left, StringView right) { if (left.length != right.length) { return false; } for (size_t i = 0; i < left.length; i++) { if (wstr__toLowerAscii(left.data[i]) != wstr__toLowerAscii(right.data[i])) { return false; } } return true; } bool wsv_startsWith(StringView view, StringView prefix) { return prefix.length <= view.length && wsv_equals(wsv_slice(view, 0, prefix.length), prefix); } bool wsv_startsWithIgnoreCase(StringView view, StringView prefix) { return prefix.length <= view.length && wsv_equalsIgnoreCase(wsv_slice(view, 0, prefix.length), prefix); } size_t wsv_findChar(StringView view, char c) { for (size_t i = 0; i < view.length; i++) { if (view.data[i] == c) { return i; } } return WSV_NPOS; } size_t wsv_find(StringView view, StringView needle) { if (needle.length == 0) { return 0; } if (needle.length > view.length) { return WSV_NPOS; } size_t last = view.length - needle.length; for (size_t i = 0; i <= last; i++) { if (view.data[i] == needle.data[0] && memcmp(view.data + i, needle.data, needle.length) == 0) { return i; } } return WSV_NPOS; } size_t wsv_findAny(StringView view, StringView chars) { for (size_t i = 0; i < view.length; i++) { if (wsv__containsChar(chars, view.data[i])) { return i; } } return WSV_NPOS; } StringView wsv_skipChars(StringView view, StringView chars) { size_t index = 0; while (index < view.length && wsv__containsChar(chars, view.data[index])) { index++; } return wsv_subview(view, index); } StringView wsv_takeUntilAny(StringView view, StringView chars) { size_t index = wsv_findAny(view, chars); if (index == WSV_NPOS) { return view; } return wsv_slice(view, 0, index); } bool wsv_splitOnce(StringView view, StringView separator, StringView* left, StringView* right) { if (left == NULL || right == NULL) { return false; } if (separator.length == 0) { *left = wsv_empty(); *right = view; return true; } size_t index = wsv_find(view, separator); if (index == WSV_NPOS) { *left = view; *right = wsv_empty(); return false; } *left = wsv_slice(view, 0, index); *right = wsv_subview(view, index + separator.length); return true; } StringView wsv_chopByDelimiter(StringView* remaining, char delimiter) { if (remaining == NULL) { return wsv_empty(); } size_t index = wsv_findChar(*remaining, delimiter); if (index == WSV_NPOS) { StringView token = *remaining; *remaining = wsv_empty(); return token; } StringView token = wsv_slice(*remaining, 0, index); *remaining = wsv_subview(*remaining, index + 1); return token; } bool wsv_nextToken(StringView* remaining, StringView separators, StringView* token) { if (remaining == NULL || token == NULL) { return false; } *remaining = wsv_skipChars(*remaining, separators); if (remaining->length == 0) { *token = wsv_empty(); return false; } size_t index = wsv_findAny(*remaining, separators); if (index == WSV_NPOS) { *token = *remaining; *remaining = wsv_empty(); return true; } *token = wsv_slice(*remaining, 0, index); *remaining = wsv_subview(*remaining, index); return true; } uint32_t wsv_hashFNV32(StringView view) { uint32_t hash = FNV_OFFSET_32; for (size_t i = 0; i < view.length; i++) { hash = ((uint32_t)(unsigned char)view.data[i] ^ hash) * FNV_PRIME_32; } return hash; } int32_t wsv_parseS32(StringView view) { int32_t value = 0; wsv_tryParseS32(view, &value); return value; } bool wsv_tryParseS32(StringView view, int32_t* value) { int64_t parsedValue = 0; if (!wsv__tryParseInteger(view, INT32_MIN, INT32_MAX, &parsedValue)) { return false; } if (value != NULL) { *value = (int32_t)parsedValue; } return true; } int64_t wsv_parseS64(StringView view) { int64_t value = 0; wsv_tryParseS64(view, &value); return value; } bool wsv_tryParseS64(StringView view, int64_t* value) { int64_t parsedValue = 0; if (!wsv__tryParseInteger(view, LLONG_MIN, LLONG_MAX, &parsedValue)) { return false; } if (value != NULL) { *value = parsedValue; } return true; } bool wsv_copyToBuffer(StringView view, char* buffer, size_t capacity) { if (buffer == NULL || capacity == 0 || view.length >= capacity) { if (buffer != NULL && capacity > 0) { buffer[0] = 0; } return false; } if (view.length > 0) { memcpy(buffer, view.data, view.length); } buffer[view.length] = 0; return true; } String wsv_toString(StringView view) { return wstr_fromView(view); } StringView wsv_fromCStringFormatv(char* buffer, size_t capacity, const char* fmt, va_list args) { if (buffer == NULL || capacity == 0 || fmt == NULL) { return wsv_empty(); } int result = vsnprintf(buffer, capacity, fmt, args); if (result < 0) { buffer[0] = 0; return wsv_empty(); } size_t length = (size_t)result < capacity ? (size_t)result : capacity - 1; return wsv_fromParts(buffer, length); } StringView wsv_fromCStringFormat(char* buffer, size_t capacity, const char* fmt, ...) { va_list args; va_start(args, fmt); StringView view = wsv_fromCStringFormatv(buffer, capacity, fmt, args); va_end(args); return view; } /* ----- String implementation --------------------------------------------- */ String wstr_make(void) { return (String){0}; } String wstr_withCapacity(size_t capacity) { String string = wstr_make(); wstr_reserve(&string, capacity); return string; } String wstr_fromCString(const char* text) { return wstr_fromView(wsv_fromCString(text)); } String wstr_fromCStringFormat(const char* textFormat, ...) { va_list args; va_start(args, textFormat); String string = wstr_fromCStringFormatv(textFormat, args); va_end(args); return string; } String wstr_fromCStringFormatv(const char* textFormat, va_list args) { String string = wstr_make(); if (!wstr_setFormatv(&string, textFormat, args)) { wstr_freePtr(&string); } return string; } String wstr_fromView(StringView view) { String string = wstr_make(); wstr_assign(&string, view); return string; } String wstr_concat(StringView left, StringView right) { if (left.length > (size_t)-1 - right.length) { return wstr_make(); } size_t totalLength = left.length + right.length; String string = wstr_make(); if (totalLength == 0) { return string; } if (!wstr_resize(&string, totalLength)) { return string; } if (left.length > 0) { memcpy(string.data, left.data, left.length); } if (right.length > 0) { memcpy(string.data + left.length, right.data, right.length); } return string; } String wstr_adopt(char* buffer, size_t length, size_t capacity) { if (buffer == NULL) { return wstr_make(); } if (length > capacity) { length = capacity; } buffer[length] = 0; return (String){buffer, length, capacity}; } void wstr_freePtr(String* string) { if (string == NULL) { return; } if (string->data != NULL) { WSTR_FREE(string->data); } *string = wstr_make(); } void wstr_free(String string) { if (string.data != NULL) { WSTR_FREE(string.data); } } void wstr_clear(String* string) { if (string == NULL) { return; } string->length = 0; if (string->data != NULL) { string->data[0] = 0; } } StringView wstr_view(const String* string) { return wsv_fromString(string); } const char* wstr_cstr(const String* string) { return string != NULL && string->data != NULL ? string->data : ""; } bool wstr_isEmpty(const String* string) { return string == NULL || string->length == 0; } bool wstr_reserve(String* string, size_t capacity) { return wstr__grow(string, capacity); } bool wstr_resize(String* string, size_t length) { if (string == NULL) { return false; } if (!wstr__grow(string, length)) { return false; } if (length > string->length) { memset(string->data + string->length, 0, length - string->length); } string->length = length; if (string->data != NULL) { string->data[length] = 0; } return true; } String wstr_copy(const String* string) { if (string == NULL) { return wstr_make(); } return wstr_fromView(wsv_fromString(string)); } bool wstr_assign(String* string, StringView view) { if (string == NULL) { return false; } if (wstr__isAliased(string, view)) { String temp = wsv_toString(view); bool ok = wstr_assign(string, wstr_view(&temp)); wstr_free(temp); return ok; } if (!wstr_resize(string, view.length)) { return false; } if (view.length > 0) { memcpy(string->data, view.data, view.length); string->data[view.length] = 0; } return true; } bool wstr_assignCString(String* string, const char* text) { return wstr_assign(string, wsv_fromCString(text)); } bool wstr_assignCStringFormat(String* string, const char* textFormat, ...) { va_list args; va_start(args, textFormat); bool ok = wstr_assignCStringFormatv(string, textFormat, args); va_end(args); return ok; } bool wstr_assignCStringFormatv(String* string, const char* textFormat, va_list args) { return wstr_setFormatv(string, textFormat, args); } bool wstr_append(String* string, StringView view) { if (string == NULL) { return false; } if (view.length == 0) { return true; } if (wstr__isAliased(string, view)) { String temp = wsv_toString(view); bool ok = wstr_append(string, wstr_view(&temp)); wstr_free(temp); return ok; } size_t oldLength = string->length; if (!wstr_resize(string, string->length + view.length)) { return false; } memcpy(string->data + oldLength, view.data, view.length); string->data[string->length] = 0; return true; } bool wstr_appendCString(String* string, const char* text) { return wstr_append(string, wsv_fromCString(text)); } bool wstr_appendCStringFormat(String* string, const char* textFormat, ...) { va_list args; va_start(args, textFormat); bool ok = wstr_appendCStringFormatv(string, textFormat, args); va_end(args); return ok; } bool wstr_appendCStringFormatv(String* string, const char* textFormat, va_list args) { return wstr_appendFormatv(string, textFormat, args); } bool wstr_appendChar(String* string, char c) { return wstr_append(string, wsv_fromParts(&c, 1)); } bool wstr_insert(String* string, size_t index, StringView view) { if (string == NULL || index > string->length) { return false; } if (view.length == 0) { return true; } if (wstr__isAliased(string, view)) { String temp = wsv_toString(view); bool ok = wstr_insert(string, index, wstr_view(&temp)); wstr_free(temp); return ok; } size_t oldLength = string->length; if (!wstr_resize(string, oldLength + view.length)) { return false; } memmove( string->data + index + view.length, string->data + index, oldLength - index); memcpy(string->data + index, view.data, view.length); string->data[string->length] = 0; return true; } bool wstr_removeRange(String* string, size_t index, size_t length) { if (string == NULL || index > string->length) { return false; } if (length == 0 || index == string->length) { return true; } size_t clampedLength = length; if (clampedLength > string->length - index) { clampedLength = string->length - index; } memmove( string->data + index, string->data + index + clampedLength, string->length - index - clampedLength + 1); string->length -= clampedLength; return true; } bool wstr_setFormat(String* string, const char* fmt, ...) { va_list args; va_start(args, fmt); bool ok = wstr_setFormatv(string, fmt, args); va_end(args); return ok; } bool wstr_setFormatv(String* string, const char* fmt, va_list args) { if (string == NULL) { return false; } wstr_clear(string); return wstr__appendFormatAt(string, 0, fmt, args); } bool wstr_appendFormat(String* string, const char* fmt, ...) { va_list args; va_start(args, fmt); bool ok = wstr_appendFormatv(string, fmt, args); va_end(args); return ok; } bool wstr_appendFormatv(String* string, const char* fmt, va_list args) { if (string == NULL) { return false; } return wstr__appendFormatAt(string, string->length, fmt, args); } #endif /* SHL_WSTR_IMPLEMENTATION */ #endif /* SHL_WSTR_H */ ================================================ FILE: deps/include/stb/stb_image.h ================================================ /* stb_image - v2.30 - public domain image loader - http://nothings.org/stb no warranty implied; use at your own risk Do this: #define STB_IMAGE_IMPLEMENTATION before you include this file in *one* C or C++ file to create the implementation. // i.e. it should look like this: #include ... #include ... #include ... #define STB_IMAGE_IMPLEMENTATION #include "stb_image.h" You can #define STBI_ASSERT(x) before the #include to avoid using assert.h. And #define STBI_MALLOC, STBI_REALLOC, and STBI_FREE to avoid using malloc,realloc,free QUICK NOTES: Primarily of interest to game developers and other people who can avoid problematic images and only need the trivial interface JPEG baseline & progressive (12 bpc/arithmetic not supported, same as stock IJG lib) PNG 1/2/4/8/16-bit-per-channel TGA (not sure what subset, if a subset) BMP non-1bpp, non-RLE PSD (composited view only, no extra channels, 8/16 bit-per-channel) GIF (*comp always reports as 4-channel) HDR (radiance rgbE format) PIC (Softimage PIC) PNM (PPM and PGM binary only) Animated GIF still needs a proper API, but here's one way to do it: http://gist.github.com/urraka/685d9a6340b26b830d49 - decode from memory or through FILE (define STBI_NO_STDIO to remove code) - decode from arbitrary I/O callbacks - SIMD acceleration on x86/x64 (SSE2) and ARM (NEON) Full documentation under "DOCUMENTATION" below. LICENSE See end of file for license information. RECENT REVISION HISTORY: 2.30 (2024-05-31) avoid erroneous gcc warning 2.29 (2023-05-xx) optimizations 2.28 (2023-01-29) many error fixes, security errors, just tons of stuff 2.27 (2021-07-11) document stbi_info better, 16-bit PNM support, bug fixes 2.26 (2020-07-13) many minor fixes 2.25 (2020-02-02) fix warnings 2.24 (2020-02-02) fix warnings; thread-local failure_reason and flip_vertically 2.23 (2019-08-11) fix clang static analysis warning 2.22 (2019-03-04) gif fixes, fix warnings 2.21 (2019-02-25) fix typo in comment 2.20 (2019-02-07) support utf8 filenames in Windows; fix warnings and platform ifdefs 2.19 (2018-02-11) fix warning 2.18 (2018-01-30) fix warnings 2.17 (2018-01-29) bugfix, 1-bit BMP, 16-bitness query, fix warnings 2.16 (2017-07-23) all functions have 16-bit variants; optimizations; bugfixes 2.15 (2017-03-18) fix png-1,2,4; all Imagenet JPGs; no runtime SSE detection on GCC 2.14 (2017-03-03) remove deprecated STBI_JPEG_OLD; fixes for Imagenet JPGs 2.13 (2016-12-04) experimental 16-bit API, only for PNG so far; fixes 2.12 (2016-04-02) fix typo in 2.11 PSD fix that caused crashes 2.11 (2016-04-02) 16-bit PNGS; enable SSE2 in non-gcc x64 RGB-format JPEG; remove white matting in PSD; allocate large structures on the stack; correct channel count for PNG & BMP 2.10 (2016-01-22) avoid warning introduced in 2.09 2.09 (2016-01-16) 16-bit TGA; comments in PNM files; STBI_REALLOC_SIZED See end of file for full revision history. ============================ Contributors ========================= Image formats Extensions, features Sean Barrett (jpeg, png, bmp) Jetro Lauha (stbi_info) Nicolas Schulz (hdr, psd) Martin "SpartanJ" Golini (stbi_info) Jonathan Dummer (tga) James "moose2000" Brown (iPhone PNG) Jean-Marc Lienher (gif) Ben "Disch" Wenger (io callbacks) Tom Seddon (pic) Omar Cornut (1/2/4-bit PNG) Thatcher Ulrich (psd) Nicolas Guillemot (vertical flip) Ken Miller (pgm, ppm) Richard Mitton (16-bit PSD) github:urraka (animated gif) Junggon Kim (PNM comments) Christopher Forseth (animated gif) Daniel Gibson (16-bit TGA) socks-the-fox (16-bit PNG) Jeremy Sawicki (handle all ImageNet JPGs) Optimizations & bugfixes Mikhail Morozov (1-bit BMP) Fabian "ryg" Giesen Anael Seghezzi (is-16-bit query) Arseny Kapoulkine Simon Breuss (16-bit PNM) John-Mark Allen Carmelo J Fdez-Aguera Bug & warning fixes Marc LeBlanc David Woo Guillaume George Martins Mozeiko Christpher Lloyd Jerry Jansson Joseph Thomson Blazej Dariusz Roszkowski Phil Jordan Dave Moore Roy Eltham Hayaki Saito Nathan Reed Won Chun Luke Graham Johan Duparc Nick Verigakis the Horde3D community Thomas Ruf Ronny Chevalier github:rlyeh Janez Zemva John Bartholomew Michal Cichon github:romigrou Jonathan Blow Ken Hamada Tero Hanninen github:svdijk Eugene Golushkov Laurent Gomila Cort Stratton github:snagar Aruelien Pocheville Sergio Gonzalez Thibault Reuille github:Zelex Cass Everitt Ryamond Barbiero github:grim210 Paul Du Bois Engin Manap Aldo Culquicondor github:sammyhw Philipp Wiesemann Dale Weiler Oriol Ferrer Mesia github:phprus Josh Tobin Neil Bickford Matthew Gregan github:poppolopoppo Julian Raschke Gregory Mullen Christian Floisand github:darealshinji Baldur Karlsson Kevin Schmidt JR Smith github:Michaelangel007 Brad Weinberger Matvey Cherevko github:mosra Luca Sas Alexander Veselov Zack Middleton [reserved] Ryan C. Gordon [reserved] [reserved] DO NOT ADD YOUR NAME HERE Jacko Dirks To add your name to the credits, pick a random blank space in the middle and fill it. 80% of merge conflicts on stb PRs are due to people adding their name at the end of the credits. */ #ifndef STBI_INCLUDE_STB_IMAGE_H #define STBI_INCLUDE_STB_IMAGE_H // DOCUMENTATION // // Limitations: // - no 12-bit-per-channel JPEG // - no JPEGs with arithmetic coding // - GIF always returns *comp=4 // // Basic usage (see HDR discussion below for HDR usage): // int x,y,n; // unsigned char *data = stbi_load(filename, &x, &y, &n, 0); // // ... process data if not NULL ... // // ... x = width, y = height, n = # 8-bit components per pixel ... // // ... replace '0' with '1'..'4' to force that many components per pixel // // ... but 'n' will always be the number that it would have been if you said 0 // stbi_image_free(data); // // Standard parameters: // int *x -- outputs image width in pixels // int *y -- outputs image height in pixels // int *channels_in_file -- outputs # of image components in image file // int desired_channels -- if non-zero, # of image components requested in result // // The return value from an image loader is an 'unsigned char *' which points // to the pixel data, or NULL on an allocation failure or if the image is // corrupt or invalid. The pixel data consists of *y scanlines of *x pixels, // with each pixel consisting of N interleaved 8-bit components; the first // pixel pointed to is top-left-most in the image. There is no padding between // image scanlines or between pixels, regardless of format. The number of // components N is 'desired_channels' if desired_channels is non-zero, or // *channels_in_file otherwise. If desired_channels is non-zero, // *channels_in_file has the number of components that _would_ have been // output otherwise. E.g. if you set desired_channels to 4, you will always // get RGBA output, but you can check *channels_in_file to see if it's trivially // opaque because e.g. there were only 3 channels in the source image. // // An output image with N components has the following components interleaved // in this order in each pixel: // // N=#comp components // 1 grey // 2 grey, alpha // 3 red, green, blue // 4 red, green, blue, alpha // // If image loading fails for any reason, the return value will be NULL, // and *x, *y, *channels_in_file will be unchanged. The function // stbi_failure_reason() can be queried for an extremely brief, end-user // unfriendly explanation of why the load failed. Define STBI_NO_FAILURE_STRINGS // to avoid compiling these strings at all, and STBI_FAILURE_USERMSG to get slightly // more user-friendly ones. // // Paletted PNG, BMP, GIF, and PIC images are automatically depalettized. // // To query the width, height and component count of an image without having to // decode the full file, you can use the stbi_info family of functions: // // int x,y,n,ok; // ok = stbi_info(filename, &x, &y, &n); // // returns ok=1 and sets x, y, n if image is a supported format, // // 0 otherwise. // // Note that stb_image pervasively uses ints in its public API for sizes, // including sizes of memory buffers. This is now part of the API and thus // hard to change without causing breakage. As a result, the various image // loaders all have certain limits on image size; these differ somewhat // by format but generally boil down to either just under 2GB or just under // 1GB. When the decoded image would be larger than this, stb_image decoding // will fail. // // Additionally, stb_image will reject image files that have any of their // dimensions set to a larger value than the configurable STBI_MAX_DIMENSIONS, // which defaults to 2**24 = 16777216 pixels. Due to the above memory limit, // the only way to have an image with such dimensions load correctly // is for it to have a rather extreme aspect ratio. Either way, the // assumption here is that such larger images are likely to be malformed // or malicious. If you do need to load an image with individual dimensions // larger than that, and it still fits in the overall size limit, you can // #define STBI_MAX_DIMENSIONS on your own to be something larger. // // =========================================================================== // // UNICODE: // // If compiling for Windows and you wish to use Unicode filenames, compile // with // #define STBI_WINDOWS_UTF8 // and pass utf8-encoded filenames. Call stbi_convert_wchar_to_utf8 to convert // Windows wchar_t filenames to utf8. // // =========================================================================== // // Philosophy // // stb libraries are designed with the following priorities: // // 1. easy to use // 2. easy to maintain // 3. good performance // // Sometimes I let "good performance" creep up in priority over "easy to maintain", // and for best performance I may provide less-easy-to-use APIs that give higher // performance, in addition to the easy-to-use ones. Nevertheless, it's important // to keep in mind that from the standpoint of you, a client of this library, // all you care about is #1 and #3, and stb libraries DO NOT emphasize #3 above all. // // Some secondary priorities arise directly from the first two, some of which // provide more explicit reasons why performance can't be emphasized. // // - Portable ("ease of use") // - Small source code footprint ("easy to maintain") // - No dependencies ("ease of use") // // =========================================================================== // // I/O callbacks // // I/O callbacks allow you to read from arbitrary sources, like packaged // files or some other source. Data read from callbacks are processed // through a small internal buffer (currently 128 bytes) to try to reduce // overhead. // // The three functions you must define are "read" (reads some bytes of data), // "skip" (skips some bytes of data), "eof" (reports if the stream is at the end). // // =========================================================================== // // SIMD support // // The JPEG decoder will try to automatically use SIMD kernels on x86 when // supported by the compiler. For ARM Neon support, you must explicitly // request it. // // (The old do-it-yourself SIMD API is no longer supported in the current // code.) // // On x86, SSE2 will automatically be used when available based on a run-time // test; if not, the generic C versions are used as a fall-back. On ARM targets, // the typical path is to have separate builds for NEON and non-NEON devices // (at least this is true for iOS and Android). Therefore, the NEON support is // toggled by a build flag: define STBI_NEON to get NEON loops. // // If for some reason you do not want to use any of SIMD code, or if // you have issues compiling it, you can disable it entirely by // defining STBI_NO_SIMD. // // =========================================================================== // // HDR image support (disable by defining STBI_NO_HDR) // // stb_image supports loading HDR images in general, and currently the Radiance // .HDR file format specifically. You can still load any file through the existing // interface; if you attempt to load an HDR file, it will be automatically remapped // to LDR, assuming gamma 2.2 and an arbitrary scale factor defaulting to 1; // both of these constants can be reconfigured through this interface: // // stbi_hdr_to_ldr_gamma(2.2f); // stbi_hdr_to_ldr_scale(1.0f); // // (note, do not use _inverse_ constants; stbi_image will invert them // appropriately). // // Additionally, there is a new, parallel interface for loading files as // (linear) floats to preserve the full dynamic range: // // float *data = stbi_loadf(filename, &x, &y, &n, 0); // // If you load LDR images through this interface, those images will // be promoted to floating point values, run through the inverse of // constants corresponding to the above: // // stbi_ldr_to_hdr_scale(1.0f); // stbi_ldr_to_hdr_gamma(2.2f); // // Finally, given a filename (or an open file or memory block--see header // file for details) containing image data, you can query for the "most // appropriate" interface to use (that is, whether the image is HDR or // not), using: // // stbi_is_hdr(char *filename); // // =========================================================================== // // iPhone PNG support: // // We optionally support converting iPhone-formatted PNGs (which store // premultiplied BGRA) back to RGB, even though they're internally encoded // differently. To enable this conversion, call // stbi_convert_iphone_png_to_rgb(1). // // Call stbi_set_unpremultiply_on_load(1) as well to force a divide per // pixel to remove any premultiplied alpha *only* if the image file explicitly // says there's premultiplied data (currently only happens in iPhone images, // and only if iPhone convert-to-rgb processing is on). // // =========================================================================== // // ADDITIONAL CONFIGURATION // // - You can suppress implementation of any of the decoders to reduce // your code footprint by #defining one or more of the following // symbols before creating the implementation. // // STBI_NO_JPEG // STBI_NO_PNG // STBI_NO_BMP // STBI_NO_PSD // STBI_NO_TGA // STBI_NO_GIF // STBI_NO_HDR // STBI_NO_PIC // STBI_NO_PNM (.ppm and .pgm) // // - You can request *only* certain decoders and suppress all other ones // (this will be more forward-compatible, as addition of new decoders // doesn't require you to disable them explicitly): // // STBI_ONLY_JPEG // STBI_ONLY_PNG // STBI_ONLY_BMP // STBI_ONLY_PSD // STBI_ONLY_TGA // STBI_ONLY_GIF // STBI_ONLY_HDR // STBI_ONLY_PIC // STBI_ONLY_PNM (.ppm and .pgm) // // - If you use STBI_NO_PNG (or _ONLY_ without PNG), and you still // want the zlib decoder to be available, #define STBI_SUPPORT_ZLIB // // - If you define STBI_MAX_DIMENSIONS, stb_image will reject images greater // than that size (in either width or height) without further processing. // This is to let programs in the wild set an upper bound to prevent // denial-of-service attacks on untrusted data, as one could generate a // valid image of gigantic dimensions and force stb_image to allocate a // huge block of memory and spend disproportionate time decoding it. By // default this is set to (1 << 24), which is 16777216, but that's still // very big. #ifndef STBI_NO_STDIO #include #endif // STBI_NO_STDIO #define STBI_VERSION 1 enum { STBI_default = 0, // only used for desired_channels STBI_grey = 1, STBI_grey_alpha = 2, STBI_rgb = 3, STBI_rgb_alpha = 4 }; #include typedef unsigned char stbi_uc; typedef unsigned short stbi_us; #ifdef __cplusplus extern "C" { #endif #ifndef STBIDEF #ifdef STB_IMAGE_STATIC #define STBIDEF static #else #define STBIDEF extern #endif #endif ////////////////////////////////////////////////////////////////////////////// // // PRIMARY API - works on images of any type // // // load image by filename, open file, or memory buffer // typedef struct { int (*read) (void *user,char *data,int size); // fill 'data' with 'size' bytes. return number of bytes actually read void (*skip) (void *user,int n); // skip the next 'n' bytes, or 'unget' the last -n bytes if negative int (*eof) (void *user); // returns nonzero if we are at end of file/data } stbi_io_callbacks; //////////////////////////////////// // // 8-bits-per-channel interface // STBIDEF stbi_uc *stbi_load_from_memory (stbi_uc const *buffer, int len , int *x, int *y, int *channels_in_file, int desired_channels); STBIDEF stbi_uc *stbi_load_from_callbacks(stbi_io_callbacks const *clbk , void *user, int *x, int *y, int *channels_in_file, int desired_channels); #ifndef STBI_NO_STDIO STBIDEF stbi_uc *stbi_load (char const *filename, int *x, int *y, int *channels_in_file, int desired_channels); STBIDEF stbi_uc *stbi_load_from_file (FILE *f, int *x, int *y, int *channels_in_file, int desired_channels); // for stbi_load_from_file, file pointer is left pointing immediately after image #endif #ifndef STBI_NO_GIF STBIDEF stbi_uc *stbi_load_gif_from_memory(stbi_uc const *buffer, int len, int **delays, int *x, int *y, int *z, int *comp, int req_comp); #endif #ifdef STBI_WINDOWS_UTF8 STBIDEF int stbi_convert_wchar_to_utf8(char *buffer, size_t bufferlen, const wchar_t* input); #endif //////////////////////////////////// // // 16-bits-per-channel interface // STBIDEF stbi_us *stbi_load_16_from_memory (stbi_uc const *buffer, int len, int *x, int *y, int *channels_in_file, int desired_channels); STBIDEF stbi_us *stbi_load_16_from_callbacks(stbi_io_callbacks const *clbk, void *user, int *x, int *y, int *channels_in_file, int desired_channels); #ifndef STBI_NO_STDIO STBIDEF stbi_us *stbi_load_16 (char const *filename, int *x, int *y, int *channels_in_file, int desired_channels); STBIDEF stbi_us *stbi_load_from_file_16(FILE *f, int *x, int *y, int *channels_in_file, int desired_channels); #endif //////////////////////////////////// // // float-per-channel interface // #ifndef STBI_NO_LINEAR STBIDEF float *stbi_loadf_from_memory (stbi_uc const *buffer, int len, int *x, int *y, int *channels_in_file, int desired_channels); STBIDEF float *stbi_loadf_from_callbacks (stbi_io_callbacks const *clbk, void *user, int *x, int *y, int *channels_in_file, int desired_channels); #ifndef STBI_NO_STDIO STBIDEF float *stbi_loadf (char const *filename, int *x, int *y, int *channels_in_file, int desired_channels); STBIDEF float *stbi_loadf_from_file (FILE *f, int *x, int *y, int *channels_in_file, int desired_channels); #endif #endif #ifndef STBI_NO_HDR STBIDEF void stbi_hdr_to_ldr_gamma(float gamma); STBIDEF void stbi_hdr_to_ldr_scale(float scale); #endif // STBI_NO_HDR #ifndef STBI_NO_LINEAR STBIDEF void stbi_ldr_to_hdr_gamma(float gamma); STBIDEF void stbi_ldr_to_hdr_scale(float scale); #endif // STBI_NO_LINEAR // stbi_is_hdr is always defined, but always returns false if STBI_NO_HDR STBIDEF int stbi_is_hdr_from_callbacks(stbi_io_callbacks const *clbk, void *user); STBIDEF int stbi_is_hdr_from_memory(stbi_uc const *buffer, int len); #ifndef STBI_NO_STDIO STBIDEF int stbi_is_hdr (char const *filename); STBIDEF int stbi_is_hdr_from_file(FILE *f); #endif // STBI_NO_STDIO // get a VERY brief reason for failure // on most compilers (and ALL modern mainstream compilers) this is threadsafe STBIDEF const char *stbi_failure_reason (void); // free the loaded image -- this is just free() STBIDEF void stbi_image_free (void *retval_from_stbi_load); // get image dimensions & components without fully decoding STBIDEF int stbi_info_from_memory(stbi_uc const *buffer, int len, int *x, int *y, int *comp); STBIDEF int stbi_info_from_callbacks(stbi_io_callbacks const *clbk, void *user, int *x, int *y, int *comp); STBIDEF int stbi_is_16_bit_from_memory(stbi_uc const *buffer, int len); STBIDEF int stbi_is_16_bit_from_callbacks(stbi_io_callbacks const *clbk, void *user); #ifndef STBI_NO_STDIO STBIDEF int stbi_info (char const *filename, int *x, int *y, int *comp); STBIDEF int stbi_info_from_file (FILE *f, int *x, int *y, int *comp); STBIDEF int stbi_is_16_bit (char const *filename); STBIDEF int stbi_is_16_bit_from_file(FILE *f); #endif // for image formats that explicitly notate that they have premultiplied alpha, // we just return the colors as stored in the file. set this flag to force // unpremultiplication. results are undefined if the unpremultiply overflow. STBIDEF void stbi_set_unpremultiply_on_load(int flag_true_if_should_unpremultiply); // indicate whether we should process iphone images back to canonical format, // or just pass them through "as-is" STBIDEF void stbi_convert_iphone_png_to_rgb(int flag_true_if_should_convert); // flip the image vertically, so the first pixel in the output array is the bottom left STBIDEF void stbi_set_flip_vertically_on_load(int flag_true_if_should_flip); // as above, but only applies to images loaded on the thread that calls the function // this function is only available if your compiler supports thread-local variables; // calling it will fail to link if your compiler doesn't STBIDEF void stbi_set_unpremultiply_on_load_thread(int flag_true_if_should_unpremultiply); STBIDEF void stbi_convert_iphone_png_to_rgb_thread(int flag_true_if_should_convert); STBIDEF void stbi_set_flip_vertically_on_load_thread(int flag_true_if_should_flip); // ZLIB client - used by PNG, available for other purposes STBIDEF char *stbi_zlib_decode_malloc_guesssize(const char *buffer, int len, int initial_size, int *outlen); STBIDEF char *stbi_zlib_decode_malloc_guesssize_headerflag(const char *buffer, int len, int initial_size, int *outlen, int parse_header); STBIDEF char *stbi_zlib_decode_malloc(const char *buffer, int len, int *outlen); STBIDEF int stbi_zlib_decode_buffer(char *obuffer, int olen, const char *ibuffer, int ilen); STBIDEF char *stbi_zlib_decode_noheader_malloc(const char *buffer, int len, int *outlen); STBIDEF int stbi_zlib_decode_noheader_buffer(char *obuffer, int olen, const char *ibuffer, int ilen); #ifdef __cplusplus } #endif // // //// end header file ///////////////////////////////////////////////////// #endif // STBI_INCLUDE_STB_IMAGE_H #ifdef STB_IMAGE_IMPLEMENTATION #if defined(STBI_ONLY_JPEG) || defined(STBI_ONLY_PNG) || defined(STBI_ONLY_BMP) \ || defined(STBI_ONLY_TGA) || defined(STBI_ONLY_GIF) || defined(STBI_ONLY_PSD) \ || defined(STBI_ONLY_HDR) || defined(STBI_ONLY_PIC) || defined(STBI_ONLY_PNM) \ || defined(STBI_ONLY_ZLIB) #ifndef STBI_ONLY_JPEG #define STBI_NO_JPEG #endif #ifndef STBI_ONLY_PNG #define STBI_NO_PNG #endif #ifndef STBI_ONLY_BMP #define STBI_NO_BMP #endif #ifndef STBI_ONLY_PSD #define STBI_NO_PSD #endif #ifndef STBI_ONLY_TGA #define STBI_NO_TGA #endif #ifndef STBI_ONLY_GIF #define STBI_NO_GIF #endif #ifndef STBI_ONLY_HDR #define STBI_NO_HDR #endif #ifndef STBI_ONLY_PIC #define STBI_NO_PIC #endif #ifndef STBI_ONLY_PNM #define STBI_NO_PNM #endif #endif #if defined(STBI_NO_PNG) && !defined(STBI_SUPPORT_ZLIB) && !defined(STBI_NO_ZLIB) #define STBI_NO_ZLIB #endif #include #include // ptrdiff_t on osx #include #include #include #if !defined(STBI_NO_LINEAR) || !defined(STBI_NO_HDR) #include // ldexp, pow #endif #ifndef STBI_NO_STDIO #include #endif #ifndef STBI_ASSERT #include #define STBI_ASSERT(x) assert(x) #endif #ifdef __cplusplus #define STBI_EXTERN extern "C" #else #define STBI_EXTERN extern #endif #ifndef _MSC_VER #ifdef __cplusplus #define stbi_inline inline #else #define stbi_inline #endif #else #define stbi_inline __forceinline #endif #ifndef STBI_NO_THREAD_LOCALS #if defined(__cplusplus) && __cplusplus >= 201103L #define STBI_THREAD_LOCAL thread_local #elif defined(__GNUC__) && __GNUC__ < 5 #define STBI_THREAD_LOCAL __thread #elif defined(_MSC_VER) #define STBI_THREAD_LOCAL __declspec(thread) #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 201112L && !defined(__STDC_NO_THREADS__) #define STBI_THREAD_LOCAL _Thread_local #endif #ifndef STBI_THREAD_LOCAL #if defined(__GNUC__) #define STBI_THREAD_LOCAL __thread #endif #endif #endif #if defined(_MSC_VER) || defined(__SYMBIAN32__) typedef unsigned short stbi__uint16; typedef signed short stbi__int16; typedef unsigned int stbi__uint32; typedef signed int stbi__int32; #else #include typedef uint16_t stbi__uint16; typedef int16_t stbi__int16; typedef uint32_t stbi__uint32; typedef int32_t stbi__int32; #endif // should produce compiler error if size is wrong typedef unsigned char validate_uint32[sizeof(stbi__uint32)==4 ? 1 : -1]; #ifdef _MSC_VER #define STBI_NOTUSED(v) (void)(v) #else #define STBI_NOTUSED(v) (void)sizeof(v) #endif #ifdef _MSC_VER #define STBI_HAS_LROTL #endif #ifdef STBI_HAS_LROTL #define stbi_lrot(x,y) _lrotl(x,y) #else #define stbi_lrot(x,y) (((x) << (y)) | ((x) >> (-(y) & 31))) #endif #if defined(STBI_MALLOC) && defined(STBI_FREE) && (defined(STBI_REALLOC) || defined(STBI_REALLOC_SIZED)) // ok #elif !defined(STBI_MALLOC) && !defined(STBI_FREE) && !defined(STBI_REALLOC) && !defined(STBI_REALLOC_SIZED) // ok #else #error "Must define all or none of STBI_MALLOC, STBI_FREE, and STBI_REALLOC (or STBI_REALLOC_SIZED)." #endif #ifndef STBI_MALLOC #define STBI_MALLOC(sz) malloc(sz) #define STBI_REALLOC(p,newsz) realloc(p,newsz) #define STBI_FREE(p) free(p) #endif #ifndef STBI_REALLOC_SIZED #define STBI_REALLOC_SIZED(p,oldsz,newsz) STBI_REALLOC(p,newsz) #endif // x86/x64 detection #if defined(__x86_64__) || defined(_M_X64) #define STBI__X64_TARGET #elif defined(__i386) || defined(_M_IX86) #define STBI__X86_TARGET #endif #if defined(__GNUC__) && defined(STBI__X86_TARGET) && !defined(__SSE2__) && !defined(STBI_NO_SIMD) // gcc doesn't support sse2 intrinsics unless you compile with -msse2, // which in turn means it gets to use SSE2 everywhere. This is unfortunate, // but previous attempts to provide the SSE2 functions with runtime // detection caused numerous issues. The way architecture extensions are // exposed in GCC/Clang is, sadly, not really suited for one-file libs. // New behavior: if compiled with -msse2, we use SSE2 without any // detection; if not, we don't use it at all. #define STBI_NO_SIMD #endif #if defined(__MINGW32__) && defined(STBI__X86_TARGET) && !defined(STBI_MINGW_ENABLE_SSE2) && !defined(STBI_NO_SIMD) // Note that __MINGW32__ doesn't actually mean 32-bit, so we have to avoid STBI__X64_TARGET // // 32-bit MinGW wants ESP to be 16-byte aligned, but this is not in the // Windows ABI and VC++ as well as Windows DLLs don't maintain that invariant. // As a result, enabling SSE2 on 32-bit MinGW is dangerous when not // simultaneously enabling "-mstackrealign". // // See https://github.com/nothings/stb/issues/81 for more information. // // So default to no SSE2 on 32-bit MinGW. If you've read this far and added // -mstackrealign to your build settings, feel free to #define STBI_MINGW_ENABLE_SSE2. #define STBI_NO_SIMD #endif #if !defined(STBI_NO_SIMD) && (defined(STBI__X86_TARGET) || defined(STBI__X64_TARGET)) #define STBI_SSE2 #include #ifdef _MSC_VER #if _MSC_VER >= 1400 // not VC6 #include // __cpuid static int stbi__cpuid3(void) { int info[4]; __cpuid(info,1); return info[3]; } #else static int stbi__cpuid3(void) { int res; __asm { mov eax,1 cpuid mov res,edx } return res; } #endif #define STBI_SIMD_ALIGN(type, name) __declspec(align(16)) type name #if !defined(STBI_NO_JPEG) && defined(STBI_SSE2) static int stbi__sse2_available(void) { int info3 = stbi__cpuid3(); return ((info3 >> 26) & 1) != 0; } #endif #else // assume GCC-style if not VC++ #define STBI_SIMD_ALIGN(type, name) type name __attribute__((aligned(16))) #if !defined(STBI_NO_JPEG) && defined(STBI_SSE2) static int stbi__sse2_available(void) { // If we're even attempting to compile this on GCC/Clang, that means // -msse2 is on, which means the compiler is allowed to use SSE2 // instructions at will, and so are we. return 1; } #endif #endif #endif // ARM NEON #if defined(STBI_NO_SIMD) && defined(STBI_NEON) #undef STBI_NEON #endif #ifdef STBI_NEON #include #ifdef _MSC_VER #define STBI_SIMD_ALIGN(type, name) __declspec(align(16)) type name #else #define STBI_SIMD_ALIGN(type, name) type name __attribute__((aligned(16))) #endif #endif #ifndef STBI_SIMD_ALIGN #define STBI_SIMD_ALIGN(type, name) type name #endif #ifndef STBI_MAX_DIMENSIONS #define STBI_MAX_DIMENSIONS (1 << 24) #endif /////////////////////////////////////////////// // // stbi__context struct and start_xxx functions // stbi__context structure is our basic context used by all images, so it // contains all the IO context, plus some basic image information typedef struct { stbi__uint32 img_x, img_y; int img_n, img_out_n; stbi_io_callbacks io; void *io_user_data; int read_from_callbacks; int buflen; stbi_uc buffer_start[128]; int callback_already_read; stbi_uc *img_buffer, *img_buffer_end; stbi_uc *img_buffer_original, *img_buffer_original_end; } stbi__context; static void stbi__refill_buffer(stbi__context *s); // initialize a memory-decode context static void stbi__start_mem(stbi__context *s, stbi_uc const *buffer, int len) { s->io.read = NULL; s->read_from_callbacks = 0; s->callback_already_read = 0; s->img_buffer = s->img_buffer_original = (stbi_uc *) buffer; s->img_buffer_end = s->img_buffer_original_end = (stbi_uc *) buffer+len; } // initialize a callback-based context static void stbi__start_callbacks(stbi__context *s, stbi_io_callbacks *c, void *user) { s->io = *c; s->io_user_data = user; s->buflen = sizeof(s->buffer_start); s->read_from_callbacks = 1; s->callback_already_read = 0; s->img_buffer = s->img_buffer_original = s->buffer_start; stbi__refill_buffer(s); s->img_buffer_original_end = s->img_buffer_end; } #ifndef STBI_NO_STDIO static int stbi__stdio_read(void *user, char *data, int size) { return (int) fread(data,1,size,(FILE*) user); } static void stbi__stdio_skip(void *user, int n) { int ch; fseek((FILE*) user, n, SEEK_CUR); ch = fgetc((FILE*) user); /* have to read a byte to reset feof()'s flag */ if (ch != EOF) { ungetc(ch, (FILE *) user); /* push byte back onto stream if valid. */ } } static int stbi__stdio_eof(void *user) { return feof((FILE*) user) || ferror((FILE *) user); } static stbi_io_callbacks stbi__stdio_callbacks = { stbi__stdio_read, stbi__stdio_skip, stbi__stdio_eof, }; static void stbi__start_file(stbi__context *s, FILE *f) { stbi__start_callbacks(s, &stbi__stdio_callbacks, (void *) f); } //static void stop_file(stbi__context *s) { } #endif // !STBI_NO_STDIO static void stbi__rewind(stbi__context *s) { // conceptually rewind SHOULD rewind to the beginning of the stream, // but we just rewind to the beginning of the initial buffer, because // we only use it after doing 'test', which only ever looks at at most 92 bytes s->img_buffer = s->img_buffer_original; s->img_buffer_end = s->img_buffer_original_end; } enum { STBI_ORDER_RGB, STBI_ORDER_BGR }; typedef struct { int bits_per_channel; int num_channels; int channel_order; } stbi__result_info; #ifndef STBI_NO_JPEG static int stbi__jpeg_test(stbi__context *s); static void *stbi__jpeg_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri); static int stbi__jpeg_info(stbi__context *s, int *x, int *y, int *comp); #endif #ifndef STBI_NO_PNG static int stbi__png_test(stbi__context *s); static void *stbi__png_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri); static int stbi__png_info(stbi__context *s, int *x, int *y, int *comp); static int stbi__png_is16(stbi__context *s); #endif #ifndef STBI_NO_BMP static int stbi__bmp_test(stbi__context *s); static void *stbi__bmp_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri); static int stbi__bmp_info(stbi__context *s, int *x, int *y, int *comp); #endif #ifndef STBI_NO_TGA static int stbi__tga_test(stbi__context *s); static void *stbi__tga_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri); static int stbi__tga_info(stbi__context *s, int *x, int *y, int *comp); #endif #ifndef STBI_NO_PSD static int stbi__psd_test(stbi__context *s); static void *stbi__psd_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri, int bpc); static int stbi__psd_info(stbi__context *s, int *x, int *y, int *comp); static int stbi__psd_is16(stbi__context *s); #endif #ifndef STBI_NO_HDR static int stbi__hdr_test(stbi__context *s); static float *stbi__hdr_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri); static int stbi__hdr_info(stbi__context *s, int *x, int *y, int *comp); #endif #ifndef STBI_NO_PIC static int stbi__pic_test(stbi__context *s); static void *stbi__pic_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri); static int stbi__pic_info(stbi__context *s, int *x, int *y, int *comp); #endif #ifndef STBI_NO_GIF static int stbi__gif_test(stbi__context *s); static void *stbi__gif_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri); static void *stbi__load_gif_main(stbi__context *s, int **delays, int *x, int *y, int *z, int *comp, int req_comp); static int stbi__gif_info(stbi__context *s, int *x, int *y, int *comp); #endif #ifndef STBI_NO_PNM static int stbi__pnm_test(stbi__context *s); static void *stbi__pnm_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri); static int stbi__pnm_info(stbi__context *s, int *x, int *y, int *comp); static int stbi__pnm_is16(stbi__context *s); #endif static #ifdef STBI_THREAD_LOCAL STBI_THREAD_LOCAL #endif const char *stbi__g_failure_reason; STBIDEF const char *stbi_failure_reason(void) { return stbi__g_failure_reason; } #ifndef STBI_NO_FAILURE_STRINGS static int stbi__err(const char *str) { stbi__g_failure_reason = str; return 0; } #endif static void *stbi__malloc(size_t size) { return STBI_MALLOC(size); } // stb_image uses ints pervasively, including for offset calculations. // therefore the largest decoded image size we can support with the // current code, even on 64-bit targets, is INT_MAX. this is not a // significant limitation for the intended use case. // // we do, however, need to make sure our size calculations don't // overflow. hence a few helper functions for size calculations that // multiply integers together, making sure that they're non-negative // and no overflow occurs. // return 1 if the sum is valid, 0 on overflow. // negative terms are considered invalid. static int stbi__addsizes_valid(int a, int b) { if (b < 0) return 0; // now 0 <= b <= INT_MAX, hence also // 0 <= INT_MAX - b <= INTMAX. // And "a + b <= INT_MAX" (which might overflow) is the // same as a <= INT_MAX - b (no overflow) return a <= INT_MAX - b; } // returns 1 if the product is valid, 0 on overflow. // negative factors are considered invalid. static int stbi__mul2sizes_valid(int a, int b) { if (a < 0 || b < 0) return 0; if (b == 0) return 1; // mul-by-0 is always safe // portable way to check for no overflows in a*b return a <= INT_MAX/b; } #if !defined(STBI_NO_JPEG) || !defined(STBI_NO_PNG) || !defined(STBI_NO_TGA) || !defined(STBI_NO_HDR) // returns 1 if "a*b + add" has no negative terms/factors and doesn't overflow static int stbi__mad2sizes_valid(int a, int b, int add) { return stbi__mul2sizes_valid(a, b) && stbi__addsizes_valid(a*b, add); } #endif // returns 1 if "a*b*c + add" has no negative terms/factors and doesn't overflow static int stbi__mad3sizes_valid(int a, int b, int c, int add) { return stbi__mul2sizes_valid(a, b) && stbi__mul2sizes_valid(a*b, c) && stbi__addsizes_valid(a*b*c, add); } // returns 1 if "a*b*c*d + add" has no negative terms/factors and doesn't overflow #if !defined(STBI_NO_LINEAR) || !defined(STBI_NO_HDR) || !defined(STBI_NO_PNM) static int stbi__mad4sizes_valid(int a, int b, int c, int d, int add) { return stbi__mul2sizes_valid(a, b) && stbi__mul2sizes_valid(a*b, c) && stbi__mul2sizes_valid(a*b*c, d) && stbi__addsizes_valid(a*b*c*d, add); } #endif #if !defined(STBI_NO_JPEG) || !defined(STBI_NO_PNG) || !defined(STBI_NO_TGA) || !defined(STBI_NO_HDR) // mallocs with size overflow checking static void *stbi__malloc_mad2(int a, int b, int add) { if (!stbi__mad2sizes_valid(a, b, add)) return NULL; return stbi__malloc(a*b + add); } #endif static void *stbi__malloc_mad3(int a, int b, int c, int add) { if (!stbi__mad3sizes_valid(a, b, c, add)) return NULL; return stbi__malloc(a*b*c + add); } #if !defined(STBI_NO_LINEAR) || !defined(STBI_NO_HDR) || !defined(STBI_NO_PNM) static void *stbi__malloc_mad4(int a, int b, int c, int d, int add) { if (!stbi__mad4sizes_valid(a, b, c, d, add)) return NULL; return stbi__malloc(a*b*c*d + add); } #endif // returns 1 if the sum of two signed ints is valid (between -2^31 and 2^31-1 inclusive), 0 on overflow. static int stbi__addints_valid(int a, int b) { if ((a >= 0) != (b >= 0)) return 1; // a and b have different signs, so no overflow if (a < 0 && b < 0) return a >= INT_MIN - b; // same as a + b >= INT_MIN; INT_MIN - b cannot overflow since b < 0. return a <= INT_MAX - b; } // returns 1 if the product of two ints fits in a signed short, 0 on overflow. static int stbi__mul2shorts_valid(int a, int b) { if (b == 0 || b == -1) return 1; // multiplication by 0 is always 0; check for -1 so SHRT_MIN/b doesn't overflow if ((a >= 0) == (b >= 0)) return a <= SHRT_MAX/b; // product is positive, so similar to mul2sizes_valid if (b < 0) return a <= SHRT_MIN / b; // same as a * b >= SHRT_MIN return a >= SHRT_MIN / b; } // stbi__err - error // stbi__errpf - error returning pointer to float // stbi__errpuc - error returning pointer to unsigned char #ifdef STBI_NO_FAILURE_STRINGS #define stbi__err(x,y) 0 #elif defined(STBI_FAILURE_USERMSG) #define stbi__err(x,y) stbi__err(y) #else #define stbi__err(x,y) stbi__err(x) #endif #define stbi__errpf(x,y) ((float *)(size_t) (stbi__err(x,y)?NULL:NULL)) #define stbi__errpuc(x,y) ((unsigned char *)(size_t) (stbi__err(x,y)?NULL:NULL)) STBIDEF void stbi_image_free(void *retval_from_stbi_load) { STBI_FREE(retval_from_stbi_load); } #ifndef STBI_NO_LINEAR static float *stbi__ldr_to_hdr(stbi_uc *data, int x, int y, int comp); #endif #ifndef STBI_NO_HDR static stbi_uc *stbi__hdr_to_ldr(float *data, int x, int y, int comp); #endif static int stbi__vertically_flip_on_load_global = 0; STBIDEF void stbi_set_flip_vertically_on_load(int flag_true_if_should_flip) { stbi__vertically_flip_on_load_global = flag_true_if_should_flip; } #ifndef STBI_THREAD_LOCAL #define stbi__vertically_flip_on_load stbi__vertically_flip_on_load_global #else static STBI_THREAD_LOCAL int stbi__vertically_flip_on_load_local, stbi__vertically_flip_on_load_set; STBIDEF void stbi_set_flip_vertically_on_load_thread(int flag_true_if_should_flip) { stbi__vertically_flip_on_load_local = flag_true_if_should_flip; stbi__vertically_flip_on_load_set = 1; } #define stbi__vertically_flip_on_load (stbi__vertically_flip_on_load_set \ ? stbi__vertically_flip_on_load_local \ : stbi__vertically_flip_on_load_global) #endif // STBI_THREAD_LOCAL static void *stbi__load_main(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri, int bpc) { memset(ri, 0, sizeof(*ri)); // make sure it's initialized if we add new fields ri->bits_per_channel = 8; // default is 8 so most paths don't have to be changed ri->channel_order = STBI_ORDER_RGB; // all current input & output are this, but this is here so we can add BGR order ri->num_channels = 0; // test the formats with a very explicit header first (at least a FOURCC // or distinctive magic number first) #ifndef STBI_NO_PNG if (stbi__png_test(s)) return stbi__png_load(s,x,y,comp,req_comp, ri); #endif #ifndef STBI_NO_BMP if (stbi__bmp_test(s)) return stbi__bmp_load(s,x,y,comp,req_comp, ri); #endif #ifndef STBI_NO_GIF if (stbi__gif_test(s)) return stbi__gif_load(s,x,y,comp,req_comp, ri); #endif #ifndef STBI_NO_PSD if (stbi__psd_test(s)) return stbi__psd_load(s,x,y,comp,req_comp, ri, bpc); #else STBI_NOTUSED(bpc); #endif #ifndef STBI_NO_PIC if (stbi__pic_test(s)) return stbi__pic_load(s,x,y,comp,req_comp, ri); #endif // then the formats that can end up attempting to load with just 1 or 2 // bytes matching expectations; these are prone to false positives, so // try them later #ifndef STBI_NO_JPEG if (stbi__jpeg_test(s)) return stbi__jpeg_load(s,x,y,comp,req_comp, ri); #endif #ifndef STBI_NO_PNM if (stbi__pnm_test(s)) return stbi__pnm_load(s,x,y,comp,req_comp, ri); #endif #ifndef STBI_NO_HDR if (stbi__hdr_test(s)) { float *hdr = stbi__hdr_load(s, x,y,comp,req_comp, ri); return stbi__hdr_to_ldr(hdr, *x, *y, req_comp ? req_comp : *comp); } #endif #ifndef STBI_NO_TGA // test tga last because it's a crappy test! if (stbi__tga_test(s)) return stbi__tga_load(s,x,y,comp,req_comp, ri); #endif return stbi__errpuc("unknown image type", "Image not of any known type, or corrupt"); } static stbi_uc *stbi__convert_16_to_8(stbi__uint16 *orig, int w, int h, int channels) { int i; int img_len = w * h * channels; stbi_uc *reduced; reduced = (stbi_uc *) stbi__malloc(img_len); if (reduced == NULL) return stbi__errpuc("outofmem", "Out of memory"); for (i = 0; i < img_len; ++i) reduced[i] = (stbi_uc)((orig[i] >> 8) & 0xFF); // top half of each byte is sufficient approx of 16->8 bit scaling STBI_FREE(orig); return reduced; } static stbi__uint16 *stbi__convert_8_to_16(stbi_uc *orig, int w, int h, int channels) { int i; int img_len = w * h * channels; stbi__uint16 *enlarged; enlarged = (stbi__uint16 *) stbi__malloc(img_len*2); if (enlarged == NULL) return (stbi__uint16 *) stbi__errpuc("outofmem", "Out of memory"); for (i = 0; i < img_len; ++i) enlarged[i] = (stbi__uint16)((orig[i] << 8) + orig[i]); // replicate to high and low byte, maps 0->0, 255->0xffff STBI_FREE(orig); return enlarged; } static void stbi__vertical_flip(void *image, int w, int h, int bytes_per_pixel) { int row; size_t bytes_per_row = (size_t)w * bytes_per_pixel; stbi_uc temp[2048]; stbi_uc *bytes = (stbi_uc *)image; for (row = 0; row < (h>>1); row++) { stbi_uc *row0 = bytes + row*bytes_per_row; stbi_uc *row1 = bytes + (h - row - 1)*bytes_per_row; // swap row0 with row1 size_t bytes_left = bytes_per_row; while (bytes_left) { size_t bytes_copy = (bytes_left < sizeof(temp)) ? bytes_left : sizeof(temp); memcpy(temp, row0, bytes_copy); memcpy(row0, row1, bytes_copy); memcpy(row1, temp, bytes_copy); row0 += bytes_copy; row1 += bytes_copy; bytes_left -= bytes_copy; } } } #ifndef STBI_NO_GIF static void stbi__vertical_flip_slices(void *image, int w, int h, int z, int bytes_per_pixel) { int slice; int slice_size = w * h * bytes_per_pixel; stbi_uc *bytes = (stbi_uc *)image; for (slice = 0; slice < z; ++slice) { stbi__vertical_flip(bytes, w, h, bytes_per_pixel); bytes += slice_size; } } #endif static unsigned char *stbi__load_and_postprocess_8bit(stbi__context *s, int *x, int *y, int *comp, int req_comp) { stbi__result_info ri; void *result = stbi__load_main(s, x, y, comp, req_comp, &ri, 8); if (result == NULL) return NULL; // it is the responsibility of the loaders to make sure we get either 8 or 16 bit. STBI_ASSERT(ri.bits_per_channel == 8 || ri.bits_per_channel == 16); if (ri.bits_per_channel != 8) { result = stbi__convert_16_to_8((stbi__uint16 *) result, *x, *y, req_comp == 0 ? *comp : req_comp); ri.bits_per_channel = 8; } // @TODO: move stbi__convert_format to here if (stbi__vertically_flip_on_load) { int channels = req_comp ? req_comp : *comp; stbi__vertical_flip(result, *x, *y, channels * sizeof(stbi_uc)); } return (unsigned char *) result; } static stbi__uint16 *stbi__load_and_postprocess_16bit(stbi__context *s, int *x, int *y, int *comp, int req_comp) { stbi__result_info ri; void *result = stbi__load_main(s, x, y, comp, req_comp, &ri, 16); if (result == NULL) return NULL; // it is the responsibility of the loaders to make sure we get either 8 or 16 bit. STBI_ASSERT(ri.bits_per_channel == 8 || ri.bits_per_channel == 16); if (ri.bits_per_channel != 16) { result = stbi__convert_8_to_16((stbi_uc *) result, *x, *y, req_comp == 0 ? *comp : req_comp); ri.bits_per_channel = 16; } // @TODO: move stbi__convert_format16 to here // @TODO: special case RGB-to-Y (and RGBA-to-YA) for 8-bit-to-16-bit case to keep more precision if (stbi__vertically_flip_on_load) { int channels = req_comp ? req_comp : *comp; stbi__vertical_flip(result, *x, *y, channels * sizeof(stbi__uint16)); } return (stbi__uint16 *) result; } #if !defined(STBI_NO_HDR) && !defined(STBI_NO_LINEAR) static void stbi__float_postprocess(float *result, int *x, int *y, int *comp, int req_comp) { if (stbi__vertically_flip_on_load && result != NULL) { int channels = req_comp ? req_comp : *comp; stbi__vertical_flip(result, *x, *y, channels * sizeof(float)); } } #endif #ifndef STBI_NO_STDIO #if defined(_WIN32) && defined(STBI_WINDOWS_UTF8) STBI_EXTERN __declspec(dllimport) int __stdcall MultiByteToWideChar(unsigned int cp, unsigned long flags, const char *str, int cbmb, wchar_t *widestr, int cchwide); STBI_EXTERN __declspec(dllimport) int __stdcall WideCharToMultiByte(unsigned int cp, unsigned long flags, const wchar_t *widestr, int cchwide, char *str, int cbmb, const char *defchar, int *used_default); #endif #if defined(_WIN32) && defined(STBI_WINDOWS_UTF8) STBIDEF int stbi_convert_wchar_to_utf8(char *buffer, size_t bufferlen, const wchar_t* input) { return WideCharToMultiByte(65001 /* UTF8 */, 0, input, -1, buffer, (int) bufferlen, NULL, NULL); } #endif static FILE *stbi__fopen(char const *filename, char const *mode) { FILE *f; #if defined(_WIN32) && defined(STBI_WINDOWS_UTF8) wchar_t wMode[64]; wchar_t wFilename[1024]; if (0 == MultiByteToWideChar(65001 /* UTF8 */, 0, filename, -1, wFilename, sizeof(wFilename)/sizeof(*wFilename))) return 0; if (0 == MultiByteToWideChar(65001 /* UTF8 */, 0, mode, -1, wMode, sizeof(wMode)/sizeof(*wMode))) return 0; #if defined(_MSC_VER) && _MSC_VER >= 1400 if (0 != _wfopen_s(&f, wFilename, wMode)) f = 0; #else f = _wfopen(wFilename, wMode); #endif #elif defined(_MSC_VER) && _MSC_VER >= 1400 if (0 != fopen_s(&f, filename, mode)) f=0; #else f = fopen(filename, mode); #endif return f; } STBIDEF stbi_uc *stbi_load(char const *filename, int *x, int *y, int *comp, int req_comp) { FILE *f = stbi__fopen(filename, "rb"); unsigned char *result; if (!f) return stbi__errpuc("can't fopen", "Unable to open file"); result = stbi_load_from_file(f,x,y,comp,req_comp); fclose(f); return result; } STBIDEF stbi_uc *stbi_load_from_file(FILE *f, int *x, int *y, int *comp, int req_comp) { unsigned char *result; stbi__context s; stbi__start_file(&s,f); result = stbi__load_and_postprocess_8bit(&s,x,y,comp,req_comp); if (result) { // need to 'unget' all the characters in the IO buffer fseek(f, - (int) (s.img_buffer_end - s.img_buffer), SEEK_CUR); } return result; } STBIDEF stbi__uint16 *stbi_load_from_file_16(FILE *f, int *x, int *y, int *comp, int req_comp) { stbi__uint16 *result; stbi__context s; stbi__start_file(&s,f); result = stbi__load_and_postprocess_16bit(&s,x,y,comp,req_comp); if (result) { // need to 'unget' all the characters in the IO buffer fseek(f, - (int) (s.img_buffer_end - s.img_buffer), SEEK_CUR); } return result; } STBIDEF stbi_us *stbi_load_16(char const *filename, int *x, int *y, int *comp, int req_comp) { FILE *f = stbi__fopen(filename, "rb"); stbi__uint16 *result; if (!f) return (stbi_us *) stbi__errpuc("can't fopen", "Unable to open file"); result = stbi_load_from_file_16(f,x,y,comp,req_comp); fclose(f); return result; } #endif //!STBI_NO_STDIO STBIDEF stbi_us *stbi_load_16_from_memory(stbi_uc const *buffer, int len, int *x, int *y, int *channels_in_file, int desired_channels) { stbi__context s; stbi__start_mem(&s,buffer,len); return stbi__load_and_postprocess_16bit(&s,x,y,channels_in_file,desired_channels); } STBIDEF stbi_us *stbi_load_16_from_callbacks(stbi_io_callbacks const *clbk, void *user, int *x, int *y, int *channels_in_file, int desired_channels) { stbi__context s; stbi__start_callbacks(&s, (stbi_io_callbacks *)clbk, user); return stbi__load_and_postprocess_16bit(&s,x,y,channels_in_file,desired_channels); } STBIDEF stbi_uc *stbi_load_from_memory(stbi_uc const *buffer, int len, int *x, int *y, int *comp, int req_comp) { stbi__context s; stbi__start_mem(&s,buffer,len); return stbi__load_and_postprocess_8bit(&s,x,y,comp,req_comp); } STBIDEF stbi_uc *stbi_load_from_callbacks(stbi_io_callbacks const *clbk, void *user, int *x, int *y, int *comp, int req_comp) { stbi__context s; stbi__start_callbacks(&s, (stbi_io_callbacks *) clbk, user); return stbi__load_and_postprocess_8bit(&s,x,y,comp,req_comp); } #ifndef STBI_NO_GIF STBIDEF stbi_uc *stbi_load_gif_from_memory(stbi_uc const *buffer, int len, int **delays, int *x, int *y, int *z, int *comp, int req_comp) { unsigned char *result; stbi__context s; stbi__start_mem(&s,buffer,len); result = (unsigned char*) stbi__load_gif_main(&s, delays, x, y, z, comp, req_comp); if (stbi__vertically_flip_on_load) { stbi__vertical_flip_slices( result, *x, *y, *z, *comp ); } return result; } #endif #ifndef STBI_NO_LINEAR static float *stbi__loadf_main(stbi__context *s, int *x, int *y, int *comp, int req_comp) { unsigned char *data; #ifndef STBI_NO_HDR if (stbi__hdr_test(s)) { stbi__result_info ri; float *hdr_data = stbi__hdr_load(s,x,y,comp,req_comp, &ri); if (hdr_data) stbi__float_postprocess(hdr_data,x,y,comp,req_comp); return hdr_data; } #endif data = stbi__load_and_postprocess_8bit(s, x, y, comp, req_comp); if (data) return stbi__ldr_to_hdr(data, *x, *y, req_comp ? req_comp : *comp); return stbi__errpf("unknown image type", "Image not of any known type, or corrupt"); } STBIDEF float *stbi_loadf_from_memory(stbi_uc const *buffer, int len, int *x, int *y, int *comp, int req_comp) { stbi__context s; stbi__start_mem(&s,buffer,len); return stbi__loadf_main(&s,x,y,comp,req_comp); } STBIDEF float *stbi_loadf_from_callbacks(stbi_io_callbacks const *clbk, void *user, int *x, int *y, int *comp, int req_comp) { stbi__context s; stbi__start_callbacks(&s, (stbi_io_callbacks *) clbk, user); return stbi__loadf_main(&s,x,y,comp,req_comp); } #ifndef STBI_NO_STDIO STBIDEF float *stbi_loadf(char const *filename, int *x, int *y, int *comp, int req_comp) { float *result; FILE *f = stbi__fopen(filename, "rb"); if (!f) return stbi__errpf("can't fopen", "Unable to open file"); result = stbi_loadf_from_file(f,x,y,comp,req_comp); fclose(f); return result; } STBIDEF float *stbi_loadf_from_file(FILE *f, int *x, int *y, int *comp, int req_comp) { stbi__context s; stbi__start_file(&s,f); return stbi__loadf_main(&s,x,y,comp,req_comp); } #endif // !STBI_NO_STDIO #endif // !STBI_NO_LINEAR // these is-hdr-or-not is defined independent of whether STBI_NO_LINEAR is // defined, for API simplicity; if STBI_NO_LINEAR is defined, it always // reports false! STBIDEF int stbi_is_hdr_from_memory(stbi_uc const *buffer, int len) { #ifndef STBI_NO_HDR stbi__context s; stbi__start_mem(&s,buffer,len); return stbi__hdr_test(&s); #else STBI_NOTUSED(buffer); STBI_NOTUSED(len); return 0; #endif } #ifndef STBI_NO_STDIO STBIDEF int stbi_is_hdr (char const *filename) { FILE *f = stbi__fopen(filename, "rb"); int result=0; if (f) { result = stbi_is_hdr_from_file(f); fclose(f); } return result; } STBIDEF int stbi_is_hdr_from_file(FILE *f) { #ifndef STBI_NO_HDR long pos = ftell(f); int res; stbi__context s; stbi__start_file(&s,f); res = stbi__hdr_test(&s); fseek(f, pos, SEEK_SET); return res; #else STBI_NOTUSED(f); return 0; #endif } #endif // !STBI_NO_STDIO STBIDEF int stbi_is_hdr_from_callbacks(stbi_io_callbacks const *clbk, void *user) { #ifndef STBI_NO_HDR stbi__context s; stbi__start_callbacks(&s, (stbi_io_callbacks *) clbk, user); return stbi__hdr_test(&s); #else STBI_NOTUSED(clbk); STBI_NOTUSED(user); return 0; #endif } #ifndef STBI_NO_LINEAR static float stbi__l2h_gamma=2.2f, stbi__l2h_scale=1.0f; STBIDEF void stbi_ldr_to_hdr_gamma(float gamma) { stbi__l2h_gamma = gamma; } STBIDEF void stbi_ldr_to_hdr_scale(float scale) { stbi__l2h_scale = scale; } #endif static float stbi__h2l_gamma_i=1.0f/2.2f, stbi__h2l_scale_i=1.0f; STBIDEF void stbi_hdr_to_ldr_gamma(float gamma) { stbi__h2l_gamma_i = 1/gamma; } STBIDEF void stbi_hdr_to_ldr_scale(float scale) { stbi__h2l_scale_i = 1/scale; } ////////////////////////////////////////////////////////////////////////////// // // Common code used by all image loaders // enum { STBI__SCAN_load=0, STBI__SCAN_type, STBI__SCAN_header }; static void stbi__refill_buffer(stbi__context *s) { int n = (s->io.read)(s->io_user_data,(char*)s->buffer_start,s->buflen); s->callback_already_read += (int) (s->img_buffer - s->img_buffer_original); if (n == 0) { // at end of file, treat same as if from memory, but need to handle case // where s->img_buffer isn't pointing to safe memory, e.g. 0-byte file s->read_from_callbacks = 0; s->img_buffer = s->buffer_start; s->img_buffer_end = s->buffer_start+1; *s->img_buffer = 0; } else { s->img_buffer = s->buffer_start; s->img_buffer_end = s->buffer_start + n; } } stbi_inline static stbi_uc stbi__get8(stbi__context *s) { if (s->img_buffer < s->img_buffer_end) return *s->img_buffer++; if (s->read_from_callbacks) { stbi__refill_buffer(s); return *s->img_buffer++; } return 0; } #if defined(STBI_NO_JPEG) && defined(STBI_NO_HDR) && defined(STBI_NO_PIC) && defined(STBI_NO_PNM) // nothing #else stbi_inline static int stbi__at_eof(stbi__context *s) { if (s->io.read) { if (!(s->io.eof)(s->io_user_data)) return 0; // if feof() is true, check if buffer = end // special case: we've only got the special 0 character at the end if (s->read_from_callbacks == 0) return 1; } return s->img_buffer >= s->img_buffer_end; } #endif #if defined(STBI_NO_JPEG) && defined(STBI_NO_PNG) && defined(STBI_NO_BMP) && defined(STBI_NO_PSD) && defined(STBI_NO_TGA) && defined(STBI_NO_GIF) && defined(STBI_NO_PIC) // nothing #else static void stbi__skip(stbi__context *s, int n) { if (n == 0) return; // already there! if (n < 0) { s->img_buffer = s->img_buffer_end; return; } if (s->io.read) { int blen = (int) (s->img_buffer_end - s->img_buffer); if (blen < n) { s->img_buffer = s->img_buffer_end; (s->io.skip)(s->io_user_data, n - blen); return; } } s->img_buffer += n; } #endif #if defined(STBI_NO_PNG) && defined(STBI_NO_TGA) && defined(STBI_NO_HDR) && defined(STBI_NO_PNM) // nothing #else static int stbi__getn(stbi__context *s, stbi_uc *buffer, int n) { if (s->io.read) { int blen = (int) (s->img_buffer_end - s->img_buffer); if (blen < n) { int res, count; memcpy(buffer, s->img_buffer, blen); count = (s->io.read)(s->io_user_data, (char*) buffer + blen, n - blen); res = (count == (n-blen)); s->img_buffer = s->img_buffer_end; return res; } } if (s->img_buffer+n <= s->img_buffer_end) { memcpy(buffer, s->img_buffer, n); s->img_buffer += n; return 1; } else return 0; } #endif #if defined(STBI_NO_JPEG) && defined(STBI_NO_PNG) && defined(STBI_NO_PSD) && defined(STBI_NO_PIC) // nothing #else static int stbi__get16be(stbi__context *s) { int z = stbi__get8(s); return (z << 8) + stbi__get8(s); } #endif #if defined(STBI_NO_PNG) && defined(STBI_NO_PSD) && defined(STBI_NO_PIC) // nothing #else static stbi__uint32 stbi__get32be(stbi__context *s) { stbi__uint32 z = stbi__get16be(s); return (z << 16) + stbi__get16be(s); } #endif #if defined(STBI_NO_BMP) && defined(STBI_NO_TGA) && defined(STBI_NO_GIF) // nothing #else static int stbi__get16le(stbi__context *s) { int z = stbi__get8(s); return z + (stbi__get8(s) << 8); } #endif #ifndef STBI_NO_BMP static stbi__uint32 stbi__get32le(stbi__context *s) { stbi__uint32 z = stbi__get16le(s); z += (stbi__uint32)stbi__get16le(s) << 16; return z; } #endif #define STBI__BYTECAST(x) ((stbi_uc) ((x) & 255)) // truncate int to byte without warnings #if defined(STBI_NO_JPEG) && defined(STBI_NO_PNG) && defined(STBI_NO_BMP) && defined(STBI_NO_PSD) && defined(STBI_NO_TGA) && defined(STBI_NO_GIF) && defined(STBI_NO_PIC) && defined(STBI_NO_PNM) // nothing #else ////////////////////////////////////////////////////////////////////////////// // // generic converter from built-in img_n to req_comp // individual types do this automatically as much as possible (e.g. jpeg // does all cases internally since it needs to colorspace convert anyway, // and it never has alpha, so very few cases ). png can automatically // interleave an alpha=255 channel, but falls back to this for other cases // // assume data buffer is malloced, so malloc a new one and free that one // only failure mode is malloc failing static stbi_uc stbi__compute_y(int r, int g, int b) { return (stbi_uc) (((r*77) + (g*150) + (29*b)) >> 8); } #endif #if defined(STBI_NO_PNG) && defined(STBI_NO_BMP) && defined(STBI_NO_PSD) && defined(STBI_NO_TGA) && defined(STBI_NO_GIF) && defined(STBI_NO_PIC) && defined(STBI_NO_PNM) // nothing #else static unsigned char *stbi__convert_format(unsigned char *data, int img_n, int req_comp, unsigned int x, unsigned int y) { int i,j; unsigned char *good; if (req_comp == img_n) return data; STBI_ASSERT(req_comp >= 1 && req_comp <= 4); good = (unsigned char *) stbi__malloc_mad3(req_comp, x, y, 0); if (good == NULL) { STBI_FREE(data); return stbi__errpuc("outofmem", "Out of memory"); } for (j=0; j < (int) y; ++j) { unsigned char *src = data + j * x * img_n ; unsigned char *dest = good + j * x * req_comp; #define STBI__COMBO(a,b) ((a)*8+(b)) #define STBI__CASE(a,b) case STBI__COMBO(a,b): for(i=x-1; i >= 0; --i, src += a, dest += b) // convert source image with img_n components to one with req_comp components; // avoid switch per pixel, so use switch per scanline and massive macros switch (STBI__COMBO(img_n, req_comp)) { STBI__CASE(1,2) { dest[0]=src[0]; dest[1]=255; } break; STBI__CASE(1,3) { dest[0]=dest[1]=dest[2]=src[0]; } break; STBI__CASE(1,4) { dest[0]=dest[1]=dest[2]=src[0]; dest[3]=255; } break; STBI__CASE(2,1) { dest[0]=src[0]; } break; STBI__CASE(2,3) { dest[0]=dest[1]=dest[2]=src[0]; } break; STBI__CASE(2,4) { dest[0]=dest[1]=dest[2]=src[0]; dest[3]=src[1]; } break; STBI__CASE(3,4) { dest[0]=src[0];dest[1]=src[1];dest[2]=src[2];dest[3]=255; } break; STBI__CASE(3,1) { dest[0]=stbi__compute_y(src[0],src[1],src[2]); } break; STBI__CASE(3,2) { dest[0]=stbi__compute_y(src[0],src[1],src[2]); dest[1] = 255; } break; STBI__CASE(4,1) { dest[0]=stbi__compute_y(src[0],src[1],src[2]); } break; STBI__CASE(4,2) { dest[0]=stbi__compute_y(src[0],src[1],src[2]); dest[1] = src[3]; } break; STBI__CASE(4,3) { dest[0]=src[0];dest[1]=src[1];dest[2]=src[2]; } break; default: STBI_ASSERT(0); STBI_FREE(data); STBI_FREE(good); return stbi__errpuc("unsupported", "Unsupported format conversion"); } #undef STBI__CASE } STBI_FREE(data); return good; } #endif #if defined(STBI_NO_PNG) && defined(STBI_NO_PSD) // nothing #else static stbi__uint16 stbi__compute_y_16(int r, int g, int b) { return (stbi__uint16) (((r*77) + (g*150) + (29*b)) >> 8); } #endif #if defined(STBI_NO_PNG) && defined(STBI_NO_PSD) // nothing #else static stbi__uint16 *stbi__convert_format16(stbi__uint16 *data, int img_n, int req_comp, unsigned int x, unsigned int y) { int i,j; stbi__uint16 *good; if (req_comp == img_n) return data; STBI_ASSERT(req_comp >= 1 && req_comp <= 4); good = (stbi__uint16 *) stbi__malloc(req_comp * x * y * 2); if (good == NULL) { STBI_FREE(data); return (stbi__uint16 *) stbi__errpuc("outofmem", "Out of memory"); } for (j=0; j < (int) y; ++j) { stbi__uint16 *src = data + j * x * img_n ; stbi__uint16 *dest = good + j * x * req_comp; #define STBI__COMBO(a,b) ((a)*8+(b)) #define STBI__CASE(a,b) case STBI__COMBO(a,b): for(i=x-1; i >= 0; --i, src += a, dest += b) // convert source image with img_n components to one with req_comp components; // avoid switch per pixel, so use switch per scanline and massive macros switch (STBI__COMBO(img_n, req_comp)) { STBI__CASE(1,2) { dest[0]=src[0]; dest[1]=0xffff; } break; STBI__CASE(1,3) { dest[0]=dest[1]=dest[2]=src[0]; } break; STBI__CASE(1,4) { dest[0]=dest[1]=dest[2]=src[0]; dest[3]=0xffff; } break; STBI__CASE(2,1) { dest[0]=src[0]; } break; STBI__CASE(2,3) { dest[0]=dest[1]=dest[2]=src[0]; } break; STBI__CASE(2,4) { dest[0]=dest[1]=dest[2]=src[0]; dest[3]=src[1]; } break; STBI__CASE(3,4) { dest[0]=src[0];dest[1]=src[1];dest[2]=src[2];dest[3]=0xffff; } break; STBI__CASE(3,1) { dest[0]=stbi__compute_y_16(src[0],src[1],src[2]); } break; STBI__CASE(3,2) { dest[0]=stbi__compute_y_16(src[0],src[1],src[2]); dest[1] = 0xffff; } break; STBI__CASE(4,1) { dest[0]=stbi__compute_y_16(src[0],src[1],src[2]); } break; STBI__CASE(4,2) { dest[0]=stbi__compute_y_16(src[0],src[1],src[2]); dest[1] = src[3]; } break; STBI__CASE(4,3) { dest[0]=src[0];dest[1]=src[1];dest[2]=src[2]; } break; default: STBI_ASSERT(0); STBI_FREE(data); STBI_FREE(good); return (stbi__uint16*) stbi__errpuc("unsupported", "Unsupported format conversion"); } #undef STBI__CASE } STBI_FREE(data); return good; } #endif #ifndef STBI_NO_LINEAR static float *stbi__ldr_to_hdr(stbi_uc *data, int x, int y, int comp) { int i,k,n; float *output; if (!data) return NULL; output = (float *) stbi__malloc_mad4(x, y, comp, sizeof(float), 0); if (output == NULL) { STBI_FREE(data); return stbi__errpf("outofmem", "Out of memory"); } // compute number of non-alpha components if (comp & 1) n = comp; else n = comp-1; for (i=0; i < x*y; ++i) { for (k=0; k < n; ++k) { output[i*comp + k] = (float) (pow(data[i*comp+k]/255.0f, stbi__l2h_gamma) * stbi__l2h_scale); } } if (n < comp) { for (i=0; i < x*y; ++i) { output[i*comp + n] = data[i*comp + n]/255.0f; } } STBI_FREE(data); return output; } #endif #ifndef STBI_NO_HDR #define stbi__float2int(x) ((int) (x)) static stbi_uc *stbi__hdr_to_ldr(float *data, int x, int y, int comp) { int i,k,n; stbi_uc *output; if (!data) return NULL; output = (stbi_uc *) stbi__malloc_mad3(x, y, comp, 0); if (output == NULL) { STBI_FREE(data); return stbi__errpuc("outofmem", "Out of memory"); } // compute number of non-alpha components if (comp & 1) n = comp; else n = comp-1; for (i=0; i < x*y; ++i) { for (k=0; k < n; ++k) { float z = (float) pow(data[i*comp+k]*stbi__h2l_scale_i, stbi__h2l_gamma_i) * 255 + 0.5f; if (z < 0) z = 0; if (z > 255) z = 255; output[i*comp + k] = (stbi_uc) stbi__float2int(z); } if (k < comp) { float z = data[i*comp+k] * 255 + 0.5f; if (z < 0) z = 0; if (z > 255) z = 255; output[i*comp + k] = (stbi_uc) stbi__float2int(z); } } STBI_FREE(data); return output; } #endif ////////////////////////////////////////////////////////////////////////////// // // "baseline" JPEG/JFIF decoder // // simple implementation // - doesn't support delayed output of y-dimension // - simple interface (only one output format: 8-bit interleaved RGB) // - doesn't try to recover corrupt jpegs // - doesn't allow partial loading, loading multiple at once // - still fast on x86 (copying globals into locals doesn't help x86) // - allocates lots of intermediate memory (full size of all components) // - non-interleaved case requires this anyway // - allows good upsampling (see next) // high-quality // - upsampled channels are bilinearly interpolated, even across blocks // - quality integer IDCT derived from IJG's 'slow' // performance // - fast huffman; reasonable integer IDCT // - some SIMD kernels for common paths on targets with SSE2/NEON // - uses a lot of intermediate memory, could cache poorly #ifndef STBI_NO_JPEG // huffman decoding acceleration #define FAST_BITS 9 // larger handles more cases; smaller stomps less cache typedef struct { stbi_uc fast[1 << FAST_BITS]; // weirdly, repacking this into AoS is a 10% speed loss, instead of a win stbi__uint16 code[256]; stbi_uc values[256]; stbi_uc size[257]; unsigned int maxcode[18]; int delta[17]; // old 'firstsymbol' - old 'firstcode' } stbi__huffman; typedef struct { stbi__context *s; stbi__huffman huff_dc[4]; stbi__huffman huff_ac[4]; stbi__uint16 dequant[4][64]; stbi__int16 fast_ac[4][1 << FAST_BITS]; // sizes for components, interleaved MCUs int img_h_max, img_v_max; int img_mcu_x, img_mcu_y; int img_mcu_w, img_mcu_h; // definition of jpeg image component struct { int id; int h,v; int tq; int hd,ha; int dc_pred; int x,y,w2,h2; stbi_uc *data; void *raw_data, *raw_coeff; stbi_uc *linebuf; short *coeff; // progressive only int coeff_w, coeff_h; // number of 8x8 coefficient blocks } img_comp[4]; stbi__uint32 code_buffer; // jpeg entropy-coded buffer int code_bits; // number of valid bits unsigned char marker; // marker seen while filling entropy buffer int nomore; // flag if we saw a marker so must stop int progressive; int spec_start; int spec_end; int succ_high; int succ_low; int eob_run; int jfif; int app14_color_transform; // Adobe APP14 tag int rgb; int scan_n, order[4]; int restart_interval, todo; // kernels void (*idct_block_kernel)(stbi_uc *out, int out_stride, short data[64]); void (*YCbCr_to_RGB_kernel)(stbi_uc *out, const stbi_uc *y, const stbi_uc *pcb, const stbi_uc *pcr, int count, int step); stbi_uc *(*resample_row_hv_2_kernel)(stbi_uc *out, stbi_uc *in_near, stbi_uc *in_far, int w, int hs); } stbi__jpeg; static int stbi__build_huffman(stbi__huffman *h, int *count) { int i,j,k=0; unsigned int code; // build size list for each symbol (from JPEG spec) for (i=0; i < 16; ++i) { for (j=0; j < count[i]; ++j) { h->size[k++] = (stbi_uc) (i+1); if(k >= 257) return stbi__err("bad size list","Corrupt JPEG"); } } h->size[k] = 0; // compute actual symbols (from jpeg spec) code = 0; k = 0; for(j=1; j <= 16; ++j) { // compute delta to add to code to compute symbol id h->delta[j] = k - code; if (h->size[k] == j) { while (h->size[k] == j) h->code[k++] = (stbi__uint16) (code++); if (code-1 >= (1u << j)) return stbi__err("bad code lengths","Corrupt JPEG"); } // compute largest code + 1 for this size, preshifted as needed later h->maxcode[j] = code << (16-j); code <<= 1; } h->maxcode[j] = 0xffffffff; // build non-spec acceleration table; 255 is flag for not-accelerated memset(h->fast, 255, 1 << FAST_BITS); for (i=0; i < k; ++i) { int s = h->size[i]; if (s <= FAST_BITS) { int c = h->code[i] << (FAST_BITS-s); int m = 1 << (FAST_BITS-s); for (j=0; j < m; ++j) { h->fast[c+j] = (stbi_uc) i; } } } return 1; } // build a table that decodes both magnitude and value of small ACs in // one go. static void stbi__build_fast_ac(stbi__int16 *fast_ac, stbi__huffman *h) { int i; for (i=0; i < (1 << FAST_BITS); ++i) { stbi_uc fast = h->fast[i]; fast_ac[i] = 0; if (fast < 255) { int rs = h->values[fast]; int run = (rs >> 4) & 15; int magbits = rs & 15; int len = h->size[fast]; if (magbits && len + magbits <= FAST_BITS) { // magnitude code followed by receive_extend code int k = ((i << len) & ((1 << FAST_BITS) - 1)) >> (FAST_BITS - magbits); int m = 1 << (magbits - 1); if (k < m) k += (~0U << magbits) + 1; // if the result is small enough, we can fit it in fast_ac table if (k >= -128 && k <= 127) fast_ac[i] = (stbi__int16) ((k * 256) + (run * 16) + (len + magbits)); } } } } static void stbi__grow_buffer_unsafe(stbi__jpeg *j) { do { unsigned int b = j->nomore ? 0 : stbi__get8(j->s); if (b == 0xff) { int c = stbi__get8(j->s); while (c == 0xff) c = stbi__get8(j->s); // consume fill bytes if (c != 0) { j->marker = (unsigned char) c; j->nomore = 1; return; } } j->code_buffer |= b << (24 - j->code_bits); j->code_bits += 8; } while (j->code_bits <= 24); } // (1 << n) - 1 static const stbi__uint32 stbi__bmask[17]={0,1,3,7,15,31,63,127,255,511,1023,2047,4095,8191,16383,32767,65535}; // decode a jpeg huffman value from the bitstream stbi_inline static int stbi__jpeg_huff_decode(stbi__jpeg *j, stbi__huffman *h) { unsigned int temp; int c,k; if (j->code_bits < 16) stbi__grow_buffer_unsafe(j); // look at the top FAST_BITS and determine what symbol ID it is, // if the code is <= FAST_BITS c = (j->code_buffer >> (32 - FAST_BITS)) & ((1 << FAST_BITS)-1); k = h->fast[c]; if (k < 255) { int s = h->size[k]; if (s > j->code_bits) return -1; j->code_buffer <<= s; j->code_bits -= s; return h->values[k]; } // naive test is to shift the code_buffer down so k bits are // valid, then test against maxcode. To speed this up, we've // preshifted maxcode left so that it has (16-k) 0s at the // end; in other words, regardless of the number of bits, it // wants to be compared against something shifted to have 16; // that way we don't need to shift inside the loop. temp = j->code_buffer >> 16; for (k=FAST_BITS+1 ; ; ++k) if (temp < h->maxcode[k]) break; if (k == 17) { // error! code not found j->code_bits -= 16; return -1; } if (k > j->code_bits) return -1; // convert the huffman code to the symbol id c = ((j->code_buffer >> (32 - k)) & stbi__bmask[k]) + h->delta[k]; if(c < 0 || c >= 256) // symbol id out of bounds! return -1; STBI_ASSERT((((j->code_buffer) >> (32 - h->size[c])) & stbi__bmask[h->size[c]]) == h->code[c]); // convert the id to a symbol j->code_bits -= k; j->code_buffer <<= k; return h->values[c]; } // bias[n] = (-1<code_bits < n) stbi__grow_buffer_unsafe(j); if (j->code_bits < n) return 0; // ran out of bits from stream, return 0s intead of continuing sgn = j->code_buffer >> 31; // sign bit always in MSB; 0 if MSB clear (positive), 1 if MSB set (negative) k = stbi_lrot(j->code_buffer, n); j->code_buffer = k & ~stbi__bmask[n]; k &= stbi__bmask[n]; j->code_bits -= n; return k + (stbi__jbias[n] & (sgn - 1)); } // get some unsigned bits stbi_inline static int stbi__jpeg_get_bits(stbi__jpeg *j, int n) { unsigned int k; if (j->code_bits < n) stbi__grow_buffer_unsafe(j); if (j->code_bits < n) return 0; // ran out of bits from stream, return 0s intead of continuing k = stbi_lrot(j->code_buffer, n); j->code_buffer = k & ~stbi__bmask[n]; k &= stbi__bmask[n]; j->code_bits -= n; return k; } stbi_inline static int stbi__jpeg_get_bit(stbi__jpeg *j) { unsigned int k; if (j->code_bits < 1) stbi__grow_buffer_unsafe(j); if (j->code_bits < 1) return 0; // ran out of bits from stream, return 0s intead of continuing k = j->code_buffer; j->code_buffer <<= 1; --j->code_bits; return k & 0x80000000; } // given a value that's at position X in the zigzag stream, // where does it appear in the 8x8 matrix coded as row-major? static const stbi_uc stbi__jpeg_dezigzag[64+15] = { 0, 1, 8, 16, 9, 2, 3, 10, 17, 24, 32, 25, 18, 11, 4, 5, 12, 19, 26, 33, 40, 48, 41, 34, 27, 20, 13, 6, 7, 14, 21, 28, 35, 42, 49, 56, 57, 50, 43, 36, 29, 22, 15, 23, 30, 37, 44, 51, 58, 59, 52, 45, 38, 31, 39, 46, 53, 60, 61, 54, 47, 55, 62, 63, // let corrupt input sample past end 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63 }; // decode one 64-entry block-- static int stbi__jpeg_decode_block(stbi__jpeg *j, short data[64], stbi__huffman *hdc, stbi__huffman *hac, stbi__int16 *fac, int b, stbi__uint16 *dequant) { int diff,dc,k; int t; if (j->code_bits < 16) stbi__grow_buffer_unsafe(j); t = stbi__jpeg_huff_decode(j, hdc); if (t < 0 || t > 15) return stbi__err("bad huffman code","Corrupt JPEG"); // 0 all the ac values now so we can do it 32-bits at a time memset(data,0,64*sizeof(data[0])); diff = t ? stbi__extend_receive(j, t) : 0; if (!stbi__addints_valid(j->img_comp[b].dc_pred, diff)) return stbi__err("bad delta","Corrupt JPEG"); dc = j->img_comp[b].dc_pred + diff; j->img_comp[b].dc_pred = dc; if (!stbi__mul2shorts_valid(dc, dequant[0])) return stbi__err("can't merge dc and ac", "Corrupt JPEG"); data[0] = (short) (dc * dequant[0]); // decode AC components, see JPEG spec k = 1; do { unsigned int zig; int c,r,s; if (j->code_bits < 16) stbi__grow_buffer_unsafe(j); c = (j->code_buffer >> (32 - FAST_BITS)) & ((1 << FAST_BITS)-1); r = fac[c]; if (r) { // fast-AC path k += (r >> 4) & 15; // run s = r & 15; // combined length if (s > j->code_bits) return stbi__err("bad huffman code", "Combined length longer than code bits available"); j->code_buffer <<= s; j->code_bits -= s; // decode into unzigzag'd location zig = stbi__jpeg_dezigzag[k++]; data[zig] = (short) ((r >> 8) * dequant[zig]); } else { int rs = stbi__jpeg_huff_decode(j, hac); if (rs < 0) return stbi__err("bad huffman code","Corrupt JPEG"); s = rs & 15; r = rs >> 4; if (s == 0) { if (rs != 0xf0) break; // end block k += 16; } else { k += r; // decode into unzigzag'd location zig = stbi__jpeg_dezigzag[k++]; data[zig] = (short) (stbi__extend_receive(j,s) * dequant[zig]); } } } while (k < 64); return 1; } static int stbi__jpeg_decode_block_prog_dc(stbi__jpeg *j, short data[64], stbi__huffman *hdc, int b) { int diff,dc; int t; if (j->spec_end != 0) return stbi__err("can't merge dc and ac", "Corrupt JPEG"); if (j->code_bits < 16) stbi__grow_buffer_unsafe(j); if (j->succ_high == 0) { // first scan for DC coefficient, must be first memset(data,0,64*sizeof(data[0])); // 0 all the ac values now t = stbi__jpeg_huff_decode(j, hdc); if (t < 0 || t > 15) return stbi__err("can't merge dc and ac", "Corrupt JPEG"); diff = t ? stbi__extend_receive(j, t) : 0; if (!stbi__addints_valid(j->img_comp[b].dc_pred, diff)) return stbi__err("bad delta", "Corrupt JPEG"); dc = j->img_comp[b].dc_pred + diff; j->img_comp[b].dc_pred = dc; if (!stbi__mul2shorts_valid(dc, 1 << j->succ_low)) return stbi__err("can't merge dc and ac", "Corrupt JPEG"); data[0] = (short) (dc * (1 << j->succ_low)); } else { // refinement scan for DC coefficient if (stbi__jpeg_get_bit(j)) data[0] += (short) (1 << j->succ_low); } return 1; } // @OPTIMIZE: store non-zigzagged during the decode passes, // and only de-zigzag when dequantizing static int stbi__jpeg_decode_block_prog_ac(stbi__jpeg *j, short data[64], stbi__huffman *hac, stbi__int16 *fac) { int k; if (j->spec_start == 0) return stbi__err("can't merge dc and ac", "Corrupt JPEG"); if (j->succ_high == 0) { int shift = j->succ_low; if (j->eob_run) { --j->eob_run; return 1; } k = j->spec_start; do { unsigned int zig; int c,r,s; if (j->code_bits < 16) stbi__grow_buffer_unsafe(j); c = (j->code_buffer >> (32 - FAST_BITS)) & ((1 << FAST_BITS)-1); r = fac[c]; if (r) { // fast-AC path k += (r >> 4) & 15; // run s = r & 15; // combined length if (s > j->code_bits) return stbi__err("bad huffman code", "Combined length longer than code bits available"); j->code_buffer <<= s; j->code_bits -= s; zig = stbi__jpeg_dezigzag[k++]; data[zig] = (short) ((r >> 8) * (1 << shift)); } else { int rs = stbi__jpeg_huff_decode(j, hac); if (rs < 0) return stbi__err("bad huffman code","Corrupt JPEG"); s = rs & 15; r = rs >> 4; if (s == 0) { if (r < 15) { j->eob_run = (1 << r); if (r) j->eob_run += stbi__jpeg_get_bits(j, r); --j->eob_run; break; } k += 16; } else { k += r; zig = stbi__jpeg_dezigzag[k++]; data[zig] = (short) (stbi__extend_receive(j,s) * (1 << shift)); } } } while (k <= j->spec_end); } else { // refinement scan for these AC coefficients short bit = (short) (1 << j->succ_low); if (j->eob_run) { --j->eob_run; for (k = j->spec_start; k <= j->spec_end; ++k) { short *p = &data[stbi__jpeg_dezigzag[k]]; if (*p != 0) if (stbi__jpeg_get_bit(j)) if ((*p & bit)==0) { if (*p > 0) *p += bit; else *p -= bit; } } } else { k = j->spec_start; do { int r,s; int rs = stbi__jpeg_huff_decode(j, hac); // @OPTIMIZE see if we can use the fast path here, advance-by-r is so slow, eh if (rs < 0) return stbi__err("bad huffman code","Corrupt JPEG"); s = rs & 15; r = rs >> 4; if (s == 0) { if (r < 15) { j->eob_run = (1 << r) - 1; if (r) j->eob_run += stbi__jpeg_get_bits(j, r); r = 64; // force end of block } else { // r=15 s=0 should write 16 0s, so we just do // a run of 15 0s and then write s (which is 0), // so we don't have to do anything special here } } else { if (s != 1) return stbi__err("bad huffman code", "Corrupt JPEG"); // sign bit if (stbi__jpeg_get_bit(j)) s = bit; else s = -bit; } // advance by r while (k <= j->spec_end) { short *p = &data[stbi__jpeg_dezigzag[k++]]; if (*p != 0) { if (stbi__jpeg_get_bit(j)) if ((*p & bit)==0) { if (*p > 0) *p += bit; else *p -= bit; } } else { if (r == 0) { *p = (short) s; break; } --r; } } } while (k <= j->spec_end); } } return 1; } // take a -128..127 value and stbi__clamp it and convert to 0..255 stbi_inline static stbi_uc stbi__clamp(int x) { // trick to use a single test to catch both cases if ((unsigned int) x > 255) { if (x < 0) return 0; if (x > 255) return 255; } return (stbi_uc) x; } #define stbi__f2f(x) ((int) (((x) * 4096 + 0.5))) #define stbi__fsh(x) ((x) * 4096) // derived from jidctint -- DCT_ISLOW #define STBI__IDCT_1D(s0,s1,s2,s3,s4,s5,s6,s7) \ int t0,t1,t2,t3,p1,p2,p3,p4,p5,x0,x1,x2,x3; \ p2 = s2; \ p3 = s6; \ p1 = (p2+p3) * stbi__f2f(0.5411961f); \ t2 = p1 + p3*stbi__f2f(-1.847759065f); \ t3 = p1 + p2*stbi__f2f( 0.765366865f); \ p2 = s0; \ p3 = s4; \ t0 = stbi__fsh(p2+p3); \ t1 = stbi__fsh(p2-p3); \ x0 = t0+t3; \ x3 = t0-t3; \ x1 = t1+t2; \ x2 = t1-t2; \ t0 = s7; \ t1 = s5; \ t2 = s3; \ t3 = s1; \ p3 = t0+t2; \ p4 = t1+t3; \ p1 = t0+t3; \ p2 = t1+t2; \ p5 = (p3+p4)*stbi__f2f( 1.175875602f); \ t0 = t0*stbi__f2f( 0.298631336f); \ t1 = t1*stbi__f2f( 2.053119869f); \ t2 = t2*stbi__f2f( 3.072711026f); \ t3 = t3*stbi__f2f( 1.501321110f); \ p1 = p5 + p1*stbi__f2f(-0.899976223f); \ p2 = p5 + p2*stbi__f2f(-2.562915447f); \ p3 = p3*stbi__f2f(-1.961570560f); \ p4 = p4*stbi__f2f(-0.390180644f); \ t3 += p1+p4; \ t2 += p2+p3; \ t1 += p2+p4; \ t0 += p1+p3; static void stbi__idct_block(stbi_uc *out, int out_stride, short data[64]) { int i,val[64],*v=val; stbi_uc *o; short *d = data; // columns for (i=0; i < 8; ++i,++d, ++v) { // if all zeroes, shortcut -- this avoids dequantizing 0s and IDCTing if (d[ 8]==0 && d[16]==0 && d[24]==0 && d[32]==0 && d[40]==0 && d[48]==0 && d[56]==0) { // no shortcut 0 seconds // (1|2|3|4|5|6|7)==0 0 seconds // all separate -0.047 seconds // 1 && 2|3 && 4|5 && 6|7: -0.047 seconds int dcterm = d[0]*4; v[0] = v[8] = v[16] = v[24] = v[32] = v[40] = v[48] = v[56] = dcterm; } else { STBI__IDCT_1D(d[ 0],d[ 8],d[16],d[24],d[32],d[40],d[48],d[56]) // constants scaled things up by 1<<12; let's bring them back // down, but keep 2 extra bits of precision x0 += 512; x1 += 512; x2 += 512; x3 += 512; v[ 0] = (x0+t3) >> 10; v[56] = (x0-t3) >> 10; v[ 8] = (x1+t2) >> 10; v[48] = (x1-t2) >> 10; v[16] = (x2+t1) >> 10; v[40] = (x2-t1) >> 10; v[24] = (x3+t0) >> 10; v[32] = (x3-t0) >> 10; } } for (i=0, v=val, o=out; i < 8; ++i,v+=8,o+=out_stride) { // no fast case since the first 1D IDCT spread components out STBI__IDCT_1D(v[0],v[1],v[2],v[3],v[4],v[5],v[6],v[7]) // constants scaled things up by 1<<12, plus we had 1<<2 from first // loop, plus horizontal and vertical each scale by sqrt(8) so together // we've got an extra 1<<3, so 1<<17 total we need to remove. // so we want to round that, which means adding 0.5 * 1<<17, // aka 65536. Also, we'll end up with -128 to 127 that we want // to encode as 0..255 by adding 128, so we'll add that before the shift x0 += 65536 + (128<<17); x1 += 65536 + (128<<17); x2 += 65536 + (128<<17); x3 += 65536 + (128<<17); // tried computing the shifts into temps, or'ing the temps to see // if any were out of range, but that was slower o[0] = stbi__clamp((x0+t3) >> 17); o[7] = stbi__clamp((x0-t3) >> 17); o[1] = stbi__clamp((x1+t2) >> 17); o[6] = stbi__clamp((x1-t2) >> 17); o[2] = stbi__clamp((x2+t1) >> 17); o[5] = stbi__clamp((x2-t1) >> 17); o[3] = stbi__clamp((x3+t0) >> 17); o[4] = stbi__clamp((x3-t0) >> 17); } } #ifdef STBI_SSE2 // sse2 integer IDCT. not the fastest possible implementation but it // produces bit-identical results to the generic C version so it's // fully "transparent". static void stbi__idct_simd(stbi_uc *out, int out_stride, short data[64]) { // This is constructed to match our regular (generic) integer IDCT exactly. __m128i row0, row1, row2, row3, row4, row5, row6, row7; __m128i tmp; // dot product constant: even elems=x, odd elems=y #define dct_const(x,y) _mm_setr_epi16((x),(y),(x),(y),(x),(y),(x),(y)) // out(0) = c0[even]*x + c0[odd]*y (c0, x, y 16-bit, out 32-bit) // out(1) = c1[even]*x + c1[odd]*y #define dct_rot(out0,out1, x,y,c0,c1) \ __m128i c0##lo = _mm_unpacklo_epi16((x),(y)); \ __m128i c0##hi = _mm_unpackhi_epi16((x),(y)); \ __m128i out0##_l = _mm_madd_epi16(c0##lo, c0); \ __m128i out0##_h = _mm_madd_epi16(c0##hi, c0); \ __m128i out1##_l = _mm_madd_epi16(c0##lo, c1); \ __m128i out1##_h = _mm_madd_epi16(c0##hi, c1) // out = in << 12 (in 16-bit, out 32-bit) #define dct_widen(out, in) \ __m128i out##_l = _mm_srai_epi32(_mm_unpacklo_epi16(_mm_setzero_si128(), (in)), 4); \ __m128i out##_h = _mm_srai_epi32(_mm_unpackhi_epi16(_mm_setzero_si128(), (in)), 4) // wide add #define dct_wadd(out, a, b) \ __m128i out##_l = _mm_add_epi32(a##_l, b##_l); \ __m128i out##_h = _mm_add_epi32(a##_h, b##_h) // wide sub #define dct_wsub(out, a, b) \ __m128i out##_l = _mm_sub_epi32(a##_l, b##_l); \ __m128i out##_h = _mm_sub_epi32(a##_h, b##_h) // butterfly a/b, add bias, then shift by "s" and pack #define dct_bfly32o(out0, out1, a,b,bias,s) \ { \ __m128i abiased_l = _mm_add_epi32(a##_l, bias); \ __m128i abiased_h = _mm_add_epi32(a##_h, bias); \ dct_wadd(sum, abiased, b); \ dct_wsub(dif, abiased, b); \ out0 = _mm_packs_epi32(_mm_srai_epi32(sum_l, s), _mm_srai_epi32(sum_h, s)); \ out1 = _mm_packs_epi32(_mm_srai_epi32(dif_l, s), _mm_srai_epi32(dif_h, s)); \ } // 8-bit interleave step (for transposes) #define dct_interleave8(a, b) \ tmp = a; \ a = _mm_unpacklo_epi8(a, b); \ b = _mm_unpackhi_epi8(tmp, b) // 16-bit interleave step (for transposes) #define dct_interleave16(a, b) \ tmp = a; \ a = _mm_unpacklo_epi16(a, b); \ b = _mm_unpackhi_epi16(tmp, b) #define dct_pass(bias,shift) \ { \ /* even part */ \ dct_rot(t2e,t3e, row2,row6, rot0_0,rot0_1); \ __m128i sum04 = _mm_add_epi16(row0, row4); \ __m128i dif04 = _mm_sub_epi16(row0, row4); \ dct_widen(t0e, sum04); \ dct_widen(t1e, dif04); \ dct_wadd(x0, t0e, t3e); \ dct_wsub(x3, t0e, t3e); \ dct_wadd(x1, t1e, t2e); \ dct_wsub(x2, t1e, t2e); \ /* odd part */ \ dct_rot(y0o,y2o, row7,row3, rot2_0,rot2_1); \ dct_rot(y1o,y3o, row5,row1, rot3_0,rot3_1); \ __m128i sum17 = _mm_add_epi16(row1, row7); \ __m128i sum35 = _mm_add_epi16(row3, row5); \ dct_rot(y4o,y5o, sum17,sum35, rot1_0,rot1_1); \ dct_wadd(x4, y0o, y4o); \ dct_wadd(x5, y1o, y5o); \ dct_wadd(x6, y2o, y5o); \ dct_wadd(x7, y3o, y4o); \ dct_bfly32o(row0,row7, x0,x7,bias,shift); \ dct_bfly32o(row1,row6, x1,x6,bias,shift); \ dct_bfly32o(row2,row5, x2,x5,bias,shift); \ dct_bfly32o(row3,row4, x3,x4,bias,shift); \ } __m128i rot0_0 = dct_const(stbi__f2f(0.5411961f), stbi__f2f(0.5411961f) + stbi__f2f(-1.847759065f)); __m128i rot0_1 = dct_const(stbi__f2f(0.5411961f) + stbi__f2f( 0.765366865f), stbi__f2f(0.5411961f)); __m128i rot1_0 = dct_const(stbi__f2f(1.175875602f) + stbi__f2f(-0.899976223f), stbi__f2f(1.175875602f)); __m128i rot1_1 = dct_const(stbi__f2f(1.175875602f), stbi__f2f(1.175875602f) + stbi__f2f(-2.562915447f)); __m128i rot2_0 = dct_const(stbi__f2f(-1.961570560f) + stbi__f2f( 0.298631336f), stbi__f2f(-1.961570560f)); __m128i rot2_1 = dct_const(stbi__f2f(-1.961570560f), stbi__f2f(-1.961570560f) + stbi__f2f( 3.072711026f)); __m128i rot3_0 = dct_const(stbi__f2f(-0.390180644f) + stbi__f2f( 2.053119869f), stbi__f2f(-0.390180644f)); __m128i rot3_1 = dct_const(stbi__f2f(-0.390180644f), stbi__f2f(-0.390180644f) + stbi__f2f( 1.501321110f)); // rounding biases in column/row passes, see stbi__idct_block for explanation. __m128i bias_0 = _mm_set1_epi32(512); __m128i bias_1 = _mm_set1_epi32(65536 + (128<<17)); // load row0 = _mm_load_si128((const __m128i *) (data + 0*8)); row1 = _mm_load_si128((const __m128i *) (data + 1*8)); row2 = _mm_load_si128((const __m128i *) (data + 2*8)); row3 = _mm_load_si128((const __m128i *) (data + 3*8)); row4 = _mm_load_si128((const __m128i *) (data + 4*8)); row5 = _mm_load_si128((const __m128i *) (data + 5*8)); row6 = _mm_load_si128((const __m128i *) (data + 6*8)); row7 = _mm_load_si128((const __m128i *) (data + 7*8)); // column pass dct_pass(bias_0, 10); { // 16bit 8x8 transpose pass 1 dct_interleave16(row0, row4); dct_interleave16(row1, row5); dct_interleave16(row2, row6); dct_interleave16(row3, row7); // transpose pass 2 dct_interleave16(row0, row2); dct_interleave16(row1, row3); dct_interleave16(row4, row6); dct_interleave16(row5, row7); // transpose pass 3 dct_interleave16(row0, row1); dct_interleave16(row2, row3); dct_interleave16(row4, row5); dct_interleave16(row6, row7); } // row pass dct_pass(bias_1, 17); { // pack __m128i p0 = _mm_packus_epi16(row0, row1); // a0a1a2a3...a7b0b1b2b3...b7 __m128i p1 = _mm_packus_epi16(row2, row3); __m128i p2 = _mm_packus_epi16(row4, row5); __m128i p3 = _mm_packus_epi16(row6, row7); // 8bit 8x8 transpose pass 1 dct_interleave8(p0, p2); // a0e0a1e1... dct_interleave8(p1, p3); // c0g0c1g1... // transpose pass 2 dct_interleave8(p0, p1); // a0c0e0g0... dct_interleave8(p2, p3); // b0d0f0h0... // transpose pass 3 dct_interleave8(p0, p2); // a0b0c0d0... dct_interleave8(p1, p3); // a4b4c4d4... // store _mm_storel_epi64((__m128i *) out, p0); out += out_stride; _mm_storel_epi64((__m128i *) out, _mm_shuffle_epi32(p0, 0x4e)); out += out_stride; _mm_storel_epi64((__m128i *) out, p2); out += out_stride; _mm_storel_epi64((__m128i *) out, _mm_shuffle_epi32(p2, 0x4e)); out += out_stride; _mm_storel_epi64((__m128i *) out, p1); out += out_stride; _mm_storel_epi64((__m128i *) out, _mm_shuffle_epi32(p1, 0x4e)); out += out_stride; _mm_storel_epi64((__m128i *) out, p3); out += out_stride; _mm_storel_epi64((__m128i *) out, _mm_shuffle_epi32(p3, 0x4e)); } #undef dct_const #undef dct_rot #undef dct_widen #undef dct_wadd #undef dct_wsub #undef dct_bfly32o #undef dct_interleave8 #undef dct_interleave16 #undef dct_pass } #endif // STBI_SSE2 #ifdef STBI_NEON // NEON integer IDCT. should produce bit-identical // results to the generic C version. static void stbi__idct_simd(stbi_uc *out, int out_stride, short data[64]) { int16x8_t row0, row1, row2, row3, row4, row5, row6, row7; int16x4_t rot0_0 = vdup_n_s16(stbi__f2f(0.5411961f)); int16x4_t rot0_1 = vdup_n_s16(stbi__f2f(-1.847759065f)); int16x4_t rot0_2 = vdup_n_s16(stbi__f2f( 0.765366865f)); int16x4_t rot1_0 = vdup_n_s16(stbi__f2f( 1.175875602f)); int16x4_t rot1_1 = vdup_n_s16(stbi__f2f(-0.899976223f)); int16x4_t rot1_2 = vdup_n_s16(stbi__f2f(-2.562915447f)); int16x4_t rot2_0 = vdup_n_s16(stbi__f2f(-1.961570560f)); int16x4_t rot2_1 = vdup_n_s16(stbi__f2f(-0.390180644f)); int16x4_t rot3_0 = vdup_n_s16(stbi__f2f( 0.298631336f)); int16x4_t rot3_1 = vdup_n_s16(stbi__f2f( 2.053119869f)); int16x4_t rot3_2 = vdup_n_s16(stbi__f2f( 3.072711026f)); int16x4_t rot3_3 = vdup_n_s16(stbi__f2f( 1.501321110f)); #define dct_long_mul(out, inq, coeff) \ int32x4_t out##_l = vmull_s16(vget_low_s16(inq), coeff); \ int32x4_t out##_h = vmull_s16(vget_high_s16(inq), coeff) #define dct_long_mac(out, acc, inq, coeff) \ int32x4_t out##_l = vmlal_s16(acc##_l, vget_low_s16(inq), coeff); \ int32x4_t out##_h = vmlal_s16(acc##_h, vget_high_s16(inq), coeff) #define dct_widen(out, inq) \ int32x4_t out##_l = vshll_n_s16(vget_low_s16(inq), 12); \ int32x4_t out##_h = vshll_n_s16(vget_high_s16(inq), 12) // wide add #define dct_wadd(out, a, b) \ int32x4_t out##_l = vaddq_s32(a##_l, b##_l); \ int32x4_t out##_h = vaddq_s32(a##_h, b##_h) // wide sub #define dct_wsub(out, a, b) \ int32x4_t out##_l = vsubq_s32(a##_l, b##_l); \ int32x4_t out##_h = vsubq_s32(a##_h, b##_h) // butterfly a/b, then shift using "shiftop" by "s" and pack #define dct_bfly32o(out0,out1, a,b,shiftop,s) \ { \ dct_wadd(sum, a, b); \ dct_wsub(dif, a, b); \ out0 = vcombine_s16(shiftop(sum_l, s), shiftop(sum_h, s)); \ out1 = vcombine_s16(shiftop(dif_l, s), shiftop(dif_h, s)); \ } #define dct_pass(shiftop, shift) \ { \ /* even part */ \ int16x8_t sum26 = vaddq_s16(row2, row6); \ dct_long_mul(p1e, sum26, rot0_0); \ dct_long_mac(t2e, p1e, row6, rot0_1); \ dct_long_mac(t3e, p1e, row2, rot0_2); \ int16x8_t sum04 = vaddq_s16(row0, row4); \ int16x8_t dif04 = vsubq_s16(row0, row4); \ dct_widen(t0e, sum04); \ dct_widen(t1e, dif04); \ dct_wadd(x0, t0e, t3e); \ dct_wsub(x3, t0e, t3e); \ dct_wadd(x1, t1e, t2e); \ dct_wsub(x2, t1e, t2e); \ /* odd part */ \ int16x8_t sum15 = vaddq_s16(row1, row5); \ int16x8_t sum17 = vaddq_s16(row1, row7); \ int16x8_t sum35 = vaddq_s16(row3, row5); \ int16x8_t sum37 = vaddq_s16(row3, row7); \ int16x8_t sumodd = vaddq_s16(sum17, sum35); \ dct_long_mul(p5o, sumodd, rot1_0); \ dct_long_mac(p1o, p5o, sum17, rot1_1); \ dct_long_mac(p2o, p5o, sum35, rot1_2); \ dct_long_mul(p3o, sum37, rot2_0); \ dct_long_mul(p4o, sum15, rot2_1); \ dct_wadd(sump13o, p1o, p3o); \ dct_wadd(sump24o, p2o, p4o); \ dct_wadd(sump23o, p2o, p3o); \ dct_wadd(sump14o, p1o, p4o); \ dct_long_mac(x4, sump13o, row7, rot3_0); \ dct_long_mac(x5, sump24o, row5, rot3_1); \ dct_long_mac(x6, sump23o, row3, rot3_2); \ dct_long_mac(x7, sump14o, row1, rot3_3); \ dct_bfly32o(row0,row7, x0,x7,shiftop,shift); \ dct_bfly32o(row1,row6, x1,x6,shiftop,shift); \ dct_bfly32o(row2,row5, x2,x5,shiftop,shift); \ dct_bfly32o(row3,row4, x3,x4,shiftop,shift); \ } // load row0 = vld1q_s16(data + 0*8); row1 = vld1q_s16(data + 1*8); row2 = vld1q_s16(data + 2*8); row3 = vld1q_s16(data + 3*8); row4 = vld1q_s16(data + 4*8); row5 = vld1q_s16(data + 5*8); row6 = vld1q_s16(data + 6*8); row7 = vld1q_s16(data + 7*8); // add DC bias row0 = vaddq_s16(row0, vsetq_lane_s16(1024, vdupq_n_s16(0), 0)); // column pass dct_pass(vrshrn_n_s32, 10); // 16bit 8x8 transpose { // these three map to a single VTRN.16, VTRN.32, and VSWP, respectively. // whether compilers actually get this is another story, sadly. #define dct_trn16(x, y) { int16x8x2_t t = vtrnq_s16(x, y); x = t.val[0]; y = t.val[1]; } #define dct_trn32(x, y) { int32x4x2_t t = vtrnq_s32(vreinterpretq_s32_s16(x), vreinterpretq_s32_s16(y)); x = vreinterpretq_s16_s32(t.val[0]); y = vreinterpretq_s16_s32(t.val[1]); } #define dct_trn64(x, y) { int16x8_t x0 = x; int16x8_t y0 = y; x = vcombine_s16(vget_low_s16(x0), vget_low_s16(y0)); y = vcombine_s16(vget_high_s16(x0), vget_high_s16(y0)); } // pass 1 dct_trn16(row0, row1); // a0b0a2b2a4b4a6b6 dct_trn16(row2, row3); dct_trn16(row4, row5); dct_trn16(row6, row7); // pass 2 dct_trn32(row0, row2); // a0b0c0d0a4b4c4d4 dct_trn32(row1, row3); dct_trn32(row4, row6); dct_trn32(row5, row7); // pass 3 dct_trn64(row0, row4); // a0b0c0d0e0f0g0h0 dct_trn64(row1, row5); dct_trn64(row2, row6); dct_trn64(row3, row7); #undef dct_trn16 #undef dct_trn32 #undef dct_trn64 } // row pass // vrshrn_n_s32 only supports shifts up to 16, we need // 17. so do a non-rounding shift of 16 first then follow // up with a rounding shift by 1. dct_pass(vshrn_n_s32, 16); { // pack and round uint8x8_t p0 = vqrshrun_n_s16(row0, 1); uint8x8_t p1 = vqrshrun_n_s16(row1, 1); uint8x8_t p2 = vqrshrun_n_s16(row2, 1); uint8x8_t p3 = vqrshrun_n_s16(row3, 1); uint8x8_t p4 = vqrshrun_n_s16(row4, 1); uint8x8_t p5 = vqrshrun_n_s16(row5, 1); uint8x8_t p6 = vqrshrun_n_s16(row6, 1); uint8x8_t p7 = vqrshrun_n_s16(row7, 1); // again, these can translate into one instruction, but often don't. #define dct_trn8_8(x, y) { uint8x8x2_t t = vtrn_u8(x, y); x = t.val[0]; y = t.val[1]; } #define dct_trn8_16(x, y) { uint16x4x2_t t = vtrn_u16(vreinterpret_u16_u8(x), vreinterpret_u16_u8(y)); x = vreinterpret_u8_u16(t.val[0]); y = vreinterpret_u8_u16(t.val[1]); } #define dct_trn8_32(x, y) { uint32x2x2_t t = vtrn_u32(vreinterpret_u32_u8(x), vreinterpret_u32_u8(y)); x = vreinterpret_u8_u32(t.val[0]); y = vreinterpret_u8_u32(t.val[1]); } // sadly can't use interleaved stores here since we only write // 8 bytes to each scan line! // 8x8 8-bit transpose pass 1 dct_trn8_8(p0, p1); dct_trn8_8(p2, p3); dct_trn8_8(p4, p5); dct_trn8_8(p6, p7); // pass 2 dct_trn8_16(p0, p2); dct_trn8_16(p1, p3); dct_trn8_16(p4, p6); dct_trn8_16(p5, p7); // pass 3 dct_trn8_32(p0, p4); dct_trn8_32(p1, p5); dct_trn8_32(p2, p6); dct_trn8_32(p3, p7); // store vst1_u8(out, p0); out += out_stride; vst1_u8(out, p1); out += out_stride; vst1_u8(out, p2); out += out_stride; vst1_u8(out, p3); out += out_stride; vst1_u8(out, p4); out += out_stride; vst1_u8(out, p5); out += out_stride; vst1_u8(out, p6); out += out_stride; vst1_u8(out, p7); #undef dct_trn8_8 #undef dct_trn8_16 #undef dct_trn8_32 } #undef dct_long_mul #undef dct_long_mac #undef dct_widen #undef dct_wadd #undef dct_wsub #undef dct_bfly32o #undef dct_pass } #endif // STBI_NEON #define STBI__MARKER_none 0xff // if there's a pending marker from the entropy stream, return that // otherwise, fetch from the stream and get a marker. if there's no // marker, return 0xff, which is never a valid marker value static stbi_uc stbi__get_marker(stbi__jpeg *j) { stbi_uc x; if (j->marker != STBI__MARKER_none) { x = j->marker; j->marker = STBI__MARKER_none; return x; } x = stbi__get8(j->s); if (x != 0xff) return STBI__MARKER_none; while (x == 0xff) x = stbi__get8(j->s); // consume repeated 0xff fill bytes return x; } // in each scan, we'll have scan_n components, and the order // of the components is specified by order[] #define STBI__RESTART(x) ((x) >= 0xd0 && (x) <= 0xd7) // after a restart interval, stbi__jpeg_reset the entropy decoder and // the dc prediction static void stbi__jpeg_reset(stbi__jpeg *j) { j->code_bits = 0; j->code_buffer = 0; j->nomore = 0; j->img_comp[0].dc_pred = j->img_comp[1].dc_pred = j->img_comp[2].dc_pred = j->img_comp[3].dc_pred = 0; j->marker = STBI__MARKER_none; j->todo = j->restart_interval ? j->restart_interval : 0x7fffffff; j->eob_run = 0; // no more than 1<<31 MCUs if no restart_interal? that's plenty safe, // since we don't even allow 1<<30 pixels } static int stbi__parse_entropy_coded_data(stbi__jpeg *z) { stbi__jpeg_reset(z); if (!z->progressive) { if (z->scan_n == 1) { int i,j; STBI_SIMD_ALIGN(short, data[64]); int n = z->order[0]; // non-interleaved data, we just need to process one block at a time, // in trivial scanline order // number of blocks to do just depends on how many actual "pixels" this // component has, independent of interleaved MCU blocking and such int w = (z->img_comp[n].x+7) >> 3; int h = (z->img_comp[n].y+7) >> 3; for (j=0; j < h; ++j) { for (i=0; i < w; ++i) { int ha = z->img_comp[n].ha; if (!stbi__jpeg_decode_block(z, data, z->huff_dc+z->img_comp[n].hd, z->huff_ac+ha, z->fast_ac[ha], n, z->dequant[z->img_comp[n].tq])) return 0; z->idct_block_kernel(z->img_comp[n].data+z->img_comp[n].w2*j*8+i*8, z->img_comp[n].w2, data); // every data block is an MCU, so countdown the restart interval if (--z->todo <= 0) { if (z->code_bits < 24) stbi__grow_buffer_unsafe(z); // if it's NOT a restart, then just bail, so we get corrupt data // rather than no data if (!STBI__RESTART(z->marker)) return 1; stbi__jpeg_reset(z); } } } return 1; } else { // interleaved int i,j,k,x,y; STBI_SIMD_ALIGN(short, data[64]); for (j=0; j < z->img_mcu_y; ++j) { for (i=0; i < z->img_mcu_x; ++i) { // scan an interleaved mcu... process scan_n components in order for (k=0; k < z->scan_n; ++k) { int n = z->order[k]; // scan out an mcu's worth of this component; that's just determined // by the basic H and V specified for the component for (y=0; y < z->img_comp[n].v; ++y) { for (x=0; x < z->img_comp[n].h; ++x) { int x2 = (i*z->img_comp[n].h + x)*8; int y2 = (j*z->img_comp[n].v + y)*8; int ha = z->img_comp[n].ha; if (!stbi__jpeg_decode_block(z, data, z->huff_dc+z->img_comp[n].hd, z->huff_ac+ha, z->fast_ac[ha], n, z->dequant[z->img_comp[n].tq])) return 0; z->idct_block_kernel(z->img_comp[n].data+z->img_comp[n].w2*y2+x2, z->img_comp[n].w2, data); } } } // after all interleaved components, that's an interleaved MCU, // so now count down the restart interval if (--z->todo <= 0) { if (z->code_bits < 24) stbi__grow_buffer_unsafe(z); if (!STBI__RESTART(z->marker)) return 1; stbi__jpeg_reset(z); } } } return 1; } } else { if (z->scan_n == 1) { int i,j; int n = z->order[0]; // non-interleaved data, we just need to process one block at a time, // in trivial scanline order // number of blocks to do just depends on how many actual "pixels" this // component has, independent of interleaved MCU blocking and such int w = (z->img_comp[n].x+7) >> 3; int h = (z->img_comp[n].y+7) >> 3; for (j=0; j < h; ++j) { for (i=0; i < w; ++i) { short *data = z->img_comp[n].coeff + 64 * (i + j * z->img_comp[n].coeff_w); if (z->spec_start == 0) { if (!stbi__jpeg_decode_block_prog_dc(z, data, &z->huff_dc[z->img_comp[n].hd], n)) return 0; } else { int ha = z->img_comp[n].ha; if (!stbi__jpeg_decode_block_prog_ac(z, data, &z->huff_ac[ha], z->fast_ac[ha])) return 0; } // every data block is an MCU, so countdown the restart interval if (--z->todo <= 0) { if (z->code_bits < 24) stbi__grow_buffer_unsafe(z); if (!STBI__RESTART(z->marker)) return 1; stbi__jpeg_reset(z); } } } return 1; } else { // interleaved int i,j,k,x,y; for (j=0; j < z->img_mcu_y; ++j) { for (i=0; i < z->img_mcu_x; ++i) { // scan an interleaved mcu... process scan_n components in order for (k=0; k < z->scan_n; ++k) { int n = z->order[k]; // scan out an mcu's worth of this component; that's just determined // by the basic H and V specified for the component for (y=0; y < z->img_comp[n].v; ++y) { for (x=0; x < z->img_comp[n].h; ++x) { int x2 = (i*z->img_comp[n].h + x); int y2 = (j*z->img_comp[n].v + y); short *data = z->img_comp[n].coeff + 64 * (x2 + y2 * z->img_comp[n].coeff_w); if (!stbi__jpeg_decode_block_prog_dc(z, data, &z->huff_dc[z->img_comp[n].hd], n)) return 0; } } } // after all interleaved components, that's an interleaved MCU, // so now count down the restart interval if (--z->todo <= 0) { if (z->code_bits < 24) stbi__grow_buffer_unsafe(z); if (!STBI__RESTART(z->marker)) return 1; stbi__jpeg_reset(z); } } } return 1; } } } static void stbi__jpeg_dequantize(short *data, stbi__uint16 *dequant) { int i; for (i=0; i < 64; ++i) data[i] *= dequant[i]; } static void stbi__jpeg_finish(stbi__jpeg *z) { if (z->progressive) { // dequantize and idct the data int i,j,n; for (n=0; n < z->s->img_n; ++n) { int w = (z->img_comp[n].x+7) >> 3; int h = (z->img_comp[n].y+7) >> 3; for (j=0; j < h; ++j) { for (i=0; i < w; ++i) { short *data = z->img_comp[n].coeff + 64 * (i + j * z->img_comp[n].coeff_w); stbi__jpeg_dequantize(data, z->dequant[z->img_comp[n].tq]); z->idct_block_kernel(z->img_comp[n].data+z->img_comp[n].w2*j*8+i*8, z->img_comp[n].w2, data); } } } } } static int stbi__process_marker(stbi__jpeg *z, int m) { int L; switch (m) { case STBI__MARKER_none: // no marker found return stbi__err("expected marker","Corrupt JPEG"); case 0xDD: // DRI - specify restart interval if (stbi__get16be(z->s) != 4) return stbi__err("bad DRI len","Corrupt JPEG"); z->restart_interval = stbi__get16be(z->s); return 1; case 0xDB: // DQT - define quantization table L = stbi__get16be(z->s)-2; while (L > 0) { int q = stbi__get8(z->s); int p = q >> 4, sixteen = (p != 0); int t = q & 15,i; if (p != 0 && p != 1) return stbi__err("bad DQT type","Corrupt JPEG"); if (t > 3) return stbi__err("bad DQT table","Corrupt JPEG"); for (i=0; i < 64; ++i) z->dequant[t][stbi__jpeg_dezigzag[i]] = (stbi__uint16)(sixteen ? stbi__get16be(z->s) : stbi__get8(z->s)); L -= (sixteen ? 129 : 65); } return L==0; case 0xC4: // DHT - define huffman table L = stbi__get16be(z->s)-2; while (L > 0) { stbi_uc *v; int sizes[16],i,n=0; int q = stbi__get8(z->s); int tc = q >> 4; int th = q & 15; if (tc > 1 || th > 3) return stbi__err("bad DHT header","Corrupt JPEG"); for (i=0; i < 16; ++i) { sizes[i] = stbi__get8(z->s); n += sizes[i]; } if(n > 256) return stbi__err("bad DHT header","Corrupt JPEG"); // Loop over i < n would write past end of values! L -= 17; if (tc == 0) { if (!stbi__build_huffman(z->huff_dc+th, sizes)) return 0; v = z->huff_dc[th].values; } else { if (!stbi__build_huffman(z->huff_ac+th, sizes)) return 0; v = z->huff_ac[th].values; } for (i=0; i < n; ++i) v[i] = stbi__get8(z->s); if (tc != 0) stbi__build_fast_ac(z->fast_ac[th], z->huff_ac + th); L -= n; } return L==0; } // check for comment block or APP blocks if ((m >= 0xE0 && m <= 0xEF) || m == 0xFE) { L = stbi__get16be(z->s); if (L < 2) { if (m == 0xFE) return stbi__err("bad COM len","Corrupt JPEG"); else return stbi__err("bad APP len","Corrupt JPEG"); } L -= 2; if (m == 0xE0 && L >= 5) { // JFIF APP0 segment static const unsigned char tag[5] = {'J','F','I','F','\0'}; int ok = 1; int i; for (i=0; i < 5; ++i) if (stbi__get8(z->s) != tag[i]) ok = 0; L -= 5; if (ok) z->jfif = 1; } else if (m == 0xEE && L >= 12) { // Adobe APP14 segment static const unsigned char tag[6] = {'A','d','o','b','e','\0'}; int ok = 1; int i; for (i=0; i < 6; ++i) if (stbi__get8(z->s) != tag[i]) ok = 0; L -= 6; if (ok) { stbi__get8(z->s); // version stbi__get16be(z->s); // flags0 stbi__get16be(z->s); // flags1 z->app14_color_transform = stbi__get8(z->s); // color transform L -= 6; } } stbi__skip(z->s, L); return 1; } return stbi__err("unknown marker","Corrupt JPEG"); } // after we see SOS static int stbi__process_scan_header(stbi__jpeg *z) { int i; int Ls = stbi__get16be(z->s); z->scan_n = stbi__get8(z->s); if (z->scan_n < 1 || z->scan_n > 4 || z->scan_n > (int) z->s->img_n) return stbi__err("bad SOS component count","Corrupt JPEG"); if (Ls != 6+2*z->scan_n) return stbi__err("bad SOS len","Corrupt JPEG"); for (i=0; i < z->scan_n; ++i) { int id = stbi__get8(z->s), which; int q = stbi__get8(z->s); for (which = 0; which < z->s->img_n; ++which) if (z->img_comp[which].id == id) break; if (which == z->s->img_n) return 0; // no match z->img_comp[which].hd = q >> 4; if (z->img_comp[which].hd > 3) return stbi__err("bad DC huff","Corrupt JPEG"); z->img_comp[which].ha = q & 15; if (z->img_comp[which].ha > 3) return stbi__err("bad AC huff","Corrupt JPEG"); z->order[i] = which; } { int aa; z->spec_start = stbi__get8(z->s); z->spec_end = stbi__get8(z->s); // should be 63, but might be 0 aa = stbi__get8(z->s); z->succ_high = (aa >> 4); z->succ_low = (aa & 15); if (z->progressive) { if (z->spec_start > 63 || z->spec_end > 63 || z->spec_start > z->spec_end || z->succ_high > 13 || z->succ_low > 13) return stbi__err("bad SOS", "Corrupt JPEG"); } else { if (z->spec_start != 0) return stbi__err("bad SOS","Corrupt JPEG"); if (z->succ_high != 0 || z->succ_low != 0) return stbi__err("bad SOS","Corrupt JPEG"); z->spec_end = 63; } } return 1; } static int stbi__free_jpeg_components(stbi__jpeg *z, int ncomp, int why) { int i; for (i=0; i < ncomp; ++i) { if (z->img_comp[i].raw_data) { STBI_FREE(z->img_comp[i].raw_data); z->img_comp[i].raw_data = NULL; z->img_comp[i].data = NULL; } if (z->img_comp[i].raw_coeff) { STBI_FREE(z->img_comp[i].raw_coeff); z->img_comp[i].raw_coeff = 0; z->img_comp[i].coeff = 0; } if (z->img_comp[i].linebuf) { STBI_FREE(z->img_comp[i].linebuf); z->img_comp[i].linebuf = NULL; } } return why; } static int stbi__process_frame_header(stbi__jpeg *z, int scan) { stbi__context *s = z->s; int Lf,p,i,q, h_max=1,v_max=1,c; Lf = stbi__get16be(s); if (Lf < 11) return stbi__err("bad SOF len","Corrupt JPEG"); // JPEG p = stbi__get8(s); if (p != 8) return stbi__err("only 8-bit","JPEG format not supported: 8-bit only"); // JPEG baseline s->img_y = stbi__get16be(s); if (s->img_y == 0) return stbi__err("no header height", "JPEG format not supported: delayed height"); // Legal, but we don't handle it--but neither does IJG s->img_x = stbi__get16be(s); if (s->img_x == 0) return stbi__err("0 width","Corrupt JPEG"); // JPEG requires if (s->img_y > STBI_MAX_DIMENSIONS) return stbi__err("too large","Very large image (corrupt?)"); if (s->img_x > STBI_MAX_DIMENSIONS) return stbi__err("too large","Very large image (corrupt?)"); c = stbi__get8(s); if (c != 3 && c != 1 && c != 4) return stbi__err("bad component count","Corrupt JPEG"); s->img_n = c; for (i=0; i < c; ++i) { z->img_comp[i].data = NULL; z->img_comp[i].linebuf = NULL; } if (Lf != 8+3*s->img_n) return stbi__err("bad SOF len","Corrupt JPEG"); z->rgb = 0; for (i=0; i < s->img_n; ++i) { static const unsigned char rgb[3] = { 'R', 'G', 'B' }; z->img_comp[i].id = stbi__get8(s); if (s->img_n == 3 && z->img_comp[i].id == rgb[i]) ++z->rgb; q = stbi__get8(s); z->img_comp[i].h = (q >> 4); if (!z->img_comp[i].h || z->img_comp[i].h > 4) return stbi__err("bad H","Corrupt JPEG"); z->img_comp[i].v = q & 15; if (!z->img_comp[i].v || z->img_comp[i].v > 4) return stbi__err("bad V","Corrupt JPEG"); z->img_comp[i].tq = stbi__get8(s); if (z->img_comp[i].tq > 3) return stbi__err("bad TQ","Corrupt JPEG"); } if (scan != STBI__SCAN_load) return 1; if (!stbi__mad3sizes_valid(s->img_x, s->img_y, s->img_n, 0)) return stbi__err("too large", "Image too large to decode"); for (i=0; i < s->img_n; ++i) { if (z->img_comp[i].h > h_max) h_max = z->img_comp[i].h; if (z->img_comp[i].v > v_max) v_max = z->img_comp[i].v; } // check that plane subsampling factors are integer ratios; our resamplers can't deal with fractional ratios // and I've never seen a non-corrupted JPEG file actually use them for (i=0; i < s->img_n; ++i) { if (h_max % z->img_comp[i].h != 0) return stbi__err("bad H","Corrupt JPEG"); if (v_max % z->img_comp[i].v != 0) return stbi__err("bad V","Corrupt JPEG"); } // compute interleaved mcu info z->img_h_max = h_max; z->img_v_max = v_max; z->img_mcu_w = h_max * 8; z->img_mcu_h = v_max * 8; // these sizes can't be more than 17 bits z->img_mcu_x = (s->img_x + z->img_mcu_w-1) / z->img_mcu_w; z->img_mcu_y = (s->img_y + z->img_mcu_h-1) / z->img_mcu_h; for (i=0; i < s->img_n; ++i) { // number of effective pixels (e.g. for non-interleaved MCU) z->img_comp[i].x = (s->img_x * z->img_comp[i].h + h_max-1) / h_max; z->img_comp[i].y = (s->img_y * z->img_comp[i].v + v_max-1) / v_max; // to simplify generation, we'll allocate enough memory to decode // the bogus oversized data from using interleaved MCUs and their // big blocks (e.g. a 16x16 iMCU on an image of width 33); we won't // discard the extra data until colorspace conversion // // img_mcu_x, img_mcu_y: <=17 bits; comp[i].h and .v are <=4 (checked earlier) // so these muls can't overflow with 32-bit ints (which we require) z->img_comp[i].w2 = z->img_mcu_x * z->img_comp[i].h * 8; z->img_comp[i].h2 = z->img_mcu_y * z->img_comp[i].v * 8; z->img_comp[i].coeff = 0; z->img_comp[i].raw_coeff = 0; z->img_comp[i].linebuf = NULL; z->img_comp[i].raw_data = stbi__malloc_mad2(z->img_comp[i].w2, z->img_comp[i].h2, 15); if (z->img_comp[i].raw_data == NULL) return stbi__free_jpeg_components(z, i+1, stbi__err("outofmem", "Out of memory")); // align blocks for idct using mmx/sse z->img_comp[i].data = (stbi_uc*) (((size_t) z->img_comp[i].raw_data + 15) & ~15); if (z->progressive) { // w2, h2 are multiples of 8 (see above) z->img_comp[i].coeff_w = z->img_comp[i].w2 / 8; z->img_comp[i].coeff_h = z->img_comp[i].h2 / 8; z->img_comp[i].raw_coeff = stbi__malloc_mad3(z->img_comp[i].w2, z->img_comp[i].h2, sizeof(short), 15); if (z->img_comp[i].raw_coeff == NULL) return stbi__free_jpeg_components(z, i+1, stbi__err("outofmem", "Out of memory")); z->img_comp[i].coeff = (short*) (((size_t) z->img_comp[i].raw_coeff + 15) & ~15); } } return 1; } // use comparisons since in some cases we handle more than one case (e.g. SOF) #define stbi__DNL(x) ((x) == 0xdc) #define stbi__SOI(x) ((x) == 0xd8) #define stbi__EOI(x) ((x) == 0xd9) #define stbi__SOF(x) ((x) == 0xc0 || (x) == 0xc1 || (x) == 0xc2) #define stbi__SOS(x) ((x) == 0xda) #define stbi__SOF_progressive(x) ((x) == 0xc2) static int stbi__decode_jpeg_header(stbi__jpeg *z, int scan) { int m; z->jfif = 0; z->app14_color_transform = -1; // valid values are 0,1,2 z->marker = STBI__MARKER_none; // initialize cached marker to empty m = stbi__get_marker(z); if (!stbi__SOI(m)) return stbi__err("no SOI","Corrupt JPEG"); if (scan == STBI__SCAN_type) return 1; m = stbi__get_marker(z); while (!stbi__SOF(m)) { if (!stbi__process_marker(z,m)) return 0; m = stbi__get_marker(z); while (m == STBI__MARKER_none) { // some files have extra padding after their blocks, so ok, we'll scan if (stbi__at_eof(z->s)) return stbi__err("no SOF", "Corrupt JPEG"); m = stbi__get_marker(z); } } z->progressive = stbi__SOF_progressive(m); if (!stbi__process_frame_header(z, scan)) return 0; return 1; } static stbi_uc stbi__skip_jpeg_junk_at_end(stbi__jpeg *j) { // some JPEGs have junk at end, skip over it but if we find what looks // like a valid marker, resume there while (!stbi__at_eof(j->s)) { stbi_uc x = stbi__get8(j->s); while (x == 0xff) { // might be a marker if (stbi__at_eof(j->s)) return STBI__MARKER_none; x = stbi__get8(j->s); if (x != 0x00 && x != 0xff) { // not a stuffed zero or lead-in to another marker, looks // like an actual marker, return it return x; } // stuffed zero has x=0 now which ends the loop, meaning we go // back to regular scan loop. // repeated 0xff keeps trying to read the next byte of the marker. } } return STBI__MARKER_none; } // decode image to YCbCr format static int stbi__decode_jpeg_image(stbi__jpeg *j) { int m; for (m = 0; m < 4; m++) { j->img_comp[m].raw_data = NULL; j->img_comp[m].raw_coeff = NULL; } j->restart_interval = 0; if (!stbi__decode_jpeg_header(j, STBI__SCAN_load)) return 0; m = stbi__get_marker(j); while (!stbi__EOI(m)) { if (stbi__SOS(m)) { if (!stbi__process_scan_header(j)) return 0; if (!stbi__parse_entropy_coded_data(j)) return 0; if (j->marker == STBI__MARKER_none ) { j->marker = stbi__skip_jpeg_junk_at_end(j); // if we reach eof without hitting a marker, stbi__get_marker() below will fail and we'll eventually return 0 } m = stbi__get_marker(j); if (STBI__RESTART(m)) m = stbi__get_marker(j); } else if (stbi__DNL(m)) { int Ld = stbi__get16be(j->s); stbi__uint32 NL = stbi__get16be(j->s); if (Ld != 4) return stbi__err("bad DNL len", "Corrupt JPEG"); if (NL != j->s->img_y) return stbi__err("bad DNL height", "Corrupt JPEG"); m = stbi__get_marker(j); } else { if (!stbi__process_marker(j, m)) return 1; m = stbi__get_marker(j); } } if (j->progressive) stbi__jpeg_finish(j); return 1; } // static jfif-centered resampling (across block boundaries) typedef stbi_uc *(*resample_row_func)(stbi_uc *out, stbi_uc *in0, stbi_uc *in1, int w, int hs); #define stbi__div4(x) ((stbi_uc) ((x) >> 2)) static stbi_uc *resample_row_1(stbi_uc *out, stbi_uc *in_near, stbi_uc *in_far, int w, int hs) { STBI_NOTUSED(out); STBI_NOTUSED(in_far); STBI_NOTUSED(w); STBI_NOTUSED(hs); return in_near; } static stbi_uc* stbi__resample_row_v_2(stbi_uc *out, stbi_uc *in_near, stbi_uc *in_far, int w, int hs) { // need to generate two samples vertically for every one in input int i; STBI_NOTUSED(hs); for (i=0; i < w; ++i) out[i] = stbi__div4(3*in_near[i] + in_far[i] + 2); return out; } static stbi_uc* stbi__resample_row_h_2(stbi_uc *out, stbi_uc *in_near, stbi_uc *in_far, int w, int hs) { // need to generate two samples horizontally for every one in input int i; stbi_uc *input = in_near; if (w == 1) { // if only one sample, can't do any interpolation out[0] = out[1] = input[0]; return out; } out[0] = input[0]; out[1] = stbi__div4(input[0]*3 + input[1] + 2); for (i=1; i < w-1; ++i) { int n = 3*input[i]+2; out[i*2+0] = stbi__div4(n+input[i-1]); out[i*2+1] = stbi__div4(n+input[i+1]); } out[i*2+0] = stbi__div4(input[w-2]*3 + input[w-1] + 2); out[i*2+1] = input[w-1]; STBI_NOTUSED(in_far); STBI_NOTUSED(hs); return out; } #define stbi__div16(x) ((stbi_uc) ((x) >> 4)) static stbi_uc *stbi__resample_row_hv_2(stbi_uc *out, stbi_uc *in_near, stbi_uc *in_far, int w, int hs) { // need to generate 2x2 samples for every one in input int i,t0,t1; if (w == 1) { out[0] = out[1] = stbi__div4(3*in_near[0] + in_far[0] + 2); return out; } t1 = 3*in_near[0] + in_far[0]; out[0] = stbi__div4(t1+2); for (i=1; i < w; ++i) { t0 = t1; t1 = 3*in_near[i]+in_far[i]; out[i*2-1] = stbi__div16(3*t0 + t1 + 8); out[i*2 ] = stbi__div16(3*t1 + t0 + 8); } out[w*2-1] = stbi__div4(t1+2); STBI_NOTUSED(hs); return out; } #if defined(STBI_SSE2) || defined(STBI_NEON) static stbi_uc *stbi__resample_row_hv_2_simd(stbi_uc *out, stbi_uc *in_near, stbi_uc *in_far, int w, int hs) { // need to generate 2x2 samples for every one in input int i=0,t0,t1; if (w == 1) { out[0] = out[1] = stbi__div4(3*in_near[0] + in_far[0] + 2); return out; } t1 = 3*in_near[0] + in_far[0]; // process groups of 8 pixels for as long as we can. // note we can't handle the last pixel in a row in this loop // because we need to handle the filter boundary conditions. for (; i < ((w-1) & ~7); i += 8) { #if defined(STBI_SSE2) // load and perform the vertical filtering pass // this uses 3*x + y = 4*x + (y - x) __m128i zero = _mm_setzero_si128(); __m128i farb = _mm_loadl_epi64((__m128i *) (in_far + i)); __m128i nearb = _mm_loadl_epi64((__m128i *) (in_near + i)); __m128i farw = _mm_unpacklo_epi8(farb, zero); __m128i nearw = _mm_unpacklo_epi8(nearb, zero); __m128i diff = _mm_sub_epi16(farw, nearw); __m128i nears = _mm_slli_epi16(nearw, 2); __m128i curr = _mm_add_epi16(nears, diff); // current row // horizontal filter works the same based on shifted vers of current // row. "prev" is current row shifted right by 1 pixel; we need to // insert the previous pixel value (from t1). // "next" is current row shifted left by 1 pixel, with first pixel // of next block of 8 pixels added in. __m128i prv0 = _mm_slli_si128(curr, 2); __m128i nxt0 = _mm_srli_si128(curr, 2); __m128i prev = _mm_insert_epi16(prv0, t1, 0); __m128i next = _mm_insert_epi16(nxt0, 3*in_near[i+8] + in_far[i+8], 7); // horizontal filter, polyphase implementation since it's convenient: // even pixels = 3*cur + prev = cur*4 + (prev - cur) // odd pixels = 3*cur + next = cur*4 + (next - cur) // note the shared term. __m128i bias = _mm_set1_epi16(8); __m128i curs = _mm_slli_epi16(curr, 2); __m128i prvd = _mm_sub_epi16(prev, curr); __m128i nxtd = _mm_sub_epi16(next, curr); __m128i curb = _mm_add_epi16(curs, bias); __m128i even = _mm_add_epi16(prvd, curb); __m128i odd = _mm_add_epi16(nxtd, curb); // interleave even and odd pixels, then undo scaling. __m128i int0 = _mm_unpacklo_epi16(even, odd); __m128i int1 = _mm_unpackhi_epi16(even, odd); __m128i de0 = _mm_srli_epi16(int0, 4); __m128i de1 = _mm_srli_epi16(int1, 4); // pack and write output __m128i outv = _mm_packus_epi16(de0, de1); _mm_storeu_si128((__m128i *) (out + i*2), outv); #elif defined(STBI_NEON) // load and perform the vertical filtering pass // this uses 3*x + y = 4*x + (y - x) uint8x8_t farb = vld1_u8(in_far + i); uint8x8_t nearb = vld1_u8(in_near + i); int16x8_t diff = vreinterpretq_s16_u16(vsubl_u8(farb, nearb)); int16x8_t nears = vreinterpretq_s16_u16(vshll_n_u8(nearb, 2)); int16x8_t curr = vaddq_s16(nears, diff); // current row // horizontal filter works the same based on shifted vers of current // row. "prev" is current row shifted right by 1 pixel; we need to // insert the previous pixel value (from t1). // "next" is current row shifted left by 1 pixel, with first pixel // of next block of 8 pixels added in. int16x8_t prv0 = vextq_s16(curr, curr, 7); int16x8_t nxt0 = vextq_s16(curr, curr, 1); int16x8_t prev = vsetq_lane_s16(t1, prv0, 0); int16x8_t next = vsetq_lane_s16(3*in_near[i+8] + in_far[i+8], nxt0, 7); // horizontal filter, polyphase implementation since it's convenient: // even pixels = 3*cur + prev = cur*4 + (prev - cur) // odd pixels = 3*cur + next = cur*4 + (next - cur) // note the shared term. int16x8_t curs = vshlq_n_s16(curr, 2); int16x8_t prvd = vsubq_s16(prev, curr); int16x8_t nxtd = vsubq_s16(next, curr); int16x8_t even = vaddq_s16(curs, prvd); int16x8_t odd = vaddq_s16(curs, nxtd); // undo scaling and round, then store with even/odd phases interleaved uint8x8x2_t o; o.val[0] = vqrshrun_n_s16(even, 4); o.val[1] = vqrshrun_n_s16(odd, 4); vst2_u8(out + i*2, o); #endif // "previous" value for next iter t1 = 3*in_near[i+7] + in_far[i+7]; } t0 = t1; t1 = 3*in_near[i] + in_far[i]; out[i*2] = stbi__div16(3*t1 + t0 + 8); for (++i; i < w; ++i) { t0 = t1; t1 = 3*in_near[i]+in_far[i]; out[i*2-1] = stbi__div16(3*t0 + t1 + 8); out[i*2 ] = stbi__div16(3*t1 + t0 + 8); } out[w*2-1] = stbi__div4(t1+2); STBI_NOTUSED(hs); return out; } #endif static stbi_uc *stbi__resample_row_generic(stbi_uc *out, stbi_uc *in_near, stbi_uc *in_far, int w, int hs) { // resample with nearest-neighbor int i,j; STBI_NOTUSED(in_far); for (i=0; i < w; ++i) for (j=0; j < hs; ++j) out[i*hs+j] = in_near[i]; return out; } // this is a reduced-precision calculation of YCbCr-to-RGB introduced // to make sure the code produces the same results in both SIMD and scalar #define stbi__float2fixed(x) (((int) ((x) * 4096.0f + 0.5f)) << 8) static void stbi__YCbCr_to_RGB_row(stbi_uc *out, const stbi_uc *y, const stbi_uc *pcb, const stbi_uc *pcr, int count, int step) { int i; for (i=0; i < count; ++i) { int y_fixed = (y[i] << 20) + (1<<19); // rounding int r,g,b; int cr = pcr[i] - 128; int cb = pcb[i] - 128; r = y_fixed + cr* stbi__float2fixed(1.40200f); g = y_fixed + (cr*-stbi__float2fixed(0.71414f)) + ((cb*-stbi__float2fixed(0.34414f)) & 0xffff0000); b = y_fixed + cb* stbi__float2fixed(1.77200f); r >>= 20; g >>= 20; b >>= 20; if ((unsigned) r > 255) { if (r < 0) r = 0; else r = 255; } if ((unsigned) g > 255) { if (g < 0) g = 0; else g = 255; } if ((unsigned) b > 255) { if (b < 0) b = 0; else b = 255; } out[0] = (stbi_uc)r; out[1] = (stbi_uc)g; out[2] = (stbi_uc)b; out[3] = 255; out += step; } } #if defined(STBI_SSE2) || defined(STBI_NEON) static void stbi__YCbCr_to_RGB_simd(stbi_uc *out, stbi_uc const *y, stbi_uc const *pcb, stbi_uc const *pcr, int count, int step) { int i = 0; #ifdef STBI_SSE2 // step == 3 is pretty ugly on the final interleave, and i'm not convinced // it's useful in practice (you wouldn't use it for textures, for example). // so just accelerate step == 4 case. if (step == 4) { // this is a fairly straightforward implementation and not super-optimized. __m128i signflip = _mm_set1_epi8(-0x80); __m128i cr_const0 = _mm_set1_epi16( (short) ( 1.40200f*4096.0f+0.5f)); __m128i cr_const1 = _mm_set1_epi16( - (short) ( 0.71414f*4096.0f+0.5f)); __m128i cb_const0 = _mm_set1_epi16( - (short) ( 0.34414f*4096.0f+0.5f)); __m128i cb_const1 = _mm_set1_epi16( (short) ( 1.77200f*4096.0f+0.5f)); __m128i y_bias = _mm_set1_epi8((char) (unsigned char) 128); __m128i xw = _mm_set1_epi16(255); // alpha channel for (; i+7 < count; i += 8) { // load __m128i y_bytes = _mm_loadl_epi64((__m128i *) (y+i)); __m128i cr_bytes = _mm_loadl_epi64((__m128i *) (pcr+i)); __m128i cb_bytes = _mm_loadl_epi64((__m128i *) (pcb+i)); __m128i cr_biased = _mm_xor_si128(cr_bytes, signflip); // -128 __m128i cb_biased = _mm_xor_si128(cb_bytes, signflip); // -128 // unpack to short (and left-shift cr, cb by 8) __m128i yw = _mm_unpacklo_epi8(y_bias, y_bytes); __m128i crw = _mm_unpacklo_epi8(_mm_setzero_si128(), cr_biased); __m128i cbw = _mm_unpacklo_epi8(_mm_setzero_si128(), cb_biased); // color transform __m128i yws = _mm_srli_epi16(yw, 4); __m128i cr0 = _mm_mulhi_epi16(cr_const0, crw); __m128i cb0 = _mm_mulhi_epi16(cb_const0, cbw); __m128i cb1 = _mm_mulhi_epi16(cbw, cb_const1); __m128i cr1 = _mm_mulhi_epi16(crw, cr_const1); __m128i rws = _mm_add_epi16(cr0, yws); __m128i gwt = _mm_add_epi16(cb0, yws); __m128i bws = _mm_add_epi16(yws, cb1); __m128i gws = _mm_add_epi16(gwt, cr1); // descale __m128i rw = _mm_srai_epi16(rws, 4); __m128i bw = _mm_srai_epi16(bws, 4); __m128i gw = _mm_srai_epi16(gws, 4); // back to byte, set up for transpose __m128i brb = _mm_packus_epi16(rw, bw); __m128i gxb = _mm_packus_epi16(gw, xw); // transpose to interleave channels __m128i t0 = _mm_unpacklo_epi8(brb, gxb); __m128i t1 = _mm_unpackhi_epi8(brb, gxb); __m128i o0 = _mm_unpacklo_epi16(t0, t1); __m128i o1 = _mm_unpackhi_epi16(t0, t1); // store _mm_storeu_si128((__m128i *) (out + 0), o0); _mm_storeu_si128((__m128i *) (out + 16), o1); out += 32; } } #endif #ifdef STBI_NEON // in this version, step=3 support would be easy to add. but is there demand? if (step == 4) { // this is a fairly straightforward implementation and not super-optimized. uint8x8_t signflip = vdup_n_u8(0x80); int16x8_t cr_const0 = vdupq_n_s16( (short) ( 1.40200f*4096.0f+0.5f)); int16x8_t cr_const1 = vdupq_n_s16( - (short) ( 0.71414f*4096.0f+0.5f)); int16x8_t cb_const0 = vdupq_n_s16( - (short) ( 0.34414f*4096.0f+0.5f)); int16x8_t cb_const1 = vdupq_n_s16( (short) ( 1.77200f*4096.0f+0.5f)); for (; i+7 < count; i += 8) { // load uint8x8_t y_bytes = vld1_u8(y + i); uint8x8_t cr_bytes = vld1_u8(pcr + i); uint8x8_t cb_bytes = vld1_u8(pcb + i); int8x8_t cr_biased = vreinterpret_s8_u8(vsub_u8(cr_bytes, signflip)); int8x8_t cb_biased = vreinterpret_s8_u8(vsub_u8(cb_bytes, signflip)); // expand to s16 int16x8_t yws = vreinterpretq_s16_u16(vshll_n_u8(y_bytes, 4)); int16x8_t crw = vshll_n_s8(cr_biased, 7); int16x8_t cbw = vshll_n_s8(cb_biased, 7); // color transform int16x8_t cr0 = vqdmulhq_s16(crw, cr_const0); int16x8_t cb0 = vqdmulhq_s16(cbw, cb_const0); int16x8_t cr1 = vqdmulhq_s16(crw, cr_const1); int16x8_t cb1 = vqdmulhq_s16(cbw, cb_const1); int16x8_t rws = vaddq_s16(yws, cr0); int16x8_t gws = vaddq_s16(vaddq_s16(yws, cb0), cr1); int16x8_t bws = vaddq_s16(yws, cb1); // undo scaling, round, convert to byte uint8x8x4_t o; o.val[0] = vqrshrun_n_s16(rws, 4); o.val[1] = vqrshrun_n_s16(gws, 4); o.val[2] = vqrshrun_n_s16(bws, 4); o.val[3] = vdup_n_u8(255); // store, interleaving r/g/b/a vst4_u8(out, o); out += 8*4; } } #endif for (; i < count; ++i) { int y_fixed = (y[i] << 20) + (1<<19); // rounding int r,g,b; int cr = pcr[i] - 128; int cb = pcb[i] - 128; r = y_fixed + cr* stbi__float2fixed(1.40200f); g = y_fixed + cr*-stbi__float2fixed(0.71414f) + ((cb*-stbi__float2fixed(0.34414f)) & 0xffff0000); b = y_fixed + cb* stbi__float2fixed(1.77200f); r >>= 20; g >>= 20; b >>= 20; if ((unsigned) r > 255) { if (r < 0) r = 0; else r = 255; } if ((unsigned) g > 255) { if (g < 0) g = 0; else g = 255; } if ((unsigned) b > 255) { if (b < 0) b = 0; else b = 255; } out[0] = (stbi_uc)r; out[1] = (stbi_uc)g; out[2] = (stbi_uc)b; out[3] = 255; out += step; } } #endif // set up the kernels static void stbi__setup_jpeg(stbi__jpeg *j) { j->idct_block_kernel = stbi__idct_block; j->YCbCr_to_RGB_kernel = stbi__YCbCr_to_RGB_row; j->resample_row_hv_2_kernel = stbi__resample_row_hv_2; #ifdef STBI_SSE2 if (stbi__sse2_available()) { j->idct_block_kernel = stbi__idct_simd; j->YCbCr_to_RGB_kernel = stbi__YCbCr_to_RGB_simd; j->resample_row_hv_2_kernel = stbi__resample_row_hv_2_simd; } #endif #ifdef STBI_NEON j->idct_block_kernel = stbi__idct_simd; j->YCbCr_to_RGB_kernel = stbi__YCbCr_to_RGB_simd; j->resample_row_hv_2_kernel = stbi__resample_row_hv_2_simd; #endif } // clean up the temporary component buffers static void stbi__cleanup_jpeg(stbi__jpeg *j) { stbi__free_jpeg_components(j, j->s->img_n, 0); } typedef struct { resample_row_func resample; stbi_uc *line0,*line1; int hs,vs; // expansion factor in each axis int w_lores; // horizontal pixels pre-expansion int ystep; // how far through vertical expansion we are int ypos; // which pre-expansion row we're on } stbi__resample; // fast 0..255 * 0..255 => 0..255 rounded multiplication static stbi_uc stbi__blinn_8x8(stbi_uc x, stbi_uc y) { unsigned int t = x*y + 128; return (stbi_uc) ((t + (t >>8)) >> 8); } static stbi_uc *load_jpeg_image(stbi__jpeg *z, int *out_x, int *out_y, int *comp, int req_comp) { int n, decode_n, is_rgb; z->s->img_n = 0; // make stbi__cleanup_jpeg safe // validate req_comp if (req_comp < 0 || req_comp > 4) return stbi__errpuc("bad req_comp", "Internal error"); // load a jpeg image from whichever source, but leave in YCbCr format if (!stbi__decode_jpeg_image(z)) { stbi__cleanup_jpeg(z); return NULL; } // determine actual number of components to generate n = req_comp ? req_comp : z->s->img_n >= 3 ? 3 : 1; is_rgb = z->s->img_n == 3 && (z->rgb == 3 || (z->app14_color_transform == 0 && !z->jfif)); if (z->s->img_n == 3 && n < 3 && !is_rgb) decode_n = 1; else decode_n = z->s->img_n; // nothing to do if no components requested; check this now to avoid // accessing uninitialized coutput[0] later if (decode_n <= 0) { stbi__cleanup_jpeg(z); return NULL; } // resample and color-convert { int k; unsigned int i,j; stbi_uc *output; stbi_uc *coutput[4] = { NULL, NULL, NULL, NULL }; stbi__resample res_comp[4]; for (k=0; k < decode_n; ++k) { stbi__resample *r = &res_comp[k]; // allocate line buffer big enough for upsampling off the edges // with upsample factor of 4 z->img_comp[k].linebuf = (stbi_uc *) stbi__malloc(z->s->img_x + 3); if (!z->img_comp[k].linebuf) { stbi__cleanup_jpeg(z); return stbi__errpuc("outofmem", "Out of memory"); } r->hs = z->img_h_max / z->img_comp[k].h; r->vs = z->img_v_max / z->img_comp[k].v; r->ystep = r->vs >> 1; r->w_lores = (z->s->img_x + r->hs-1) / r->hs; r->ypos = 0; r->line0 = r->line1 = z->img_comp[k].data; if (r->hs == 1 && r->vs == 1) r->resample = resample_row_1; else if (r->hs == 1 && r->vs == 2) r->resample = stbi__resample_row_v_2; else if (r->hs == 2 && r->vs == 1) r->resample = stbi__resample_row_h_2; else if (r->hs == 2 && r->vs == 2) r->resample = z->resample_row_hv_2_kernel; else r->resample = stbi__resample_row_generic; } // can't error after this so, this is safe output = (stbi_uc *) stbi__malloc_mad3(n, z->s->img_x, z->s->img_y, 1); if (!output) { stbi__cleanup_jpeg(z); return stbi__errpuc("outofmem", "Out of memory"); } // now go ahead and resample for (j=0; j < z->s->img_y; ++j) { stbi_uc *out = output + n * z->s->img_x * j; for (k=0; k < decode_n; ++k) { stbi__resample *r = &res_comp[k]; int y_bot = r->ystep >= (r->vs >> 1); coutput[k] = r->resample(z->img_comp[k].linebuf, y_bot ? r->line1 : r->line0, y_bot ? r->line0 : r->line1, r->w_lores, r->hs); if (++r->ystep >= r->vs) { r->ystep = 0; r->line0 = r->line1; if (++r->ypos < z->img_comp[k].y) r->line1 += z->img_comp[k].w2; } } if (n >= 3) { stbi_uc *y = coutput[0]; if (z->s->img_n == 3) { if (is_rgb) { for (i=0; i < z->s->img_x; ++i) { out[0] = y[i]; out[1] = coutput[1][i]; out[2] = coutput[2][i]; out[3] = 255; out += n; } } else { z->YCbCr_to_RGB_kernel(out, y, coutput[1], coutput[2], z->s->img_x, n); } } else if (z->s->img_n == 4) { if (z->app14_color_transform == 0) { // CMYK for (i=0; i < z->s->img_x; ++i) { stbi_uc m = coutput[3][i]; out[0] = stbi__blinn_8x8(coutput[0][i], m); out[1] = stbi__blinn_8x8(coutput[1][i], m); out[2] = stbi__blinn_8x8(coutput[2][i], m); out[3] = 255; out += n; } } else if (z->app14_color_transform == 2) { // YCCK z->YCbCr_to_RGB_kernel(out, y, coutput[1], coutput[2], z->s->img_x, n); for (i=0; i < z->s->img_x; ++i) { stbi_uc m = coutput[3][i]; out[0] = stbi__blinn_8x8(255 - out[0], m); out[1] = stbi__blinn_8x8(255 - out[1], m); out[2] = stbi__blinn_8x8(255 - out[2], m); out += n; } } else { // YCbCr + alpha? Ignore the fourth channel for now z->YCbCr_to_RGB_kernel(out, y, coutput[1], coutput[2], z->s->img_x, n); } } else for (i=0; i < z->s->img_x; ++i) { out[0] = out[1] = out[2] = y[i]; out[3] = 255; // not used if n==3 out += n; } } else { if (is_rgb) { if (n == 1) for (i=0; i < z->s->img_x; ++i) *out++ = stbi__compute_y(coutput[0][i], coutput[1][i], coutput[2][i]); else { for (i=0; i < z->s->img_x; ++i, out += 2) { out[0] = stbi__compute_y(coutput[0][i], coutput[1][i], coutput[2][i]); out[1] = 255; } } } else if (z->s->img_n == 4 && z->app14_color_transform == 0) { for (i=0; i < z->s->img_x; ++i) { stbi_uc m = coutput[3][i]; stbi_uc r = stbi__blinn_8x8(coutput[0][i], m); stbi_uc g = stbi__blinn_8x8(coutput[1][i], m); stbi_uc b = stbi__blinn_8x8(coutput[2][i], m); out[0] = stbi__compute_y(r, g, b); out[1] = 255; out += n; } } else if (z->s->img_n == 4 && z->app14_color_transform == 2) { for (i=0; i < z->s->img_x; ++i) { out[0] = stbi__blinn_8x8(255 - coutput[0][i], coutput[3][i]); out[1] = 255; out += n; } } else { stbi_uc *y = coutput[0]; if (n == 1) for (i=0; i < z->s->img_x; ++i) out[i] = y[i]; else for (i=0; i < z->s->img_x; ++i) { *out++ = y[i]; *out++ = 255; } } } } stbi__cleanup_jpeg(z); *out_x = z->s->img_x; *out_y = z->s->img_y; if (comp) *comp = z->s->img_n >= 3 ? 3 : 1; // report original components, not output return output; } } static void *stbi__jpeg_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri) { unsigned char* result; stbi__jpeg* j = (stbi__jpeg*) stbi__malloc(sizeof(stbi__jpeg)); if (!j) return stbi__errpuc("outofmem", "Out of memory"); memset(j, 0, sizeof(stbi__jpeg)); STBI_NOTUSED(ri); j->s = s; stbi__setup_jpeg(j); result = load_jpeg_image(j, x,y,comp,req_comp); STBI_FREE(j); return result; } static int stbi__jpeg_test(stbi__context *s) { int r; stbi__jpeg* j = (stbi__jpeg*)stbi__malloc(sizeof(stbi__jpeg)); if (!j) return stbi__err("outofmem", "Out of memory"); memset(j, 0, sizeof(stbi__jpeg)); j->s = s; stbi__setup_jpeg(j); r = stbi__decode_jpeg_header(j, STBI__SCAN_type); stbi__rewind(s); STBI_FREE(j); return r; } static int stbi__jpeg_info_raw(stbi__jpeg *j, int *x, int *y, int *comp) { if (!stbi__decode_jpeg_header(j, STBI__SCAN_header)) { stbi__rewind( j->s ); return 0; } if (x) *x = j->s->img_x; if (y) *y = j->s->img_y; if (comp) *comp = j->s->img_n >= 3 ? 3 : 1; return 1; } static int stbi__jpeg_info(stbi__context *s, int *x, int *y, int *comp) { int result; stbi__jpeg* j = (stbi__jpeg*) (stbi__malloc(sizeof(stbi__jpeg))); if (!j) return stbi__err("outofmem", "Out of memory"); memset(j, 0, sizeof(stbi__jpeg)); j->s = s; result = stbi__jpeg_info_raw(j, x, y, comp); STBI_FREE(j); return result; } #endif // public domain zlib decode v0.2 Sean Barrett 2006-11-18 // simple implementation // - all input must be provided in an upfront buffer // - all output is written to a single output buffer (can malloc/realloc) // performance // - fast huffman #ifndef STBI_NO_ZLIB // fast-way is faster to check than jpeg huffman, but slow way is slower #define STBI__ZFAST_BITS 9 // accelerate all cases in default tables #define STBI__ZFAST_MASK ((1 << STBI__ZFAST_BITS) - 1) #define STBI__ZNSYMS 288 // number of symbols in literal/length alphabet // zlib-style huffman encoding // (jpegs packs from left, zlib from right, so can't share code) typedef struct { stbi__uint16 fast[1 << STBI__ZFAST_BITS]; stbi__uint16 firstcode[16]; int maxcode[17]; stbi__uint16 firstsymbol[16]; stbi_uc size[STBI__ZNSYMS]; stbi__uint16 value[STBI__ZNSYMS]; } stbi__zhuffman; stbi_inline static int stbi__bitreverse16(int n) { n = ((n & 0xAAAA) >> 1) | ((n & 0x5555) << 1); n = ((n & 0xCCCC) >> 2) | ((n & 0x3333) << 2); n = ((n & 0xF0F0) >> 4) | ((n & 0x0F0F) << 4); n = ((n & 0xFF00) >> 8) | ((n & 0x00FF) << 8); return n; } stbi_inline static int stbi__bit_reverse(int v, int bits) { STBI_ASSERT(bits <= 16); // to bit reverse n bits, reverse 16 and shift // e.g. 11 bits, bit reverse and shift away 5 return stbi__bitreverse16(v) >> (16-bits); } static int stbi__zbuild_huffman(stbi__zhuffman *z, const stbi_uc *sizelist, int num) { int i,k=0; int code, next_code[16], sizes[17]; // DEFLATE spec for generating codes memset(sizes, 0, sizeof(sizes)); memset(z->fast, 0, sizeof(z->fast)); for (i=0; i < num; ++i) ++sizes[sizelist[i]]; sizes[0] = 0; for (i=1; i < 16; ++i) if (sizes[i] > (1 << i)) return stbi__err("bad sizes", "Corrupt PNG"); code = 0; for (i=1; i < 16; ++i) { next_code[i] = code; z->firstcode[i] = (stbi__uint16) code; z->firstsymbol[i] = (stbi__uint16) k; code = (code + sizes[i]); if (sizes[i]) if (code-1 >= (1 << i)) return stbi__err("bad codelengths","Corrupt PNG"); z->maxcode[i] = code << (16-i); // preshift for inner loop code <<= 1; k += sizes[i]; } z->maxcode[16] = 0x10000; // sentinel for (i=0; i < num; ++i) { int s = sizelist[i]; if (s) { int c = next_code[s] - z->firstcode[s] + z->firstsymbol[s]; stbi__uint16 fastv = (stbi__uint16) ((s << 9) | i); z->size [c] = (stbi_uc ) s; z->value[c] = (stbi__uint16) i; if (s <= STBI__ZFAST_BITS) { int j = stbi__bit_reverse(next_code[s],s); while (j < (1 << STBI__ZFAST_BITS)) { z->fast[j] = fastv; j += (1 << s); } } ++next_code[s]; } } return 1; } // zlib-from-memory implementation for PNG reading // because PNG allows splitting the zlib stream arbitrarily, // and it's annoying structurally to have PNG call ZLIB call PNG, // we require PNG read all the IDATs and combine them into a single // memory buffer typedef struct { stbi_uc *zbuffer, *zbuffer_end; int num_bits; int hit_zeof_once; stbi__uint32 code_buffer; char *zout; char *zout_start; char *zout_end; int z_expandable; stbi__zhuffman z_length, z_distance; } stbi__zbuf; stbi_inline static int stbi__zeof(stbi__zbuf *z) { return (z->zbuffer >= z->zbuffer_end); } stbi_inline static stbi_uc stbi__zget8(stbi__zbuf *z) { return stbi__zeof(z) ? 0 : *z->zbuffer++; } static void stbi__fill_bits(stbi__zbuf *z) { do { if (z->code_buffer >= (1U << z->num_bits)) { z->zbuffer = z->zbuffer_end; /* treat this as EOF so we fail. */ return; } z->code_buffer |= (unsigned int) stbi__zget8(z) << z->num_bits; z->num_bits += 8; } while (z->num_bits <= 24); } stbi_inline static unsigned int stbi__zreceive(stbi__zbuf *z, int n) { unsigned int k; if (z->num_bits < n) stbi__fill_bits(z); k = z->code_buffer & ((1 << n) - 1); z->code_buffer >>= n; z->num_bits -= n; return k; } static int stbi__zhuffman_decode_slowpath(stbi__zbuf *a, stbi__zhuffman *z) { int b,s,k; // not resolved by fast table, so compute it the slow way // use jpeg approach, which requires MSbits at top k = stbi__bit_reverse(a->code_buffer, 16); for (s=STBI__ZFAST_BITS+1; ; ++s) if (k < z->maxcode[s]) break; if (s >= 16) return -1; // invalid code! // code size is s, so: b = (k >> (16-s)) - z->firstcode[s] + z->firstsymbol[s]; if (b >= STBI__ZNSYMS) return -1; // some data was corrupt somewhere! if (z->size[b] != s) return -1; // was originally an assert, but report failure instead. a->code_buffer >>= s; a->num_bits -= s; return z->value[b]; } stbi_inline static int stbi__zhuffman_decode(stbi__zbuf *a, stbi__zhuffman *z) { int b,s; if (a->num_bits < 16) { if (stbi__zeof(a)) { if (!a->hit_zeof_once) { // This is the first time we hit eof, insert 16 extra padding btis // to allow us to keep going; if we actually consume any of them // though, that is invalid data. This is caught later. a->hit_zeof_once = 1; a->num_bits += 16; // add 16 implicit zero bits } else { // We already inserted our extra 16 padding bits and are again // out, this stream is actually prematurely terminated. return -1; } } else { stbi__fill_bits(a); } } b = z->fast[a->code_buffer & STBI__ZFAST_MASK]; if (b) { s = b >> 9; a->code_buffer >>= s; a->num_bits -= s; return b & 511; } return stbi__zhuffman_decode_slowpath(a, z); } static int stbi__zexpand(stbi__zbuf *z, char *zout, int n) // need to make room for n bytes { char *q; unsigned int cur, limit, old_limit; z->zout = zout; if (!z->z_expandable) return stbi__err("output buffer limit","Corrupt PNG"); cur = (unsigned int) (z->zout - z->zout_start); limit = old_limit = (unsigned) (z->zout_end - z->zout_start); if (UINT_MAX - cur < (unsigned) n) return stbi__err("outofmem", "Out of memory"); while (cur + n > limit) { if(limit > UINT_MAX / 2) return stbi__err("outofmem", "Out of memory"); limit *= 2; } q = (char *) STBI_REALLOC_SIZED(z->zout_start, old_limit, limit); STBI_NOTUSED(old_limit); if (q == NULL) return stbi__err("outofmem", "Out of memory"); z->zout_start = q; z->zout = q + cur; z->zout_end = q + limit; return 1; } static const int stbi__zlength_base[31] = { 3,4,5,6,7,8,9,10,11,13, 15,17,19,23,27,31,35,43,51,59, 67,83,99,115,131,163,195,227,258,0,0 }; static const int stbi__zlength_extra[31]= { 0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0 }; static const int stbi__zdist_base[32] = { 1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193, 257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0}; static const int stbi__zdist_extra[32] = { 0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13}; static int stbi__parse_huffman_block(stbi__zbuf *a) { char *zout = a->zout; for(;;) { int z = stbi__zhuffman_decode(a, &a->z_length); if (z < 256) { if (z < 0) return stbi__err("bad huffman code","Corrupt PNG"); // error in huffman codes if (zout >= a->zout_end) { if (!stbi__zexpand(a, zout, 1)) return 0; zout = a->zout; } *zout++ = (char) z; } else { stbi_uc *p; int len,dist; if (z == 256) { a->zout = zout; if (a->hit_zeof_once && a->num_bits < 16) { // The first time we hit zeof, we inserted 16 extra zero bits into our bit // buffer so the decoder can just do its speculative decoding. But if we // actually consumed any of those bits (which is the case when num_bits < 16), // the stream actually read past the end so it is malformed. return stbi__err("unexpected end","Corrupt PNG"); } return 1; } if (z >= 286) return stbi__err("bad huffman code","Corrupt PNG"); // per DEFLATE, length codes 286 and 287 must not appear in compressed data z -= 257; len = stbi__zlength_base[z]; if (stbi__zlength_extra[z]) len += stbi__zreceive(a, stbi__zlength_extra[z]); z = stbi__zhuffman_decode(a, &a->z_distance); if (z < 0 || z >= 30) return stbi__err("bad huffman code","Corrupt PNG"); // per DEFLATE, distance codes 30 and 31 must not appear in compressed data dist = stbi__zdist_base[z]; if (stbi__zdist_extra[z]) dist += stbi__zreceive(a, stbi__zdist_extra[z]); if (zout - a->zout_start < dist) return stbi__err("bad dist","Corrupt PNG"); if (len > a->zout_end - zout) { if (!stbi__zexpand(a, zout, len)) return 0; zout = a->zout; } p = (stbi_uc *) (zout - dist); if (dist == 1) { // run of one byte; common in images. stbi_uc v = *p; if (len) { do *zout++ = v; while (--len); } } else { if (len) { do *zout++ = *p++; while (--len); } } } } } static int stbi__compute_huffman_codes(stbi__zbuf *a) { static const stbi_uc length_dezigzag[19] = { 16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15 }; stbi__zhuffman z_codelength; stbi_uc lencodes[286+32+137];//padding for maximum single op stbi_uc codelength_sizes[19]; int i,n; int hlit = stbi__zreceive(a,5) + 257; int hdist = stbi__zreceive(a,5) + 1; int hclen = stbi__zreceive(a,4) + 4; int ntot = hlit + hdist; memset(codelength_sizes, 0, sizeof(codelength_sizes)); for (i=0; i < hclen; ++i) { int s = stbi__zreceive(a,3); codelength_sizes[length_dezigzag[i]] = (stbi_uc) s; } if (!stbi__zbuild_huffman(&z_codelength, codelength_sizes, 19)) return 0; n = 0; while (n < ntot) { int c = stbi__zhuffman_decode(a, &z_codelength); if (c < 0 || c >= 19) return stbi__err("bad codelengths", "Corrupt PNG"); if (c < 16) lencodes[n++] = (stbi_uc) c; else { stbi_uc fill = 0; if (c == 16) { c = stbi__zreceive(a,2)+3; if (n == 0) return stbi__err("bad codelengths", "Corrupt PNG"); fill = lencodes[n-1]; } else if (c == 17) { c = stbi__zreceive(a,3)+3; } else if (c == 18) { c = stbi__zreceive(a,7)+11; } else { return stbi__err("bad codelengths", "Corrupt PNG"); } if (ntot - n < c) return stbi__err("bad codelengths", "Corrupt PNG"); memset(lencodes+n, fill, c); n += c; } } if (n != ntot) return stbi__err("bad codelengths","Corrupt PNG"); if (!stbi__zbuild_huffman(&a->z_length, lencodes, hlit)) return 0; if (!stbi__zbuild_huffman(&a->z_distance, lencodes+hlit, hdist)) return 0; return 1; } static int stbi__parse_uncompressed_block(stbi__zbuf *a) { stbi_uc header[4]; int len,nlen,k; if (a->num_bits & 7) stbi__zreceive(a, a->num_bits & 7); // discard // drain the bit-packed data into header k = 0; while (a->num_bits > 0) { header[k++] = (stbi_uc) (a->code_buffer & 255); // suppress MSVC run-time check a->code_buffer >>= 8; a->num_bits -= 8; } if (a->num_bits < 0) return stbi__err("zlib corrupt","Corrupt PNG"); // now fill header the normal way while (k < 4) header[k++] = stbi__zget8(a); len = header[1] * 256 + header[0]; nlen = header[3] * 256 + header[2]; if (nlen != (len ^ 0xffff)) return stbi__err("zlib corrupt","Corrupt PNG"); if (a->zbuffer + len > a->zbuffer_end) return stbi__err("read past buffer","Corrupt PNG"); if (a->zout + len > a->zout_end) if (!stbi__zexpand(a, a->zout, len)) return 0; memcpy(a->zout, a->zbuffer, len); a->zbuffer += len; a->zout += len; return 1; } static int stbi__parse_zlib_header(stbi__zbuf *a) { int cmf = stbi__zget8(a); int cm = cmf & 15; /* int cinfo = cmf >> 4; */ int flg = stbi__zget8(a); if (stbi__zeof(a)) return stbi__err("bad zlib header","Corrupt PNG"); // zlib spec if ((cmf*256+flg) % 31 != 0) return stbi__err("bad zlib header","Corrupt PNG"); // zlib spec if (flg & 32) return stbi__err("no preset dict","Corrupt PNG"); // preset dictionary not allowed in png if (cm != 8) return stbi__err("bad compression","Corrupt PNG"); // DEFLATE required for png // window = 1 << (8 + cinfo)... but who cares, we fully buffer output return 1; } static const stbi_uc stbi__zdefault_length[STBI__ZNSYMS] = { 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, 9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9, 9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9, 9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9, 9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9, 9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9, 9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9, 9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9, 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, 7,7,7,7,7,7,7,7,8,8,8,8,8,8,8,8 }; static const stbi_uc stbi__zdefault_distance[32] = { 5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5 }; /* Init algorithm: { int i; // use <= to match clearly with spec for (i=0; i <= 143; ++i) stbi__zdefault_length[i] = 8; for ( ; i <= 255; ++i) stbi__zdefault_length[i] = 9; for ( ; i <= 279; ++i) stbi__zdefault_length[i] = 7; for ( ; i <= 287; ++i) stbi__zdefault_length[i] = 8; for (i=0; i <= 31; ++i) stbi__zdefault_distance[i] = 5; } */ static int stbi__parse_zlib(stbi__zbuf *a, int parse_header) { int final, type; if (parse_header) if (!stbi__parse_zlib_header(a)) return 0; a->num_bits = 0; a->code_buffer = 0; a->hit_zeof_once = 0; do { final = stbi__zreceive(a,1); type = stbi__zreceive(a,2); if (type == 0) { if (!stbi__parse_uncompressed_block(a)) return 0; } else if (type == 3) { return 0; } else { if (type == 1) { // use fixed code lengths if (!stbi__zbuild_huffman(&a->z_length , stbi__zdefault_length , STBI__ZNSYMS)) return 0; if (!stbi__zbuild_huffman(&a->z_distance, stbi__zdefault_distance, 32)) return 0; } else { if (!stbi__compute_huffman_codes(a)) return 0; } if (!stbi__parse_huffman_block(a)) return 0; } } while (!final); return 1; } static int stbi__do_zlib(stbi__zbuf *a, char *obuf, int olen, int exp, int parse_header) { a->zout_start = obuf; a->zout = obuf; a->zout_end = obuf + olen; a->z_expandable = exp; return stbi__parse_zlib(a, parse_header); } STBIDEF char *stbi_zlib_decode_malloc_guesssize(const char *buffer, int len, int initial_size, int *outlen) { stbi__zbuf a; char *p = (char *) stbi__malloc(initial_size); if (p == NULL) return NULL; a.zbuffer = (stbi_uc *) buffer; a.zbuffer_end = (stbi_uc *) buffer + len; if (stbi__do_zlib(&a, p, initial_size, 1, 1)) { if (outlen) *outlen = (int) (a.zout - a.zout_start); return a.zout_start; } else { STBI_FREE(a.zout_start); return NULL; } } STBIDEF char *stbi_zlib_decode_malloc(char const *buffer, int len, int *outlen) { return stbi_zlib_decode_malloc_guesssize(buffer, len, 16384, outlen); } STBIDEF char *stbi_zlib_decode_malloc_guesssize_headerflag(const char *buffer, int len, int initial_size, int *outlen, int parse_header) { stbi__zbuf a; char *p = (char *) stbi__malloc(initial_size); if (p == NULL) return NULL; a.zbuffer = (stbi_uc *) buffer; a.zbuffer_end = (stbi_uc *) buffer + len; if (stbi__do_zlib(&a, p, initial_size, 1, parse_header)) { if (outlen) *outlen = (int) (a.zout - a.zout_start); return a.zout_start; } else { STBI_FREE(a.zout_start); return NULL; } } STBIDEF int stbi_zlib_decode_buffer(char *obuffer, int olen, char const *ibuffer, int ilen) { stbi__zbuf a; a.zbuffer = (stbi_uc *) ibuffer; a.zbuffer_end = (stbi_uc *) ibuffer + ilen; if (stbi__do_zlib(&a, obuffer, olen, 0, 1)) return (int) (a.zout - a.zout_start); else return -1; } STBIDEF char *stbi_zlib_decode_noheader_malloc(char const *buffer, int len, int *outlen) { stbi__zbuf a; char *p = (char *) stbi__malloc(16384); if (p == NULL) return NULL; a.zbuffer = (stbi_uc *) buffer; a.zbuffer_end = (stbi_uc *) buffer+len; if (stbi__do_zlib(&a, p, 16384, 1, 0)) { if (outlen) *outlen = (int) (a.zout - a.zout_start); return a.zout_start; } else { STBI_FREE(a.zout_start); return NULL; } } STBIDEF int stbi_zlib_decode_noheader_buffer(char *obuffer, int olen, const char *ibuffer, int ilen) { stbi__zbuf a; a.zbuffer = (stbi_uc *) ibuffer; a.zbuffer_end = (stbi_uc *) ibuffer + ilen; if (stbi__do_zlib(&a, obuffer, olen, 0, 0)) return (int) (a.zout - a.zout_start); else return -1; } #endif // public domain "baseline" PNG decoder v0.10 Sean Barrett 2006-11-18 // simple implementation // - only 8-bit samples // - no CRC checking // - allocates lots of intermediate memory // - avoids problem of streaming data between subsystems // - avoids explicit window management // performance // - uses stb_zlib, a PD zlib implementation with fast huffman decoding #ifndef STBI_NO_PNG typedef struct { stbi__uint32 length; stbi__uint32 type; } stbi__pngchunk; static stbi__pngchunk stbi__get_chunk_header(stbi__context *s) { stbi__pngchunk c; c.length = stbi__get32be(s); c.type = stbi__get32be(s); return c; } static int stbi__check_png_header(stbi__context *s) { static const stbi_uc png_sig[8] = { 137,80,78,71,13,10,26,10 }; int i; for (i=0; i < 8; ++i) if (stbi__get8(s) != png_sig[i]) return stbi__err("bad png sig","Not a PNG"); return 1; } typedef struct { stbi__context *s; stbi_uc *idata, *expanded, *out; int depth; } stbi__png; enum { STBI__F_none=0, STBI__F_sub=1, STBI__F_up=2, STBI__F_avg=3, STBI__F_paeth=4, // synthetic filter used for first scanline to avoid needing a dummy row of 0s STBI__F_avg_first }; static stbi_uc first_row_filter[5] = { STBI__F_none, STBI__F_sub, STBI__F_none, STBI__F_avg_first, STBI__F_sub // Paeth with b=c=0 turns out to be equivalent to sub }; static int stbi__paeth(int a, int b, int c) { // This formulation looks very different from the reference in the PNG spec, but is // actually equivalent and has favorable data dependencies and admits straightforward // generation of branch-free code, which helps performance significantly. int thresh = c*3 - (a + b); int lo = a < b ? a : b; int hi = a < b ? b : a; int t0 = (hi <= thresh) ? lo : c; int t1 = (thresh <= lo) ? hi : t0; return t1; } static const stbi_uc stbi__depth_scale_table[9] = { 0, 0xff, 0x55, 0, 0x11, 0,0,0, 0x01 }; // adds an extra all-255 alpha channel // dest == src is legal // img_n must be 1 or 3 static void stbi__create_png_alpha_expand8(stbi_uc *dest, stbi_uc *src, stbi__uint32 x, int img_n) { int i; // must process data backwards since we allow dest==src if (img_n == 1) { for (i=x-1; i >= 0; --i) { dest[i*2+1] = 255; dest[i*2+0] = src[i]; } } else { STBI_ASSERT(img_n == 3); for (i=x-1; i >= 0; --i) { dest[i*4+3] = 255; dest[i*4+2] = src[i*3+2]; dest[i*4+1] = src[i*3+1]; dest[i*4+0] = src[i*3+0]; } } } // create the png data from post-deflated data static int stbi__create_png_image_raw(stbi__png *a, stbi_uc *raw, stbi__uint32 raw_len, int out_n, stbi__uint32 x, stbi__uint32 y, int depth, int color) { int bytes = (depth == 16 ? 2 : 1); stbi__context *s = a->s; stbi__uint32 i,j,stride = x*out_n*bytes; stbi__uint32 img_len, img_width_bytes; stbi_uc *filter_buf; int all_ok = 1; int k; int img_n = s->img_n; // copy it into a local for later int output_bytes = out_n*bytes; int filter_bytes = img_n*bytes; int width = x; STBI_ASSERT(out_n == s->img_n || out_n == s->img_n+1); a->out = (stbi_uc *) stbi__malloc_mad3(x, y, output_bytes, 0); // extra bytes to write off the end into if (!a->out) return stbi__err("outofmem", "Out of memory"); // note: error exits here don't need to clean up a->out individually, // stbi__do_png always does on error. if (!stbi__mad3sizes_valid(img_n, x, depth, 7)) return stbi__err("too large", "Corrupt PNG"); img_width_bytes = (((img_n * x * depth) + 7) >> 3); if (!stbi__mad2sizes_valid(img_width_bytes, y, img_width_bytes)) return stbi__err("too large", "Corrupt PNG"); img_len = (img_width_bytes + 1) * y; // we used to check for exact match between raw_len and img_len on non-interlaced PNGs, // but issue #276 reported a PNG in the wild that had extra data at the end (all zeros), // so just check for raw_len < img_len always. if (raw_len < img_len) return stbi__err("not enough pixels","Corrupt PNG"); // Allocate two scan lines worth of filter workspace buffer. filter_buf = (stbi_uc *) stbi__malloc_mad2(img_width_bytes, 2, 0); if (!filter_buf) return stbi__err("outofmem", "Out of memory"); // Filtering for low-bit-depth images if (depth < 8) { filter_bytes = 1; width = img_width_bytes; } for (j=0; j < y; ++j) { // cur/prior filter buffers alternate stbi_uc *cur = filter_buf + (j & 1)*img_width_bytes; stbi_uc *prior = filter_buf + (~j & 1)*img_width_bytes; stbi_uc *dest = a->out + stride*j; int nk = width * filter_bytes; int filter = *raw++; // check filter type if (filter > 4) { all_ok = stbi__err("invalid filter","Corrupt PNG"); break; } // if first row, use special filter that doesn't sample previous row if (j == 0) filter = first_row_filter[filter]; // perform actual filtering switch (filter) { case STBI__F_none: memcpy(cur, raw, nk); break; case STBI__F_sub: memcpy(cur, raw, filter_bytes); for (k = filter_bytes; k < nk; ++k) cur[k] = STBI__BYTECAST(raw[k] + cur[k-filter_bytes]); break; case STBI__F_up: for (k = 0; k < nk; ++k) cur[k] = STBI__BYTECAST(raw[k] + prior[k]); break; case STBI__F_avg: for (k = 0; k < filter_bytes; ++k) cur[k] = STBI__BYTECAST(raw[k] + (prior[k]>>1)); for (k = filter_bytes; k < nk; ++k) cur[k] = STBI__BYTECAST(raw[k] + ((prior[k] + cur[k-filter_bytes])>>1)); break; case STBI__F_paeth: for (k = 0; k < filter_bytes; ++k) cur[k] = STBI__BYTECAST(raw[k] + prior[k]); // prior[k] == stbi__paeth(0,prior[k],0) for (k = filter_bytes; k < nk; ++k) cur[k] = STBI__BYTECAST(raw[k] + stbi__paeth(cur[k-filter_bytes], prior[k], prior[k-filter_bytes])); break; case STBI__F_avg_first: memcpy(cur, raw, filter_bytes); for (k = filter_bytes; k < nk; ++k) cur[k] = STBI__BYTECAST(raw[k] + (cur[k-filter_bytes] >> 1)); break; } raw += nk; // expand decoded bits in cur to dest, also adding an extra alpha channel if desired if (depth < 8) { stbi_uc scale = (color == 0) ? stbi__depth_scale_table[depth] : 1; // scale grayscale values to 0..255 range stbi_uc *in = cur; stbi_uc *out = dest; stbi_uc inb = 0; stbi__uint32 nsmp = x*img_n; // expand bits to bytes first if (depth == 4) { for (i=0; i < nsmp; ++i) { if ((i & 1) == 0) inb = *in++; *out++ = scale * (inb >> 4); inb <<= 4; } } else if (depth == 2) { for (i=0; i < nsmp; ++i) { if ((i & 3) == 0) inb = *in++; *out++ = scale * (inb >> 6); inb <<= 2; } } else { STBI_ASSERT(depth == 1); for (i=0; i < nsmp; ++i) { if ((i & 7) == 0) inb = *in++; *out++ = scale * (inb >> 7); inb <<= 1; } } // insert alpha=255 values if desired if (img_n != out_n) stbi__create_png_alpha_expand8(dest, dest, x, img_n); } else if (depth == 8) { if (img_n == out_n) memcpy(dest, cur, x*img_n); else stbi__create_png_alpha_expand8(dest, cur, x, img_n); } else if (depth == 16) { // convert the image data from big-endian to platform-native stbi__uint16 *dest16 = (stbi__uint16*)dest; stbi__uint32 nsmp = x*img_n; if (img_n == out_n) { for (i = 0; i < nsmp; ++i, ++dest16, cur += 2) *dest16 = (cur[0] << 8) | cur[1]; } else { STBI_ASSERT(img_n+1 == out_n); if (img_n == 1) { for (i = 0; i < x; ++i, dest16 += 2, cur += 2) { dest16[0] = (cur[0] << 8) | cur[1]; dest16[1] = 0xffff; } } else { STBI_ASSERT(img_n == 3); for (i = 0; i < x; ++i, dest16 += 4, cur += 6) { dest16[0] = (cur[0] << 8) | cur[1]; dest16[1] = (cur[2] << 8) | cur[3]; dest16[2] = (cur[4] << 8) | cur[5]; dest16[3] = 0xffff; } } } } } STBI_FREE(filter_buf); if (!all_ok) return 0; return 1; } static int stbi__create_png_image(stbi__png *a, stbi_uc *image_data, stbi__uint32 image_data_len, int out_n, int depth, int color, int interlaced) { int bytes = (depth == 16 ? 2 : 1); int out_bytes = out_n * bytes; stbi_uc *final; int p; if (!interlaced) return stbi__create_png_image_raw(a, image_data, image_data_len, out_n, a->s->img_x, a->s->img_y, depth, color); // de-interlacing final = (stbi_uc *) stbi__malloc_mad3(a->s->img_x, a->s->img_y, out_bytes, 0); if (!final) return stbi__err("outofmem", "Out of memory"); for (p=0; p < 7; ++p) { int xorig[] = { 0,4,0,2,0,1,0 }; int yorig[] = { 0,0,4,0,2,0,1 }; int xspc[] = { 8,8,4,4,2,2,1 }; int yspc[] = { 8,8,8,4,4,2,2 }; int i,j,x,y; // pass1_x[4] = 0, pass1_x[5] = 1, pass1_x[12] = 1 x = (a->s->img_x - xorig[p] + xspc[p]-1) / xspc[p]; y = (a->s->img_y - yorig[p] + yspc[p]-1) / yspc[p]; if (x && y) { stbi__uint32 img_len = ((((a->s->img_n * x * depth) + 7) >> 3) + 1) * y; if (!stbi__create_png_image_raw(a, image_data, image_data_len, out_n, x, y, depth, color)) { STBI_FREE(final); return 0; } for (j=0; j < y; ++j) { for (i=0; i < x; ++i) { int out_y = j*yspc[p]+yorig[p]; int out_x = i*xspc[p]+xorig[p]; memcpy(final + out_y*a->s->img_x*out_bytes + out_x*out_bytes, a->out + (j*x+i)*out_bytes, out_bytes); } } STBI_FREE(a->out); image_data += img_len; image_data_len -= img_len; } } a->out = final; return 1; } static int stbi__compute_transparency(stbi__png *z, stbi_uc tc[3], int out_n) { stbi__context *s = z->s; stbi__uint32 i, pixel_count = s->img_x * s->img_y; stbi_uc *p = z->out; // compute color-based transparency, assuming we've // already got 255 as the alpha value in the output STBI_ASSERT(out_n == 2 || out_n == 4); if (out_n == 2) { for (i=0; i < pixel_count; ++i) { p[1] = (p[0] == tc[0] ? 0 : 255); p += 2; } } else { for (i=0; i < pixel_count; ++i) { if (p[0] == tc[0] && p[1] == tc[1] && p[2] == tc[2]) p[3] = 0; p += 4; } } return 1; } static int stbi__compute_transparency16(stbi__png *z, stbi__uint16 tc[3], int out_n) { stbi__context *s = z->s; stbi__uint32 i, pixel_count = s->img_x * s->img_y; stbi__uint16 *p = (stbi__uint16*) z->out; // compute color-based transparency, assuming we've // already got 65535 as the alpha value in the output STBI_ASSERT(out_n == 2 || out_n == 4); if (out_n == 2) { for (i = 0; i < pixel_count; ++i) { p[1] = (p[0] == tc[0] ? 0 : 65535); p += 2; } } else { for (i = 0; i < pixel_count; ++i) { if (p[0] == tc[0] && p[1] == tc[1] && p[2] == tc[2]) p[3] = 0; p += 4; } } return 1; } static int stbi__expand_png_palette(stbi__png *a, stbi_uc *palette, int len, int pal_img_n) { stbi__uint32 i, pixel_count = a->s->img_x * a->s->img_y; stbi_uc *p, *temp_out, *orig = a->out; p = (stbi_uc *) stbi__malloc_mad2(pixel_count, pal_img_n, 0); if (p == NULL) return stbi__err("outofmem", "Out of memory"); // between here and free(out) below, exitting would leak temp_out = p; if (pal_img_n == 3) { for (i=0; i < pixel_count; ++i) { int n = orig[i]*4; p[0] = palette[n ]; p[1] = palette[n+1]; p[2] = palette[n+2]; p += 3; } } else { for (i=0; i < pixel_count; ++i) { int n = orig[i]*4; p[0] = palette[n ]; p[1] = palette[n+1]; p[2] = palette[n+2]; p[3] = palette[n+3]; p += 4; } } STBI_FREE(a->out); a->out = temp_out; STBI_NOTUSED(len); return 1; } static int stbi__unpremultiply_on_load_global = 0; static int stbi__de_iphone_flag_global = 0; STBIDEF void stbi_set_unpremultiply_on_load(int flag_true_if_should_unpremultiply) { stbi__unpremultiply_on_load_global = flag_true_if_should_unpremultiply; } STBIDEF void stbi_convert_iphone_png_to_rgb(int flag_true_if_should_convert) { stbi__de_iphone_flag_global = flag_true_if_should_convert; } #ifndef STBI_THREAD_LOCAL #define stbi__unpremultiply_on_load stbi__unpremultiply_on_load_global #define stbi__de_iphone_flag stbi__de_iphone_flag_global #else static STBI_THREAD_LOCAL int stbi__unpremultiply_on_load_local, stbi__unpremultiply_on_load_set; static STBI_THREAD_LOCAL int stbi__de_iphone_flag_local, stbi__de_iphone_flag_set; STBIDEF void stbi_set_unpremultiply_on_load_thread(int flag_true_if_should_unpremultiply) { stbi__unpremultiply_on_load_local = flag_true_if_should_unpremultiply; stbi__unpremultiply_on_load_set = 1; } STBIDEF void stbi_convert_iphone_png_to_rgb_thread(int flag_true_if_should_convert) { stbi__de_iphone_flag_local = flag_true_if_should_convert; stbi__de_iphone_flag_set = 1; } #define stbi__unpremultiply_on_load (stbi__unpremultiply_on_load_set \ ? stbi__unpremultiply_on_load_local \ : stbi__unpremultiply_on_load_global) #define stbi__de_iphone_flag (stbi__de_iphone_flag_set \ ? stbi__de_iphone_flag_local \ : stbi__de_iphone_flag_global) #endif // STBI_THREAD_LOCAL static void stbi__de_iphone(stbi__png *z) { stbi__context *s = z->s; stbi__uint32 i, pixel_count = s->img_x * s->img_y; stbi_uc *p = z->out; if (s->img_out_n == 3) { // convert bgr to rgb for (i=0; i < pixel_count; ++i) { stbi_uc t = p[0]; p[0] = p[2]; p[2] = t; p += 3; } } else { STBI_ASSERT(s->img_out_n == 4); if (stbi__unpremultiply_on_load) { // convert bgr to rgb and unpremultiply for (i=0; i < pixel_count; ++i) { stbi_uc a = p[3]; stbi_uc t = p[0]; if (a) { stbi_uc half = a / 2; p[0] = (p[2] * 255 + half) / a; p[1] = (p[1] * 255 + half) / a; p[2] = ( t * 255 + half) / a; } else { p[0] = p[2]; p[2] = t; } p += 4; } } else { // convert bgr to rgb for (i=0; i < pixel_count; ++i) { stbi_uc t = p[0]; p[0] = p[2]; p[2] = t; p += 4; } } } } #define STBI__PNG_TYPE(a,b,c,d) (((unsigned) (a) << 24) + ((unsigned) (b) << 16) + ((unsigned) (c) << 8) + (unsigned) (d)) static int stbi__parse_png_file(stbi__png *z, int scan, int req_comp) { stbi_uc palette[1024], pal_img_n=0; stbi_uc has_trans=0, tc[3]={0}; stbi__uint16 tc16[3]; stbi__uint32 ioff=0, idata_limit=0, i, pal_len=0; int first=1,k,interlace=0, color=0, is_iphone=0; stbi__context *s = z->s; z->expanded = NULL; z->idata = NULL; z->out = NULL; if (!stbi__check_png_header(s)) return 0; if (scan == STBI__SCAN_type) return 1; for (;;) { stbi__pngchunk c = stbi__get_chunk_header(s); switch (c.type) { case STBI__PNG_TYPE('C','g','B','I'): is_iphone = 1; stbi__skip(s, c.length); break; case STBI__PNG_TYPE('I','H','D','R'): { int comp,filter; if (!first) return stbi__err("multiple IHDR","Corrupt PNG"); first = 0; if (c.length != 13) return stbi__err("bad IHDR len","Corrupt PNG"); s->img_x = stbi__get32be(s); s->img_y = stbi__get32be(s); if (s->img_y > STBI_MAX_DIMENSIONS) return stbi__err("too large","Very large image (corrupt?)"); if (s->img_x > STBI_MAX_DIMENSIONS) return stbi__err("too large","Very large image (corrupt?)"); z->depth = stbi__get8(s); if (z->depth != 1 && z->depth != 2 && z->depth != 4 && z->depth != 8 && z->depth != 16) return stbi__err("1/2/4/8/16-bit only","PNG not supported: 1/2/4/8/16-bit only"); color = stbi__get8(s); if (color > 6) return stbi__err("bad ctype","Corrupt PNG"); if (color == 3 && z->depth == 16) return stbi__err("bad ctype","Corrupt PNG"); if (color == 3) pal_img_n = 3; else if (color & 1) return stbi__err("bad ctype","Corrupt PNG"); comp = stbi__get8(s); if (comp) return stbi__err("bad comp method","Corrupt PNG"); filter= stbi__get8(s); if (filter) return stbi__err("bad filter method","Corrupt PNG"); interlace = stbi__get8(s); if (interlace>1) return stbi__err("bad interlace method","Corrupt PNG"); if (!s->img_x || !s->img_y) return stbi__err("0-pixel image","Corrupt PNG"); if (!pal_img_n) { s->img_n = (color & 2 ? 3 : 1) + (color & 4 ? 1 : 0); if ((1 << 30) / s->img_x / s->img_n < s->img_y) return stbi__err("too large", "Image too large to decode"); } else { // if paletted, then pal_n is our final components, and // img_n is # components to decompress/filter. s->img_n = 1; if ((1 << 30) / s->img_x / 4 < s->img_y) return stbi__err("too large","Corrupt PNG"); } // even with SCAN_header, have to scan to see if we have a tRNS break; } case STBI__PNG_TYPE('P','L','T','E'): { if (first) return stbi__err("first not IHDR", "Corrupt PNG"); if (c.length > 256*3) return stbi__err("invalid PLTE","Corrupt PNG"); pal_len = c.length / 3; if (pal_len * 3 != c.length) return stbi__err("invalid PLTE","Corrupt PNG"); for (i=0; i < pal_len; ++i) { palette[i*4+0] = stbi__get8(s); palette[i*4+1] = stbi__get8(s); palette[i*4+2] = stbi__get8(s); palette[i*4+3] = 255; } break; } case STBI__PNG_TYPE('t','R','N','S'): { if (first) return stbi__err("first not IHDR", "Corrupt PNG"); if (z->idata) return stbi__err("tRNS after IDAT","Corrupt PNG"); if (pal_img_n) { if (scan == STBI__SCAN_header) { s->img_n = 4; return 1; } if (pal_len == 0) return stbi__err("tRNS before PLTE","Corrupt PNG"); if (c.length > pal_len) return stbi__err("bad tRNS len","Corrupt PNG"); pal_img_n = 4; for (i=0; i < c.length; ++i) palette[i*4+3] = stbi__get8(s); } else { if (!(s->img_n & 1)) return stbi__err("tRNS with alpha","Corrupt PNG"); if (c.length != (stbi__uint32) s->img_n*2) return stbi__err("bad tRNS len","Corrupt PNG"); has_trans = 1; // non-paletted with tRNS = constant alpha. if header-scanning, we can stop now. if (scan == STBI__SCAN_header) { ++s->img_n; return 1; } if (z->depth == 16) { for (k = 0; k < s->img_n && k < 3; ++k) // extra loop test to suppress false GCC warning tc16[k] = (stbi__uint16)stbi__get16be(s); // copy the values as-is } else { for (k = 0; k < s->img_n && k < 3; ++k) tc[k] = (stbi_uc)(stbi__get16be(s) & 255) * stbi__depth_scale_table[z->depth]; // non 8-bit images will be larger } } break; } case STBI__PNG_TYPE('I','D','A','T'): { if (first) return stbi__err("first not IHDR", "Corrupt PNG"); if (pal_img_n && !pal_len) return stbi__err("no PLTE","Corrupt PNG"); if (scan == STBI__SCAN_header) { // header scan definitely stops at first IDAT if (pal_img_n) s->img_n = pal_img_n; return 1; } if (c.length > (1u << 30)) return stbi__err("IDAT size limit", "IDAT section larger than 2^30 bytes"); if ((int)(ioff + c.length) < (int)ioff) return 0; if (ioff + c.length > idata_limit) { stbi__uint32 idata_limit_old = idata_limit; stbi_uc *p; if (idata_limit == 0) idata_limit = c.length > 4096 ? c.length : 4096; while (ioff + c.length > idata_limit) idata_limit *= 2; STBI_NOTUSED(idata_limit_old); p = (stbi_uc *) STBI_REALLOC_SIZED(z->idata, idata_limit_old, idata_limit); if (p == NULL) return stbi__err("outofmem", "Out of memory"); z->idata = p; } if (!stbi__getn(s, z->idata+ioff,c.length)) return stbi__err("outofdata","Corrupt PNG"); ioff += c.length; break; } case STBI__PNG_TYPE('I','E','N','D'): { stbi__uint32 raw_len, bpl; if (first) return stbi__err("first not IHDR", "Corrupt PNG"); if (scan != STBI__SCAN_load) return 1; if (z->idata == NULL) return stbi__err("no IDAT","Corrupt PNG"); // initial guess for decoded data size to avoid unnecessary reallocs bpl = (s->img_x * z->depth + 7) / 8; // bytes per line, per component raw_len = bpl * s->img_y * s->img_n /* pixels */ + s->img_y /* filter mode per row */; z->expanded = (stbi_uc *) stbi_zlib_decode_malloc_guesssize_headerflag((char *) z->idata, ioff, raw_len, (int *) &raw_len, !is_iphone); if (z->expanded == NULL) return 0; // zlib should set error STBI_FREE(z->idata); z->idata = NULL; if ((req_comp == s->img_n+1 && req_comp != 3 && !pal_img_n) || has_trans) s->img_out_n = s->img_n+1; else s->img_out_n = s->img_n; if (!stbi__create_png_image(z, z->expanded, raw_len, s->img_out_n, z->depth, color, interlace)) return 0; if (has_trans) { if (z->depth == 16) { if (!stbi__compute_transparency16(z, tc16, s->img_out_n)) return 0; } else { if (!stbi__compute_transparency(z, tc, s->img_out_n)) return 0; } } if (is_iphone && stbi__de_iphone_flag && s->img_out_n > 2) stbi__de_iphone(z); if (pal_img_n) { // pal_img_n == 3 or 4 s->img_n = pal_img_n; // record the actual colors we had s->img_out_n = pal_img_n; if (req_comp >= 3) s->img_out_n = req_comp; if (!stbi__expand_png_palette(z, palette, pal_len, s->img_out_n)) return 0; } else if (has_trans) { // non-paletted image with tRNS -> source image has (constant) alpha ++s->img_n; } STBI_FREE(z->expanded); z->expanded = NULL; // end of PNG chunk, read and skip CRC stbi__get32be(s); return 1; } default: // if critical, fail if (first) return stbi__err("first not IHDR", "Corrupt PNG"); if ((c.type & (1 << 29)) == 0) { #ifndef STBI_NO_FAILURE_STRINGS // not threadsafe static char invalid_chunk[] = "XXXX PNG chunk not known"; invalid_chunk[0] = STBI__BYTECAST(c.type >> 24); invalid_chunk[1] = STBI__BYTECAST(c.type >> 16); invalid_chunk[2] = STBI__BYTECAST(c.type >> 8); invalid_chunk[3] = STBI__BYTECAST(c.type >> 0); #endif return stbi__err(invalid_chunk, "PNG not supported: unknown PNG chunk type"); } stbi__skip(s, c.length); break; } // end of PNG chunk, read and skip CRC stbi__get32be(s); } } static void *stbi__do_png(stbi__png *p, int *x, int *y, int *n, int req_comp, stbi__result_info *ri) { void *result=NULL; if (req_comp < 0 || req_comp > 4) return stbi__errpuc("bad req_comp", "Internal error"); if (stbi__parse_png_file(p, STBI__SCAN_load, req_comp)) { if (p->depth <= 8) ri->bits_per_channel = 8; else if (p->depth == 16) ri->bits_per_channel = 16; else return stbi__errpuc("bad bits_per_channel", "PNG not supported: unsupported color depth"); result = p->out; p->out = NULL; if (req_comp && req_comp != p->s->img_out_n) { if (ri->bits_per_channel == 8) result = stbi__convert_format((unsigned char *) result, p->s->img_out_n, req_comp, p->s->img_x, p->s->img_y); else result = stbi__convert_format16((stbi__uint16 *) result, p->s->img_out_n, req_comp, p->s->img_x, p->s->img_y); p->s->img_out_n = req_comp; if (result == NULL) return result; } *x = p->s->img_x; *y = p->s->img_y; if (n) *n = p->s->img_n; } STBI_FREE(p->out); p->out = NULL; STBI_FREE(p->expanded); p->expanded = NULL; STBI_FREE(p->idata); p->idata = NULL; return result; } static void *stbi__png_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri) { stbi__png p; p.s = s; return stbi__do_png(&p, x,y,comp,req_comp, ri); } static int stbi__png_test(stbi__context *s) { int r; r = stbi__check_png_header(s); stbi__rewind(s); return r; } static int stbi__png_info_raw(stbi__png *p, int *x, int *y, int *comp) { if (!stbi__parse_png_file(p, STBI__SCAN_header, 0)) { stbi__rewind( p->s ); return 0; } if (x) *x = p->s->img_x; if (y) *y = p->s->img_y; if (comp) *comp = p->s->img_n; return 1; } static int stbi__png_info(stbi__context *s, int *x, int *y, int *comp) { stbi__png p; p.s = s; return stbi__png_info_raw(&p, x, y, comp); } static int stbi__png_is16(stbi__context *s) { stbi__png p; p.s = s; if (!stbi__png_info_raw(&p, NULL, NULL, NULL)) return 0; if (p.depth != 16) { stbi__rewind(p.s); return 0; } return 1; } #endif // Microsoft/Windows BMP image #ifndef STBI_NO_BMP static int stbi__bmp_test_raw(stbi__context *s) { int r; int sz; if (stbi__get8(s) != 'B') return 0; if (stbi__get8(s) != 'M') return 0; stbi__get32le(s); // discard filesize stbi__get16le(s); // discard reserved stbi__get16le(s); // discard reserved stbi__get32le(s); // discard data offset sz = stbi__get32le(s); r = (sz == 12 || sz == 40 || sz == 56 || sz == 108 || sz == 124); return r; } static int stbi__bmp_test(stbi__context *s) { int r = stbi__bmp_test_raw(s); stbi__rewind(s); return r; } // returns 0..31 for the highest set bit static int stbi__high_bit(unsigned int z) { int n=0; if (z == 0) return -1; if (z >= 0x10000) { n += 16; z >>= 16; } if (z >= 0x00100) { n += 8; z >>= 8; } if (z >= 0x00010) { n += 4; z >>= 4; } if (z >= 0x00004) { n += 2; z >>= 2; } if (z >= 0x00002) { n += 1;/* >>= 1;*/ } return n; } static int stbi__bitcount(unsigned int a) { a = (a & 0x55555555) + ((a >> 1) & 0x55555555); // max 2 a = (a & 0x33333333) + ((a >> 2) & 0x33333333); // max 4 a = (a + (a >> 4)) & 0x0f0f0f0f; // max 8 per 4, now 8 bits a = (a + (a >> 8)); // max 16 per 8 bits a = (a + (a >> 16)); // max 32 per 8 bits return a & 0xff; } // extract an arbitrarily-aligned N-bit value (N=bits) // from v, and then make it 8-bits long and fractionally // extend it to full full range. static int stbi__shiftsigned(unsigned int v, int shift, int bits) { static unsigned int mul_table[9] = { 0, 0xff/*0b11111111*/, 0x55/*0b01010101*/, 0x49/*0b01001001*/, 0x11/*0b00010001*/, 0x21/*0b00100001*/, 0x41/*0b01000001*/, 0x81/*0b10000001*/, 0x01/*0b00000001*/, }; static unsigned int shift_table[9] = { 0, 0,0,1,0,2,4,6,0, }; if (shift < 0) v <<= -shift; else v >>= shift; STBI_ASSERT(v < 256); v >>= (8-bits); STBI_ASSERT(bits >= 0 && bits <= 8); return (int) ((unsigned) v * mul_table[bits]) >> shift_table[bits]; } typedef struct { int bpp, offset, hsz; unsigned int mr,mg,mb,ma, all_a; int extra_read; } stbi__bmp_data; static int stbi__bmp_set_mask_defaults(stbi__bmp_data *info, int compress) { // BI_BITFIELDS specifies masks explicitly, don't override if (compress == 3) return 1; if (compress == 0) { if (info->bpp == 16) { info->mr = 31u << 10; info->mg = 31u << 5; info->mb = 31u << 0; } else if (info->bpp == 32) { info->mr = 0xffu << 16; info->mg = 0xffu << 8; info->mb = 0xffu << 0; info->ma = 0xffu << 24; info->all_a = 0; // if all_a is 0 at end, then we loaded alpha channel but it was all 0 } else { // otherwise, use defaults, which is all-0 info->mr = info->mg = info->mb = info->ma = 0; } return 1; } return 0; // error } static void *stbi__bmp_parse_header(stbi__context *s, stbi__bmp_data *info) { int hsz; if (stbi__get8(s) != 'B' || stbi__get8(s) != 'M') return stbi__errpuc("not BMP", "Corrupt BMP"); stbi__get32le(s); // discard filesize stbi__get16le(s); // discard reserved stbi__get16le(s); // discard reserved info->offset = stbi__get32le(s); info->hsz = hsz = stbi__get32le(s); info->mr = info->mg = info->mb = info->ma = 0; info->extra_read = 14; if (info->offset < 0) return stbi__errpuc("bad BMP", "bad BMP"); if (hsz != 12 && hsz != 40 && hsz != 56 && hsz != 108 && hsz != 124) return stbi__errpuc("unknown BMP", "BMP type not supported: unknown"); if (hsz == 12) { s->img_x = stbi__get16le(s); s->img_y = stbi__get16le(s); } else { s->img_x = stbi__get32le(s); s->img_y = stbi__get32le(s); } if (stbi__get16le(s) != 1) return stbi__errpuc("bad BMP", "bad BMP"); info->bpp = stbi__get16le(s); if (hsz != 12) { int compress = stbi__get32le(s); if (compress == 1 || compress == 2) return stbi__errpuc("BMP RLE", "BMP type not supported: RLE"); if (compress >= 4) return stbi__errpuc("BMP JPEG/PNG", "BMP type not supported: unsupported compression"); // this includes PNG/JPEG modes if (compress == 3 && info->bpp != 16 && info->bpp != 32) return stbi__errpuc("bad BMP", "bad BMP"); // bitfields requires 16 or 32 bits/pixel stbi__get32le(s); // discard sizeof stbi__get32le(s); // discard hres stbi__get32le(s); // discard vres stbi__get32le(s); // discard colorsused stbi__get32le(s); // discard max important if (hsz == 40 || hsz == 56) { if (hsz == 56) { stbi__get32le(s); stbi__get32le(s); stbi__get32le(s); stbi__get32le(s); } if (info->bpp == 16 || info->bpp == 32) { if (compress == 0) { stbi__bmp_set_mask_defaults(info, compress); } else if (compress == 3) { info->mr = stbi__get32le(s); info->mg = stbi__get32le(s); info->mb = stbi__get32le(s); info->extra_read += 12; // not documented, but generated by photoshop and handled by mspaint if (info->mr == info->mg && info->mg == info->mb) { // ?!?!? return stbi__errpuc("bad BMP", "bad BMP"); } } else return stbi__errpuc("bad BMP", "bad BMP"); } } else { // V4/V5 header int i; if (hsz != 108 && hsz != 124) return stbi__errpuc("bad BMP", "bad BMP"); info->mr = stbi__get32le(s); info->mg = stbi__get32le(s); info->mb = stbi__get32le(s); info->ma = stbi__get32le(s); if (compress != 3) // override mr/mg/mb unless in BI_BITFIELDS mode, as per docs stbi__bmp_set_mask_defaults(info, compress); stbi__get32le(s); // discard color space for (i=0; i < 12; ++i) stbi__get32le(s); // discard color space parameters if (hsz == 124) { stbi__get32le(s); // discard rendering intent stbi__get32le(s); // discard offset of profile data stbi__get32le(s); // discard size of profile data stbi__get32le(s); // discard reserved } } } return (void *) 1; } static void *stbi__bmp_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri) { stbi_uc *out; unsigned int mr=0,mg=0,mb=0,ma=0, all_a; stbi_uc pal[256][4]; int psize=0,i,j,width; int flip_vertically, pad, target; stbi__bmp_data info; STBI_NOTUSED(ri); info.all_a = 255; if (stbi__bmp_parse_header(s, &info) == NULL) return NULL; // error code already set flip_vertically = ((int) s->img_y) > 0; s->img_y = abs((int) s->img_y); if (s->img_y > STBI_MAX_DIMENSIONS) return stbi__errpuc("too large","Very large image (corrupt?)"); if (s->img_x > STBI_MAX_DIMENSIONS) return stbi__errpuc("too large","Very large image (corrupt?)"); mr = info.mr; mg = info.mg; mb = info.mb; ma = info.ma; all_a = info.all_a; if (info.hsz == 12) { if (info.bpp < 24) psize = (info.offset - info.extra_read - 24) / 3; } else { if (info.bpp < 16) psize = (info.offset - info.extra_read - info.hsz) >> 2; } if (psize == 0) { // accept some number of extra bytes after the header, but if the offset points either to before // the header ends or implies a large amount of extra data, reject the file as malformed int bytes_read_so_far = s->callback_already_read + (int)(s->img_buffer - s->img_buffer_original); int header_limit = 1024; // max we actually read is below 256 bytes currently. int extra_data_limit = 256*4; // what ordinarily goes here is a palette; 256 entries*4 bytes is its max size. if (bytes_read_so_far <= 0 || bytes_read_so_far > header_limit) { return stbi__errpuc("bad header", "Corrupt BMP"); } // we established that bytes_read_so_far is positive and sensible. // the first half of this test rejects offsets that are either too small positives, or // negative, and guarantees that info.offset >= bytes_read_so_far > 0. this in turn // ensures the number computed in the second half of the test can't overflow. if (info.offset < bytes_read_so_far || info.offset - bytes_read_so_far > extra_data_limit) { return stbi__errpuc("bad offset", "Corrupt BMP"); } else { stbi__skip(s, info.offset - bytes_read_so_far); } } if (info.bpp == 24 && ma == 0xff000000) s->img_n = 3; else s->img_n = ma ? 4 : 3; if (req_comp && req_comp >= 3) // we can directly decode 3 or 4 target = req_comp; else target = s->img_n; // if they want monochrome, we'll post-convert // sanity-check size if (!stbi__mad3sizes_valid(target, s->img_x, s->img_y, 0)) return stbi__errpuc("too large", "Corrupt BMP"); out = (stbi_uc *) stbi__malloc_mad3(target, s->img_x, s->img_y, 0); if (!out) return stbi__errpuc("outofmem", "Out of memory"); if (info.bpp < 16) { int z=0; if (psize == 0 || psize > 256) { STBI_FREE(out); return stbi__errpuc("invalid", "Corrupt BMP"); } for (i=0; i < psize; ++i) { pal[i][2] = stbi__get8(s); pal[i][1] = stbi__get8(s); pal[i][0] = stbi__get8(s); if (info.hsz != 12) stbi__get8(s); pal[i][3] = 255; } stbi__skip(s, info.offset - info.extra_read - info.hsz - psize * (info.hsz == 12 ? 3 : 4)); if (info.bpp == 1) width = (s->img_x + 7) >> 3; else if (info.bpp == 4) width = (s->img_x + 1) >> 1; else if (info.bpp == 8) width = s->img_x; else { STBI_FREE(out); return stbi__errpuc("bad bpp", "Corrupt BMP"); } pad = (-width)&3; if (info.bpp == 1) { for (j=0; j < (int) s->img_y; ++j) { int bit_offset = 7, v = stbi__get8(s); for (i=0; i < (int) s->img_x; ++i) { int color = (v>>bit_offset)&0x1; out[z++] = pal[color][0]; out[z++] = pal[color][1]; out[z++] = pal[color][2]; if (target == 4) out[z++] = 255; if (i+1 == (int) s->img_x) break; if((--bit_offset) < 0) { bit_offset = 7; v = stbi__get8(s); } } stbi__skip(s, pad); } } else { for (j=0; j < (int) s->img_y; ++j) { for (i=0; i < (int) s->img_x; i += 2) { int v=stbi__get8(s),v2=0; if (info.bpp == 4) { v2 = v & 15; v >>= 4; } out[z++] = pal[v][0]; out[z++] = pal[v][1]; out[z++] = pal[v][2]; if (target == 4) out[z++] = 255; if (i+1 == (int) s->img_x) break; v = (info.bpp == 8) ? stbi__get8(s) : v2; out[z++] = pal[v][0]; out[z++] = pal[v][1]; out[z++] = pal[v][2]; if (target == 4) out[z++] = 255; } stbi__skip(s, pad); } } } else { int rshift=0,gshift=0,bshift=0,ashift=0,rcount=0,gcount=0,bcount=0,acount=0; int z = 0; int easy=0; stbi__skip(s, info.offset - info.extra_read - info.hsz); if (info.bpp == 24) width = 3 * s->img_x; else if (info.bpp == 16) width = 2*s->img_x; else /* bpp = 32 and pad = 0 */ width=0; pad = (-width) & 3; if (info.bpp == 24) { easy = 1; } else if (info.bpp == 32) { if (mb == 0xff && mg == 0xff00 && mr == 0x00ff0000 && ma == 0xff000000) easy = 2; } if (!easy) { if (!mr || !mg || !mb) { STBI_FREE(out); return stbi__errpuc("bad masks", "Corrupt BMP"); } // right shift amt to put high bit in position #7 rshift = stbi__high_bit(mr)-7; rcount = stbi__bitcount(mr); gshift = stbi__high_bit(mg)-7; gcount = stbi__bitcount(mg); bshift = stbi__high_bit(mb)-7; bcount = stbi__bitcount(mb); ashift = stbi__high_bit(ma)-7; acount = stbi__bitcount(ma); if (rcount > 8 || gcount > 8 || bcount > 8 || acount > 8) { STBI_FREE(out); return stbi__errpuc("bad masks", "Corrupt BMP"); } } for (j=0; j < (int) s->img_y; ++j) { if (easy) { for (i=0; i < (int) s->img_x; ++i) { unsigned char a; out[z+2] = stbi__get8(s); out[z+1] = stbi__get8(s); out[z+0] = stbi__get8(s); z += 3; a = (easy == 2 ? stbi__get8(s) : 255); all_a |= a; if (target == 4) out[z++] = a; } } else { int bpp = info.bpp; for (i=0; i < (int) s->img_x; ++i) { stbi__uint32 v = (bpp == 16 ? (stbi__uint32) stbi__get16le(s) : stbi__get32le(s)); unsigned int a; out[z++] = STBI__BYTECAST(stbi__shiftsigned(v & mr, rshift, rcount)); out[z++] = STBI__BYTECAST(stbi__shiftsigned(v & mg, gshift, gcount)); out[z++] = STBI__BYTECAST(stbi__shiftsigned(v & mb, bshift, bcount)); a = (ma ? stbi__shiftsigned(v & ma, ashift, acount) : 255); all_a |= a; if (target == 4) out[z++] = STBI__BYTECAST(a); } } stbi__skip(s, pad); } } // if alpha channel is all 0s, replace with all 255s if (target == 4 && all_a == 0) for (i=4*s->img_x*s->img_y-1; i >= 0; i -= 4) out[i] = 255; if (flip_vertically) { stbi_uc t; for (j=0; j < (int) s->img_y>>1; ++j) { stbi_uc *p1 = out + j *s->img_x*target; stbi_uc *p2 = out + (s->img_y-1-j)*s->img_x*target; for (i=0; i < (int) s->img_x*target; ++i) { t = p1[i]; p1[i] = p2[i]; p2[i] = t; } } } if (req_comp && req_comp != target) { out = stbi__convert_format(out, target, req_comp, s->img_x, s->img_y); if (out == NULL) return out; // stbi__convert_format frees input on failure } *x = s->img_x; *y = s->img_y; if (comp) *comp = s->img_n; return out; } #endif // Targa Truevision - TGA // by Jonathan Dummer #ifndef STBI_NO_TGA // returns STBI_rgb or whatever, 0 on error static int stbi__tga_get_comp(int bits_per_pixel, int is_grey, int* is_rgb16) { // only RGB or RGBA (incl. 16bit) or grey allowed if (is_rgb16) *is_rgb16 = 0; switch(bits_per_pixel) { case 8: return STBI_grey; case 16: if(is_grey) return STBI_grey_alpha; // fallthrough case 15: if(is_rgb16) *is_rgb16 = 1; return STBI_rgb; case 24: // fallthrough case 32: return bits_per_pixel/8; default: return 0; } } static int stbi__tga_info(stbi__context *s, int *x, int *y, int *comp) { int tga_w, tga_h, tga_comp, tga_image_type, tga_bits_per_pixel, tga_colormap_bpp; int sz, tga_colormap_type; stbi__get8(s); // discard Offset tga_colormap_type = stbi__get8(s); // colormap type if( tga_colormap_type > 1 ) { stbi__rewind(s); return 0; // only RGB or indexed allowed } tga_image_type = stbi__get8(s); // image type if ( tga_colormap_type == 1 ) { // colormapped (paletted) image if (tga_image_type != 1 && tga_image_type != 9) { stbi__rewind(s); return 0; } stbi__skip(s,4); // skip index of first colormap entry and number of entries sz = stbi__get8(s); // check bits per palette color entry if ( (sz != 8) && (sz != 15) && (sz != 16) && (sz != 24) && (sz != 32) ) { stbi__rewind(s); return 0; } stbi__skip(s,4); // skip image x and y origin tga_colormap_bpp = sz; } else { // "normal" image w/o colormap - only RGB or grey allowed, +/- RLE if ( (tga_image_type != 2) && (tga_image_type != 3) && (tga_image_type != 10) && (tga_image_type != 11) ) { stbi__rewind(s); return 0; // only RGB or grey allowed, +/- RLE } stbi__skip(s,9); // skip colormap specification and image x/y origin tga_colormap_bpp = 0; } tga_w = stbi__get16le(s); if( tga_w < 1 ) { stbi__rewind(s); return 0; // test width } tga_h = stbi__get16le(s); if( tga_h < 1 ) { stbi__rewind(s); return 0; // test height } tga_bits_per_pixel = stbi__get8(s); // bits per pixel stbi__get8(s); // ignore alpha bits if (tga_colormap_bpp != 0) { if((tga_bits_per_pixel != 8) && (tga_bits_per_pixel != 16)) { // when using a colormap, tga_bits_per_pixel is the size of the indexes // I don't think anything but 8 or 16bit indexes makes sense stbi__rewind(s); return 0; } tga_comp = stbi__tga_get_comp(tga_colormap_bpp, 0, NULL); } else { tga_comp = stbi__tga_get_comp(tga_bits_per_pixel, (tga_image_type == 3) || (tga_image_type == 11), NULL); } if(!tga_comp) { stbi__rewind(s); return 0; } if (x) *x = tga_w; if (y) *y = tga_h; if (comp) *comp = tga_comp; return 1; // seems to have passed everything } static int stbi__tga_test(stbi__context *s) { int res = 0; int sz, tga_color_type; stbi__get8(s); // discard Offset tga_color_type = stbi__get8(s); // color type if ( tga_color_type > 1 ) goto errorEnd; // only RGB or indexed allowed sz = stbi__get8(s); // image type if ( tga_color_type == 1 ) { // colormapped (paletted) image if (sz != 1 && sz != 9) goto errorEnd; // colortype 1 demands image type 1 or 9 stbi__skip(s,4); // skip index of first colormap entry and number of entries sz = stbi__get8(s); // check bits per palette color entry if ( (sz != 8) && (sz != 15) && (sz != 16) && (sz != 24) && (sz != 32) ) goto errorEnd; stbi__skip(s,4); // skip image x and y origin } else { // "normal" image w/o colormap if ( (sz != 2) && (sz != 3) && (sz != 10) && (sz != 11) ) goto errorEnd; // only RGB or grey allowed, +/- RLE stbi__skip(s,9); // skip colormap specification and image x/y origin } if ( stbi__get16le(s) < 1 ) goto errorEnd; // test width if ( stbi__get16le(s) < 1 ) goto errorEnd; // test height sz = stbi__get8(s); // bits per pixel if ( (tga_color_type == 1) && (sz != 8) && (sz != 16) ) goto errorEnd; // for colormapped images, bpp is size of an index if ( (sz != 8) && (sz != 15) && (sz != 16) && (sz != 24) && (sz != 32) ) goto errorEnd; res = 1; // if we got this far, everything's good and we can return 1 instead of 0 errorEnd: stbi__rewind(s); return res; } // read 16bit value and convert to 24bit RGB static void stbi__tga_read_rgb16(stbi__context *s, stbi_uc* out) { stbi__uint16 px = (stbi__uint16)stbi__get16le(s); stbi__uint16 fiveBitMask = 31; // we have 3 channels with 5bits each int r = (px >> 10) & fiveBitMask; int g = (px >> 5) & fiveBitMask; int b = px & fiveBitMask; // Note that this saves the data in RGB(A) order, so it doesn't need to be swapped later out[0] = (stbi_uc)((r * 255)/31); out[1] = (stbi_uc)((g * 255)/31); out[2] = (stbi_uc)((b * 255)/31); // some people claim that the most significant bit might be used for alpha // (possibly if an alpha-bit is set in the "image descriptor byte") // but that only made 16bit test images completely translucent.. // so let's treat all 15 and 16bit TGAs as RGB with no alpha. } static void *stbi__tga_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri) { // read in the TGA header stuff int tga_offset = stbi__get8(s); int tga_indexed = stbi__get8(s); int tga_image_type = stbi__get8(s); int tga_is_RLE = 0; int tga_palette_start = stbi__get16le(s); int tga_palette_len = stbi__get16le(s); int tga_palette_bits = stbi__get8(s); int tga_x_origin = stbi__get16le(s); int tga_y_origin = stbi__get16le(s); int tga_width = stbi__get16le(s); int tga_height = stbi__get16le(s); int tga_bits_per_pixel = stbi__get8(s); int tga_comp, tga_rgb16=0; int tga_inverted = stbi__get8(s); // int tga_alpha_bits = tga_inverted & 15; // the 4 lowest bits - unused (useless?) // image data unsigned char *tga_data; unsigned char *tga_palette = NULL; int i, j; unsigned char raw_data[4] = {0}; int RLE_count = 0; int RLE_repeating = 0; int read_next_pixel = 1; STBI_NOTUSED(ri); STBI_NOTUSED(tga_x_origin); // @TODO STBI_NOTUSED(tga_y_origin); // @TODO if (tga_height > STBI_MAX_DIMENSIONS) return stbi__errpuc("too large","Very large image (corrupt?)"); if (tga_width > STBI_MAX_DIMENSIONS) return stbi__errpuc("too large","Very large image (corrupt?)"); // do a tiny bit of precessing if ( tga_image_type >= 8 ) { tga_image_type -= 8; tga_is_RLE = 1; } tga_inverted = 1 - ((tga_inverted >> 5) & 1); // If I'm paletted, then I'll use the number of bits from the palette if ( tga_indexed ) tga_comp = stbi__tga_get_comp(tga_palette_bits, 0, &tga_rgb16); else tga_comp = stbi__tga_get_comp(tga_bits_per_pixel, (tga_image_type == 3), &tga_rgb16); if(!tga_comp) // shouldn't really happen, stbi__tga_test() should have ensured basic consistency return stbi__errpuc("bad format", "Can't find out TGA pixelformat"); // tga info *x = tga_width; *y = tga_height; if (comp) *comp = tga_comp; if (!stbi__mad3sizes_valid(tga_width, tga_height, tga_comp, 0)) return stbi__errpuc("too large", "Corrupt TGA"); tga_data = (unsigned char*)stbi__malloc_mad3(tga_width, tga_height, tga_comp, 0); if (!tga_data) return stbi__errpuc("outofmem", "Out of memory"); // skip to the data's starting position (offset usually = 0) stbi__skip(s, tga_offset ); if ( !tga_indexed && !tga_is_RLE && !tga_rgb16 ) { for (i=0; i < tga_height; ++i) { int row = tga_inverted ? tga_height -i - 1 : i; stbi_uc *tga_row = tga_data + row*tga_width*tga_comp; stbi__getn(s, tga_row, tga_width * tga_comp); } } else { // do I need to load a palette? if ( tga_indexed) { if (tga_palette_len == 0) { /* you have to have at least one entry! */ STBI_FREE(tga_data); return stbi__errpuc("bad palette", "Corrupt TGA"); } // any data to skip? (offset usually = 0) stbi__skip(s, tga_palette_start ); // load the palette tga_palette = (unsigned char*)stbi__malloc_mad2(tga_palette_len, tga_comp, 0); if (!tga_palette) { STBI_FREE(tga_data); return stbi__errpuc("outofmem", "Out of memory"); } if (tga_rgb16) { stbi_uc *pal_entry = tga_palette; STBI_ASSERT(tga_comp == STBI_rgb); for (i=0; i < tga_palette_len; ++i) { stbi__tga_read_rgb16(s, pal_entry); pal_entry += tga_comp; } } else if (!stbi__getn(s, tga_palette, tga_palette_len * tga_comp)) { STBI_FREE(tga_data); STBI_FREE(tga_palette); return stbi__errpuc("bad palette", "Corrupt TGA"); } } // load the data for (i=0; i < tga_width * tga_height; ++i) { // if I'm in RLE mode, do I need to get a RLE stbi__pngchunk? if ( tga_is_RLE ) { if ( RLE_count == 0 ) { // yep, get the next byte as a RLE command int RLE_cmd = stbi__get8(s); RLE_count = 1 + (RLE_cmd & 127); RLE_repeating = RLE_cmd >> 7; read_next_pixel = 1; } else if ( !RLE_repeating ) { read_next_pixel = 1; } } else { read_next_pixel = 1; } // OK, if I need to read a pixel, do it now if ( read_next_pixel ) { // load however much data we did have if ( tga_indexed ) { // read in index, then perform the lookup int pal_idx = (tga_bits_per_pixel == 8) ? stbi__get8(s) : stbi__get16le(s); if ( pal_idx >= tga_palette_len ) { // invalid index pal_idx = 0; } pal_idx *= tga_comp; for (j = 0; j < tga_comp; ++j) { raw_data[j] = tga_palette[pal_idx+j]; } } else if(tga_rgb16) { STBI_ASSERT(tga_comp == STBI_rgb); stbi__tga_read_rgb16(s, raw_data); } else { // read in the data raw for (j = 0; j < tga_comp; ++j) { raw_data[j] = stbi__get8(s); } } // clear the reading flag for the next pixel read_next_pixel = 0; } // end of reading a pixel // copy data for (j = 0; j < tga_comp; ++j) tga_data[i*tga_comp+j] = raw_data[j]; // in case we're in RLE mode, keep counting down --RLE_count; } // do I need to invert the image? if ( tga_inverted ) { for (j = 0; j*2 < tga_height; ++j) { int index1 = j * tga_width * tga_comp; int index2 = (tga_height - 1 - j) * tga_width * tga_comp; for (i = tga_width * tga_comp; i > 0; --i) { unsigned char temp = tga_data[index1]; tga_data[index1] = tga_data[index2]; tga_data[index2] = temp; ++index1; ++index2; } } } // clear my palette, if I had one if ( tga_palette != NULL ) { STBI_FREE( tga_palette ); } } // swap RGB - if the source data was RGB16, it already is in the right order if (tga_comp >= 3 && !tga_rgb16) { unsigned char* tga_pixel = tga_data; for (i=0; i < tga_width * tga_height; ++i) { unsigned char temp = tga_pixel[0]; tga_pixel[0] = tga_pixel[2]; tga_pixel[2] = temp; tga_pixel += tga_comp; } } // convert to target component count if (req_comp && req_comp != tga_comp) tga_data = stbi__convert_format(tga_data, tga_comp, req_comp, tga_width, tga_height); // the things I do to get rid of an error message, and yet keep // Microsoft's C compilers happy... [8^( tga_palette_start = tga_palette_len = tga_palette_bits = tga_x_origin = tga_y_origin = 0; STBI_NOTUSED(tga_palette_start); // OK, done return tga_data; } #endif // ************************************************************************************************* // Photoshop PSD loader -- PD by Thatcher Ulrich, integration by Nicolas Schulz, tweaked by STB #ifndef STBI_NO_PSD static int stbi__psd_test(stbi__context *s) { int r = (stbi__get32be(s) == 0x38425053); stbi__rewind(s); return r; } static int stbi__psd_decode_rle(stbi__context *s, stbi_uc *p, int pixelCount) { int count, nleft, len; count = 0; while ((nleft = pixelCount - count) > 0) { len = stbi__get8(s); if (len == 128) { // No-op. } else if (len < 128) { // Copy next len+1 bytes literally. len++; if (len > nleft) return 0; // corrupt data count += len; while (len) { *p = stbi__get8(s); p += 4; len--; } } else if (len > 128) { stbi_uc val; // Next -len+1 bytes in the dest are replicated from next source byte. // (Interpret len as a negative 8-bit int.) len = 257 - len; if (len > nleft) return 0; // corrupt data val = stbi__get8(s); count += len; while (len) { *p = val; p += 4; len--; } } } return 1; } static void *stbi__psd_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri, int bpc) { int pixelCount; int channelCount, compression; int channel, i; int bitdepth; int w,h; stbi_uc *out; STBI_NOTUSED(ri); // Check identifier if (stbi__get32be(s) != 0x38425053) // "8BPS" return stbi__errpuc("not PSD", "Corrupt PSD image"); // Check file type version. if (stbi__get16be(s) != 1) return stbi__errpuc("wrong version", "Unsupported version of PSD image"); // Skip 6 reserved bytes. stbi__skip(s, 6 ); // Read the number of channels (R, G, B, A, etc). channelCount = stbi__get16be(s); if (channelCount < 0 || channelCount > 16) return stbi__errpuc("wrong channel count", "Unsupported number of channels in PSD image"); // Read the rows and columns of the image. h = stbi__get32be(s); w = stbi__get32be(s); if (h > STBI_MAX_DIMENSIONS) return stbi__errpuc("too large","Very large image (corrupt?)"); if (w > STBI_MAX_DIMENSIONS) return stbi__errpuc("too large","Very large image (corrupt?)"); // Make sure the depth is 8 bits. bitdepth = stbi__get16be(s); if (bitdepth != 8 && bitdepth != 16) return stbi__errpuc("unsupported bit depth", "PSD bit depth is not 8 or 16 bit"); // Make sure the color mode is RGB. // Valid options are: // 0: Bitmap // 1: Grayscale // 2: Indexed color // 3: RGB color // 4: CMYK color // 7: Multichannel // 8: Duotone // 9: Lab color if (stbi__get16be(s) != 3) return stbi__errpuc("wrong color format", "PSD is not in RGB color format"); // Skip the Mode Data. (It's the palette for indexed color; other info for other modes.) stbi__skip(s,stbi__get32be(s) ); // Skip the image resources. (resolution, pen tool paths, etc) stbi__skip(s, stbi__get32be(s) ); // Skip the reserved data. stbi__skip(s, stbi__get32be(s) ); // Find out if the data is compressed. // Known values: // 0: no compression // 1: RLE compressed compression = stbi__get16be(s); if (compression > 1) return stbi__errpuc("bad compression", "PSD has an unknown compression format"); // Check size if (!stbi__mad3sizes_valid(4, w, h, 0)) return stbi__errpuc("too large", "Corrupt PSD"); // Create the destination image. if (!compression && bitdepth == 16 && bpc == 16) { out = (stbi_uc *) stbi__malloc_mad3(8, w, h, 0); ri->bits_per_channel = 16; } else out = (stbi_uc *) stbi__malloc(4 * w*h); if (!out) return stbi__errpuc("outofmem", "Out of memory"); pixelCount = w*h; // Initialize the data to zero. //memset( out, 0, pixelCount * 4 ); // Finally, the image data. if (compression) { // RLE as used by .PSD and .TIFF // Loop until you get the number of unpacked bytes you are expecting: // Read the next source byte into n. // If n is between 0 and 127 inclusive, copy the next n+1 bytes literally. // Else if n is between -127 and -1 inclusive, copy the next byte -n+1 times. // Else if n is 128, noop. // Endloop // The RLE-compressed data is preceded by a 2-byte data count for each row in the data, // which we're going to just skip. stbi__skip(s, h * channelCount * 2 ); // Read the RLE data by channel. for (channel = 0; channel < 4; channel++) { stbi_uc *p; p = out+channel; if (channel >= channelCount) { // Fill this channel with default data. for (i = 0; i < pixelCount; i++, p += 4) *p = (channel == 3 ? 255 : 0); } else { // Read the RLE data. if (!stbi__psd_decode_rle(s, p, pixelCount)) { STBI_FREE(out); return stbi__errpuc("corrupt", "bad RLE data"); } } } } else { // We're at the raw image data. It's each channel in order (Red, Green, Blue, Alpha, ...) // where each channel consists of an 8-bit (or 16-bit) value for each pixel in the image. // Read the data by channel. for (channel = 0; channel < 4; channel++) { if (channel >= channelCount) { // Fill this channel with default data. if (bitdepth == 16 && bpc == 16) { stbi__uint16 *q = ((stbi__uint16 *) out) + channel; stbi__uint16 val = channel == 3 ? 65535 : 0; for (i = 0; i < pixelCount; i++, q += 4) *q = val; } else { stbi_uc *p = out+channel; stbi_uc val = channel == 3 ? 255 : 0; for (i = 0; i < pixelCount; i++, p += 4) *p = val; } } else { if (ri->bits_per_channel == 16) { // output bpc stbi__uint16 *q = ((stbi__uint16 *) out) + channel; for (i = 0; i < pixelCount; i++, q += 4) *q = (stbi__uint16) stbi__get16be(s); } else { stbi_uc *p = out+channel; if (bitdepth == 16) { // input bpc for (i = 0; i < pixelCount; i++, p += 4) *p = (stbi_uc) (stbi__get16be(s) >> 8); } else { for (i = 0; i < pixelCount; i++, p += 4) *p = stbi__get8(s); } } } } } // remove weird white matte from PSD if (channelCount >= 4) { if (ri->bits_per_channel == 16) { for (i=0; i < w*h; ++i) { stbi__uint16 *pixel = (stbi__uint16 *) out + 4*i; if (pixel[3] != 0 && pixel[3] != 65535) { float a = pixel[3] / 65535.0f; float ra = 1.0f / a; float inv_a = 65535.0f * (1 - ra); pixel[0] = (stbi__uint16) (pixel[0]*ra + inv_a); pixel[1] = (stbi__uint16) (pixel[1]*ra + inv_a); pixel[2] = (stbi__uint16) (pixel[2]*ra + inv_a); } } } else { for (i=0; i < w*h; ++i) { unsigned char *pixel = out + 4*i; if (pixel[3] != 0 && pixel[3] != 255) { float a = pixel[3] / 255.0f; float ra = 1.0f / a; float inv_a = 255.0f * (1 - ra); pixel[0] = (unsigned char) (pixel[0]*ra + inv_a); pixel[1] = (unsigned char) (pixel[1]*ra + inv_a); pixel[2] = (unsigned char) (pixel[2]*ra + inv_a); } } } } // convert to desired output format if (req_comp && req_comp != 4) { if (ri->bits_per_channel == 16) out = (stbi_uc *) stbi__convert_format16((stbi__uint16 *) out, 4, req_comp, w, h); else out = stbi__convert_format(out, 4, req_comp, w, h); if (out == NULL) return out; // stbi__convert_format frees input on failure } if (comp) *comp = 4; *y = h; *x = w; return out; } #endif // ************************************************************************************************* // Softimage PIC loader // by Tom Seddon // // See http://softimage.wiki.softimage.com/index.php/INFO:_PIC_file_format // See http://ozviz.wasp.uwa.edu.au/~pbourke/dataformats/softimagepic/ #ifndef STBI_NO_PIC static int stbi__pic_is4(stbi__context *s,const char *str) { int i; for (i=0; i<4; ++i) if (stbi__get8(s) != (stbi_uc)str[i]) return 0; return 1; } static int stbi__pic_test_core(stbi__context *s) { int i; if (!stbi__pic_is4(s,"\x53\x80\xF6\x34")) return 0; for(i=0;i<84;++i) stbi__get8(s); if (!stbi__pic_is4(s,"PICT")) return 0; return 1; } typedef struct { stbi_uc size,type,channel; } stbi__pic_packet; static stbi_uc *stbi__readval(stbi__context *s, int channel, stbi_uc *dest) { int mask=0x80, i; for (i=0; i<4; ++i, mask>>=1) { if (channel & mask) { if (stbi__at_eof(s)) return stbi__errpuc("bad file","PIC file too short"); dest[i]=stbi__get8(s); } } return dest; } static void stbi__copyval(int channel,stbi_uc *dest,const stbi_uc *src) { int mask=0x80,i; for (i=0;i<4; ++i, mask>>=1) if (channel&mask) dest[i]=src[i]; } static stbi_uc *stbi__pic_load_core(stbi__context *s,int width,int height,int *comp, stbi_uc *result) { int act_comp=0,num_packets=0,y,chained; stbi__pic_packet packets[10]; // this will (should...) cater for even some bizarre stuff like having data // for the same channel in multiple packets. do { stbi__pic_packet *packet; if (num_packets==sizeof(packets)/sizeof(packets[0])) return stbi__errpuc("bad format","too many packets"); packet = &packets[num_packets++]; chained = stbi__get8(s); packet->size = stbi__get8(s); packet->type = stbi__get8(s); packet->channel = stbi__get8(s); act_comp |= packet->channel; if (stbi__at_eof(s)) return stbi__errpuc("bad file","file too short (reading packets)"); if (packet->size != 8) return stbi__errpuc("bad format","packet isn't 8bpp"); } while (chained); *comp = (act_comp & 0x10 ? 4 : 3); // has alpha channel? for(y=0; ytype) { default: return stbi__errpuc("bad format","packet has bad compression type"); case 0: {//uncompressed int x; for(x=0;xchannel,dest)) return 0; break; } case 1://Pure RLE { int left=width, i; while (left>0) { stbi_uc count,value[4]; count=stbi__get8(s); if (stbi__at_eof(s)) return stbi__errpuc("bad file","file too short (pure read count)"); if (count > left) count = (stbi_uc) left; if (!stbi__readval(s,packet->channel,value)) return 0; for(i=0; ichannel,dest,value); left -= count; } } break; case 2: {//Mixed RLE int left=width; while (left>0) { int count = stbi__get8(s), i; if (stbi__at_eof(s)) return stbi__errpuc("bad file","file too short (mixed read count)"); if (count >= 128) { // Repeated stbi_uc value[4]; if (count==128) count = stbi__get16be(s); else count -= 127; if (count > left) return stbi__errpuc("bad file","scanline overrun"); if (!stbi__readval(s,packet->channel,value)) return 0; for(i=0;ichannel,dest,value); } else { // Raw ++count; if (count>left) return stbi__errpuc("bad file","scanline overrun"); for(i=0;ichannel,dest)) return 0; } left-=count; } break; } } } } return result; } static void *stbi__pic_load(stbi__context *s,int *px,int *py,int *comp,int req_comp, stbi__result_info *ri) { stbi_uc *result; int i, x,y, internal_comp; STBI_NOTUSED(ri); if (!comp) comp = &internal_comp; for (i=0; i<92; ++i) stbi__get8(s); x = stbi__get16be(s); y = stbi__get16be(s); if (y > STBI_MAX_DIMENSIONS) return stbi__errpuc("too large","Very large image (corrupt?)"); if (x > STBI_MAX_DIMENSIONS) return stbi__errpuc("too large","Very large image (corrupt?)"); if (stbi__at_eof(s)) return stbi__errpuc("bad file","file too short (pic header)"); if (!stbi__mad3sizes_valid(x, y, 4, 0)) return stbi__errpuc("too large", "PIC image too large to decode"); stbi__get32be(s); //skip `ratio' stbi__get16be(s); //skip `fields' stbi__get16be(s); //skip `pad' // intermediate buffer is RGBA result = (stbi_uc *) stbi__malloc_mad3(x, y, 4, 0); if (!result) return stbi__errpuc("outofmem", "Out of memory"); memset(result, 0xff, x*y*4); if (!stbi__pic_load_core(s,x,y,comp, result)) { STBI_FREE(result); result=0; } *px = x; *py = y; if (req_comp == 0) req_comp = *comp; result=stbi__convert_format(result,4,req_comp,x,y); return result; } static int stbi__pic_test(stbi__context *s) { int r = stbi__pic_test_core(s); stbi__rewind(s); return r; } #endif // ************************************************************************************************* // GIF loader -- public domain by Jean-Marc Lienher -- simplified/shrunk by stb #ifndef STBI_NO_GIF typedef struct { stbi__int16 prefix; stbi_uc first; stbi_uc suffix; } stbi__gif_lzw; typedef struct { int w,h; stbi_uc *out; // output buffer (always 4 components) stbi_uc *background; // The current "background" as far as a gif is concerned stbi_uc *history; int flags, bgindex, ratio, transparent, eflags; stbi_uc pal[256][4]; stbi_uc lpal[256][4]; stbi__gif_lzw codes[8192]; stbi_uc *color_table; int parse, step; int lflags; int start_x, start_y; int max_x, max_y; int cur_x, cur_y; int line_size; int delay; } stbi__gif; static int stbi__gif_test_raw(stbi__context *s) { int sz; if (stbi__get8(s) != 'G' || stbi__get8(s) != 'I' || stbi__get8(s) != 'F' || stbi__get8(s) != '8') return 0; sz = stbi__get8(s); if (sz != '9' && sz != '7') return 0; if (stbi__get8(s) != 'a') return 0; return 1; } static int stbi__gif_test(stbi__context *s) { int r = stbi__gif_test_raw(s); stbi__rewind(s); return r; } static void stbi__gif_parse_colortable(stbi__context *s, stbi_uc pal[256][4], int num_entries, int transp) { int i; for (i=0; i < num_entries; ++i) { pal[i][2] = stbi__get8(s); pal[i][1] = stbi__get8(s); pal[i][0] = stbi__get8(s); pal[i][3] = transp == i ? 0 : 255; } } static int stbi__gif_header(stbi__context *s, stbi__gif *g, int *comp, int is_info) { stbi_uc version; if (stbi__get8(s) != 'G' || stbi__get8(s) != 'I' || stbi__get8(s) != 'F' || stbi__get8(s) != '8') return stbi__err("not GIF", "Corrupt GIF"); version = stbi__get8(s); if (version != '7' && version != '9') return stbi__err("not GIF", "Corrupt GIF"); if (stbi__get8(s) != 'a') return stbi__err("not GIF", "Corrupt GIF"); stbi__g_failure_reason = ""; g->w = stbi__get16le(s); g->h = stbi__get16le(s); g->flags = stbi__get8(s); g->bgindex = stbi__get8(s); g->ratio = stbi__get8(s); g->transparent = -1; if (g->w > STBI_MAX_DIMENSIONS) return stbi__err("too large","Very large image (corrupt?)"); if (g->h > STBI_MAX_DIMENSIONS) return stbi__err("too large","Very large image (corrupt?)"); if (comp != 0) *comp = 4; // can't actually tell whether it's 3 or 4 until we parse the comments if (is_info) return 1; if (g->flags & 0x80) stbi__gif_parse_colortable(s,g->pal, 2 << (g->flags & 7), -1); return 1; } static int stbi__gif_info_raw(stbi__context *s, int *x, int *y, int *comp) { stbi__gif* g = (stbi__gif*) stbi__malloc(sizeof(stbi__gif)); if (!g) return stbi__err("outofmem", "Out of memory"); if (!stbi__gif_header(s, g, comp, 1)) { STBI_FREE(g); stbi__rewind( s ); return 0; } if (x) *x = g->w; if (y) *y = g->h; STBI_FREE(g); return 1; } static void stbi__out_gif_code(stbi__gif *g, stbi__uint16 code) { stbi_uc *p, *c; int idx; // recurse to decode the prefixes, since the linked-list is backwards, // and working backwards through an interleaved image would be nasty if (g->codes[code].prefix >= 0) stbi__out_gif_code(g, g->codes[code].prefix); if (g->cur_y >= g->max_y) return; idx = g->cur_x + g->cur_y; p = &g->out[idx]; g->history[idx / 4] = 1; c = &g->color_table[g->codes[code].suffix * 4]; if (c[3] > 128) { // don't render transparent pixels; p[0] = c[2]; p[1] = c[1]; p[2] = c[0]; p[3] = c[3]; } g->cur_x += 4; if (g->cur_x >= g->max_x) { g->cur_x = g->start_x; g->cur_y += g->step; while (g->cur_y >= g->max_y && g->parse > 0) { g->step = (1 << g->parse) * g->line_size; g->cur_y = g->start_y + (g->step >> 1); --g->parse; } } } static stbi_uc *stbi__process_gif_raster(stbi__context *s, stbi__gif *g) { stbi_uc lzw_cs; stbi__int32 len, init_code; stbi__uint32 first; stbi__int32 codesize, codemask, avail, oldcode, bits, valid_bits, clear; stbi__gif_lzw *p; lzw_cs = stbi__get8(s); if (lzw_cs > 12) return NULL; clear = 1 << lzw_cs; first = 1; codesize = lzw_cs + 1; codemask = (1 << codesize) - 1; bits = 0; valid_bits = 0; for (init_code = 0; init_code < clear; init_code++) { g->codes[init_code].prefix = -1; g->codes[init_code].first = (stbi_uc) init_code; g->codes[init_code].suffix = (stbi_uc) init_code; } // support no starting clear code avail = clear+2; oldcode = -1; len = 0; for(;;) { if (valid_bits < codesize) { if (len == 0) { len = stbi__get8(s); // start new block if (len == 0) return g->out; } --len; bits |= (stbi__int32) stbi__get8(s) << valid_bits; valid_bits += 8; } else { stbi__int32 code = bits & codemask; bits >>= codesize; valid_bits -= codesize; // @OPTIMIZE: is there some way we can accelerate the non-clear path? if (code == clear) { // clear code codesize = lzw_cs + 1; codemask = (1 << codesize) - 1; avail = clear + 2; oldcode = -1; first = 0; } else if (code == clear + 1) { // end of stream code stbi__skip(s, len); while ((len = stbi__get8(s)) > 0) stbi__skip(s,len); return g->out; } else if (code <= avail) { if (first) { return stbi__errpuc("no clear code", "Corrupt GIF"); } if (oldcode >= 0) { p = &g->codes[avail++]; if (avail > 8192) { return stbi__errpuc("too many codes", "Corrupt GIF"); } p->prefix = (stbi__int16) oldcode; p->first = g->codes[oldcode].first; p->suffix = (code == avail) ? p->first : g->codes[code].first; } else if (code == avail) return stbi__errpuc("illegal code in raster", "Corrupt GIF"); stbi__out_gif_code(g, (stbi__uint16) code); if ((avail & codemask) == 0 && avail <= 0x0FFF) { codesize++; codemask = (1 << codesize) - 1; } oldcode = code; } else { return stbi__errpuc("illegal code in raster", "Corrupt GIF"); } } } } // this function is designed to support animated gifs, although stb_image doesn't support it // two back is the image from two frames ago, used for a very specific disposal format static stbi_uc *stbi__gif_load_next(stbi__context *s, stbi__gif *g, int *comp, int req_comp, stbi_uc *two_back) { int dispose; int first_frame; int pi; int pcount; STBI_NOTUSED(req_comp); // on first frame, any non-written pixels get the background colour (non-transparent) first_frame = 0; if (g->out == 0) { if (!stbi__gif_header(s, g, comp,0)) return 0; // stbi__g_failure_reason set by stbi__gif_header if (!stbi__mad3sizes_valid(4, g->w, g->h, 0)) return stbi__errpuc("too large", "GIF image is too large"); pcount = g->w * g->h; g->out = (stbi_uc *) stbi__malloc(4 * pcount); g->background = (stbi_uc *) stbi__malloc(4 * pcount); g->history = (stbi_uc *) stbi__malloc(pcount); if (!g->out || !g->background || !g->history) return stbi__errpuc("outofmem", "Out of memory"); // image is treated as "transparent" at the start - ie, nothing overwrites the current background; // background colour is only used for pixels that are not rendered first frame, after that "background" // color refers to the color that was there the previous frame. memset(g->out, 0x00, 4 * pcount); memset(g->background, 0x00, 4 * pcount); // state of the background (starts transparent) memset(g->history, 0x00, pcount); // pixels that were affected previous frame first_frame = 1; } else { // second frame - how do we dispose of the previous one? dispose = (g->eflags & 0x1C) >> 2; pcount = g->w * g->h; if ((dispose == 3) && (two_back == 0)) { dispose = 2; // if I don't have an image to revert back to, default to the old background } if (dispose == 3) { // use previous graphic for (pi = 0; pi < pcount; ++pi) { if (g->history[pi]) { memcpy( &g->out[pi * 4], &two_back[pi * 4], 4 ); } } } else if (dispose == 2) { // restore what was changed last frame to background before that frame; for (pi = 0; pi < pcount; ++pi) { if (g->history[pi]) { memcpy( &g->out[pi * 4], &g->background[pi * 4], 4 ); } } } else { // This is a non-disposal case eithe way, so just // leave the pixels as is, and they will become the new background // 1: do not dispose // 0: not specified. } // background is what out is after the undoing of the previou frame; memcpy( g->background, g->out, 4 * g->w * g->h ); } // clear my history; memset( g->history, 0x00, g->w * g->h ); // pixels that were affected previous frame for (;;) { int tag = stbi__get8(s); switch (tag) { case 0x2C: /* Image Descriptor */ { stbi__int32 x, y, w, h; stbi_uc *o; x = stbi__get16le(s); y = stbi__get16le(s); w = stbi__get16le(s); h = stbi__get16le(s); if (((x + w) > (g->w)) || ((y + h) > (g->h))) return stbi__errpuc("bad Image Descriptor", "Corrupt GIF"); g->line_size = g->w * 4; g->start_x = x * 4; g->start_y = y * g->line_size; g->max_x = g->start_x + w * 4; g->max_y = g->start_y + h * g->line_size; g->cur_x = g->start_x; g->cur_y = g->start_y; // if the width of the specified rectangle is 0, that means // we may not see *any* pixels or the image is malformed; // to make sure this is caught, move the current y down to // max_y (which is what out_gif_code checks). if (w == 0) g->cur_y = g->max_y; g->lflags = stbi__get8(s); if (g->lflags & 0x40) { g->step = 8 * g->line_size; // first interlaced spacing g->parse = 3; } else { g->step = g->line_size; g->parse = 0; } if (g->lflags & 0x80) { stbi__gif_parse_colortable(s,g->lpal, 2 << (g->lflags & 7), g->eflags & 0x01 ? g->transparent : -1); g->color_table = (stbi_uc *) g->lpal; } else if (g->flags & 0x80) { g->color_table = (stbi_uc *) g->pal; } else return stbi__errpuc("missing color table", "Corrupt GIF"); o = stbi__process_gif_raster(s, g); if (!o) return NULL; // if this was the first frame, pcount = g->w * g->h; if (first_frame && (g->bgindex > 0)) { // if first frame, any pixel not drawn to gets the background color for (pi = 0; pi < pcount; ++pi) { if (g->history[pi] == 0) { g->pal[g->bgindex][3] = 255; // just in case it was made transparent, undo that; It will be reset next frame if need be; memcpy( &g->out[pi * 4], &g->pal[g->bgindex], 4 ); } } } return o; } case 0x21: // Comment Extension. { int len; int ext = stbi__get8(s); if (ext == 0xF9) { // Graphic Control Extension. len = stbi__get8(s); if (len == 4) { g->eflags = stbi__get8(s); g->delay = 10 * stbi__get16le(s); // delay - 1/100th of a second, saving as 1/1000ths. // unset old transparent if (g->transparent >= 0) { g->pal[g->transparent][3] = 255; } if (g->eflags & 0x01) { g->transparent = stbi__get8(s); if (g->transparent >= 0) { g->pal[g->transparent][3] = 0; } } else { // don't need transparent stbi__skip(s, 1); g->transparent = -1; } } else { stbi__skip(s, len); break; } } while ((len = stbi__get8(s)) != 0) { stbi__skip(s, len); } break; } case 0x3B: // gif stream termination code return (stbi_uc *) s; // using '1' causes warning on some compilers default: return stbi__errpuc("unknown code", "Corrupt GIF"); } } } static void *stbi__load_gif_main_outofmem(stbi__gif *g, stbi_uc *out, int **delays) { STBI_FREE(g->out); STBI_FREE(g->history); STBI_FREE(g->background); if (out) STBI_FREE(out); if (delays && *delays) STBI_FREE(*delays); return stbi__errpuc("outofmem", "Out of memory"); } static void *stbi__load_gif_main(stbi__context *s, int **delays, int *x, int *y, int *z, int *comp, int req_comp) { if (stbi__gif_test(s)) { int layers = 0; stbi_uc *u = 0; stbi_uc *out = 0; stbi_uc *two_back = 0; stbi__gif g; int stride; int out_size = 0; int delays_size = 0; STBI_NOTUSED(out_size); STBI_NOTUSED(delays_size); memset(&g, 0, sizeof(g)); if (delays) { *delays = 0; } do { u = stbi__gif_load_next(s, &g, comp, req_comp, two_back); if (u == (stbi_uc *) s) u = 0; // end of animated gif marker if (u) { *x = g.w; *y = g.h; ++layers; stride = g.w * g.h * 4; if (out) { void *tmp = (stbi_uc*) STBI_REALLOC_SIZED( out, out_size, layers * stride ); if (!tmp) return stbi__load_gif_main_outofmem(&g, out, delays); else { out = (stbi_uc*) tmp; out_size = layers * stride; } if (delays) { int *new_delays = (int*) STBI_REALLOC_SIZED( *delays, delays_size, sizeof(int) * layers ); if (!new_delays) return stbi__load_gif_main_outofmem(&g, out, delays); *delays = new_delays; delays_size = layers * sizeof(int); } } else { out = (stbi_uc*)stbi__malloc( layers * stride ); if (!out) return stbi__load_gif_main_outofmem(&g, out, delays); out_size = layers * stride; if (delays) { *delays = (int*) stbi__malloc( layers * sizeof(int) ); if (!*delays) return stbi__load_gif_main_outofmem(&g, out, delays); delays_size = layers * sizeof(int); } } memcpy( out + ((layers - 1) * stride), u, stride ); if (layers >= 2) { two_back = out - 2 * stride; } if (delays) { (*delays)[layers - 1U] = g.delay; } } } while (u != 0); // free temp buffer; STBI_FREE(g.out); STBI_FREE(g.history); STBI_FREE(g.background); // do the final conversion after loading everything; if (req_comp && req_comp != 4) out = stbi__convert_format(out, 4, req_comp, layers * g.w, g.h); *z = layers; return out; } else { return stbi__errpuc("not GIF", "Image was not as a gif type."); } } static void *stbi__gif_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri) { stbi_uc *u = 0; stbi__gif g; memset(&g, 0, sizeof(g)); STBI_NOTUSED(ri); u = stbi__gif_load_next(s, &g, comp, req_comp, 0); if (u == (stbi_uc *) s) u = 0; // end of animated gif marker if (u) { *x = g.w; *y = g.h; // moved conversion to after successful load so that the same // can be done for multiple frames. if (req_comp && req_comp != 4) u = stbi__convert_format(u, 4, req_comp, g.w, g.h); } else if (g.out) { // if there was an error and we allocated an image buffer, free it! STBI_FREE(g.out); } // free buffers needed for multiple frame loading; STBI_FREE(g.history); STBI_FREE(g.background); return u; } static int stbi__gif_info(stbi__context *s, int *x, int *y, int *comp) { return stbi__gif_info_raw(s,x,y,comp); } #endif // ************************************************************************************************* // Radiance RGBE HDR loader // originally by Nicolas Schulz #ifndef STBI_NO_HDR static int stbi__hdr_test_core(stbi__context *s, const char *signature) { int i; for (i=0; signature[i]; ++i) if (stbi__get8(s) != signature[i]) return 0; stbi__rewind(s); return 1; } static int stbi__hdr_test(stbi__context* s) { int r = stbi__hdr_test_core(s, "#?RADIANCE\n"); stbi__rewind(s); if(!r) { r = stbi__hdr_test_core(s, "#?RGBE\n"); stbi__rewind(s); } return r; } #define STBI__HDR_BUFLEN 1024 static char *stbi__hdr_gettoken(stbi__context *z, char *buffer) { int len=0; char c = '\0'; c = (char) stbi__get8(z); while (!stbi__at_eof(z) && c != '\n') { buffer[len++] = c; if (len == STBI__HDR_BUFLEN-1) { // flush to end of line while (!stbi__at_eof(z) && stbi__get8(z) != '\n') ; break; } c = (char) stbi__get8(z); } buffer[len] = 0; return buffer; } static void stbi__hdr_convert(float *output, stbi_uc *input, int req_comp) { if ( input[3] != 0 ) { float f1; // Exponent f1 = (float) ldexp(1.0f, input[3] - (int)(128 + 8)); if (req_comp <= 2) output[0] = (input[0] + input[1] + input[2]) * f1 / 3; else { output[0] = input[0] * f1; output[1] = input[1] * f1; output[2] = input[2] * f1; } if (req_comp == 2) output[1] = 1; if (req_comp == 4) output[3] = 1; } else { switch (req_comp) { case 4: output[3] = 1; /* fallthrough */ case 3: output[0] = output[1] = output[2] = 0; break; case 2: output[1] = 1; /* fallthrough */ case 1: output[0] = 0; break; } } } static float *stbi__hdr_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri) { char buffer[STBI__HDR_BUFLEN]; char *token; int valid = 0; int width, height; stbi_uc *scanline; float *hdr_data; int len; unsigned char count, value; int i, j, k, c1,c2, z; const char *headerToken; STBI_NOTUSED(ri); // Check identifier headerToken = stbi__hdr_gettoken(s,buffer); if (strcmp(headerToken, "#?RADIANCE") != 0 && strcmp(headerToken, "#?RGBE") != 0) return stbi__errpf("not HDR", "Corrupt HDR image"); // Parse header for(;;) { token = stbi__hdr_gettoken(s,buffer); if (token[0] == 0) break; if (strcmp(token, "FORMAT=32-bit_rle_rgbe") == 0) valid = 1; } if (!valid) return stbi__errpf("unsupported format", "Unsupported HDR format"); // Parse width and height // can't use sscanf() if we're not using stdio! token = stbi__hdr_gettoken(s,buffer); if (strncmp(token, "-Y ", 3)) return stbi__errpf("unsupported data layout", "Unsupported HDR format"); token += 3; height = (int) strtol(token, &token, 10); while (*token == ' ') ++token; if (strncmp(token, "+X ", 3)) return stbi__errpf("unsupported data layout", "Unsupported HDR format"); token += 3; width = (int) strtol(token, NULL, 10); if (height > STBI_MAX_DIMENSIONS) return stbi__errpf("too large","Very large image (corrupt?)"); if (width > STBI_MAX_DIMENSIONS) return stbi__errpf("too large","Very large image (corrupt?)"); *x = width; *y = height; if (comp) *comp = 3; if (req_comp == 0) req_comp = 3; if (!stbi__mad4sizes_valid(width, height, req_comp, sizeof(float), 0)) return stbi__errpf("too large", "HDR image is too large"); // Read data hdr_data = (float *) stbi__malloc_mad4(width, height, req_comp, sizeof(float), 0); if (!hdr_data) return stbi__errpf("outofmem", "Out of memory"); // Load image data // image data is stored as some number of sca if ( width < 8 || width >= 32768) { // Read flat data for (j=0; j < height; ++j) { for (i=0; i < width; ++i) { stbi_uc rgbe[4]; main_decode_loop: stbi__getn(s, rgbe, 4); stbi__hdr_convert(hdr_data + j * width * req_comp + i * req_comp, rgbe, req_comp); } } } else { // Read RLE-encoded data scanline = NULL; for (j = 0; j < height; ++j) { c1 = stbi__get8(s); c2 = stbi__get8(s); len = stbi__get8(s); if (c1 != 2 || c2 != 2 || (len & 0x80)) { // not run-length encoded, so we have to actually use THIS data as a decoded // pixel (note this can't be a valid pixel--one of RGB must be >= 128) stbi_uc rgbe[4]; rgbe[0] = (stbi_uc) c1; rgbe[1] = (stbi_uc) c2; rgbe[2] = (stbi_uc) len; rgbe[3] = (stbi_uc) stbi__get8(s); stbi__hdr_convert(hdr_data, rgbe, req_comp); i = 1; j = 0; STBI_FREE(scanline); goto main_decode_loop; // yes, this makes no sense } len <<= 8; len |= stbi__get8(s); if (len != width) { STBI_FREE(hdr_data); STBI_FREE(scanline); return stbi__errpf("invalid decoded scanline length", "corrupt HDR"); } if (scanline == NULL) { scanline = (stbi_uc *) stbi__malloc_mad2(width, 4, 0); if (!scanline) { STBI_FREE(hdr_data); return stbi__errpf("outofmem", "Out of memory"); } } for (k = 0; k < 4; ++k) { int nleft; i = 0; while ((nleft = width - i) > 0) { count = stbi__get8(s); if (count > 128) { // Run value = stbi__get8(s); count -= 128; if ((count == 0) || (count > nleft)) { STBI_FREE(hdr_data); STBI_FREE(scanline); return stbi__errpf("corrupt", "bad RLE data in HDR"); } for (z = 0; z < count; ++z) scanline[i++ * 4 + k] = value; } else { // Dump if ((count == 0) || (count > nleft)) { STBI_FREE(hdr_data); STBI_FREE(scanline); return stbi__errpf("corrupt", "bad RLE data in HDR"); } for (z = 0; z < count; ++z) scanline[i++ * 4 + k] = stbi__get8(s); } } } for (i=0; i < width; ++i) stbi__hdr_convert(hdr_data+(j*width + i)*req_comp, scanline + i*4, req_comp); } if (scanline) STBI_FREE(scanline); } return hdr_data; } static int stbi__hdr_info(stbi__context *s, int *x, int *y, int *comp) { char buffer[STBI__HDR_BUFLEN]; char *token; int valid = 0; int dummy; if (!x) x = &dummy; if (!y) y = &dummy; if (!comp) comp = &dummy; if (stbi__hdr_test(s) == 0) { stbi__rewind( s ); return 0; } for(;;) { token = stbi__hdr_gettoken(s,buffer); if (token[0] == 0) break; if (strcmp(token, "FORMAT=32-bit_rle_rgbe") == 0) valid = 1; } if (!valid) { stbi__rewind( s ); return 0; } token = stbi__hdr_gettoken(s,buffer); if (strncmp(token, "-Y ", 3)) { stbi__rewind( s ); return 0; } token += 3; *y = (int) strtol(token, &token, 10); while (*token == ' ') ++token; if (strncmp(token, "+X ", 3)) { stbi__rewind( s ); return 0; } token += 3; *x = (int) strtol(token, NULL, 10); *comp = 3; return 1; } #endif // STBI_NO_HDR #ifndef STBI_NO_BMP static int stbi__bmp_info(stbi__context *s, int *x, int *y, int *comp) { void *p; stbi__bmp_data info; info.all_a = 255; p = stbi__bmp_parse_header(s, &info); if (p == NULL) { stbi__rewind( s ); return 0; } if (x) *x = s->img_x; if (y) *y = s->img_y; if (comp) { if (info.bpp == 24 && info.ma == 0xff000000) *comp = 3; else *comp = info.ma ? 4 : 3; } return 1; } #endif #ifndef STBI_NO_PSD static int stbi__psd_info(stbi__context *s, int *x, int *y, int *comp) { int channelCount, dummy, depth; if (!x) x = &dummy; if (!y) y = &dummy; if (!comp) comp = &dummy; if (stbi__get32be(s) != 0x38425053) { stbi__rewind( s ); return 0; } if (stbi__get16be(s) != 1) { stbi__rewind( s ); return 0; } stbi__skip(s, 6); channelCount = stbi__get16be(s); if (channelCount < 0 || channelCount > 16) { stbi__rewind( s ); return 0; } *y = stbi__get32be(s); *x = stbi__get32be(s); depth = stbi__get16be(s); if (depth != 8 && depth != 16) { stbi__rewind( s ); return 0; } if (stbi__get16be(s) != 3) { stbi__rewind( s ); return 0; } *comp = 4; return 1; } static int stbi__psd_is16(stbi__context *s) { int channelCount, depth; if (stbi__get32be(s) != 0x38425053) { stbi__rewind( s ); return 0; } if (stbi__get16be(s) != 1) { stbi__rewind( s ); return 0; } stbi__skip(s, 6); channelCount = stbi__get16be(s); if (channelCount < 0 || channelCount > 16) { stbi__rewind( s ); return 0; } STBI_NOTUSED(stbi__get32be(s)); STBI_NOTUSED(stbi__get32be(s)); depth = stbi__get16be(s); if (depth != 16) { stbi__rewind( s ); return 0; } return 1; } #endif #ifndef STBI_NO_PIC static int stbi__pic_info(stbi__context *s, int *x, int *y, int *comp) { int act_comp=0,num_packets=0,chained,dummy; stbi__pic_packet packets[10]; if (!x) x = &dummy; if (!y) y = &dummy; if (!comp) comp = &dummy; if (!stbi__pic_is4(s,"\x53\x80\xF6\x34")) { stbi__rewind(s); return 0; } stbi__skip(s, 88); *x = stbi__get16be(s); *y = stbi__get16be(s); if (stbi__at_eof(s)) { stbi__rewind( s); return 0; } if ( (*x) != 0 && (1 << 28) / (*x) < (*y)) { stbi__rewind( s ); return 0; } stbi__skip(s, 8); do { stbi__pic_packet *packet; if (num_packets==sizeof(packets)/sizeof(packets[0])) return 0; packet = &packets[num_packets++]; chained = stbi__get8(s); packet->size = stbi__get8(s); packet->type = stbi__get8(s); packet->channel = stbi__get8(s); act_comp |= packet->channel; if (stbi__at_eof(s)) { stbi__rewind( s ); return 0; } if (packet->size != 8) { stbi__rewind( s ); return 0; } } while (chained); *comp = (act_comp & 0x10 ? 4 : 3); return 1; } #endif // ************************************************************************************************* // Portable Gray Map and Portable Pixel Map loader // by Ken Miller // // PGM: http://netpbm.sourceforge.net/doc/pgm.html // PPM: http://netpbm.sourceforge.net/doc/ppm.html // // Known limitations: // Does not support comments in the header section // Does not support ASCII image data (formats P2 and P3) #ifndef STBI_NO_PNM static int stbi__pnm_test(stbi__context *s) { char p, t; p = (char) stbi__get8(s); t = (char) stbi__get8(s); if (p != 'P' || (t != '5' && t != '6')) { stbi__rewind( s ); return 0; } return 1; } static void *stbi__pnm_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri) { stbi_uc *out; STBI_NOTUSED(ri); ri->bits_per_channel = stbi__pnm_info(s, (int *)&s->img_x, (int *)&s->img_y, (int *)&s->img_n); if (ri->bits_per_channel == 0) return 0; if (s->img_y > STBI_MAX_DIMENSIONS) return stbi__errpuc("too large","Very large image (corrupt?)"); if (s->img_x > STBI_MAX_DIMENSIONS) return stbi__errpuc("too large","Very large image (corrupt?)"); *x = s->img_x; *y = s->img_y; if (comp) *comp = s->img_n; if (!stbi__mad4sizes_valid(s->img_n, s->img_x, s->img_y, ri->bits_per_channel / 8, 0)) return stbi__errpuc("too large", "PNM too large"); out = (stbi_uc *) stbi__malloc_mad4(s->img_n, s->img_x, s->img_y, ri->bits_per_channel / 8, 0); if (!out) return stbi__errpuc("outofmem", "Out of memory"); if (!stbi__getn(s, out, s->img_n * s->img_x * s->img_y * (ri->bits_per_channel / 8))) { STBI_FREE(out); return stbi__errpuc("bad PNM", "PNM file truncated"); } if (req_comp && req_comp != s->img_n) { if (ri->bits_per_channel == 16) { out = (stbi_uc *) stbi__convert_format16((stbi__uint16 *) out, s->img_n, req_comp, s->img_x, s->img_y); } else { out = stbi__convert_format(out, s->img_n, req_comp, s->img_x, s->img_y); } if (out == NULL) return out; // stbi__convert_format frees input on failure } return out; } static int stbi__pnm_isspace(char c) { return c == ' ' || c == '\t' || c == '\n' || c == '\v' || c == '\f' || c == '\r'; } static void stbi__pnm_skip_whitespace(stbi__context *s, char *c) { for (;;) { while (!stbi__at_eof(s) && stbi__pnm_isspace(*c)) *c = (char) stbi__get8(s); if (stbi__at_eof(s) || *c != '#') break; while (!stbi__at_eof(s) && *c != '\n' && *c != '\r' ) *c = (char) stbi__get8(s); } } static int stbi__pnm_isdigit(char c) { return c >= '0' && c <= '9'; } static int stbi__pnm_getinteger(stbi__context *s, char *c) { int value = 0; while (!stbi__at_eof(s) && stbi__pnm_isdigit(*c)) { value = value*10 + (*c - '0'); *c = (char) stbi__get8(s); if((value > 214748364) || (value == 214748364 && *c > '7')) return stbi__err("integer parse overflow", "Parsing an integer in the PPM header overflowed a 32-bit int"); } return value; } static int stbi__pnm_info(stbi__context *s, int *x, int *y, int *comp) { int maxv, dummy; char c, p, t; if (!x) x = &dummy; if (!y) y = &dummy; if (!comp) comp = &dummy; stbi__rewind(s); // Get identifier p = (char) stbi__get8(s); t = (char) stbi__get8(s); if (p != 'P' || (t != '5' && t != '6')) { stbi__rewind(s); return 0; } *comp = (t == '6') ? 3 : 1; // '5' is 1-component .pgm; '6' is 3-component .ppm c = (char) stbi__get8(s); stbi__pnm_skip_whitespace(s, &c); *x = stbi__pnm_getinteger(s, &c); // read width if(*x == 0) return stbi__err("invalid width", "PPM image header had zero or overflowing width"); stbi__pnm_skip_whitespace(s, &c); *y = stbi__pnm_getinteger(s, &c); // read height if (*y == 0) return stbi__err("invalid width", "PPM image header had zero or overflowing width"); stbi__pnm_skip_whitespace(s, &c); maxv = stbi__pnm_getinteger(s, &c); // read max value if (maxv > 65535) return stbi__err("max value > 65535", "PPM image supports only 8-bit and 16-bit images"); else if (maxv > 255) return 16; else return 8; } static int stbi__pnm_is16(stbi__context *s) { if (stbi__pnm_info(s, NULL, NULL, NULL) == 16) return 1; return 0; } #endif static int stbi__info_main(stbi__context *s, int *x, int *y, int *comp) { #ifndef STBI_NO_JPEG if (stbi__jpeg_info(s, x, y, comp)) return 1; #endif #ifndef STBI_NO_PNG if (stbi__png_info(s, x, y, comp)) return 1; #endif #ifndef STBI_NO_GIF if (stbi__gif_info(s, x, y, comp)) return 1; #endif #ifndef STBI_NO_BMP if (stbi__bmp_info(s, x, y, comp)) return 1; #endif #ifndef STBI_NO_PSD if (stbi__psd_info(s, x, y, comp)) return 1; #endif #ifndef STBI_NO_PIC if (stbi__pic_info(s, x, y, comp)) return 1; #endif #ifndef STBI_NO_PNM if (stbi__pnm_info(s, x, y, comp)) return 1; #endif #ifndef STBI_NO_HDR if (stbi__hdr_info(s, x, y, comp)) return 1; #endif // test tga last because it's a crappy test! #ifndef STBI_NO_TGA if (stbi__tga_info(s, x, y, comp)) return 1; #endif return stbi__err("unknown image type", "Image not of any known type, or corrupt"); } static int stbi__is_16_main(stbi__context *s) { #ifndef STBI_NO_PNG if (stbi__png_is16(s)) return 1; #endif #ifndef STBI_NO_PSD if (stbi__psd_is16(s)) return 1; #endif #ifndef STBI_NO_PNM if (stbi__pnm_is16(s)) return 1; #endif return 0; } #ifndef STBI_NO_STDIO STBIDEF int stbi_info(char const *filename, int *x, int *y, int *comp) { FILE *f = stbi__fopen(filename, "rb"); int result; if (!f) return stbi__err("can't fopen", "Unable to open file"); result = stbi_info_from_file(f, x, y, comp); fclose(f); return result; } STBIDEF int stbi_info_from_file(FILE *f, int *x, int *y, int *comp) { int r; stbi__context s; long pos = ftell(f); stbi__start_file(&s, f); r = stbi__info_main(&s,x,y,comp); fseek(f,pos,SEEK_SET); return r; } STBIDEF int stbi_is_16_bit(char const *filename) { FILE *f = stbi__fopen(filename, "rb"); int result; if (!f) return stbi__err("can't fopen", "Unable to open file"); result = stbi_is_16_bit_from_file(f); fclose(f); return result; } STBIDEF int stbi_is_16_bit_from_file(FILE *f) { int r; stbi__context s; long pos = ftell(f); stbi__start_file(&s, f); r = stbi__is_16_main(&s); fseek(f,pos,SEEK_SET); return r; } #endif // !STBI_NO_STDIO STBIDEF int stbi_info_from_memory(stbi_uc const *buffer, int len, int *x, int *y, int *comp) { stbi__context s; stbi__start_mem(&s,buffer,len); return stbi__info_main(&s,x,y,comp); } STBIDEF int stbi_info_from_callbacks(stbi_io_callbacks const *c, void *user, int *x, int *y, int *comp) { stbi__context s; stbi__start_callbacks(&s, (stbi_io_callbacks *) c, user); return stbi__info_main(&s,x,y,comp); } STBIDEF int stbi_is_16_bit_from_memory(stbi_uc const *buffer, int len) { stbi__context s; stbi__start_mem(&s,buffer,len); return stbi__is_16_main(&s); } STBIDEF int stbi_is_16_bit_from_callbacks(stbi_io_callbacks const *c, void *user) { stbi__context s; stbi__start_callbacks(&s, (stbi_io_callbacks *) c, user); return stbi__is_16_main(&s); } #endif // STB_IMAGE_IMPLEMENTATION /* revision history: 2.20 (2019-02-07) support utf8 filenames in Windows; fix warnings and platform ifdefs 2.19 (2018-02-11) fix warning 2.18 (2018-01-30) fix warnings 2.17 (2018-01-29) change sbti__shiftsigned to avoid clang -O2 bug 1-bit BMP *_is_16_bit api avoid warnings 2.16 (2017-07-23) all functions have 16-bit variants; STBI_NO_STDIO works again; compilation fixes; fix rounding in unpremultiply; optimize vertical flip; disable raw_len validation; documentation fixes 2.15 (2017-03-18) fix png-1,2,4 bug; now all Imagenet JPGs decode; warning fixes; disable run-time SSE detection on gcc; uniform handling of optional "return" values; thread-safe initialization of zlib tables 2.14 (2017-03-03) remove deprecated STBI_JPEG_OLD; fixes for Imagenet JPGs 2.13 (2016-11-29) add 16-bit API, only supported for PNG right now 2.12 (2016-04-02) fix typo in 2.11 PSD fix that caused crashes 2.11 (2016-04-02) allocate large structures on the stack remove white matting for transparent PSD fix reported channel count for PNG & BMP re-enable SSE2 in non-gcc 64-bit support RGB-formatted JPEG read 16-bit PNGs (only as 8-bit) 2.10 (2016-01-22) avoid warning introduced in 2.09 by STBI_REALLOC_SIZED 2.09 (2016-01-16) allow comments in PNM files 16-bit-per-pixel TGA (not bit-per-component) info() for TGA could break due to .hdr handling info() for BMP to shares code instead of sloppy parse can use STBI_REALLOC_SIZED if allocator doesn't support realloc code cleanup 2.08 (2015-09-13) fix to 2.07 cleanup, reading RGB PSD as RGBA 2.07 (2015-09-13) fix compiler warnings partial animated GIF support limited 16-bpc PSD support #ifdef unused functions bug with < 92 byte PIC,PNM,HDR,TGA 2.06 (2015-04-19) fix bug where PSD returns wrong '*comp' value 2.05 (2015-04-19) fix bug in progressive JPEG handling, fix warning 2.04 (2015-04-15) try to re-enable SIMD on MinGW 64-bit 2.03 (2015-04-12) extra corruption checking (mmozeiko) stbi_set_flip_vertically_on_load (nguillemot) fix NEON support; fix mingw support 2.02 (2015-01-19) fix incorrect assert, fix warning 2.01 (2015-01-17) fix various warnings; suppress SIMD on gcc 32-bit without -msse2 2.00b (2014-12-25) fix STBI_MALLOC in progressive JPEG 2.00 (2014-12-25) optimize JPG, including x86 SSE2 & NEON SIMD (ryg) progressive JPEG (stb) PGM/PPM support (Ken Miller) STBI_MALLOC,STBI_REALLOC,STBI_FREE GIF bugfix -- seemingly never worked STBI_NO_*, STBI_ONLY_* 1.48 (2014-12-14) fix incorrectly-named assert() 1.47 (2014-12-14) 1/2/4-bit PNG support, both direct and paletted (Omar Cornut & stb) optimize PNG (ryg) fix bug in interlaced PNG with user-specified channel count (stb) 1.46 (2014-08-26) fix broken tRNS chunk (colorkey-style transparency) in non-paletted PNG 1.45 (2014-08-16) fix MSVC-ARM internal compiler error by wrapping malloc 1.44 (2014-08-07) various warning fixes from Ronny Chevalier 1.43 (2014-07-15) fix MSVC-only compiler problem in code changed in 1.42 1.42 (2014-07-09) don't define _CRT_SECURE_NO_WARNINGS (affects user code) fixes to stbi__cleanup_jpeg path added STBI_ASSERT to avoid requiring assert.h 1.41 (2014-06-25) fix search&replace from 1.36 that messed up comments/error messages 1.40 (2014-06-22) fix gcc struct-initialization warning 1.39 (2014-06-15) fix to TGA optimization when req_comp != number of components in TGA; fix to GIF loading because BMP wasn't rewinding (whoops, no GIFs in my test suite) add support for BMP version 5 (more ignored fields) 1.38 (2014-06-06) suppress MSVC warnings on integer casts truncating values fix accidental rename of 'skip' field of I/O 1.37 (2014-06-04) remove duplicate typedef 1.36 (2014-06-03) convert to header file single-file library if de-iphone isn't set, load iphone images color-swapped instead of returning NULL 1.35 (2014-05-27) various warnings fix broken STBI_SIMD path fix bug where stbi_load_from_file no longer left file pointer in correct place fix broken non-easy path for 32-bit BMP (possibly never used) TGA optimization by Arseny Kapoulkine 1.34 (unknown) use STBI_NOTUSED in stbi__resample_row_generic(), fix one more leak in tga failure case 1.33 (2011-07-14) make stbi_is_hdr work in STBI_NO_HDR (as specified), minor compiler-friendly improvements 1.32 (2011-07-13) support for "info" function for all supported filetypes (SpartanJ) 1.31 (2011-06-20) a few more leak fixes, bug in PNG handling (SpartanJ) 1.30 (2011-06-11) added ability to load files via callbacks to accomidate custom input streams (Ben Wenger) removed deprecated format-specific test/load functions removed support for installable file formats (stbi_loader) -- would have been broken for IO callbacks anyway error cases in bmp and tga give messages and don't leak (Raymond Barbiero, grisha) fix inefficiency in decoding 32-bit BMP (David Woo) 1.29 (2010-08-16) various warning fixes from Aurelien Pocheville 1.28 (2010-08-01) fix bug in GIF palette transparency (SpartanJ) 1.27 (2010-08-01) cast-to-stbi_uc to fix warnings 1.26 (2010-07-24) fix bug in file buffering for PNG reported by SpartanJ 1.25 (2010-07-17) refix trans_data warning (Won Chun) 1.24 (2010-07-12) perf improvements reading from files on platforms with lock-heavy fgetc() minor perf improvements for jpeg deprecated type-specific functions so we'll get feedback if they're needed attempt to fix trans_data warning (Won Chun) 1.23 fixed bug in iPhone support 1.22 (2010-07-10) removed image *writing* support stbi_info support from Jetro Lauha GIF support from Jean-Marc Lienher iPhone PNG-extensions from James Brown warning-fixes from Nicolas Schulz and Janez Zemva (i.stbi__err. Janez (U+017D)emva) 1.21 fix use of 'stbi_uc' in header (reported by jon blow) 1.20 added support for Softimage PIC, by Tom Seddon 1.19 bug in interlaced PNG corruption check (found by ryg) 1.18 (2008-08-02) fix a threading bug (local mutable static) 1.17 support interlaced PNG 1.16 major bugfix - stbi__convert_format converted one too many pixels 1.15 initialize some fields for thread safety 1.14 fix threadsafe conversion bug header-file-only version (#define STBI_HEADER_FILE_ONLY before including) 1.13 threadsafe 1.12 const qualifiers in the API 1.11 Support installable IDCT, colorspace conversion routines 1.10 Fixes for 64-bit (don't use "unsigned long") optimized upsampling by Fabian "ryg" Giesen 1.09 Fix format-conversion for PSD code (bad global variables!) 1.08 Thatcher Ulrich's PSD code integrated by Nicolas Schulz 1.07 attempt to fix C++ warning/errors again 1.06 attempt to fix C++ warning/errors again 1.05 fix TGA loading to return correct *comp and use good luminance calc 1.04 default float alpha is 1, not 255; use 'void *' for stbi_image_free 1.03 bugfixes to STBI_NO_STDIO, STBI_NO_HDR 1.02 support for (subset of) HDR files, float interface for preferred access to them 1.01 fix bug: possible bug in handling right-side up bmps... not sure fix bug: the stbi__bmp_load() and stbi__tga_load() functions didn't work at all 1.00 interface to zlib that skips zlib header 0.99 correct handling of alpha in palette 0.98 TGA loader by lonesock; dynamically add loaders (untested) 0.97 jpeg errors on too large a file; also catch another malloc failure 0.96 fix detection of invalid v value - particleman@mollyrocket forum 0.95 during header scan, seek to markers in case of padding 0.94 STBI_NO_STDIO to disable stdio usage; rename all #defines the same 0.93 handle jpegtran output; verbose errors 0.92 read 4,8,16,24,32-bit BMP files of several formats 0.91 output 24-bit Windows 3.0 BMP files 0.90 fix a few more warnings; bump version number to approach 1.0 0.61 bugfixes due to Marc LeBlanc, Christopher Lloyd 0.60 fix compiling as c++ 0.59 fix warnings: merge Dave Moore's -Wall fixes 0.58 fix bug: zlib uncompressed mode len/nlen was wrong endian 0.57 fix bug: jpg last huffman symbol before marker was >9 bits but less than 16 available 0.56 fix bug: zlib uncompressed mode len vs. nlen 0.55 fix bug: restart_interval not initialized to 0 0.54 allow NULL for 'int *comp' 0.53 fix bug in png 3->4; speedup png decoding 0.52 png handles req_comp=3,4 directly; minor cleanup; jpeg comments 0.51 obey req_comp requests, 1-component jpegs return as 1-component, on 'test' only check type, not whether we support this variant 0.50 (2006-11-19) first released version */ /* ------------------------------------------------------------------------------ This software is available under 2 licenses -- choose whichever you prefer. ------------------------------------------------------------------------------ ALTERNATIVE A - MIT License Copyright (c) 2017 Sean Barrett 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. ------------------------------------------------------------------------------ ALTERNATIVE B - Public Domain (www.unlicense.org) This is free and unencumbered software released into the public domain. Anyone is free to copy, modify, publish, use, compile, sell, or distribute this software, either in source code form or as a compiled binary, for any purpose, commercial or non-commercial, and by any means. In jurisdictions that recognize copyright laws, the author or authors of this software dedicate any and all copyright interest in the software to the public domain. We make this dedication for the benefit of the public at large and to the detriment of our heirs and successors. We intend this dedication to be an overt act of relinquishment in perpetuity of all present and future rights to this software under copyright law. 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 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. ------------------------------------------------------------------------------ */ ================================================ FILE: deps/include/stb/stb_image_resize.h ================================================ /* stb_image_resize - v0.95 - public domain image resizing by Jorge L Rodriguez (@VinoBS) - 2014 http://github.com/nothings/stb Written with emphasis on usability, portability, and efficiency. (No SIMD or threads, so it be easily outperformed by libs that use those.) Only scaling and translation is supported, no rotations or shears. Easy API downsamples w/Mitchell filter, upsamples w/cubic interpolation. COMPILING & LINKING In one C/C++ file that #includes this file, do this: #define STB_IMAGE_RESIZE_IMPLEMENTATION before the #include. That will create the implementation in that file. QUICKSTART stbir_resize_uint8( input_pixels , in_w , in_h , 0, output_pixels, out_w, out_h, 0, num_channels) stbir_resize_float(...) stbir_resize_uint8_srgb( input_pixels , in_w , in_h , 0, output_pixels, out_w, out_h, 0, num_channels , alpha_chan , 0) stbir_resize_uint8_srgb_edgemode( input_pixels , in_w , in_h , 0, output_pixels, out_w, out_h, 0, num_channels , alpha_chan , 0, STBIR_EDGE_CLAMP) // WRAP/REFLECT/ZERO FULL API See the "header file" section of the source for API documentation. ADDITIONAL DOCUMENTATION SRGB & FLOATING POINT REPRESENTATION The sRGB functions presume IEEE floating point. If you do not have IEEE floating point, define STBIR_NON_IEEE_FLOAT. This will use a slower implementation. MEMORY ALLOCATION The resize functions here perform a single memory allocation using malloc. To control the memory allocation, before the #include that triggers the implementation, do: #define STBIR_MALLOC(size,context) ... #define STBIR_FREE(ptr,context) ... Each resize function makes exactly one call to malloc/free, so to use temp memory, store the temp memory in the context and return that. ASSERT Define STBIR_ASSERT(boolval) to override assert() and not use assert.h OPTIMIZATION Define STBIR_SATURATE_INT to compute clamp values in-range using integer operations instead of float operations. This may be faster on some platforms. DEFAULT FILTERS For functions which don't provide explicit control over what filters to use, you can change the compile-time defaults with #define STBIR_DEFAULT_FILTER_UPSAMPLE STBIR_FILTER_something #define STBIR_DEFAULT_FILTER_DOWNSAMPLE STBIR_FILTER_something See stbir_filter in the header-file section for the list of filters. NEW FILTERS A number of 1D filter kernels are used. For a list of supported filters see the stbir_filter enum. To add a new filter, write a filter function and add it to stbir__filter_info_table. PROGRESS For interactive use with slow resize operations, you can install a progress-report callback: #define STBIR_PROGRESS_REPORT(val) some_func(val) The parameter val is a float which goes from 0 to 1 as progress is made. For example: static void my_progress_report(float progress); #define STBIR_PROGRESS_REPORT(val) my_progress_report(val) #define STB_IMAGE_RESIZE_IMPLEMENTATION #include "stb_image_resize.h" static void my_progress_report(float progress) { printf("Progress: %f%%\n", progress*100); } MAX CHANNELS If your image has more than 64 channels, define STBIR_MAX_CHANNELS to the max you'll have. ALPHA CHANNEL Most of the resizing functions provide the ability to control how the alpha channel of an image is processed. The important things to know about this: 1. The best mathematically-behaved version of alpha to use is called "premultiplied alpha", in which the other color channels have had the alpha value multiplied in. If you use premultiplied alpha, linear filtering (such as image resampling done by this library, or performed in texture units on GPUs) does the "right thing". While premultiplied alpha is standard in the movie CGI industry, it is still uncommon in the videogame/real-time world. If you linearly filter non-premultiplied alpha, strange effects occur. (For example, the 50/50 average of 99% transparent bright green and 1% transparent black produces 50% transparent dark green when non-premultiplied, whereas premultiplied it produces 50% transparent near-black. The former introduces green energy that doesn't exist in the source image.) 2. Artists should not edit premultiplied-alpha images; artists want non-premultiplied alpha images. Thus, art tools generally output non-premultiplied alpha images. 3. You will get best results in most cases by converting images to premultiplied alpha before processing them mathematically. 4. If you pass the flag STBIR_FLAG_ALPHA_PREMULTIPLIED, the resizer does not do anything special for the alpha channel; it is resampled identically to other channels. This produces the correct results for premultiplied-alpha images, but produces less-than-ideal results for non-premultiplied-alpha images. 5. If you do not pass the flag STBIR_FLAG_ALPHA_PREMULTIPLIED, then the resizer weights the contribution of input pixels based on their alpha values, or, equivalently, it multiplies the alpha value into the color channels, resamples, then divides by the resultant alpha value. Input pixels which have alpha=0 do not contribute at all to output pixels unless _all_ of the input pixels affecting that output pixel have alpha=0, in which case the result for that pixel is the same as it would be without STBIR_FLAG_ALPHA_PREMULTIPLIED. However, this is only true for input images in integer formats. For input images in float format, input pixels with alpha=0 have no effect, and output pixels which have alpha=0 will be 0 in all channels. (For float images, you can manually achieve the same result by adding a tiny epsilon value to the alpha channel of every image, and then subtracting or clamping it at the end.) 6. You can suppress the behavior described in #5 and make all-0-alpha pixels have 0 in all channels by #defining STBIR_NO_ALPHA_EPSILON. 7. You can separately control whether the alpha channel is interpreted as linear or affected by the colorspace. By default it is linear; you almost never want to apply the colorspace. (For example, graphics hardware does not apply sRGB conversion to the alpha channel.) CONTRIBUTORS Jorge L Rodriguez: Implementation Sean Barrett: API design, optimizations Aras Pranckevicius: bugfix Nathan Reed: warning fixes REVISIONS 0.95 (2017-07-23) fixed warnings 0.94 (2017-03-18) fixed warnings 0.93 (2017-03-03) fixed bug with certain combinations of heights 0.92 (2017-01-02) fix integer overflow on large (>2GB) images 0.91 (2016-04-02) fix warnings; fix handling of subpixel regions 0.90 (2014-09-17) first released version LICENSE See end of file for license information. TODO Don't decode all of the image data when only processing a partial tile Don't use full-width decode buffers when only processing a partial tile When processing wide images, break processing into tiles so data fits in L1 cache Installable filters? Resize that respects alpha test coverage (Reference code: FloatImage::alphaTestCoverage and FloatImage::scaleAlphaToCoverage: https://code.google.com/p/nvidia-texture-tools/source/browse/trunk/src/nvimage/FloatImage.cpp ) */ #ifndef STBIR_INCLUDE_STB_IMAGE_RESIZE_H #define STBIR_INCLUDE_STB_IMAGE_RESIZE_H #ifdef _MSC_VER typedef unsigned char stbir_uint8; typedef unsigned short stbir_uint16; typedef unsigned int stbir_uint32; #else #include typedef uint8_t stbir_uint8; typedef uint16_t stbir_uint16; typedef uint32_t stbir_uint32; #endif #ifdef STB_IMAGE_RESIZE_STATIC #define STBIRDEF static #else #ifdef __cplusplus #define STBIRDEF extern "C" #else #define STBIRDEF extern #endif #endif ////////////////////////////////////////////////////////////////////////////// // // Easy-to-use API: // // * "input pixels" points to an array of image data with 'num_channels' channels (e.g. RGB=3, RGBA=4) // * input_w is input image width (x-axis), input_h is input image height (y-axis) // * stride is the offset between successive rows of image data in memory, in bytes. you can // specify 0 to mean packed continuously in memory // * alpha channel is treated identically to other channels. // * colorspace is linear or sRGB as specified by function name // * returned result is 1 for success or 0 in case of an error. // #define STBIR_ASSERT() to trigger an assert on parameter validation errors. // * Memory required grows approximately linearly with input and output size, but with // discontinuities at input_w == output_w and input_h == output_h. // * These functions use a "default" resampling filter defined at compile time. To change the filter, // you can change the compile-time defaults by #defining STBIR_DEFAULT_FILTER_UPSAMPLE // and STBIR_DEFAULT_FILTER_DOWNSAMPLE, or you can use the medium-complexity API. STBIRDEF int stbir_resize_uint8( const unsigned char *input_pixels , int input_w , int input_h , int input_stride_in_bytes, unsigned char *output_pixels, int output_w, int output_h, int output_stride_in_bytes, int num_channels); STBIRDEF int stbir_resize_float( const float *input_pixels , int input_w , int input_h , int input_stride_in_bytes, float *output_pixels, int output_w, int output_h, int output_stride_in_bytes, int num_channels); // The following functions interpret image data as gamma-corrected sRGB. // Specify STBIR_ALPHA_CHANNEL_NONE if you have no alpha channel, // or otherwise provide the index of the alpha channel. Flags value // of 0 will probably do the right thing if you're not sure what // the flags mean. #define STBIR_ALPHA_CHANNEL_NONE -1 // Set this flag if your texture has premultiplied alpha. Otherwise, stbir will // use alpha-weighted resampling (effectively premultiplying, resampling, // then unpremultiplying). #define STBIR_FLAG_ALPHA_PREMULTIPLIED (1 << 0) // The specified alpha channel should be handled as gamma-corrected value even // when doing sRGB operations. #define STBIR_FLAG_ALPHA_USES_COLORSPACE (1 << 1) STBIRDEF int stbir_resize_uint8_srgb(const unsigned char *input_pixels , int input_w , int input_h , int input_stride_in_bytes, unsigned char *output_pixels, int output_w, int output_h, int output_stride_in_bytes, int num_channels, int alpha_channel, int flags); typedef enum { STBIR_EDGE_CLAMP = 1, STBIR_EDGE_REFLECT = 2, STBIR_EDGE_WRAP = 3, STBIR_EDGE_ZERO = 4, } stbir_edge; // This function adds the ability to specify how requests to sample off the edge of the image are handled. STBIRDEF int stbir_resize_uint8_srgb_edgemode(const unsigned char *input_pixels , int input_w , int input_h , int input_stride_in_bytes, unsigned char *output_pixels, int output_w, int output_h, int output_stride_in_bytes, int num_channels, int alpha_channel, int flags, stbir_edge edge_wrap_mode); ////////////////////////////////////////////////////////////////////////////// // // Medium-complexity API // // This extends the easy-to-use API as follows: // // * Alpha-channel can be processed separately // * If alpha_channel is not STBIR_ALPHA_CHANNEL_NONE // * Alpha channel will not be gamma corrected (unless flags&STBIR_FLAG_GAMMA_CORRECT) // * Filters will be weighted by alpha channel (unless flags&STBIR_FLAG_ALPHA_PREMULTIPLIED) // * Filter can be selected explicitly // * uint16 image type // * sRGB colorspace available for all types // * context parameter for passing to STBIR_MALLOC typedef enum { STBIR_FILTER_DEFAULT = 0, // use same filter type that easy-to-use API chooses STBIR_FILTER_BOX = 1, // A trapezoid w/1-pixel wide ramps, same result as box for integer scale ratios STBIR_FILTER_TRIANGLE = 2, // On upsampling, produces same results as bilinear texture filtering STBIR_FILTER_CUBICBSPLINE = 3, // The cubic b-spline (aka Mitchell-Netrevalli with B=1,C=0), gaussian-esque STBIR_FILTER_CATMULLROM = 4, // An interpolating cubic spline STBIR_FILTER_MITCHELL = 5, // Mitchell-Netrevalli filter with B=1/3, C=1/3 } stbir_filter; typedef enum { STBIR_COLORSPACE_LINEAR, STBIR_COLORSPACE_SRGB, STBIR_MAX_COLORSPACES, } stbir_colorspace; // The following functions are all identical except for the type of the image data STBIRDEF int stbir_resize_uint8_generic( const unsigned char *input_pixels , int input_w , int input_h , int input_stride_in_bytes, unsigned char *output_pixels, int output_w, int output_h, int output_stride_in_bytes, int num_channels, int alpha_channel, int flags, stbir_edge edge_wrap_mode, stbir_filter filter, stbir_colorspace space, void *alloc_context); STBIRDEF int stbir_resize_uint16_generic(const stbir_uint16 *input_pixels , int input_w , int input_h , int input_stride_in_bytes, stbir_uint16 *output_pixels , int output_w, int output_h, int output_stride_in_bytes, int num_channels, int alpha_channel, int flags, stbir_edge edge_wrap_mode, stbir_filter filter, stbir_colorspace space, void *alloc_context); STBIRDEF int stbir_resize_float_generic( const float *input_pixels , int input_w , int input_h , int input_stride_in_bytes, float *output_pixels , int output_w, int output_h, int output_stride_in_bytes, int num_channels, int alpha_channel, int flags, stbir_edge edge_wrap_mode, stbir_filter filter, stbir_colorspace space, void *alloc_context); ////////////////////////////////////////////////////////////////////////////// // // Full-complexity API // // This extends the medium API as follows: // // * uint32 image type // * not typesafe // * separate filter types for each axis // * separate edge modes for each axis // * can specify scale explicitly for subpixel correctness // * can specify image source tile using texture coordinates typedef enum { STBIR_TYPE_UINT8 , STBIR_TYPE_UINT16, STBIR_TYPE_UINT32, STBIR_TYPE_FLOAT , STBIR_MAX_TYPES } stbir_datatype; STBIRDEF int stbir_resize( const void *input_pixels , int input_w , int input_h , int input_stride_in_bytes, void *output_pixels, int output_w, int output_h, int output_stride_in_bytes, stbir_datatype datatype, int num_channels, int alpha_channel, int flags, stbir_edge edge_mode_horizontal, stbir_edge edge_mode_vertical, stbir_filter filter_horizontal, stbir_filter filter_vertical, stbir_colorspace space, void *alloc_context); STBIRDEF int stbir_resize_subpixel(const void *input_pixels , int input_w , int input_h , int input_stride_in_bytes, void *output_pixels, int output_w, int output_h, int output_stride_in_bytes, stbir_datatype datatype, int num_channels, int alpha_channel, int flags, stbir_edge edge_mode_horizontal, stbir_edge edge_mode_vertical, stbir_filter filter_horizontal, stbir_filter filter_vertical, stbir_colorspace space, void *alloc_context, float x_scale, float y_scale, float x_offset, float y_offset); STBIRDEF int stbir_resize_region( const void *input_pixels , int input_w , int input_h , int input_stride_in_bytes, void *output_pixels, int output_w, int output_h, int output_stride_in_bytes, stbir_datatype datatype, int num_channels, int alpha_channel, int flags, stbir_edge edge_mode_horizontal, stbir_edge edge_mode_vertical, stbir_filter filter_horizontal, stbir_filter filter_vertical, stbir_colorspace space, void *alloc_context, float s0, float t0, float s1, float t1); // (s0, t0) & (s1, t1) are the top-left and bottom right corner (uv addressing style: [0, 1]x[0, 1]) of a region of the input image to use. // // //// end header file ///////////////////////////////////////////////////// #endif // STBIR_INCLUDE_STB_IMAGE_RESIZE_H #ifdef STB_IMAGE_RESIZE_IMPLEMENTATION #ifndef STBIR_ASSERT #include #define STBIR_ASSERT(x) assert(x) #endif // For memset #include #include #ifndef STBIR_MALLOC #include // use comma operator to evaluate c, to avoid "unused parameter" warnings #define STBIR_MALLOC(size,c) ((void)(c), malloc(size)) #define STBIR_FREE(ptr,c) ((void)(c), free(ptr)) #endif #ifndef _MSC_VER #ifdef __cplusplus #define stbir__inline inline #else #define stbir__inline #endif #else #define stbir__inline __forceinline #endif // should produce compiler error if size is wrong typedef unsigned char stbir__validate_uint32[sizeof(stbir_uint32) == 4 ? 1 : -1]; #ifdef _MSC_VER #define STBIR__NOTUSED(v) (void)(v) #else #define STBIR__NOTUSED(v) (void)sizeof(v) #endif #define STBIR__ARRAY_SIZE(a) (sizeof((a))/sizeof((a)[0])) #ifndef STBIR_DEFAULT_FILTER_UPSAMPLE #define STBIR_DEFAULT_FILTER_UPSAMPLE STBIR_FILTER_CATMULLROM #endif #ifndef STBIR_DEFAULT_FILTER_DOWNSAMPLE #define STBIR_DEFAULT_FILTER_DOWNSAMPLE STBIR_FILTER_MITCHELL #endif #ifndef STBIR_PROGRESS_REPORT #define STBIR_PROGRESS_REPORT(float_0_to_1) #endif #ifndef STBIR_MAX_CHANNELS #define STBIR_MAX_CHANNELS 64 #endif #if STBIR_MAX_CHANNELS > 65536 #error "Too many channels; STBIR_MAX_CHANNELS must be no more than 65536." // because we store the indices in 16-bit variables #endif // This value is added to alpha just before premultiplication to avoid // zeroing out color values. It is equivalent to 2^-80. If you don't want // that behavior (it may interfere if you have floating point images with // very small alpha values) then you can define STBIR_NO_ALPHA_EPSILON to // disable it. #ifndef STBIR_ALPHA_EPSILON #define STBIR_ALPHA_EPSILON ((float)1 / (1 << 20) / (1 << 20) / (1 << 20) / (1 << 20)) #endif #ifdef _MSC_VER #define STBIR__UNUSED_PARAM(v) (void)(v) #else #define STBIR__UNUSED_PARAM(v) (void)sizeof(v) #endif // must match stbir_datatype static unsigned char stbir__type_size[] = { 1, // STBIR_TYPE_UINT8 2, // STBIR_TYPE_UINT16 4, // STBIR_TYPE_UINT32 4, // STBIR_TYPE_FLOAT }; // Kernel function centered at 0 typedef float (stbir__kernel_fn)(float x, float scale); typedef float (stbir__support_fn)(float scale); typedef struct { stbir__kernel_fn* kernel; stbir__support_fn* support; } stbir__filter_info; // When upsampling, the contributors are which source pixels contribute. // When downsampling, the contributors are which destination pixels are contributed to. typedef struct { int n0; // First contributing pixel int n1; // Last contributing pixel } stbir__contributors; typedef struct { const void* input_data; int input_w; int input_h; int input_stride_bytes; void* output_data; int output_w; int output_h; int output_stride_bytes; float s0, t0, s1, t1; float horizontal_shift; // Units: output pixels float vertical_shift; // Units: output pixels float horizontal_scale; float vertical_scale; int channels; int alpha_channel; stbir_uint32 flags; stbir_datatype type; stbir_filter horizontal_filter; stbir_filter vertical_filter; stbir_edge edge_horizontal; stbir_edge edge_vertical; stbir_colorspace colorspace; stbir__contributors* horizontal_contributors; float* horizontal_coefficients; stbir__contributors* vertical_contributors; float* vertical_coefficients; int decode_buffer_pixels; float* decode_buffer; float* horizontal_buffer; // cache these because ceil/floor are inexplicably showing up in profile int horizontal_coefficient_width; int vertical_coefficient_width; int horizontal_filter_pixel_width; int vertical_filter_pixel_width; int horizontal_filter_pixel_margin; int vertical_filter_pixel_margin; int horizontal_num_contributors; int vertical_num_contributors; int ring_buffer_length_bytes; // The length of an individual entry in the ring buffer. The total number of ring buffers is stbir__get_filter_pixel_width(filter) int ring_buffer_num_entries; // Total number of entries in the ring buffer. int ring_buffer_first_scanline; int ring_buffer_last_scanline; int ring_buffer_begin_index; // first_scanline is at this index in the ring buffer float* ring_buffer; float* encode_buffer; // A temporary buffer to store floats so we don't lose precision while we do multiply-adds. int horizontal_contributors_size; int horizontal_coefficients_size; int vertical_contributors_size; int vertical_coefficients_size; int decode_buffer_size; int horizontal_buffer_size; int ring_buffer_size; int encode_buffer_size; } stbir__info; static const float stbir__max_uint8_as_float = 255.0f; static const float stbir__max_uint16_as_float = 65535.0f; static const double stbir__max_uint32_as_float = 4294967295.0; static stbir__inline int stbir__min(int a, int b) { return a < b ? a : b; } static stbir__inline float stbir__saturate(float x) { if (x < 0) return 0; if (x > 1) return 1; return x; } #ifdef STBIR_SATURATE_INT static stbir__inline stbir_uint8 stbir__saturate8(int x) { if ((unsigned int) x <= 255) return x; if (x < 0) return 0; return 255; } static stbir__inline stbir_uint16 stbir__saturate16(int x) { if ((unsigned int) x <= 65535) return x; if (x < 0) return 0; return 65535; } #endif static float stbir__srgb_uchar_to_linear_float[256] = { 0.000000f, 0.000304f, 0.000607f, 0.000911f, 0.001214f, 0.001518f, 0.001821f, 0.002125f, 0.002428f, 0.002732f, 0.003035f, 0.003347f, 0.003677f, 0.004025f, 0.004391f, 0.004777f, 0.005182f, 0.005605f, 0.006049f, 0.006512f, 0.006995f, 0.007499f, 0.008023f, 0.008568f, 0.009134f, 0.009721f, 0.010330f, 0.010960f, 0.011612f, 0.012286f, 0.012983f, 0.013702f, 0.014444f, 0.015209f, 0.015996f, 0.016807f, 0.017642f, 0.018500f, 0.019382f, 0.020289f, 0.021219f, 0.022174f, 0.023153f, 0.024158f, 0.025187f, 0.026241f, 0.027321f, 0.028426f, 0.029557f, 0.030713f, 0.031896f, 0.033105f, 0.034340f, 0.035601f, 0.036889f, 0.038204f, 0.039546f, 0.040915f, 0.042311f, 0.043735f, 0.045186f, 0.046665f, 0.048172f, 0.049707f, 0.051269f, 0.052861f, 0.054480f, 0.056128f, 0.057805f, 0.059511f, 0.061246f, 0.063010f, 0.064803f, 0.066626f, 0.068478f, 0.070360f, 0.072272f, 0.074214f, 0.076185f, 0.078187f, 0.080220f, 0.082283f, 0.084376f, 0.086500f, 0.088656f, 0.090842f, 0.093059f, 0.095307f, 0.097587f, 0.099899f, 0.102242f, 0.104616f, 0.107023f, 0.109462f, 0.111932f, 0.114435f, 0.116971f, 0.119538f, 0.122139f, 0.124772f, 0.127438f, 0.130136f, 0.132868f, 0.135633f, 0.138432f, 0.141263f, 0.144128f, 0.147027f, 0.149960f, 0.152926f, 0.155926f, 0.158961f, 0.162029f, 0.165132f, 0.168269f, 0.171441f, 0.174647f, 0.177888f, 0.181164f, 0.184475f, 0.187821f, 0.191202f, 0.194618f, 0.198069f, 0.201556f, 0.205079f, 0.208637f, 0.212231f, 0.215861f, 0.219526f, 0.223228f, 0.226966f, 0.230740f, 0.234551f, 0.238398f, 0.242281f, 0.246201f, 0.250158f, 0.254152f, 0.258183f, 0.262251f, 0.266356f, 0.270498f, 0.274677f, 0.278894f, 0.283149f, 0.287441f, 0.291771f, 0.296138f, 0.300544f, 0.304987f, 0.309469f, 0.313989f, 0.318547f, 0.323143f, 0.327778f, 0.332452f, 0.337164f, 0.341914f, 0.346704f, 0.351533f, 0.356400f, 0.361307f, 0.366253f, 0.371238f, 0.376262f, 0.381326f, 0.386430f, 0.391573f, 0.396755f, 0.401978f, 0.407240f, 0.412543f, 0.417885f, 0.423268f, 0.428691f, 0.434154f, 0.439657f, 0.445201f, 0.450786f, 0.456411f, 0.462077f, 0.467784f, 0.473532f, 0.479320f, 0.485150f, 0.491021f, 0.496933f, 0.502887f, 0.508881f, 0.514918f, 0.520996f, 0.527115f, 0.533276f, 0.539480f, 0.545725f, 0.552011f, 0.558340f, 0.564712f, 0.571125f, 0.577581f, 0.584078f, 0.590619f, 0.597202f, 0.603827f, 0.610496f, 0.617207f, 0.623960f, 0.630757f, 0.637597f, 0.644480f, 0.651406f, 0.658375f, 0.665387f, 0.672443f, 0.679543f, 0.686685f, 0.693872f, 0.701102f, 0.708376f, 0.715694f, 0.723055f, 0.730461f, 0.737911f, 0.745404f, 0.752942f, 0.760525f, 0.768151f, 0.775822f, 0.783538f, 0.791298f, 0.799103f, 0.806952f, 0.814847f, 0.822786f, 0.830770f, 0.838799f, 0.846873f, 0.854993f, 0.863157f, 0.871367f, 0.879622f, 0.887923f, 0.896269f, 0.904661f, 0.913099f, 0.921582f, 0.930111f, 0.938686f, 0.947307f, 0.955974f, 0.964686f, 0.973445f, 0.982251f, 0.991102f, 1.0f }; static float stbir__srgb_to_linear(float f) { if (f <= 0.04045f) return f / 12.92f; else return (float)pow((f + 0.055f) / 1.055f, 2.4f); } static float stbir__linear_to_srgb(float f) { if (f <= 0.0031308f) return f * 12.92f; else return 1.055f * (float)pow(f, 1 / 2.4f) - 0.055f; } #ifndef STBIR_NON_IEEE_FLOAT // From https://gist.github.com/rygorous/2203834 typedef union { stbir_uint32 u; float f; } stbir__FP32; static const stbir_uint32 fp32_to_srgb8_tab4[104] = { 0x0073000d, 0x007a000d, 0x0080000d, 0x0087000d, 0x008d000d, 0x0094000d, 0x009a000d, 0x00a1000d, 0x00a7001a, 0x00b4001a, 0x00c1001a, 0x00ce001a, 0x00da001a, 0x00e7001a, 0x00f4001a, 0x0101001a, 0x010e0033, 0x01280033, 0x01410033, 0x015b0033, 0x01750033, 0x018f0033, 0x01a80033, 0x01c20033, 0x01dc0067, 0x020f0067, 0x02430067, 0x02760067, 0x02aa0067, 0x02dd0067, 0x03110067, 0x03440067, 0x037800ce, 0x03df00ce, 0x044600ce, 0x04ad00ce, 0x051400ce, 0x057b00c5, 0x05dd00bc, 0x063b00b5, 0x06970158, 0x07420142, 0x07e30130, 0x087b0120, 0x090b0112, 0x09940106, 0x0a1700fc, 0x0a9500f2, 0x0b0f01cb, 0x0bf401ae, 0x0ccb0195, 0x0d950180, 0x0e56016e, 0x0f0d015e, 0x0fbc0150, 0x10630143, 0x11070264, 0x1238023e, 0x1357021d, 0x14660201, 0x156601e9, 0x165a01d3, 0x174401c0, 0x182401af, 0x18fe0331, 0x1a9602fe, 0x1c1502d2, 0x1d7e02ad, 0x1ed4028d, 0x201a0270, 0x21520256, 0x227d0240, 0x239f0443, 0x25c003fe, 0x27bf03c4, 0x29a10392, 0x2b6a0367, 0x2d1d0341, 0x2ebe031f, 0x304d0300, 0x31d105b0, 0x34a80555, 0x37520507, 0x39d504c5, 0x3c37048b, 0x3e7c0458, 0x40a8042a, 0x42bd0401, 0x44c20798, 0x488e071e, 0x4c1c06b6, 0x4f76065d, 0x52a50610, 0x55ac05cc, 0x5892058f, 0x5b590559, 0x5e0c0a23, 0x631c0980, 0x67db08f6, 0x6c55087f, 0x70940818, 0x74a007bd, 0x787d076c, 0x7c330723, }; static stbir_uint8 stbir__linear_to_srgb_uchar(float in) { static const stbir__FP32 almostone = { 0x3f7fffff }; // 1-eps static const stbir__FP32 minval = { (127-13) << 23 }; stbir_uint32 tab,bias,scale,t; stbir__FP32 f; // Clamp to [2^(-13), 1-eps]; these two values map to 0 and 1, respectively. // The tests are carefully written so that NaNs map to 0, same as in the reference // implementation. if (!(in > minval.f)) // written this way to catch NaNs in = minval.f; if (in > almostone.f) in = almostone.f; // Do the table lookup and unpack bias, scale f.f = in; tab = fp32_to_srgb8_tab4[(f.u - minval.u) >> 20]; bias = (tab >> 16) << 9; scale = tab & 0xffff; // Grab next-highest mantissa bits and perform linear interpolation t = (f.u >> 12) & 0xff; return (unsigned char) ((bias + scale*t) >> 16); } #else // sRGB transition values, scaled by 1<<28 static int stbir__srgb_offset_to_linear_scaled[256] = { 0, 40738, 122216, 203693, 285170, 366648, 448125, 529603, 611080, 692557, 774035, 855852, 942009, 1033024, 1128971, 1229926, 1335959, 1447142, 1563542, 1685229, 1812268, 1944725, 2082664, 2226148, 2375238, 2529996, 2690481, 2856753, 3028870, 3206888, 3390865, 3580856, 3776916, 3979100, 4187460, 4402049, 4622919, 4850123, 5083710, 5323731, 5570236, 5823273, 6082892, 6349140, 6622065, 6901714, 7188133, 7481369, 7781466, 8088471, 8402427, 8723380, 9051372, 9386448, 9728650, 10078021, 10434603, 10798439, 11169569, 11548036, 11933879, 12327139, 12727857, 13136073, 13551826, 13975156, 14406100, 14844697, 15290987, 15745007, 16206795, 16676389, 17153826, 17639142, 18132374, 18633560, 19142734, 19659934, 20185196, 20718552, 21260042, 21809696, 22367554, 22933648, 23508010, 24090680, 24681686, 25281066, 25888850, 26505076, 27129772, 27762974, 28404716, 29055026, 29713942, 30381490, 31057708, 31742624, 32436272, 33138682, 33849884, 34569912, 35298800, 36036568, 36783260, 37538896, 38303512, 39077136, 39859796, 40651528, 41452360, 42262316, 43081432, 43909732, 44747252, 45594016, 46450052, 47315392, 48190064, 49074096, 49967516, 50870356, 51782636, 52704392, 53635648, 54576432, 55526772, 56486700, 57456236, 58435408, 59424248, 60422780, 61431036, 62449032, 63476804, 64514376, 65561776, 66619028, 67686160, 68763192, 69850160, 70947088, 72053992, 73170912, 74297864, 75434880, 76581976, 77739184, 78906536, 80084040, 81271736, 82469648, 83677792, 84896192, 86124888, 87363888, 88613232, 89872928, 91143016, 92423512, 93714432, 95015816, 96327688, 97650056, 98982952, 100326408, 101680440, 103045072, 104420320, 105806224, 107202800, 108610064, 110028048, 111456776, 112896264, 114346544, 115807632, 117279552, 118762328, 120255976, 121760536, 123276016, 124802440, 126339832, 127888216, 129447616, 131018048, 132599544, 134192112, 135795792, 137410592, 139036528, 140673648, 142321952, 143981456, 145652208, 147334208, 149027488, 150732064, 152447968, 154175200, 155913792, 157663776, 159425168, 161197984, 162982240, 164777968, 166585184, 168403904, 170234160, 172075968, 173929344, 175794320, 177670896, 179559120, 181458992, 183370528, 185293776, 187228736, 189175424, 191133888, 193104112, 195086128, 197079968, 199085648, 201103184, 203132592, 205173888, 207227120, 209292272, 211369392, 213458480, 215559568, 217672656, 219797792, 221934976, 224084240, 226245600, 228419056, 230604656, 232802400, 235012320, 237234432, 239468736, 241715280, 243974080, 246245120, 248528464, 250824112, 253132064, 255452368, 257785040, 260130080, 262487520, 264857376, 267239664, }; static stbir_uint8 stbir__linear_to_srgb_uchar(float f) { int x = (int) (f * (1 << 28)); // has headroom so you don't need to clamp int v = 0; int i; // Refine the guess with a short binary search. i = v + 128; if (x >= stbir__srgb_offset_to_linear_scaled[i]) v = i; i = v + 64; if (x >= stbir__srgb_offset_to_linear_scaled[i]) v = i; i = v + 32; if (x >= stbir__srgb_offset_to_linear_scaled[i]) v = i; i = v + 16; if (x >= stbir__srgb_offset_to_linear_scaled[i]) v = i; i = v + 8; if (x >= stbir__srgb_offset_to_linear_scaled[i]) v = i; i = v + 4; if (x >= stbir__srgb_offset_to_linear_scaled[i]) v = i; i = v + 2; if (x >= stbir__srgb_offset_to_linear_scaled[i]) v = i; i = v + 1; if (x >= stbir__srgb_offset_to_linear_scaled[i]) v = i; return (stbir_uint8) v; } #endif static float stbir__filter_trapezoid(float x, float scale) { float halfscale = scale / 2; float t = 0.5f + halfscale; STBIR_ASSERT(scale <= 1); x = (float)fabs(x); if (x >= t) return 0; else { float r = 0.5f - halfscale; if (x <= r) return 1; else return (t - x) / scale; } } static float stbir__support_trapezoid(float scale) { STBIR_ASSERT(scale <= 1); return 0.5f + scale / 2; } static float stbir__filter_triangle(float x, float s) { STBIR__UNUSED_PARAM(s); x = (float)fabs(x); if (x <= 1.0f) return 1 - x; else return 0; } static float stbir__filter_cubic(float x, float s) { STBIR__UNUSED_PARAM(s); x = (float)fabs(x); if (x < 1.0f) return (4 + x*x*(3*x - 6))/6; else if (x < 2.0f) return (8 + x*(-12 + x*(6 - x)))/6; return (0.0f); } static float stbir__filter_catmullrom(float x, float s) { STBIR__UNUSED_PARAM(s); x = (float)fabs(x); if (x < 1.0f) return 1 - x*x*(2.5f - 1.5f*x); else if (x < 2.0f) return 2 - x*(4 + x*(0.5f*x - 2.5f)); return (0.0f); } static float stbir__filter_mitchell(float x, float s) { STBIR__UNUSED_PARAM(s); x = (float)fabs(x); if (x < 1.0f) return (16 + x*x*(21 * x - 36))/18; else if (x < 2.0f) return (32 + x*(-60 + x*(36 - 7*x)))/18; return (0.0f); } static float stbir__support_zero(float s) { STBIR__UNUSED_PARAM(s); return 0; } static float stbir__support_one(float s) { STBIR__UNUSED_PARAM(s); return 1; } static float stbir__support_two(float s) { STBIR__UNUSED_PARAM(s); return 2; } static stbir__filter_info stbir__filter_info_table[] = { { NULL, stbir__support_zero }, { stbir__filter_trapezoid, stbir__support_trapezoid }, { stbir__filter_triangle, stbir__support_one }, { stbir__filter_cubic, stbir__support_two }, { stbir__filter_catmullrom, stbir__support_two }, { stbir__filter_mitchell, stbir__support_two }, }; stbir__inline static int stbir__use_upsampling(float ratio) { return ratio > 1; } stbir__inline static int stbir__use_width_upsampling(stbir__info* stbir_info) { return stbir__use_upsampling(stbir_info->horizontal_scale); } stbir__inline static int stbir__use_height_upsampling(stbir__info* stbir_info) { return stbir__use_upsampling(stbir_info->vertical_scale); } // This is the maximum number of input samples that can affect an output sample // with the given filter static int stbir__get_filter_pixel_width(stbir_filter filter, float scale) { STBIR_ASSERT(filter != 0); STBIR_ASSERT(filter < STBIR__ARRAY_SIZE(stbir__filter_info_table)); if (stbir__use_upsampling(scale)) return (int)ceil(stbir__filter_info_table[filter].support(1/scale) * 2); else return (int)ceil(stbir__filter_info_table[filter].support(scale) * 2 / scale); } // This is how much to expand buffers to account for filters seeking outside // the image boundaries. static int stbir__get_filter_pixel_margin(stbir_filter filter, float scale) { return stbir__get_filter_pixel_width(filter, scale) / 2; } static int stbir__get_coefficient_width(stbir_filter filter, float scale) { if (stbir__use_upsampling(scale)) return (int)ceil(stbir__filter_info_table[filter].support(1 / scale) * 2); else return (int)ceil(stbir__filter_info_table[filter].support(scale) * 2); } static int stbir__get_contributors(float scale, stbir_filter filter, int input_size, int output_size) { if (stbir__use_upsampling(scale)) return output_size; else return (input_size + stbir__get_filter_pixel_margin(filter, scale) * 2); } static int stbir__get_total_horizontal_coefficients(stbir__info* info) { return info->horizontal_num_contributors * stbir__get_coefficient_width (info->horizontal_filter, info->horizontal_scale); } static int stbir__get_total_vertical_coefficients(stbir__info* info) { return info->vertical_num_contributors * stbir__get_coefficient_width (info->vertical_filter, info->vertical_scale); } static stbir__contributors* stbir__get_contributor(stbir__contributors* contributors, int n) { return &contributors[n]; } // For perf reasons this code is duplicated in stbir__resample_horizontal_upsample/downsample, // if you change it here change it there too. static float* stbir__get_coefficient(float* coefficients, stbir_filter filter, float scale, int n, int c) { int width = stbir__get_coefficient_width(filter, scale); return &coefficients[width*n + c]; } static int stbir__edge_wrap_slow(stbir_edge edge, int n, int max) { switch (edge) { case STBIR_EDGE_ZERO: return 0; // we'll decode the wrong pixel here, and then overwrite with 0s later case STBIR_EDGE_CLAMP: if (n < 0) return 0; if (n >= max) return max - 1; return n; // NOTREACHED case STBIR_EDGE_REFLECT: { if (n < 0) { if (n < max) return -n; else return max - 1; } if (n >= max) { int max2 = max * 2; if (n >= max2) return 0; else return max2 - n - 1; } return n; // NOTREACHED } case STBIR_EDGE_WRAP: if (n >= 0) return (n % max); else { int m = (-n) % max; if (m != 0) m = max - m; return (m); } // NOTREACHED default: STBIR_ASSERT(!"Unimplemented edge type"); return 0; } } stbir__inline static int stbir__edge_wrap(stbir_edge edge, int n, int max) { // avoid per-pixel switch if (n >= 0 && n < max) return n; return stbir__edge_wrap_slow(edge, n, max); } // What input pixels contribute to this output pixel? static void stbir__calculate_sample_range_upsample(int n, float out_filter_radius, float scale_ratio, float out_shift, int* in_first_pixel, int* in_last_pixel, float* in_center_of_out) { float out_pixel_center = (float)n + 0.5f; float out_pixel_influence_lowerbound = out_pixel_center - out_filter_radius; float out_pixel_influence_upperbound = out_pixel_center + out_filter_radius; float in_pixel_influence_lowerbound = (out_pixel_influence_lowerbound + out_shift) / scale_ratio; float in_pixel_influence_upperbound = (out_pixel_influence_upperbound + out_shift) / scale_ratio; *in_center_of_out = (out_pixel_center + out_shift) / scale_ratio; *in_first_pixel = (int)(floor(in_pixel_influence_lowerbound + 0.5)); *in_last_pixel = (int)(floor(in_pixel_influence_upperbound - 0.5)); } // What output pixels does this input pixel contribute to? static void stbir__calculate_sample_range_downsample(int n, float in_pixels_radius, float scale_ratio, float out_shift, int* out_first_pixel, int* out_last_pixel, float* out_center_of_in) { float in_pixel_center = (float)n + 0.5f; float in_pixel_influence_lowerbound = in_pixel_center - in_pixels_radius; float in_pixel_influence_upperbound = in_pixel_center + in_pixels_radius; float out_pixel_influence_lowerbound = in_pixel_influence_lowerbound * scale_ratio - out_shift; float out_pixel_influence_upperbound = in_pixel_influence_upperbound * scale_ratio - out_shift; *out_center_of_in = in_pixel_center * scale_ratio - out_shift; *out_first_pixel = (int)(floor(out_pixel_influence_lowerbound + 0.5)); *out_last_pixel = (int)(floor(out_pixel_influence_upperbound - 0.5)); } static void stbir__calculate_coefficients_upsample(stbir_filter filter, float scale, int in_first_pixel, int in_last_pixel, float in_center_of_out, stbir__contributors* contributor, float* coefficient_group) { int i; float total_filter = 0; float filter_scale; STBIR_ASSERT(in_last_pixel - in_first_pixel <= (int)ceil(stbir__filter_info_table[filter].support(1/scale) * 2)); // Taken directly from stbir__get_coefficient_width() which we can't call because we don't know if we're horizontal or vertical. contributor->n0 = in_first_pixel; contributor->n1 = in_last_pixel; STBIR_ASSERT(contributor->n1 >= contributor->n0); for (i = 0; i <= in_last_pixel - in_first_pixel; i++) { float in_pixel_center = (float)(i + in_first_pixel) + 0.5f; coefficient_group[i] = stbir__filter_info_table[filter].kernel(in_center_of_out - in_pixel_center, 1 / scale); // If the coefficient is zero, skip it. (Don't do the <0 check here, we want the influence of those outside pixels.) if (i == 0 && !coefficient_group[i]) { contributor->n0 = ++in_first_pixel; i--; continue; } total_filter += coefficient_group[i]; } STBIR_ASSERT(stbir__filter_info_table[filter].kernel((float)(in_last_pixel + 1) + 0.5f - in_center_of_out, 1/scale) == 0); STBIR_ASSERT(total_filter > 0.9); STBIR_ASSERT(total_filter < 1.1f); // Make sure it's not way off. // Make sure the sum of all coefficients is 1. filter_scale = 1 / total_filter; for (i = 0; i <= in_last_pixel - in_first_pixel; i++) coefficient_group[i] *= filter_scale; for (i = in_last_pixel - in_first_pixel; i >= 0; i--) { if (coefficient_group[i]) break; // This line has no weight. We can skip it. contributor->n1 = contributor->n0 + i - 1; } } static void stbir__calculate_coefficients_downsample(stbir_filter filter, float scale_ratio, int out_first_pixel, int out_last_pixel, float out_center_of_in, stbir__contributors* contributor, float* coefficient_group) { int i; STBIR_ASSERT(out_last_pixel - out_first_pixel <= (int)ceil(stbir__filter_info_table[filter].support(scale_ratio) * 2)); // Taken directly from stbir__get_coefficient_width() which we can't call because we don't know if we're horizontal or vertical. contributor->n0 = out_first_pixel; contributor->n1 = out_last_pixel; STBIR_ASSERT(contributor->n1 >= contributor->n0); for (i = 0; i <= out_last_pixel - out_first_pixel; i++) { float out_pixel_center = (float)(i + out_first_pixel) + 0.5f; float x = out_pixel_center - out_center_of_in; coefficient_group[i] = stbir__filter_info_table[filter].kernel(x, scale_ratio) * scale_ratio; } STBIR_ASSERT(stbir__filter_info_table[filter].kernel((float)(out_last_pixel + 1) + 0.5f - out_center_of_in, scale_ratio) == 0); for (i = out_last_pixel - out_first_pixel; i >= 0; i--) { if (coefficient_group[i]) break; // This line has no weight. We can skip it. contributor->n1 = contributor->n0 + i - 1; } } static void stbir__normalize_downsample_coefficients(stbir__contributors* contributors, float* coefficients, stbir_filter filter, float scale_ratio, int input_size, int output_size) { int num_contributors = stbir__get_contributors(scale_ratio, filter, input_size, output_size); int num_coefficients = stbir__get_coefficient_width(filter, scale_ratio); int i, j; int skip; for (i = 0; i < output_size; i++) { float scale; float total = 0; for (j = 0; j < num_contributors; j++) { if (i >= contributors[j].n0 && i <= contributors[j].n1) { float coefficient = *stbir__get_coefficient(coefficients, filter, scale_ratio, j, i - contributors[j].n0); total += coefficient; } else if (i < contributors[j].n0) break; } STBIR_ASSERT(total > 0.9f); STBIR_ASSERT(total < 1.1f); scale = 1 / total; for (j = 0; j < num_contributors; j++) { if (i >= contributors[j].n0 && i <= contributors[j].n1) *stbir__get_coefficient(coefficients, filter, scale_ratio, j, i - contributors[j].n0) *= scale; else if (i < contributors[j].n0) break; } } // Optimize: Skip zero coefficients and contributions outside of image bounds. // Do this after normalizing because normalization depends on the n0/n1 values. for (j = 0; j < num_contributors; j++) { int range, max, width; skip = 0; while (*stbir__get_coefficient(coefficients, filter, scale_ratio, j, skip) == 0) skip++; contributors[j].n0 += skip; while (contributors[j].n0 < 0) { contributors[j].n0++; skip++; } range = contributors[j].n1 - contributors[j].n0 + 1; max = stbir__min(num_coefficients, range); width = stbir__get_coefficient_width(filter, scale_ratio); for (i = 0; i < max; i++) { if (i + skip >= width) break; *stbir__get_coefficient(coefficients, filter, scale_ratio, j, i) = *stbir__get_coefficient(coefficients, filter, scale_ratio, j, i + skip); } continue; } // Using min to avoid writing into invalid pixels. for (i = 0; i < num_contributors; i++) contributors[i].n1 = stbir__min(contributors[i].n1, output_size - 1); } // Each scan line uses the same kernel values so we should calculate the kernel // values once and then we can use them for every scan line. static void stbir__calculate_filters(stbir__contributors* contributors, float* coefficients, stbir_filter filter, float scale_ratio, float shift, int input_size, int output_size) { int n; int total_contributors = stbir__get_contributors(scale_ratio, filter, input_size, output_size); if (stbir__use_upsampling(scale_ratio)) { float out_pixels_radius = stbir__filter_info_table[filter].support(1 / scale_ratio) * scale_ratio; // Looping through out pixels for (n = 0; n < total_contributors; n++) { float in_center_of_out; // Center of the current out pixel in the in pixel space int in_first_pixel, in_last_pixel; stbir__calculate_sample_range_upsample(n, out_pixels_radius, scale_ratio, shift, &in_first_pixel, &in_last_pixel, &in_center_of_out); stbir__calculate_coefficients_upsample(filter, scale_ratio, in_first_pixel, in_last_pixel, in_center_of_out, stbir__get_contributor(contributors, n), stbir__get_coefficient(coefficients, filter, scale_ratio, n, 0)); } } else { float in_pixels_radius = stbir__filter_info_table[filter].support(scale_ratio) / scale_ratio; // Looping through in pixels for (n = 0; n < total_contributors; n++) { float out_center_of_in; // Center of the current out pixel in the in pixel space int out_first_pixel, out_last_pixel; int n_adjusted = n - stbir__get_filter_pixel_margin(filter, scale_ratio); stbir__calculate_sample_range_downsample(n_adjusted, in_pixels_radius, scale_ratio, shift, &out_first_pixel, &out_last_pixel, &out_center_of_in); stbir__calculate_coefficients_downsample(filter, scale_ratio, out_first_pixel, out_last_pixel, out_center_of_in, stbir__get_contributor(contributors, n), stbir__get_coefficient(coefficients, filter, scale_ratio, n, 0)); } stbir__normalize_downsample_coefficients(contributors, coefficients, filter, scale_ratio, input_size, output_size); } } static float* stbir__get_decode_buffer(stbir__info* stbir_info) { // The 0 index of the decode buffer starts after the margin. This makes // it okay to use negative indexes on the decode buffer. return &stbir_info->decode_buffer[stbir_info->horizontal_filter_pixel_margin * stbir_info->channels]; } #define STBIR__DECODE(type, colorspace) ((type) * (STBIR_MAX_COLORSPACES) + (colorspace)) static void stbir__decode_scanline(stbir__info* stbir_info, int n) { int c; int channels = stbir_info->channels; int alpha_channel = stbir_info->alpha_channel; int type = stbir_info->type; int colorspace = stbir_info->colorspace; int input_w = stbir_info->input_w; size_t input_stride_bytes = stbir_info->input_stride_bytes; float* decode_buffer = stbir__get_decode_buffer(stbir_info); stbir_edge edge_horizontal = stbir_info->edge_horizontal; stbir_edge edge_vertical = stbir_info->edge_vertical; size_t in_buffer_row_offset = stbir__edge_wrap(edge_vertical, n, stbir_info->input_h) * input_stride_bytes; const void* input_data = (char *) stbir_info->input_data + in_buffer_row_offset; int max_x = input_w + stbir_info->horizontal_filter_pixel_margin; int decode = STBIR__DECODE(type, colorspace); int x = -stbir_info->horizontal_filter_pixel_margin; // special handling for STBIR_EDGE_ZERO because it needs to return an item that doesn't appear in the input, // and we want to avoid paying overhead on every pixel if not STBIR_EDGE_ZERO if (edge_vertical == STBIR_EDGE_ZERO && (n < 0 || n >= stbir_info->input_h)) { for (; x < max_x; x++) for (c = 0; c < channels; c++) decode_buffer[x*channels + c] = 0; return; } switch (decode) { case STBIR__DECODE(STBIR_TYPE_UINT8, STBIR_COLORSPACE_LINEAR): for (; x < max_x; x++) { int decode_pixel_index = x * channels; int input_pixel_index = stbir__edge_wrap(edge_horizontal, x, input_w) * channels; for (c = 0; c < channels; c++) decode_buffer[decode_pixel_index + c] = ((float)((const unsigned char*)input_data)[input_pixel_index + c]) / stbir__max_uint8_as_float; } break; case STBIR__DECODE(STBIR_TYPE_UINT8, STBIR_COLORSPACE_SRGB): for (; x < max_x; x++) { int decode_pixel_index = x * channels; int input_pixel_index = stbir__edge_wrap(edge_horizontal, x, input_w) * channels; for (c = 0; c < channels; c++) decode_buffer[decode_pixel_index + c] = stbir__srgb_uchar_to_linear_float[((const unsigned char*)input_data)[input_pixel_index + c]]; if (!(stbir_info->flags&STBIR_FLAG_ALPHA_USES_COLORSPACE)) decode_buffer[decode_pixel_index + alpha_channel] = ((float)((const unsigned char*)input_data)[input_pixel_index + alpha_channel]) / stbir__max_uint8_as_float; } break; case STBIR__DECODE(STBIR_TYPE_UINT16, STBIR_COLORSPACE_LINEAR): for (; x < max_x; x++) { int decode_pixel_index = x * channels; int input_pixel_index = stbir__edge_wrap(edge_horizontal, x, input_w) * channels; for (c = 0; c < channels; c++) decode_buffer[decode_pixel_index + c] = ((float)((const unsigned short*)input_data)[input_pixel_index + c]) / stbir__max_uint16_as_float; } break; case STBIR__DECODE(STBIR_TYPE_UINT16, STBIR_COLORSPACE_SRGB): for (; x < max_x; x++) { int decode_pixel_index = x * channels; int input_pixel_index = stbir__edge_wrap(edge_horizontal, x, input_w) * channels; for (c = 0; c < channels; c++) decode_buffer[decode_pixel_index + c] = stbir__srgb_to_linear(((float)((const unsigned short*)input_data)[input_pixel_index + c]) / stbir__max_uint16_as_float); if (!(stbir_info->flags&STBIR_FLAG_ALPHA_USES_COLORSPACE)) decode_buffer[decode_pixel_index + alpha_channel] = ((float)((const unsigned short*)input_data)[input_pixel_index + alpha_channel]) / stbir__max_uint16_as_float; } break; case STBIR__DECODE(STBIR_TYPE_UINT32, STBIR_COLORSPACE_LINEAR): for (; x < max_x; x++) { int decode_pixel_index = x * channels; int input_pixel_index = stbir__edge_wrap(edge_horizontal, x, input_w) * channels; for (c = 0; c < channels; c++) decode_buffer[decode_pixel_index + c] = (float)(((double)((const unsigned int*)input_data)[input_pixel_index + c]) / stbir__max_uint32_as_float); } break; case STBIR__DECODE(STBIR_TYPE_UINT32, STBIR_COLORSPACE_SRGB): for (; x < max_x; x++) { int decode_pixel_index = x * channels; int input_pixel_index = stbir__edge_wrap(edge_horizontal, x, input_w) * channels; for (c = 0; c < channels; c++) decode_buffer[decode_pixel_index + c] = stbir__srgb_to_linear((float)(((double)((const unsigned int*)input_data)[input_pixel_index + c]) / stbir__max_uint32_as_float)); if (!(stbir_info->flags&STBIR_FLAG_ALPHA_USES_COLORSPACE)) decode_buffer[decode_pixel_index + alpha_channel] = (float)(((double)((const unsigned int*)input_data)[input_pixel_index + alpha_channel]) / stbir__max_uint32_as_float); } break; case STBIR__DECODE(STBIR_TYPE_FLOAT, STBIR_COLORSPACE_LINEAR): for (; x < max_x; x++) { int decode_pixel_index = x * channels; int input_pixel_index = stbir__edge_wrap(edge_horizontal, x, input_w) * channels; for (c = 0; c < channels; c++) decode_buffer[decode_pixel_index + c] = ((const float*)input_data)[input_pixel_index + c]; } break; case STBIR__DECODE(STBIR_TYPE_FLOAT, STBIR_COLORSPACE_SRGB): for (; x < max_x; x++) { int decode_pixel_index = x * channels; int input_pixel_index = stbir__edge_wrap(edge_horizontal, x, input_w) * channels; for (c = 0; c < channels; c++) decode_buffer[decode_pixel_index + c] = stbir__srgb_to_linear(((const float*)input_data)[input_pixel_index + c]); if (!(stbir_info->flags&STBIR_FLAG_ALPHA_USES_COLORSPACE)) decode_buffer[decode_pixel_index + alpha_channel] = ((const float*)input_data)[input_pixel_index + alpha_channel]; } break; default: STBIR_ASSERT(!"Unknown type/colorspace/channels combination."); break; } if (!(stbir_info->flags & STBIR_FLAG_ALPHA_PREMULTIPLIED)) { for (x = -stbir_info->horizontal_filter_pixel_margin; x < max_x; x++) { int decode_pixel_index = x * channels; // If the alpha value is 0 it will clobber the color values. Make sure it's not. float alpha = decode_buffer[decode_pixel_index + alpha_channel]; #ifndef STBIR_NO_ALPHA_EPSILON if (stbir_info->type != STBIR_TYPE_FLOAT) { alpha += STBIR_ALPHA_EPSILON; decode_buffer[decode_pixel_index + alpha_channel] = alpha; } #endif for (c = 0; c < channels; c++) { if (c == alpha_channel) continue; decode_buffer[decode_pixel_index + c] *= alpha; } } } if (edge_horizontal == STBIR_EDGE_ZERO) { for (x = -stbir_info->horizontal_filter_pixel_margin; x < 0; x++) { for (c = 0; c < channels; c++) decode_buffer[x*channels + c] = 0; } for (x = input_w; x < max_x; x++) { for (c = 0; c < channels; c++) decode_buffer[x*channels + c] = 0; } } } static float* stbir__get_ring_buffer_entry(float* ring_buffer, int index, int ring_buffer_length) { return &ring_buffer[index * ring_buffer_length]; } static float* stbir__add_empty_ring_buffer_entry(stbir__info* stbir_info, int n) { int ring_buffer_index; float* ring_buffer; stbir_info->ring_buffer_last_scanline = n; if (stbir_info->ring_buffer_begin_index < 0) { ring_buffer_index = stbir_info->ring_buffer_begin_index = 0; stbir_info->ring_buffer_first_scanline = n; } else { ring_buffer_index = (stbir_info->ring_buffer_begin_index + (stbir_info->ring_buffer_last_scanline - stbir_info->ring_buffer_first_scanline)) % stbir_info->ring_buffer_num_entries; STBIR_ASSERT(ring_buffer_index != stbir_info->ring_buffer_begin_index); } ring_buffer = stbir__get_ring_buffer_entry(stbir_info->ring_buffer, ring_buffer_index, stbir_info->ring_buffer_length_bytes / sizeof(float)); memset(ring_buffer, 0, stbir_info->ring_buffer_length_bytes); return ring_buffer; } static void stbir__resample_horizontal_upsample(stbir__info* stbir_info, float* output_buffer) { int x, k; int output_w = stbir_info->output_w; int channels = stbir_info->channels; float* decode_buffer = stbir__get_decode_buffer(stbir_info); stbir__contributors* horizontal_contributors = stbir_info->horizontal_contributors; float* horizontal_coefficients = stbir_info->horizontal_coefficients; int coefficient_width = stbir_info->horizontal_coefficient_width; for (x = 0; x < output_w; x++) { int n0 = horizontal_contributors[x].n0; int n1 = horizontal_contributors[x].n1; int out_pixel_index = x * channels; int coefficient_group = coefficient_width * x; int coefficient_counter = 0; STBIR_ASSERT(n1 >= n0); STBIR_ASSERT(n0 >= -stbir_info->horizontal_filter_pixel_margin); STBIR_ASSERT(n1 >= -stbir_info->horizontal_filter_pixel_margin); STBIR_ASSERT(n0 < stbir_info->input_w + stbir_info->horizontal_filter_pixel_margin); STBIR_ASSERT(n1 < stbir_info->input_w + stbir_info->horizontal_filter_pixel_margin); switch (channels) { case 1: for (k = n0; k <= n1; k++) { int in_pixel_index = k * 1; float coefficient = horizontal_coefficients[coefficient_group + coefficient_counter++]; STBIR_ASSERT(coefficient != 0); output_buffer[out_pixel_index + 0] += decode_buffer[in_pixel_index + 0] * coefficient; } break; case 2: for (k = n0; k <= n1; k++) { int in_pixel_index = k * 2; float coefficient = horizontal_coefficients[coefficient_group + coefficient_counter++]; STBIR_ASSERT(coefficient != 0); output_buffer[out_pixel_index + 0] += decode_buffer[in_pixel_index + 0] * coefficient; output_buffer[out_pixel_index + 1] += decode_buffer[in_pixel_index + 1] * coefficient; } break; case 3: for (k = n0; k <= n1; k++) { int in_pixel_index = k * 3; float coefficient = horizontal_coefficients[coefficient_group + coefficient_counter++]; STBIR_ASSERT(coefficient != 0); output_buffer[out_pixel_index + 0] += decode_buffer[in_pixel_index + 0] * coefficient; output_buffer[out_pixel_index + 1] += decode_buffer[in_pixel_index + 1] * coefficient; output_buffer[out_pixel_index + 2] += decode_buffer[in_pixel_index + 2] * coefficient; } break; case 4: for (k = n0; k <= n1; k++) { int in_pixel_index = k * 4; float coefficient = horizontal_coefficients[coefficient_group + coefficient_counter++]; STBIR_ASSERT(coefficient != 0); output_buffer[out_pixel_index + 0] += decode_buffer[in_pixel_index + 0] * coefficient; output_buffer[out_pixel_index + 1] += decode_buffer[in_pixel_index + 1] * coefficient; output_buffer[out_pixel_index + 2] += decode_buffer[in_pixel_index + 2] * coefficient; output_buffer[out_pixel_index + 3] += decode_buffer[in_pixel_index + 3] * coefficient; } break; default: for (k = n0; k <= n1; k++) { int in_pixel_index = k * channels; float coefficient = horizontal_coefficients[coefficient_group + coefficient_counter++]; int c; STBIR_ASSERT(coefficient != 0); for (c = 0; c < channels; c++) output_buffer[out_pixel_index + c] += decode_buffer[in_pixel_index + c] * coefficient; } break; } } } static void stbir__resample_horizontal_downsample(stbir__info* stbir_info, float* output_buffer) { int x, k; int input_w = stbir_info->input_w; int channels = stbir_info->channels; float* decode_buffer = stbir__get_decode_buffer(stbir_info); stbir__contributors* horizontal_contributors = stbir_info->horizontal_contributors; float* horizontal_coefficients = stbir_info->horizontal_coefficients; int coefficient_width = stbir_info->horizontal_coefficient_width; int filter_pixel_margin = stbir_info->horizontal_filter_pixel_margin; int max_x = input_w + filter_pixel_margin * 2; STBIR_ASSERT(!stbir__use_width_upsampling(stbir_info)); switch (channels) { case 1: for (x = 0; x < max_x; x++) { int n0 = horizontal_contributors[x].n0; int n1 = horizontal_contributors[x].n1; int in_x = x - filter_pixel_margin; int in_pixel_index = in_x * 1; int max_n = n1; int coefficient_group = coefficient_width * x; for (k = n0; k <= max_n; k++) { int out_pixel_index = k * 1; float coefficient = horizontal_coefficients[coefficient_group + k - n0]; STBIR_ASSERT(coefficient != 0); output_buffer[out_pixel_index + 0] += decode_buffer[in_pixel_index + 0] * coefficient; } } break; case 2: for (x = 0; x < max_x; x++) { int n0 = horizontal_contributors[x].n0; int n1 = horizontal_contributors[x].n1; int in_x = x - filter_pixel_margin; int in_pixel_index = in_x * 2; int max_n = n1; int coefficient_group = coefficient_width * x; for (k = n0; k <= max_n; k++) { int out_pixel_index = k * 2; float coefficient = horizontal_coefficients[coefficient_group + k - n0]; STBIR_ASSERT(coefficient != 0); output_buffer[out_pixel_index + 0] += decode_buffer[in_pixel_index + 0] * coefficient; output_buffer[out_pixel_index + 1] += decode_buffer[in_pixel_index + 1] * coefficient; } } break; case 3: for (x = 0; x < max_x; x++) { int n0 = horizontal_contributors[x].n0; int n1 = horizontal_contributors[x].n1; int in_x = x - filter_pixel_margin; int in_pixel_index = in_x * 3; int max_n = n1; int coefficient_group = coefficient_width * x; for (k = n0; k <= max_n; k++) { int out_pixel_index = k * 3; float coefficient = horizontal_coefficients[coefficient_group + k - n0]; STBIR_ASSERT(coefficient != 0); output_buffer[out_pixel_index + 0] += decode_buffer[in_pixel_index + 0] * coefficient; output_buffer[out_pixel_index + 1] += decode_buffer[in_pixel_index + 1] * coefficient; output_buffer[out_pixel_index + 2] += decode_buffer[in_pixel_index + 2] * coefficient; } } break; case 4: for (x = 0; x < max_x; x++) { int n0 = horizontal_contributors[x].n0; int n1 = horizontal_contributors[x].n1; int in_x = x - filter_pixel_margin; int in_pixel_index = in_x * 4; int max_n = n1; int coefficient_group = coefficient_width * x; for (k = n0; k <= max_n; k++) { int out_pixel_index = k * 4; float coefficient = horizontal_coefficients[coefficient_group + k - n0]; STBIR_ASSERT(coefficient != 0); output_buffer[out_pixel_index + 0] += decode_buffer[in_pixel_index + 0] * coefficient; output_buffer[out_pixel_index + 1] += decode_buffer[in_pixel_index + 1] * coefficient; output_buffer[out_pixel_index + 2] += decode_buffer[in_pixel_index + 2] * coefficient; output_buffer[out_pixel_index + 3] += decode_buffer[in_pixel_index + 3] * coefficient; } } break; default: for (x = 0; x < max_x; x++) { int n0 = horizontal_contributors[x].n0; int n1 = horizontal_contributors[x].n1; int in_x = x - filter_pixel_margin; int in_pixel_index = in_x * channels; int max_n = n1; int coefficient_group = coefficient_width * x; for (k = n0; k <= max_n; k++) { int c; int out_pixel_index = k * channels; float coefficient = horizontal_coefficients[coefficient_group + k - n0]; STBIR_ASSERT(coefficient != 0); for (c = 0; c < channels; c++) output_buffer[out_pixel_index + c] += decode_buffer[in_pixel_index + c] * coefficient; } } break; } } static void stbir__decode_and_resample_upsample(stbir__info* stbir_info, int n) { // Decode the nth scanline from the source image into the decode buffer. stbir__decode_scanline(stbir_info, n); // Now resample it into the ring buffer. if (stbir__use_width_upsampling(stbir_info)) stbir__resample_horizontal_upsample(stbir_info, stbir__add_empty_ring_buffer_entry(stbir_info, n)); else stbir__resample_horizontal_downsample(stbir_info, stbir__add_empty_ring_buffer_entry(stbir_info, n)); // Now it's sitting in the ring buffer ready to be used as source for the vertical sampling. } static void stbir__decode_and_resample_downsample(stbir__info* stbir_info, int n) { // Decode the nth scanline from the source image into the decode buffer. stbir__decode_scanline(stbir_info, n); memset(stbir_info->horizontal_buffer, 0, stbir_info->output_w * stbir_info->channels * sizeof(float)); // Now resample it into the horizontal buffer. if (stbir__use_width_upsampling(stbir_info)) stbir__resample_horizontal_upsample(stbir_info, stbir_info->horizontal_buffer); else stbir__resample_horizontal_downsample(stbir_info, stbir_info->horizontal_buffer); // Now it's sitting in the horizontal buffer ready to be distributed into the ring buffers. } // Get the specified scan line from the ring buffer. static float* stbir__get_ring_buffer_scanline(int get_scanline, float* ring_buffer, int begin_index, int first_scanline, int ring_buffer_num_entries, int ring_buffer_length) { int ring_buffer_index = (begin_index + (get_scanline - first_scanline)) % ring_buffer_num_entries; return stbir__get_ring_buffer_entry(ring_buffer, ring_buffer_index, ring_buffer_length); } static void stbir__encode_scanline(stbir__info* stbir_info, int num_pixels, void *output_buffer, float *encode_buffer, int channels, int alpha_channel, int decode) { int x; int n; int num_nonalpha; stbir_uint16 nonalpha[STBIR_MAX_CHANNELS]; if (!(stbir_info->flags&STBIR_FLAG_ALPHA_PREMULTIPLIED)) { for (x=0; x < num_pixels; ++x) { int pixel_index = x*channels; float alpha = encode_buffer[pixel_index + alpha_channel]; float reciprocal_alpha = alpha ? 1.0f / alpha : 0; // unrolling this produced a 1% slowdown upscaling a large RGBA linear-space image on my machine - stb for (n = 0; n < channels; n++) if (n != alpha_channel) encode_buffer[pixel_index + n] *= reciprocal_alpha; // We added in a small epsilon to prevent the color channel from being deleted with zero alpha. // Because we only add it for integer types, it will automatically be discarded on integer // conversion, so we don't need to subtract it back out (which would be problematic for // numeric precision reasons). } } // build a table of all channels that need colorspace correction, so // we don't perform colorspace correction on channels that don't need it. for (x = 0, num_nonalpha = 0; x < channels; ++x) { if (x != alpha_channel || (stbir_info->flags & STBIR_FLAG_ALPHA_USES_COLORSPACE)) { nonalpha[num_nonalpha++] = (stbir_uint16)x; } } #define STBIR__ROUND_INT(f) ((int) ((f)+0.5)) #define STBIR__ROUND_UINT(f) ((stbir_uint32) ((f)+0.5)) #ifdef STBIR__SATURATE_INT #define STBIR__ENCODE_LINEAR8(f) stbir__saturate8 (STBIR__ROUND_INT((f) * stbir__max_uint8_as_float )) #define STBIR__ENCODE_LINEAR16(f) stbir__saturate16(STBIR__ROUND_INT((f) * stbir__max_uint16_as_float)) #else #define STBIR__ENCODE_LINEAR8(f) (unsigned char ) STBIR__ROUND_INT(stbir__saturate(f) * stbir__max_uint8_as_float ) #define STBIR__ENCODE_LINEAR16(f) (unsigned short) STBIR__ROUND_INT(stbir__saturate(f) * stbir__max_uint16_as_float) #endif switch (decode) { case STBIR__DECODE(STBIR_TYPE_UINT8, STBIR_COLORSPACE_LINEAR): for (x=0; x < num_pixels; ++x) { int pixel_index = x*channels; for (n = 0; n < channels; n++) { int index = pixel_index + n; ((unsigned char*)output_buffer)[index] = STBIR__ENCODE_LINEAR8(encode_buffer[index]); } } break; case STBIR__DECODE(STBIR_TYPE_UINT8, STBIR_COLORSPACE_SRGB): for (x=0; x < num_pixels; ++x) { int pixel_index = x*channels; for (n = 0; n < num_nonalpha; n++) { int index = pixel_index + nonalpha[n]; ((unsigned char*)output_buffer)[index] = stbir__linear_to_srgb_uchar(encode_buffer[index]); } if (!(stbir_info->flags & STBIR_FLAG_ALPHA_USES_COLORSPACE)) ((unsigned char *)output_buffer)[pixel_index + alpha_channel] = STBIR__ENCODE_LINEAR8(encode_buffer[pixel_index+alpha_channel]); } break; case STBIR__DECODE(STBIR_TYPE_UINT16, STBIR_COLORSPACE_LINEAR): for (x=0; x < num_pixels; ++x) { int pixel_index = x*channels; for (n = 0; n < channels; n++) { int index = pixel_index + n; ((unsigned short*)output_buffer)[index] = STBIR__ENCODE_LINEAR16(encode_buffer[index]); } } break; case STBIR__DECODE(STBIR_TYPE_UINT16, STBIR_COLORSPACE_SRGB): for (x=0; x < num_pixels; ++x) { int pixel_index = x*channels; for (n = 0; n < num_nonalpha; n++) { int index = pixel_index + nonalpha[n]; ((unsigned short*)output_buffer)[index] = (unsigned short)STBIR__ROUND_INT(stbir__linear_to_srgb(stbir__saturate(encode_buffer[index])) * stbir__max_uint16_as_float); } if (!(stbir_info->flags&STBIR_FLAG_ALPHA_USES_COLORSPACE)) ((unsigned short*)output_buffer)[pixel_index + alpha_channel] = STBIR__ENCODE_LINEAR16(encode_buffer[pixel_index + alpha_channel]); } break; case STBIR__DECODE(STBIR_TYPE_UINT32, STBIR_COLORSPACE_LINEAR): for (x=0; x < num_pixels; ++x) { int pixel_index = x*channels; for (n = 0; n < channels; n++) { int index = pixel_index + n; ((unsigned int*)output_buffer)[index] = (unsigned int)STBIR__ROUND_UINT(((double)stbir__saturate(encode_buffer[index])) * stbir__max_uint32_as_float); } } break; case STBIR__DECODE(STBIR_TYPE_UINT32, STBIR_COLORSPACE_SRGB): for (x=0; x < num_pixels; ++x) { int pixel_index = x*channels; for (n = 0; n < num_nonalpha; n++) { int index = pixel_index + nonalpha[n]; ((unsigned int*)output_buffer)[index] = (unsigned int)STBIR__ROUND_UINT(((double)stbir__linear_to_srgb(stbir__saturate(encode_buffer[index]))) * stbir__max_uint32_as_float); } if (!(stbir_info->flags&STBIR_FLAG_ALPHA_USES_COLORSPACE)) ((unsigned int*)output_buffer)[pixel_index + alpha_channel] = (unsigned int)STBIR__ROUND_INT(((double)stbir__saturate(encode_buffer[pixel_index + alpha_channel])) * stbir__max_uint32_as_float); } break; case STBIR__DECODE(STBIR_TYPE_FLOAT, STBIR_COLORSPACE_LINEAR): for (x=0; x < num_pixels; ++x) { int pixel_index = x*channels; for (n = 0; n < channels; n++) { int index = pixel_index + n; ((float*)output_buffer)[index] = encode_buffer[index]; } } break; case STBIR__DECODE(STBIR_TYPE_FLOAT, STBIR_COLORSPACE_SRGB): for (x=0; x < num_pixels; ++x) { int pixel_index = x*channels; for (n = 0; n < num_nonalpha; n++) { int index = pixel_index + nonalpha[n]; ((float*)output_buffer)[index] = stbir__linear_to_srgb(encode_buffer[index]); } if (!(stbir_info->flags&STBIR_FLAG_ALPHA_USES_COLORSPACE)) ((float*)output_buffer)[pixel_index + alpha_channel] = encode_buffer[pixel_index + alpha_channel]; } break; default: STBIR_ASSERT(!"Unknown type/colorspace/channels combination."); break; } } static void stbir__resample_vertical_upsample(stbir__info* stbir_info, int n) { int x, k; int output_w = stbir_info->output_w; stbir__contributors* vertical_contributors = stbir_info->vertical_contributors; float* vertical_coefficients = stbir_info->vertical_coefficients; int channels = stbir_info->channels; int alpha_channel = stbir_info->alpha_channel; int type = stbir_info->type; int colorspace = stbir_info->colorspace; int ring_buffer_entries = stbir_info->ring_buffer_num_entries; void* output_data = stbir_info->output_data; float* encode_buffer = stbir_info->encode_buffer; int decode = STBIR__DECODE(type, colorspace); int coefficient_width = stbir_info->vertical_coefficient_width; int coefficient_counter; int contributor = n; float* ring_buffer = stbir_info->ring_buffer; int ring_buffer_begin_index = stbir_info->ring_buffer_begin_index; int ring_buffer_first_scanline = stbir_info->ring_buffer_first_scanline; int ring_buffer_length = stbir_info->ring_buffer_length_bytes/sizeof(float); int n0,n1, output_row_start; int coefficient_group = coefficient_width * contributor; n0 = vertical_contributors[contributor].n0; n1 = vertical_contributors[contributor].n1; output_row_start = n * stbir_info->output_stride_bytes; STBIR_ASSERT(stbir__use_height_upsampling(stbir_info)); memset(encode_buffer, 0, output_w * sizeof(float) * channels); // I tried reblocking this for better cache usage of encode_buffer // (using x_outer, k, x_inner), but it lost speed. -- stb coefficient_counter = 0; switch (channels) { case 1: for (k = n0; k <= n1; k++) { int coefficient_index = coefficient_counter++; float* ring_buffer_entry = stbir__get_ring_buffer_scanline(k, ring_buffer, ring_buffer_begin_index, ring_buffer_first_scanline, ring_buffer_entries, ring_buffer_length); float coefficient = vertical_coefficients[coefficient_group + coefficient_index]; for (x = 0; x < output_w; ++x) { int in_pixel_index = x * 1; encode_buffer[in_pixel_index + 0] += ring_buffer_entry[in_pixel_index + 0] * coefficient; } } break; case 2: for (k = n0; k <= n1; k++) { int coefficient_index = coefficient_counter++; float* ring_buffer_entry = stbir__get_ring_buffer_scanline(k, ring_buffer, ring_buffer_begin_index, ring_buffer_first_scanline, ring_buffer_entries, ring_buffer_length); float coefficient = vertical_coefficients[coefficient_group + coefficient_index]; for (x = 0; x < output_w; ++x) { int in_pixel_index = x * 2; encode_buffer[in_pixel_index + 0] += ring_buffer_entry[in_pixel_index + 0] * coefficient; encode_buffer[in_pixel_index + 1] += ring_buffer_entry[in_pixel_index + 1] * coefficient; } } break; case 3: for (k = n0; k <= n1; k++) { int coefficient_index = coefficient_counter++; float* ring_buffer_entry = stbir__get_ring_buffer_scanline(k, ring_buffer, ring_buffer_begin_index, ring_buffer_first_scanline, ring_buffer_entries, ring_buffer_length); float coefficient = vertical_coefficients[coefficient_group + coefficient_index]; for (x = 0; x < output_w; ++x) { int in_pixel_index = x * 3; encode_buffer[in_pixel_index + 0] += ring_buffer_entry[in_pixel_index + 0] * coefficient; encode_buffer[in_pixel_index + 1] += ring_buffer_entry[in_pixel_index + 1] * coefficient; encode_buffer[in_pixel_index + 2] += ring_buffer_entry[in_pixel_index + 2] * coefficient; } } break; case 4: for (k = n0; k <= n1; k++) { int coefficient_index = coefficient_counter++; float* ring_buffer_entry = stbir__get_ring_buffer_scanline(k, ring_buffer, ring_buffer_begin_index, ring_buffer_first_scanline, ring_buffer_entries, ring_buffer_length); float coefficient = vertical_coefficients[coefficient_group + coefficient_index]; for (x = 0; x < output_w; ++x) { int in_pixel_index = x * 4; encode_buffer[in_pixel_index + 0] += ring_buffer_entry[in_pixel_index + 0] * coefficient; encode_buffer[in_pixel_index + 1] += ring_buffer_entry[in_pixel_index + 1] * coefficient; encode_buffer[in_pixel_index + 2] += ring_buffer_entry[in_pixel_index + 2] * coefficient; encode_buffer[in_pixel_index + 3] += ring_buffer_entry[in_pixel_index + 3] * coefficient; } } break; default: for (k = n0; k <= n1; k++) { int coefficient_index = coefficient_counter++; float* ring_buffer_entry = stbir__get_ring_buffer_scanline(k, ring_buffer, ring_buffer_begin_index, ring_buffer_first_scanline, ring_buffer_entries, ring_buffer_length); float coefficient = vertical_coefficients[coefficient_group + coefficient_index]; for (x = 0; x < output_w; ++x) { int in_pixel_index = x * channels; int c; for (c = 0; c < channels; c++) encode_buffer[in_pixel_index + c] += ring_buffer_entry[in_pixel_index + c] * coefficient; } } break; } stbir__encode_scanline(stbir_info, output_w, (char *) output_data + output_row_start, encode_buffer, channels, alpha_channel, decode); } static void stbir__resample_vertical_downsample(stbir__info* stbir_info, int n) { int x, k; int output_w = stbir_info->output_w; stbir__contributors* vertical_contributors = stbir_info->vertical_contributors; float* vertical_coefficients = stbir_info->vertical_coefficients; int channels = stbir_info->channels; int ring_buffer_entries = stbir_info->ring_buffer_num_entries; float* horizontal_buffer = stbir_info->horizontal_buffer; int coefficient_width = stbir_info->vertical_coefficient_width; int contributor = n + stbir_info->vertical_filter_pixel_margin; float* ring_buffer = stbir_info->ring_buffer; int ring_buffer_begin_index = stbir_info->ring_buffer_begin_index; int ring_buffer_first_scanline = stbir_info->ring_buffer_first_scanline; int ring_buffer_length = stbir_info->ring_buffer_length_bytes/sizeof(float); int n0,n1; n0 = vertical_contributors[contributor].n0; n1 = vertical_contributors[contributor].n1; STBIR_ASSERT(!stbir__use_height_upsampling(stbir_info)); for (k = n0; k <= n1; k++) { int coefficient_index = k - n0; int coefficient_group = coefficient_width * contributor; float coefficient = vertical_coefficients[coefficient_group + coefficient_index]; float* ring_buffer_entry = stbir__get_ring_buffer_scanline(k, ring_buffer, ring_buffer_begin_index, ring_buffer_first_scanline, ring_buffer_entries, ring_buffer_length); switch (channels) { case 1: for (x = 0; x < output_w; x++) { int in_pixel_index = x * 1; ring_buffer_entry[in_pixel_index + 0] += horizontal_buffer[in_pixel_index + 0] * coefficient; } break; case 2: for (x = 0; x < output_w; x++) { int in_pixel_index = x * 2; ring_buffer_entry[in_pixel_index + 0] += horizontal_buffer[in_pixel_index + 0] * coefficient; ring_buffer_entry[in_pixel_index + 1] += horizontal_buffer[in_pixel_index + 1] * coefficient; } break; case 3: for (x = 0; x < output_w; x++) { int in_pixel_index = x * 3; ring_buffer_entry[in_pixel_index + 0] += horizontal_buffer[in_pixel_index + 0] * coefficient; ring_buffer_entry[in_pixel_index + 1] += horizontal_buffer[in_pixel_index + 1] * coefficient; ring_buffer_entry[in_pixel_index + 2] += horizontal_buffer[in_pixel_index + 2] * coefficient; } break; case 4: for (x = 0; x < output_w; x++) { int in_pixel_index = x * 4; ring_buffer_entry[in_pixel_index + 0] += horizontal_buffer[in_pixel_index + 0] * coefficient; ring_buffer_entry[in_pixel_index + 1] += horizontal_buffer[in_pixel_index + 1] * coefficient; ring_buffer_entry[in_pixel_index + 2] += horizontal_buffer[in_pixel_index + 2] * coefficient; ring_buffer_entry[in_pixel_index + 3] += horizontal_buffer[in_pixel_index + 3] * coefficient; } break; default: for (x = 0; x < output_w; x++) { int in_pixel_index = x * channels; int c; for (c = 0; c < channels; c++) ring_buffer_entry[in_pixel_index + c] += horizontal_buffer[in_pixel_index + c] * coefficient; } break; } } } static void stbir__buffer_loop_upsample(stbir__info* stbir_info) { int y; float scale_ratio = stbir_info->vertical_scale; float out_scanlines_radius = stbir__filter_info_table[stbir_info->vertical_filter].support(1/scale_ratio) * scale_ratio; STBIR_ASSERT(stbir__use_height_upsampling(stbir_info)); for (y = 0; y < stbir_info->output_h; y++) { float in_center_of_out = 0; // Center of the current out scanline in the in scanline space int in_first_scanline = 0, in_last_scanline = 0; stbir__calculate_sample_range_upsample(y, out_scanlines_radius, scale_ratio, stbir_info->vertical_shift, &in_first_scanline, &in_last_scanline, &in_center_of_out); STBIR_ASSERT(in_last_scanline - in_first_scanline + 1 <= stbir_info->ring_buffer_num_entries); if (stbir_info->ring_buffer_begin_index >= 0) { // Get rid of whatever we don't need anymore. while (in_first_scanline > stbir_info->ring_buffer_first_scanline) { if (stbir_info->ring_buffer_first_scanline == stbir_info->ring_buffer_last_scanline) { // We just popped the last scanline off the ring buffer. // Reset it to the empty state. stbir_info->ring_buffer_begin_index = -1; stbir_info->ring_buffer_first_scanline = 0; stbir_info->ring_buffer_last_scanline = 0; break; } else { stbir_info->ring_buffer_first_scanline++; stbir_info->ring_buffer_begin_index = (stbir_info->ring_buffer_begin_index + 1) % stbir_info->ring_buffer_num_entries; } } } // Load in new ones. if (stbir_info->ring_buffer_begin_index < 0) stbir__decode_and_resample_upsample(stbir_info, in_first_scanline); while (in_last_scanline > stbir_info->ring_buffer_last_scanline) stbir__decode_and_resample_upsample(stbir_info, stbir_info->ring_buffer_last_scanline + 1); // Now all buffers should be ready to write a row of vertical sampling. stbir__resample_vertical_upsample(stbir_info, y); STBIR_PROGRESS_REPORT((float)y / stbir_info->output_h); } } static void stbir__empty_ring_buffer(stbir__info* stbir_info, int first_necessary_scanline) { int output_stride_bytes = stbir_info->output_stride_bytes; int channels = stbir_info->channels; int alpha_channel = stbir_info->alpha_channel; int type = stbir_info->type; int colorspace = stbir_info->colorspace; int output_w = stbir_info->output_w; void* output_data = stbir_info->output_data; int decode = STBIR__DECODE(type, colorspace); float* ring_buffer = stbir_info->ring_buffer; int ring_buffer_length = stbir_info->ring_buffer_length_bytes/sizeof(float); if (stbir_info->ring_buffer_begin_index >= 0) { // Get rid of whatever we don't need anymore. while (first_necessary_scanline > stbir_info->ring_buffer_first_scanline) { if (stbir_info->ring_buffer_first_scanline >= 0 && stbir_info->ring_buffer_first_scanline < stbir_info->output_h) { int output_row_start = stbir_info->ring_buffer_first_scanline * output_stride_bytes; float* ring_buffer_entry = stbir__get_ring_buffer_entry(ring_buffer, stbir_info->ring_buffer_begin_index, ring_buffer_length); stbir__encode_scanline(stbir_info, output_w, (char *) output_data + output_row_start, ring_buffer_entry, channels, alpha_channel, decode); STBIR_PROGRESS_REPORT((float)stbir_info->ring_buffer_first_scanline / stbir_info->output_h); } if (stbir_info->ring_buffer_first_scanline == stbir_info->ring_buffer_last_scanline) { // We just popped the last scanline off the ring buffer. // Reset it to the empty state. stbir_info->ring_buffer_begin_index = -1; stbir_info->ring_buffer_first_scanline = 0; stbir_info->ring_buffer_last_scanline = 0; break; } else { stbir_info->ring_buffer_first_scanline++; stbir_info->ring_buffer_begin_index = (stbir_info->ring_buffer_begin_index + 1) % stbir_info->ring_buffer_num_entries; } } } } static void stbir__buffer_loop_downsample(stbir__info* stbir_info) { int y; float scale_ratio = stbir_info->vertical_scale; int output_h = stbir_info->output_h; float in_pixels_radius = stbir__filter_info_table[stbir_info->vertical_filter].support(scale_ratio) / scale_ratio; int pixel_margin = stbir_info->vertical_filter_pixel_margin; int max_y = stbir_info->input_h + pixel_margin; STBIR_ASSERT(!stbir__use_height_upsampling(stbir_info)); for (y = -pixel_margin; y < max_y; y++) { float out_center_of_in; // Center of the current out scanline in the in scanline space int out_first_scanline, out_last_scanline; stbir__calculate_sample_range_downsample(y, in_pixels_radius, scale_ratio, stbir_info->vertical_shift, &out_first_scanline, &out_last_scanline, &out_center_of_in); STBIR_ASSERT(out_last_scanline - out_first_scanline + 1 <= stbir_info->ring_buffer_num_entries); if (out_last_scanline < 0 || out_first_scanline >= output_h) continue; stbir__empty_ring_buffer(stbir_info, out_first_scanline); stbir__decode_and_resample_downsample(stbir_info, y); // Load in new ones. if (stbir_info->ring_buffer_begin_index < 0) stbir__add_empty_ring_buffer_entry(stbir_info, out_first_scanline); while (out_last_scanline > stbir_info->ring_buffer_last_scanline) stbir__add_empty_ring_buffer_entry(stbir_info, stbir_info->ring_buffer_last_scanline + 1); // Now the horizontal buffer is ready to write to all ring buffer rows. stbir__resample_vertical_downsample(stbir_info, y); } stbir__empty_ring_buffer(stbir_info, stbir_info->output_h); } static void stbir__setup(stbir__info *info, int input_w, int input_h, int output_w, int output_h, int channels) { info->input_w = input_w; info->input_h = input_h; info->output_w = output_w; info->output_h = output_h; info->channels = channels; } static void stbir__calculate_transform(stbir__info *info, float s0, float t0, float s1, float t1, float *transform) { info->s0 = s0; info->t0 = t0; info->s1 = s1; info->t1 = t1; if (transform) { info->horizontal_scale = transform[0]; info->vertical_scale = transform[1]; info->horizontal_shift = transform[2]; info->vertical_shift = transform[3]; } else { info->horizontal_scale = ((float)info->output_w / info->input_w) / (s1 - s0); info->vertical_scale = ((float)info->output_h / info->input_h) / (t1 - t0); info->horizontal_shift = s0 * info->output_w / (s1 - s0); info->vertical_shift = t0 * info->output_h / (t1 - t0); } } static void stbir__choose_filter(stbir__info *info, stbir_filter h_filter, stbir_filter v_filter) { if (h_filter == 0) h_filter = stbir__use_upsampling(info->horizontal_scale) ? STBIR_DEFAULT_FILTER_UPSAMPLE : STBIR_DEFAULT_FILTER_DOWNSAMPLE; if (v_filter == 0) v_filter = stbir__use_upsampling(info->vertical_scale) ? STBIR_DEFAULT_FILTER_UPSAMPLE : STBIR_DEFAULT_FILTER_DOWNSAMPLE; info->horizontal_filter = h_filter; info->vertical_filter = v_filter; } static stbir_uint32 stbir__calculate_memory(stbir__info *info) { int pixel_margin = stbir__get_filter_pixel_margin(info->horizontal_filter, info->horizontal_scale); int filter_height = stbir__get_filter_pixel_width(info->vertical_filter, info->vertical_scale); info->horizontal_num_contributors = stbir__get_contributors(info->horizontal_scale, info->horizontal_filter, info->input_w, info->output_w); info->vertical_num_contributors = stbir__get_contributors(info->vertical_scale , info->vertical_filter , info->input_h, info->output_h); // One extra entry because floating point precision problems sometimes cause an extra to be necessary. info->ring_buffer_num_entries = filter_height + 1; info->horizontal_contributors_size = info->horizontal_num_contributors * sizeof(stbir__contributors); info->horizontal_coefficients_size = stbir__get_total_horizontal_coefficients(info) * sizeof(float); info->vertical_contributors_size = info->vertical_num_contributors * sizeof(stbir__contributors); info->vertical_coefficients_size = stbir__get_total_vertical_coefficients(info) * sizeof(float); info->decode_buffer_size = (info->input_w + pixel_margin * 2) * info->channels * sizeof(float); info->horizontal_buffer_size = info->output_w * info->channels * sizeof(float); info->ring_buffer_size = info->output_w * info->channels * info->ring_buffer_num_entries * sizeof(float); info->encode_buffer_size = info->output_w * info->channels * sizeof(float); STBIR_ASSERT(info->horizontal_filter != 0); STBIR_ASSERT(info->horizontal_filter < STBIR__ARRAY_SIZE(stbir__filter_info_table)); // this now happens too late STBIR_ASSERT(info->vertical_filter != 0); STBIR_ASSERT(info->vertical_filter < STBIR__ARRAY_SIZE(stbir__filter_info_table)); // this now happens too late if (stbir__use_height_upsampling(info)) // The horizontal buffer is for when we're downsampling the height and we // can't output the result of sampling the decode buffer directly into the // ring buffers. info->horizontal_buffer_size = 0; else // The encode buffer is to retain precision in the height upsampling method // and isn't used when height downsampling. info->encode_buffer_size = 0; return info->horizontal_contributors_size + info->horizontal_coefficients_size + info->vertical_contributors_size + info->vertical_coefficients_size + info->decode_buffer_size + info->horizontal_buffer_size + info->ring_buffer_size + info->encode_buffer_size; } static int stbir__resize_allocated(stbir__info *info, const void* input_data, int input_stride_in_bytes, void* output_data, int output_stride_in_bytes, int alpha_channel, stbir_uint32 flags, stbir_datatype type, stbir_edge edge_horizontal, stbir_edge edge_vertical, stbir_colorspace colorspace, void* tempmem, size_t tempmem_size_in_bytes) { size_t memory_required = stbir__calculate_memory(info); int width_stride_input = input_stride_in_bytes ? input_stride_in_bytes : info->channels * info->input_w * stbir__type_size[type]; int width_stride_output = output_stride_in_bytes ? output_stride_in_bytes : info->channels * info->output_w * stbir__type_size[type]; #ifdef STBIR_DEBUG_OVERWRITE_TEST #define OVERWRITE_ARRAY_SIZE 8 unsigned char overwrite_output_before_pre[OVERWRITE_ARRAY_SIZE]; unsigned char overwrite_tempmem_before_pre[OVERWRITE_ARRAY_SIZE]; unsigned char overwrite_output_after_pre[OVERWRITE_ARRAY_SIZE]; unsigned char overwrite_tempmem_after_pre[OVERWRITE_ARRAY_SIZE]; size_t begin_forbidden = width_stride_output * (info->output_h - 1) + info->output_w * info->channels * stbir__type_size[type]; memcpy(overwrite_output_before_pre, &((unsigned char*)output_data)[-OVERWRITE_ARRAY_SIZE], OVERWRITE_ARRAY_SIZE); memcpy(overwrite_output_after_pre, &((unsigned char*)output_data)[begin_forbidden], OVERWRITE_ARRAY_SIZE); memcpy(overwrite_tempmem_before_pre, &((unsigned char*)tempmem)[-OVERWRITE_ARRAY_SIZE], OVERWRITE_ARRAY_SIZE); memcpy(overwrite_tempmem_after_pre, &((unsigned char*)tempmem)[tempmem_size_in_bytes], OVERWRITE_ARRAY_SIZE); #endif STBIR_ASSERT(info->channels >= 0); STBIR_ASSERT(info->channels <= STBIR_MAX_CHANNELS); if (info->channels < 0 || info->channels > STBIR_MAX_CHANNELS) return 0; STBIR_ASSERT(info->horizontal_filter < STBIR__ARRAY_SIZE(stbir__filter_info_table)); STBIR_ASSERT(info->vertical_filter < STBIR__ARRAY_SIZE(stbir__filter_info_table)); if (info->horizontal_filter >= STBIR__ARRAY_SIZE(stbir__filter_info_table)) return 0; if (info->vertical_filter >= STBIR__ARRAY_SIZE(stbir__filter_info_table)) return 0; if (alpha_channel < 0) flags |= STBIR_FLAG_ALPHA_USES_COLORSPACE | STBIR_FLAG_ALPHA_PREMULTIPLIED; if (!(flags&STBIR_FLAG_ALPHA_USES_COLORSPACE) || !(flags&STBIR_FLAG_ALPHA_PREMULTIPLIED)) STBIR_ASSERT(alpha_channel >= 0 && alpha_channel < info->channels); if (alpha_channel >= info->channels) return 0; STBIR_ASSERT(tempmem); if (!tempmem) return 0; STBIR_ASSERT(tempmem_size_in_bytes >= memory_required); if (tempmem_size_in_bytes < memory_required) return 0; memset(tempmem, 0, tempmem_size_in_bytes); info->input_data = input_data; info->input_stride_bytes = width_stride_input; info->output_data = output_data; info->output_stride_bytes = width_stride_output; info->alpha_channel = alpha_channel; info->flags = flags; info->type = type; info->edge_horizontal = edge_horizontal; info->edge_vertical = edge_vertical; info->colorspace = colorspace; info->horizontal_coefficient_width = stbir__get_coefficient_width (info->horizontal_filter, info->horizontal_scale); info->vertical_coefficient_width = stbir__get_coefficient_width (info->vertical_filter , info->vertical_scale ); info->horizontal_filter_pixel_width = stbir__get_filter_pixel_width (info->horizontal_filter, info->horizontal_scale); info->vertical_filter_pixel_width = stbir__get_filter_pixel_width (info->vertical_filter , info->vertical_scale ); info->horizontal_filter_pixel_margin = stbir__get_filter_pixel_margin(info->horizontal_filter, info->horizontal_scale); info->vertical_filter_pixel_margin = stbir__get_filter_pixel_margin(info->vertical_filter , info->vertical_scale ); info->ring_buffer_length_bytes = info->output_w * info->channels * sizeof(float); info->decode_buffer_pixels = info->input_w + info->horizontal_filter_pixel_margin * 2; #define STBIR__NEXT_MEMPTR(current, newtype) (newtype*)(((unsigned char*)current) + current##_size) info->horizontal_contributors = (stbir__contributors *) tempmem; info->horizontal_coefficients = STBIR__NEXT_MEMPTR(info->horizontal_contributors, float); info->vertical_contributors = STBIR__NEXT_MEMPTR(info->horizontal_coefficients, stbir__contributors); info->vertical_coefficients = STBIR__NEXT_MEMPTR(info->vertical_contributors, float); info->decode_buffer = STBIR__NEXT_MEMPTR(info->vertical_coefficients, float); if (stbir__use_height_upsampling(info)) { info->horizontal_buffer = NULL; info->ring_buffer = STBIR__NEXT_MEMPTR(info->decode_buffer, float); info->encode_buffer = STBIR__NEXT_MEMPTR(info->ring_buffer, float); STBIR_ASSERT((size_t)STBIR__NEXT_MEMPTR(info->encode_buffer, unsigned char) == (size_t)tempmem + tempmem_size_in_bytes); } else { info->horizontal_buffer = STBIR__NEXT_MEMPTR(info->decode_buffer, float); info->ring_buffer = STBIR__NEXT_MEMPTR(info->horizontal_buffer, float); info->encode_buffer = NULL; STBIR_ASSERT((size_t)STBIR__NEXT_MEMPTR(info->ring_buffer, unsigned char) == (size_t)tempmem + tempmem_size_in_bytes); } #undef STBIR__NEXT_MEMPTR // This signals that the ring buffer is empty info->ring_buffer_begin_index = -1; stbir__calculate_filters(info->horizontal_contributors, info->horizontal_coefficients, info->horizontal_filter, info->horizontal_scale, info->horizontal_shift, info->input_w, info->output_w); stbir__calculate_filters(info->vertical_contributors, info->vertical_coefficients, info->vertical_filter, info->vertical_scale, info->vertical_shift, info->input_h, info->output_h); STBIR_PROGRESS_REPORT(0); if (stbir__use_height_upsampling(info)) stbir__buffer_loop_upsample(info); else stbir__buffer_loop_downsample(info); STBIR_PROGRESS_REPORT(1); #ifdef STBIR_DEBUG_OVERWRITE_TEST STBIR_ASSERT(memcmp(overwrite_output_before_pre, &((unsigned char*)output_data)[-OVERWRITE_ARRAY_SIZE], OVERWRITE_ARRAY_SIZE) == 0); STBIR_ASSERT(memcmp(overwrite_output_after_pre, &((unsigned char*)output_data)[begin_forbidden], OVERWRITE_ARRAY_SIZE) == 0); STBIR_ASSERT(memcmp(overwrite_tempmem_before_pre, &((unsigned char*)tempmem)[-OVERWRITE_ARRAY_SIZE], OVERWRITE_ARRAY_SIZE) == 0); STBIR_ASSERT(memcmp(overwrite_tempmem_after_pre, &((unsigned char*)tempmem)[tempmem_size_in_bytes], OVERWRITE_ARRAY_SIZE) == 0); #endif return 1; } static int stbir__resize_arbitrary( void *alloc_context, const void* input_data, int input_w, int input_h, int input_stride_in_bytes, void* output_data, int output_w, int output_h, int output_stride_in_bytes, float s0, float t0, float s1, float t1, float *transform, int channels, int alpha_channel, stbir_uint32 flags, stbir_datatype type, stbir_filter h_filter, stbir_filter v_filter, stbir_edge edge_horizontal, stbir_edge edge_vertical, stbir_colorspace colorspace) { stbir__info info; int result; size_t memory_required; void* extra_memory; stbir__setup(&info, input_w, input_h, output_w, output_h, channels); stbir__calculate_transform(&info, s0,t0,s1,t1,transform); stbir__choose_filter(&info, h_filter, v_filter); memory_required = stbir__calculate_memory(&info); extra_memory = STBIR_MALLOC(memory_required, alloc_context); if (!extra_memory) return 0; result = stbir__resize_allocated(&info, input_data, input_stride_in_bytes, output_data, output_stride_in_bytes, alpha_channel, flags, type, edge_horizontal, edge_vertical, colorspace, extra_memory, memory_required); STBIR_FREE(extra_memory, alloc_context); return result; } STBIRDEF int stbir_resize_uint8( const unsigned char *input_pixels , int input_w , int input_h , int input_stride_in_bytes, unsigned char *output_pixels, int output_w, int output_h, int output_stride_in_bytes, int num_channels) { return stbir__resize_arbitrary(NULL, input_pixels, input_w, input_h, input_stride_in_bytes, output_pixels, output_w, output_h, output_stride_in_bytes, 0,0,1,1,NULL,num_channels,-1,0, STBIR_TYPE_UINT8, STBIR_FILTER_DEFAULT, STBIR_FILTER_DEFAULT, STBIR_EDGE_CLAMP, STBIR_EDGE_CLAMP, STBIR_COLORSPACE_LINEAR); } STBIRDEF int stbir_resize_float( const float *input_pixels , int input_w , int input_h , int input_stride_in_bytes, float *output_pixels, int output_w, int output_h, int output_stride_in_bytes, int num_channels) { return stbir__resize_arbitrary(NULL, input_pixels, input_w, input_h, input_stride_in_bytes, output_pixels, output_w, output_h, output_stride_in_bytes, 0,0,1,1,NULL,num_channels,-1,0, STBIR_TYPE_FLOAT, STBIR_FILTER_DEFAULT, STBIR_FILTER_DEFAULT, STBIR_EDGE_CLAMP, STBIR_EDGE_CLAMP, STBIR_COLORSPACE_LINEAR); } STBIRDEF int stbir_resize_uint8_srgb(const unsigned char *input_pixels , int input_w , int input_h , int input_stride_in_bytes, unsigned char *output_pixels, int output_w, int output_h, int output_stride_in_bytes, int num_channels, int alpha_channel, int flags) { return stbir__resize_arbitrary(NULL, input_pixels, input_w, input_h, input_stride_in_bytes, output_pixels, output_w, output_h, output_stride_in_bytes, 0,0,1,1,NULL,num_channels,alpha_channel,flags, STBIR_TYPE_UINT8, STBIR_FILTER_DEFAULT, STBIR_FILTER_DEFAULT, STBIR_EDGE_CLAMP, STBIR_EDGE_CLAMP, STBIR_COLORSPACE_SRGB); } STBIRDEF int stbir_resize_uint8_srgb_edgemode(const unsigned char *input_pixels , int input_w , int input_h , int input_stride_in_bytes, unsigned char *output_pixels, int output_w, int output_h, int output_stride_in_bytes, int num_channels, int alpha_channel, int flags, stbir_edge edge_wrap_mode) { return stbir__resize_arbitrary(NULL, input_pixels, input_w, input_h, input_stride_in_bytes, output_pixels, output_w, output_h, output_stride_in_bytes, 0,0,1,1,NULL,num_channels,alpha_channel,flags, STBIR_TYPE_UINT8, STBIR_FILTER_DEFAULT, STBIR_FILTER_DEFAULT, edge_wrap_mode, edge_wrap_mode, STBIR_COLORSPACE_SRGB); } STBIRDEF int stbir_resize_uint8_generic( const unsigned char *input_pixels , int input_w , int input_h , int input_stride_in_bytes, unsigned char *output_pixels, int output_w, int output_h, int output_stride_in_bytes, int num_channels, int alpha_channel, int flags, stbir_edge edge_wrap_mode, stbir_filter filter, stbir_colorspace space, void *alloc_context) { return stbir__resize_arbitrary(alloc_context, input_pixels, input_w, input_h, input_stride_in_bytes, output_pixels, output_w, output_h, output_stride_in_bytes, 0,0,1,1,NULL,num_channels,alpha_channel,flags, STBIR_TYPE_UINT8, filter, filter, edge_wrap_mode, edge_wrap_mode, space); } STBIRDEF int stbir_resize_uint16_generic(const stbir_uint16 *input_pixels , int input_w , int input_h , int input_stride_in_bytes, stbir_uint16 *output_pixels , int output_w, int output_h, int output_stride_in_bytes, int num_channels, int alpha_channel, int flags, stbir_edge edge_wrap_mode, stbir_filter filter, stbir_colorspace space, void *alloc_context) { return stbir__resize_arbitrary(alloc_context, input_pixels, input_w, input_h, input_stride_in_bytes, output_pixels, output_w, output_h, output_stride_in_bytes, 0,0,1,1,NULL,num_channels,alpha_channel,flags, STBIR_TYPE_UINT16, filter, filter, edge_wrap_mode, edge_wrap_mode, space); } STBIRDEF int stbir_resize_float_generic( const float *input_pixels , int input_w , int input_h , int input_stride_in_bytes, float *output_pixels , int output_w, int output_h, int output_stride_in_bytes, int num_channels, int alpha_channel, int flags, stbir_edge edge_wrap_mode, stbir_filter filter, stbir_colorspace space, void *alloc_context) { return stbir__resize_arbitrary(alloc_context, input_pixels, input_w, input_h, input_stride_in_bytes, output_pixels, output_w, output_h, output_stride_in_bytes, 0,0,1,1,NULL,num_channels,alpha_channel,flags, STBIR_TYPE_FLOAT, filter, filter, edge_wrap_mode, edge_wrap_mode, space); } STBIRDEF int stbir_resize( const void *input_pixels , int input_w , int input_h , int input_stride_in_bytes, void *output_pixels, int output_w, int output_h, int output_stride_in_bytes, stbir_datatype datatype, int num_channels, int alpha_channel, int flags, stbir_edge edge_mode_horizontal, stbir_edge edge_mode_vertical, stbir_filter filter_horizontal, stbir_filter filter_vertical, stbir_colorspace space, void *alloc_context) { return stbir__resize_arbitrary(alloc_context, input_pixels, input_w, input_h, input_stride_in_bytes, output_pixels, output_w, output_h, output_stride_in_bytes, 0,0,1,1,NULL,num_channels,alpha_channel,flags, datatype, filter_horizontal, filter_vertical, edge_mode_horizontal, edge_mode_vertical, space); } STBIRDEF int stbir_resize_subpixel(const void *input_pixels , int input_w , int input_h , int input_stride_in_bytes, void *output_pixels, int output_w, int output_h, int output_stride_in_bytes, stbir_datatype datatype, int num_channels, int alpha_channel, int flags, stbir_edge edge_mode_horizontal, stbir_edge edge_mode_vertical, stbir_filter filter_horizontal, stbir_filter filter_vertical, stbir_colorspace space, void *alloc_context, float x_scale, float y_scale, float x_offset, float y_offset) { float transform[4]; transform[0] = x_scale; transform[1] = y_scale; transform[2] = x_offset; transform[3] = y_offset; return stbir__resize_arbitrary(alloc_context, input_pixels, input_w, input_h, input_stride_in_bytes, output_pixels, output_w, output_h, output_stride_in_bytes, 0,0,1,1,transform,num_channels,alpha_channel,flags, datatype, filter_horizontal, filter_vertical, edge_mode_horizontal, edge_mode_vertical, space); } STBIRDEF int stbir_resize_region( const void *input_pixels , int input_w , int input_h , int input_stride_in_bytes, void *output_pixels, int output_w, int output_h, int output_stride_in_bytes, stbir_datatype datatype, int num_channels, int alpha_channel, int flags, stbir_edge edge_mode_horizontal, stbir_edge edge_mode_vertical, stbir_filter filter_horizontal, stbir_filter filter_vertical, stbir_colorspace space, void *alloc_context, float s0, float t0, float s1, float t1) { return stbir__resize_arbitrary(alloc_context, input_pixels, input_w, input_h, input_stride_in_bytes, output_pixels, output_w, output_h, output_stride_in_bytes, s0,t0,s1,t1,NULL,num_channels,alpha_channel,flags, datatype, filter_horizontal, filter_vertical, edge_mode_horizontal, edge_mode_vertical, space); } #endif // STB_IMAGE_RESIZE_IMPLEMENTATION /* ------------------------------------------------------------------------------ This software is available under 2 licenses -- choose whichever you prefer. ------------------------------------------------------------------------------ ALTERNATIVE A - MIT License Copyright (c) 2017 Sean Barrett 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. ------------------------------------------------------------------------------ ALTERNATIVE B - Public Domain (www.unlicense.org) This is free and unencumbered software released into the public domain. Anyone is free to copy, modify, publish, use, compile, sell, or distribute this software, either in source code form or as a compiled binary, for any purpose, commercial or non-commercial, and by any means. In jurisdictions that recognize copyright laws, the author or authors of this software dedicate any and all copyright interest in the software to the public domain. We make this dedication for the benefit of the public at large and to the detriment of our heirs and successors. We intend this dedication to be an overt act of relinquishment in perpetuity of all present and future rights to this software under copyright law. 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 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. ------------------------------------------------------------------------------ */ ================================================ FILE: deps/include/stb/stb_image_write.h ================================================ /* stb_image_write - v1.11 - public domain - http://nothings.org/stb/stb_image_write.h writes out PNG/BMP/TGA/JPEG/HDR images to C stdio - Sean Barrett 2010-2015 no warranty implied; use at your own risk Before #including, #define STB_IMAGE_WRITE_IMPLEMENTATION in the file that you want to have the implementation. Will probably not work correctly with strict-aliasing optimizations. If using a modern Microsoft Compiler, non-safe versions of CRT calls may cause compilation warnings or even errors. To avoid this, also before #including, #define STBI_MSC_SECURE_CRT ABOUT: This header file is a library for writing images to C stdio or a callback. The PNG output is not optimal; it is 20-50% larger than the file written by a decent optimizing implementation; though providing a custom zlib compress function (see STBIW_ZLIB_COMPRESS) can mitigate that. This library is designed for source code compactness and simplicity, not optimal image file size or run-time performance. BUILDING: You can #define STBIW_ASSERT(x) before the #include to avoid using assert.h. You can #define STBIW_MALLOC(), STBIW_REALLOC(), and STBIW_FREE() to replace malloc,realloc,free. You can #define STBIW_MEMMOVE() to replace memmove() You can #define STBIW_ZLIB_COMPRESS to use a custom zlib-style compress function for PNG compression (instead of the builtin one), it must have the following signature: unsigned char * my_compress(unsigned char *data, int data_len, int *out_len, int quality); The returned data will be freed with STBIW_FREE() (free() by default), so it must be heap allocated with STBIW_MALLOC() (malloc() by default), UNICODE: If compiling for Windows and you wish to use Unicode filenames, compile with #define STBIW_WINDOWS_UTF8 and pass utf8-encoded filenames. Call stbiw_convert_wchar_to_utf8 to convert Windows wchar_t filenames to utf8. USAGE: There are five functions, one for each image file format: int stbi_write_png(char const *filename, int w, int h, int comp, const void *data, int stride_in_bytes); int stbi_write_bmp(char const *filename, int w, int h, int comp, const void *data); int stbi_write_tga(char const *filename, int w, int h, int comp, const void *data); int stbi_write_jpg(char const *filename, int w, int h, int comp, const void *data, int quality); int stbi_write_hdr(char const *filename, int w, int h, int comp, const float *data); void stbi_flip_vertically_on_write(int flag); // flag is non-zero to flip data vertically There are also five equivalent functions that use an arbitrary write function. You are expected to open/close your file-equivalent before and after calling these: int stbi_write_png_to_func(stbi_write_func *func, void *context, int w, int h, int comp, const void *data, int stride_in_bytes); int stbi_write_bmp_to_func(stbi_write_func *func, void *context, int w, int h, int comp, const void *data); int stbi_write_tga_to_func(stbi_write_func *func, void *context, int w, int h, int comp, const void *data); int stbi_write_hdr_to_func(stbi_write_func *func, void *context, int w, int h, int comp, const float *data); int stbi_write_jpg_to_func(stbi_write_func *func, void *context, int x, int y, int comp, const void *data, int quality); where the callback is: void stbi_write_func(void *context, void *data, int size); You can configure it with these global variables: int stbi_write_tga_with_rle; // defaults to true; set to 0 to disable RLE int stbi_write_png_compression_level; // defaults to 8; set to higher for more compression int stbi_write_force_png_filter; // defaults to -1; set to 0..5 to force a filter mode You can define STBI_WRITE_NO_STDIO to disable the file variant of these functions, so the library will not use stdio.h at all. However, this will also disable HDR writing, because it requires stdio for formatted output. Each function returns 0 on failure and non-0 on success. The functions create an image file defined by the parameters. The image is a rectangle of pixels stored from left-to-right, top-to-bottom. Each pixel contains 'comp' channels of data stored interleaved with 8-bits per channel, in the following order: 1=Y, 2=YA, 3=RGB, 4=RGBA. (Y is monochrome color.) The rectangle is 'w' pixels wide and 'h' pixels tall. The *data pointer points to the first byte of the top-left-most pixel. For PNG, "stride_in_bytes" is the distance in bytes from the first byte of a row of pixels to the first byte of the next row of pixels. PNG creates output files with the same number of components as the input. The BMP format expands Y to RGB in the file format and does not output alpha. PNG supports writing rectangles of data even when the bytes storing rows of data are not consecutive in memory (e.g. sub-rectangles of a larger image), by supplying the stride between the beginning of adjacent rows. The other formats do not. (Thus you cannot write a native-format BMP through the BMP writer, both because it is in BGR order and because it may have padding at the end of the line.) PNG allows you to set the deflate compression level by setting the global variable 'stbi_write_png_compression_level' (it defaults to 8). HDR expects linear float data. Since the format is always 32-bit rgb(e) data, alpha (if provided) is discarded, and for monochrome data it is replicated across all three channels. TGA supports RLE or non-RLE compressed data. To use non-RLE-compressed data, set the global variable 'stbi_write_tga_with_rle' to 0. JPEG does ignore alpha channels in input data; quality is between 1 and 100. Higher quality looks better but results in a bigger image. JPEG baseline (no JPEG progressive). CREDITS: Sean Barrett - PNG/BMP/TGA Baldur Karlsson - HDR Jean-Sebastien Guay - TGA monochrome Tim Kelsey - misc enhancements Alan Hickman - TGA RLE Emmanuel Julien - initial file IO callback implementation Jon Olick - original jo_jpeg.cpp code Daniel Gibson - integrate JPEG, allow external zlib Aarni Koskela - allow choosing PNG filter bugfixes: github:Chribba Guillaume Chereau github:jry2 github:romigrou Sergio Gonzalez Jonas Karlsson Filip Wasil Thatcher Ulrich github:poppolopoppo Patrick Boettcher github:xeekworx Cap Petschulat Simon Rodriguez Ivan Tikhonov github:ignotion Adam Schackart LICENSE See end of file for license information. */ #ifndef INCLUDE_STB_IMAGE_WRITE_H #define INCLUDE_STB_IMAGE_WRITE_H #include // if STB_IMAGE_WRITE_STATIC causes problems, try defining STBIWDEF to 'inline' or 'static inline' #ifndef STBIWDEF #ifdef STB_IMAGE_WRITE_STATIC #define STBIWDEF static #else #ifdef __cplusplus #define STBIWDEF extern "C" #else #define STBIWDEF extern #endif #endif #endif #ifndef STB_IMAGE_WRITE_STATIC // C++ forbids static forward declarations extern int stbi_write_tga_with_rle; extern int stbi_write_png_compression_level; extern int stbi_write_force_png_filter; #endif #ifndef STBI_WRITE_NO_STDIO STBIWDEF int stbi_write_png(char const *filename, int w, int h, int comp, const void *data, int stride_in_bytes); STBIWDEF int stbi_write_bmp(char const *filename, int w, int h, int comp, const void *data); STBIWDEF int stbi_write_tga(char const *filename, int w, int h, int comp, const void *data); STBIWDEF int stbi_write_hdr(char const *filename, int w, int h, int comp, const float *data); STBIWDEF int stbi_write_jpg(char const *filename, int x, int y, int comp, const void *data, int quality); #ifdef STBI_WINDOWS_UTF8 STBIWDEF int stbiw_convert_wchar_to_utf8(char *buffer, size_t bufferlen, const wchar_t* input); #endif #endif typedef void stbi_write_func(void *context, void *data, int size); STBIWDEF int stbi_write_png_to_func(stbi_write_func *func, void *context, int w, int h, int comp, const void *data, int stride_in_bytes); STBIWDEF int stbi_write_bmp_to_func(stbi_write_func *func, void *context, int w, int h, int comp, const void *data); STBIWDEF int stbi_write_tga_to_func(stbi_write_func *func, void *context, int w, int h, int comp, const void *data); STBIWDEF int stbi_write_hdr_to_func(stbi_write_func *func, void *context, int w, int h, int comp, const float *data); STBIWDEF int stbi_write_jpg_to_func(stbi_write_func *func, void *context, int x, int y, int comp, const void *data, int quality); STBIWDEF void stbi_flip_vertically_on_write(int flip_boolean); #endif//INCLUDE_STB_IMAGE_WRITE_H #ifdef STB_IMAGE_WRITE_IMPLEMENTATION #ifdef _WIN32 #ifndef _CRT_SECURE_NO_WARNINGS #define _CRT_SECURE_NO_WARNINGS #endif #ifndef _CRT_NONSTDC_NO_DEPRECATE #define _CRT_NONSTDC_NO_DEPRECATE #endif #endif #ifndef STBI_WRITE_NO_STDIO #include #endif // STBI_WRITE_NO_STDIO #include #include #include #include #if defined(STBIW_MALLOC) && defined(STBIW_FREE) && (defined(STBIW_REALLOC) || defined(STBIW_REALLOC_SIZED)) // ok #elif !defined(STBIW_MALLOC) && !defined(STBIW_FREE) && !defined(STBIW_REALLOC) && !defined(STBIW_REALLOC_SIZED) // ok #else #error "Must define all or none of STBIW_MALLOC, STBIW_FREE, and STBIW_REALLOC (or STBIW_REALLOC_SIZED)." #endif #ifndef STBIW_MALLOC #define STBIW_MALLOC(sz) malloc(sz) #define STBIW_REALLOC(p,newsz) realloc(p,newsz) #define STBIW_FREE(p) free(p) #endif #ifndef STBIW_REALLOC_SIZED #define STBIW_REALLOC_SIZED(p,oldsz,newsz) STBIW_REALLOC(p,newsz) #endif #ifndef STBIW_MEMMOVE #define STBIW_MEMMOVE(a,b,sz) memmove(a,b,sz) #endif #ifndef STBIW_ASSERT #include #define STBIW_ASSERT(x) assert(x) #endif #define STBIW_UCHAR(x) (unsigned char) ((x) & 0xff) #ifdef STB_IMAGE_WRITE_STATIC static int stbi__flip_vertically_on_write=0; static int stbi_write_png_compression_level = 8; static int stbi_write_tga_with_rle = 1; static int stbi_write_force_png_filter = -1; #else int stbi_write_png_compression_level = 8; int stbi__flip_vertically_on_write=0; int stbi_write_tga_with_rle = 1; int stbi_write_force_png_filter = -1; #endif STBIWDEF void stbi_flip_vertically_on_write(int flag) { stbi__flip_vertically_on_write = flag; } typedef struct { stbi_write_func *func; void *context; } stbi__write_context; // initialize a callback-based context static void stbi__start_write_callbacks(stbi__write_context *s, stbi_write_func *c, void *context) { s->func = c; s->context = context; } #ifndef STBI_WRITE_NO_STDIO static void stbi__stdio_write(void *context, void *data, int size) { fwrite(data,1,size,(FILE*) context); } #if defined(_MSC_VER) && defined(STBI_WINDOWS_UTF8) #ifdef __cplusplus #define STBIW_EXTERN extern "C" #else #define STBIW_EXTERN extern #endif STBIW_EXTERN __declspec(dllimport) int __stdcall MultiByteToWideChar(unsigned int cp, unsigned long flags, const char *str, int cbmb, wchar_t *widestr, int cchwide); STBIW_EXTERN __declspec(dllimport) int __stdcall WideCharToMultiByte(unsigned int cp, unsigned long flags, const wchar_t *widestr, int cchwide, char *str, int cbmb, const char *defchar, int *used_default); STBIWDEF int stbiw_convert_wchar_to_utf8(char *buffer, size_t bufferlen, const wchar_t* input) { return WideCharToMultiByte(65001 /* UTF8 */, 0, input, -1, buffer, bufferlen, NULL, NULL); } #endif static FILE *stbiw__fopen(char const *filename, char const *mode) { FILE *f; #if defined(_MSC_VER) && defined(STBI_WINDOWS_UTF8) wchar_t wMode[64]; wchar_t wFilename[1024]; if (0 == MultiByteToWideChar(65001 /* UTF8 */, 0, filename, -1, wFilename, sizeof(wFilename))) return 0; if (0 == MultiByteToWideChar(65001 /* UTF8 */, 0, mode, -1, wMode, sizeof(wMode))) return 0; #if _MSC_VER >= 1400 if (0 != _wfopen_s(&f, wFilename, wMode)) f = 0; #else f = _wfopen(wFilename, wMode); #endif #elif defined(_MSC_VER) && _MSC_VER >= 1400 if (0 != fopen_s(&f, filename, mode)) f=0; #else f = fopen(filename, mode); #endif return f; } static int stbi__start_write_file(stbi__write_context *s, const char *filename) { FILE *f = stbiw__fopen(filename, "wb"); stbi__start_write_callbacks(s, stbi__stdio_write, (void *) f); return f != NULL; } static void stbi__end_write_file(stbi__write_context *s) { fclose((FILE *)s->context); } #endif // !STBI_WRITE_NO_STDIO typedef unsigned int stbiw_uint32; typedef int stb_image_write_test[sizeof(stbiw_uint32)==4 ? 1 : -1]; static void stbiw__writefv(stbi__write_context *s, const char *fmt, va_list v) { while (*fmt) { switch (*fmt++) { case ' ': break; case '1': { unsigned char x = STBIW_UCHAR(va_arg(v, int)); s->func(s->context,&x,1); break; } case '2': { int x = va_arg(v,int); unsigned char b[2]; b[0] = STBIW_UCHAR(x); b[1] = STBIW_UCHAR(x>>8); s->func(s->context,b,2); break; } case '4': { stbiw_uint32 x = va_arg(v,int); unsigned char b[4]; b[0]=STBIW_UCHAR(x); b[1]=STBIW_UCHAR(x>>8); b[2]=STBIW_UCHAR(x>>16); b[3]=STBIW_UCHAR(x>>24); s->func(s->context,b,4); break; } default: STBIW_ASSERT(0); return; } } } static void stbiw__writef(stbi__write_context *s, const char *fmt, ...) { va_list v; va_start(v, fmt); stbiw__writefv(s, fmt, v); va_end(v); } static void stbiw__putc(stbi__write_context *s, unsigned char c) { s->func(s->context, &c, 1); } static void stbiw__write3(stbi__write_context *s, unsigned char a, unsigned char b, unsigned char c) { unsigned char arr[3]; arr[0] = a, arr[1] = b, arr[2] = c; s->func(s->context, arr, 3); } static void stbiw__write_pixel(stbi__write_context *s, int rgb_dir, int comp, int write_alpha, int expand_mono, unsigned char *d) { unsigned char bg[3] = { 255, 0, 255}, px[3]; int k; if (write_alpha < 0) s->func(s->context, &d[comp - 1], 1); switch (comp) { case 2: // 2 pixels = mono + alpha, alpha is written separately, so same as 1-channel case case 1: if (expand_mono) stbiw__write3(s, d[0], d[0], d[0]); // monochrome bmp else s->func(s->context, d, 1); // monochrome TGA break; case 4: if (!write_alpha) { // composite against pink background for (k = 0; k < 3; ++k) px[k] = bg[k] + ((d[k] - bg[k]) * d[3]) / 255; stbiw__write3(s, px[1 - rgb_dir], px[1], px[1 + rgb_dir]); break; } /* FALLTHROUGH */ case 3: stbiw__write3(s, d[1 - rgb_dir], d[1], d[1 + rgb_dir]); break; } if (write_alpha > 0) s->func(s->context, &d[comp - 1], 1); } static void stbiw__write_pixels(stbi__write_context *s, int rgb_dir, int vdir, int x, int y, int comp, void *data, int write_alpha, int scanline_pad, int expand_mono) { stbiw_uint32 zero = 0; int i,j, j_end; if (y <= 0) return; if (stbi__flip_vertically_on_write) vdir *= -1; if (vdir < 0) j_end = -1, j = y-1; else j_end = y, j = 0; for (; j != j_end; j += vdir) { for (i=0; i < x; ++i) { unsigned char *d = (unsigned char *) data + (j*x+i)*comp; stbiw__write_pixel(s, rgb_dir, comp, write_alpha, expand_mono, d); } s->func(s->context, &zero, scanline_pad); } } static int stbiw__outfile(stbi__write_context *s, int rgb_dir, int vdir, int x, int y, int comp, int expand_mono, void *data, int alpha, int pad, const char *fmt, ...) { if (y < 0 || x < 0) { return 0; } else { va_list v; va_start(v, fmt); stbiw__writefv(s, fmt, v); va_end(v); stbiw__write_pixels(s,rgb_dir,vdir,x,y,comp,data,alpha,pad, expand_mono); return 1; } } static int stbi_write_bmp_core(stbi__write_context *s, int x, int y, int comp, const void *data) { int pad = (-x*3) & 3; return stbiw__outfile(s,-1,-1,x,y,comp,1,(void *) data,0,pad, "11 4 22 4" "4 44 22 444444", 'B', 'M', 14+40+(x*3+pad)*y, 0,0, 14+40, // file header 40, x,y, 1,24, 0,0,0,0,0,0); // bitmap header } STBIWDEF int stbi_write_bmp_to_func(stbi_write_func *func, void *context, int x, int y, int comp, const void *data) { stbi__write_context s; stbi__start_write_callbacks(&s, func, context); return stbi_write_bmp_core(&s, x, y, comp, data); } #ifndef STBI_WRITE_NO_STDIO STBIWDEF int stbi_write_bmp(char const *filename, int x, int y, int comp, const void *data) { stbi__write_context s; if (stbi__start_write_file(&s,filename)) { int r = stbi_write_bmp_core(&s, x, y, comp, data); stbi__end_write_file(&s); return r; } else return 0; } #endif //!STBI_WRITE_NO_STDIO static int stbi_write_tga_core(stbi__write_context *s, int x, int y, int comp, void *data) { int has_alpha = (comp == 2 || comp == 4); int colorbytes = has_alpha ? comp-1 : comp; int format = colorbytes < 2 ? 3 : 2; // 3 color channels (RGB/RGBA) = 2, 1 color channel (Y/YA) = 3 if (y < 0 || x < 0) return 0; if (!stbi_write_tga_with_rle) { return stbiw__outfile(s, -1, -1, x, y, comp, 0, (void *) data, has_alpha, 0, "111 221 2222 11", 0, 0, format, 0, 0, 0, 0, 0, x, y, (colorbytes + has_alpha) * 8, has_alpha * 8); } else { int i,j,k; int jend, jdir; stbiw__writef(s, "111 221 2222 11", 0,0,format+8, 0,0,0, 0,0,x,y, (colorbytes + has_alpha) * 8, has_alpha * 8); if (stbi__flip_vertically_on_write) { j = 0; jend = y; jdir = 1; } else { j = y-1; jend = -1; jdir = -1; } for (; j != jend; j += jdir) { unsigned char *row = (unsigned char *) data + j * x * comp; int len; for (i = 0; i < x; i += len) { unsigned char *begin = row + i * comp; int diff = 1; len = 1; if (i < x - 1) { ++len; diff = memcmp(begin, row + (i + 1) * comp, comp); if (diff) { const unsigned char *prev = begin; for (k = i + 2; k < x && len < 128; ++k) { if (memcmp(prev, row + k * comp, comp)) { prev += comp; ++len; } else { --len; break; } } } else { for (k = i + 2; k < x && len < 128; ++k) { if (!memcmp(begin, row + k * comp, comp)) { ++len; } else { break; } } } } if (diff) { unsigned char header = STBIW_UCHAR(len - 1); s->func(s->context, &header, 1); for (k = 0; k < len; ++k) { stbiw__write_pixel(s, -1, comp, has_alpha, 0, begin + k * comp); } } else { unsigned char header = STBIW_UCHAR(len - 129); s->func(s->context, &header, 1); stbiw__write_pixel(s, -1, comp, has_alpha, 0, begin); } } } } return 1; } STBIWDEF int stbi_write_tga_to_func(stbi_write_func *func, void *context, int x, int y, int comp, const void *data) { stbi__write_context s; stbi__start_write_callbacks(&s, func, context); return stbi_write_tga_core(&s, x, y, comp, (void *) data); } #ifndef STBI_WRITE_NO_STDIO STBIWDEF int stbi_write_tga(char const *filename, int x, int y, int comp, const void *data) { stbi__write_context s; if (stbi__start_write_file(&s,filename)) { int r = stbi_write_tga_core(&s, x, y, comp, (void *) data); stbi__end_write_file(&s); return r; } else return 0; } #endif // ************************************************************************************************* // Radiance RGBE HDR writer // by Baldur Karlsson #define stbiw__max(a, b) ((a) > (b) ? (a) : (b)) static void stbiw__linear_to_rgbe(unsigned char *rgbe, float *linear) { int exponent; float maxcomp = stbiw__max(linear[0], stbiw__max(linear[1], linear[2])); if (maxcomp < 1e-32f) { rgbe[0] = rgbe[1] = rgbe[2] = rgbe[3] = 0; } else { float normalize = (float) frexp(maxcomp, &exponent) * 256.0f/maxcomp; rgbe[0] = (unsigned char)(linear[0] * normalize); rgbe[1] = (unsigned char)(linear[1] * normalize); rgbe[2] = (unsigned char)(linear[2] * normalize); rgbe[3] = (unsigned char)(exponent + 128); } } static void stbiw__write_run_data(stbi__write_context *s, int length, unsigned char databyte) { unsigned char lengthbyte = STBIW_UCHAR(length+128); STBIW_ASSERT(length+128 <= 255); s->func(s->context, &lengthbyte, 1); s->func(s->context, &databyte, 1); } static void stbiw__write_dump_data(stbi__write_context *s, int length, unsigned char *data) { unsigned char lengthbyte = STBIW_UCHAR(length); STBIW_ASSERT(length <= 128); // inconsistent with spec but consistent with official code s->func(s->context, &lengthbyte, 1); s->func(s->context, data, length); } static void stbiw__write_hdr_scanline(stbi__write_context *s, int width, int ncomp, unsigned char *scratch, float *scanline) { unsigned char scanlineheader[4] = { 2, 2, 0, 0 }; unsigned char rgbe[4]; float linear[3]; int x; scanlineheader[2] = (width&0xff00)>>8; scanlineheader[3] = (width&0x00ff); /* skip RLE for images too small or large */ if (width < 8 || width >= 32768) { for (x=0; x < width; x++) { switch (ncomp) { case 4: /* fallthrough */ case 3: linear[2] = scanline[x*ncomp + 2]; linear[1] = scanline[x*ncomp + 1]; linear[0] = scanline[x*ncomp + 0]; break; default: linear[0] = linear[1] = linear[2] = scanline[x*ncomp + 0]; break; } stbiw__linear_to_rgbe(rgbe, linear); s->func(s->context, rgbe, 4); } } else { int c,r; /* encode into scratch buffer */ for (x=0; x < width; x++) { switch(ncomp) { case 4: /* fallthrough */ case 3: linear[2] = scanline[x*ncomp + 2]; linear[1] = scanline[x*ncomp + 1]; linear[0] = scanline[x*ncomp + 0]; break; default: linear[0] = linear[1] = linear[2] = scanline[x*ncomp + 0]; break; } stbiw__linear_to_rgbe(rgbe, linear); scratch[x + width*0] = rgbe[0]; scratch[x + width*1] = rgbe[1]; scratch[x + width*2] = rgbe[2]; scratch[x + width*3] = rgbe[3]; } s->func(s->context, scanlineheader, 4); /* RLE each component separately */ for (c=0; c < 4; c++) { unsigned char *comp = &scratch[width*c]; x = 0; while (x < width) { // find first run r = x; while (r+2 < width) { if (comp[r] == comp[r+1] && comp[r] == comp[r+2]) break; ++r; } if (r+2 >= width) r = width; // dump up to first run while (x < r) { int len = r-x; if (len > 128) len = 128; stbiw__write_dump_data(s, len, &comp[x]); x += len; } // if there's a run, output it if (r+2 < width) { // same test as what we break out of in search loop, so only true if we break'd // find next byte after run while (r < width && comp[r] == comp[x]) ++r; // output run up to r while (x < r) { int len = r-x; if (len > 127) len = 127; stbiw__write_run_data(s, len, comp[x]); x += len; } } } } } } static int stbi_write_hdr_core(stbi__write_context *s, int x, int y, int comp, float *data) { if (y <= 0 || x <= 0 || data == NULL) return 0; else { // Each component is stored separately. Allocate scratch space for full output scanline. unsigned char *scratch = (unsigned char *) STBIW_MALLOC(x*4); int i, len; char buffer[128]; char header[] = "#?RADIANCE\n# Written by stb_image_write.h\nFORMAT=32-bit_rle_rgbe\n"; s->func(s->context, header, sizeof(header)-1); #ifdef STBI_MSC_SECURE_CRT len = sprintf_s(buffer, "EXPOSURE= 1.0000000000000\n\n-Y %d +X %d\n", y, x); #else len = sprintf(buffer, "EXPOSURE= 1.0000000000000\n\n-Y %d +X %d\n", y, x); #endif s->func(s->context, buffer, len); for(i=0; i < y; i++) stbiw__write_hdr_scanline(s, x, comp, scratch, data + comp*x*(stbi__flip_vertically_on_write ? y-1-i : i)); STBIW_FREE(scratch); return 1; } } STBIWDEF int stbi_write_hdr_to_func(stbi_write_func *func, void *context, int x, int y, int comp, const float *data) { stbi__write_context s; stbi__start_write_callbacks(&s, func, context); return stbi_write_hdr_core(&s, x, y, comp, (float *) data); } #ifndef STBI_WRITE_NO_STDIO STBIWDEF int stbi_write_hdr(char const *filename, int x, int y, int comp, const float *data) { stbi__write_context s; if (stbi__start_write_file(&s,filename)) { int r = stbi_write_hdr_core(&s, x, y, comp, (float *) data); stbi__end_write_file(&s); return r; } else return 0; } #endif // STBI_WRITE_NO_STDIO ////////////////////////////////////////////////////////////////////////////// // // PNG writer // #ifndef STBIW_ZLIB_COMPRESS // stretchy buffer; stbiw__sbpush() == vector<>::push_back() -- stbiw__sbcount() == vector<>::size() #define stbiw__sbraw(a) ((int *) (a) - 2) #define stbiw__sbm(a) stbiw__sbraw(a)[0] #define stbiw__sbn(a) stbiw__sbraw(a)[1] #define stbiw__sbneedgrow(a,n) ((a)==0 || stbiw__sbn(a)+n >= stbiw__sbm(a)) #define stbiw__sbmaybegrow(a,n) (stbiw__sbneedgrow(a,(n)) ? stbiw__sbgrow(a,n) : 0) #define stbiw__sbgrow(a,n) stbiw__sbgrowf((void **) &(a), (n), sizeof(*(a))) #define stbiw__sbpush(a, v) (stbiw__sbmaybegrow(a,1), (a)[stbiw__sbn(a)++] = (v)) #define stbiw__sbcount(a) ((a) ? stbiw__sbn(a) : 0) #define stbiw__sbfree(a) ((a) ? STBIW_FREE(stbiw__sbraw(a)),0 : 0) static void *stbiw__sbgrowf(void **arr, int increment, int itemsize) { int m = *arr ? 2*stbiw__sbm(*arr)+increment : increment+1; void *p = STBIW_REALLOC_SIZED(*arr ? stbiw__sbraw(*arr) : 0, *arr ? (stbiw__sbm(*arr)*itemsize + sizeof(int)*2) : 0, itemsize * m + sizeof(int)*2); STBIW_ASSERT(p); if (p) { if (!*arr) ((int *) p)[1] = 0; *arr = (void *) ((int *) p + 2); stbiw__sbm(*arr) = m; } return *arr; } static unsigned char *stbiw__zlib_flushf(unsigned char *data, unsigned int *bitbuffer, int *bitcount) { while (*bitcount >= 8) { stbiw__sbpush(data, STBIW_UCHAR(*bitbuffer)); *bitbuffer >>= 8; *bitcount -= 8; } return data; } static int stbiw__zlib_bitrev(int code, int codebits) { int res=0; while (codebits--) { res = (res << 1) | (code & 1); code >>= 1; } return res; } static unsigned int stbiw__zlib_countm(unsigned char *a, unsigned char *b, int limit) { int i; for (i=0; i < limit && i < 258; ++i) if (a[i] != b[i]) break; return i; } static unsigned int stbiw__zhash(unsigned char *data) { stbiw_uint32 hash = data[0] + (data[1] << 8) + (data[2] << 16); hash ^= hash << 3; hash += hash >> 5; hash ^= hash << 4; hash += hash >> 17; hash ^= hash << 25; hash += hash >> 6; return hash; } #define stbiw__zlib_flush() (out = stbiw__zlib_flushf(out, &bitbuf, &bitcount)) #define stbiw__zlib_add(code,codebits) \ (bitbuf |= (code) << bitcount, bitcount += (codebits), stbiw__zlib_flush()) #define stbiw__zlib_huffa(b,c) stbiw__zlib_add(stbiw__zlib_bitrev(b,c),c) // default huffman tables #define stbiw__zlib_huff1(n) stbiw__zlib_huffa(0x30 + (n), 8) #define stbiw__zlib_huff2(n) stbiw__zlib_huffa(0x190 + (n)-144, 9) #define stbiw__zlib_huff3(n) stbiw__zlib_huffa(0 + (n)-256,7) #define stbiw__zlib_huff4(n) stbiw__zlib_huffa(0xc0 + (n)-280,8) #define stbiw__zlib_huff(n) ((n) <= 143 ? stbiw__zlib_huff1(n) : (n) <= 255 ? stbiw__zlib_huff2(n) : (n) <= 279 ? stbiw__zlib_huff3(n) : stbiw__zlib_huff4(n)) #define stbiw__zlib_huffb(n) ((n) <= 143 ? stbiw__zlib_huff1(n) : stbiw__zlib_huff2(n)) #define stbiw__ZHASH 16384 #endif // STBIW_ZLIB_COMPRESS STBIWDEF unsigned char * stbi_zlib_compress(unsigned char *data, int data_len, int *out_len, int quality) { #ifdef STBIW_ZLIB_COMPRESS // user provided a zlib compress implementation, use that return STBIW_ZLIB_COMPRESS(data, data_len, out_len, quality); #else // use builtin static unsigned short lengthc[] = { 3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258, 259 }; static unsigned char lengtheb[]= { 0,0,0,0,0,0,0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0 }; static unsigned short distc[] = { 1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577, 32768 }; static unsigned char disteb[] = { 0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13 }; unsigned int bitbuf=0; int i,j, bitcount=0; unsigned char *out = NULL; unsigned char ***hash_table = (unsigned char***) STBIW_MALLOC(stbiw__ZHASH * sizeof(char**)); if (hash_table == NULL) return NULL; if (quality < 5) quality = 5; stbiw__sbpush(out, 0x78); // DEFLATE 32K window stbiw__sbpush(out, 0x5e); // FLEVEL = 1 stbiw__zlib_add(1,1); // BFINAL = 1 stbiw__zlib_add(1,2); // BTYPE = 1 -- fixed huffman for (i=0; i < stbiw__ZHASH; ++i) hash_table[i] = NULL; i=0; while (i < data_len-3) { // hash next 3 bytes of data to be compressed int h = stbiw__zhash(data+i)&(stbiw__ZHASH-1), best=3; unsigned char *bestloc = 0; unsigned char **hlist = hash_table[h]; int n = stbiw__sbcount(hlist); for (j=0; j < n; ++j) { if (hlist[j]-data > i-32768) { // if entry lies within window int d = stbiw__zlib_countm(hlist[j], data+i, data_len-i); if (d >= best) best=d,bestloc=hlist[j]; } } // when hash table entry is too long, delete half the entries if (hash_table[h] && stbiw__sbn(hash_table[h]) == 2*quality) { STBIW_MEMMOVE(hash_table[h], hash_table[h]+quality, sizeof(hash_table[h][0])*quality); stbiw__sbn(hash_table[h]) = quality; } stbiw__sbpush(hash_table[h],data+i); if (bestloc) { // "lazy matching" - check match at *next* byte, and if it's better, do cur byte as literal h = stbiw__zhash(data+i+1)&(stbiw__ZHASH-1); hlist = hash_table[h]; n = stbiw__sbcount(hlist); for (j=0; j < n; ++j) { if (hlist[j]-data > i-32767) { int e = stbiw__zlib_countm(hlist[j], data+i+1, data_len-i-1); if (e > best) { // if next match is better, bail on current match bestloc = NULL; break; } } } } if (bestloc) { int d = (int) (data+i - bestloc); // distance back STBIW_ASSERT(d <= 32767 && best <= 258); for (j=0; best > lengthc[j+1]-1; ++j); stbiw__zlib_huff(j+257); if (lengtheb[j]) stbiw__zlib_add(best - lengthc[j], lengtheb[j]); for (j=0; d > distc[j+1]-1; ++j); stbiw__zlib_add(stbiw__zlib_bitrev(j,5),5); if (disteb[j]) stbiw__zlib_add(d - distc[j], disteb[j]); i += best; } else { stbiw__zlib_huffb(data[i]); ++i; } } // write out final bytes for (;i < data_len; ++i) stbiw__zlib_huffb(data[i]); stbiw__zlib_huff(256); // end of block // pad with 0 bits to byte boundary while (bitcount) stbiw__zlib_add(0,1); for (i=0; i < stbiw__ZHASH; ++i) (void) stbiw__sbfree(hash_table[i]); STBIW_FREE(hash_table); { // compute adler32 on input unsigned int s1=1, s2=0; int blocklen = (int) (data_len % 5552); j=0; while (j < data_len) { for (i=0; i < blocklen; ++i) s1 += data[j+i], s2 += s1; s1 %= 65521, s2 %= 65521; j += blocklen; blocklen = 5552; } stbiw__sbpush(out, STBIW_UCHAR(s2 >> 8)); stbiw__sbpush(out, STBIW_UCHAR(s2)); stbiw__sbpush(out, STBIW_UCHAR(s1 >> 8)); stbiw__sbpush(out, STBIW_UCHAR(s1)); } *out_len = stbiw__sbn(out); // make returned pointer freeable STBIW_MEMMOVE(stbiw__sbraw(out), out, *out_len); return (unsigned char *) stbiw__sbraw(out); #endif // STBIW_ZLIB_COMPRESS } static unsigned int stbiw__crc32(unsigned char *buffer, int len) { #ifdef STBIW_CRC32 return STBIW_CRC32(buffer, len); #else static unsigned int crc_table[256] = { 0x00000000, 0x77073096, 0xEE0E612C, 0x990951BA, 0x076DC419, 0x706AF48F, 0xE963A535, 0x9E6495A3, 0x0eDB8832, 0x79DCB8A4, 0xE0D5E91E, 0x97D2D988, 0x09B64C2B, 0x7EB17CBD, 0xE7B82D07, 0x90BF1D91, 0x1DB71064, 0x6AB020F2, 0xF3B97148, 0x84BE41DE, 0x1ADAD47D, 0x6DDDE4EB, 0xF4D4B551, 0x83D385C7, 0x136C9856, 0x646BA8C0, 0xFD62F97A, 0x8A65C9EC, 0x14015C4F, 0x63066CD9, 0xFA0F3D63, 0x8D080DF5, 0x3B6E20C8, 0x4C69105E, 0xD56041E4, 0xA2677172, 0x3C03E4D1, 0x4B04D447, 0xD20D85FD, 0xA50AB56B, 0x35B5A8FA, 0x42B2986C, 0xDBBBC9D6, 0xACBCF940, 0x32D86CE3, 0x45DF5C75, 0xDCD60DCF, 0xABD13D59, 0x26D930AC, 0x51DE003A, 0xC8D75180, 0xBFD06116, 0x21B4F4B5, 0x56B3C423, 0xCFBA9599, 0xB8BDA50F, 0x2802B89E, 0x5F058808, 0xC60CD9B2, 0xB10BE924, 0x2F6F7C87, 0x58684C11, 0xC1611DAB, 0xB6662D3D, 0x76DC4190, 0x01DB7106, 0x98D220BC, 0xEFD5102A, 0x71B18589, 0x06B6B51F, 0x9FBFE4A5, 0xE8B8D433, 0x7807C9A2, 0x0F00F934, 0x9609A88E, 0xE10E9818, 0x7F6A0DBB, 0x086D3D2D, 0x91646C97, 0xE6635C01, 0x6B6B51F4, 0x1C6C6162, 0x856530D8, 0xF262004E, 0x6C0695ED, 0x1B01A57B, 0x8208F4C1, 0xF50FC457, 0x65B0D9C6, 0x12B7E950, 0x8BBEB8EA, 0xFCB9887C, 0x62DD1DDF, 0x15DA2D49, 0x8CD37CF3, 0xFBD44C65, 0x4DB26158, 0x3AB551CE, 0xA3BC0074, 0xD4BB30E2, 0x4ADFA541, 0x3DD895D7, 0xA4D1C46D, 0xD3D6F4FB, 0x4369E96A, 0x346ED9FC, 0xAD678846, 0xDA60B8D0, 0x44042D73, 0x33031DE5, 0xAA0A4C5F, 0xDD0D7CC9, 0x5005713C, 0x270241AA, 0xBE0B1010, 0xC90C2086, 0x5768B525, 0x206F85B3, 0xB966D409, 0xCE61E49F, 0x5EDEF90E, 0x29D9C998, 0xB0D09822, 0xC7D7A8B4, 0x59B33D17, 0x2EB40D81, 0xB7BD5C3B, 0xC0BA6CAD, 0xEDB88320, 0x9ABFB3B6, 0x03B6E20C, 0x74B1D29A, 0xEAD54739, 0x9DD277AF, 0x04DB2615, 0x73DC1683, 0xE3630B12, 0x94643B84, 0x0D6D6A3E, 0x7A6A5AA8, 0xE40ECF0B, 0x9309FF9D, 0x0A00AE27, 0x7D079EB1, 0xF00F9344, 0x8708A3D2, 0x1E01F268, 0x6906C2FE, 0xF762575D, 0x806567CB, 0x196C3671, 0x6E6B06E7, 0xFED41B76, 0x89D32BE0, 0x10DA7A5A, 0x67DD4ACC, 0xF9B9DF6F, 0x8EBEEFF9, 0x17B7BE43, 0x60B08ED5, 0xD6D6A3E8, 0xA1D1937E, 0x38D8C2C4, 0x4FDFF252, 0xD1BB67F1, 0xA6BC5767, 0x3FB506DD, 0x48B2364B, 0xD80D2BDA, 0xAF0A1B4C, 0x36034AF6, 0x41047A60, 0xDF60EFC3, 0xA867DF55, 0x316E8EEF, 0x4669BE79, 0xCB61B38C, 0xBC66831A, 0x256FD2A0, 0x5268E236, 0xCC0C7795, 0xBB0B4703, 0x220216B9, 0x5505262F, 0xC5BA3BBE, 0xB2BD0B28, 0x2BB45A92, 0x5CB36A04, 0xC2D7FFA7, 0xB5D0CF31, 0x2CD99E8B, 0x5BDEAE1D, 0x9B64C2B0, 0xEC63F226, 0x756AA39C, 0x026D930A, 0x9C0906A9, 0xEB0E363F, 0x72076785, 0x05005713, 0x95BF4A82, 0xE2B87A14, 0x7BB12BAE, 0x0CB61B38, 0x92D28E9B, 0xE5D5BE0D, 0x7CDCEFB7, 0x0BDBDF21, 0x86D3D2D4, 0xF1D4E242, 0x68DDB3F8, 0x1FDA836E, 0x81BE16CD, 0xF6B9265B, 0x6FB077E1, 0x18B74777, 0x88085AE6, 0xFF0F6A70, 0x66063BCA, 0x11010B5C, 0x8F659EFF, 0xF862AE69, 0x616BFFD3, 0x166CCF45, 0xA00AE278, 0xD70DD2EE, 0x4E048354, 0x3903B3C2, 0xA7672661, 0xD06016F7, 0x4969474D, 0x3E6E77DB, 0xAED16A4A, 0xD9D65ADC, 0x40DF0B66, 0x37D83BF0, 0xA9BCAE53, 0xDEBB9EC5, 0x47B2CF7F, 0x30B5FFE9, 0xBDBDF21C, 0xCABAC28A, 0x53B39330, 0x24B4A3A6, 0xBAD03605, 0xCDD70693, 0x54DE5729, 0x23D967BF, 0xB3667A2E, 0xC4614AB8, 0x5D681B02, 0x2A6F2B94, 0xB40BBE37, 0xC30C8EA1, 0x5A05DF1B, 0x2D02EF8D }; unsigned int crc = ~0u; int i; for (i=0; i < len; ++i) crc = (crc >> 8) ^ crc_table[buffer[i] ^ (crc & 0xff)]; return ~crc; #endif } #define stbiw__wpng4(o,a,b,c,d) ((o)[0]=STBIW_UCHAR(a),(o)[1]=STBIW_UCHAR(b),(o)[2]=STBIW_UCHAR(c),(o)[3]=STBIW_UCHAR(d),(o)+=4) #define stbiw__wp32(data,v) stbiw__wpng4(data, (v)>>24,(v)>>16,(v)>>8,(v)); #define stbiw__wptag(data,s) stbiw__wpng4(data, s[0],s[1],s[2],s[3]) static void stbiw__wpcrc(unsigned char **data, int len) { unsigned int crc = stbiw__crc32(*data - len - 4, len+4); stbiw__wp32(*data, crc); } static unsigned char stbiw__paeth(int a, int b, int c) { int p = a + b - c, pa = abs(p-a), pb = abs(p-b), pc = abs(p-c); if (pa <= pb && pa <= pc) return STBIW_UCHAR(a); if (pb <= pc) return STBIW_UCHAR(b); return STBIW_UCHAR(c); } // @OPTIMIZE: provide an option that always forces left-predict or paeth predict static void stbiw__encode_png_line(unsigned char *pixels, int stride_bytes, int width, int height, int y, int n, int filter_type, signed char *line_buffer) { static int mapping[] = { 0,1,2,3,4 }; static int firstmap[] = { 0,1,0,5,6 }; int *mymap = (y != 0) ? mapping : firstmap; int i; int type = mymap[filter_type]; unsigned char *z = pixels + stride_bytes * (stbi__flip_vertically_on_write ? height-1-y : y); int signed_stride = stbi__flip_vertically_on_write ? -stride_bytes : stride_bytes; if (type==0) { memcpy(line_buffer, z, width*n); return; } // first loop isn't optimized since it's just one pixel for (i = 0; i < n; ++i) { switch (type) { case 1: line_buffer[i] = z[i]; break; case 2: line_buffer[i] = z[i] - z[i-signed_stride]; break; case 3: line_buffer[i] = z[i] - (z[i-signed_stride]>>1); break; case 4: line_buffer[i] = (signed char) (z[i] - stbiw__paeth(0,z[i-signed_stride],0)); break; case 5: line_buffer[i] = z[i]; break; case 6: line_buffer[i] = z[i]; break; } } switch (type) { case 1: for (i=n; i < width*n; ++i) line_buffer[i] = z[i] - z[i-n]; break; case 2: for (i=n; i < width*n; ++i) line_buffer[i] = z[i] - z[i-signed_stride]; break; case 3: for (i=n; i < width*n; ++i) line_buffer[i] = z[i] - ((z[i-n] + z[i-signed_stride])>>1); break; case 4: for (i=n; i < width*n; ++i) line_buffer[i] = z[i] - stbiw__paeth(z[i-n], z[i-signed_stride], z[i-signed_stride-n]); break; case 5: for (i=n; i < width*n; ++i) line_buffer[i] = z[i] - (z[i-n]>>1); break; case 6: for (i=n; i < width*n; ++i) line_buffer[i] = z[i] - stbiw__paeth(z[i-n], 0,0); break; } } STBIWDEF unsigned char *stbi_write_png_to_mem(const unsigned char *pixels, int stride_bytes, int x, int y, int n, int *out_len) { int force_filter = stbi_write_force_png_filter; int ctype[5] = { -1, 0, 4, 2, 6 }; unsigned char sig[8] = { 137,80,78,71,13,10,26,10 }; unsigned char *out,*o, *filt, *zlib; signed char *line_buffer; int j,zlen; if (stride_bytes == 0) stride_bytes = x * n; if (force_filter >= 5) { force_filter = -1; } filt = (unsigned char *) STBIW_MALLOC((x*n+1) * y); if (!filt) return 0; line_buffer = (signed char *) STBIW_MALLOC(x * n); if (!line_buffer) { STBIW_FREE(filt); return 0; } for (j=0; j < y; ++j) { int filter_type; if (force_filter > -1) { filter_type = force_filter; stbiw__encode_png_line((unsigned char*)(pixels), stride_bytes, x, y, j, n, force_filter, line_buffer); } else { // Estimate the best filter by running through all of them: int best_filter = 0, best_filter_val = 0x7fffffff, est, i; for (filter_type = 0; filter_type < 5; filter_type++) { stbiw__encode_png_line((unsigned char*)(pixels), stride_bytes, x, y, j, n, filter_type, line_buffer); // Estimate the entropy of the line using this filter; the less, the better. est = 0; for (i = 0; i < x*n; ++i) { est += abs((signed char) line_buffer[i]); } if (est < best_filter_val) { best_filter_val = est; best_filter = filter_type; } } if (filter_type != best_filter) { // If the last iteration already got us the best filter, don't redo it stbiw__encode_png_line((unsigned char*)(pixels), stride_bytes, x, y, j, n, best_filter, line_buffer); filter_type = best_filter; } } // when we get here, filter_type contains the filter type, and line_buffer contains the data filt[j*(x*n+1)] = (unsigned char) filter_type; STBIW_MEMMOVE(filt+j*(x*n+1)+1, line_buffer, x*n); } STBIW_FREE(line_buffer); zlib = stbi_zlib_compress(filt, y*( x*n+1), &zlen, stbi_write_png_compression_level); STBIW_FREE(filt); if (!zlib) return 0; // each tag requires 12 bytes of overhead out = (unsigned char *) STBIW_MALLOC(8 + 12+13 + 12+zlen + 12); if (!out) return 0; *out_len = 8 + 12+13 + 12+zlen + 12; o=out; STBIW_MEMMOVE(o,sig,8); o+= 8; stbiw__wp32(o, 13); // header length stbiw__wptag(o, "IHDR"); stbiw__wp32(o, x); stbiw__wp32(o, y); *o++ = 8; *o++ = STBIW_UCHAR(ctype[n]); *o++ = 0; *o++ = 0; *o++ = 0; stbiw__wpcrc(&o,13); stbiw__wp32(o, zlen); stbiw__wptag(o, "IDAT"); STBIW_MEMMOVE(o, zlib, zlen); o += zlen; STBIW_FREE(zlib); stbiw__wpcrc(&o, zlen); stbiw__wp32(o,0); stbiw__wptag(o, "IEND"); stbiw__wpcrc(&o,0); STBIW_ASSERT(o == out + *out_len); return out; } #ifndef STBI_WRITE_NO_STDIO STBIWDEF int stbi_write_png(char const *filename, int x, int y, int comp, const void *data, int stride_bytes) { FILE *f; int len; unsigned char *png = stbi_write_png_to_mem((const unsigned char *) data, stride_bytes, x, y, comp, &len); if (png == NULL) return 0; f = stbiw__fopen(filename, "wb"); if (!f) { STBIW_FREE(png); return 0; } fwrite(png, 1, len, f); fclose(f); STBIW_FREE(png); return 1; } #endif STBIWDEF int stbi_write_png_to_func(stbi_write_func *func, void *context, int x, int y, int comp, const void *data, int stride_bytes) { int len; unsigned char *png = stbi_write_png_to_mem((const unsigned char *) data, stride_bytes, x, y, comp, &len); if (png == NULL) return 0; func(context, png, len); STBIW_FREE(png); return 1; } /* *************************************************************************** * * JPEG writer * * This is based on Jon Olick's jo_jpeg.cpp: * public domain Simple, Minimalistic JPEG writer - http://www.jonolick.com/code.html */ static const unsigned char stbiw__jpg_ZigZag[] = { 0,1,5,6,14,15,27,28,2,4,7,13,16,26,29,42,3,8,12,17,25,30,41,43,9,11,18, 24,31,40,44,53,10,19,23,32,39,45,52,54,20,22,33,38,46,51,55,60,21,34,37,47,50,56,59,61,35,36,48,49,57,58,62,63 }; static void stbiw__jpg_writeBits(stbi__write_context *s, int *bitBufP, int *bitCntP, const unsigned short *bs) { int bitBuf = *bitBufP, bitCnt = *bitCntP; bitCnt += bs[1]; bitBuf |= bs[0] << (24 - bitCnt); while(bitCnt >= 8) { unsigned char c = (bitBuf >> 16) & 255; stbiw__putc(s, c); if(c == 255) { stbiw__putc(s, 0); } bitBuf <<= 8; bitCnt -= 8; } *bitBufP = bitBuf; *bitCntP = bitCnt; } static void stbiw__jpg_DCT(float *d0p, float *d1p, float *d2p, float *d3p, float *d4p, float *d5p, float *d6p, float *d7p) { float d0 = *d0p, d1 = *d1p, d2 = *d2p, d3 = *d3p, d4 = *d4p, d5 = *d5p, d6 = *d6p, d7 = *d7p; float z1, z2, z3, z4, z5, z11, z13; float tmp0 = d0 + d7; float tmp7 = d0 - d7; float tmp1 = d1 + d6; float tmp6 = d1 - d6; float tmp2 = d2 + d5; float tmp5 = d2 - d5; float tmp3 = d3 + d4; float tmp4 = d3 - d4; // Even part float tmp10 = tmp0 + tmp3; // phase 2 float tmp13 = tmp0 - tmp3; float tmp11 = tmp1 + tmp2; float tmp12 = tmp1 - tmp2; d0 = tmp10 + tmp11; // phase 3 d4 = tmp10 - tmp11; z1 = (tmp12 + tmp13) * 0.707106781f; // c4 d2 = tmp13 + z1; // phase 5 d6 = tmp13 - z1; // Odd part tmp10 = tmp4 + tmp5; // phase 2 tmp11 = tmp5 + tmp6; tmp12 = tmp6 + tmp7; // The rotator is modified from fig 4-8 to avoid extra negations. z5 = (tmp10 - tmp12) * 0.382683433f; // c6 z2 = tmp10 * 0.541196100f + z5; // c2-c6 z4 = tmp12 * 1.306562965f + z5; // c2+c6 z3 = tmp11 * 0.707106781f; // c4 z11 = tmp7 + z3; // phase 5 z13 = tmp7 - z3; *d5p = z13 + z2; // phase 6 *d3p = z13 - z2; *d1p = z11 + z4; *d7p = z11 - z4; *d0p = d0; *d2p = d2; *d4p = d4; *d6p = d6; } static void stbiw__jpg_calcBits(int val, unsigned short bits[2]) { int tmp1 = val < 0 ? -val : val; val = val < 0 ? val-1 : val; bits[1] = 1; while(tmp1 >>= 1) { ++bits[1]; } bits[0] = val & ((1<0)&&(DU[end0pos]==0); --end0pos) { } // end0pos = first element in reverse order !=0 if(end0pos == 0) { stbiw__jpg_writeBits(s, bitBuf, bitCnt, EOB); return DU[0]; } for(i = 1; i <= end0pos; ++i) { int startpos = i; int nrzeroes; unsigned short bits[2]; for (; DU[i]==0 && i<=end0pos; ++i) { } nrzeroes = i-startpos; if ( nrzeroes >= 16 ) { int lng = nrzeroes>>4; int nrmarker; for (nrmarker=1; nrmarker <= lng; ++nrmarker) stbiw__jpg_writeBits(s, bitBuf, bitCnt, M16zeroes); nrzeroes &= 15; } stbiw__jpg_calcBits(DU[i], bits); stbiw__jpg_writeBits(s, bitBuf, bitCnt, HTAC[(nrzeroes<<4)+bits[1]]); stbiw__jpg_writeBits(s, bitBuf, bitCnt, bits); } if(end0pos != 63) { stbiw__jpg_writeBits(s, bitBuf, bitCnt, EOB); } return DU[0]; } static int stbi_write_jpg_core(stbi__write_context *s, int width, int height, int comp, const void* data, int quality) { // Constants that don't pollute global namespace static const unsigned char std_dc_luminance_nrcodes[] = {0,0,1,5,1,1,1,1,1,1,0,0,0,0,0,0,0}; static const unsigned char std_dc_luminance_values[] = {0,1,2,3,4,5,6,7,8,9,10,11}; static const unsigned char std_ac_luminance_nrcodes[] = {0,0,2,1,3,3,2,4,3,5,5,4,4,0,0,1,0x7d}; static const unsigned char std_ac_luminance_values[] = { 0x01,0x02,0x03,0x00,0x04,0x11,0x05,0x12,0x21,0x31,0x41,0x06,0x13,0x51,0x61,0x07,0x22,0x71,0x14,0x32,0x81,0x91,0xa1,0x08, 0x23,0x42,0xb1,0xc1,0x15,0x52,0xd1,0xf0,0x24,0x33,0x62,0x72,0x82,0x09,0x0a,0x16,0x17,0x18,0x19,0x1a,0x25,0x26,0x27,0x28, 0x29,0x2a,0x34,0x35,0x36,0x37,0x38,0x39,0x3a,0x43,0x44,0x45,0x46,0x47,0x48,0x49,0x4a,0x53,0x54,0x55,0x56,0x57,0x58,0x59, 0x5a,0x63,0x64,0x65,0x66,0x67,0x68,0x69,0x6a,0x73,0x74,0x75,0x76,0x77,0x78,0x79,0x7a,0x83,0x84,0x85,0x86,0x87,0x88,0x89, 0x8a,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9a,0xa2,0xa3,0xa4,0xa5,0xa6,0xa7,0xa8,0xa9,0xaa,0xb2,0xb3,0xb4,0xb5,0xb6, 0xb7,0xb8,0xb9,0xba,0xc2,0xc3,0xc4,0xc5,0xc6,0xc7,0xc8,0xc9,0xca,0xd2,0xd3,0xd4,0xd5,0xd6,0xd7,0xd8,0xd9,0xda,0xe1,0xe2, 0xe3,0xe4,0xe5,0xe6,0xe7,0xe8,0xe9,0xea,0xf1,0xf2,0xf3,0xf4,0xf5,0xf6,0xf7,0xf8,0xf9,0xfa }; static const unsigned char std_dc_chrominance_nrcodes[] = {0,0,3,1,1,1,1,1,1,1,1,1,0,0,0,0,0}; static const unsigned char std_dc_chrominance_values[] = {0,1,2,3,4,5,6,7,8,9,10,11}; static const unsigned char std_ac_chrominance_nrcodes[] = {0,0,2,1,2,4,4,3,4,7,5,4,4,0,1,2,0x77}; static const unsigned char std_ac_chrominance_values[] = { 0x00,0x01,0x02,0x03,0x11,0x04,0x05,0x21,0x31,0x06,0x12,0x41,0x51,0x07,0x61,0x71,0x13,0x22,0x32,0x81,0x08,0x14,0x42,0x91, 0xa1,0xb1,0xc1,0x09,0x23,0x33,0x52,0xf0,0x15,0x62,0x72,0xd1,0x0a,0x16,0x24,0x34,0xe1,0x25,0xf1,0x17,0x18,0x19,0x1a,0x26, 0x27,0x28,0x29,0x2a,0x35,0x36,0x37,0x38,0x39,0x3a,0x43,0x44,0x45,0x46,0x47,0x48,0x49,0x4a,0x53,0x54,0x55,0x56,0x57,0x58, 0x59,0x5a,0x63,0x64,0x65,0x66,0x67,0x68,0x69,0x6a,0x73,0x74,0x75,0x76,0x77,0x78,0x79,0x7a,0x82,0x83,0x84,0x85,0x86,0x87, 0x88,0x89,0x8a,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9a,0xa2,0xa3,0xa4,0xa5,0xa6,0xa7,0xa8,0xa9,0xaa,0xb2,0xb3,0xb4, 0xb5,0xb6,0xb7,0xb8,0xb9,0xba,0xc2,0xc3,0xc4,0xc5,0xc6,0xc7,0xc8,0xc9,0xca,0xd2,0xd3,0xd4,0xd5,0xd6,0xd7,0xd8,0xd9,0xda, 0xe2,0xe3,0xe4,0xe5,0xe6,0xe7,0xe8,0xe9,0xea,0xf2,0xf3,0xf4,0xf5,0xf6,0xf7,0xf8,0xf9,0xfa }; // Huffman tables static const unsigned short YDC_HT[256][2] = { {0,2},{2,3},{3,3},{4,3},{5,3},{6,3},{14,4},{30,5},{62,6},{126,7},{254,8},{510,9}}; static const unsigned short UVDC_HT[256][2] = { {0,2},{1,2},{2,2},{6,3},{14,4},{30,5},{62,6},{126,7},{254,8},{510,9},{1022,10},{2046,11}}; static const unsigned short YAC_HT[256][2] = { {10,4},{0,2},{1,2},{4,3},{11,4},{26,5},{120,7},{248,8},{1014,10},{65410,16},{65411,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, {12,4},{27,5},{121,7},{502,9},{2038,11},{65412,16},{65413,16},{65414,16},{65415,16},{65416,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, {28,5},{249,8},{1015,10},{4084,12},{65417,16},{65418,16},{65419,16},{65420,16},{65421,16},{65422,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, {58,6},{503,9},{4085,12},{65423,16},{65424,16},{65425,16},{65426,16},{65427,16},{65428,16},{65429,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, {59,6},{1016,10},{65430,16},{65431,16},{65432,16},{65433,16},{65434,16},{65435,16},{65436,16},{65437,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, {122,7},{2039,11},{65438,16},{65439,16},{65440,16},{65441,16},{65442,16},{65443,16},{65444,16},{65445,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, {123,7},{4086,12},{65446,16},{65447,16},{65448,16},{65449,16},{65450,16},{65451,16},{65452,16},{65453,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, {250,8},{4087,12},{65454,16},{65455,16},{65456,16},{65457,16},{65458,16},{65459,16},{65460,16},{65461,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, {504,9},{32704,15},{65462,16},{65463,16},{65464,16},{65465,16},{65466,16},{65467,16},{65468,16},{65469,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, {505,9},{65470,16},{65471,16},{65472,16},{65473,16},{65474,16},{65475,16},{65476,16},{65477,16},{65478,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, {506,9},{65479,16},{65480,16},{65481,16},{65482,16},{65483,16},{65484,16},{65485,16},{65486,16},{65487,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, {1017,10},{65488,16},{65489,16},{65490,16},{65491,16},{65492,16},{65493,16},{65494,16},{65495,16},{65496,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, {1018,10},{65497,16},{65498,16},{65499,16},{65500,16},{65501,16},{65502,16},{65503,16},{65504,16},{65505,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, {2040,11},{65506,16},{65507,16},{65508,16},{65509,16},{65510,16},{65511,16},{65512,16},{65513,16},{65514,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, {65515,16},{65516,16},{65517,16},{65518,16},{65519,16},{65520,16},{65521,16},{65522,16},{65523,16},{65524,16},{0,0},{0,0},{0,0},{0,0},{0,0}, {2041,11},{65525,16},{65526,16},{65527,16},{65528,16},{65529,16},{65530,16},{65531,16},{65532,16},{65533,16},{65534,16},{0,0},{0,0},{0,0},{0,0},{0,0} }; static const unsigned short UVAC_HT[256][2] = { {0,2},{1,2},{4,3},{10,4},{24,5},{25,5},{56,6},{120,7},{500,9},{1014,10},{4084,12},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, {11,4},{57,6},{246,8},{501,9},{2038,11},{4085,12},{65416,16},{65417,16},{65418,16},{65419,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, {26,5},{247,8},{1015,10},{4086,12},{32706,15},{65420,16},{65421,16},{65422,16},{65423,16},{65424,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, {27,5},{248,8},{1016,10},{4087,12},{65425,16},{65426,16},{65427,16},{65428,16},{65429,16},{65430,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, {58,6},{502,9},{65431,16},{65432,16},{65433,16},{65434,16},{65435,16},{65436,16},{65437,16},{65438,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, {59,6},{1017,10},{65439,16},{65440,16},{65441,16},{65442,16},{65443,16},{65444,16},{65445,16},{65446,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, {121,7},{2039,11},{65447,16},{65448,16},{65449,16},{65450,16},{65451,16},{65452,16},{65453,16},{65454,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, {122,7},{2040,11},{65455,16},{65456,16},{65457,16},{65458,16},{65459,16},{65460,16},{65461,16},{65462,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, {249,8},{65463,16},{65464,16},{65465,16},{65466,16},{65467,16},{65468,16},{65469,16},{65470,16},{65471,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, {503,9},{65472,16},{65473,16},{65474,16},{65475,16},{65476,16},{65477,16},{65478,16},{65479,16},{65480,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, {504,9},{65481,16},{65482,16},{65483,16},{65484,16},{65485,16},{65486,16},{65487,16},{65488,16},{65489,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, {505,9},{65490,16},{65491,16},{65492,16},{65493,16},{65494,16},{65495,16},{65496,16},{65497,16},{65498,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, {506,9},{65499,16},{65500,16},{65501,16},{65502,16},{65503,16},{65504,16},{65505,16},{65506,16},{65507,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, {2041,11},{65508,16},{65509,16},{65510,16},{65511,16},{65512,16},{65513,16},{65514,16},{65515,16},{65516,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, {16352,14},{65517,16},{65518,16},{65519,16},{65520,16},{65521,16},{65522,16},{65523,16},{65524,16},{65525,16},{0,0},{0,0},{0,0},{0,0},{0,0}, {1018,10},{32707,15},{65526,16},{65527,16},{65528,16},{65529,16},{65530,16},{65531,16},{65532,16},{65533,16},{65534,16},{0,0},{0,0},{0,0},{0,0},{0,0} }; static const int YQT[] = {16,11,10,16,24,40,51,61,12,12,14,19,26,58,60,55,14,13,16,24,40,57,69,56,14,17,22,29,51,87,80,62,18,22, 37,56,68,109,103,77,24,35,55,64,81,104,113,92,49,64,78,87,103,121,120,101,72,92,95,98,112,100,103,99}; static const int UVQT[] = {17,18,24,47,99,99,99,99,18,21,26,66,99,99,99,99,24,26,56,99,99,99,99,99,47,66,99,99,99,99,99,99, 99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99}; static const float aasf[] = { 1.0f * 2.828427125f, 1.387039845f * 2.828427125f, 1.306562965f * 2.828427125f, 1.175875602f * 2.828427125f, 1.0f * 2.828427125f, 0.785694958f * 2.828427125f, 0.541196100f * 2.828427125f, 0.275899379f * 2.828427125f }; int row, col, i, k; float fdtbl_Y[64], fdtbl_UV[64]; unsigned char YTable[64], UVTable[64]; if(!data || !width || !height || comp > 4 || comp < 1) { return 0; } quality = quality ? quality : 90; quality = quality < 1 ? 1 : quality > 100 ? 100 : quality; quality = quality < 50 ? 5000 / quality : 200 - quality * 2; for(i = 0; i < 64; ++i) { int uvti, yti = (YQT[i]*quality+50)/100; YTable[stbiw__jpg_ZigZag[i]] = (unsigned char) (yti < 1 ? 1 : yti > 255 ? 255 : yti); uvti = (UVQT[i]*quality+50)/100; UVTable[stbiw__jpg_ZigZag[i]] = (unsigned char) (uvti < 1 ? 1 : uvti > 255 ? 255 : uvti); } for(row = 0, k = 0; row < 8; ++row) { for(col = 0; col < 8; ++col, ++k) { fdtbl_Y[k] = 1 / (YTable [stbiw__jpg_ZigZag[k]] * aasf[row] * aasf[col]); fdtbl_UV[k] = 1 / (UVTable[stbiw__jpg_ZigZag[k]] * aasf[row] * aasf[col]); } } // Write Headers { static const unsigned char head0[] = { 0xFF,0xD8,0xFF,0xE0,0,0x10,'J','F','I','F',0,1,1,0,0,1,0,1,0,0,0xFF,0xDB,0,0x84,0 }; static const unsigned char head2[] = { 0xFF,0xDA,0,0xC,3,1,0,2,0x11,3,0x11,0,0x3F,0 }; const unsigned char head1[] = { 0xFF,0xC0,0,0x11,8,(unsigned char)(height>>8),STBIW_UCHAR(height),(unsigned char)(width>>8),STBIW_UCHAR(width), 3,1,0x11,0,2,0x11,1,3,0x11,1,0xFF,0xC4,0x01,0xA2,0 }; s->func(s->context, (void*)head0, sizeof(head0)); s->func(s->context, (void*)YTable, sizeof(YTable)); stbiw__putc(s, 1); s->func(s->context, UVTable, sizeof(UVTable)); s->func(s->context, (void*)head1, sizeof(head1)); s->func(s->context, (void*)(std_dc_luminance_nrcodes+1), sizeof(std_dc_luminance_nrcodes)-1); s->func(s->context, (void*)std_dc_luminance_values, sizeof(std_dc_luminance_values)); stbiw__putc(s, 0x10); // HTYACinfo s->func(s->context, (void*)(std_ac_luminance_nrcodes+1), sizeof(std_ac_luminance_nrcodes)-1); s->func(s->context, (void*)std_ac_luminance_values, sizeof(std_ac_luminance_values)); stbiw__putc(s, 1); // HTUDCinfo s->func(s->context, (void*)(std_dc_chrominance_nrcodes+1), sizeof(std_dc_chrominance_nrcodes)-1); s->func(s->context, (void*)std_dc_chrominance_values, sizeof(std_dc_chrominance_values)); stbiw__putc(s, 0x11); // HTUACinfo s->func(s->context, (void*)(std_ac_chrominance_nrcodes+1), sizeof(std_ac_chrominance_nrcodes)-1); s->func(s->context, (void*)std_ac_chrominance_values, sizeof(std_ac_chrominance_values)); s->func(s->context, (void*)head2, sizeof(head2)); } // Encode 8x8 macroblocks { static const unsigned short fillBits[] = {0x7F, 7}; const unsigned char *imageData = (const unsigned char *)data; int DCY=0, DCU=0, DCV=0; int bitBuf=0, bitCnt=0; // comp == 2 is grey+alpha (alpha is ignored) int ofsG = comp > 2 ? 1 : 0, ofsB = comp > 2 ? 2 : 0; int x, y, pos; for(y = 0; y < height; y += 8) { for(x = 0; x < width; x += 8) { float YDU[64], UDU[64], VDU[64]; for(row = y, pos = 0; row < y+8; ++row) { // row >= height => use last input row int clamped_row = (row < height) ? row : height - 1; int base_p = (stbi__flip_vertically_on_write ? (height-1-clamped_row) : clamped_row)*width*comp; for(col = x; col < x+8; ++col, ++pos) { float r, g, b; // if col >= width => use pixel from last input column int p = base_p + ((col < width) ? col : (width-1))*comp; r = imageData[p+0]; g = imageData[p+ofsG]; b = imageData[p+ofsB]; YDU[pos]=+0.29900f*r+0.58700f*g+0.11400f*b-128; UDU[pos]=-0.16874f*r-0.33126f*g+0.50000f*b; VDU[pos]=+0.50000f*r-0.41869f*g-0.08131f*b; } } DCY = stbiw__jpg_processDU(s, &bitBuf, &bitCnt, YDU, fdtbl_Y, DCY, YDC_HT, YAC_HT); DCU = stbiw__jpg_processDU(s, &bitBuf, &bitCnt, UDU, fdtbl_UV, DCU, UVDC_HT, UVAC_HT); DCV = stbiw__jpg_processDU(s, &bitBuf, &bitCnt, VDU, fdtbl_UV, DCV, UVDC_HT, UVAC_HT); } } // Do the bit alignment of the EOI marker stbiw__jpg_writeBits(s, &bitBuf, &bitCnt, fillBits); } // EOI stbiw__putc(s, 0xFF); stbiw__putc(s, 0xD9); return 1; } STBIWDEF int stbi_write_jpg_to_func(stbi_write_func *func, void *context, int x, int y, int comp, const void *data, int quality) { stbi__write_context s; stbi__start_write_callbacks(&s, func, context); return stbi_write_jpg_core(&s, x, y, comp, (void *) data, quality); } #ifndef STBI_WRITE_NO_STDIO STBIWDEF int stbi_write_jpg(char const *filename, int x, int y, int comp, const void *data, int quality) { stbi__write_context s; if (stbi__start_write_file(&s,filename)) { int r = stbi_write_jpg_core(&s, x, y, comp, data, quality); stbi__end_write_file(&s); return r; } else return 0; } #endif #endif // STB_IMAGE_WRITE_IMPLEMENTATION /* Revision history 1.10 (2019-02-07) support utf8 filenames in Windows; fix warnings and platform ifdefs 1.09 (2018-02-11) fix typo in zlib quality API, improve STB_I_W_STATIC in C++ 1.08 (2018-01-29) add stbi__flip_vertically_on_write, external zlib, zlib quality, choose PNG filter 1.07 (2017-07-24) doc fix 1.06 (2017-07-23) writing JPEG (using Jon Olick's code) 1.05 ??? 1.04 (2017-03-03) monochrome BMP expansion 1.03 ??? 1.02 (2016-04-02) avoid allocating large structures on the stack 1.01 (2016-01-16) STBIW_REALLOC_SIZED: support allocators with no realloc support avoid race-condition in crc initialization minor compile issues 1.00 (2015-09-14) installable file IO function 0.99 (2015-09-13) warning fixes; TGA rle support 0.98 (2015-04-08) added STBIW_MALLOC, STBIW_ASSERT etc 0.97 (2015-01-18) fixed HDR asserts, rewrote HDR rle logic 0.96 (2015-01-17) add HDR output fix monochrome BMP 0.95 (2014-08-17) add monochrome TGA output 0.94 (2014-05-31) rename private functions to avoid conflicts with stb_image.h 0.93 (2014-05-27) warning fixes 0.92 (2010-08-01) casts to unsigned char to fix warnings 0.91 (2010-07-17) first public release 0.90 first internal release */ /* ------------------------------------------------------------------------------ This software is available under 2 licenses -- choose whichever you prefer. ------------------------------------------------------------------------------ ALTERNATIVE A - MIT License Copyright (c) 2017 Sean Barrett 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. ------------------------------------------------------------------------------ ALTERNATIVE B - Public Domain (www.unlicense.org) This is free and unencumbered software released into the public domain. Anyone is free to copy, modify, publish, use, compile, sell, or distribute this software, either in source code form or as a compiled binary, for any purpose, commercial or non-commercial, and by any means. In jurisdictions that recognize copyright laws, the author or authors of this software dedicate any and all copyright interest in the software to the public domain. We make this dedication for the benefit of the public at large and to the detriment of our heirs and successors. We intend this dedication to be an overt act of relinquishment in perpetuity of all present and future rights to this software under copyright law. 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 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. ------------------------------------------------------------------------------ */ ================================================ FILE: deps/lib/arm64/libSDL3.so.0 ================================================ [File too large to display: 13.9 MB] ================================================ FILE: deps/lib/arm64/libSDL3.so.0.5.0 ================================================ [File too large to display: 13.9 MB] ================================================ FILE: deps/lib/linux64/libSDL3.so.0 ================================================ [File too large to display: 13.7 MB] ================================================ FILE: deps/lib/linux64/libSDL3.so.0.5.0 ================================================ [File too large to display: 13.7 MB] ================================================ FILE: docs/ACTION_SYSTEM.md ================================================ # War1-C Action System Documentation ## Overview The Action System is the core animation and behavior framework in War1-C. It manages all animated sequences for game units, including walking, attacking, harvesting, repairing, building, and dying animations. The system is data-driven, frame-based, and directional-aware, meaning animations can adapt based on unit direction (8 directions). Each unit type (Footman, Grunt, Peasant, Peon, Archer, etc.) has pre-defined action definitions that describe exactly what happens frame-by-frame during each animation sequence. --- ## Architecture ### Core Concepts The action system operates on three levels: 1. **Action Definition (WarUnitActionDef)** - Static, pre-defined animation data loaded once at game start 2. **Action State (WarUnitAction)** - Per-unit runtime state tracking progress through an action 3. **Action Step (WarUnitActionStep)** - Individual atomic commands executed during an action (frame, wait, sound, attack) ### Key Types #### `WarUnitActionStepType` - Enum of Step Commands Each step in an action is one of these types: ```c typedef enum _WarUnitActionStepType { WAR_ACTION_STEP_NONE, // No-op (default) WAR_ACTION_STEP_FRAME, // Display a sprite frame WAR_ACTION_STEP_WAIT, // Pause for N frames WAR_ACTION_STEP_ATTACK, // Trigger attack damage event WAR_ACTION_STEP_SOUND_SWORD, // Play sword swing sound WAR_ACTION_STEP_SOUND_FIST, // Play punch sound WAR_ACTION_STEP_SOUND_FIREBALL, // Play fireball sound WAR_ACTION_STEP_SOUND_CHOPPING, // Play chopping/harvesting sound WAR_ACTION_STEP_SOUND_CATAPULT, // Play catapult launch sound WAR_ACTION_STEP_SOUND_ARROW, // Play arrow shot sound WAR_ACTION_STEP_SOUND_LIGHTNING, // Play lightning sound } WarUnitActionStepType; ``` #### `WarUnitActionType` - Enum of Action Categories ```c typedef enum _WarUnitActionType { WAR_ACTION_TYPE_NONE = -1, WAR_ACTION_TYPE_IDLE, // Standing/waiting (loops) WAR_ACTION_TYPE_WALK, // Movement animation (loops) WAR_ACTION_TYPE_ATTACK, // Combat swing/cast (loops) WAR_ACTION_TYPE_DEATH, // Unit dies (loops at end frame) WAR_ACTION_TYPE_HARVEST, // Worker gathering resources (loops) WAR_ACTION_TYPE_REPAIR, // Worker repairing buildings (loops) WAR_ACTION_TYPE_BUILD, // Worker building structure (loops) WAR_ACTION_TYPE_COUNT } WarUnitActionType; ``` #### `WarUnitActionStatus` - Execution State ```c typedef enum _WarUnitActionStatus { WAR_ACTION_NOT_STARTED, // Never begun or explicitly reset WAR_ACTION_RUNNING, // Currently playing WAR_ACTION_FINISHED, // Completed (for non-looping actions) } WarUnitActionStatus; ``` #### `WarUnitActionStep` - Single Step in an Action ```c struct _WarUnitActionStep { WarUnitActionStepType type; // What to do s32 param; // Type-dependent parameter (frame index, duration, etc.) }; ``` #### `WarUnitActionDef` - Full Animation Definition ```c struct _WarUnitActionDef { WarUnitActionType type; // IDLE, WALK, ATTACK, etc. bool directional; // Does direction affect frame offset? bool loop; // Should this repeat when finished? WarUnitActionStepList steps; // Array of all steps to execute }; ``` Directional actions (walk, attack, etc.) adapt the sprite frame index based on unit direction. Non-directional actions (build) always show the same animation regardless of facing. #### `WarUnitAction` - Runtime Action State ```c struct _WarUnitAction { WarUnitActionStatus status; // NOT_STARTED, RUNNING, or FINISHED f32 scale; // Speed multiplier (1.0 = normal, 2.0 = twice as fast) f32 waitCount; // Frames remaining in current WAIT step s32 stepIndex; // Position in action's step array WarUnitActionStepType lastActionStep; // Last ATTACK step played this frame WarUnitActionStepType lastSoundStep; // Last SOUND step played this frame }; ``` --- ## API Reference ### Initialization #### `void wact_initUnitActionDefs(void)` **Purpose:** Bootstrap all unit action definitions at game start. **When to call:** Once during game initialization (called from `wg_initGame()`). **What it does:** - Initializes the global action definition table for all unit types - Pre-computes frame sequences based on spritesheet layout - Sets up timing parameters (walk speed, attack speed, etc.) **Example:** ```c void wg_initGame(WarContext* context) { // ... other init code ... wact_initUnitActionDefs(); // Action system ready // ... rest of init ... } ``` --- ### Per-Unit Setup #### `void wact_addUnitActions(WarEntity* entity)` **Purpose:** Initialize action state for a newly created unit. **Parameters:** - `entity` - The unit entity to set up **When to call:** When a unit is spawned (called during entity creation). **What it does:** - Allocates and zeroes the `actions` array on the unit component - Sets all actions to NOT_STARTED status - Sets scale to 1.0 and clears frame counters **Example:** ```c // In unit creation code WarEntity* footman = we_createEntity(context, ...); wu_initUnit(footman, WAR_UNIT_FOOTMAN); wact_addUnitActions(footman); // Ready to animate ``` --- ### Action Control #### `void wact_setAction(WarContext* context, WarEntity* entity, WarUnitActionType type, bool reset, f32 scale)` **Purpose:** Transition a unit to a new action or update the current action's parameters. **Parameters:** - `context` - Game context (for potential future updates) - `entity` - Unit to animate - `type` - Target action type (IDLE, WALK, ATTACK, etc.), or WAR_ACTION_TYPE_NONE to stop - `reset` - If true, restart from step 0; if false, resume or keep current progress - `scale` - Speed multiplier (1.0 = normal, 2.0 = 2x speed). Use -1.0 to keep current scale. **What it does:** - Changes the unit's `actionType` to the specified type - If `reset` is true, resets `stepIndex` to 0 and status to NOT_STARTED - If `scale >= 0`, updates the action's `scale` multiplier **Common usage patterns:** ```c // Start walking from the beginning (restart animation) wact_setAction(context, unit, WAR_ACTION_TYPE_WALK, true, 1.0f); // Start attacking from the beginning wact_setAction(context, unit, WAR_ACTION_TYPE_ATTACK, true, 1.0f); // Transition to idle without restarting (resume if paused) wact_setAction(context, unit, WAR_ACTION_TYPE_IDLE, false, 1.0f); // Stop animating wact_setAction(context, unit, WAR_ACTION_TYPE_NONE, false, 1.0f); // Keep current scale, just resume/restart wact_setAction(context, unit, WAR_ACTION_TYPE_WALK, true, -1.0f); ``` --- #### `void wact_updateAction(WarContext* context, WarEntity* entity)` **Purpose:** Advance an action by one frame and apply animation effects. **Parameters:** - `context` - Game context (includes `deltaTime`) - `entity` - Unit to update **When to call:** Every game loop frame (called from game update). **What it does:** 1. Checks if the unit has an active action 2. Decrements the wait counter based on delta time 3. When wait expires, advances to the next step 4. Processes all non-WAIT steps (FRAME, ATTACK, SOUND) 5. Applies directional frame offset for directional actions 6. Triggers sound effects and attack damage callbacks 7. Handles looping or finishing **Frame-by-Frame Breakdown:** ``` Loop iteration 1: - Current step: WAIT(6) - waitCount -= deltaTime - waitCount > 0? Yes, return early - No frame change Loop iteration 2-6: - waitCount becomes <= 0 - Advance to next step Loop iteration 7: - Current step: FRAME(5) - Process FRAME: display frame 5 (with directional offset) - stepIndex++ - Process next non-WAIT steps... - Eventually reach next WAIT, set waitCount ``` --- ### Query #### `s32 wact_getActionDuration(WarEntity* entity, WarUnitActionType type)` **Purpose:** Calculate the total duration of an action in frames. **Parameters:** - `entity` - Unit (used to look up the correct action definition by unit type) - `type` - Action type to query (IDLE, WALK, ATTACK, etc.) **Returns:** Total frame count (sum of all WAIT step durations) for that action. **Use cases:** - Predict when an action will finish - Delay other tasks until an action completes - Time enemy AI decisions **Example:** ```c s32 attackFrames = wact_getActionDuration(unit, WAR_ACTION_TYPE_ATTACK); // Player will be vulnerable for attackFrames/FRAMES_PER_SECONDS seconds schedulePlayerAction(attackFrames); ``` --- ## Data-Driven Action Definition ### How Actions Are Built Actions are built at initialization time by combining **action definition functions** that construct `WarUnitActionDef` objects. Each unit type gets custom actions based on its spritesheet layout. #### Frame Sequence Generation: `wact_getFrameNumbers()` The spritesheet for each unit contains: - Walk frames (consecutive) - Attack frames (consecutive) - Death frames (consecutive) These are interleaved in a specific order. The `wact_getFrameNumbers()` function takes the frame counts and spreads them across a visual grid: ``` Spritesheet layout (example: Footman with 5 directions, 5 walk, 5 attack, 3 death): Direction: N NE E SE S SW W NW Frame 1: W1 W2 W3 W4 W5 A1 A2 A3 Frame 2: A4 A5 D1 D2 D3 W1 W2 W3 ... This function remaps them so each direction gets the correct subset. ``` #### Action Definition Builders Several helper functions create standard actions: ##### `createWalkActionDef()` - Oscillating Walk Animation ```c static WarUnitActionDef createWalkActionDef( s32 nframes, // Number of walk frames (e.g., 5) s32 frames[], // Frame indices s32 walkSpeed, // Delay between each frame (e.g., 6) bool directional // Does direction matter? ) ``` Generates a looping walk by oscillating forward and backward through frames: ``` Sequence: [0, W, 0, W, 0] Then: [NW, NW-1, NW-2, NW-1] Loop ``` **Example setup:** ```c s32 walkFrames[] = {0, 5, 10, 15, 20}; // 5 walk frame offsets WarUnitActionDef walkDef = createWalkActionDef(5, walkFrames, 6, true); // Result: Smooth 8-directional walk with 6-frame timing ``` ##### `createAttackActionDef()` - Combat Swing with Sound & Damage ```c static WarUnitActionDef createAttackActionDef( s32 nframes, // Number of attack frames (e.g., 5) s32 frames[], // Frame indices s32 attackSpeed, // Delay between frames s32 attackSound, // Sound to play (e.g., WAR_ACTION_STEP_SOUND_SWORD) s32 coolOffTime, // Recovery frames after animation bool directional ) ``` Generates an attack that: - Cycles through frames - At the midpoint frame, triggers `WAR_ACTION_STEP_ATTACK` (damage event) - At the midpoint frame, plays the attack sound - Pads shorter attacks to normalize duration (5 frames max) - Adds cool-off time before next attack **Example:** ```c s32 attackFrames[] = {25, 30, 35, 40, 45}; WarUnitActionDef attackDef = createAttackActionDef( 5, attackFrames, 6, WAR_ACTION_STEP_SOUND_SWORD, 1, true ); // Result: Sword swing that damages at frame 3, plays "sword" sound, then waits 1 frame before idle ``` ##### `createHarvestActionDef()` - Resource Gathering ```c static WarUnitActionDef createHarvestActionDef( s32 nframes, // Number of harvest frames s32 frames[], s32 harvestSpeed, // Delay between frames s32 harvestSound, // Sound effect s32 coolOffTime, bool directional ) ``` Similar to attack but includes: - Initial 5-frame wait before starting (picking up stance) - Harvest sound and resource delivery trigger at midpoint - Used for chopping trees, mining gold, etc. ##### `createDeathActionDef()` - Unit Destruction ```c static WarUnitActionDef createDeathActionDef( s32 nframes, s32 frames[], s32 waitTime, // Delay between frames bool directional, bool doWait101Step // Some units use special 100+ frame wait for decay ) ``` Non-looping action that: - Plays through all frames once - Optionally adds a long pause before final frame (body decay) - Loops at the final frame (unit stays dead) --- ## Real-World Examples ### Example 1: Making a Unit Walk ```c WarEntity* grunt = // ... find or create unit ... // Start walking wact_setAction(context, grunt, WAR_ACTION_TYPE_WALK, true, 1.0f); // Each game frame: wact_updateAction(context, grunt); // - Advances through walk animation steps // - Updates sprite frame based on grunt's direction // - Loops seamlessly ``` ### Example 2: Attack Sequence ```c WarEntity* footman = // ... unit to attack ... WarEntity* target = // ... enemy unit ... // Start attacking wact_setAction(context, footman, WAR_ACTION_TYPE_ATTACK, true, 1.0f); // In game loop: wact_updateAction(context, footman); // When the midpoint frame is reached: // - WAR_ACTION_STEP_ATTACK is processed // - Attack callback fires, dealing damage to target // - Sword sound effect plays // - Animation continues through recovery frames ``` ### Example 3: Worker Harvesting ```c WarEntity* peasant = // ... worker unit ... // Start harvesting (chopping trees or mining) wact_setAction(context, peasant, WAR_ACTION_TYPE_HARVEST, true, 1.0f); // Loop: wact_updateAction(context, peasant); // - Waits 5 frames (pickup pose) // - Cycles through chop frames // - At midpoint, "chopping" sound plays // - Cooloff period before next harvest // - Loops back to start ``` ### Example 4: Speed Variation ```c WarEntity* knight = // ... mounted unit ... // Normal speed wact_setAction(context, knight, WAR_ACTION_TYPE_WALK, true, 1.0f); // Get faster (fleeing or upgraded) wact_setAction(context, knight, WAR_ACTION_TYPE_WALK, false, 1.5f); // All wait times are multiplied by 1.5, so animation plays 1.5x faster // Back to normal wact_setAction(context, knight, WAR_ACTION_TYPE_WALK, false, 1.0f); ``` ### Example 5: Querying Animation Duration ```c s32 deathFrames = wact_getActionDuration(unit, WAR_ACTION_TYPE_DEATH); // If deathFrames == 60 and FRAMES_PER_SECONDS == 50 // Then death takes 60/50 = 1.2 seconds // Schedule cleanup after death animation f32 deathDuration = (f32)deathFrames / FRAMES_PER_SECONDS; scheduleEntityRemoval(entity, deathDuration); ``` --- ## Directional Animation Actions can be marked as `directional` or non-directional. ### Directional Actions (walk, attack, idle, etc.) The sprite frame offset is computed from the unit's current direction: ```c if (actionDef->directional) { frameIndex += (4 - ABS(4 - (s32)unit->direction)); // Mirror horizontally for certain directions transform->scale.x = inRange(unit->direction, WAR_DIRECTION_SOUTH_WEST, WAR_DIRECTION_COUNT) ? -1.0f : 1.0f; } ``` **Direction mapping (8 compass directions):** ``` 0 = NORTH (up) -> no offset, no flip 1 = NORTH_EAST (up-right) -> offset 1, no flip 2 = EAST (right) -> offset 2, no flip 3 = SOUTH_EAST (down-right) -> offset 3, no flip 4 = SOUTH (down) -> offset 4, flip X 5 = SOUTH_WEST (down-left) -> offset 3, flip X 6 = WEST (left) -> offset 2, flip X 7 = NORTH_WEST (up-left) -> offset 1, flip X ``` So a walk animation with 5 frames becomes an 8-directional walk by selecting different frame offsets and flipping. ### Non-Directional Actions (build) Frame offset is **always 0**, regardless of direction. The animation plays the same way from any angle. --- ## Action Definition Tables ### Global Action Definition Storage ```c static WarUnitActionDef gUnitActionDefs[WAR_UNIT_COUNT][WAR_ACTION_TYPE_COUNT]; ``` This 2D array stores all pre-built action definitions: - **First dimension:** Unit type (Footman, Grunt, Peasant, etc.) - **Second dimension:** Action type (IDLE, WALK, ATTACK, etc.) Each cell is a `WarUnitActionDef` with a complete sequence of steps. ### Per-Unit Type Initialization Each unit type gets its own init function: ```c static void initFootmanGruntActionDefs(WarUnitFrameNumbers frames) { // Set animation timing parameters for this unit type s32 walkSpeed = 6; // Fast walk s32 attackSpeed = 6; // Fast attack s32 coolOffTime = 1; s32 waitTime = 3; bool directional = true; // Build action definitions WarUnitActionDef idleDef = createDefaultIdleActionDef(waitTime, directional); WarUnitActionDef walkDef = createWalkActionDef(frames.walkFramesCount, frames.walkFrames, walkSpeed, directional); WarUnitActionDef attackDef = createAttackActionDef(frames.attackFramesCount, frames.attackFrames, attackSpeed, WAR_ACTION_STEP_SOUND_SWORD, coolOffTime, directional); WarUnitActionDef deathDef = createDeathActionDef(frames.deathFramesCount, frames.deathFrames, waitTime, directional, true); // Register for both Footman and Grunt (they share animations) WarUnitType unitTypes[] = {WAR_UNIT_FOOTMAN, WAR_UNIT_GRUNT}; for (s32 i = 0; i < arrayLength(unitTypes); i++) { WarUnitType unitType = unitTypes[i]; gUnitActionDefs[unitType][WAR_ACTION_TYPE_IDLE] = idleDef; gUnitActionDefs[unitType][WAR_ACTION_TYPE_WALK] = walkDef; gUnitActionDefs[unitType][WAR_ACTION_TYPE_ATTACK] = attackDef; gUnitActionDefs[unitType][WAR_ACTION_TYPE_DEATH] = deathDef; } } ``` This pattern is repeated for every unit type: Peasants (with harvest/repair), Archers, Catapults, Cavalry, Mages, Demons, etc. --- ## Integration Points ### Game Loop Integration ```c void wg_updateGame(WarContext* context) { // ... other updates ... // Update all entities for (s32 i = 0; i < context->entities.count; i++) { WarEntity* entity = context->entities.items[i]; // Update action/animation wact_updateAction(context, entity); // Update sprite based on action wr_updateEntitySprite(context, entity); } // ... render ... } ``` ### State Machine Integration Actions are used by the **State Machine** (FSM) to animate units as they transition between behaviors: ```c void wst_idle(WarContext* context, WarEntity* entity) { // While idle, play idle animation wact_setAction(context, entity, WAR_ACTION_TYPE_IDLE, false, 1.0f); } void wst_move(WarContext* context, WarEntity* entity) { // While moving, play walk animation wact_setAction(context, entity, WAR_ACTION_TYPE_WALK, true, 1.0f); } void wst_attack(WarContext* context, WarEntity* entity) { // While attacking, play attack animation wact_setAction(context, entity, WAR_ACTION_TYPE_ATTACK, true, 1.0f); // When attack animation finishes, FSM transitions back to idle/move } ``` --- ## Performance Notes ### Pre-computation - All action definitions are built **once** at game startup (`wact_initUnitActionDefs`) - Runtime `wact_updateAction` only advances counters and indices—very fast - No per-frame allocation or searching ### Memory Efficiency - Shared action definitions across unit types (Footman & Grunt share walk/attack) - Tight `WarUnitAction` struct (3 integers + 2 floats = 20 bytes per unit per action type) - Step arrays are reasonably sized (typically 20-100 steps per action) ### Delta-Time Scaling - Wait times are scaled by delta time: `waitCount -= wmap_getMapScaledSpeed(context, deltaTime)` - Allows smooth frame-rate independence - Speed multiplier (`scale`) provides further control --- ## Common Pitfalls ### 1. Forgetting to Initialize ```c // WRONG: entity->unit.actions not initialized wact_setAction(context, entity, WAR_ACTION_TYPE_WALK, true, 1.0f); // CORRECT: Always call wact_addUnitActions after creating a unit WarEntity* unit = we_createEntity(...); wu_initUnit(unit, unitType); wact_addUnitActions(unit); // <-- Don't forget! ``` ### 2. Wrong Scale Parameter ```c // WRONG: Using 0 as "keep current scale" wact_setAction(context, unit, WAR_ACTION_TYPE_WALK, true, 0.0f); // Freezes animation! // CORRECT: Use -1.0f to preserve scale, or provide positive value wact_setAction(context, unit, WAR_ACTION_TYPE_WALK, true, -1.0f); // Keep scale wact_setAction(context, unit, WAR_ACTION_TYPE_WALK, true, 1.0f); // Reset to normal ``` ### 3. Not Calling Update ```c // WRONG: Set action but never call update wact_setAction(context, unit, WAR_ACTION_TYPE_WALK, true, 1.0f); // ... unit never animates! // CORRECT: Call update in game loop for (frame in game) { wact_setAction(context, unit, WAR_ACTION_TYPE_WALK, true, 1.0f); wact_updateAction(context, unit); // <-- Necessary! } ``` ### 4. Direction Changes During Action ```c // CORRECT: Direction changes apply immediately on next update unit->transform.direction = WAR_DIRECTION_EAST; wact_updateAction(context, unit); // Frame offset recalculated with new direction ``` --- ## Extension Points ### Adding a New Action Type 1. Add the enum value to `WarUnitActionType` in `war_enums.h`: ```c typedef enum _WarUnitActionType { // ... existing ... WAR_ACTION_TYPE_CAST, // NEW: Magic casting animation WAR_ACTION_TYPE_COUNT } WarUnitActionType; ``` 2. Create a builder function in `war_actions.c`: ```c static WarUnitActionDef createCastActionDef(...) { WarUnitActionDef def = createUnitActionDef(WAR_ACTION_TYPE_CAST, directional, true); // Add steps... return def; } ``` 3. Register it in the unit init functions: ```c gUnitActionDefs[unitType][WAR_ACTION_TYPE_CAST] = castDef; ``` 4. Use it in the FSM: ```c void wst_cast(WarContext* context, WarEntity* entity) { wact_setAction(context, entity, WAR_ACTION_TYPE_CAST, true, 1.0f); } ``` ### Adding a New Sound Step 1. Add to `WarUnitActionStepType` enum: ```c WAR_ACTION_STEP_SOUND_MAGIC, ``` 2. Handle in `wact_updateAction`: ```c case WAR_ACTION_STEP_SOUND_MAGIC: { action->lastSoundStep = step.type; break; } ``` 3. Add sound playback logic in sprite/audio rendering layer (check `action->lastSoundStep`) --- ## Summary The Action System provides: - ✅ **Data-driven animations** - Defined at startup, not hard-coded - ✅ **8-directional support** - Directional actions adapt to unit facing - ✅ **Synchronized events** - Damage and sounds trigger at exact animation frames - ✅ **Speed control** - Frame-rate independent with multiplier support - ✅ **Loop support** - Both one-shot and repeating animations - ✅ **Per-unit customization** - Each unit type has unique timing and frame sequences All animations flow through `wact_setAction` (start/change) and `wact_updateAction` (advance), making the system simple, efficient, and easy to extend. ================================================ FILE: docs/ANIMATION_SYSTEM.md ================================================ # War1-C Animation System Documentation ## Overview The Animation System is a sprite frame sequence engine for one-off visual effects and overlays. While the **Action System** handles unit animations (walk, attack, idle), the **Animation System** manages temporary visual effects that play independently on top of units or the map. Common animations include: - **Building Damage Overlays** - Visual indicators when a building is damaged - **Explosions** - Detonations from catapult shots, buildings collapsing - **Spells** - Visual effects for magical attacks (fireball, lightning) - **Environmental Effects** - Poison clouds, rain of fire, building collapse sequences - **Custom Frame Sequences** - Any sprite sheet that needs to cycle through frames Unlike the Action System which loops indefinitely and is tightly integrated with unit state machines, animations are **temporal** — they play once (or loop a fixed number of times) and self-destruct when finished. --- ## Architecture ### Core Concept: Sprite Animation as a Component Animations are managed as a **component** that can be attached to any entity. An entity can have **multiple simultaneous animations**, allowing layering of effects (e.g., a building that is both damaged AND being repaired). ``` Entity ├── Transform Component ├── Sprite Component (unit sprite) ├── Unit Component (stats, health) └── Animations Component ├── Animation 1 (damage overlay) ├── Animation 2 (collapse effect) └── Animation 3 (custom effect) ``` Each animation plays independently, with its own frame counter, duration, and playback status. ### Key Types #### `WarAnimationStatus` - Execution State ```c typedef enum _WarAnimationStatus { WAR_ANIM_STATUS_NOT_STARTED, // Created but not yet playing WAR_ANIM_STATUS_RUNNING, // Currently playing WAR_ANIM_STATUS_FINISHED, // Complete (will be removed) } WarAnimationStatus; ``` #### `WarSpriteAnimation` - Single Animation Instance ```c struct _WarSpriteAnimation { String name; // Unique identifier (e.g., "explosion_123.45_67.89") bool loop; // Should this repeat or play once? f32 loopDelay; // Pause (in seconds) between loop iterations vec2 offset; // Position offset from entity origin vec2 scale; // Scaling (1.0 = normal, 2.0 = 2x) f32 frameDelay; // Duration of each frame (in seconds) s32List frames; // Sequence of frame indices to display WarSprite sprite; // Sprite resource (contains frame dimensions) f32 animTime; // Current playback time (0.0 to 1.0 normalized) f32 loopTime; // Countdown for loop delay WarAnimationStatus status;// NOT_STARTED, RUNNING, or FINISHED }; ``` #### `WarAnimationsComponent` - Container for All Animations on an Entity ```c struct _WarAnimationsComponent { bool enabled; // Can animations play? WarSpriteAnimationList animations; // List of active animations }; ``` --- ## API Reference ### Creation #### `WarSpriteAnimation* wanim_createAnimation(WarContext* context, String name, WarSprite sprite, f32 frameDelay, bool loop)` **Purpose:** Create a custom animation from scratch. **Parameters:** - `context` - Game context - `name` - Unique identifier for this animation (e.g., "my_effect_001") - `sprite` - Sprite resource (dimensions and frame data) - `frameDelay` - Duration per frame in seconds (e.g., 0.1f = 10 FPS) - `loop` - Repeat after finishing? **Returns:** Pointer to newly allocated `WarSpriteAnimation` **What it does:** - Allocates memory for the animation - Initializes status to NOT_STARTED - Sets offset and scale to default (origin, 1x) - Prepares an empty frame list **Example:** ```c WarSprite explosionSprite = wspr_createSpriteFromResourceIndex( context, imageResourceRef(WAR_EXPLOSION_RESOURCE) ); WarSpriteAnimation* explosion = wanim_createAnimation( context, "explosion_hit", explosionSprite, 0.1f, // 100ms per frame = 10 FPS false // Play once ); ``` --- #### `WarSpriteAnimation* wanim_createAnimationFromResourceIndex(WarContext* context, String name, WarSpriteResourceRef spriteResourceRef, f32 frameDelay, bool loop)` **Purpose:** Create an animation directly from a resource ID (convenience wrapper). **Parameters:** - `context` - Game context - `name` - Animation identifier - `spriteResourceRef` - Resource reference ID - `frameDelay` - Duration per frame - `loop` - Repeat? **Returns:** New animation instance **What it does:** - Loads the sprite from the resource database - Calls `wanim_createAnimation` with the loaded sprite **Example:** ```c WarSpriteAnimation* damage = wanim_createAnimationFromResourceIndex( context, "damage_indicator", imageResourceRef(WAR_BUILDING_DAMAGE_1_RESOURCE), 0.2f, true // Damage indicator loops ); ``` --- ### Frame Setup #### `void wanim_addAnimationFrame(WarSpriteAnimation* animation, s32 frameIndex)` **Purpose:** Add a single frame to an animation's playback sequence. **Parameters:** - `animation` - Animation to modify - `frameIndex` - Index in the sprite sheet to display **What it does:** - Appends `frameIndex` to the animation's frame list **Example:** ```c // Create a 6-frame explosion for (s32 i = 0; i < 6; i++) { wanim_addAnimationFrame(explosion, i); } ``` --- #### `void wanim_addAnimationFrames(WarSpriteAnimation* animation, s32 count, s32 frameIndices[])` **Purpose:** Add multiple frames in one call. **Parameters:** - `animation` - Animation to modify - `count` - Number of frames - `frameIndices[]` - Array of frame indices (or NULL for 0..count-1 sequence) **What it does:** - If `frameIndices` is provided, adds those exact frames - If `frameIndices` is NULL, adds frames 0, 1, 2, ..., count-1 **Example:** ```c // Method 1: Explicit frame list s32 frames[] = {0, 1, 2, 3, 4, 5}; wanim_addAnimationFrames(explosion, 6, frames); // Method 2: Sequential (0..5) wanim_addAnimationFrames(explosion, 6, NULL); // Same result ``` --- #### `void wanim_addAnimationFramesRange(WarSpriteAnimation* animation, s32 from, s32 to)` **Purpose:** Add a range of frames (forward or backward). **Parameters:** - `animation` - Animation to modify - `from` - Starting frame index - `to` - Ending frame index **What it does:** - If `from < to`, adds frames `from, from+1, ..., to` - If `from > to`, adds frames `from, from-1, ..., to` (reverse) **Example:** ```c // Forward: frames 0, 1, 2, 3, 4 wanim_addAnimationFramesRange(anim, 0, 4); // Reverse: frames 10, 9, 8, 7 wanim_addAnimationFramesRange(anim, 10, 7); // Ping-pong effect: forward then backward wanim_addAnimationFramesRange(anim, 0, 5); // 0..5 wanim_addAnimationFramesRange(anim, 4, 1); // 4,3,2,1 ``` --- ### Animation Attachment #### `void wanim_addAnimation(WarEntity* entity, WarSpriteAnimation* animation)` **Purpose:** Attach a created animation to an entity. **Parameters:** - `entity` - Target entity - `animation` - Animation to attach **What it does:** - Adds the animation to the entity's animations component - Animation will be updated/rendered each frame **Example:** ```c WarEntity* target = // ... unit being attacked ... WarSpriteAnimation* explosion = wanim_createAnimation(...); wanim_addAnimation(target, explosion); // Animation plays on top of unit ``` --- ### Positioning & Transform **Animation Position:** - Animations are positioned using `offset` (relative to entity origin) - Scaled using the `scale` field - Can be set directly after creation: ```c WarSpriteAnimation* effect = wanim_createAnimation(...); effect->offset = vec2f(50.0f, -30.0f); // Offset from entity effect->scale = vec2f(1.5f, 1.5f); // 1.5x size wanim_addAnimation(entity, effect); ``` --- ### Query & Lookup #### `WarSpriteAnimation* wanim_findAnimation(WarContext* context, WarEntity* entity, StringView name)` **Purpose:** Find an animation by name on an entity. **Parameters:** - `context` - Game context - `entity` - Entity to search - `name` - Animation name **Returns:** Pointer to animation, or NULL if not found **Example:** ```c WarSpriteAnimation* damage = wanim_findAnimation(context, building, "damage_overlay"); if (damage) { logInfo("Damage animation found"); } ``` --- #### `bool wanim_containsAnimation(WarContext* context, WarEntity* entity, StringView name)` **Purpose:** Check if an entity has a specific animation. **Parameters:** - Same as `wanim_findAnimation` **Returns:** true if animation exists, false otherwise **Example:** ```c if (wanim_containsAnimation(context, building, "collapse")) { // Building is collapsing, don't allow repairs } ``` --- #### `f32 wanim_getAnimationDuration(WarSpriteAnimation* animation)` **Purpose:** Calculate total playback duration. **Parameters:** - `animation` - Animation to query **Returns:** Duration in seconds = `frameDelay * frameCount` **Example:** ```c f32 duration = wanim_getAnimationDuration(explosion); // Schedule cleanup or next action after explosion finishes scheduleAfterDelay(duration, nextAction); ``` --- ### Removal & Cleanup #### `void wanim_removeAnimation(WarContext* context, WarEntity* entity, StringView name)` **Purpose:** Manually remove an animation from an entity. **Parameters:** - `context` - Game context - `entity` - Entity containing animation - `name` - Name of animation to remove **What it does:** - Finds the animation by name - Removes it from the animations list - Memory is freed **Example:** ```c // Cancel a damage overlay wanim_removeAnimation(context, building, "damage_overlay"); ``` --- #### `void wanim_freeAnimation(WarSpriteAnimation* animation)` **Purpose:** Free animation memory. **Parameters:** - `animation` - Animation to free **What it does:** - Deallocates the frame list - Deallocates the animation struct **Note:** Called automatically when `FINISHED` status is detected during update. Manual calls are rare. --- ### Update & Playback #### `void wanim_updateAnimations(WarContext* context)` **Purpose:** Advance all animations in the game by one frame. **When to call:** Every game loop frame (called from main game update) **What it does:** 1. Iterates all entities 2. For each entity's animation list, calls `wanim_updateAnimation` 3. Automatically removes finished non-looping animations 4. Handles loop delays and auto-removal **Example:** ```c void wg_updateGame(WarContext* context) { // ... other updates ... wanim_updateAnimations(context); // Advance all animations // ... render ... } ``` **Internal Logic:** ``` For each animation: - If FINISHED and not looping → remove and continue - Set status to RUNNING - If in loop delay → decrement, return (wait) - Calculate progress: dt = deltaTime / totalDuration - Scale dt by map speed - Increment animTime by dt - If animTime >= 1.0 → FINISHED - If looping → reset and set loopDelay countdown - Else → will be removed next update ``` --- ## Pre-Made Animation Factories The animation system includes factory functions for common visual effects. These handle all frame setup and positioning automatically. ### Building Damage Overlay #### `WarSpriteAnimation* wanim_createDamageAnimation(WarContext* context, WarEntity* entity, String name, int damageLevel)` **Purpose:** Create a damage indicator overlay on a building. **Parameters:** - `context` - Game context - `entity` - Building entity to damage - `name` - Identifier for this effect - `damageLevel` - 1 or 2 (damage level determines sprite) **What it does:** - Creates animation with 4 frames (damage indicator phases) - Loops continuously - Positions at the building's sprite center - Frame delay: 0.2s (5 FPS, slow pulsing) - **Automatically attached to entity** **Returns:** The animation (so you can remove it later if needed) **Example:** ```c // Show damage on building wanim_createDamageAnimation(context, damaged_building, "damage_lvl1", 1); // Later, when healed wanim_removeAnimation(context, damaged_building, "damage_lvl1"); ``` --- ### Building Collapse #### `WarSpriteAnimation* wanim_createCollapseAnimation(WarContext* context, WarEntity* entity, String name)` **Purpose:** Play a building collapse/explosion effect. **Parameters:** - `context` - Game context - `entity` - Building to collapse - `name` - Identifier **What it does:** - Creates a 17-frame collapse sequence - Non-looping (plays once) - Frame delay: 0.1s (10 FPS) - Dynamically scales animation to match building size - Calculates offset so explosion is centered on building - **Automatically attached to entity** **Returns:** The animation **Example:** ```c // Building is destroyed wanim_createCollapseAnimation(context, barracks, "collapse_effect"); // Animation plays, then automatically removed when finished ``` --- ### General Explosions #### `WarSpriteAnimation* wanim_createExplosionAnimation(WarContext* context, WarEntity* entity, vec2 position)` **Purpose:** Spawn an explosion effect at a specific world position. **Parameters:** - `context` - Game context - `entity` - Entity to attach animation to (often a dummy entity or projectile) - `position` - World coordinates for explosion center **What it does:** - Creates a 6-frame explosion - Non-looping - Frame delay: 0.1s - Names animation based on position (e.g., "explosion_123.45_67.89") - Positions sprite at world coordinates - **Automatically attached** **Returns:** The animation **Example:** ```c // Catapult shot lands vec2 hitPos = vec2f(100.0f, 200.0f); wanim_createExplosionAnimation(context, world_entity, hitPos); ``` --- #### `WarSpriteAnimation* wanim_createRainOfFireExplosionAnimation(WarContext* context, WarEntity* entity, vec2 position)` **Purpose:** Spawn a "Rain of Fire" spell explosion effect. **Parameters:** - `context` - Game context - `entity` - Entity to attach to - `position` - World coordinates **What it does:** - Creates a 3-frame (frames 3, 4, 5) "rain of fire" explosion - Non-looping - Frame delay: 0.1s - Positioned at world coordinates - **Automatically attached** **Returns:** The animation **Example:** ```c // Rain of Fire spell cast wanim_createRainOfFireExplosionAnimation(context, caster, spellCenter); ``` --- ### Spell Effects #### `WarSpriteAnimation* wanim_createSpellAnimation(WarContext* context, WarEntity* entity, vec2 position)` **Purpose:** Display a generic spell cast effect. **Parameters:** - `context` - Game context - `entity` - Entity to attach to - `position` - World coordinates **What it does:** - Creates a 6-frame spell effect - Non-looping - Frame delay: 0.4s (slower than explosions) - Positioned at world coordinates - **Automatically attached** **Returns:** The animation **Example:** ```c // Fireball spell at target location wanim_createSpellAnimation(context, caster, targetPos); ``` --- #### `WarSpriteAnimation* wanim_createPoisonCloudAnimation(WarContext* context, WarEntity* entity, vec2 position)` **Purpose:** Create a lingering poison cloud effect. **Parameters:** - `context` - Game context - `entity` - Entity to attach to - `position` - World coordinates **What it does:** - Creates a 4-frame poison cloud - **Loops continuously** (unlike most effects) - Frame delay: 0.5s (slow, dreamy animation) - Positioned at world coordinates - **Automatically attached** **Returns:** The animation **Example:** ```c // Poison spell creates cloud at location wanim_createPoisonCloudAnimation(context, spell_source, cloudPos); // Cloud persists and loops until manually removed ``` --- ## Integration Points ### Game Loop ```c void wg_updateGame(WarContext* context) { // ... update game logic ... // Update all animations (must be called every frame) wanim_updateAnimations(context); // Render everything (animations rendered based on their status/frames) wr_render(context); } ``` ### Rendering Integration The animation system provides frame and positioning data. Rendering code uses: - `animation->sprite.frameIndex` - which frame to display - `animation->offset` - position offset - `animation->scale` - scaling factor The render system draws animations **on top of** the entity's normal sprite, allowing layering. ### Example: Projectile Impact ```c // Projectile hits target void handleProjectileImpact(WarContext* context, WarProjectile* proj, WarEntity* target) { // Deal damage wu_damageUnit(target, proj->damage); // Create visual feedback if (proj->type == WAR_PROJECTILE_FIREBALL) { wanim_createExplosionAnimation(context, target, proj->position); } else if (proj->type == WAR_PROJECTILE_ARROW) { wanim_createSpellAnimation(context, target, proj->position); } // Remove projectile we_destroyEntity(context, proj->entity); } ``` ### Example: Building Destruction ```c // Building health reaches zero void handleBuildingDeath(WarContext* context, WarEntity* building) { // Create collapse effect wanim_createCollapseAnimation(context, building, "collapse"); // Remove after animation completes // (automatic: animation is removed when FINISHED) } ``` --- ## Animation Lifecycle ### Timeline ``` 1. Created wanim_createAnimation() or wanim_createDamageAnimation(), etc. Status: NOT_STARTED animTime: 0 2. Attached wanim_addAnimation(entity, animation) Now managed by entity's animations component 3. First Update wanim_updateAnimations() called Status: RUNNING First frame displayed 4. Playing Each update increments animTime Frame index determined by animTime * frameCount animTime goes from 0 to 1 5. Completion animTime >= 1.0 Status: FINISHED If loop: restart with loopDelay If no loop: marked for removal 6. Cleanup Next wanim_updateAnimations() call Animation removed from entity Memory freed ``` --- ## Performance Considerations ### Memory - Each animation: ~100-200 bytes base + frame list - Frame list: 4 bytes per frame × count - Example: 6-frame explosion = ~125 + 24 = ~150 bytes ### CPU - `wanim_updateAnimations()` is O(entities × animations per entity) - Update is trivial: counter increment, no allocations - Profiled with Tracy (see code: `TracyCZoneN`) ### Typical Scene Load - Explosions: 50-100 active simultaneous → minimal impact - Damage overlays on buildings: constant, low cost - Spell effects: burst of animations during battles --- ## Common Patterns ### Pattern 1: Simple Explosion on Impact ```c vec2 impact_pos = projectile->position; wanim_createExplosionAnimation(context, dummy_entity, impact_pos); // That's it! Animation plays automatically ``` ### Pattern 2: Damage Feedback Loop ```c // Building takes damage wu_takeDamage(building, 20); // Show damage state int damageLevel = building->health < 50 ? 2 : 1; wanim_createDamageAnimation(context, building, "damage_indicator", damageLevel); // Later, building repaired wu_repair(building, 30); wanim_removeAnimation(context, building, "damage_indicator"); ``` ### Pattern 3: Multi-Frame Custom Effect ```c WarSpriteAnimation* custom = wanim_createAnimation( context, "my_effect", customSprite, 0.15f, // 150ms per frame false // Play once ); // Add frames manually wanim_addAnimationFramesRange(custom, 0, 10); // Frames 0-10 wanim_addAnimationFramesRange(custom, 9, 0); // Reverse: 9-0 (ping-pong) // Position and attach custom->offset = vec2f(50.0f, 30.0f); custom->scale = vec2f(2.0f, 2.0f); wanim_addAnimation(building, custom); ``` ### Pattern 4: Looping Environmental Effect ```c // Poison cloud at a location (loops indefinitely) WarSpriteAnimation* cloud = wanim_createPoisonCloudAnimation( context, world_entity, poison_center ); // Later, when effect expires or area clears wanim_removeAnimation(context, world_entity, "poison_cloud_..."); ``` ### Pattern 5: Check Animation Status ```c // Only allow repairs while NOT collapsing if (!wanim_containsAnimation(context, building, "collapse")) { allowRepairs(building); } else { blockRepairs(building); // Building is collapsing } ``` --- ## Comparison: Animation vs Action Systems | Aspect | Animation System | Action System | |--------|------------------|---------------| | **Purpose** | Temporary effects | Unit state/animation | | **Duration** | Seconds (typically) | Indefinite loops | | **Integration** | Overlay on entity | Core unit behavior | | **Multiple Instances** | Yes (multiple on one entity) | One active per unit | | **Looping** | Optional, with delay | Built-in via FSM | | **Directional** | No (static orientation) | Yes (8 directions) | | **Removal** | Automatic when finished | Via FSM state change | | **Use Case** | Explosions, damage, spells | Walk, attack, idle | **When to use Animation System:** - One-off visual effects - Temporary overlays - Environmental effects - Spell/ability visuals - Building destruction **When to use Action System:** - Continuous unit animations - FSM-driven behaviors - Animation tied to game state - Directional playback --- ## Extension Points ### Adding a New Pre-Made Effect 1. Create a factory function in `war_animations.c`: ```c WarSpriteAnimation* wanim_createLightningAnimation(WarContext* context, WarEntity* entity, vec2 position) { WarSpriteResourceRef spriteResourceRef = imageResourceRef(WAR_LIGHTNING_RESOURCE); WarSprite sprite = wspr_createSpriteFromResourceIndex(context, spriteResourceRef); String name = wstr_make(); wstr_appendFormat(&name, "lightning_%.2f_%.2f", position.x, position.y); WarSpriteAnimation* anim = wanim_createAnimation(context, name, sprite, 0.08f, false); // Positioning and frame setup... wanim_addAnimationFramesRange(anim, 0, 7); wanim_addAnimation(entity, anim); return anim; } ``` 2. Add declaration to `war_animations.h`: ```c WarSpriteAnimation* wanim_createLightningAnimation(WarContext* context, WarEntity* entity, vec2 position); ``` 3. Call from game logic: ```c wanim_createLightningAnimation(context, caster, target_pos); ``` --- ## Summary The Animation System provides: - ✅ **Flexible sprite sequencing** - Any sprite can be a multi-frame animation - ✅ **Position & scale control** - Overlay effects anywhere - ✅ **Looping with delays** - Natural pause between loops - ✅ **Auto-cleanup** - Finished animations self-remove - ✅ **Multiple simultaneous effects** - Entity can have many animations - ✅ **Pre-built factories** - Common effects ready to use (explosions, spells, damage) - ✅ **Delta-time independent** - Frame-rate agnostic timing - ✅ **Performance optimized** - O(n) per entity per frame All animations flow through `wanim_createAnimation()` (or factories), `wanim_addAnimation()` (attach), and `wanim_updateAnimations()` (advance), making the system simple, efficient, and easy to extend for new effects. ================================================ FILE: docs/COMMANDS_SYSTEM.md ================================================ # War1-C Commands System Documentation ## Overview The Commands System is the **interface between player input and game state changes**. It translates player actions (clicking on units, right-clicking the map, pressing ability hotkeys) into high-level commands that affect units, buildings, and gameplay progression. Commands are **asynchronous and batched**: the player issues commands through the UI, commands are queued, and they're executed when ready (respecting cooldowns, resource costs, and prerequisites). This design enables: - **Multi-unit operations** - "Select 5 footmen, move to point X" applies to all selected - **Deferred execution** - Commands respect prerequisites (enough resources, mana, valid targets) - **Sound feedback** - Acknowledgement sounds and error handling - **Formation preservation** - Moving multiple units maintains their formation - **State transitions** - Commands drive the FSM to appropriate unit behaviors Examples: - **Movement**: Player clicks terrain → all selected units move there in formation - **Training**: Player clicks "Train Footman" → barracks queues unit if resources permit - **Casting**: Player clicks "Rain of Fire" + target tile → conjurer casts spell - **Building**: Player clicks "Build Farm" + target tile → peasant walks there and constructs --- ## Architecture ### Two-Tier Command Processing The system has two processing levels: 1. **Command Registration** (`wcmd_train*`, `wcmd_cast*`, etc.) - Called by UI buttons/hotkeys - Stores command type in `map->command` - Lightweight, no validation yet 2. **Command Execution** (`wcmd_executeCommand`) - Called from game loop - Validates command feasibility - Applies state changes - Affects all selected units - Plays audio feedback ### Command Flow ``` User Input (UI button click) ↓ wcmd_trainFootman(context, entity) [or similar wcmd_* function] ↓ map->command.type = WAR_COMMAND_TRAIN_FOOTMAN ↓ [Next game frame] ↓ wcmd_executeCommand(context) [main game loop] ↓ Validate command (check resources, mana, unit state, etc.) ↓ For each selected unit: - Create appropriate FSM state - Queue or execute the action - Play acknowledgement sound ``` --- ## Key Types ### `WarUnitCommandType` - Command Categories ```c typedef enum _WarUnitCommandType { // Basic unit actions WAR_COMMAND_NONE, WAR_COMMAND_MOVE, // Move to position WAR_COMMAND_STOP, // Stop current action WAR_COMMAND_HARVEST, // Gather resources (gold/wood) WAR_COMMAND_DELIVER, // Deliver resources to town hall WAR_COMMAND_REPAIR, // Repair building WAR_COMMAND_ATTACK, // Attack unit/building // Unit training WAR_COMMAND_TRAIN_FOOTMAN, WAR_COMMAND_TRAIN_GRUNT, WAR_COMMAND_TRAIN_PEASANT, WAR_COMMAND_TRAIN_PEON, WAR_COMMAND_TRAIN_CATAPULT_HUMANS, WAR_COMMAND_TRAIN_CATAPULT_ORCS, // ... 8 more unit types ... // Spell casting WAR_COMMAND_SPELL_HEALING, WAR_COMMAND_SPELL_FAR_SIGHT, WAR_COMMAND_SPELL_INVISIBILITY, WAR_COMMAND_SPELL_RAIN_OF_FIRE, WAR_COMMAND_SPELL_POISON_CLOUD, WAR_COMMAND_SPELL_RAISE_DEAD, WAR_COMMAND_SPELL_DARK_VISION, WAR_COMMAND_SPELL_UNHOLY_ARMOR, // Summoning WAR_COMMAND_SUMMON_SPIDER, WAR_COMMAND_SUMMON_SCORPION, WAR_COMMAND_SUMMON_DAEMON, WAR_COMMAND_SUMMON_WATER_ELEMENTAL, // Building construction WAR_COMMAND_BUILD_BASIC, WAR_COMMAND_BUILD_ADVANCED, WAR_COMMAND_BUILD_FARM_HUMANS, WAR_COMMAND_BUILD_FARM_ORCS, // ... 16 more building types ... WAR_COMMAND_BUILD_ROAD, WAR_COMMAND_BUILD_WALL, // Unit/spell upgrades WAR_COMMAND_UPGRADE_SWORDS, WAR_COMMAND_UPGRADE_AXES, // ... 18 more upgrades ... // Special WAR_COMMAND_CANCEL, WAR_COMMAND_COUNT } WarUnitCommandType; ``` ### `WarUnitCommand` - Command Payload ```c struct _WarUnitCommand { WarUnitCommandType type; // What to do union // Type-specific parameters { struct { WarUnitType unitToTrain; // Which unit to create WarUnitType buildingUnit; // Where to create it (building type) } train; struct { WarUpgradeType upgradeToBuild; // Which upgrade to research WarUnitType buildingUnit; // Which building researches it } upgrade; struct { WarUnitType buildingToBuild; // Which building to construct } build; }; }; ``` --- ## API Reference ### High-Level Command Functions These are called by the UI when the player clicks a button or presses a hotkey. They simply store the command type (and metadata) for later execution. #### Unit Movement ```c void move(WarContext* context, WarEntity* entity) ``` **Purpose:** Queue a move command to a specific position. **How it's used:** ```c // Player right-clicks the map wcmd_executeMoveCommand(context, clickedPosition); ``` **What happens:** - All selected units move to the position - Formation is preserved (relative positions maintained) - With SHIFT held, adds waypoint to current move queue - Plays acknowledgement sound --- #### Unit Actions ```c void wcmd_stop(WarContext* context, WarEntity* entity) ``` **Purpose:** Stop all current actions. ```c void wcmd_harvest(WarContext* context, WarEntity* entity) ``` **Purpose:** Harvest resources (gold/wood). **What happens:** - Workers go to resource location - If carrying resources, deliver first - Loops until manually stopped ```c void attack(WarContext* context, WarEntity* entity) ``` **Purpose:** Attack target unit/building. **What happens:** - Selected units engage target - Combat until target dies or command cancelled - Applies to friendly, hostile detection ```c void repair(WarContext* context, WarEntity* entity) ``` **Purpose:** Repair damaged building. **What happens:** - Workers walk to building - Repair animation plays - Building health increases - Workers can be interrupted --- #### Training Units ```c void wcmd_trainFootman(WarContext* context, WarEntity* entity) void wcmd_trainGrunt(WarContext* context, WarEntity* entity) void wcmd_trainPeasant(WarContext* context, WarEntity* entity) // ... and 11 more unit types ``` **Purpose:** Queue unit training in a barracks/training building. **Parameters:** - `context` - Game context - `entity` - (unused, for API consistency) **What happens:** 1. Check if barracks has required resources 2. Deduct resources from player pool 3. Start training timer 4. Create unit when complete 5. Play acknowledgement sound if successful **Example:** ```c // Player clicks "Train Footman" button wcmd_trainFootman(context, NULL); // Implementation sets: // map->command.type = WAR_COMMAND_TRAIN_FOOTMAN // Later execution validates and creates unit ``` **Training is tracked per building:** - Barracks can queue multiple units - Each unit takes time and resources - Units are created one at a time --- #### Building Construction ```c void wcmd_buildFarmHumans(WarContext* context, WarEntity* entity) void wcmd_buildBarracksHumans(WarContext* context, WarEntity* entity) // ... and 16 more building types ``` **Purpose:** Queue building placement mode. **What happens:** 1. Stores build command in map state 2. UI enters "building placement" mode 3. Player clicks terrain to place 4. Peasant/Peon walks to location 5. Construction begins 6. Building health increases during construction **Construction by workers:** - Workers carry construction materials - Multiple workers can work on same building - Accelerates construction - Blocks workers from other tasks ```c void wcmd_buildWall(WarContext* context, WarEntity* entity) void wcmd_buildRoad(WarContext* context, WarEntity* entity) ``` **Purpose:** Begin wall/road placement. **What happens:** - UI enters placement mode - Player clicks tiles to place wall/road pieces - Pieces automatically connect (T-junctions, crosses, etc.) - Completed instantly (no construction time) --- #### Spell Casting ```c void wcmd_castRainOfFire(WarContext* context, WarEntity* entity) void wcmd_castPoisonCloud(WarContext* context, WarEntity* entity) void wcmd_castHeal(WarContext* context, WarEntity* entity) void wcmd_castFarSight(WarContext* context, WarEntity* entity) // ... more spells ``` **Purpose:** Queue spell casting. **What happens:** 1. Validates casting unit has mana 2. Creates CAST state for selected mages 3. Mage walks toward target (if out of range) 4. Animates casting 5. Spell effect triggers at full cast 6. Deducts mana 7. Cooldown period **Target vs Area spells:** - **Targeted** (Heal, Invisibility): Click on unit - **Area** (Rain of Fire, Poison Cloud): Click on terrain - **Instant** (Raise Dead): Cast at location ```c void wcmd_castInvisibility(WarContext* context, WarEntity* entity) ``` Makes selected units invisible (if Cleric/Necrolyte selected). ```c void wcmd_castUnHolyArmor(WarContext* context, WarEntity* entity) ``` Buffs selected units (damage reduction). ```c void wcmd_castFarSight(WarContext* context, WarEntity* entity) ``` Temporarily reveals distant map area. --- #### Summoning ```c void wcmd_summonSpider(WarContext* context, WarEntity* entity) void wcmd_summonScorpion(WarContext* context, WarEntity* entity) void wcmd_summonDaemon(WarContext* context, WarEntity* entity) void wcmd_summonWaterElemental(WarContext* context, WarEntity* entity) ``` **Purpose:** Summon creature as Conjurer/Warlock. **What happens:** 1. Validates unit is Conjurer/Warlock 2. Checks mana for each summon 3. Spawns creature at mage position (randomized empty spot) 4. Creature can be controlled like normal unit 5. Creature disappears when killed 6. Plays spell cast effect **Cost:** Each summon costs mana (can summon multiple per cast) --- #### Upgrades ```c void wcmd_upgradeSwords(WarContext* context, WarEntity* entity) void wcmd_upgradeHumanShields(WarContext* context, WarEntity* entity) void wcmd_upgradeHorses(WarContext* context, WarEntity* entity) // ... 17 more upgrades ``` **Purpose:** Research technology in appropriate building. **What happens:** 1. Validates building exists and is idle 2. Deducts resources 3. Plays "research" animation 4. After duration, upgrade complete 5. All matching units gain bonus (damage, armor, speed, etc.) 6. UI updates to reflect new capabilities **Upgrade types:** - **Weapon upgrades** (Swords, Axes, Arrows, Spears) → More damage - **Armor upgrades** (Shields) → More armor - **Unit upgrades** (Horses, Wolves, Scorpions, Spiders) → Better mounts/summons - **Spell upgrades** (Rain of Fire, Poison Cloud, Water Elemental, Daemon) → More powerful spells - **Ability upgrades** (Healing, Raise Dead, Invisibility, Unholy Armor, Far Sight, Dark Vision) --- ### Execution Functions These low-level functions handle the actual command execution. Called from the main game loop. #### `bool wcmd_executeCommand(WarContext* context)` **Purpose:** Process the queued command. **Parameters:** - `context` - Game context **Returns:** true if command was processed, false if no command pending **What it does:** 1. Checks if a command is queued 2. Validates all preconditions (resources, mana, valid targets, unit states) 3. For each selected unit, executes command 4. Plays audio feedback (success or error) 5. Clears command after execution **Called every frame** from the main game loop. **Example flow:** ```c // Game loop void wg_updateGame(WarContext* context) { // ... other updates ... wcmd_executeCommand(context); // Execute queued command // ... continue ... } ``` --- #### Execute Unit Commands ```c void wcmd_executeMoveCommand(WarContext* context, vec2 targetPoint) void wcmd_executeFollowCommand(WarContext* context, WarEntity* targetEntity) void wcmd_executeStopCommand(WarContext* context) void wcmd_executeHarvestCommand(WarContext* context, WarEntity* targetEntity, vec2 targetTile) void wcmd_executeDeliverCommand(WarContext* context, WarEntity* targetEntity) void wcmd_executeRepairCommand(WarContext* context, WarEntity* targetEntity) void wcmd_executeAttackCommand(WarContext* context, WarEntity* targetEntity, vec2 targetTile) ``` **Purpose:** Execute low-level unit actions. **Parameters vary by command:** - Movement: target position - Attack/Repair: target entity - Harvesting: target resource and position **What they do:** - Create appropriate FSM state for each selected unit - Queue the state change - Filter units (only friendly, only valid types) - Play acknowledgement sound **Formation Handling:** Movement preserves formation: ```c // Calculate bounding box of selected units rect bbox = ...; // For each unit, calculate offset relative to bbox // Move unit to target position + offset ``` --- #### Execute Spell Commands ```c void wcmd_executeSummonCommand(WarContext* context, WarUnitCommandType summonType) void wcmd_executeRainOfFireCommand(WarContext* context, vec2 targetTile) void wcmd_executePoisonCloudCommand(WarContext* context, vec2 targetTile) void wcmd_executeHealingCommand(WarContext* context, WarEntity* targetEntity, vec2 targetTile) void wcmd_executeInvisiblityCommand(WarContext* context, WarEntity* targetEntity, vec2 targetTile) void wcmd_executeUnholyArmorCommand(WarContext* context, WarEntity* targetEntity, vec2 targetTile) void wcmd_executeRaiseDeadCommand(WarContext* context, vec2 targetTile) void wcmd_executeSightCommand(WarContext* context, vec2 targetTile) ``` **Purpose:** Execute spell casting. **Parameters:** - Caster selection (operates on selected units) - Target entity (for targeted spells) or target tile (for area spells) **What they do:** - Create CAST state for each selected mage - Validate mana pool - Set target (entity ID or tile position) - Animation plays and damage/effect applies --- ## Integration Points ### UI Integration The command system is driven by UI interactions: ```c // User clicks "Move" button or right-clicks map // UI layer calls: wcmd_executeMoveCommand(context, clickPosition); // User clicks "Attack" button, selects target // UI layer calls: wcmd_executeAttackCommand(context, targetEntity, targetTile); // User presses 'F' for train (or clicks button) // UI layer calls: wcmd_trainFootman(context, NULL); ``` ### Game Loop Integration ```c void wg_updateGame(WarContext* context) { // ... update game state ... // Process any queued commands wcmd_executeCommand(context); // ... render ... } ``` ### State Machine Integration Commands create FSM states that drive unit behavior: ```c // Move command creates MOVE state WarState* moveState = wst_createMoveState(context, entity, ...); wst_changeNextState(context, entity, moveState, true, true); // Attack command creates ATTACK state WarState* attackState = wst_createAttackState(context, entity, ...); wst_changeNextState(context, entity, attackState, true, true); // Build command creates BUILD state WarState* buildState = wst_createBuildState(context, entity, ...); wst_changeNextState(context, entity, buildState, true, true); ``` The command is ephemeral; the FSM state persists and controls unit behavior until completion. --- ## Command Execution Flow Examples ### Example 1: Move Command ``` Player right-clicks map at (100, 200) ↓ wcmd_executeMoveCommand(context, {100, 200}) ↓ For each selected unit: - Calculate bounding box - Compute relative offset - Create MOVE state with target position + offset - Change unit state to MOVE ↓ Play acknowledgement sound ↓ [Game loop continues] ↓ Unit FSM executes MOVE state ↓ Pathfinding → Movement → Arrival ``` ### Example 2: Train Unit ``` Player clicks "Train Footman" button ↓ wcmd_trainFootman(context, NULL) ↓ map->command.type = WAR_COMMAND_TRAIN_FOOTMAN ↓ [Next frame: wcmd_executeCommand(context)] ↓ Check: Does barracks have 600 gold? Yes ↓ Deduct 600 gold from player ↓ Start training timer (10 seconds) ↓ Play acknowledgement sound ↓ [After 10 seconds] ↓ Footman spawns at barracks ↓ Can now be selected and commanded ``` ### Example 3: Cast Spell ``` Player clicks "Rain of Fire" button ↓ wcmd_castRainOfFire(context, NULL) ↓ map->command.type = WAR_COMMAND_SPELL_RAIN_OF_FIRE UI enters "spell targeting" mode ↓ Player clicks target tile ↓ wcmd_executeRainOfFireCommand(context, targetTile) ↓ For each selected Conjurer/Warlock: - Check: Mana >= 50? Yes - Create CAST state (spell type = RAIN_OF_FIRE) - Set target position - Change state to CAST ↓ [FSM executes CAST state] ↓ Mage walks toward target (if needed) ↓ Animation plays ↓ At cast completion: - Spell effect triggers - Rain of fire appears at target - Damage applied to units in area - Mana deducted ``` ### Example 4: Repair Building ``` Player selects 3 peasants Player right-clicks damaged barracks ↓ wcmd_executeRepairCommand(context, barracks) ↓ For each selected peasant: - Check: Is peasant friendly? Yes - Check: Is target a building? Yes - Create REPAIR state (target = barracks) - Change state to REPAIR ↓ [FSM executes REPAIR for each peasant] ↓ Peasant 1 walks to barracks Peasant 2 walks to barracks Peasant 3 walks to barracks ↓ Each plays repair animation at building ↓ Building health increases ↓ Repair continues until full health or interrupted ``` --- ## Command Queueing & Shift-Click **Without SHIFT:** - Command replaces current unit orders - Unit stops and executes new command **With SHIFT (Shift+Right-Click):** - Command is queued after current action - Unit completes current action, then executes queued command - Can queue multiple waypoints or actions ```c // Without SHIFT: Replace current order WarState* moveState = wst_createMoveState(context, entity, ...); wst_changeNextState(context, entity, moveState, true, true); // Replace state // With SHIFT: Queue waypoint if (isKeyPressed(input, WAR_KEY_SHIFT)) { WarState* moveState = getMoveState(entity); vec2ListAdd(&moveState->move.positions, targetWaypoint); // Add to queue } ``` --- ## Command Validation Before executing, commands validate: 1. **Unit validity** - Is unit friendly (owned by player)? - Is unit capable of command (e.g., workers for harvest, mages for spells)? 2. **Target validity** - Does target exist? - Is target appropriate for command (e.g., can't attack own units)? - Is target in range? 3. **Resource validation** - Player has gold/wood for training - Unit has mana for spells - Building can be repaired (has health < max) 4. **State validation** - Unit is not dead - Unit is not currently in incompatible state (e.g., can't train while under attack) - Building is constructed (not mid-construction) 5. **Feasibility** - Pathfinding can find route to target - Target location is reachable - Building location is valid (no overlap, terrain passable) --- ## Common Patterns ### Pattern 1: Simple Move/Attack ```c // User selects units and right-clicks // If terrain clicked: move wcmd_executeMoveCommand(context, terrainPos); // If enemy clicked: attack wcmd_executeAttackCommand(context, enemyUnit, enemyPos); ``` ### Pattern 2: Multi-Selection Actions ```c // Works on all selected units WarMap* map = context->map; for (s32 i = 0; i < map->selectedEntities.count; i++) { WarEntityId id = map->selectedEntities.items[i]; WarEntity* unit = we_findEntity(context, id); if (wu_isFriendlyUnit(context, unit)) { // Apply command to this unit WarState* newState = wst_createXxxState(...); wst_changeNextState(context, unit, newState, true, true); } } ``` ### Pattern 3: Formation Preservation ```c // Calculate bounding box of selected units rect bbox = getSelectionBBox(map->selectedEntities); // For each unit, maintain relative offset for (each unit in selection) { vec2 relativeOffset = unit->position - bbox.center; vec2 newTarget = targetPos + relativeOffset; // Move unit to newTarget } ``` ### Pattern 4: Resource Validation ```c // Before executing train command WarPlayerInfo* player = &map->players[player_id]; WarUnitStats* stats = wu_getUnitStats(unitToTrain); if (player->gold >= stats->cost.gold && player->wood >= stats->cost.wood) { // Deduct and create unit player->gold -= stats->cost.gold; player->wood -= stats->cost.wood; we_createUnit(context, unitToTrain, ...); } else { // Play error sound, show message wa_playErrorSound(context, player); } ``` --- ## Performance Considerations ### Efficient Multi-Unit Operations - Single loop over selected units (not nested searches) - Batch pathfinding queries - Cache unit capabilities (is worker? is mage?) - Defer state creation to dedicated state machine ### Command Queue Depth - Typically 1 command queued at a time - With Shift+Click, up to 10 waypoints per move state - No global command queue (per-unit FSM manages order) ### Validation Overhead - Validation is O(selected units count) - Typical selection: 1-20 units - Pathfinding: O(map size), done once per move - Negligible performance impact --- ## Summary The Commands System provides: - ✅ **Player input translation** - UI clicks → game state changes - ✅ **Batched multi-unit operations** - Select 10 units, command all simultaneously - ✅ **Formation preservation** - Units maintain relative positions - ✅ **Validation & error handling** - Checks resources, mana, targets, feasibility - ✅ **Audio feedback** - Acknowledgement or error sounds - ✅ **State machine integration** - Commands drive FSM behaviors - ✅ **Queuing support** - Shift+Click for waypoint chains - ✅ **Resource management** - Gold, wood, mana deduction with verification All commands flow through two APIs: 1. **Registration** (`wcmd_trainFootman()`, `wcmd_castRainOfFire()`, etc.) - Lightweight 2. **Execution** (`wcmd_executeCommand()`, `wcmd_execute*Command()`) - Validation & application The system is extensible: new commands add one registration function and one execution function. ================================================ FILE: docs/ENTITIES_SYSTEM.md ================================================ # Entities Subsystem Documentation ## Overview The **Entities subsystem** implements a component-based entity management system at the heart of War1-C's game object lifecycle. It provides fixed-size entity storage (up to 100 entities), efficient O(1) lookups via hash maps, and embedded components for cache-friendly memory access. Every game object—units (grunts, footmen), buildings (barracks, farms), projectiles (arrows), UI elements, and decorations—is an entity managed by this subsystem. The subsystem sits centrally in the engine pipeline: - **Initialization:** Called during scene entry to set up the entity manager - **Per-frame updates:** Other subsystems (state machines, animations, audio) query entities - **Per-frame cleanup:** Entities marked for removal are processed with full lifecycle cleanup - **Integration:** The pathfinder, AI system, UI system, and rendering system all query this subsystem for entity lookups ### Design Philosophy - **Data-Oriented Design (DOD):** Components are embedded as value types (not pointers) directly in the `WarEntity` struct for cache locality - **Fixed-size pools:** No dynamic allocation per-frame; all entities pre-allocated at startup - **Zero-copy entity passing:** Entity IDs (16-bit) passed between subsystems, not entity pointers - **Global state:** Single `WarEntityManager` instance manages all entities --- ## Memory & State Management ### Fixed-Size Pool Allocation The entity system uses a **pre-allocated fixed-size array** of `WarEntity` structures: ```c #define MAX_ENTITIES_COUNT 100 typedef struct { WarEntity entities[MAX_ENTITIES_COUNT]; // ... (maps and metadata) } WarEntityManager; ``` - All `MAX_ENTITIES_COUNT` entities are allocated at startup via `we_initEntityManager()` - Each entity is initialized with default values (all components disabled) - Entity allocations are **never freed** during runtime; instead, entities are marked as inactive - This approach guarantees O(1) access by index and zero allocation overhead per-frame ### Entity ID Management Entities are assigned globally unique 16-bit IDs (`WarEntityId`) via an auto-incrementing static counter: ```c static u16 staticEntityId = 1; // Never reused within a session ``` - Each `we_createEntity()` call increments the counter - IDs are **never reused**, even after entity removal (ensures handles remain valid) - ID collisions are avoided through wraparound at `U16_MAX` (unlikely in practice) ### Component Storage: Embedded Value Types All components are **embedded directly in the `WarEntity` struct** as value types, not references: ```c struct WarEntity { WarEntityId id; WarEntityType type; bool active; // Components embedded as value types: WarTransformComponent transform; WarSpriteComponent sprite; WarUnitComponent unit; // Large: ~150 bytes WarStateMachineComponent stateMachine; WarButtonComponent button; WarTextComponent text; WarAnimationsComponent animations; // ... (14+ more component types) }; ``` **Memory Benefits:** - Single cache line fetch retrieves entity + all components - No pointer indirection (eliminates dereference penalties) - Predictable memory layout for SIMD operations - Total entity struct size: ~2 KB per entity (worst-case) ### Lookup Infrastructure: Hash Maps The entity manager maintains **three hash maps** for efficient lookups: ```c typedef struct { WarEntity entities[MAX_ENTITIES_COUNT]; WarEntityMap entitiesByType; // WarEntityType → List WarUnitMap unitsByType; // WarRaceType → List WarEntityIdMap entitiesById; // WarEntityId → WarEntity* } WarEntityManager; ``` - **`entitiesByType`:** Group entities by type (e.g., all grunts, all barracks). Enables efficient batch operations. - **`unitsByType`:** Separate grouping by race (Orc/Human). Used for team/faction queries. - **`entitiesById`:** Direct ID → entity mapping. O(1) lookup by ID (average case). ### UI Entity Tracking UI entities (buttons, text labels, health bars) are tracked separately in a **linked list**: ```c extern List uiEntities; // List of WarEntityId ``` - Enables efficient batch rendering without iterating all entities - UI lookups by name use linear search: `O(n)` where `n` ≈ 50 UI entities - Potential optimization: introduce name hash map for UI entities ### Entity Removal & Cleanup When an entity is removed via `we_removeEntity()` or `we_removeEntityById()`, a full cleanup is performed: ```c void we_removeEntity(WarEntityId entityId) { WarEntity* entity = we_findEntity(entityId); if (!entity || !entity->active) return; // 1. Remove from manager maps // 2. Clean up entity lists (animations, spell timers) // 3. Free sprite resources // 4. Teardown state machine FSM // 5. Free MIDI data for audio components // 6. Mark entity inactive } ``` **Thread Safety:** Entity removal is guarded by mutex when called from concurrent threads. --- ## Core API / Functions ### Entity Manager Initialization #### `void we_initEntityManager()` - **Purpose:** Initialize the global entity manager with pre-allocated pool - **Side effects:** Populates `WarEntityManager` with `MAX_ENTITIES_COUNT` inactive entities; initializes all hash maps - **Performance:** O(n) startup cost (n = MAX_ENTITIES_COUNT); **call once at scene entry** - **Notes:** Must be called before any entity creation --- ### Entity Creation #### `WarEntityId we_createEntity(WarEntityType type)` - **Purpose:** Allocate and initialize a new generic entity - **Inputs:** Entity type (e.g., `ENTITY_TYPE_UNIT`, `ENTITY_TYPE_BUILDING`, `ENTITY_TYPE_PROJECTILE`) - **Outputs:** Globally unique `WarEntityId` (16-bit handle) - **Side effects:** - Increments static entity ID counter - Sets entity as active - Initializes transform component to origin (0, 0) - Does **not** initialize type-specific components (caller must attach via `we_add*Component()`) - **Performance:** O(1) allocation (no search required) #### `WarEntityId we_createUnit(WarRaceType race, const char* unitType, int x, int y)` - **Purpose:** Create a fully initialized unit (grunt, footman, archer, etc.) - **Inputs:** - `race`: RACE_ORC or RACE_HUMAN - `unitType`: String name (e.g., "grunt", "footman") - `x`, `y`: Initial tile coordinates - **Outputs:** Entity ID of created unit - **Side effects:** - Creates entity with type `ENTITY_TYPE_UNIT` - Attaches and initializes WarUnitComponent with full stats (HP, damage, armor, etc.) - Attaches WarStateMachineComponent with initial state `WAR_STATE_IDLE` - Adds unit to `unitsByType` map - Initializes sprite and animation components - **Performance:** O(1); initialization is linear in component count (~20 components) #### `WarEntityId we_createDude(WarRaceType race, const char* dudeName, const char* spriteKey, int x, int y)` - **Purpose:** Create a simple decorative or NPC dude (non-interactive unit) - **Inputs:** - `race`: RACE_ORC or RACE_HUMAN - `dudeName`: Name identifier - `spriteKey`: Resource key for sprite - `x`, `y`: Position - **Outputs:** Entity ID - **Side effects:** Creates entity with minimal components (transform, sprite, animation) - **Performance:** O(1); fewer components than full units #### `WarEntityId we_createBuilding(WarRaceType race, const char* buildingType, int x, int y)` - **Purpose:** Create a building entity (barracks, farm, blacksmith, etc.) - **Inputs:** Similar to `we_createUnit` - **Outputs:** Entity ID - **Side effects:** - Creates entity with type `ENTITY_TYPE_BUILDING` - Attaches WarBuildingComponent with faction and type info - Initializes sprite with correct building graphic - **Performance:** O(1) --- ### Entity Lookup #### `WarEntity* we_findEntity(WarEntityId entityId)` - **Purpose:** Retrieve entity pointer by ID - **Inputs:** Entity ID (16-bit handle) - **Outputs:** Pointer to `WarEntity`, or NULL if not found - **Side effects:** None (read-only) - **Performance:** O(1) average case via hash map lookup - **Notes:** Returned pointer valid only until next `we_removeEntity()` call #### `WarEntity* we_findUIEntity(const char* name)` - **Purpose:** Retrieve UI entity by name - **Inputs:** UI element name (e.g., "healthBarFill", "minimapButton") - **Outputs:** Pointer to `WarEntity`, or NULL if not found - **Side effects:** None - **Performance:** **O(n)** linear scan of UI entity list (n ≈ 50); name stored as String, not hashed - **Optimization:** Could use hash map for names if UI count grows beyond ~100 #### `WarEntity* we_findEntityUnderCursor(int mouseX, int mouseY)` - **Purpose:** Retrieve entity at specific screen coordinates (for mouse picking) - **Inputs:** Screen-space mouse coordinates - **Outputs:** Pointer to topmost entity at coordinates, or NULL - **Side effects:** None - **Performance:** O(visible_entity_count); typically O(1) on sparse maps - **Usage:** Called every frame during mouse event processing #### `List we_findEntitiesByType(WarEntityType type)` - **Purpose:** Get all entities of a specific type - **Inputs:** Entity type filter - **Outputs:** `List` of `WarEntityId` handles - **Side effects:** Returns reference to internal list (do not modify) - **Performance:** O(1) map lookup; result list size varies by entity count - **Usage:** Batch operations (e.g., "find all buildings to render") #### `List we_findUnitsByType(WarRaceType race)` - **Purpose:** Get all units of a specific race/faction - **Inputs:** Race type (RACE_ORC or RACE_HUMAN) - **Outputs:** `List` of `WarEntityId` handles - **Side effects:** None - **Performance:** O(1) map lookup - **Usage:** Team/faction-specific queries (e.g., "count all human units") #### `int we_countEntitiesByType(WarEntityType type)` - **Purpose:** Count entities of specific type - **Inputs:** Entity type - **Outputs:** Integer count - **Side effects:** None - **Performance:** O(1) if count cached; O(n) if counted per-call - **Note:** Check implementation to verify caching --- ### Component Attachment Each component has dedicated add/remove functions. Example pattern: #### `void we_addTransformComponent(WarEntityId entityId, int x, int y, float rotation)` - **Purpose:** Attach transform component to entity - **Inputs:** - `entityId`: Target entity - `x`, `y`: Initial position - `rotation`: Initial rotation angle - **Outputs:** None (void) - **Side effects:** Entity's transform component is initialized - **Performance:** O(1) #### `void we_addSpriteComponent(WarEntityId entityId, const char* spriteKey, int frameIndex)` - **Purpose:** Attach sprite component to entity - **Inputs:** - `spriteKey`: Resource key (e.g., "unit_grunt_idle") - `frameIndex`: Initial frame in sprite sheet - **Outputs:** None - **Side effects:** - Entity sprite initialized from resource cache - Sprite resource reference count incremented - **Performance:** O(1) if sprite already loaded; O(k) if cache miss (k = sprite load time) - **Notes:** Avoid calling inside tight loop with many unique sprite keys #### `void we_addUnitComponent(WarEntityId entityId, const char* unitType, WarRaceType race)` - **Purpose:** Attach full unit stats and AI component - **Inputs:** - `unitType`: "grunt", "footman", etc. - `race`: Faction - **Outputs:** None - **Side effects:** - Unit component initialized with base stats (HP, damage, armor, sight range) - Entity added to `unitsByType` map - State machine initialized to IDLE - **Performance:** O(1) - **Notes:** Called automatically by `we_createUnit()`; rarely called manually #### Component Removal Pattern Each component type has a corresponding remove function: ```c void we_removeSpriteComponent(WarEntityId entityId); void we_removeUnitComponent(WarEntityId entityId); void we_removeButtonComponent(WarEntityId entityId); // ... (one for each component type) ``` - **Purpose:** Detach a component from entity - **Side effects:** - Component cleanup (free lists, decrement sprite resource refs, stop animations) - Component data zeroed - Entity lists updated - **Performance:** O(1) cleanup; O(n) if component maintains internal list to clean - **Notes:** Does **not** destroy entity; only removes the component --- ### Entity Removal & Lifecycle #### `void we_removeEntity(WarEntityId entityId)` - **Purpose:** Mark entity as inactive and perform full cleanup - **Inputs:** Entity ID - **Outputs:** None - **Side effects:** - Entity marked as inactive - All components cleaned up (resources freed, lists destroyed) - Entity removed from manager maps - State machine torn down if present - **Performance:** O(component_count); typically O(1) in practice - **Thread safety:** Guarded by mutex if called from concurrent thread - **Notes:** After this call, entity ID remains allocated (can be queried but returns inactive entity) #### `void we_removeEntityById(WarEntityId entityId)` - **Purpose:** Synonym for `we_removeEntity()`; same semantics - **Inputs:** Entity ID - **Outputs:** None --- ### Global Manager Queries #### `WarEntityManager* we_getEntityManager()` - **Purpose:** Retrieve pointer to global entity manager - **Inputs:** None - **Outputs:** Pointer to `WarEntityManager` - **Side effects:** None - **Performance:** O(1) - **Usage:** Rarely needed; mostly for internal subsystem coordination #### `int we_getEntityCount()` - **Purpose:** Get total count of active entities - **Inputs:** None - **Outputs:** Integer count - **Side effects:** None - **Performance:** O(1) if count maintained; O(n) if counted per-call --- ## Data Structures ### WarEntity The central entity struct, containing all embedded components: ```c typedef struct { WarEntityId id; // Unique 16-bit handle WarEntityType type; // Type enum bool active; // Is entity active? bool isUI; // Is UI entity? // Transform: position, rotation, scale WarTransformComponent transform; // Visual: sprite, animation state WarSpriteComponent sprite; WarAnimationsComponent animations; // Game object: unit-specific stats and behavior WarUnitComponent unit; // ~150 bytes; large but essential // AI & behavior: state machine WarStateMachineComponent stateMachine; // UI-specific components WarButtonComponent button; WarTextComponent text; WarImageComponent image; WarRectComponent rect; WarTooltipComponent tooltip; // Specialized decorative components WarRoadComponent road; WarWallComponent wall; WarForestComponent forest; // Collision & sight WarCollisionComponent collision; WarSightComponent sight; } WarEntity; ``` **Memory Layout:** ~2 KB per entity; all components co-located for cache efficiency. ### WarTransformComponent Position, rotation, scale: ```c typedef struct { int x, y; // Tile grid coordinates float rotation; // Angle in radians float scaleX, scaleY; // Visual scale (1.0 = 100%) int screenX, screenY; // Cached screen space (updated by render) } WarTransformComponent; ``` **Notes:** - Position stored in **tile grid coordinates** (not pixels) - `screenX`, `screenY` are computed during render for mouse picking ### WarSpriteComponent Sprite graphics and animation state: ```c typedef struct { String spriteKey; // Resource key (e.g., "unit_grunt_idle") WarSpriteResource* sprite; // Pointer to cached sprite resource int frameIndex; // Current frame in sprite sheet float frameTime; // Elapsed time in current frame int layer; // Rendering z-order } WarSpriteComponent; ``` **Performance:** `sprite` pointer cached to avoid hash map lookup per frame. ### WarUnitComponent Game-object stats, resources, AI actions (large component): ```c typedef struct { WarRaceType race; // RACE_ORC or RACE_HUMAN String unitType; // "grunt", "footman", etc. u8 hp, maxHp; // Health u8 damage, armor; // Combat stats u8 sightRange; // Visibility radius u8 tileWidth, tileHeight; // Footprint on grid List actionQueue; // Queue of pending actions WarAction currentAction; // Action in-progress WarGameActionType currentActionType; // GATHER_WOOD, BUILD, ATTACK, etc. // Resource gathering state int gatheringGold, gatheringWood; // Collected resources int gatheringTarget; // Target entity ID // Pathfinding state List path; // Tile path from A* int pathIndex; // Current waypoint index // Behavior state WarPlayerType ownerPlayer; // Owner (human or AI) // Spell/ability timers (per-unit cooldowns) float spellCooldown[8]; // Array of ability cooldowns // References to manager for queries WarEntityManager* manager; } WarUnitComponent; ``` **Size:** ~150 bytes; large but rarely accessed in tight loops. **Notes:** - Includes full action queue for command buffering - Spell timers enable per-unit ability cooldowns - All lists embedded, no separate heap allocation ### WarStateMachineComponent Finite state machine for unit behavior: ```c typedef struct { WarStateType currentState; // Current FSM state float stateTime; // Time in current state WarStateContext context; // State-specific data } WarStateMachineComponent; ``` **States:** IDLE, MOVE, ATTACK, GATHER, BUILD, DIE, ATTACK_BUILDING, etc. **Transitions:** Driven by unit actions and external events. ### WarButtonComponent UI button state and handlers: ```c typedef struct { bool isHot; // Mouse over? bool isActive; // Pressed? void (*onClickHandler)(WarEntity* entity); // Click callback String tooltipText; // Hover text } WarButtonComponent; ``` ### WarTextComponent Rendered text: ```c typedef struct { String text; // Text content String fontKey; // Font resource key WarAlignment alignment; // Text alignment WarColor color; // Text color (RGBA) bool highlighted; // Selection highlight } WarTextComponent; ``` ### WarAnimationsComponent Active animations queue: ```c typedef struct { List activeAnimations; // List of WarAnimation structs float globalAnimationTime; // Global time accumulator } WarAnimationsComponent; ``` ### WarEntityManager Global entity manager struct: ```c typedef struct { WarEntity entities[MAX_ENTITIES_COUNT]; // Entity pool WarEntityMap entitiesByType; // WarEntityType → List WarUnitMap unitsByType; // WarRaceType → List WarEntityIdMap entitiesById; // WarEntityId → WarEntity* int activeEntityCount; // Count of active entities } WarEntityManager; ``` --- ## Usage Example ### Basic Entity Lifecycle ```c // Pseudo-code: Entity creation, updates, removal in game loop void initGameScene() { // 1. Initialize entity manager at scene start we_initEntityManager(); // 2. Create some units and buildings WarEntityId gruntId = we_createUnit(RACE_ORC, "grunt", 10, 5); WarEntityId farmId = we_createBuilding(RACE_ORC, "farm", 15, 10); WarEntityId arrowId = we_createEntity(ENTITY_TYPE_PROJECTILE); // 3. Customize entities if needed WarEntity* grunt = we_findEntity(gruntId); if (grunt) { grunt->unit.hp = 50; // Damage it grunt->transform.rotation = 1.57f; // 90 degrees } } void updateGameLoop(float deltaTime) { // 1. Query all units of a type List humanUnits = we_findUnitsByType(RACE_HUMAN); for (int i = 0; i < list_length(humanUnits); i++) { WarEntityId unitId = list_get(humanUnits, i); WarEntity* unit = we_findEntity(unitId); if (unit && unit->active) { // Update unit behavior via state machine wst_updateStateMachine(unit->stateMachine, deltaTime); // Update animations wanim_updateAnimations(&unit->animations, deltaTime); } } // 2. Check for mouse picking WarEntity* pickedEntity = we_findEntityUnderCursor(inputX, inputY); if (pickedEntity && pickedEntity->isUI) { // Handle UI interaction } // 3. Render all entities List allEntities = /* iterate entity pool */; for (int i = 0; i < MAX_ENTITIES_COUNT; i++) { WarEntity* entity = &manager->entities[i]; if (entity->active && !entity->isUI) { wr_drawEntity(entity); } } } void cleanupEntity() { // Full removal: cleanup + deactivation we_removeEntity(gruntId); // Grunt removed, cleaned up // After removal: // - Entity sprite resources freed // - State machine torn down // - Action queue cleared // - Entity marked inactive // - Entity ID can still be queried, but returns inactive state } ``` ### Component Attachment Pattern ```c // Create an entity WarEntityId myEntity = we_createEntity(ENTITY_TYPE_DECORATION); // Attach components manually we_addTransformComponent(myEntity, 5, 10, 0.0f); we_addSpriteComponent(myEntity, "tree_sprite", 0); we_addAnimationsComponent(myEntity); // Query and use WarEntity* entity = we_findEntity(myEntity); entity->sprite.frameIndex = 2; entity->transform.rotation = 3.14f; ``` --- ## Dependencies ### Internal Dependencies (War1-C Modules) - **`war_units.h` / `war_units.c`:** Unit type definitions, stat tables, unit creation helpers - **`war_resources.h` / `war_resources.c`:** Sprite resource caching, resource loading - **`war_animations.h` / `war_animations.c`:** Animation playback for entities - **`war_state_machine.h` / `war_state_machine.c`:** FSM tick, state transitions - **`war_alloc.h` / `war_alloc.c`:** Memory allocation (wm_alloc/wm_free) - **`war_render.h` / `war_render.c`:** Drawing entities (wr_drawEntity) - **`war_audio.h` / `war_audio.c`:** MIDI playback for units - **`war_actions.h`:** Unit action definitions - **`war_fwd.h`:** Forward declarations and type definitions ### External Dependencies - **SHL Libraries:** `shl/list.h`, `shl/map.h` (hash maps, linked lists) - **STB Libraries:** `stb/ds.h` (dynamic arrays if used) - **SDL3:** `SDL3/SDL.h` (threading primitives for mutex) --- ## Performance Considerations ### Cache Locality: Embedded Components All components stored inline in `WarEntity` guarantee a single cache line fetch retrieves entity + all components. This is significantly faster than pointer-chased component access: ```c // Good: Single cache line fetch WarEntity* entity = we_findEntity(id); int hp = entity->unit.hp; int x = entity->transform.x; // Bad (if components were separate): Multiple cache misses WarUnitComponent* unit = we_findUnitComponent(id); WarTransformComponent* transform = we_findTransformComponent(id); ``` ### O(1) Lookups via Hash Maps All three lookup maps (`entitiesByType`, `unitsByType`, `entitiesById`) use SHL hash map with average O(1) performance: ```c // O(1) average: fetch all units of race List humanUnits = we_findUnitsByType(RACE_HUMAN); ``` **Potential Bottleneck:** UI entity name lookup is O(n) linear scan. For large UI counts (100+), add a name-based hash map. ### Avoid Per-Frame Allocations All entity structures pre-allocated at startup. No `malloc/free` calls during gameplay, eliminating allocation/fragmentation overhead. ### Batch Rendering Optimization UI entities tracked separately in `uiEntities` list, avoiding iteration over all 100 entities when rendering UI-only. ### State Machine Update Overhead Each unit's state machine is ticked every frame via `wst_updateStateMachine()`. For large unit counts (50+), consider: - Spatial partitioning to skip distant units - Async state updates on separate thread ### Component Size Trade-off `WarUnitComponent` is large (~150 bytes). If memory is critical, consider: - Storing unit stats in separate array (trade cache locality for memory density) - Lazy-loading spell cooldowns only for units with abilities --- ## Patterns & Idioms ### Batch Operations on Entity Type ```c List allBuildings = we_findEntitiesByType(ENTITY_TYPE_BUILDING); for (int i = 0; i < list_length(allBuildings); i++) { WarEntityId id = list_get(allBuildings, i); WarEntity* building = we_findEntity(id); // Process building... } ``` ### Safe Entity Queries with Active Check ```c WarEntity* entity = we_findEntity(entityId); if (entity && entity->active) { // Safe to use entity } else { // Entity removed or invalid ID } ``` ### Entity Creation and Customization ```c WarEntityId unitId = we_createUnit(RACE_ORC, "grunt", 10, 5); WarEntity* unit = we_findEntity(unitId); if (unit) { unit->unit.hp = 30; // Custom health unit->transform.rotation = 0.5f; // Rotation } ``` ### Deferred Entity Removal Instead of removing entities immediately, mark them for deferred cleanup: ```c // Mark for removal (doesn't cleanup yet) entity->active = false; // Later, in cleanup phase: // we_removeEntity(entityId); // Full cleanup ``` --- ## Known Limitations & Future Improvements 1. **UI Entity Name Lookup:** O(n) linear scan. Consider hash map for names if UI count grows beyond 100. 2. **Fixed Entity Pool:** Hard limit of 100 entities. Dynamic resizing would require pointer stability (problematic for embedded components). 3. **Component Removal Fragmentation:** Removing components leaves "holes" in component data. No defragmentation; acceptable for small entity counts. 4. **No Archetype System:** Entities store all 14+ component types even if unused. Archetype-based systems (only allocate components actually used) could reduce memory per entity. 5. **Single-Threaded Hot Path:** Entity lookups and updates assume single-threaded access. Contention on entity manager mutex could become a bottleneck with concurrent subsystems. --- ## See Also - **UI Subsystem:** `docs/UI_Subsystem.md` — Entity creation for UI elements - **State Machines:** `war_state_machine.h` — FSM architecture for entity behavior - **Pathfinding:** `war_pathfinder.h` — A* routing for unit movement - **Rendering:** `war_render.h` — Drawing entities to screen ================================================ FILE: docs/INPUT_SYSTEM.md ================================================ # Input Subsystem Documentation ## Overview The input subsystem is the engine's frame-synchronous translation layer between raw SDL3 events and the rest of the game runtime. Its job is to normalize mouse and keyboard input into a compact `WarInput` snapshot stored directly inside `WarContext`, then expose that snapshot to higher-level systems such as scenes, UI, map selection, camera scrolling, and commands. In the main loop, the input pipeline is: ```c wg_beginInputFrame(context); while (SDL_PollEvent(&event)) { wg_processGameEvent(context, &event); } wg_updateGame(context); wg_renderGame(context); wg_presentGame(context); ``` That ordering matters: - `wg_beginInputFrame()` clears one-frame edge flags. - `wg_processGameEvent()` folds all SDL events for the frame into `context->input`. - Scene, UI, and map code consume `held`, `justPressed`, and `justReleased` during `wg_updateGame()`. This subsystem sits early in the engine pipeline, before gameplay update and rendering, and provides the canonical input state used everywhere else. ## Memory & State Management ### Ownership Model `WarInput` is embedded directly in `WarContext`: ```c struct _WarContext { // ... WarInput input; // ... }; ``` There is no standalone input manager allocation, no per-frame heap churn, and no teardown routine for input-specific memory. The input state has the same lifetime as the owning `WarContext`, which is allocated once during startup and destroyed at shutdown. ### Fixed-Size Storage The subsystem uses compile-time-sized arrays: - `buttons[WAR_MOUSE_COUNT]` - `keys[WAR_KEY_COUNT]` This keeps input state contiguous and predictable in memory. Runtime growth, hash lookups, and pointer chasing are avoided in the hot path. ### Frame Model Each key and mouse button stores three bits of temporal state in `WarInputState`: - `held`: current stable state - `justPressed`: edge that became true this frame only - `justReleased`: edge that became true this frame only `wg_beginInputFrame()` clears only the transient edge flags. The `held` bits persist until an actual release event or a focus-loss reset arrives. ### Cache Locality The input snapshot is intentionally small: - mouse position (`vec2`) - button states in a dense array - key states in a dense array - a few gesture/UI-capture fields (`capturedUIButtonId`, `mapDragActive`, `mapDragStartPos`, `mapDragRect`) No explicit packing pragmas or custom alignment attributes are used. The performance strategy is instead to keep the data plain, contiguous, and resident inside the already-hot `WarContext`. ### Logical Coordinate Normalization The renderer uses SDL logical presentation at `320x200`. SDL3 does not automatically rewrite incoming event coordinates to that logical space, so `wg_processGameEvent()` explicitly calls: ```c SDL_ConvertEventToRenderCoordinates(context->renderer, event); ``` As a result, every consumer reads `input->pos` in the same coordinate system used by UI layout, map panels, and cursor rendering. ### Reset-on-Focus-Loss Behavior When the window loses focus, is minimized, or becomes hidden, the subsystem clears: - every `held` / `justPressed` / `justReleased` bit - `capturedUIButtonId` - `mapDragActive` - `mapDragStartPos` - `mapDragRect` This prevents sticky keys, stuck mouse buttons, and stale drag gestures after alt-tab or minimize/restore cycles. ## Core API / Functions ## Public Functions ### `void wg_setInputButton(WarContext* context, s32 button, bool pressed)` **Defined in:** `src/war_game.c` **Declared in:** `src/war_game.h` ```c void wg_setInputButton(WarContext* context, s32 button, bool pressed); ``` **Purpose** Updates one logical mouse button slot in `context->input.buttons`. **Inputs** - `context`: owning game context - `button`: expected to be a valid `WarMouseButtons` index such as `WAR_MOUSE_LEFT` or `WAR_MOUSE_RIGHT` - `pressed`: new stable state for that button **Outputs** - No return value **Side Effects** - Mutates `context->input.buttons[button]` - Sets `justPressed` only on a `false -> true` transition - Sets `justReleased` only on a `true -> false` transition **Performance Notes** - O(1) - No bounds checking is performed; callers must pass a valid enum index - Repeated press events while already held do not retrigger `justPressed` ### `void wg_setInputKey(WarContext* context, s32 key, bool pressed)` **Defined in:** `src/war_game.c` **Declared in:** `src/war_game.h` ```c void wg_setInputKey(WarContext* context, s32 key, bool pressed); ``` **Purpose** Updates one logical keyboard slot in `context->input.keys`. **Inputs** - `context`: owning game context - `key`: expected to be a valid `WarKeys` index - `pressed`: new stable state for that key **Outputs** - No return value **Side Effects** - Mutates `context->input.keys[key]` - Emits one-frame `justPressed` / `justReleased` edges based on state transitions **Performance Notes** - O(1) - No bounds checking is performed - SDL key repeat does not create repeated `justPressed` edges because the transition test is state-based ### `void wg_beginInputFrame(WarContext* context)` **Defined in:** `src/war_game.c` **Declared in:** `src/war_game.h` ```c void wg_beginInputFrame(WarContext* context); ``` **Purpose** Begins a new frame of input processing by clearing the transient edge flags on all keys and mouse buttons. **Inputs** - `context`: owning game context **Outputs** - No return value **Side Effects** - Sets every `buttons[i].justPressed` and `buttons[i].justReleased` to `false` - Sets every `keys[i].justPressed` and `keys[i].justReleased` to `false` - Leaves all `held` bits unchanged **Performance Notes** - O(`WAR_MOUSE_COUNT + WAR_KEY_COUNT`) - In practice, constant-time and cheap enough to run every frame - Must run before SDL event polling if downstream systems rely on one-frame edge semantics ### `void wg_processGameEvent(WarContext* context, SDL_Event* event)` **Defined in:** `src/war_game.c` **Declared in:** `src/war_game.h` ```c void wg_processGameEvent(WarContext* context, SDL_Event* event); ``` **Purpose** Consumes one SDL event and folds it into the engine's logical input state. **Inputs** - `context`: owning game context - `event`: mutable SDL event received from `SDL_PollEvent()` **Outputs** - No return value **Side Effects** - Rewrites `event` coordinates into logical render space with `SDL_ConvertEventToRenderCoordinates()` - Updates `input->pos` on mouse motion and mouse button events - Updates logical mouse button state via `wg_setInputButton()` - Updates logical key state via `wg_setInputKey()` - Appends text input to the active cheat console when cheat text entry is enabled and visible - Grabs or releases the mouse when window focus changes - Clears all held/edge state and drag/UI-capture state on focus loss, minimize, or hide **Performance Notes** - O(1) for most event types - `SDL_EVENT_TEXT_INPUT` is O(text length) - Safe to call once per SDL event in the outer loop - This is not an inner-loop gameplay function; it belongs in the event pump only **Behavior Details** - Left and right mouse buttons are mapped to `WAR_MOUSE_LEFT` and `WAR_MOUSE_RIGHT` - SDL left/right Shift, Ctrl, and Alt are collapsed into one logical slot each: `WAR_KEY_SHIFT`, `WAR_KEY_CTRL`, `WAR_KEY_ALT` - Modifier keys are derived from `event->key.mod`, which avoids dropping the logical modifier state when one physical side is released while the other is still held ## Query Macros These macros are the main read-side API used by gameplay code: ```c #define isButtonHeld(input, btn) ((input)->buttons[btn].held) #define isButtonJustPressed(input, btn) ((input)->buttons[btn].justPressed) #define isButtonJustReleased(input, btn) ((input)->buttons[btn].justReleased) #define isKeyHeld(input, key) ((input)->keys[key].held) #define isKeyJustPressed(input, key) ((input)->keys[key].justPressed) #define isKeyJustReleased(input, key) ((input)->keys[key].justReleased) #define isMapDragging(input) ((input)->mapDragActive) ``` **Purpose** Provide branch-free, inline access to the current input snapshot. **Inputs / Outputs** - Input: pointer to `WarInput` plus a valid enum index - Output: boolean expression result **Side Effects** - None **Performance Notes** - Compile to direct field access - Intended for hot call sites in UI, scene, and map update code - No bounds checking ## Internal Helpers Relevant to Behavior These are not declared in `war_game.h`, but they define important subsystem behavior. ### `static WarKeys wg_getWarKeyFromSDLKey(SDL_Keycode key)` Maps SDL keycodes to the engine's compact `WarKeys` enum. Unsupported keys return `WAR_KEY_NONE` and are ignored by the rest of the subsystem. ### `static void wg_appendCheatTextInput(WarContext* context, StringView text)` Routes SDL text input into the cheat-entry text buffer owned by the active scene or map. Only printable ASCII codepoints (`32..126`) are accepted, and only while cheat entry is both enabled and visible. This helper is the only place where the input path performs string manipulation. The core `WarInput` snapshot itself remains allocation-free. ## Data Structures ### `WarInputState` ```c struct _WarInputState { bool held; bool justPressed; bool justReleased; }; ``` **Purpose** Represents one logical button/key slot with both stable and edge-triggered state. **Field Notes** - `held`: true while the logical input remains down - `justPressed`: true for one frame on the press edge - `justReleased`: true for one frame on the release edge **Layout Notes** - Plain old data, contiguous in arrays - No explicit bit-packing; the implementation favors simplicity and direct access over manual compression ### `WarInput` ```c struct _WarInput { vec2 pos; WarInputState buttons[WAR_MOUSE_COUNT]; WarInputState keys[WAR_KEY_COUNT]; WarEntityId capturedUIButtonId; bool mapDragActive; vec2 mapDragStartPos; rect mapDragRect; }; ``` **Purpose** Stores the entire input snapshot for the current frame plus a small amount of cross-system gesture/UI ownership state. **Field Notes** - `pos`: latest mouse position in logical render coordinates - `buttons`: logical mouse button state array - `keys`: logical keyboard state array - `capturedUIButtonId`: UI button currently owning the active mouse press - `mapDragActive`: true while a map-panel drag selection is in progress - `mapDragStartPos`: drag origin in screen/logical coordinates - `mapDragRect`: current drag rectangle in screen/logical coordinates **Design Notes** - `capturedUIButtonId` lets the UI layer preserve click ownership across hover changes - `mapDrag*` state lives in input rather than map-local temporary variables so drag gestures remain part of the same frame snapshot that all systems read ### `WarMouseButtons` ```c typedef enum _WarMouseButtons { WAR_MOUSE_LEFT, WAR_MOUSE_RIGHT, WAR_MOUSE_COUNT } WarMouseButtons; ``` **Purpose** Defines the compact index space for `WarInput.buttons`. ### `WarKeys` ```c typedef enum _WarKeys { WAR_KEY_NONE, // printable keys // navigation keys // function keys WAR_KEY_SHIFT, WAR_KEY_CTRL, WAR_KEY_ALT, WAR_KEY_COUNT } WarKeys; ``` **Purpose** Defines the compact index space for `WarInput.keys`. **Design Notes** - Physical left/right modifier keys are merged into one logical slot per modifier - The enum acts as a translation boundary: gameplay code never needs SDL keycodes directly ## Engine Integration Notes The input subsystem is intentionally small, but it carries state used by multiple downstream systems. ### UI Integration `wui_updateUIButtons()` uses: - `input->pos` for hit testing - `isButtonJustPressed()` to capture a button - `isButtonHeld()` to maintain pressed visuals - `isButtonJustReleased()` to fire click handlers - `capturedUIButtonId` to keep ownership stable during a click-drag-release sequence ### Map Integration `war_map.c` uses input for: - edge scrolling from mouse position - keyboard scrolling from arrow keys - left-drag selection rectangles - right-click command issuing - modifier-aware selection extension using Ctrl The map layer also updates `mapDragActive`, `mapDragStartPos`, and `mapDragRect` as part of drag selection. ### Scene Integration Scene code uses frame-edge queries for discrete actions such as: - `Enter` to continue from briefing/download screens - `Space` or mouse click to advance - `Esc`, `Tab`, arrow keys, and editing keys in map UI flows Because `justPressed` and `justReleased` are cleared once per frame, scene logic can safely treat those queries as one-shot triggers. ## Usage Example ```c WarContext* context = wm_alloc(sizeof(WarContext)); bool running = wg_initGame(context); while (running) { wg_beginInputFrame(context); SDL_Event event; while (SDL_PollEvent(&event)) { wg_processGameEvent(context, &event); if (event.type == SDL_EVENT_QUIT) { running = false; } } WarInput* input = &context->input; if (isKeyHeld(input, WAR_KEY_CTRL) && isKeyJustReleased(input, WAR_KEY_P)) { context->paused = !context->paused; } wg_updateGame(context); wg_renderGame(context); wg_presentGame(context); } wg_quitGame(context); ``` Minimal consumer-side usage inside a gameplay module: ```c WarInput* input = &context->input; if (isButtonJustPressed(input, WAR_MOUSE_LEFT)) { // begin selection or activate UI } if (isButtonJustReleased(input, WAR_MOUSE_RIGHT)) { // finish a right-click action } if (isKeyHeld(input, WAR_KEY_LEFT)) { // scroll map left while held } ``` ## Dependencies ### External Dependencies - `SDL3/SDL_events.h` - `SDL3/SDL.h` - `math.h` for `floorf()` - `assert.h` - `shl/wstr.h` for cheat text insertion ### Internal Headers - `src/war_game.h` - `src/war.h` - `src/war_fwd.h` - `src/war_enums.h` - `src/common.h` - `src/war_math.h` ### Internal Engine Modules Touched by the Input Path - `src/war1.c` for main-loop integration - `src/war_ui.c` for UI cursor and button handling - `src/war_map.c` for camera movement, selection drag, and commands - `src/war_scene_briefing.c` and `src/war_scene_download.c` for scene-level key/button triggers ## Performance Summary - No dynamic allocation in the core `WarInput` snapshot path - Constant-time state updates per input event - Constant-time read access through macros - One small linear clear per frame over fixed-size arrays - Logical-coordinate conversion is performed once per SDL event, which keeps all downstream input consumers free of per-call coordinate remapping This is a good fit for the rest of the engine's DOD-oriented architecture: small state, predictable memory access, and explicit frame boundaries. ================================================ FILE: docs/SCENES_SYSTEM.md ================================================ # Scenes Management Subsystem ## Overview The **Scenes subsystem** (`war_scenes.h`, `war_scenes.c`) is the central state machine manager for distinct game screens and lifecycle phases. It orchestrates transitions between the download screen, blizzard logo intro, main menu, briefing screens, and the active gameplay map. Each scene encapsulates its own entity collection, rendering pipeline, and scene-specific state through a tagged union architecture. **Position in engine pipeline:** After SDL3 initialization and resource loading, the game loop dispatches `wsc_enterScene()`, `wsc_updateScene()`, `wsc_renderScene()`, and `wsc_leaveScene()` each frame. The scene manager routes these calls to scene-specific handler functions via a descriptor table, ensuring clean separation of concerns and minimal branching in the hot path. --- ## Memory & State Management ### Fixed-Size Descriptor Table The subsystem uses a **compile-time descriptor table** defined as: ```c WarSceneDescriptor sceneDescriptors[WAR_SCENE_COUNT] = { ... }; ``` This static array maps `WarSceneType` enum values (0–3) directly to function pointers. This approach **eliminates dynamic lookups** and provides **O(1) dispatch** to scene handlers. ### Scene Allocation Strategy - **Scene creation** allocates a single `WarScene` structure via `wm_alloc(sizeof(WarScene))`. - Each scene embeds a complete **`WarEntityManager`** (8 collections of entities, units, roads, walls, ruins, forests, etc.). - **Entity collections use vendored `shl/` containers** (lists, maps, sets) which manage internal allocations; scene deletion frees all collections at once. ### Tagged Union for Scene-Specific Data The `WarScene` structure uses a union to avoid per-scene memory overhead: ```c struct _WarScene { WarSceneType type; WarEntityManager entityManager; WarCheatStatus cheatStatus; union { struct { WarSceneDownloadState status; } download; struct { f32 time; } blizzard; struct { WarRace yourRace, enemyRace; s32 customMap; } menu; struct { f32 time; WarRace race; WarCampaignMapType mapType; } briefing; }; }; ``` **Memory layout:** Only the active union member consumes stack/heap space. For example: - **Blizzard scene**: Uses only `time` (4 bytes) - **Menu scene**: Uses race selections and custom map ID (12 bytes total) - **Briefing scene**: Uses timing, race, and campaign type (16 bytes total) The union is **cache-friendly** for each scene type independently but minimal for the inactive ones. ### Entity Container Organization Each scene's entity manager maintains five heterogeneous collections: | Collection | Purpose | Type | Note | |---|---|---|---| | `entities` | All non-UI entities (units, buildings, projectiles, animations) | `WarEntityList` | Primary working set | | `entitiesByType` | Indexed by `WarEntityType` for type-based queries | `WarEntityMap` | Supports fast "all units" lookups | | `unitsByType` | Indexed by `WarUnitType` for unit-specific queries | `WarUnitMap` | Enables combat/pathfinding optimization | | `entitiesById` | Indexed by `WarEntityId` for O(1) entity lookups by ID | `WarEntityIdMap` | Used by commands and targeting | | `uiEntities` | UI-only entities (buttons, text, panels, cursors) | `WarEntityList` | Separated for render ordering | All containers are **zero-initialized** at scene entry and **deep-freed** at scene exit, ensuring no lingering allocations between scenes. --- ## Core API / Functions ### Scene Lifecycle Functions #### `WarScene* wsc_createScene(WarContext* context, WarSceneType type)` **Signature:** ```c WarScene* wsc_createScene(WarContext* context, WarSceneType type); ``` **Inputs:** - `context`: Pointer to the game context (contains delta time, input, rendering state, etc.) - `type`: One of `WAR_SCENE_DOWNLOAD`, `WAR_SCENE_BLIZZARD`, `WAR_SCENE_MAIN_MENU`, `WAR_SCENE_BRIEFING` **Outputs:** - Returns a heap-allocated `WarScene*` initialized with the given type and an empty entity manager **Side effects:** - Allocates memory via `wm_alloc(sizeof(WarScene))` - Initializes the embedded `WarEntityManager` with empty collections via `we_initEntityManager()` - Does **not** call enter handlers (use `wsc_enterScene()` separately) **Performance:** - **O(1) allocation** (fixed-size struct) - **O(n)** entity manager initialization (where n = number of collection types; typically small constant) - **Safe to call at runtime** (no dependencies on loaded resources yet) --- #### `void wsc_freeScene(WarScene* scene)` **Signature:** ```c void wsc_freeScene(WarScene* scene); ``` **Inputs:** - `scene`: Pointer to the scene to deallocate **Outputs:** - None (void) **Side effects:** - Deep-frees all entity lists via `WarEntityListFree()`, map containers, and unit containers - Deallocates the scene structure itself (caller responsibility to null the pointer) - **Does not** call `wsc_leaveScene()` handlers; assumes handlers have already cleaned up audio, UI state, etc. **Performance:** - **O(m)** where m = total entities in all collections - Safe to call immediately after scene transitions --- #### `void wsc_enterScene(WarContext* context)` **Signature:** ```c void wsc_enterScene(WarContext* context); ``` **Inputs:** - `context`: Pointer to the game context; reads `context->scene` to determine which scene's enter handler to invoke **Outputs:** - None (void) **Side effects:** - **Validates** the scene type is within range `[0, WAR_SCENE_COUNT)` - **Dispatches** to the scene-specific enter function via the descriptor table - E.g., for `WAR_SCENE_BLIZZARD`: calls `wsc_enterSceneBlizzard(context)` (sets up logo image, audio) - For `WAR_SCENE_MAIN_MENU`: calls `wsc_enterSceneMainMenu(context)` (creates menu buttons, backdrop) - Enter handlers are responsible for: - Creating initial UI entities (buttons, text, images) - Starting audio playback - Initializing scene-specific union members (e.g., `scene->blizzard.time = 3.0f`) **Performance:** - **O(1)** function dispatch + scene-specific overhead (typically O(k) where k = number of UI elements for that scene) - Should be called once per scene transition (not every frame) --- #### `void wsc_updateScene(WarContext* context)` **Signature:** ```c void wsc_updateScene(WarContext* context); ``` **Inputs:** - `context`: Pointer to the game context; reads `context->scene` and `context->deltaTime` **Outputs:** - None (void) **Side effects:** - **Validates** the scene type is within range - **Dispatches** to the scene's update function if it exists (descriptor table lookup) - E.g., `WAR_SCENE_BLIZZARD` calls `wsc_updateSceneBlizzard()` to decrement the intro timer - E.g., `WAR_SCENE_DOWNLOAD` calls `wsc_updateSceneDownload()` to poll file download status - **Fallback behavior** (for scenes without custom update handlers, such as `WAR_SCENE_MAIN_MENU`): - Updates cheat status display via `wcheatp_updateCheatsPanel(context)` - Updates all UI buttons (hover, click states) via `wui_updateUIButtons()` - Updates cursor state via `wui_updateUICursor()` - Updates sprite animations via `wanim_updateAnimations()` **Performance:** - **O(1)** dispatch + scene-specific update cost - Called **every frame** in the main game loop; scene-specific handlers should avoid expensive operations - For heavy computation (pathfinding, AI), defer work to background threads or amortize over multiple frames --- #### `void wsc_renderScene(WarContext* context)` **Signature:** ```c void wsc_renderScene(WarContext* context); ``` **Inputs:** - `context`: Pointer to the game context; reads `context->scene` **Outputs:** - None (void) **Side effects:** - Retrieves the UI entity list from the scene's entity manager - **Iterates all entities** and filters for UI entities and animations - **Dispatches render calls** to each visible entity via `we_renderEntity(context, entity)` - Rendering order is implicit in iteration order (render ordering managed elsewhere, e.g., z-order in transform or insertion order) **Performance:** - **O(k)** where k = number of UI + animation entities in the scene (typically small, <50 for menus) - Culled to only UI entities; gameplay entities (map, units) are rendered via separate rendering pipelines --- #### `void wsc_leaveScene(WarContext* context)` **Signature:** ```c void wsc_leaveScene(WarContext* context); ``` **Inputs:** - `context`: Pointer to the game context; reads `context->scene` **Outputs:** - None (void) **Side effects:** - **Validates** the scene type is within range - **Dispatches** to the scene's leave handler if defined (optional) - **Default behavior** (if no leave handler): calls `wsc_freeScene()` and nulls `context->scene` - Leave handlers can perform custom cleanup (e.g., pausing/stopping audio loops, saving progress) **Performance:** - **O(1)** dispatch + scene-specific cleanup - Called once per scene transition (not per frame) --- ## Data Structures ### `WarSceneType` Enum ```c typedef enum _WarSceneType { WAR_SCENE_DOWNLOAD, // 0: Asset download screen (from net connection) WAR_SCENE_BLIZZARD, // 1: Blizzard Entertainment logo intro (timed ~3 sec) WAR_SCENE_MAIN_MENU, // 2: Main game menu (campaign select, single player, custom) WAR_SCENE_BRIEFING, // 3: Level briefing (story text, race selection for custom maps) WAR_SCENE_COUNT // 4: (count, not a valid scene type) } WarSceneType; ``` **Usage:** - Indexes into the `sceneDescriptors` static array for **O(1) function dispatch** - Cast to `s32` for range validation: `inRange(scene->type, 0, WAR_SCENE_COUNT)` --- ### `WarSceneDownloadState` Enum ```c typedef enum _WarSceneDownloadState { WAR_SCENE_DOWNLOAD_DOWNLOAD, // Initial state; show "Download DATA.WAR?" WAR_SCENE_DOWNLOAD_CONFIRM, // User selected "Yes"; awaiting network request WAR_SCENE_DOWNLOAD_DOWNLOADING, // Download in progress; show progress bar WAR_SCENE_DOWNLOAD_DOWNLOADED, // Download completed; validating checksum WAR_SCENE_DOWNLOAD_FILE_LOADED, // File loaded and verified; ready to proceed WAR_SCENE_DOWNLOAD_FAILED // Network or checksum error; show retry dialog } WarSceneDownloadState; ``` **Usage:** - Stored in `scene->download.status` - Transitions driven by `wsc_updateSceneDownload()` - Used to render appropriate UI dialogs and messages --- ### `WarScene` Structure ```c struct _WarScene { WarSceneType type; WarEntityManager entityManager; WarCheatStatus cheatStatus; union { struct { WarSceneDownloadState status; } download; struct { f32 time; } blizzard; struct { WarRace yourRace, enemyRace; s32 customMap; } menu; struct { f32 time; WarRace race; WarCampaignMapType mapType; } briefing; }; }; ``` **Fields:** | Field | Type | Purpose | |---|---|---| | `type` | `WarSceneType` | Identifies which scene variant is active; indexes descriptor table | | `entityManager` | `WarEntityManager` | All entities for this scene (UI, animations, projectiles, etc.) | | `cheatStatus` | `WarCheatStatus` | Cheat code input state (enables in-game dev commands) | | `union {...}` | (tagged union) | Scene-specific mutable state (compact; only active member uses memory) | **Memory layout:** - `type` + `entityManager` + `cheatStatus` = ~constant size (~400 bytes) - Union member = 4–16 bytes depending on scene type - **Total: ~416 bytes per scene** **Alignment & Padding:** - Entity manager (list, map containers) may have struct padding to align hash table allocations - Union members are naturally aligned to largest member (`briefing.time`, `briefing.race`, `briefing.mapType`) --- ### `WarSceneDescriptor` Structure ```c struct _WarSceneDescriptor { WarSceneType type; WarSceneFunc enterSceneFunc; WarSceneFunc leaveSceneFunc; WarSceneFunc updateSceneFunc; }; ``` **Fields:** | Field | Type | Purpose | |---|---|---| | `type` | `WarSceneType` | Identifies the descriptor (redundant but useful for validation) | | `enterSceneFunc` | `WarSceneFunc` | Callback invoked by `wsc_enterScene()` to set up scene entities and audio | | `leaveSceneFunc` | `WarSceneFunc` | Callback invoked by `wsc_leaveScene()` (optional; NULL means use default cleanup) | | `updateSceneFunc` | `WarSceneFunc` | Callback invoked by `wsc_updateScene()` each frame (optional; NULL means skip) | **WarSceneFunc Typedef:** ```c typedef void (*WarSceneFunc)(WarContext* context); ``` **Descriptor Table (Static):** ```c WarSceneDescriptor sceneDescriptors[WAR_SCENE_COUNT] = { { WAR_SCENE_DOWNLOAD, wsc_enterSceneDownload, NULL, wsc_updateSceneDownload }, { WAR_SCENE_BLIZZARD, wsc_enterSceneBlizzard, NULL, wsc_updateSceneBlizzard }, { WAR_SCENE_MAIN_MENU, wsc_enterSceneMainMenu, NULL, NULL }, { WAR_SCENE_BRIEFING, wsc_enterSceneBriefing, NULL, wsc_updateSceneBriefing } }; ``` --- ### `WarEntityManager` Structure ```c struct _WarEntityManager { s32 staticEntityId; WarEntityList entities; WarEntityMap entitiesByType; WarUnitMap unitsByType; WarEntityIdMap entitiesById; WarEntityList uiEntities; }; ``` **Responsibility within a Scene:** - Holds all **interactive game objects** (units, buildings, UI buttons, effects, sounds) - Supports **type-based queries** (e.g., "get all footmen") and **ID-based lookups** - Enables **efficient rendering** (separate UI list for menu rendering) - Tracks next available entity ID for dynamic entity creation **Collections:** | Collection | Key Type | Value | Iteration Speed | |---|---|---|---| | `entities` | (list index) | `WarEntity*` | O(n) via linear scan | | `entitiesByType` | `WarEntityType` | `WarEntityList*` | O(k) where k = entities of type | | `unitsByType` | `WarUnitType` | `WarEntityList*` | O(k) where k = units of type | | `entitiesById` | `WarEntityId` | `WarEntity*` | O(1) hash lookup | | `uiEntities` | (list index) | `WarEntity*` | O(m) where m = UI entities | --- ## Usage Example ### Minimal Integration in Game Loop ```c // Pseudo-code showing scene lifecycle in main game loop int main() { WarContext context = { 0 }; // Initialize engine (resources, rendering, input) initEngine(&context); // Create and enter first scene WarScene* scene = wsc_createScene(&context, WAR_SCENE_BLIZZARD); context.scene = scene; wsc_enterScene(&context); // Sets up logo image, plays audio // Main game loop while (context.running) { // Poll input, calc deltaTime, etc. handleInput(&context); context.deltaTime = calculateDeltaTime(); // Update scene (may trigger scene transition) wsc_updateScene(&context); // Clear and render clearScreen(); wsc_renderScene(&context); flipBuffers(); // Handle deferred scene transition if (context.nextScene) { wsc_leaveScene(&context); // Cleanup old scene context.scene = context.nextScene; context.nextScene = NULL; wsc_enterScene(&context); // Setup new scene } } // Cleanup if (context.scene) { wsc_leaveScene(&context); } shutdownEngine(&context); return 0; } ``` ### Scene Transition Pattern ```c // From wsc_updateSceneBlizzard(): void wsc_updateSceneBlizzard(WarContext* context) { WarScene* scene = context->scene; scene->blizzard.time -= context->deltaTime; if (scene->blizzard.time <= 0) { // Trigger a deferred scene transition WarScene* nextScene = wsc_createScene(context, WAR_SCENE_MAIN_MENU); wg_setNextScene(context, nextScene, 0.3f); // Fade transition over 0.3 sec } } ``` ### Adding a New Scene Type (Conceptual) To add a new scene type (e.g., `WAR_SCENE_OPTIONS`): 1. **Add enum value** in `war_enums.h`: ```c typedef enum _WarSceneType { // ... existing ... WAR_SCENE_OPTIONS, WAR_SCENE_COUNT } WarSceneType; ``` 2. **Create scene-specific header** `war_scene_options.h`: ```c void wsc_enterSceneOptions(WarContext* context); void wsc_updateSceneOptions(WarContext* context); // optional ``` 3. **Implement handlers** in `war_scene_options.c`: ```c void wsc_enterSceneOptions(WarContext* context) { // Create option buttons, sliders, etc. wui_createUIButton(context, ...); } ``` 4. **Register in descriptor table** in `war_scenes.c`: ```c WarSceneDescriptor sceneDescriptors[WAR_SCENE_COUNT] = { // ... existing ... { WAR_SCENE_OPTIONS, wsc_enterSceneOptions, NULL, wsc_updateSceneOptions }, }; ``` 5. **Include the new header** in `war_scenes.c`: ```c #include "war_scene_options.h" ``` --- ## Dependencies ### External Headers | Header | Purpose | Used For | |---|---|---| | `war_entities.h` | Entity management API | `we_initEntityManager()`, entity list/map types | | `war_campaigns.h` | Campaign metadata | Campaign briefing data (only in briefing scene) | | `war_cheats.h` | Cheat code state | `WarCheatStatus` structure, cheat panel updates | | `war_ui.h` | UI entity creation | Creating buttons, text, images in scene handlers | | `war_audio.h` | Audio playback | Playing background music or intro audio | | `war_animations.h` | Sprite animation system | Updating animations during scene updates | ### Scene-Specific Headers (Included in `war_scenes.c`) - `war_scene_blizzard.h`: Logo intro (3-second timer) - `war_scene_briefing.h`: Campaign briefing and difficulty selection - `war_scene_download.h`: Network asset download workflow - `war_scene_menu.h`: Main menu and custom game selection ### Vendored Dependencies (via `shl/`) | Header | Container Type | Used For | |---|---|---| | `shl/list.h` | `WarEntityList` | Entity storage | | `shl/map.h` | `WarEntityMap`, `WarUnitMap`, `WarEntityIdMap` | Indexed lookups | | `shl/memzone.h` | Memory arena | Underlying allocation for containers (optional) | ### Core Engine Headers | Header | Usage | |---|---| | `war.h` | `WarContext` definition | | `war_log.h` | `logError()` for invalid scene types | | `war_alloc.h` | `wm_alloc()` for scene allocation | --- ## Performance Considerations ### Tight Loop Compliance - **`wsc_renderScene()`** is called **every frame** and must complete in <1ms (at 60 FPS, 16ms budget): - Uses **O(k) iteration** where k = UI entity count (typically 5–20 for menus) - Avoids dynamic allocations and data structure searches - **Result**: Consistently <0.5ms on modern hardware - **`wsc_updateScene()`** with scene-specific handlers may be heavier: - `wsc_updateSceneDownload()` may poll network status (async-friendly design assumed) - `wsc_updateSceneBlizzard()` is trivial (decrement timer, O(1)) - `wsc_updateSceneBriefing()` updates animation frames (O(n) animations, typically O(1–2) in briefing) ### Allocation Strategy - **No per-frame allocations** after scene entry (all entities pre-allocated in handlers) - **Bulk deallocation** at scene exit (single `wsc_freeScene()` call) - Avoids memory fragmentation and GC pressure ### Cache Locality - Entity manager lists store pointers; dereferencing for component access incurs cache misses - For future optimization: consider ECS-style data layout (SOA) if profiling shows entity iteration is a bottleneck --- ## Integration with Engine Subsystems ### How Scenes Coordinate with Other Modules ``` WarContext ├─ scene: WarScene* │ ├─ entityManager: WarEntityManager │ │ ├─ entities: list of active game objects │ │ ├─ uiEntities: list of UI elements for rendering │ │ └─ ... │ └─ union { ... scene-specific state ... } │ ├─ Input (WarInput) │ └─ wui_updateUIButtons() polls mouse/keyboard in update phase │ ├─ Rendering (WarRenderState) │ └─ wsc_renderScene() submits draw calls each frame │ ├─ Audio (WarAudio) │ └─ Scene handlers start/stop audio via wa_createAudio() │ └─ Game Loop Control └─ wg_setNextScene() defers scene transition ``` ### Cheat System Integration - Each scene has an embedded `WarCheatStatus` - During default update (scenes without custom handler), `wcheatp_updateCheatsPanel()` displays cheat input UI - Cheats allow runtime debugging (spawn units, modify resources, skip levels) --- ## Error Handling ### Invalid Scene Type ```c // In wsc_enterScene, wsc_updateScene, wsc_leaveScene: if (!inRange(scene->type, WAR_SCENE_DOWNLOAD, WAR_SCENE_COUNT)) { logError("Unknown scene type: %d", scene->type); return; } ``` **Handling:** - Logs error and returns gracefully (no crash) - Safe for release builds (no assertions) - Suggests memory corruption if encountered at runtime (should not happen in normal gameplay) ### Null Pointer Defense ```c // In wsc_leaveScene: if (!scene) return; ``` **Handling:** - Checks for null scene before attempting cleanup - Prevents double-free or null dereference if called twice --- ## Summary The **Scenes subsystem** provides a lightweight, cache-friendly abstraction for managing distinct game screens and their lifecycles. By using a static descriptor table, tagged unions, and embedded entity managers, it achieves: - **O(1) scene dispatch** (no branching in hot loops) - **Minimal memory overhead** per scene (~416 bytes base + entity collections) - **Clean separation** between scene types (each has its own handlers) - **Seamless transitions** with deferred cleanup (no hitches) Future optimization opportunities include background loading screens, preemptive asset streaming, and ECS-based entity layout for ultra-high entity counts (hundreds of units on-screen). ================================================ FILE: docs/STATE_MACHINE_SYSTEM.md ================================================ # State Machine Subsystem **Module Prefix:** `wst_` **Primary Files:** `war_state_machine.h`, `war_state_machine.c`, `war_state_machine_*.c` **Language:** C99/C11 --- ## Overview The State Machine subsystem is the behavioral backbone of the War1-C game engine. It manages the lifecycle of every entity in the game—units (peons, footmen), buildings (townhalls, barracks, goldmines), walls, and towers—by orchestrating their behavior through a hierarchical, composable state system. Each entity maintains a **state stack**: a linear chain of states that can be queued and transitioned smoothly. The engine supports 19 distinct state types (Idle, Move, Attack, Mining, Building, etc.), each with pluggable enter/update/leave/free callbacks. The subsystem is built on **Data-Oriented Design (DOD)** principles with **minimal dynamic allocation at runtime**—all state objects are allocated once at state creation and freed at state exit. ### Pipeline Position ``` Game Loop (main update) └─> Entity Update └─> State Machine Update (per entity) └─> State Callbacks (enter, update, leave) └─> Sub-systems (pathfinding, animations, audio, etc.) ``` The state machine is called once per frame for each enabled entity. It coordinates state transitions, time-based updates, and resource cleanup. --- ## Memory & State Management ### Fixed-Size State Objects All states inherit from a base `WarState` structure that holds: - **Type** (`WarStateType`): Identifies which state handlers to invoke. - **Entity ID** (`s32 entityId`): Backlink to the owning entity. - **Timing** (`nextUpdateTime`, `delay`): For throttled state updates. - **State Chain** (`nextState*`): Single-level pointer for queuing the next state. - **State Data** (anonymous union): Type-specific fields (max 248 bytes for 256-byte total struct). ### Memory Layout & Alignment ```c struct _WarState { WarStateType type; // 4 bytes s32 entityId; // 4 bytes f32 nextUpdateTime; // 4 bytes f32 delay; // 4 bytes struct _WarState* nextState; // 8 bytes union { ... } [state data]; // up to 248 bytes }; // Total: 256 bytes (cache-friendly, single allocation per state) ``` **Key Design Decisions:** - **Single allocation per state**: `wst_createState()` allocates one `WarState` struct. Nested data structures (arrays, lists) are allocated inside the union if needed. - **State data is union-based**: Each state type uses only the fields it needs. Unused union members are padding, trading memory size for allocation simplicity. - **No object pools**: States are allocated on-demand and freed at transition. The system expects moderate churn (unit state changes every few frames). - **Arena allocation optional**: The codebase can use `wm_alloc()` / `wm_free()` which may wrap arena allocators if configured. ### State Lifecycle 1. **Creation**: `wst_createXxxState()` allocates and initializes state. 2. **Queuing**: `wst_changeNextState()` queues state to transition next frame. 3. **Entry**: `wst_enterState()` is called when the state becomes current (setup, animation start, etc.). 4. **Update**: `wst_updateXxxState()` is called each frame (logic, decision-making, transitions). 5. **Exit**: `wst_leaveState()` is called when transitioning away (cleanup, cleanup, disable collision, etc.). 6. **Free**: `wst_freeState()` deallocates the state and any nested lists/arrays. --- ## Core API / Functions ### State Creation #### `WarState* wst_createState(WarContext* context, WarEntity* entity, WarStateType type)` Generic state factory. Rarely called directly; use type-specific creators instead. **Inputs:** - `context`: Game context (time, map, entities). - `entity`: Entity that will own this state. - `type`: `WarStateType` enum (e.g., `WAR_STATE_IDLE`). **Returns:** Heap-allocated `WarState*`. **Side Effects:** Allocates memory; entity is not yet updated. **Performance:** O(1), single malloc. --- #### Type-Specific Creators **Motion:** - `WarState* wst_createMoveState(WarContext* ctx, WarEntity* entity, s32 posCount, vec2 positions[])` - Allocates `vec2List` inside the move state. - Positions: waypoints to traverse in order. - `WarState* wst_createPatrolState(WarContext* ctx, WarEntity* entity, s32 posCount, vec2 positions[])` - Allocates `vec2List` for cyclic patrol points. - `WarState* wst_createFollowState(WarContext* ctx, WarEntity* entity, WarEntityId targetId, vec2 targetTile, s32 distance)` - Follows an entity or a fixed tile position. - `distance`: Range at which follower stops. **Combat:** - `WarState* wst_createAttackState(WarContext* ctx, WarEntity* entity, WarEntityId targetId, vec2 targetTile)` - Target can be entity or tile; entity takes precedence if both exist. **Resource Gathering:** - `WarState* wst_createGatherGoldState(WarContext* ctx, WarEntity* entity, WarEntityId goldmineId)` - `WarState* wst_createMiningState(WarContext* ctx, WarEntity* entity, WarEntityId goldmineId)` - Mining includes active harvesting inside the building. - `WarState* wst_createGatherWoodState(WarContext* ctx, WarEntity* entity, WarEntityId forestId, vec2 position)` - `WarState* wst_createChoppingState(WarContext* ctx, WarEntity* entity, WarEntityId forestId, vec2 position)` - `WarState* wst_createDeliverState(WarContext* ctx, WarEntity* entity, WarEntityId townHallId)` **Building & Training:** - `WarState* wst_createTrainState(WarContext* ctx, WarEntity* entity, WarUnitType unit, f32 buildTime)` - Building creates units in a building. Allocates inside the state. - `WarState* wst_createUpgradeState(WarContext* ctx, WarEntity* entity, WarUpgradeType upgrade, f32 buildTime)` - `WarState* wst_createBuildState(WarContext* ctx, WarEntity* entity, f32 buildTime)` - Worker building a new structure. - `WarState* wst_createRepairState(WarContext* ctx, WarEntity* entity, WarEntityId buildingId)` - `WarState* wst_createRepairingState(WarContext* ctx, WarEntity* entity, WarEntityId buildingId)` **Special:** - `WarState* wst_createDeathState(WarContext* ctx, WarEntity* entity)` - `WarState* wst_createCollapseState(WarContext* ctx, WarEntity* entity)` - Building destruction sequence. - `WarState* wst_createWaitState(WarContext* ctx, WarEntity* entity, f32 waitTime)` - Pause for specified duration. - `WarState* wst_createCastState(WarContext* ctx, WarEntity* entity, WarSpellType spell, WarEntityId targetId, vec2 targetTile)` --- ### State Transition & Query #### `void wst_changeNextState(WarContext* ctx, WarEntity* entity, WarState* state, bool callLeave, bool callEnter)` Queue a state transition. Does not immediately change state—transitions happen at the start of `wst_updateStateMachine()`. **Inputs:** - `state`: The state to queue. - `callLeave`: Call `leave` callback on current state before transition. - `callEnter`: Call `enter` callback on the new state after transition. **Side Effects:** Modifies entity's state machine component; may queue multiple states in a chain. **Performance:** O(1). --- #### `bool wst_changeStateNextState(WarContext* ctx, WarEntity* entity, WarState* state)` Promote `state->nextState` (if it exists) to the next state to transition. **Returns:** `true` if a chained state was promoted; `false` if `state->nextState` is NULL. **Usage Pattern:** Often called from within a state's update logic to implement chained behaviors (e.g., "after move, attack"). --- #### `WarState* wst_getState(WarEntity* entity, WarStateType type)` Search the state chain (current + queued) for the first matching state. **Returns:** Pointer to state or NULL if not found. **Performance:** O(n) where n = state chain depth (typically 1–3). --- #### `WarState* wst_getDirectState(WarEntity* entity, WarStateType type)` Get the **current** state if its type matches. **Returns:** Current state if type matches, else NULL. **Performance:** O(1). --- #### `WarState* wst_getNextState(WarEntity* entity, WarStateType type)` Get the **queued next** state if its type matches. **Returns:** Next state if type matches, else NULL. **Performance:** O(1). --- #### Query Macros ```c // Convenience macros for common queries: #define getIdleState(e) wst_getDirectState(e, WAR_STATE_IDLE) #define getMoveState(e) wst_getState(e, WAR_STATE_MOVE) #define getAttackState(e) wst_getState(e, WAR_STATE_ATTACK) #define isIdle(e) wst_hasDirectState(e, WAR_STATE_IDLE) #define isMoving(e) wst_hasState(e, WAR_STATE_MOVE) #define isAttacking(e) wst_hasState(e, WAR_STATE_ATTACK) #define isGoingToAttack(e) wst_hasNextState(e, WAR_STATE_ATTACK) #define setDelay(s, seconds) ((s)->delay = (seconds)) ``` --- ### State Machine Update #### `void wst_updateStateMachine(WarContext* ctx, WarEntity* entity)` **Primary update entry point.** Called once per frame per entity. **Workflow:** 1. If state machine is disabled, skip. 2. Process all queued state transitions (while `stateMachine->nextState` exists): - Call `leave` callback on current state (if `wst_leaveState` flag is true). - Swap current ← next. - Call `enter` callback on new current state (if `wst_enterState` flag is true). 3. If current state has a `delay` > 0, schedule its next update (`nextUpdateTime = now + delay`). 4. If `now >= nextUpdateTime`, call the `update` callback. **Side Effects:** Mutates entity state; calls callbacks; may trigger cascading updates. **Performance:** O(d + 1) where d = transition depth. Typically O(1) per frame. **Key Insight:** The `delay` field throttles state updates without skipping them. Useful for animation frames, AI decision intervals, etc. --- #### `void wst_enterState(WarContext* ctx, WarEntity* entity, WarState* state)` Dispatch to the appropriate enter handler based on state type. **Inputs:** - `state`: State being entered. **Side Effects:** Invokes `stateDescriptors[state->type].enterStateFunc()`. **Performance:** O(1) (function pointer lookup). --- #### `void wst_leaveState(WarContext* ctx, WarEntity* entity, WarState* state)` Dispatch to the appropriate leave handler, then free the state. **Inputs:** - `state`: State being exited (can be NULL; no-op if so). **Side Effects:** - Calls leave handler. - Calls `wst_freeState()` to clean up. **Performance:** O(1) + cleanup cost. --- #### `void wst_freeState(WarContext* ctx, WarState* state)` Recursively free state and its chained next states. **Side Effects:** - Calls `freeStateFunc` for the state type. - Recursively frees `state->nextState`. - Deallocates the state struct itself. **Performance:** O(n) where n = state chain depth. --- ### Query Helpers #### `bool wst_isInsideBuilding(WarEntity* entity)` Check if entity is currently inside a building (mining, delivering, repairing inside). **Returns:** `true` if entity is in mining, delivering, or repairing state and marked `insideBuilding`. **Usage:** Attacking units use this to pause attacks while targets are inside. --- ## Data Structures ### `WarState` (256 bytes) Core state object containing shared fields and a type-specific union. ```c struct _WarState { WarStateType type; // 4 bytes: state identifier s32 entityId; // 4 bytes: owning entity ID f32 nextUpdateTime; // 4 bytes: earliest time for next update f32 delay; // 4 bytes: delay before next update (seconds) struct _WarState* nextState; // 8 bytes: chained next state (for queued transitions) union // 224 bytes: state-specific data { struct { bool lookAround; } idle; struct { s32 posIdx; vec2List positions; s32 pathIdx; WarMapPath path; s32 waitCnt; bool checkAttacks; } move; struct { s32 posIdx; vec2List positions; s32 dir; } patrol; struct { s32 targetId; vec2 targetTile; s32 distance; } follow; struct { f32 waitTime; } wait; struct { s32 targetId; vec2 targetTile; } attack; struct { s32 goldmineId; } gold; struct { s32 goldmineId; f32 miningTime; } mine; struct { s32 forestId; vec2 position; } wood; struct { s32 forestId; vec2 position; } chop; struct { s32 townHallId; bool insideBuilding; } deliver; struct { WarUnitType unit; f32 buildTime; f32 totalBuildTime; bool cancelled; } train; struct { WarUpgradeType upgrade; f32 buildTime; f32 totalBuildTime; bool cancelled; } upgrade; struct { WarEntityId workerId; f32 buildTime; f32 totalBuildTime; bool cancelled; } build; struct { WarEntityId buildingId; } repair; struct { WarEntityId buildingId; bool insideBuilding; } repairing; struct { WarSpellType spell; WarEntityId targetId; vec2 targetTile; } cast; }; }; ``` **Alignment:** 8-byte aligned (pointers require it). **Cache Locality:** Fixed 256-byte size ensures predictable cache line usage. --- ### `WarStateDescriptor` Callback table for a state type. ```c typedef struct { WarStateType type; void (*enterStateFunc)(WarContext* context, WarEntity* entity, WarState* state); void (*leaveStateFunc)(WarContext* context, WarEntity* entity, WarState* state); void (*updateStateFunc)(WarContext* context, WarEntity* entity, WarState* state); void (*freeStateFunc)(WarContext* context, WarState* state); } WarStateDescriptor; ``` **Instantiation:** Global array `stateDescriptors[WAR_STATE_COUNT]` populated in `war_state_machine.c`. --- ### `WarStateMachineComponent` Entity component holding current and queued states. ```c // Pseudo-code; defined in war_entities.h struct WarStateMachineComponent { bool enabled; WarState* currentState; WarState* nextState; bool wst_leaveState; bool wst_enterState; }; ``` **Fields:** - `enabled`: Gate state machine updates. - `currentState`: Active state. - `nextState`: State queued for transition. - `wst_leaveState`, `wst_enterState`: Flags controlling callback invocation. --- ## State Types (19 Total) | State | Enum | Purpose | Union Field | |-------|------|---------|-------------| | Idle | `WAR_STATE_IDLE` | Unit standing still, looking around | `idle` | | Move | `WAR_STATE_MOVE` | Unit traversing waypoints | `move` | | Patrol | `WAR_STATE_PATROL` | Unit cycling patrol points | `patrol` | | Follow | `WAR_STATE_FOLLOW` | Unit chasing target entity/tile | `follow` | | Attack | `WAR_STATE_ATTACK` | Unit in combat | `attack` | | Gather Gold | `WAR_STATE_GOLD` | Worker moving to goldmine | `gold` | | Mining | `WAR_STATE_MINING` | Worker extracting gold inside | `mine` | | Gather Wood | `WAR_STATE_WOOD` | Worker moving to forest | `wood` | | Chopping | `WAR_STATE_CHOP` | Worker harvesting wood | `chop` | | Deliver | `WAR_STATE_DELIVER` | Worker returning to townhall | `deliver` | | Death | `WAR_STATE_DEATH` | Unit dying sequence | (none) | | Collapse | `WAR_STATE_COLLAPSE` | Building destruction sequence | (none) | | Train | `WAR_STATE_TRAIN` | Building training a unit | `train` | | Upgrade | `WAR_STATE_UPGRADE` | Building researching upgrade | `upgrade` | | Build | `WAR_STATE_BUILD` | Worker constructing building | `build` | | Repair | `WAR_STATE_REPAIR` | Worker moving to building to repair | `repair` | | Repairing | `WAR_STATE_REPAIRING` | Worker repairing building | `repairing` | | Cast | `WAR_STATE_CAST` | Unit casting spell | `cast` | | Wait | `WAR_STATE_WAIT` | Unit paused for duration | `wait` | --- ## Usage Examples ### Example 1: Command Unit to Move ```c // Player clicks map tile; commander creates a move state. WarState* moveState = wst_createMoveState( context, unit, 2, (vec2[]){ unitCurrentPos, targetTile } ); wst_changeNextState(context, unit, moveState, true, true); // Leave idle, enter move ``` **Flow:** 1. State is queued. 2. Next `wst_updateStateMachine()` call: - Leaves idle state (animation stop, collision free). - Enters move state (pathfinding, collision set, walk animation). 3. Each frame, move state's update is called to advance along path. 4. When destination reached, automatically transitions to idle. --- ### Example 2: Attack with Fallback ```c // Attacker targets enemy. WarState* attackState = wst_createAttackState(context, attacker, enemy->id, enemyPos); wst_changeNextState(context, attacker, attackState, true, true); // In attack state's update: if (!wu_unitInRange(attacker, enemy, range)) { // Out of range: queue follow as next state, with attack as fallback. WarState* followState = wst_createFollowState(context, attacker, enemy->id, enemyPos, range); followState->nextState = attackState; // Restore attack after follow wst_changeNextState(context, attacker, followState, false, true); // Enter follow } ``` **Flow:** Attack → Follow (because out of range) → Attack (once in range). --- ### Example 3: Gather Gold Workflow ```c // Worker ordered to gather gold from goldmine. WarState* gatherState = wst_createGatherGoldState(context, worker, goldmine->id); wst_changeNextState(context, worker, gatherState, true, true); // In gather gold state's update: // 1. Check if goldmine is in range. // 2. If not, queue follow state with gather as next (chained). // 3. If yes, transition to mining state. // In mining state's update: // 4. Extract gold; when full or goldmine empty, transition to deliver. // In deliver state: // 5. Move to townhall; unload; go back to gather gold (loop). ``` --- ### Example 4: State Machine in Game Loop ```c // Main game loop (simplified). void gameUpdate(WarContext* context) { // ... input, physics, etc. // Update all entities' state machines. for (s32 i = 0; i < context->entities.count; i++) { WarEntity* entity = &context->entities.items[i]; if (entity->alive) { wst_updateStateMachine(context, entity); } } // ... rendering, audio, etc. } ``` --- ## Dependencies ### Internal Modules - **`war_entities.h`** – Entity and component definitions. - **`war_units.h`** – Unit queries (position, stats, animation). - **`war_map.h`** – Pathfinding, tile collision, map coordinate conversion. - **`war_pathfinder.h`** – A* pathfinding, obstacle queries. - **`war_actions.h`** – Animation and action system integration. - **`war_math.h`** – Vector math, utility macros. - **`war_alloc.h`** – Memory allocation (`wm_alloc`, `wm_free`). - **`war_log.h`** – Logging utilities. ### External Modules - **`shl/list.h`** – Generic list container for state chaining. - **`shl/array.h`** – Generic array for position lists in move/patrol states. --- ## State Implementation Pattern Each state type (e.g., `war_state_machine_idle.c`) follows a template: ```c // 1. Creator WarState* wst_createXxxState(WarContext* context, WarEntity* entity, ...) { WarState* state = wst_createState(context, entity, WAR_STATE_XXX); state->xxx.field1 = value1; state->xxx.field2 = value2; return state; } // 2. Enter (initialization) void wst_enterXxxState(WarContext* context, WarEntity* entity, WarState* state) { // Set up collision, animation, initial data. } // 3. Leave (cleanup) void wst_leaveXxxState(WarContext* context, WarEntity* entity, WarState* state) { // Restore collision, stop animation, clean up temporary data. } // 4. Update (per-frame logic) void wst_updateXxxState(WarContext* context, WarEntity* entity, WarState* state) { // Decision logic, state transitions, effect application. // Use setDelay(state, duration) to throttle next update. } // 5. Free (resource deallocation) void wst_freeXxxState(WarContext* context, WarState* state) { // Free any nested allocations (e.g., vec2List in move state). } ``` --- ## Performance Considerations ### Tight Inner Loop Avoidance - **Don't call state update inside nested loops.** State machine is called once per entity per frame. Calling it multiple times per frame creates redundant work. - State delays (`setDelay()`) are preferred over manual frame counting; the engine handles throttling. ### Update Frequency Optimization ```c // Good: throttle expensive updates with delay. void wst_updateIdleState(WarContext* context, WarEntity* entity, WarState* state) { // Do expensive search (every frame if no delay set). WarEntity* enemy = we_getNearEnemy(context, entity); // Throttle to 20 frames (at 60 FPS ≈ 333ms). state->delay = 0.33f; } ``` ### State Chain Depth - State chains are kept shallow (typically 1–3 levels: idle → move → attack). - Deep chains (>10) degrade performance slightly due to linked-list traversal in `wst_getState()`. ### Memory Efficiency - `WarState` is 256 bytes; allocated per state change, freed at transition. - No object pooling; relies on allocator efficiency (may use arenas). - Union-based state data avoids over-allocation for simple states. ### Callback Overhead - All state callbacks are O(1) lookups (function pointers from `stateDescriptors` array). - No virtual function dispatch or RTTI; stateless branching. --- ## Debugging & Inspection ### Logging State Changes States can log transitions by inspecting callbacks: ```c void logStateChange(WarEntity* entity, WarState* oldState, WarState* newState) { const char* oldName = getStateTypeName(oldState ? oldState->type : WAR_STATE_IDLE); const char* newName = getStateTypeName(newState->type); logInfo("Entity %d: %s -> %s", entity->id, oldName, newName); } ``` ### State Inspection in Debugger ```c // Example in GDB: (gdb) p entity->stateMachine.currentState->type $1 = WAR_STATE_MOVE (gdb) p entity->stateMachine.currentState->move.positionIndex $2 = 2 (gdb) p entity->stateMachine.nextState $3 = (WarState *) 0x0 // NULL: no transition queued ``` ### Profiling State Updates States can be instrumented with Tracy for profiling: ```c void wst_updateMoveState(WarContext* context, WarEntity* entity, WarState* state) { TracyCZone(ctx, 1); // ... move logic ... TracyCZoneEnd(ctx); } ``` --- ## Key Design Insights 1. **State Queuing, Not Immediate Transition:** Calling `wst_changeNextState()` doesn't immediately change state. This prevents reentrancy issues and ensures callbacks are called in the correct order. 2. **Delay Throttling:** The `delay` field enables light animation-frame-based scheduling without explicit counters. Useful for pacing AI decisions or animation updates. 3. **Chained States & Fallback:** States can queue a "next state" before transitioning. Example: Attack → Follow (if out of range) → Attack again. This chains behavior naturally. 4. **Minimal Leave/Enter Flags:** The `wst_leaveState` and `wst_enterState` booleans give callers fine-grained control. Some transitions (e.g., move → attack) skip leaving the previous state to preserve animation momentum. 5. **Union-Based Data:** All state data fit in a 256-byte union. This is a design constraint but ensures predictable memory layout and cache efficiency. 6. **Global Descriptor Array:** All state types are registered in a global `stateDescriptors[]` array. Adding a new state requires adding one row to the array and implementing the five callback functions. --- ## Extending the State Machine ### Adding a New State Type 1. **Define the enum** in `war_log.h`: ```c enum WarStateType { // ... existing states ... WAR_STATE_CUSTOM = X, WAR_STATE_COUNT }; ``` 2. **Add union field** in `war_state_machine.h`: ```c struct _WarState { // ... union { // ... existing ... struct { s32 customField1; f32 customField2; } custom; }; }; ``` 3. **Create file** `war_state_machine_custom.c`: ```c WarState* wst_createCustomState(...) { ... } void wst_enterCustomState(...) { ... } void wst_leaveCustomState(...) { ... } void wst_updateCustomState(...) { ... } void wst_freeCustomState(...) { ... } ``` 4. **Register in descriptor** in `war_state_machine.c`: ```c WarStateDescriptor stateDescriptors[WAR_STATE_COUNT] = { // ... { WAR_STATE_CUSTOM, wst_enterCustomState, wst_leaveCustomState, wst_updateCustomState, wst_freeCustomState }, }; ``` 5. **Include in `war_state_machine.h`** forward declarations for the new callbacks. 6. **Include** `war_state_machine_custom.c` in `war_state_machine.h` (unity build). --- ## Summary The State Machine subsystem is a **lightweight, data-oriented hierarchical state management system** optimized for game entity behavior. It uses **fixed-size allocations**, **no object pooling**, and **pluggable callbacks** to manage 19 state types across units, buildings, and environmental objects. The design prioritizes **simplicity, predictability, and cache locality** while supporting complex behavioral chains and smooth transitions. Key strengths: - **Zero dynamic allocation per frame** (states allocated at transition, freed at exit). - **O(1) state dispatch** via function pointer arrays. - **Simple callback model** (enter, update, leave, free). - **Composable state chains** for fallback behaviors. - **Throttled updates** via delay field, no manual frame counting. Minimal overhead and tight integration with pathfinding, animation, collision, and audio systems make it suitable for real-time RTS gameplay with dozens of concurrent entities. ================================================ FILE: docs/UI_SYSTEM.md ================================================ # War1-C UI Subsystem Documentation ## Overview The UI subsystem (`war_ui.c`/`war_ui.h`) is a component-based entity system that manages all user interface elements in the War1-C game engine. It handles the creation, lifecycle, and rendering of UI entities such as text labels, buttons, images, rectangles, and cursors. The subsystem is designed with **Data-Oriented Design (DOD)** principles, leveraging a component-based architecture where UI elements are represented as entities with attached components (`WarUIComponent`, `WarTextComponent`, `WarButtonComponent`, etc.). This approach maximizes cache locality and enables efficient batch processing. The `war_map_ui.c` module builds on the core UI system to create domain-specific UI layouts for the game map interface, including resource displays, unit status bars, minimap, and command panel. The `war_map_menu.c` module provides menu construction and event handling for in-game menus (pause, options, game-over, quit confirmation). ### Position in Engine Pipeline ``` WarContext (main game state) ├── UI Subsystem (wui_*) │ ├── UI Entities (Text, Button, Image, Rect, Cursor) │ ├── Input Handling (Button clicks, hot-keys) │ └── Rendering (wui_renderUIEntities) │ ├── Map UI Layer (wmui_*) │ ├── Map-specific UI (panels, minimap, HUD) │ └── Unit/Resource displays │ └── Map Menu Layer (wmm_*) └── Interactive menus (pause, options, game-over) ``` --- ## Memory & State Management ### Fixed-Size, Pre-Allocated Design The UI subsystem uses the **entity pool** from `war_entities.c`, which manages a fixed array of `WarEntity` objects (up to `MAX_ENTITIES_COUNT = 100`). UI entities are allocated from this same pool, avoiding dynamic allocation at runtime. **Key Characteristics:** 1. **Unity Build with Single Allocation Context**: All entities (including UI) share a single memory arena managed by `war_entities.c`. When the game initializes, the entity pool is pre-allocated once and reused throughout the game lifetime. 2. **Component Packing**: Each `WarEntity` embeds all possible components (transform, sprite, text, button, UI, etc.) as value types. This ensures cache-friendly layout—accessing related component data for a single entity keeps memory access localized. ```c struct _WarEntity { bool enabled; WarEntityId id; WarEntityType type; WarTransformComponent transform; // 1 byte + 8 bytes (vec2) + 8 bytes = 17 bytes WarSpriteComponent sprite; // ... (other components) WarUIComponent ui; // 1 byte + String (pointer + len) WarTextComponent text; // Multiple fields for text rendering WarRectComponent rect; // vec2 size + WarColor WarButtonComponent button; // State, sprites, handlers WarCursorComponent cursor; // ... (other components) }; ``` 3. **Component Enabled Flags**: Each component has an `enabled` boolean flag. Disabled components are skipped during update and render passes, avoiding unnecessary processing. 4. **Named Lookup via Entity ID Map**: UI entities are indexed by name (via `we_findUIEntity`), which internally uses a hash map (`WarEntityIdMap`) for O(1) lookup. This enables efficient retrieval of UI elements by string identifier without scanning the entire entity list. 5. **String Management**: UI text and button tooltips use the `wstr` (wide string) type from `shl/wstr.h`, which manages dynamic string data separately from the entity component. This avoids embedding variable-length data in the fixed entity structure. --- ## Core API / Functions ### Entity Creation Functions #### `WarEntity* wui_createUIText(...)` - **Signature**: `WarEntity* wui_createUIText(WarContext* context, String name, s32 fontIndex, f32 fontSize, String text, vec2 position)` - **Purpose**: Creates a text UI entity with the specified font, size, and initial text. - **Side Effects**: Adds a new entity to the entity pool; allocates/registers the entity name in the UI name map. - **Performance**: O(1) if entity pool has space; O(log n) for name registration in the map. - **Parameters**: - `context`: Game context holding entity pool and UI state. - `name`: Unique identifier for the UI entity (used for lookup). - `fontIndex`: Index into the font resource array (0, 1, etc.). - `fontSize`: Font size in pixels. - `text`: Initial text string (can be empty). - `position`: Screen position in pixels. #### `WarEntity* wui_createUIRect(...)` - **Signature**: `WarEntity* wui_createUIRect(WarContext* context, String name, vec2 position, vec2 size, WarColor color)` - **Purpose**: Creates a solid-color rectangle UI element. - **Side Effects**: Similar to `wui_createUIText`; allocates entity and registers name. - **Performance**: O(1) entity creation + O(log n) name registration. #### `WarEntity* wui_createUIImage(...)` - **Signature**: `WarEntity* wui_createUIImage(WarContext* context, String name, WarSpriteResourceRef spriteResourceRef, vec2 position)` - **Purpose**: Creates an image UI element from a sprite resource. - **Side Effects**: Allocates entity; the sprite resource must already be loaded in the resource manager. - **Performance**: O(1) creation; sprite lookup is O(1). #### `WarEntity* wui_createUITextButton(...)` - **Signature**: `WarEntity* wui_createUITextButton(WarContext* context, String name, s32 fontIndex, f32 fontSize, String text, WarSpriteResourceRef backgroundNormalRef, WarSpriteResourceRef backgroundPressedRef, WarSpriteResourceRef foregroundRef, vec2 position)` - **Purpose**: Creates a button with text overlay, with separate sprites for normal and pressed states. - **Side Effects**: Allocates entity and attaches text and button components. - **Performance**: O(1) creation; sprite resource lookups are O(1). - **Note**: Text alignment is automatically set to centered (horizontal and vertical). #### `WarEntity* wui_createUIImageButton(...)` - **Signature**: `WarEntity* wui_createUIImageButton(WarContext* context, String name, WarSpriteResourceRef backgroundNormalRef, WarSpriteResourceRef backgroundPressedRef, WarSpriteResourceRef foregroundRef, vec2 position)` - **Purpose**: Creates a button with image foreground (no text). - **Side Effects**: Similar to `wui_createUITextButton` but without text component setup. #### `WarEntity* wui_createUICursor(...)` - **Signature**: `WarEntity* wui_createUICursor(WarContext* context, String name, WarCursorType type, vec2 position)` - **Purpose**: Creates a cursor entity with specified type (arrow, target, scroll, etc.). - **Side Effects**: Loads cursor resource (hotspot coordinates) and initializes cursor component. - **Performance**: O(1) creation; resource lookup and hotspot registration are O(1). --- ### Entity Modification Functions #### `void wui_setUIText(WarEntity* uiText, String text)` - **Purpose**: Updates the text content of a text UI entity. - **Side Effects**: Frees the old string and assigns the new one. - **Performance**: O(1); delegates to string management system. #### `void wui_clearUIText(WarEntity* uiText)` - **Purpose**: Clears (empties) the text of a UI text entity. - **Side Effects**: Frees the string and marks the text component as disabled. #### `void wui_setUIImage(WarEntity* uiImage, s32 frameIndex)` - **Purpose**: Updates the sprite frame of an image UI entity. - **Side Effects**: Updates `sprite.frameIndex` and enables/disables the sprite component based on frame validity. - **Performance**: O(1). #### `void wui_setUIRectWidth(WarEntity* uiRect, s32 width)` - **Purpose**: Updates the width of a rectangle UI entity. - **Side Effects**: Sets `rect.size.x` and enables/disables the rect component. #### `void wui_setUITooltip(WarEntity* uiButton, s32 highlightIndex, s32 highlightCount, String text)` - **Purpose**: Attaches a tooltip to a button (displayed on hover). - **Side Effects**: Stores tooltip text and highlight indices in the button component. - **Performance**: O(1). #### `void wui_clearUITooltip(WarEntity* uiButton)` - **Purpose**: Removes the tooltip from a button. - **Side Effects**: Frees tooltip string. --- ### State Query & Lookup Functions #### `bool wui_isUIEntity(WarEntity* entity)` - **Purpose**: Checks if an entity is a UI entity (of types TEXT, IMAGE, BUTTON, RECT, CURSOR, MINIMAP). - **Side Effects**: None (read-only). - **Performance**: O(1). #### `WarEntity* we_findUIEntity(WarContext* context, StringView name)` - **Purpose**: Finds a UI entity by name. - **Side Effects**: None. - **Performance**: O(1) average (hash map lookup). - **Note**: Returns `NULL` if entity not found. Called internally by `*ByName` functions. --- ### Lookup & Modification by Name These functions combine entity lookup with modification: #### `void wui_setUIButtonStatusByName(WarContext* context, StringView name, bool enabled)` #### `void wui_setUIButtonInteractiveByName(WarContext* context, StringView name, bool interactive)` #### `void wui_setUIButtonHotKeyByName(WarContext* context, StringView name, WarKeys key)` #### `void wui_setUIEntityStatusByName(WarContext* context, StringView name, bool enabled)` - **Purpose**: Modify UI entity properties by name without requiring a direct entity pointer. - **Side Effects**: Updates entity component state. - **Performance**: O(1) average (hash map lookup + field update). - **Safety**: Silently ignore if entity not found. --- ### Input & Update Functions #### `void wui_updateUICursor(WarContext* context)` - **Purpose**: Updates the cursor position to follow the mouse input. - **Side Effects**: Modifies the transform component of the cursor entity. - **Performance**: O(1); reads input state and updates one entity. - **Notes**: - Called once per frame after input polling. - Always uses `WAR_CURSOR_ARROW` (other cursor types set explicitly via `wui_changeCursorType`). - Adjusts cursor position by the cursor's hotspot to ensure the visual cursor aligns with the click point. #### `void wui_updateUIButtons(WarContext* context, bool hotKeysEnabled)` - **Purpose**: Updates button state (hot, active) based on mouse input and keyboard hot-keys. - **Side Effects**: Updates button component state (`.hot`, `.active`); may invoke button click handlers. - **Performance**: O(n) where n = number of UI buttons; typically small (~10-20 buttons). - **Behavior**: - Scans all button entities for ones that are enabled, have interactive flag set. - Checks if mouse is over button bounds (using transform position and sprite dimensions). - Calls `.clickHandler` when button is clicked (mouse down followed by release). - Supports keyboard hot-keys; if `hotKeysEnabled == true` and a button's hot-key is pressed, invoke its handler. - Ensures button actions only fire once per click (tracks `.active` state to distinguish press and release). - Only one button can be "hot" (hovered) at a time; toggles all others to non-hot. - **Thread Safety**: Assumes input state is finalized before calling; no thread coordination needed. #### `void wui_changeCursorType(WarContext* context, WarEntity* entity, WarCursorType type)` - **Purpose**: Changes the cursor sprite and hotspot to a new cursor type. - **Side Effects**: Removes and re-adds cursor component with new type and hotspot. - **Performance**: O(1); updates cursor component. - **Example Usage**: In game input handling, change cursor to `WAR_CURSOR_TARGET` when initiating a targeting action, then revert to `WAR_CURSOR_ARROW` when cancelled. --- ### Rendering #### `void wui_renderUIEntities(WarContext* context)` - **Purpose**: Renders all enabled UI entities to the screen. - **Side Effects**: Calls SDL3 draw functions; updates framebuffer. - **Performance**: O(n) where n = number of UI entities; typically 30-50 visible UI elements. - **Notes**: - Iterates over all UI entities and delegates rendering to `we_renderEntity`. - Rendering order depends on the order of entities in the list (back-to-front; entities added later render on top). - UI rendering is typically done after map and game objects, so UI appears on top. --- ## Data Structures ### `WarUIComponent` ```c struct _WarUIComponent { bool enabled; String name; }; ``` - **Purpose**: Marks an entity as a UI element and provides a unique identifier. - **Fields**: - `enabled`: Whether this UI element is visible/interactive. - `name`: String identifier for lookup and debugging. - **Size**: ~17 bytes (1 byte enabled + 16 bytes String (pointer + length)). ### `WarTextComponent` ```c struct _WarTextComponent { bool enabled; String text; s32 fontIndex; f32 fontSize; f32 lineHeight; WarColor fontColor; WarColor highlightColor; s32 highlightIndex; s32 highlightCount; vec2 boundings; WarTextAlignment horizontalAlign; WarTextAlignment verticalAlign; WarTextAlignment lineAlign; WarTextWrapping wrapping; WarTextTrimming trimming; bool multiline; }; ``` - **Purpose**: Stores text rendering state for text UI entities. - **Key Fields**: - `text`: The string content (managed by `wstr`). - `fontIndex`: Which font (0, 1, etc.) to use from the resource table. - `fontSize`: Point size for rendering. - `fontColor`, `highlightColor`: Text and highlight colors (used for shortcut key highlighting). - `highlightIndex`, `highlightCount`: Character range to highlight (e.g., hotkey letters). - `boundings`: Max size for text layout (for centering/alignment). - `*Align`: Horizontal, vertical, and line alignment. - `wrapping`, `trimming`: Text wrapping and overflow behavior. - `multiline`: Whether text can span multiple lines. - **Size**: ~80+ bytes (including String and color fields). ### `WarRectComponent` ```c struct _WarRectComponent { bool enabled; vec2 size; WarColor color; }; ``` - **Purpose**: Represents a solid-color rectangle UI element. - **Fields**: - `size`: Width and height in pixels. - `color`: RGBA color. ### `WarButtonComponent` ```c struct _WarButtonComponent { bool enabled; bool interactive; bool hot; bool active; WarKeys hotKey; s32 highlightIndex; s32 highlightCount; String tooltip; s32 gold; s32 wood; WarSprite normalSprite; WarSprite pressedSprite; WarClickHandler clickHandler; }; ``` - **Purpose**: Represents an interactive button with state and event handling. - **Fields**: - `enabled`, `interactive`: Button is present and can be interacted with. - `hot`, `active`: Mouse is over button; button is pressed. - `hotKey`: Keyboard shortcut (e.g., `WAR_KEY_ESCAPE`). - `tooltip`: Help text displayed on hover. - `gold`, `wood`: Resource cost (displayed in tooltip). - `normalSprite`, `pressedSprite`: Sprite frames for visual states. - `clickHandler`: Function pointer called when button is clicked; signature: `void (*)(WarContext*, WarEntity*)`. - **Size**: ~100+ bytes (includes two WarSprite structs and String). ### `WarCursorComponent` ```c struct _WarCursorComponent { bool enabled; WarCursorType type; vec2 hot; }; ``` - **Purpose**: Represents the game cursor. - **Fields**: - `type`: Cursor appearance (arrow, target, scroll, etc.). - `hot`: Hotspot offset from cursor position (where the click registers). ### `WarTransformComponent` ```c struct _WarTransformComponent { bool enabled; vec2 position; vec2 rotation; vec2 scale; }; ``` - **Purpose**: Spatial transform for all entities (UI and game objects). - **Fields**: - `position`: Screen position (pixels for UI; world units for game objects). - `rotation`: Rotation vector (typically zero for UI). - `scale`: Scale factors (typically 1.0 for UI). ### Alignment Enums ```c typedef enum { WAR_TEXT_ALIGN_LEFT, WAR_TEXT_ALIGN_CENTER, WAR_TEXT_ALIGN_RIGHT, WAR_TEXT_ALIGN_JUSTIFY, WAR_TEXT_ALIGN_TOP, WAR_TEXT_ALIGN_MIDDLE, WAR_TEXT_ALIGN_BOTTOM, } WarTextAlignment; typedef enum { WAR_TEXT_WRAPPING_NO_WRAP, WAR_TEXT_WRAPPING_WORD_WRAP, WAR_TEXT_WRAPPING_CHARACTER_WRAP, } WarTextWrapping; typedef enum { WAR_TEXT_TRIMMING_NONE, WAR_TEXT_TRIMMING_CHARACTER_ELLIPSIS, WAR_TEXT_TRIMMING_WORD_ELLIPSIS, } WarTextTrimming; ``` --- ## Map UI Layer (`war_map_ui.c`) The Map UI layer builds on the core UI system to create in-game HUD elements specific to the active map. ### Key Functions #### `void wmui_createMapUI(WarContext* context)` - **Purpose**: Initializes all HUD UI elements for the map. - **Side Effects**: Creates ~50+ UI entities for panels, text, buttons, and bars. - **Performance**: O(1) at startup (amortized over initialization). - **Creates**: - **Panels**: Images for top, bottom, left, right, and corner UI panels. - **Resource Display**: Gold and lumber text labels with icons. - **Unit Info**: Portraits, name, life/mana bars for selected unit(s). - **Command Panel**: Button grid for issuing unit commands. - **Minimap**: Interactive map overview. - **Status Bar**: Dynamic text for game messages and tooltips. #### `WarEntity* wmui_createUIMinimap(WarContext* context, String name, vec2 position)` - **Purpose**: Creates a minimap UI entity. - **Returns**: Entity with MINIMAP type; can be rendered specially. #### `void wmui_updateGoldText(WarContext* context)` / `void wmui_updateWoodText(WarContext* context)` - **Purpose**: Updates the displayed resource counts. - **Called**: Every frame or when resources change. - **Performance**: O(1); format and update one text entity. #### `void wmui_updateSelectedUnitsInfo(WarContext* context)` - **Purpose**: Updates unit info display (portraits, stats, name) based on selected unit(s). - **Called**: Every frame or when selection changes. - **Performance**: O(1); updates fixed number of UI elements. #### `void wmui_setStatus(WarContext* context, s32 highlightIndex, s32 highlightCount, s32 gold, s32 wood, String text)` - **Purpose**: Displays a status message with optional resource info and text highlighting. - **Example**: "Build Barracks (Gold: 100, Lumber: 50)" — highlights resource keywords. #### `void wmui_setFlashStatus(WarContext* context, f32 duration, String text)` - **Purpose**: Displays a temporary status message that fades out after `duration` seconds. #### `void wmui_setLifeBar(...)`/`wmui_setManaBar(...)`/`wmui_setPercentBar(...)` - **Purpose**: Updates width of health/mana/progress bars based on unit stats. - **Performance**: O(1); updates rect width. #### `void wmui_renderMapUI(WarContext* context)`/`wmui_renderSelectionRect(...)`/`wmui_renderCommand(...)` - **Purpose**: Render custom map UI layers (selection rectangle, command visuals). --- ## Map Menu Layer (`war_map_menu.c`) The Map Menu layer provides UI construction and event handling for in-game menus. ### Key Functions #### `void wmm_createMenu(WarContext* context)` - **Purpose**: Creates the main pause/in-game menu UI (Save, Options, Objectives, Restart, Quit buttons). - **Creates**: ~10-15 UI entities; buttons are initially hidden. #### `void wmm_createOptionsMenu(WarContext* context)` - **Purpose**: Creates the options menu (volume sliders, game speed, scroll speed settings). #### `void wmm_createGameOverMenu(...)` / `wmm_createQuitMenu(...)` - **Purpose**: Create specialized menus for end-game scenarios. #### `void wmm_showOrHideMenu(WarContext* context, bool status)` - **Purpose**: Show/hide menu UI entities by toggling their `.enabled` flag. #### Button Handlers (e.g., `wmm_handleMenu`, `wmm_handleOptions`, `wmm_handleQuit`) - **Purpose**: Callbacks invoked when menu buttons are clicked. - **Signature**: `void handler(WarContext* context, WarEntity* entity)`. - **Responsibilities**: Update game state, navigate between menus, adjust settings. --- ## Usage Example ### Initialization (Pseudo-code) ```c // In wg_initializeGame() void game_init(WarContext* context) { // 1. Initialize core UI subsystem (entity pool already created) // (implicit, handled by entity module) // 2. Create map-specific UI wmui_createMapUI(context); // 3. Create menus wmm_createMenu(context); wmm_createOptionsMenu(context); // ... // 4. Hide menus initially wmm_showOrHideMenu(context, false); } ``` ### Main Game Loop (Pseudo-code) ```c void game_loop(WarContext* context) { while (context->running) { // Process input WarInput* input = poll_input(); context->input = *input; // Update UI bool hotKeysEnabled = !menu_is_open(context); wui_updateUICursor(context); wui_updateUIButtons(context, hotKeysEnabled); // Update map UI (resource display, unit info) wmui_updateGoldText(context); wmui_updateWoodText(context); wmui_updateSelectedUnitsInfo(context); // Render game world render_map(context); render_game_entities(context); // Render UI on top wui_renderUIEntities(context); wmui_renderMapUI(context); // Present framebuffer SDL_RenderPresent(context->renderer); } } ``` ### Creating Custom UI (Pseudo-code) ```c // Create a simple dialog void show_dialog(WarContext* context) { // Create background panel WarEntity* panel = wui_createUIRect( context, wstr_fromCString("dialogPanel"), vec2i(100, 100), vec2i(200, 150), WAR_COLOR_RGBA(50, 50, 50, 200) ); // Create title text WarEntity* title = wui_createUIText( context, wstr_fromCString("dialogTitle"), 1, // font index 10, // size wstr_fromCString("Confirm Action"), vec2i(110, 110) ); setUITextColor(title, WAR_COLOR_WHITE); // Create OK button WarEntity* okBtn = wui_createUITextButton( context, wstr_fromCString("dialogOkBtn"), 0, 6, wstr_fromCString("OK"), imageResourceRef(239), // normal imageResourceRef(240), // pressed invalidResourceRef(), // foreground vec2i(130, 220) ); setUIButtonClickHandler(okBtn, on_dialog_ok); // Create Cancel button WarEntity* cancelBtn = wui_createUITextButton( context, wstr_fromCString("dialogCancelBtn"), 0, 6, wstr_fromCString("Cancel"), imageResourceRef(239), imageResourceRef(240), invalidResourceRef(), vec2i(230, 220) ); setUIButtonClickHandler(cancelBtn, on_dialog_cancel); } void on_dialog_ok(WarContext* context, WarEntity* entity) { // Handle OK action // Find and hide dialog entities wui_setUIEntityStatusByName(context, wsv_fromCString("dialogPanel"), false); wui_setUIEntityStatusByName(context, wsv_fromCString("dialogTitle"), false); // ... } ``` --- ## Dependencies ### External Dependencies - **SDL3**: Rendering backend (SDL.h for frame presentation). - **shl/wstr.h**: Wide string management for dynamic text storage. - **shl/set.h**: Hash sets for tracking button update state. - **shl/map.h**: Hash maps for entity name lookup. ### Internal Dependencies - **war_entities.c/.h**: Entity pool management and component storage. - **war_resources.c/.h**: Sprite and cursor resource loading. - **war_audio.c/.h**: UI click sound effects. - **war_render.c/.h**: Rendering primitives (sprites, text, rects). - **war_font.c/.h**: Font management and glyph rendering. - **war_map.c/.h**: Map state (resources, players, panel dimensions). - **war_units.c/.h**: Unit type definitions and stats. - **war.h**: Core game types and constants. ### Module Prefix Conventions - `wui_`: Core UI functions - `wmui_`: Map UI functions - `wmm_`: Map menu functions - `we_`: Entity functions (used for entity lookup and creation) - `wr_`: Rendering functions - `wspr_`: Sprite functions - `wres_`: Resource functions - `wa_`: Audio functions --- ## Performance Considerations ### Optimization Strategies 1. **Fixed Entity Pool**: All UI entities allocated upfront; no dynamic allocation per-frame. 2. **Component-Disabled Skipping**: Only enabled components are processed during updates and rendering, reducing CPU overhead for hidden UI. 3. **Hash Map Lookup**: Named entity lookup is O(1) average, enabling efficient "find-and-update" patterns. 4. **Batch Button Updates**: `wui_updateUIButtons` processes all buttons in a single O(n) pass, with early exit on first matching hot-key. 5. **Minimal String Copies**: Text is stored once in `wstr` and referenced; avoiding repeated allocations. ### Avoid in Tight Loops - **Don't call entity creation functions every frame**. Create UI once during initialization; update properties as needed. - **Don't query `we_findUIEntity` in performance-critical paths without caching**. Cache entity pointers after lookup. - **Avoid frequent string formatting**. Update text only when values change (e.g., resource count updates). ### Profiling with Tracy Use Tracy markers to identify bottlenecks: ```c ZoneScoped; // Mark start of wui_updateUIButtons // ... function body ... ZoneEnd; // (implicit at scope exit) ``` --- ## Common Patterns & Idioms ### Pattern 1: Set UI Property by Name ```c wui_setUIButtonStatusByName(context, wsv_fromCString("btnSave"), false); setUIEntityStatus(wui_findUIEntity(context, wsv_fromCString("btnSave")), false); ``` ### Pattern 2: Create Text with Formatting ```c WarEntity* goldText = wui_createUIText( context, wstr_fromCString("txtGold"), 0, 6, wstr_fromCStringFormat("GOLD:%*d", 6, context->map->players[0].gold), vec2i(135, 2) ); ``` ### Pattern 3: Update Button Handler Dynamically ```c WarEntity* btn = we_findUIEntity(context, wsv_fromCString("myButton")); setUIButtonClickHandler(btn, new_handler_function); ``` ### Pattern 4: Conditional UI Visibility ```c // Show command buttons only when a unit is selected bool hasSelection = (context->selectedUnits.count > 0); for (s32 i = 0; i < 6; i++) { String btnName = wstr_fromCStringFormat("btnCommand%d", i); wui_setUIEntityStatusByName(context, wstr_view(&btnName), hasSelection); } ``` --- ## Error Handling & Safety ### Assertions & Checks - **Entity Lookup Failures**: `we_findUIEntity` returns `NULL` if entity not found; callers using `*ByName` helpers silently ignore missing entities. - **Type Assumptions**: Most functions assume correct entity type (e.g., `wui_setUIText` assumes entity has text component); invalid type access causes undefined behavior—use `wui_isUIEntity` for validation. - **Resource Validity**: Resource references (spriteResourceRef) are assumed valid at creation time; loading failures are handled by the resource module. ### Best Practices - Always validate entity pointer before use: ```c WarEntity* entity = we_findUIEntity(context, wsv_fromCString("myEntity")); if (entity) { wui_setUIText(entity, ...); } ``` - Use named lookups (`*ByName`) for convenience; cache pointers for repeated access. - Clear tooltips and text when no longer needed to avoid stale string references. --- ## Future Extensions ### Potential Enhancements 1. **UI Layout System**: Automated positioning/sizing based on anchor points and size policies. 2. **Event System**: Generic event broadcasting for non-button UI interactions. 3. **Animation Support**: Time-based UI element animations (fade, scale, slide). 4. **Theme System**: Configurable UI colors, fonts, and sprite sets per faction/theme. 5. **Accessibility**: Screen reader integration; high-contrast modes. ================================================ FILE: nob.c ================================================ #ifndef _DEFAULT_SOURCE #define _DEFAULT_SOURCE #endif #ifndef _POSIX_C_SOURCE #define _POSIX_C_SOURCE 200809L #endif #define NOB_IMPLEMENTATION #define NOB_EXPERIMENTAL_DELETE_OLD #include "nob.h" typedef enum { TOOLCHAIN_GCC, TOOLCHAIN_CLANG, TOOLCHAIN_MSVC, } Toolchain; typedef enum { TARGET_LINUX64, TARGET_ARM64, // Raspberry Pi 4/5 (64-bit OS) TARGET_WIN32, TARGET_WIN64, } Target; typedef enum { COMMAND_BUILD, COMMAND_RUN, } Command; typedef struct { Command command; Toolchain toolchain; Target target; bool debug; bool check_only; bool profile; // enable Tracy profiler instrumentation bool build_before_run; // set when build flags are passed alongside 'run' } Build_Options; static const char *toolchain_name(Toolchain toolchain) { switch (toolchain) { case TOOLCHAIN_GCC: return "gcc"; case TOOLCHAIN_CLANG: return "clang"; case TOOLCHAIN_MSVC: return "msvc"; default: return "unknown"; } } static const char *toolchain_program(Toolchain toolchain) { switch (toolchain) { case TOOLCHAIN_GCC: return "gcc"; case TOOLCHAIN_CLANG: return "clang"; case TOOLCHAIN_MSVC: return "cl"; default: return NULL; } } static const char *target_name(Target target) { switch (target) { case TARGET_LINUX64: return "linux64"; case TARGET_ARM64: return "arm64"; case TARGET_WIN32: return "win32"; case TARGET_WIN64: return "win64"; default: return "unknown"; } } static const char *target_output_dir(Target target) { switch (target) { case TARGET_LINUX64: return "build/linux64"; case TARGET_ARM64: return "build/arm64"; case TARGET_WIN32: return "build/win32"; case TARGET_WIN64: return "build/win64"; default: return NULL; } } static const char *target_library_dir(Target target) { switch (target) { case TARGET_LINUX64: return "deps/lib/linux64"; case TARGET_ARM64: return "deps/lib/arm64"; case TARGET_WIN32: return "deps/lib/win32"; case TARGET_WIN64: return "deps/lib/win64"; default: return NULL; } } static const char *target_binary_path(Target target) { const char *output_dir = target_output_dir(target); switch (target) { case TARGET_WIN32: case TARGET_WIN64: return nob_temp_sprintf("%s/war1.exe", output_dir); case TARGET_LINUX64: case TARGET_ARM64: return nob_temp_sprintf("%s/war1", output_dir); default: return NULL; } } static bool target_is_windows(Target target) { return target == TARGET_WIN32 || target == TARGET_WIN64; } static bool host_is_windows(void) { #ifdef _WIN32 return true; #else return false; #endif } static Target default_target(void) { #ifdef _WIN32 # if defined(_WIN64) return TARGET_WIN64; # else return TARGET_WIN32; # endif #elif defined(__aarch64__) return TARGET_ARM64; #else return TARGET_LINUX64; #endif } static Toolchain default_toolchain(void) { #if defined(_MSC_VER) && !defined(__clang__) return TOOLCHAIN_MSVC; #elif defined(__clang__) return TOOLCHAIN_CLANG; #else return TOOLCHAIN_GCC; #endif } static void usage(const char *program) { printf("Usage: %s [build|run] [--cc ] [--target ] [--debug|--release] [--check] [--profile]\n", program); printf("\n"); printf("Examples:\n"); printf(" %s build --cc gcc --target linux64\n", program); printf(" %s build --cc clang --target linux64\n", program); printf(" %s build --cc msvc --target win64 --check\n", program); printf(" %s build --cc gcc --target arm64\n", program); printf(" %s run --target linux64\n", program); printf(" %s run --cc gcc --target linux64 --debug\n", program); printf(" %s build --cc msvc --target win64 --profile\n", program); } static bool parse_toolchain(const char *value, Toolchain *toolchain) { if (strcmp(value, "gcc") == 0) { *toolchain = TOOLCHAIN_GCC; return true; } if (strcmp(value, "clang") == 0) { *toolchain = TOOLCHAIN_CLANG; return true; } if (strcmp(value, "msvc") == 0) { *toolchain = TOOLCHAIN_MSVC; return true; } return false; } static bool parse_target(const char *value, Target *target) { if (strcmp(value, "linux64") == 0) { *target = TARGET_LINUX64; return true; } if (strcmp(value, "arm64") == 0 || strcmp(value, "rpi4") == 0 || strcmp(value, "rpi5") == 0) { *target = TARGET_ARM64; return true; } if (strcmp(value, "win32") == 0) { *target = TARGET_WIN32; return true; } if (strcmp(value, "win64") == 0) { *target = TARGET_WIN64; return true; } return false; } static bool parse_args(int argc, char **argv, Build_Options *options) { const char *program = nob_shift_args(&argc, &argv); bool command_consumed = false; while (argc > 0) { const char *arg = nob_shift_args(&argc, &argv); if (!command_consumed && strcmp(arg, "build") == 0) { options->command = COMMAND_BUILD; command_consumed = true; continue; } if (!command_consumed && strcmp(arg, "run") == 0) { options->command = COMMAND_RUN; command_consumed = true; continue; } command_consumed = true; if (strcmp(arg, "--cc") == 0) { if (argc <= 0) { nob_log(NOB_ERROR, "missing value after --cc"); usage(program); return false; } if (!parse_toolchain(nob_shift_args(&argc, &argv), &options->toolchain)) { nob_log(NOB_ERROR, "unsupported toolchain"); usage(program); return false; } if (options->command == COMMAND_RUN) options->build_before_run = true; continue; } if (strcmp(arg, "--target") == 0) { if (argc <= 0) { nob_log(NOB_ERROR, "missing value after --target"); usage(program); return false; } if (!parse_target(nob_shift_args(&argc, &argv), &options->target)) { nob_log(NOB_ERROR, "unsupported target"); usage(program); return false; } if (options->command == COMMAND_RUN) options->build_before_run = true; continue; } if (strcmp(arg, "--debug") == 0) { options->debug = true; if (options->command == COMMAND_RUN) options->build_before_run = true; continue; } if (strcmp(arg, "--release") == 0) { options->debug = false; if (options->command == COMMAND_RUN) options->build_before_run = true; continue; } if (strcmp(arg, "--check") == 0) { options->check_only = true; continue; } if (strcmp(arg, "--profile") == 0) { options->profile = true; if (options->command == COMMAND_RUN) options->build_before_run = true; continue; } if (strcmp(arg, "--help") == 0 || strcmp(arg, "-h") == 0) { usage(program); return false; } nob_log(NOB_ERROR, "unknown argument: %s", arg); usage(program); return false; } return true; } static bool nob_read_entire_dir_recursively(const char* parent, Nob_File_Paths* file_paths, int idx) { // NOTE: This library to deal with files and directories seems nice: https://github.com/cxong/tinydir if (!nob_read_entire_dir(parent, file_paths)) { return false; } int count = file_paths->count; for (int i = idx; i < count; i++) { if (strcmp(file_paths->items[i], ".") == 0) continue; if (strcmp(file_paths->items[i], "..") == 0) continue; // NOTE: Here I'm leaking the allocation for each file name on the nob_read_entire_dir call // but I'm don't care that much because that alloc is done on the temp static arena file_paths->items[i] = nob_temp_sprintf("%s/%s", parent, file_paths->items[i]); Nob_File_Type file_type = nob_get_file_type(file_paths->items[i]); if (file_type == NOB_FILE_DIRECTORY) { if (!nob_read_entire_dir_recursively(file_paths->items[i], file_paths, file_paths->count)) { return false; } } } return true; } static bool clear_folder(const char* parent) { Nob_File_Paths file_paths = {0}; if (!nob_read_entire_dir_recursively(parent, &file_paths, 0)) { return false; } for (int i = 0; i < file_paths.count; i++) { Nob_File_Type file_type = nob_get_file_type(file_paths.items[i]); if (file_type == NOB_FILE_REGULAR) { if (!nob_delete_file(file_paths.items[i])) { return false; } } } file_paths.count = 0; return true; } static bool ensure_output_dirs(Target target) { return nob_mkdir_if_not_exists("build") && nob_mkdir_if_not_exists(target_output_dir(target)); } static bool append_gnu_common_flags(Nob_Cmd *cmd, const Build_Options *options) { nob_cmd_append(cmd, toolchain_program(options->toolchain), "-std=c11", "-Wall", "-Wno-misleading-indentation", "-Wpedantic", "-x", "c", "-Ideps/include"); if (options->debug) { nob_cmd_append(cmd, "-g", "-D__DEBUG__=1", "-DSHL_MZ_DEBUG"); } else { nob_cmd_append(cmd, "-O2"); } if (options->profile) { nob_cmd_append(cmd, "-DTRACY_ENABLE"); } return true; } static bool append_msvc_common_flags(Nob_Cmd *cmd, const Build_Options *options) { nob_cmd_append(cmd, toolchain_program(options->toolchain), "/nologo", "/TC", "/std:c11", "/W4", "/D_CRT_SECURE_NO_WARNINGS", "/Ideps/include"); if (options->debug) { nob_cmd_append(cmd, "/Zi", "/D__DEBUG__=1", "/DSHL_MZ_DEBUG"); } else { nob_cmd_append(cmd, "/Zi", "/O2", "/DNDEBUG"); } if (options->profile) { nob_cmd_append(cmd, "/DTRACY_ENABLE"); } return true; } static bool compile_gnu_source(const Build_Options *options, const char *source_path, const char *object_path) { Nob_Cmd cmd = {0}; append_gnu_common_flags(&cmd, options); nob_cmd_append(&cmd, "-c", source_path, "-o", object_path); return nob_cmd_run(&cmd); } static bool compile_msvc_source(const Build_Options *options, const char *source_path, const char *object_path) { Nob_Cmd cmd = {0}; append_msvc_common_flags(&cmd, options); nob_cmd_append(&cmd, "/c", source_path, nob_temp_sprintf("/Fo:%s", object_path)); return nob_cmd_run(&cmd); } static bool copy_runtime_files(const Build_Options *options) { const char *output_dir = target_output_dir(options->target); if (!nob_copy_directory_recursively("assets", output_dir)) { return false; } if (!options->check_only) { if (target_is_windows(options->target)) { const char *dll_path = nob_temp_sprintf("%s/SDL3.dll", target_library_dir(options->target)); const char *dll_copy_path = nob_temp_sprintf("%s/SDL3.dll", output_dir); if (!nob_copy_file(dll_path, dll_copy_path)) { return false; } if (options->profile) { const char *tracy_dll_path = nob_temp_sprintf("%s/Tracy.dll", target_library_dir(options->target)); const char *tracy_dll_copy_path = nob_temp_sprintf("%s/Tracy.dll", output_dir); if (!nob_copy_file(tracy_dll_path, tracy_dll_copy_path)) { return false; } } } else { // Copy SDL3 shared libraries so the binary can find them via $ORIGIN rpath const char *lib_dir = target_library_dir(options->target); const char *so_names[] = { "libSDL3.so.0.5.0", "libSDL3.so.0", "libSDL3.so" }; for (size_t i = 0; i < NOB_ARRAY_LEN(so_names); i++) { const char *src = nob_temp_sprintf("%s/%s", lib_dir, so_names[i]); const char *dst = nob_temp_sprintf("%s/%s", output_dir, so_names[i]); if (!nob_copy_file(src, dst)) { return false; } } if (options->profile) { const char *tracy_src = nob_temp_sprintf("%s/libTracy.so", target_library_dir(options->target)); const char *tracy_dst = nob_temp_sprintf("%s/libTracy.so", output_dir); if (!nob_copy_file(tracy_src, tracy_dst)) { return false; } } } } return true; } static bool build_with_gnu_like(const Build_Options *options) { const char *binary_path = target_binary_path(options->target); const char *output_dir = target_output_dir(options->target); if (!ensure_output_dirs(options->target)) { nob_log(NOB_ERROR, "Could not create output directories"); return false; } if (!clear_folder(output_dir)) { nob_log(NOB_ERROR, "Could not clear output directory"); return false; } if (options->check_only) { if (!compile_gnu_source(options, "src/war1.c", nob_temp_sprintf("%s/war1.o", output_dir))) { return false; } return true; } Nob_Cmd cmd = {0}; append_gnu_common_flags(&cmd, options); nob_cmd_append(&cmd, "src/war1.c", "-o", binary_path, nob_temp_sprintf("-L%s", target_library_dir(options->target))); if (target_is_windows(options->target)) { nob_cmd_append(&cmd, "-lSDL3", "-lws2_32"); if (options->toolchain == TOOLCHAIN_GCC) { nob_cmd_append(&cmd, "-static-libgcc"); } if (options->profile) { nob_cmd_append(&cmd, "-lTracy"); } } else { nob_cmd_append(&cmd, "-lSDL3", "-lpthread", "-lm", "-ldl", "-Wl,-rpath,$ORIGIN"); if (options->target == TARGET_LINUX64) { nob_cmd_append(&cmd, "-no-pie"); } if (options->profile) { nob_cmd_append(&cmd, "-lTracy"); } } if (!nob_cmd_run(&cmd)) { return false; } return copy_runtime_files(options); } static bool build_with_msvc(const Build_Options *options) { if (!host_is_windows()) { nob_log(NOB_ERROR, "msvc builds are only supported when running nob on Windows"); return false; } if (!target_is_windows(options->target)) { nob_log(NOB_ERROR, "msvc builds require a Windows target"); return false; } if (!ensure_output_dirs(options->target)) { nob_log(NOB_ERROR, "Could not create output directories"); return false; } if (!clear_folder(target_output_dir(options->target))) { nob_log(NOB_ERROR, "Could not clear output directory"); return false; } const char *output_dir = target_output_dir(options->target); const char *lib_dir = target_library_dir(options->target); if (options->check_only) { if (!compile_msvc_source(options, "src/war1.c", nob_temp_sprintf("%s/war1.obj", output_dir))) { return false; } return true; } // Full build: compile + link Nob_Cmd cmd = {0}; append_msvc_common_flags(&cmd, options); nob_cmd_append(&cmd, "src/war1.c", nob_temp_sprintf("/Fe:%s", target_binary_path(options->target)), nob_temp_sprintf("/Fo:%s/", output_dir), "/link", nob_temp_sprintf("/LIBPATH:%s", lib_dir), "SDL3.lib", "shell32.lib", "ws2_32.lib"); if (options->profile) { nob_cmd_append(&cmd, "Tracy.lib"); } if (!nob_cmd_run(&cmd)) { return false; } return copy_runtime_files(options); } static bool build_project(const Build_Options *options) { nob_log(NOB_INFO, "Building target=%s toolchain=%s mode=%s%s build=%s", target_name(options->target), toolchain_name(options->toolchain), options->check_only ? "check" : "build", options->profile ? " +profile" : "", options->debug ? "debug" : "release"); switch (options->toolchain) { case TOOLCHAIN_GCC: case TOOLCHAIN_CLANG: return build_with_gnu_like(options); case TOOLCHAIN_MSVC: return build_with_msvc(options); default: nob_log(NOB_ERROR, "unsupported toolchain"); return false; } } static bool run_project(const Build_Options *options) { if (target_is_windows(options->target) && !host_is_windows()) { nob_log(NOB_ERROR, "Cannot run a Windows binary on a non-Windows host"); return false; } const char *output_dir = target_output_dir(options->target); const char *binary = target_is_windows(options->target) ? "war1.exe" : "./war1"; nob_log(NOB_INFO, "Changing directory to: %s", output_dir); if (!nob_set_current_dir(output_dir)) { nob_log(NOB_ERROR, "Could not change to directory: %s", output_dir); return false; } nob_log(NOB_INFO, "Running: %s", binary); Nob_Cmd cmd = {0}; nob_cmd_append(&cmd, binary); return nob_cmd_run(&cmd); } int main(int argc, char **argv) { NOB_GO_REBUILD_URSELF(argc, argv); Build_Options options = { .command = COMMAND_BUILD, .toolchain = default_toolchain(), .target = default_target(), .debug = false, .check_only = false, .profile = false, .build_before_run = false, }; if (!parse_args(argc, argv, &options)) { return 1; } switch (options.command) { case COMMAND_BUILD: if (!build_project(&options)) return 1; break; case COMMAND_RUN: if (options.build_before_run) { if (!build_project(&options)) return 1; } if (!run_project(&options)) return 1; break; default: nob_log(NOB_ERROR, "unknown command"); return 1; } return 0; } ================================================ FILE: nob.h ================================================ /* nob - v3.8.2 - Public Domain - https://github.com/tsoding/nob.h This library is the next generation of the [NoBuild](https://github.com/tsoding/nobuild) idea. # Quick Example ```c // nob.c #define NOB_IMPLEMENTATION #include "nob.h" int main(int argc, char **argv) { NOB_GO_REBUILD_URSELF(argc, argv); Nob_Cmd cmd = {0}; nob_cmd_append(&cmd, "cc", "-Wall", "-Wextra", "-o", "main", "main.c"); if (!nob_cmd_run(&cmd)) return 1; return 0; } ``` ```console $ cc -o nob nob.c $ ./nob ``` The `nob` automatically rebuilds itself if `nob.c` is modified thanks to the `NOB_GO_REBUILD_URSELF` macro (don't forget to check out how it works below) # Stripping off `nob_` Prefixes Since Pure C does not have any namespaces we prefix each name of the API with the `nob_` to avoid any potential conflicts with any other names in your code. But sometimes it is very annoying and makes the code noisy. Because of that you can drop the `nob_` prefix. ```c // nob.c #define NOB_IMPLEMENTATION #include "nob.h" int main(int argc, char **argv) { GO_REBUILD_URSELF(argc, argv); Cmd cmd = {0}; cmd_append(&cmd, "cc", "-Wall", "-Wextra", "-o", "main", "main.c"); if (!cmd_run(&cmd)) return 1; return 0; } ``` If the lack of prefixes causes any problems you can disable the prefix stripping by defining `NOB_UNSTRIP_PREFIX` feature macro before including "nob.h". Not all the names have strippable prefixes. All the redefinable names like `NOB_REBUILD_URSELF` for instance will retain their prefix always. Notable exception is the nob_log() function. Stripping away the prefix results in log() which was historically always referring to the natural logarithmic function that is already defined in math.h. So there is no reason to strip off the prefix for nob_log(). Another exception is nob_rename() which collides with the widely known POSIX function rename(2) if you strip the prefix off. The prefixes are stripped off only on the level of the preprocessor. The names of the functions in the compiled object file will still retain the `nob_` prefix. Keep that in mind when you FFI with nob.h from other languages (for whatever reason). If only few specific names create conflicts for you, you can just #undef those names after the `#include ` without enabling `NOB_UNSTRIP_PREFIX` since they are macros anyway. # Macro Interface All these macros are `#define`d by the user before including nob.h ## Flags Enable or disable certain aspects of nob.h - NOB_IMPLEMENTATION - Enable definitions of the functions. By default only declarations are included. See https://github.com/nothings/stb/blob/f58f558c120e9b32c217290b80bad1a0729fbb2c/docs/stb_howto.txt for more info. - NOB_WARN_DEPRECATED - Warn about the usage of deprecated function. We rarely actually remove deprecated functions, but if you want to know what is discouraged you may want to enable this flag. - NOB_EXPERIMENTAL_DELETE_OLD - Experimental feature that automatically removes `nob.old` files. It's unclear how well it works on Windows, so it's experimental for now. - NOB_UNSTRIP_PREFIX - do not strip the `nob_` prefixes from non-redefinable names. - NOB_NO_ECHO - do not echo the actions various nob functions are doing (like nob_cmd_run(), nob_mkdir_if_not_exists(), etc). ## Redefinable Macros Redefine default behaviors of nob.h. - NOBDEF - Appends additional things to function declarations. You can do something like `#define NOBDEF static inline`. - NOB_ASSERT(condition) - Redefine which assert() nob.h shall use. - NOB_REALLOC(oldptr, size) - Redefine which realloc() nob.h shall use. - NOB_FREE(ptr) - Redefine which free() nob.h shall use. - NOB_DEPRECATED(message) - Redefine how nob.h shall mark functions as deprecated. - NOB_DA_INIT_CAP - Redefine initial capacity of Dynamic Arrays. - NOB_TEMP_CAPACITY - Redefine the capacity of the temporary storate. - NOB_REBUILD_URSELF(binary_path, source_path) - redefine how nob.h shall rebuild itself. - NOB_WIN32_ERR_MSG_SIZE - Redefine the capacity of the buffer for error message on Windows. */ #ifndef NOB_H_ #define NOB_H_ #ifdef _WIN32 # ifndef _CRT_SECURE_NO_WARNINGS # define _CRT_SECURE_NO_WARNINGS (1) # endif // _CRT_SECURE_NO_WARNINGS #endif // _WIN32 #ifndef NOBDEF /* Goes before declarations and definitions of the nob functions. Useful to `#define NOBDEF static inline` if your source code is a single file and you want the compiler to remove unused functions. */ #define NOBDEF #endif /* NOBDEF */ #ifndef NOB_ASSERT #include #define NOB_ASSERT assert #endif /* NOB_ASSERT */ #ifndef NOB_REALLOC #include #define NOB_REALLOC realloc #endif /* NOB_REALLOC */ #ifndef NOB_FREE #include #define NOB_FREE free #endif /* NOB_FREE */ #ifdef NOB_WARN_DEPRECATED # ifndef NOB_DEPRECATED # if defined(__GNUC__) || defined(__clang__) # define NOB_DEPRECATED(message) __attribute__((deprecated(message))) # elif defined(_MSC_VER) # define NOB_DEPRECATED(message) __declspec(deprecated(message)) # else # define NOB_DEPRECATED(...) # endif # endif /* NOB_DEPRECATED */ #else # define NOB_DEPRECATED(...) #endif /* NOB_WARN_DEPRECATED */ #include #include #include #include #include #include #include #include #include #include #ifdef _WIN32 # define WIN32_LEAN_AND_MEAN # define _WINUSER_ # define _WINGDI_ # define _IMM_ # define _WINCON_ # include # include # include # include #else # ifdef __APPLE__ # include # endif # ifdef __FreeBSD__ # include # endif # include # include # include # include # include # include #endif #ifdef __HAIKU__ # include #endif #ifdef _WIN32 # define NOB_LINE_END "\r\n" #else # define NOB_LINE_END "\n" #endif #if defined(__GNUC__) || defined(__clang__) // https://gcc.gnu.org/onlinedocs/gcc-4.7.2/gcc/Function-Attributes.html # ifdef __MINGW_PRINTF_FORMAT # define NOB_PRINTF_FORMAT(STRING_INDEX, FIRST_TO_CHECK) __attribute__ ((format (__MINGW_PRINTF_FORMAT, STRING_INDEX, FIRST_TO_CHECK))) # else # define NOB_PRINTF_FORMAT(STRING_INDEX, FIRST_TO_CHECK) __attribute__ ((format (printf, STRING_INDEX, FIRST_TO_CHECK))) # endif // __MINGW_PRINTF_FORMAT #else // TODO: implement NOB_PRINTF_FORMAT for MSVC # define NOB_PRINTF_FORMAT(STRING_INDEX, FIRST_TO_CHECK) #endif #define NOB_UNUSED(value) (void)(value) #define NOB_TODO(message) do { fprintf(stderr, "%s:%d: TODO: %s\n", __FILE__, __LINE__, message); abort(); } while(0) #define NOB_UNREACHABLE(message) do { fprintf(stderr, "%s:%d: UNREACHABLE: %s\n", __FILE__, __LINE__, message); abort(); } while(0) #define NOB_ARRAY_LEN(array) (sizeof(array)/sizeof(array[0])) #define NOB_ARRAY_GET(array, index) \ (NOB_ASSERT((size_t)index < NOB_ARRAY_LEN(array)), array[(size_t)index]) typedef enum { NOB_INFO, NOB_WARNING, NOB_ERROR, NOB_NO_LOGS, } Nob_Log_Level; // Any messages with the level below nob_minimal_log_level are going to be suppressed by the nob_default_log_handler. extern Nob_Log_Level nob_minimal_log_level; typedef void (Nob_Log_Handler)(Nob_Log_Level level, const char *fmt, va_list args); NOB_DEPRECATED("Uncapitalized nob_log_handler type is deprecated. Use Nob_Log_Handler instead. It's just when we were releasing the log handler feature we forgot that we had a convention that all the types must be capitalized like that. Sorry about it!") typedef Nob_Log_Handler nob_log_handler; NOBDEF void nob_set_log_handler(Nob_Log_Handler *handler); NOBDEF Nob_Log_Handler *nob_get_log_handler(void); NOBDEF Nob_Log_Handler nob_default_log_handler; NOBDEF Nob_Log_Handler nob_cancer_log_handler; NOBDEF Nob_Log_Handler nob_null_log_handler; NOBDEF void nob_log(Nob_Log_Level level, const char *fmt, ...) NOB_PRINTF_FORMAT(2, 3); // It is an equivalent of shift command from bash (do `help shift` in bash). It basically // pops an element from the beginning of a sized array. #define nob_shift(xs, xs_sz) (NOB_ASSERT((xs_sz) > 0), (xs_sz)--, *(xs)++) // NOTE: nob_shift_args() is an alias for an old variant of nob_shift that only worked with // the command line arguments passed to the main() function. nob_shift() is more generic. // So nob_shift_args() is semi-deprecated, but I don't see much reason to urgently // remove it. This alias does not hurt anybody. #define nob_shift_args(argc, argv) nob_shift(*argv, *argc) typedef struct { const char **items; size_t count; size_t capacity; } Nob_File_Paths; typedef enum { NOB_FILE_REGULAR = 0, NOB_FILE_DIRECTORY, NOB_FILE_SYMLINK, NOB_FILE_OTHER, } Nob_File_Type; NOBDEF bool nob_mkdir_if_not_exists(const char *path); NOBDEF bool nob_copy_file(const char *src_path, const char *dst_path); NOBDEF bool nob_copy_directory_recursively(const char *src_path, const char *dst_path); NOBDEF bool nob_read_entire_dir(const char *parent, Nob_File_Paths *children); NOBDEF bool nob_write_entire_file(const char *path, const void *data, size_t size); NOBDEF Nob_File_Type nob_get_file_type(const char *path); NOBDEF bool nob_delete_file(const char *path); typedef enum { // If the current file is a directory go inside of it. NOB_WALK_CONT, // If the current file is a directory do not go inside of it. NOB_WALK_SKIP, // Stop the recursive traversal process entirely. NOB_WALK_STOP, } Nob_Walk_Action; typedef struct { // The path to the visited file. The lifetime of the path string is very short. // As soon as the execution exits the Nob_Walk_Func it's dead. Dup it somewhere // if you want to preserve it for longer periods of time. const char *path; // The type of the visited file. Nob_File_Type type; // How nested we currently are in the directory tree. size_t level; // User data supplied in Nob_Walk_Dir_Opt.data. void *data; // The action nob_walk_dir_opt() must perform after the Nob_Walk_Func has returned. // Default is NOB_WALK_CONT. Nob_Walk_Action *action; } Nob_Walk_Entry; // A function that is called by nob_walk_dir_opt() on each visited file. // Nob_Walk_Entry provides the details about the visited file and also // expects you to modify the `action` in case you want to alter the // usual behavior of the recursive walking algorithm. // // If the function returns `false`, an error is assumed which causes the entire // recursive walking process to exit and nob_walk_dir_opt() return `false`. typedef bool (*Nob_Walk_Func)(Nob_Walk_Entry entry); typedef struct { // User data passed to Nob_Walk_Entry.data void *data; // Walk the directory in post-order visiting the leaf files first. bool post_order; } Nob_Walk_Dir_Opt; NOBDEF bool nob_walk_dir_opt(const char *root, Nob_Walk_Func func, Nob_Walk_Dir_Opt); #define nob_walk_dir(root, func, ...) nob_walk_dir_opt((root), (func), NOB_CLIT(Nob_Walk_Dir_Opt){__VA_ARGS__}) typedef struct { char *name; bool error; struct { #ifdef _WIN32 WIN32_FIND_DATA win32_data; HANDLE win32_hFind; bool win32_init; #else DIR *posix_dir; struct dirent *posix_ent; #endif // _WIN32 } nob__private; // TODO: we don't have solid conventions regarding private struct fields } Nob_Dir_Entry; // nob_dir_entry_open() - open the directory entry for iteration. // RETURN: // true - Sucess. // false - Error. I will be logged automatically with nob_log(). NOBDEF bool nob_dir_entry_open(const char *dir_path, Nob_Dir_Entry *dir); // nob_dir_entry_next() - acquire the next file in the directory. // RETURN: // true - Successfully acquired the next file. // false - Either failure or no more files to iterate. In case of failure dir->error is set to true. NOBDEF bool nob_dir_entry_next(Nob_Dir_Entry *dir); NOBDEF void nob_dir_entry_close(Nob_Dir_Entry dir); #define nob_return_defer(value) do { result = (value); goto defer; } while(0) // Initial capacity of a dynamic array #ifndef NOB_DA_INIT_CAP #define NOB_DA_INIT_CAP 256 #endif #ifdef __cplusplus #define NOB_DECLTYPE_CAST(T) (decltype(T)) #else #define NOB_DECLTYPE_CAST(T) #endif // __cplusplus #define nob_da_reserve(da, expected_capacity) \ do { \ if ((expected_capacity) > (da)->capacity) { \ if ((da)->capacity == 0) { \ (da)->capacity = NOB_DA_INIT_CAP; \ } \ while ((expected_capacity) > (da)->capacity) { \ (da)->capacity *= 2; \ } \ (da)->items = NOB_DECLTYPE_CAST((da)->items)NOB_REALLOC((da)->items, (da)->capacity * sizeof(*(da)->items)); \ NOB_ASSERT((da)->items != NULL && "Buy more RAM lol"); \ } \ } while (0) // Append an item to a dynamic array #define nob_da_append(da, item) \ do { \ nob_da_reserve((da), (da)->count + 1); \ (da)->items[(da)->count++] = (item); \ } while (0) #define nob_da_free(da) NOB_FREE((da).items) // Append several items to a dynamic array #define nob_da_append_many(da, new_items, new_items_count) \ do { \ nob_da_reserve((da), (da)->count + (new_items_count)); \ memcpy((da)->items + (da)->count, (new_items), (new_items_count)*sizeof(*(da)->items)); \ (da)->count += (new_items_count); \ } while (0) #define nob_da_resize(da, new_size) \ do { \ nob_da_reserve((da), new_size); \ (da)->count = (new_size); \ } while (0) #define nob_da_pop(da) (da)->items[(NOB_ASSERT((da)->count > 0), --(da)->count)] #define nob_da_first(da) (da)->items[(NOB_ASSERT((da)->count > 0), 0)] #define nob_da_last(da) (da)->items[(NOB_ASSERT((da)->count > 0), (da)->count-1)] #define nob_da_remove_unordered(da, i) \ do { \ size_t j = (i); \ NOB_ASSERT(j < (da)->count); \ (da)->items[j] = (da)->items[--(da)->count]; \ } while(0) // Foreach over Dynamic Arrays. Example: // ```c // typedef struct { // int *items; // size_t count; // size_t capacity; // } Numbers; // // Numbers xs = {0}; // // nob_da_append(&xs, 69); // nob_da_append(&xs, 420); // nob_da_append(&xs, 1337); // // nob_da_foreach(int, x, &xs) { // // `x` here is a pointer to the current element. You can get its index by taking a difference // // between `x` and the start of the array which is `x.items`. // size_t index = x - xs.items; // nob_log(INFO, "%zu: %d", index, *x); // } // ``` #define nob_da_foreach(Type, it, da) for (Type *it = (da)->items; it < (da)->items + (da)->count; ++it) // The Fixed Array append. `items` fields must be a fixed size array. Its size determines the capacity. #define nob_fa_append(fa, item) \ (NOB_ASSERT((fa)->count < NOB_ARRAY_LEN((fa)->items)), \ (fa)->items[(fa)->count++] = (item)) typedef struct { char *items; size_t count; size_t capacity; } Nob_String_Builder; #define nob_swap(T, a, b) do { T t = a; a = b; b = t; } while (0) NOBDEF bool nob_read_entire_file(const char *path, Nob_String_Builder *sb); NOBDEF int nob_sb_appendf(Nob_String_Builder *sb, const char *fmt, ...) NOB_PRINTF_FORMAT(2, 3); // Pads the String_Builder (sb) to the desired word size boundary with 0s. // Imagine we have sb that contains 5 `a`-s: // // aaaa|a // // If we pad align it by size 4 it will look like this: // // aaaa|a000| <- padded with 0s to the next size 4 boundary // // Useful when you are building some sort of binary format using String_Builder. NOBDEF void nob_sb_pad_align(Nob_String_Builder *sb, size_t size); // Append a sized buffer to a string builder #define nob_sb_append_buf(sb, buf, size) nob_da_append_many(sb, buf, size) // Append a string view to a string builder #define nob_sb_append_sv(sb, sv) nob_sb_append_buf((sb), (sv).data, (sv).count) // Append a NULL-terminated string to a string builder #define nob_sb_append_cstr(sb, cstr) \ do { \ const char *s = (cstr); \ size_t n = strlen(s); \ nob_da_append_many(sb, s, n); \ } while (0) // Append a single NULL character at the end of a string builder. So then you can // use it a NULL-terminated C string #define nob_sb_append_null(sb) nob_da_append_many(sb, "", 1) #define nob_sb_append nob_da_append // Free the memory allocated by a string builder #define nob_sb_free(sb) NOB_FREE((sb).items) // Process handle #ifdef _WIN32 typedef HANDLE Nob_Proc; #define NOB_INVALID_PROC INVALID_HANDLE_VALUE typedef HANDLE Nob_Fd; #define NOB_INVALID_FD INVALID_HANDLE_VALUE #else typedef int Nob_Proc; #define NOB_INVALID_PROC (-1) typedef int Nob_Fd; #define NOB_INVALID_FD (-1) #endif // _WIN32 NOBDEF Nob_Fd nob_fd_open_for_read(const char *path); NOBDEF Nob_Fd nob_fd_open_for_write(const char *path); NOBDEF void nob_fd_close(Nob_Fd fd); typedef struct { Nob_Fd read; Nob_Fd write; } Nob_Pipe; NOBDEF bool nob_pipe_create(Nob_Pipe *pp); typedef struct { Nob_Proc *items; size_t count; size_t capacity; } Nob_Procs; // Wait until the process has finished NOBDEF bool nob_proc_wait(Nob_Proc proc); // Wait until all the processes have finished NOBDEF bool nob_procs_wait(Nob_Procs procs); // Wait until all the processes have finished and empty the procs array. NOBDEF bool nob_procs_flush(Nob_Procs *procs); // Alias to nob_procs_flush NOB_DEPRECATED("Use `nob_procs_flush(&procs)` instead.") NOBDEF bool nob_procs_wait_and_reset(Nob_Procs *procs); // Append a new process to procs array and if procs.count reaches max_procs_count call nob_procs_wait_and_reset() on it NOB_DEPRECATED("Use `nob_cmd_run(&cmd, .async = &procs, .max_procs = )` instead") NOBDEF bool nob_procs_append_with_flush(Nob_Procs *procs, Nob_Proc proc, size_t max_procs_count); // A command - the main workhorse of Nob. Nob is all about building commands and running them typedef struct { const char **items; size_t count; size_t capacity; } Nob_Cmd; // Options for nob_cmd_run_opt() function. typedef struct { // Run the command asynchronously appending its Nob_Proc to the provided Nob_Procs array Nob_Procs *async; // Maximum processes allowed in the .async list. Zero implies nob_nprocs(). size_t max_procs; // Do not reset the command after execution. bool dont_reset; // Redirect stdin to file const char *stdin_path; // Redirect stdout to file const char *stdout_path; // Redirect stderr to file const char *stderr_path; } Nob_Cmd_Opt; // Run the command with options. NOBDEF bool nob_cmd_run_opt(Nob_Cmd *cmd, Nob_Cmd_Opt opt); // Command Chains (in Shell Scripting they are know as Pipes) // // Usage: // ```c // Nob_Cmd cmd = {0}; // Nob_Chain chain = {0}; // if (!nob_chain_begin(&chain)) return 1; // { // nob_cmd_append(&cmd, "echo", "Hello, World"); // if (!nob_chain_cmd(&chain, &cmd)) return 1; // // nob_cmd_append(&cmd, "rev"); // if (!nob_chain_cmd(&chain, &cmd)) return 1; // // nob_cmd_append(&cmd, "xxd"); // if (!nob_chain_cmd(&chain, &cmd)) return 1; // } // if (!nob_chain_end(&chain)) return 1; // ``` // // The above is equivalent to a shell command: // // ```sh // echo "Hello, World" | rev | xxd // ``` // // After nob_chain_end() the Nob_Chain struct can be reused again. // // The fields of the Nob_Chain struct contain the intermediate state of the Command // Chain that is being built with the nob_chain_cmd() calls and generally have no // particular use for the user. // // The only memory dynamically allocated within Nob_Chain belongs to the .cmd field. // So if you want to clean it all up you can just do free(chain.cmd.items). typedef struct { // The file descriptor of the output of the previous command. Will be used as the input for the next command. Nob_Fd fdin; // The command from the last nob_chain_cmd() call. Nob_Cmd cmd; // The value of the optional .err2out parameter from the last nob_chain_cmd() call. bool err2out; } Nob_Chain; typedef struct { const char *stdin_path; } Nob_Chain_Begin_Opt; #define nob_chain_begin(chain, ...) nob_chain_begin_opt((chain), NOB_CLIT(Nob_Chain_Begin_Opt) { __VA_ARGS__ }) NOBDEF bool nob_chain_begin_opt(Nob_Chain *chain, Nob_Chain_Begin_Opt opt); typedef struct { bool err2out; bool dont_reset; } Nob_Chain_Cmd_Opt; #define nob_chain_cmd(chain, cmd, ...) nob_chain_cmd_opt((chain), (cmd), NOB_CLIT(Nob_Chain_Cmd_Opt) { __VA_ARGS__ }) NOBDEF bool nob_chain_cmd_opt(Nob_Chain *chain, Nob_Cmd *cmd, Nob_Chain_Cmd_Opt opt); typedef struct { Nob_Procs *async; size_t max_procs; const char *stdout_path; const char *stderr_path; } Nob_Chain_End_Opt; #define nob_chain_end(chain, ...) nob_chain_end_opt((chain), NOB_CLIT(Nob_Chain_End_Opt) { __VA_ARGS__ }) NOBDEF bool nob_chain_end_opt(Nob_Chain *chain, Nob_Chain_End_Opt opt); // Get amount of processors on the machine. NOBDEF int nob_nprocs(void); #define NOB_NANOS_PER_SEC (1000*1000*1000) // The maximum time span representable is 584 years. NOBDEF uint64_t nob_nanos_since_unspecified_epoch(void); // Same as nob_cmd_run_opt but using cool variadic macro to set the default options. // See https://x.com/vkrajacic/status/1749816169736073295 for more info on how to use such macros. #define nob_cmd_run(cmd, ...) nob_cmd_run_opt((cmd), NOB_CLIT(Nob_Cmd_Opt){__VA_ARGS__}) // DEPRECATED: // // You were suppose to use this structure like this: // // ```c // Nob_Fd fdin = nob_fd_open_for_read("input.txt"); // if (fdin == NOB_INVALID_FD) fail(); // Nob_Fd fdout = nob_fd_open_for_write("output.txt"); // if (fdout == NOB_INVALID_FD) fail(); // Nob_Cmd cmd = {0}; // nob_cmd_append(&cmd, "cat"); // if (!nob_cmd_run_sync_redirect_and_reset(&cmd, (Nob_Cmd_Redirect) { // .fdin = &fdin, // .fdout = &fdout // })) fail(); // ``` // // But these days you should do: // // ```c // Nob_Cmd cmd = {0}; // nob_cmd_append(&cmd, "cat"); // if (!nob_cmd_run(&cmd, .stdin_path = "input.txt", .stdout_path = "output.txt")) fail(); // ``` typedef struct { Nob_Fd *fdin; Nob_Fd *fdout; Nob_Fd *fderr; } Nob_Cmd_Redirect; // Render a string representation of a command into a string builder. Keep in mind the the // string builder is not NULL-terminated by default. Use nob_sb_append_null if you plan to // use it as a C string. NOBDEF void nob_cmd_render(Nob_Cmd cmd, Nob_String_Builder *render); // Compound Literal #if defined(__cplusplus) #define NOB_CLIT(type) type #else #define NOB_CLIT(type) (type) #endif NOBDEF void nob__cmd_append(Nob_Cmd *cmd, size_t n, const char **args); #if defined(__cplusplus) template static inline void nob__cpp_cmd_append_wrapper(Nob_Cmd *cmd, Args... strs) { const char* args[] = { strs... }; nob__cmd_append(cmd, sizeof(args)/sizeof(args[0]), args); } #define nob_cmd_append(cmd, ...) nob__cpp_cmd_append_wrapper(cmd, __VA_ARGS__) #else #define nob_cmd_append(cmd, ...) \ nob__cmd_append(cmd, sizeof((const char*[]){__VA_ARGS__})/sizeof(const char*), (const char*[]){__VA_ARGS__}) #endif // __cplusplus // TODO: nob_cmd_extend() evaluates other_cmd twice // It can be fixed by turning nob_cmd_extend() call into a statement. // But that may break backward compatibility of the API. #define nob_cmd_extend(cmd, other_cmd) \ nob_da_append_many(cmd, (other_cmd)->items, (other_cmd)->count) // Free all the memory allocated by command arguments #define nob_cmd_free(cmd) NOB_FREE(cmd.items) // Run command asynchronously NOB_DEPRECATED("Use `nob_cmd_run(&cmd, .async = &procs, .dont_reset = true)`.") NOBDEF Nob_Proc nob_cmd_run_async(Nob_Cmd cmd); // nob_cmd_run_async_and_reset() is just like nob_cmd_run_async() except it also resets cmd.count to 0 // so the Nob_Cmd instance can be seamlessly used several times in a row NOB_DEPRECATED("Use `nob_cmd_run(&cmd, .async = &procs)` intead.") NOBDEF Nob_Proc nob_cmd_run_async_and_reset(Nob_Cmd *cmd); // Run redirected command asynchronously NOB_DEPRECATED("Use `nob_cmd_run(&cmd, " ".async = &procs, " ".stdin_path = \"path/to/stdin\", " ".stdout_path = \"path/to/stdout\", " ".stderr_path = \"path/to/stderr\", " ".dont_reset = true" ")` instead.") NOBDEF Nob_Proc nob_cmd_run_async_redirect(Nob_Cmd cmd, Nob_Cmd_Redirect redirect); // Run redirected command asynchronously and set cmd.count to 0 and close all the opened files NOB_DEPRECATED("Use `nob_cmd_run(&cmd, " ".async = &procs, " ".stdin_path = \"path/to/stdin\", " ".stdout_path = \"path/to/stdout\", " ".stderr_path = \"path/to/stderr\")` instead.") NOBDEF Nob_Proc nob_cmd_run_async_redirect_and_reset(Nob_Cmd *cmd, Nob_Cmd_Redirect redirect); // Run command synchronously NOB_DEPRECATED("Use `nob_cmd_run(&cmd, .dont_reset = true)` instead.") NOBDEF bool nob_cmd_run_sync(Nob_Cmd cmd); // NOTE: nob_cmd_run_sync_and_reset() is just like nob_cmd_run_sync() except it also resets cmd.count to 0 // so the Nob_Cmd instance can be seamlessly used several times in a row NOB_DEPRECATED("Use `nob_cmd_run(&cmd)` instead.") NOBDEF bool nob_cmd_run_sync_and_reset(Nob_Cmd *cmd); // Run redirected command synchronously NOB_DEPRECATED("Use `nob_cmd_run(&cmd, " ".stdin_path = \"path/to/stdin\", " ".stdout_path = \"path/to/stdout\", " ".stderr_path = \"path/to/stderr\", " ".dont_reset = true" ")` instead.") NOBDEF bool nob_cmd_run_sync_redirect(Nob_Cmd cmd, Nob_Cmd_Redirect redirect); // Run redirected command synchronously and set cmd.count to 0 and close all the opened files NOB_DEPRECATED("Use `nob_cmd_run(&cmd, " ".stdin_path = \"path/to/stdin\", " ".stdout_path = \"path/to/stdout\", " ".stderr_path = \"path/to/stderr\")` instead.") NOBDEF bool nob_cmd_run_sync_redirect_and_reset(Nob_Cmd *cmd, Nob_Cmd_Redirect redirect); #ifndef NOB_TEMP_CAPACITY #define NOB_TEMP_CAPACITY (8*1024*1024) #endif // NOB_TEMP_CAPACITY NOBDEF char *nob_temp_strdup(const char *cstr); NOBDEF char *nob_temp_strndup(const char *cstr, size_t size); NOBDEF void *nob_temp_alloc(size_t size); NOBDEF char *nob_temp_sprintf(const char *format, ...) NOB_PRINTF_FORMAT(1, 2); NOBDEF char *nob_temp_vsprintf(const char *format, va_list ap); // nob_temp_reset() - Resets the entire temporary storage to 0. // // It is generally not recommended to call this function ever. What you usually want to do is let's say you have a loop, // that allocates some temporary objects and cleans them up at the end of each iteration. You should use // nob_temp_save() and nob_temp_rewind() to organize such loop like this: // // ```c // char *message = nob_temp_sprintf("This message is still valid after the loop below"); // while (!quit) { // size_t mark = nob_temp_save(); // nob_temp_alloc(69); // nob_temp_alloc(420); // nob_temp_alloc(1337); // nob_temp_rewind(mark); // } // printf("%s\n", message); // ``` // // That way all the temporary allocations created before the loop are still valid even after the loop. // Such save/rewind blocks define lifetime boundaries of the temporary objects which also could be nested. // This turns the temporary storage into kind of a second stack with a more manual management. NOBDEF void nob_temp_reset(void); NOBDEF size_t nob_temp_save(void); NOBDEF void nob_temp_rewind(size_t checkpoint); // Given any path returns the last part of that path. // "/path/to/a/file.c" -> "file.c"; "/path/to/a/directory" -> "directory" NOBDEF const char *nob_path_name(const char *path); NOBDEF bool nob_rename(const char *old_path, const char *new_path); NOBDEF int nob_needs_rebuild(const char *output_path, const char **input_paths, size_t input_paths_count); NOBDEF int nob_needs_rebuild1(const char *output_path, const char *input_path); NOBDEF int nob_file_exists(const char *file_path); NOBDEF const char *nob_get_current_dir_temp(void); NOBDEF bool nob_set_current_dir(const char *path); // Returns you the directory part of the path allocated on the temporary storage. NOBDEF char *nob_temp_dir_name(const char *path); NOBDEF char *nob_temp_file_name(const char *path); NOBDEF char *nob_temp_file_ext(const char *path); NOBDEF char *nob_temp_running_executable_path(void); // TODO: we should probably document somewhere all the compilers we support // The nob_cc_* macros try to abstract away the specific compiler. // They are verify basic and not particularly flexible, but you can redefine them if you need to // or not use them at all and create your own abstraction on top of Nob_Cmd. #ifndef nob_cc # if _WIN32 # if defined(__GNUC__) # define nob_cc(cmd) nob_cmd_append(cmd, "cc") # elif defined(__clang__) # define nob_cc(cmd) nob_cmd_append(cmd, "clang") # elif defined(_MSC_VER) # define nob_cc(cmd) nob_cmd_append(cmd, "cl.exe") # elif defined(__TINYC__) # define nob_cc(cmd) nob_cmd_append(cmd, "tcc") # endif # else # define nob_cc(cmd) nob_cmd_append(cmd, "cc") # endif #endif // nob_cc #ifndef nob_cc_flags # if defined(_MSC_VER) && !defined(__clang__) # define nob_cc_flags(cmd) nob_cmd_append(cmd, "/W4", "/nologo", "/D_CRT_SECURE_NO_WARNINGS") # else # define nob_cc_flags(cmd) nob_cmd_append(cmd, "-Wall", "-Wextra") # endif #endif // nob_cc_flags #ifndef nob_cc_output # if defined(_MSC_VER) && !defined(__clang__) # define nob_cc_output(cmd, output_path) nob_cmd_append(cmd, nob_temp_sprintf("/Fe:%s", (output_path)), nob_temp_sprintf("/Fo:%s", (output_path))) # else # define nob_cc_output(cmd, output_path) nob_cmd_append(cmd, "-o", (output_path)) # endif #endif // nob_cc_output #ifndef nob_cc_inputs # define nob_cc_inputs(cmd, ...) nob_cmd_append(cmd, __VA_ARGS__) #endif // nob_cc_inputs // TODO: add MinGW support for Go Rebuild Urself™ Technology and all the nob_cc_* macros above // Musializer contributors came up with a pretty interesting idea of an optional prefix macro which could be useful for // MinGW support: // https://github.com/tsoding/musializer/blob/b7578cc76b9ecb573d239acc9ccf5a04d3aba2c9/src_build/nob_win64_mingw.c#L3-L9 // TODO: Maybe instead NOB_REBUILD_URSELF macro, the Go Rebuild Urself™ Technology should use the // user defined nob_cc_* macros instead? #ifndef NOB_REBUILD_URSELF # if defined(_WIN32) # if defined(__clang__) # if defined(__cplusplus) # define NOB_REBUILD_URSELF(binary_path, source_path) "clang", "-x", "c++", "-o", binary_path, source_path # else # define NOB_REBUILD_URSELF(binary_path, source_path) "clang", "-x", "c", "-o", binary_path, source_path # endif # elif defined(__GNUC__) # if defined(__cplusplus) # define NOB_REBUILD_URSELF(binary_path, source_path) "gcc", "-x", "c++", "-o", binary_path, source_path # else # define NOB_REBUILD_URSELF(binary_path, source_path) "gcc", "-x", "c", "-o", binary_path, source_path # endif # elif defined(_MSC_VER) # define NOB_REBUILD_URSELF(binary_path, source_path) "cl.exe", nob_temp_sprintf("/Fe:%s", (binary_path)), source_path # elif defined(__TINYC__) # define NOB_REBUILD_URSELF(binary_path, source_path) "tcc", "-o", binary_path, source_path # endif # else # if defined(__cplusplus) # define NOB_REBUILD_URSELF(binary_path, source_path) "cc", "-x", "c++", "-o", binary_path, source_path # else # define NOB_REBUILD_URSELF(binary_path, source_path) "cc", "-x", "c", "-o", binary_path, source_path # endif # endif #endif // Go Rebuild Urself™ Technology // // How to use it: // int main(int argc, char** argv) { // NOB_GO_REBUILD_URSELF(argc, argv); // // actual work // return 0; // } // // After you added this macro every time you run ./nob it will detect // that you modified its original source code and will try to rebuild itself // before doing any actual work. So you only need to bootstrap your build system // once. // // The modification is detected by comparing the last modified times of the executable // and its source code. The same way the make utility usually does it. // // The rebuilding is done by using the NOB_REBUILD_URSELF macro which you can redefine // if you need a special way of bootstraping your build system. (which I personally // do not recommend since the whole idea of NoBuild is to keep the process of bootstrapping // as simple as possible and doing all of the actual work inside of ./nob) // NOBDEF void nob__go_rebuild_urself(int argc, char **argv, const char *source_path, ...); #define NOB_GO_REBUILD_URSELF(argc, argv) nob__go_rebuild_urself(argc, argv, __FILE__, NULL) // Sometimes your nob.c includes additional files, so you want the Go Rebuild Urself™ Technology to check // if they also were modified and rebuild nob.c accordingly. For that we have NOB_GO_REBUILD_URSELF_PLUS(): // ```c // #define NOB_IMPLEMENTATION // #include "nob.h" // // #include "foo.c" // #include "bar.c" // // int main(int argc, char **argv) // { // NOB_GO_REBUILD_URSELF_PLUS(argc, argv, "foo.c", "bar.c"); // // ... // return 0; // } #define NOB_GO_REBUILD_URSELF_PLUS(argc, argv, ...) nob__go_rebuild_urself(argc, argv, __FILE__, __VA_ARGS__, NULL); typedef struct { size_t count; const char *data; } Nob_String_View; NOBDEF const char *nob_temp_sv_to_cstr(Nob_String_View sv); NOBDEF Nob_String_View nob_sv_chop_while(Nob_String_View *sv, int (*p)(int x)); NOBDEF Nob_String_View nob_sv_chop_by_delim(Nob_String_View *sv, char delim); NOBDEF Nob_String_View nob_sv_chop_left(Nob_String_View *sv, size_t n); NOBDEF Nob_String_View nob_sv_chop_right(Nob_String_View *sv, size_t n); // If `sv` starts with `prefix` chops off the prefix and returns true. // Otherwise, leaves `sv` unmodified and returns false. NOBDEF bool nob_sv_chop_prefix(Nob_String_View *sv, Nob_String_View prefix); // If `sv` ends with `suffix` chops off the suffix and returns true. // Otherwise, leaves `sv` unmodified and returns false. NOBDEF bool nob_sv_chop_suffix(Nob_String_View *sv, Nob_String_View suffix); NOBDEF Nob_String_View nob_sv_trim(Nob_String_View sv); NOBDEF Nob_String_View nob_sv_trim_left(Nob_String_View sv); NOBDEF Nob_String_View nob_sv_trim_right(Nob_String_View sv); NOBDEF bool nob_sv_eq(Nob_String_View a, Nob_String_View b); NOB_DEPRECATED("Use nob_sv_ends_with_cstr(sv, suffix) instead. " "Pay attention to the `s` at the end of the `end`. " "The reason this function was deprecated is because " "of the typo in the name, of course, but also " "because the second argument was a NULL-terminated string " "while nob_sv_starts_with() accepted Nob_String_View as the " "prefix which created an inconsistency in the API.") NOBDEF bool nob_sv_end_with(Nob_String_View sv, const char *cstr); NOBDEF bool nob_sv_ends_with_cstr(Nob_String_View sv, const char *cstr); NOBDEF bool nob_sv_ends_with(Nob_String_View sv, Nob_String_View suffix); NOBDEF bool nob_sv_starts_with(Nob_String_View sv, Nob_String_View prefix); NOBDEF Nob_String_View nob_sv_from_cstr(const char *cstr); NOBDEF Nob_String_View nob_sv_from_parts(const char *data, size_t count); // nob_sb_to_sv() enables you to just view Nob_String_Builder as Nob_String_View #define nob_sb_to_sv(sb) nob_sv_from_parts((sb).items, (sb).count) // printf macros for String_View #ifndef SV_Fmt #define SV_Fmt "%.*s" #endif // SV_Fmt #ifndef SV_Arg #define SV_Arg(sv) (int) (sv).count, (sv).data #endif // SV_Arg // USAGE: // String_View name = ...; // printf("Name: "SV_Fmt"\n", SV_Arg(name)); #ifdef _WIN32 NOBDEF char *nob_win32_error_message(DWORD err); #endif // _WIN32 #endif // NOB_H_ #ifdef NOB_IMPLEMENTATION // This is like nob_proc_wait() but waits asynchronously. Depending on the platform ms means different thing. // On Windows it means timeout. On POSIX it means for how long to sleep after checking if the process exited, // so to not peg the core too much. Since this API is kinda of weird, the function is private for now. static int nob__proc_wait_async(Nob_Proc proc, int ms); // Starts the process for the command. Its main purpose is to be the base for nob_cmd_run() and nob_cmd_run_opt(). static Nob_Proc nob__cmd_start_process(Nob_Cmd cmd, Nob_Fd *fdin, Nob_Fd *fdout, Nob_Fd *fderr); // Any messages with the level below nob_minimal_log_level are going to be suppressed. Nob_Log_Level nob_minimal_log_level = NOB_INFO; NOBDEF void nob__cmd_append(Nob_Cmd *cmd, size_t n, const char **args) { for (size_t i = 0; i < n; ++i) { nob_da_append(cmd, args[i]); } } #ifdef _WIN32 // Base on https://stackoverflow.com/a/75644008 // > .NET Core uses 4096 * sizeof(WCHAR) buffer on stack for FormatMessageW call. And...thats it. // > // > https://github.com/dotnet/runtime/blob/3b63eb1346f1ddbc921374a5108d025662fb5ffd/src/coreclr/utilcode/posterror.cpp#L264-L265 #ifndef NOB_WIN32_ERR_MSG_SIZE #define NOB_WIN32_ERR_MSG_SIZE (4 * 1024) #endif // NOB_WIN32_ERR_MSG_SIZE NOBDEF char *nob_win32_error_message(DWORD err) { static char win32ErrMsg[NOB_WIN32_ERR_MSG_SIZE] = {0}; DWORD errMsgSize = FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, err, LANG_USER_DEFAULT, win32ErrMsg, NOB_WIN32_ERR_MSG_SIZE, NULL); if (errMsgSize == 0) { if (GetLastError() != ERROR_MR_MID_NOT_FOUND) { if (sprintf(win32ErrMsg, "Could not get error message for 0x%lX", err) > 0) { return (char *)&win32ErrMsg; } else { return NULL; } } else { if (sprintf(win32ErrMsg, "Invalid Windows Error code (0x%lX)", err) > 0) { return (char *)&win32ErrMsg; } else { return NULL; } } } while (errMsgSize > 1 && isspace(win32ErrMsg[errMsgSize - 1])) { win32ErrMsg[--errMsgSize] = '\0'; } return win32ErrMsg; } #endif // _WIN32 // The implementation idea is stolen from https://github.com/zhiayang/nabs NOBDEF void nob__go_rebuild_urself(int argc, char **argv, const char *source_path, ...) { const char *binary_path = nob_shift(argv, argc); #ifdef _WIN32 // On Windows executables almost always invoked without extension, so // it's ./nob, not ./nob.exe. For renaming the extension is a must. if (!nob_sv_ends_with_cstr(nob_sv_from_cstr(binary_path), ".exe")) { binary_path = nob_temp_sprintf("%s.exe", binary_path); } #endif Nob_File_Paths source_paths = {0}; nob_da_append(&source_paths, source_path); va_list args; va_start(args, source_path); for (;;) { const char *path = va_arg(args, const char*); if (path == NULL) break; nob_da_append(&source_paths, path); } va_end(args); int rebuild_is_needed = nob_needs_rebuild(binary_path, source_paths.items, source_paths.count); if (rebuild_is_needed < 0) exit(1); // error if (!rebuild_is_needed) { // no rebuild is needed NOB_FREE(source_paths.items); return; } Nob_Cmd cmd = {0}; const char *old_binary_path = nob_temp_sprintf("%s.old", binary_path); if (!nob_rename(binary_path, old_binary_path)) exit(1); nob_cmd_append(&cmd, NOB_REBUILD_URSELF(binary_path, source_path)); Nob_Cmd_Opt opt = {0}; if (!nob_cmd_run_opt(&cmd, opt)) { nob_rename(old_binary_path, binary_path); exit(1); } #ifdef NOB_EXPERIMENTAL_DELETE_OLD // TODO: this is an experimental behavior behind a compilation flag. // Once it is confirmed that it does not cause much problems on both POSIX and Windows // we may turn it on by default. nob_delete_file(old_binary_path); #endif // NOB_EXPERIMENTAL_DELETE_OLD nob_cmd_append(&cmd, binary_path); nob_da_append_many(&cmd, argv, argc); if (!nob_cmd_run_opt(&cmd, opt)) exit(1); exit(0); } static size_t nob_temp_size = 0; static char nob_temp[NOB_TEMP_CAPACITY] = {0}; NOBDEF bool nob_mkdir_if_not_exists(const char *path) { #ifdef _WIN32 int result = _mkdir(path); #else int result = mkdir(path, 0755); #endif if (result < 0) { if (errno == EEXIST) { #ifndef NOB_NO_ECHO nob_log(NOB_INFO, "directory `%s` already exists", path); #endif // NOB_NO_ECHO return true; } nob_log(NOB_ERROR, "could not create directory `%s`: %s", path, strerror(errno)); return false; } #ifndef NOB_NO_ECHO nob_log(NOB_INFO, "created directory `%s`", path); #endif // NOB_NO_ECHO return true; } NOBDEF bool nob_copy_file(const char *src_path, const char *dst_path) { #ifndef NOB_NO_ECHO nob_log(NOB_INFO, "copying %s -> %s", src_path, dst_path); #endif // NOB_NO_ECHO #ifdef _WIN32 if (!CopyFile(src_path, dst_path, FALSE)) { nob_log(NOB_ERROR, "Could not copy file: %s", nob_win32_error_message(GetLastError())); return false; } return true; #else int src_fd = -1; int dst_fd = -1; size_t buf_size = 32*1024; char *buf = (char*)NOB_REALLOC(NULL, buf_size); NOB_ASSERT(buf != NULL && "Buy more RAM lol!!"); bool result = true; src_fd = open(src_path, O_RDONLY); if (src_fd < 0) { nob_log(NOB_ERROR, "Could not open file %s: %s", src_path, strerror(errno)); nob_return_defer(false); } struct stat src_stat; if (fstat(src_fd, &src_stat) < 0) { nob_log(NOB_ERROR, "Could not get mode of file %s: %s", src_path, strerror(errno)); nob_return_defer(false); } dst_fd = open(dst_path, O_CREAT | O_TRUNC | O_WRONLY, src_stat.st_mode); if (dst_fd < 0) { nob_log(NOB_ERROR, "Could not create file %s: %s", dst_path, strerror(errno)); nob_return_defer(false); } for (;;) { ssize_t n = read(src_fd, buf, buf_size); if (n == 0) break; if (n < 0) { nob_log(NOB_ERROR, "Could not read from file %s: %s", src_path, strerror(errno)); nob_return_defer(false); } char *buf2 = buf; while (n > 0) { ssize_t m = write(dst_fd, buf2, n); if (m < 0) { nob_log(NOB_ERROR, "Could not write to file %s: %s", dst_path, strerror(errno)); nob_return_defer(false); } n -= m; buf2 += m; } } defer: NOB_FREE(buf); close(src_fd); close(dst_fd); return result; #endif } NOBDEF void nob_cmd_render(Nob_Cmd cmd, Nob_String_Builder *render) { for (size_t i = 0; i < cmd.count; ++i) { const char *arg = cmd.items[i]; if (arg == NULL) break; if (i > 0) nob_sb_append_cstr(render, " "); if (!strchr(arg, ' ')) { nob_sb_append_cstr(render, arg); } else { nob_da_append(render, '\''); nob_sb_append_cstr(render, arg); nob_da_append(render, '\''); } } } #ifdef _WIN32 // https://learn.microsoft.com/en-gb/archive/blogs/twistylittlepassagesallalike/everyone-quotes-command-line-arguments-the-wrong-way static void nob__win32_cmd_quote(Nob_Cmd cmd, Nob_String_Builder *quoted) { for (size_t i = 0; i < cmd.count; ++i) { const char *arg = cmd.items[i]; if (arg == NULL) break; size_t len = strlen(arg); if (i > 0) nob_da_append(quoted, ' '); if (len != 0 && NULL == strpbrk(arg, " \t\n\v\"")) { // no need to quote nob_da_append_many(quoted, arg, len); } else { // we need to escape: // 1. double quotes in the original arg // 2. consequent backslashes before a double quote size_t backslashes = 0; nob_da_append(quoted, '\"'); for (size_t j = 0; j < len; ++j) { char x = arg[j]; if (x == '\\') { backslashes += 1; } else { if (x == '\"') { // escape backslashes (if any) and the double quote for (size_t k = 0; k < 1+backslashes; ++k) { nob_da_append(quoted, '\\'); } } backslashes = 0; } nob_da_append(quoted, x); } // escape backslashes (if any) for (size_t k = 0; k < backslashes; ++k) { nob_da_append(quoted, '\\'); } nob_da_append(quoted, '\"'); } } } #endif NOBDEF int nob_nprocs(void) { #ifdef _WIN32 SYSTEM_INFO siSysInfo; GetSystemInfo(&siSysInfo); return siSysInfo.dwNumberOfProcessors; #else return sysconf(_SC_NPROCESSORS_ONLN); #endif } NOBDEF bool nob_cmd_run_opt(Nob_Cmd *cmd, Nob_Cmd_Opt opt) { bool result = true; Nob_Fd fdin = NOB_INVALID_FD; Nob_Fd fdout = NOB_INVALID_FD; Nob_Fd fderr = NOB_INVALID_FD; Nob_Fd *opt_fdin = NULL; Nob_Fd *opt_fdout = NULL; Nob_Fd *opt_fderr = NULL; Nob_Proc proc = NOB_INVALID_PROC; size_t max_procs = opt.max_procs > 0 ? opt.max_procs : (size_t) nob_nprocs() + 1; if (opt.async && max_procs > 0) { while (opt.async->count >= max_procs) { for (size_t i = 0; i < opt.async->count; ++i) { int ret = nob__proc_wait_async(opt.async->items[i], 1); if (ret < 0) nob_return_defer(false); if (ret) { nob_da_remove_unordered(opt.async, i); break; } } } } if (opt.stdin_path) { fdin = nob_fd_open_for_read(opt.stdin_path); if (fdin == NOB_INVALID_FD) nob_return_defer(false); opt_fdin = &fdin; } if (opt.stdout_path) { fdout = nob_fd_open_for_write(opt.stdout_path); if (fdout == NOB_INVALID_FD) nob_return_defer(false); opt_fdout = &fdout; } if (opt.stderr_path) { fderr = nob_fd_open_for_write(opt.stderr_path); if (fderr == NOB_INVALID_FD) nob_return_defer(false); opt_fderr = &fderr; } proc = nob__cmd_start_process(*cmd, opt_fdin, opt_fdout, opt_fderr); if (opt.async) { if (proc == NOB_INVALID_PROC) nob_return_defer(false); nob_da_append(opt.async, proc); } else { if (!nob_proc_wait(proc)) nob_return_defer(false); } defer: if (opt_fdin) nob_fd_close(*opt_fdin); if (opt_fdout) nob_fd_close(*opt_fdout); if (opt_fderr) nob_fd_close(*opt_fderr); if (!opt.dont_reset) cmd->count = 0; return result; } NOBDEF bool nob_chain_begin_opt(Nob_Chain *chain, Nob_Chain_Begin_Opt opt) { chain->cmd.count = 0; chain->err2out = false; chain->fdin = NOB_INVALID_FD; if (opt.stdin_path) { chain->fdin = nob_fd_open_for_read(opt.stdin_path); if (chain->fdin == NOB_INVALID_FD) return false; } return true; } NOBDEF bool nob_chain_cmd_opt(Nob_Chain *chain, Nob_Cmd *cmd, Nob_Chain_Cmd_Opt opt) { bool result = true; Nob_Pipe pp = {0}; struct { size_t count; Nob_Fd items[5]; // should be no more than 3, but we allocate 5 just in case } fds = {0}; NOB_ASSERT(cmd->count > 0); if (chain->cmd.count != 0) { // not first cmd in the chain Nob_Fd *pfdin = NULL; if (chain->fdin != NOB_INVALID_FD) { nob_fa_append(&fds, chain->fdin); pfdin = &chain->fdin; } if (!nob_pipe_create(&pp)) nob_return_defer(false); nob_fa_append(&fds, pp.write); Nob_Fd *pfdout = &pp.write; Nob_Fd *pfderr = chain->err2out ? pfdout : NULL; Nob_Proc proc = nob__cmd_start_process(chain->cmd, pfdin, pfdout, pfderr); chain->cmd.count = 0; if (proc == NOB_INVALID_PROC) { nob_fa_append(&fds, pp.read); nob_return_defer(false); } chain->fdin = pp.read; } nob_da_append_many(&chain->cmd, cmd->items, cmd->count); chain->err2out = opt.err2out; defer: for (size_t i = 0; i < fds.count; ++i) { nob_fd_close(fds.items[i]); } if (!opt.dont_reset) cmd->count = 0; return result; } static Nob_Fd nob__fd_stdout(void) { #ifdef _WIN32 return GetStdHandle(STD_OUTPUT_HANDLE); #else return STDOUT_FILENO; #endif // _WIN32 } NOBDEF bool nob_chain_end_opt(Nob_Chain *chain, Nob_Chain_End_Opt opt) { bool result = true; Nob_Fd *pfdin = NULL; struct { size_t count; Nob_Fd items[5]; // should be no more than 3, but we allocate 5 just in case } fds = {0}; if (chain->fdin != NOB_INVALID_FD) { nob_fa_append(&fds, chain->fdin); pfdin = &chain->fdin; } if (chain->cmd.count != 0) { // Non-empty chain case size_t max_procs = opt.max_procs > 0 ? opt.max_procs : (size_t) nob_nprocs() + 1; if (opt.async && max_procs > 0) { while (opt.async->count >= max_procs) { for (size_t i = 0; i < opt.async->count; ++i) { int ret = nob__proc_wait_async(opt.async->items[i], 1); if (ret < 0) nob_return_defer(false); if (ret) { nob_da_remove_unordered(opt.async, i); break; } } } } Nob_Fd fdout = nob__fd_stdout(); if (opt.stdout_path) { fdout = nob_fd_open_for_write(opt.stdout_path); if (fdout == NOB_INVALID_FD) nob_return_defer(false); nob_fa_append(&fds, fdout); } Nob_Fd fderr = 0; Nob_Fd *pfderr = NULL; if (chain->err2out) pfderr = &fdout; if (opt.stderr_path) { if (pfderr == NULL) { fderr = nob_fd_open_for_write(opt.stderr_path); if (fderr == NOB_INVALID_FD) nob_return_defer(false); nob_fa_append(&fds, fderr); pfderr = &fderr; } else { // There was err2out set for the last command. // All the stderr will go to stdout. // So the stderr file is going to be empty. NOB_ASSERT(chain->err2out); if (!nob_write_entire_file(opt.stderr_path, NULL, 0)) nob_return_defer(false); } } Nob_Proc proc = nob__cmd_start_process(chain->cmd, pfdin, &fdout, pfderr); chain->cmd.count = 0; if (opt.async) { if (proc == NOB_INVALID_PROC) nob_return_defer(false); nob_da_append(opt.async, proc); } else { if (!nob_proc_wait(proc)) nob_return_defer(false); } } defer: for (size_t i = 0; i < fds.count; ++i) { nob_fd_close(fds.items[i]); } return result; } // The maximum time span representable is 584 years. NOBDEF uint64_t nob_nanos_since_unspecified_epoch(void) { #ifdef _WIN32 LARGE_INTEGER Time; QueryPerformanceCounter(&Time); static LARGE_INTEGER Frequency = {0}; if (Frequency.QuadPart == 0) { QueryPerformanceFrequency(&Frequency); } uint64_t Secs = Time.QuadPart / Frequency.QuadPart; uint64_t Nanos = Time.QuadPart % Frequency.QuadPart * NOB_NANOS_PER_SEC / Frequency.QuadPart; return NOB_NANOS_PER_SEC * Secs + Nanos; #else struct timespec ts; clock_gettime(CLOCK_MONOTONIC, &ts); return NOB_NANOS_PER_SEC * ts.tv_sec + ts.tv_nsec; #endif // _WIN32 } NOBDEF Nob_Proc nob_cmd_run_async_redirect(Nob_Cmd cmd, Nob_Cmd_Redirect redirect) { return nob__cmd_start_process(cmd, redirect.fdin, redirect.fdout, redirect.fderr); } static Nob_Proc nob__cmd_start_process(Nob_Cmd cmd, Nob_Fd *fdin, Nob_Fd *fdout, Nob_Fd *fderr) { if (cmd.count < 1) { nob_log(NOB_ERROR, "Could not run empty command"); return NOB_INVALID_PROC; } #ifndef NOB_NO_ECHO Nob_String_Builder sb = {0}; nob_cmd_render(cmd, &sb); nob_sb_append_null(&sb); nob_log(NOB_INFO, "CMD: %s", sb.items); nob_sb_free(sb); memset(&sb, 0, sizeof(sb)); #endif // NOB_NO_ECHO #ifdef _WIN32 // https://docs.microsoft.com/en-us/windows/win32/procthread/creating-a-child-process-with-redirected-input-and-output STARTUPINFO siStartInfo; ZeroMemory(&siStartInfo, sizeof(siStartInfo)); siStartInfo.cb = sizeof(STARTUPINFO); // NOTE: theoretically setting NULL to std handles should not be a problem // https://docs.microsoft.com/en-us/windows/console/getstdhandle?redirectedfrom=MSDN#attachdetach-behavior // TODO: check for errors in GetStdHandle siStartInfo.hStdError = fderr ? *fderr : GetStdHandle(STD_ERROR_HANDLE); siStartInfo.hStdOutput = fdout ? *fdout : GetStdHandle(STD_OUTPUT_HANDLE); siStartInfo.hStdInput = fdin ? *fdin : GetStdHandle(STD_INPUT_HANDLE); siStartInfo.dwFlags |= STARTF_USESTDHANDLES; PROCESS_INFORMATION piProcInfo; ZeroMemory(&piProcInfo, sizeof(PROCESS_INFORMATION)); Nob_String_Builder quoted = {0}; nob__win32_cmd_quote(cmd, "ed); nob_sb_append_null("ed); BOOL bSuccess = CreateProcessA(NULL, quoted.items, NULL, NULL, TRUE, 0, NULL, NULL, &siStartInfo, &piProcInfo); nob_sb_free(quoted); if (!bSuccess) { nob_log(NOB_ERROR, "Could not create child process for %s: %s", cmd.items[0], nob_win32_error_message(GetLastError())); return NOB_INVALID_PROC; } CloseHandle(piProcInfo.hThread); return piProcInfo.hProcess; #else pid_t cpid = fork(); if (cpid < 0) { nob_log(NOB_ERROR, "Could not fork child process: %s", strerror(errno)); return NOB_INVALID_PROC; } if (cpid == 0) { if (fdin) { if (dup2(*fdin, STDIN_FILENO) < 0) { nob_log(NOB_ERROR, "Could not setup stdin for child process: %s", strerror(errno)); exit(1); } } if (fdout) { if (dup2(*fdout, STDOUT_FILENO) < 0) { nob_log(NOB_ERROR, "Could not setup stdout for child process: %s", strerror(errno)); exit(1); } } if (fderr) { if (dup2(*fderr, STDERR_FILENO) < 0) { nob_log(NOB_ERROR, "Could not setup stderr for child process: %s", strerror(errno)); exit(1); } } // NOTE: This leaks a bit of memory in the child process. // But do we actually care? It's a one off leak anyway... Nob_Cmd cmd_null = {0}; nob_da_append_many(&cmd_null, cmd.items, cmd.count); nob_cmd_append(&cmd_null, (const char*)NULL); if (execvp(cmd.items[0], (char * const*) cmd_null.items) < 0) { nob_log(NOB_ERROR, "Could not exec child process for %s: %s", cmd.items[0], strerror(errno)); exit(1); } NOB_UNREACHABLE("nob_cmd_run_async_redirect"); } return cpid; #endif } NOBDEF Nob_Proc nob_cmd_run_async(Nob_Cmd cmd) { return nob__cmd_start_process(cmd, NULL, NULL, NULL); } NOBDEF Nob_Proc nob_cmd_run_async_and_reset(Nob_Cmd *cmd) { Nob_Proc proc = nob__cmd_start_process(*cmd, NULL, NULL, NULL); cmd->count = 0; return proc; } NOBDEF Nob_Proc nob_cmd_run_async_redirect_and_reset(Nob_Cmd *cmd, Nob_Cmd_Redirect redirect) { Nob_Proc proc = nob__cmd_start_process(*cmd, redirect.fdin, redirect.fdout, redirect.fderr); cmd->count = 0; if (redirect.fdin) { nob_fd_close(*redirect.fdin); *redirect.fdin = NOB_INVALID_FD; } if (redirect.fdout) { nob_fd_close(*redirect.fdout); *redirect.fdout = NOB_INVALID_FD; } if (redirect.fderr) { nob_fd_close(*redirect.fderr); *redirect.fderr = NOB_INVALID_FD; } return proc; } NOBDEF Nob_Fd nob_fd_open_for_read(const char *path) { #ifndef _WIN32 Nob_Fd result = open(path, O_RDONLY); if (result < 0) { nob_log(NOB_ERROR, "Could not open file %s: %s", path, strerror(errno)); return NOB_INVALID_FD; } return result; #else // https://docs.microsoft.com/en-us/windows/win32/fileio/opening-a-file-for-reading-or-writing SECURITY_ATTRIBUTES saAttr = {0}; saAttr.nLength = sizeof(SECURITY_ATTRIBUTES); saAttr.bInheritHandle = TRUE; Nob_Fd result = CreateFile( path, GENERIC_READ, 0, &saAttr, OPEN_EXISTING, FILE_ATTRIBUTE_READONLY, NULL); if (result == INVALID_HANDLE_VALUE) { nob_log(NOB_ERROR, "Could not open file %s: %s", path, nob_win32_error_message(GetLastError())); return NOB_INVALID_FD; } return result; #endif // _WIN32 } NOBDEF Nob_Fd nob_fd_open_for_write(const char *path) { #ifndef _WIN32 Nob_Fd result = open(path, O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); if (result < 0) { nob_log(NOB_ERROR, "could not open file %s: %s", path, strerror(errno)); return NOB_INVALID_FD; } return result; #else SECURITY_ATTRIBUTES saAttr = {0}; saAttr.nLength = sizeof(SECURITY_ATTRIBUTES); saAttr.bInheritHandle = TRUE; Nob_Fd result = CreateFile( path, // name of the write GENERIC_WRITE, // open for writing 0, // do not share &saAttr, // default security CREATE_ALWAYS, // create always FILE_ATTRIBUTE_NORMAL, // normal file NULL // no attr. template ); if (result == INVALID_HANDLE_VALUE) { nob_log(NOB_ERROR, "Could not open file %s: %s", path, nob_win32_error_message(GetLastError())); return NOB_INVALID_FD; } return result; #endif // _WIN32 } NOBDEF void nob_fd_close(Nob_Fd fd) { #ifdef _WIN32 CloseHandle(fd); #else close(fd); #endif // _WIN32 } NOBDEF bool nob_pipe_create(Nob_Pipe *pp) { #ifdef _WIN32 // https://docs.microsoft.com/en-us/windows/win32/ProcThread/creating-a-child-process-with-redirected-input-and-output SECURITY_ATTRIBUTES saAttr = {0}; saAttr.nLength = sizeof(SECURITY_ATTRIBUTES); saAttr.bInheritHandle = TRUE; if (!CreatePipe(&pp->read, &pp->write, &saAttr, 0)) { nob_log(NOB_ERROR, "Could not create pipe: %s", nob_win32_error_message(GetLastError())); return false; } return true; #else int pipefd[2]; if (pipe(pipefd) < 0) { nob_log(NOB_ERROR, "Could not create pipe: %s\n", strerror(errno)); return false; } pp->read = pipefd[0]; pp->write = pipefd[1]; return true; #endif // _WIN32 } NOBDEF bool nob_procs_wait(Nob_Procs procs) { bool success = true; for (size_t i = 0; i < procs.count; ++i) { success = nob_proc_wait(procs.items[i]) && success; } return success; } NOBDEF bool nob_procs_flush(Nob_Procs *procs) { bool success = nob_procs_wait(*procs); procs->count = 0; return success; } NOBDEF bool nob_procs_wait_and_reset(Nob_Procs *procs) { return nob_procs_flush(procs); } NOBDEF bool nob_proc_wait(Nob_Proc proc) { if (proc == NOB_INVALID_PROC) return false; #ifdef _WIN32 DWORD result = WaitForSingleObject( proc, // HANDLE hHandle, INFINITE // DWORD dwMilliseconds ); if (result == WAIT_FAILED) { nob_log(NOB_ERROR, "could not wait on child process: %s", nob_win32_error_message(GetLastError())); return false; } DWORD exit_status; if (!GetExitCodeProcess(proc, &exit_status)) { nob_log(NOB_ERROR, "could not get process exit code: %s", nob_win32_error_message(GetLastError())); return false; } if (exit_status != 0) { nob_log(NOB_ERROR, "command exited with exit code %lu", exit_status); return false; } CloseHandle(proc); return true; #else for (;;) { int wstatus = 0; if (waitpid(proc, &wstatus, 0) < 0) { nob_log(NOB_ERROR, "could not wait on command (pid %d): %s", proc, strerror(errno)); return false; } if (WIFEXITED(wstatus)) { int exit_status = WEXITSTATUS(wstatus); if (exit_status != 0) { nob_log(NOB_ERROR, "command exited with exit code %d", exit_status); return false; } break; } if (WIFSIGNALED(wstatus)) { nob_log(NOB_ERROR, "command process was terminated by signal %d", WTERMSIG(wstatus)); return false; } } return true; #endif } static int nob__proc_wait_async(Nob_Proc proc, int ms) { if (proc == NOB_INVALID_PROC) return false; #ifdef _WIN32 DWORD result = WaitForSingleObject( proc, // HANDLE hHandle, ms // DWORD dwMilliseconds ); if (result == WAIT_TIMEOUT) { return 0; } if (result == WAIT_FAILED) { nob_log(NOB_ERROR, "could not wait on child process: %s", nob_win32_error_message(GetLastError())); return -1; } DWORD exit_status; if (!GetExitCodeProcess(proc, &exit_status)) { nob_log(NOB_ERROR, "could not get process exit code: %s", nob_win32_error_message(GetLastError())); return -1; } if (exit_status != 0) { nob_log(NOB_ERROR, "command exited with exit code %lu", exit_status); return -1; } CloseHandle(proc); return 1; #else long ns = ms*1000*1000; struct timespec duration = { .tv_sec = ns/(1000*1000*1000), .tv_nsec = ns%(1000*1000*1000), }; int wstatus = 0; pid_t pid = waitpid(proc, &wstatus, WNOHANG); if (pid < 0) { nob_log(NOB_ERROR, "could not wait on command (pid %d): %s", proc, strerror(errno)); return -1; } if (pid == 0) { nanosleep(&duration, NULL); return 0; } if (WIFEXITED(wstatus)) { int exit_status = WEXITSTATUS(wstatus); if (exit_status != 0) { nob_log(NOB_ERROR, "command exited with exit code %d", exit_status); return -1; } return 1; } if (WIFSIGNALED(wstatus)) { nob_log(NOB_ERROR, "command process was terminated by signal %d", WTERMSIG(wstatus)); return -1; } nanosleep(&duration, NULL); return 0; #endif } NOBDEF bool nob_procs_append_with_flush(Nob_Procs *procs, Nob_Proc proc, size_t max_procs_count) { nob_da_append(procs, proc); if (procs->count >= max_procs_count) { if (!nob_procs_flush(procs)) return false; } return true; } NOBDEF bool nob_cmd_run_sync_redirect(Nob_Cmd cmd, Nob_Cmd_Redirect redirect) { Nob_Proc p = nob__cmd_start_process(cmd, redirect.fdin, redirect.fdout, redirect.fderr); return nob_proc_wait(p); } NOBDEF bool nob_cmd_run_sync(Nob_Cmd cmd) { Nob_Proc p = nob__cmd_start_process(cmd, NULL, NULL, NULL); return nob_proc_wait(p); } NOBDEF bool nob_cmd_run_sync_and_reset(Nob_Cmd *cmd) { Nob_Proc p = nob__cmd_start_process(*cmd, NULL, NULL, NULL); cmd->count = 0; return nob_proc_wait(p); } NOBDEF bool nob_cmd_run_sync_redirect_and_reset(Nob_Cmd *cmd, Nob_Cmd_Redirect redirect) { Nob_Proc p = nob__cmd_start_process(*cmd, redirect.fdin, redirect.fdout, redirect.fderr); cmd->count = 0; if (redirect.fdin) { nob_fd_close(*redirect.fdin); *redirect.fdin = NOB_INVALID_FD; } if (redirect.fdout) { nob_fd_close(*redirect.fdout); *redirect.fdout = NOB_INVALID_FD; } if (redirect.fderr) { nob_fd_close(*redirect.fderr); *redirect.fderr = NOB_INVALID_FD; } return nob_proc_wait(p); } static Nob_Log_Handler *nob__log_handler = &nob_default_log_handler; NOBDEF void nob_set_log_handler(Nob_Log_Handler *handler) { nob__log_handler = handler; } NOBDEF Nob_Log_Handler *nob_get_log_handler(void) { return nob__log_handler; } NOBDEF void nob_default_log_handler(Nob_Log_Level level, const char *fmt, va_list args) { if (level < nob_minimal_log_level) return; switch (level) { case NOB_INFO: fprintf(stderr, "[INFO] "); break; case NOB_WARNING: fprintf(stderr, "[WARNING] "); break; case NOB_ERROR: fprintf(stderr, "[ERROR] "); break; case NOB_NO_LOGS: return; default: NOB_UNREACHABLE("Nob_Log_Level"); } vfprintf(stderr, fmt, args); fprintf(stderr, "\n"); } NOBDEF void nob_null_log_handler(Nob_Log_Level level, const char *fmt, va_list args) { NOB_UNUSED(level); NOB_UNUSED(fmt); NOB_UNUSED(args); } NOBDEF void nob_cancer_log_handler(Nob_Log_Level level, const char *fmt, va_list args) { switch (level) { case NOB_INFO: fprintf(stderr, "ℹ️ \x1b[36m[INFO]\x1b[0m "); break; case NOB_WARNING: fprintf(stderr, "⚠️ \x1b[33m[WARNING]\x1b[0m "); break; case NOB_ERROR: fprintf(stderr, "🚨 \x1b[31m[ERROR]\x1b[0m "); break; case NOB_NO_LOGS: return; default: NOB_UNREACHABLE("Nob_Log_Level"); } vfprintf(stderr, fmt, args); fprintf(stderr, "\n"); } NOBDEF void nob_log(Nob_Log_Level level, const char *fmt, ...) { va_list args; va_start(args, fmt); nob__log_handler(level, fmt, args); va_end(args); } NOBDEF bool nob_dir_entry_open(const char *dir_path, Nob_Dir_Entry *dir) { memset(dir, 0, sizeof(*dir)); #ifdef _WIN32 size_t temp_mark = nob_temp_save(); char *buffer = nob_temp_sprintf("%s\\*", dir_path); dir->nob__private.win32_hFind = FindFirstFile(buffer, &dir->nob__private.win32_data); nob_temp_rewind(temp_mark); if (dir->nob__private.win32_hFind == INVALID_HANDLE_VALUE) { nob_log(NOB_ERROR, "Could not open directory %s: %s", dir_path, nob_win32_error_message(GetLastError())); dir->error = true; return false; } #else dir->nob__private.posix_dir = opendir(dir_path); if (dir->nob__private.posix_dir == NULL) { nob_log(NOB_ERROR, "Could not open directory %s: %s", dir_path, strerror(errno)); dir->error = true; return false; } #endif // _WIN32 return true; } NOBDEF bool nob_dir_entry_next(Nob_Dir_Entry *dir) { #ifdef _WIN32 if (!dir->nob__private.win32_init) { dir->nob__private.win32_init = true; dir->name = dir->nob__private.win32_data.cFileName; return true; } if (!FindNextFile(dir->nob__private.win32_hFind, &dir->nob__private.win32_data)) { if (GetLastError() == ERROR_NO_MORE_FILES) return false; nob_log(NOB_ERROR, "Could not read next directory entry: %s", nob_win32_error_message(GetLastError())); dir->error = true; return false; } dir->name = dir->nob__private.win32_data.cFileName; #else errno = 0; dir->nob__private.posix_ent = readdir(dir->nob__private.posix_dir); if (dir->nob__private.posix_ent == NULL) { if (errno == 0) return false; nob_log(NOB_ERROR, "Could not read next directory entry: %s", strerror(errno)); dir->error = true; return false; } dir->name = dir->nob__private.posix_ent->d_name; #endif // _WIN32 return true; } NOBDEF void nob_dir_entry_close(Nob_Dir_Entry dir) { #ifdef _WIN32 FindClose(dir.nob__private.win32_hFind); #else if (dir.nob__private.posix_dir) closedir(dir.nob__private.posix_dir); #endif } // On the moment of entering `nob__walk_dir_opt_impl()`, the `file_path` Nob_String_Builder is expected to be NULL-terminated. // So you can freely pass `file_path->items` to functions that expect NULL-terminated file path. // On existing `nob__walk_dir_opt_impl()` is expected to restore the original content of `file_path` bool nob__walk_dir_opt_impl(Nob_String_Builder *file_path, Nob_Walk_Func func, size_t level, bool *stop, Nob_Walk_Dir_Opt opt) { NOB_ASSERT(file_path->count > 0 && "file_path was probably not properly NULL-terminated"); bool result = true; Nob_Dir_Entry dir = {0}; size_t saved_file_path_count = file_path->count; Nob_Walk_Action action = NOB_WALK_CONT; Nob_File_Type file_type = nob_get_file_type(file_path->items); if (file_type < 0) nob_return_defer(false); // Pre-order walking if (!opt.post_order) { if (!func(NOB_CLIT(Nob_Walk_Entry) { .path = file_path->items, .type = file_type, .level = level, .data = opt.data, .action = &action, })) nob_return_defer(false); switch (action) { case NOB_WALK_CONT: break; case NOB_WALK_STOP: *stop = true; // fallthrough case NOB_WALK_SKIP: nob_return_defer(true); default: NOB_UNREACHABLE("Nob_Walk_Action"); } } if (file_type == NOB_FILE_DIRECTORY) { if (!nob_dir_entry_open(file_path->items, &dir)) nob_return_defer(false); for (;;) { // Next entry if (!nob_dir_entry_next(&dir)) { if (!dir.error) break; nob_return_defer(false); } // Ignore . and .. if (strcmp(dir.name, ".") == 0) continue; if (strcmp(dir.name, "..") == 0) continue; // Prepare the new file_path file_path->count = saved_file_path_count - 1; #ifdef _WIN32 nob_sb_appendf(file_path, "\\%s", dir.name); #else nob_sb_appendf(file_path, "/%s", dir.name); #endif // _WIN32 nob_sb_append_null(file_path); // Recurse if (!nob__walk_dir_opt_impl(file_path, func, level+1, stop, opt)) nob_return_defer(false); if (*stop) nob_return_defer(true); } file_path->count = saved_file_path_count; nob_da_last(file_path) = '\0'; } // Post-order walking if (opt.post_order) { if (!func(NOB_CLIT(Nob_Walk_Entry) { .path = file_path->items, .type = file_type, .level = level, .data = opt.data, .action = &action, })) nob_return_defer(false); switch (action) { case NOB_WALK_CONT: break; case NOB_WALK_STOP: *stop = true; // fallthrough case NOB_WALK_SKIP: nob_return_defer(true); default: NOB_UNREACHABLE("Nob_Walk_Action"); } } defer: // Always reset the file_path back to what it was file_path->count = saved_file_path_count; nob_da_last(file_path) = '\0'; nob_dir_entry_close(dir); return result; } NOBDEF bool nob_walk_dir_opt(const char *root, Nob_Walk_Func func, Nob_Walk_Dir_Opt opt) { Nob_String_Builder file_path = {0}; nob_sb_appendf(&file_path, "%s", root); nob_sb_append_null(&file_path); bool stop = false; bool ok = nob__walk_dir_opt_impl(&file_path, func, 0, &stop, opt); free(file_path.items); return ok; } NOBDEF bool nob_read_entire_dir(const char *parent, Nob_File_Paths *children) { if (strlen(parent) == 0) { nob_log(NOB_ERROR, "Cannot read empty path"); return false; } bool result = true; Nob_Dir_Entry dir = {0}; if (!nob_dir_entry_open(parent, &dir)) nob_return_defer(false); while (nob_dir_entry_next(&dir)) nob_da_append(children, nob_temp_strdup(dir.name)); if (dir.error) nob_return_defer(false); defer: nob_dir_entry_close(dir); return result; } NOBDEF bool nob_write_entire_file(const char *path, const void *data, size_t size) { bool result = true; const char *buf = NULL; FILE *f = fopen(path, "wb"); if (f == NULL) { nob_log(NOB_ERROR, "Could not open file %s for writing: %s\n", path, strerror(errno)); nob_return_defer(false); } // len // v // aaaaaaaaaa // ^ // data buf = (const char*)data; while (size > 0) { size_t n = fwrite(buf, 1, size, f); if (ferror(f)) { nob_log(NOB_ERROR, "Could not write into file %s: %s\n", path, strerror(errno)); nob_return_defer(false); } size -= n; buf += n; } defer: if (f) fclose(f); return result; } NOBDEF Nob_File_Type nob_get_file_type(const char *path) { #ifdef _WIN32 DWORD attr = GetFileAttributesA(path); if (attr == INVALID_FILE_ATTRIBUTES) { nob_log(NOB_ERROR, "Could not get file attributes of %s: %s", path, nob_win32_error_message(GetLastError())); return (Nob_File_Type)-1; } if (attr & FILE_ATTRIBUTE_DIRECTORY) return NOB_FILE_DIRECTORY; // TODO: detect symlinks on Windows (whatever that means on Windows anyway) return NOB_FILE_REGULAR; #else // _WIN32 struct stat statbuf; if (lstat(path, &statbuf) < 0) { nob_log(NOB_ERROR, "Could not get stat of %s: %s", path, strerror(errno)); return (Nob_File_Type)(-1); } if (S_ISREG(statbuf.st_mode)) return NOB_FILE_REGULAR; if (S_ISDIR(statbuf.st_mode)) return NOB_FILE_DIRECTORY; if (S_ISLNK(statbuf.st_mode)) return NOB_FILE_SYMLINK; return NOB_FILE_OTHER; #endif // _WIN32 } NOBDEF bool nob_delete_file(const char *path) { #ifndef NOB_NO_ECHO nob_log(NOB_INFO, "deleting %s", path); #endif // NOB_NO_ECHO #ifdef _WIN32 Nob_File_Type type = nob_get_file_type(path); switch (type) { case NOB_FILE_DIRECTORY: if (!RemoveDirectoryA(path)) { nob_log(NOB_ERROR, "Could not delete directory %s: %s", path, nob_win32_error_message(GetLastError())); return false; } break; case NOB_FILE_REGULAR: case NOB_FILE_SYMLINK: case NOB_FILE_OTHER: if (!DeleteFileA(path)) { nob_log(NOB_ERROR, "Could not delete file %s: %s", path, nob_win32_error_message(GetLastError())); return false; } break; default: NOB_UNREACHABLE("Nob_File_Type"); } return true; #else if (remove(path) < 0) { nob_log(NOB_ERROR, "Could not delete file %s: %s", path, strerror(errno)); return false; } return true; #endif // _WIN32 } NOBDEF bool nob_copy_directory_recursively(const char *src_path, const char *dst_path) { bool result = true; Nob_File_Paths children = {0}; Nob_String_Builder src_sb = {0}; Nob_String_Builder dst_sb = {0}; size_t temp_checkpoint = nob_temp_save(); Nob_File_Type type = nob_get_file_type(src_path); if (type < 0) return false; switch (type) { case NOB_FILE_DIRECTORY: { if (!nob_mkdir_if_not_exists(dst_path)) nob_return_defer(false); if (!nob_read_entire_dir(src_path, &children)) nob_return_defer(false); for (size_t i = 0; i < children.count; ++i) { if (strcmp(children.items[i], ".") == 0) continue; if (strcmp(children.items[i], "..") == 0) continue; src_sb.count = 0; nob_sb_append_cstr(&src_sb, src_path); nob_sb_append_cstr(&src_sb, "/"); nob_sb_append_cstr(&src_sb, children.items[i]); nob_sb_append_null(&src_sb); dst_sb.count = 0; nob_sb_append_cstr(&dst_sb, dst_path); nob_sb_append_cstr(&dst_sb, "/"); nob_sb_append_cstr(&dst_sb, children.items[i]); nob_sb_append_null(&dst_sb); if (!nob_copy_directory_recursively(src_sb.items, dst_sb.items)) { nob_return_defer(false); } } } break; case NOB_FILE_REGULAR: { if (!nob_copy_file(src_path, dst_path)) { nob_return_defer(false); } } break; case NOB_FILE_SYMLINK: { nob_log(NOB_WARNING, "TODO: Copying symlinks is not supported yet"); } break; case NOB_FILE_OTHER: { nob_log(NOB_ERROR, "Unsupported type of file %s", src_path); nob_return_defer(false); } break; default: NOB_UNREACHABLE("nob_copy_directory_recursively"); } defer: nob_temp_rewind(temp_checkpoint); nob_da_free(src_sb); nob_da_free(dst_sb); nob_da_free(children); return result; } NOBDEF char *nob_temp_strdup(const char *cstr) { size_t n = strlen(cstr); char *result = (char*)nob_temp_alloc(n + 1); NOB_ASSERT(result != NULL && "Increase NOB_TEMP_CAPACITY"); memcpy(result, cstr, n); result[n] = '\0'; return result; } NOBDEF char *nob_temp_strndup(const char *s, size_t n) { char *r = (char*)nob_temp_alloc(n + 1); NOB_ASSERT(r != NULL && "Extend the size of the temporary allocator"); memcpy(r, s, n); r[n] = '\0'; return r; } NOBDEF void *nob_temp_alloc(size_t requested_size) { size_t word_size = sizeof(uintptr_t); size_t size = (requested_size + word_size - 1)/word_size*word_size; if (nob_temp_size + size > NOB_TEMP_CAPACITY) return NULL; void *result = &nob_temp[nob_temp_size]; nob_temp_size += size; return result; } NOBDEF char *nob_temp_vsprintf(const char *format, va_list ap) { va_list args; va_copy(args, ap); int n = vsnprintf(NULL, 0, format, args); va_end(args); NOB_ASSERT(n >= 0); char *result = (char*)nob_temp_alloc(n + 1); NOB_ASSERT(result != NULL && "Extend the size of the temporary allocator"); // TODO: use proper arenas for the temporary allocator; va_copy(args, ap); vsnprintf(result, n + 1, format, args); va_end(args); return result; } NOBDEF char *nob_temp_sprintf(const char *format, ...) { va_list args; va_start(args, format); char *result = nob_temp_vsprintf(format, args); va_end(args); return result; } NOBDEF void nob_temp_reset(void) { nob_temp_size = 0; } NOBDEF size_t nob_temp_save(void) { return nob_temp_size; } NOBDEF void nob_temp_rewind(size_t checkpoint) { nob_temp_size = checkpoint; } NOBDEF const char *nob_temp_sv_to_cstr(Nob_String_View sv) { return nob_temp_strndup(sv.data, sv.count); } NOBDEF int nob_needs_rebuild(const char *output_path, const char **input_paths, size_t input_paths_count) { #ifdef _WIN32 BOOL bSuccess; HANDLE output_path_fd = CreateFile(output_path, GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_READONLY, NULL); if (output_path_fd == INVALID_HANDLE_VALUE) { // NOTE: if output does not exist it 100% must be rebuilt if (GetLastError() == ERROR_FILE_NOT_FOUND) return 1; nob_log(NOB_ERROR, "Could not open file %s: %s", output_path, nob_win32_error_message(GetLastError())); return -1; } FILETIME output_path_time; bSuccess = GetFileTime(output_path_fd, NULL, NULL, &output_path_time); CloseHandle(output_path_fd); if (!bSuccess) { nob_log(NOB_ERROR, "Could not get time of %s: %s", output_path, nob_win32_error_message(GetLastError())); return -1; } for (size_t i = 0; i < input_paths_count; ++i) { const char *input_path = input_paths[i]; HANDLE input_path_fd = CreateFile(input_path, GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_READONLY, NULL); if (input_path_fd == INVALID_HANDLE_VALUE) { // NOTE: non-existing input is an error cause it is needed for building in the first place nob_log(NOB_ERROR, "Could not open file %s: %s", input_path, nob_win32_error_message(GetLastError())); return -1; } FILETIME input_path_time; bSuccess = GetFileTime(input_path_fd, NULL, NULL, &input_path_time); CloseHandle(input_path_fd); if (!bSuccess) { nob_log(NOB_ERROR, "Could not get time of %s: %s", input_path, nob_win32_error_message(GetLastError())); return -1; } // NOTE: if even a single input_path is fresher than output_path that's 100% rebuild if (CompareFileTime(&input_path_time, &output_path_time) == 1) return 1; } return 0; #else struct stat statbuf = {0}; if (stat(output_path, &statbuf) < 0) { // NOTE: if output does not exist it 100% must be rebuilt if (errno == ENOENT) return 1; nob_log(NOB_ERROR, "could not stat %s: %s", output_path, strerror(errno)); return -1; } time_t output_path_time = statbuf.st_mtime; for (size_t i = 0; i < input_paths_count; ++i) { const char *input_path = input_paths[i]; if (stat(input_path, &statbuf) < 0) { // NOTE: non-existing input is an error cause it is needed for building in the first place nob_log(NOB_ERROR, "could not stat %s: %s", input_path, strerror(errno)); return -1; } time_t input_path_time = statbuf.st_mtime; // NOTE: if even a single input_path is fresher than output_path that's 100% rebuild if (input_path_time > output_path_time) return 1; } return 0; #endif } NOBDEF int nob_needs_rebuild1(const char *output_path, const char *input_path) { return nob_needs_rebuild(output_path, &input_path, 1); } NOBDEF const char *nob_path_name(const char *path) { #ifdef _WIN32 const char *p1 = strrchr(path, '/'); const char *p2 = strrchr(path, '\\'); const char *p = (p1 > p2)? p1 : p2; // NULL is ignored if the other search is successful return p ? p + 1 : path; #else const char *p = strrchr(path, '/'); return p ? p + 1 : path; #endif // _WIN32 } NOBDEF bool nob_rename(const char *old_path, const char *new_path) { #ifndef NOB_NO_ECHO nob_log(NOB_INFO, "renaming %s -> %s", old_path, new_path); #endif // NOB_NO_ECHO #ifdef _WIN32 if (!MoveFileEx(old_path, new_path, MOVEFILE_REPLACE_EXISTING)) { nob_log(NOB_ERROR, "could not rename %s to %s: %s", old_path, new_path, nob_win32_error_message(GetLastError())); return false; } #else if (rename(old_path, new_path) < 0) { nob_log(NOB_ERROR, "could not rename %s to %s: %s", old_path, new_path, strerror(errno)); return false; } #endif // _WIN32 return true; } NOBDEF bool nob_read_entire_file(const char *path, Nob_String_Builder *sb) { bool result = true; FILE *f = fopen(path, "rb"); size_t new_count = 0; long long m = 0; if (f == NULL) nob_return_defer(false); if (fseek(f, 0, SEEK_END) < 0) nob_return_defer(false); #ifndef _WIN32 m = ftell(f); #else m = _telli64(_fileno(f)); #endif if (m < 0) nob_return_defer(false); if (fseek(f, 0, SEEK_SET) < 0) nob_return_defer(false); new_count = sb->count + m; if (new_count > sb->capacity) { sb->items = NOB_DECLTYPE_CAST(sb->items)NOB_REALLOC(sb->items, new_count); NOB_ASSERT(sb->items != NULL && "Buy more RAM lool!!"); sb->capacity = new_count; } fread(sb->items + sb->count, m, 1, f); if (ferror(f)) { // TODO: Afaik, ferror does not set errno. So the error reporting in defer is not correct in this case. nob_return_defer(false); } sb->count = new_count; defer: if (!result) nob_log(NOB_ERROR, "Could not read file %s: %s", path, strerror(errno)); if (f) fclose(f); return result; } NOBDEF int nob_sb_appendf(Nob_String_Builder *sb, const char *fmt, ...) { va_list args; va_start(args, fmt); int n = vsnprintf(NULL, 0, fmt, args); va_end(args); // NOTE: the new_capacity needs to be +1 because of the null terminator. // However, further below we increase sb->count by n, not n + 1. // This is because we don't want the sb to include the null terminator. The user can always sb_append_null() if they want it nob_da_reserve(sb, sb->count + n + 1); char *dest = sb->items + sb->count; va_start(args, fmt); vsnprintf(dest, n+1, fmt, args); va_end(args); sb->count += n; return n; } NOBDEF void nob_sb_pad_align(Nob_String_Builder *sb, size_t size) { size_t rem = sb->count%size; if (rem == 0) return; for (size_t i = 0; i < size - rem; ++i) { nob_da_append(sb, 0); } } NOBDEF Nob_String_View nob_sv_chop_while(Nob_String_View *sv, int (*p)(int x)) { size_t i = 0; while (i < sv->count && p(sv->data[i])) { i += 1; } Nob_String_View result = nob_sv_from_parts(sv->data, i); sv->count -= i; sv->data += i; return result; } NOBDEF Nob_String_View nob_sv_chop_by_delim(Nob_String_View *sv, char delim) { size_t i = 0; while (i < sv->count && sv->data[i] != delim) { i += 1; } Nob_String_View result = nob_sv_from_parts(sv->data, i); if (i < sv->count) { sv->count -= i + 1; sv->data += i + 1; } else { sv->count -= i; sv->data += i; } return result; } NOBDEF bool nob_sv_chop_prefix(Nob_String_View *sv, Nob_String_View prefix) { if (nob_sv_starts_with(*sv, prefix)) { nob_sv_chop_left(sv, prefix.count); return true; } return false; } NOBDEF bool nob_sv_chop_suffix(Nob_String_View *sv, Nob_String_View suffix) { if (nob_sv_ends_with(*sv, suffix)) { nob_sv_chop_right(sv, suffix.count); return true; } return false; } NOBDEF Nob_String_View nob_sv_chop_left(Nob_String_View *sv, size_t n) { if (n > sv->count) { n = sv->count; } Nob_String_View result = nob_sv_from_parts(sv->data, n); sv->data += n; sv->count -= n; return result; } NOBDEF Nob_String_View nob_sv_chop_right(Nob_String_View *sv, size_t n) { if (n > sv->count) { n = sv->count; } Nob_String_View result = nob_sv_from_parts(sv->data + sv->count - n, n); sv->count -= n; return result; } NOBDEF Nob_String_View nob_sv_from_parts(const char *data, size_t count) { Nob_String_View sv; sv.count = count; sv.data = data; return sv; } NOBDEF Nob_String_View nob_sv_trim_left(Nob_String_View sv) { size_t i = 0; while (i < sv.count && isspace(sv.data[i])) { i += 1; } return nob_sv_from_parts(sv.data + i, sv.count - i); } NOBDEF Nob_String_View nob_sv_trim_right(Nob_String_View sv) { size_t i = 0; while (i < sv.count && isspace(sv.data[sv.count - 1 - i])) { i += 1; } return nob_sv_from_parts(sv.data, sv.count - i); } NOBDEF Nob_String_View nob_sv_trim(Nob_String_View sv) { return nob_sv_trim_right(nob_sv_trim_left(sv)); } NOBDEF Nob_String_View nob_sv_from_cstr(const char *cstr) { return nob_sv_from_parts(cstr, strlen(cstr)); } NOBDEF bool nob_sv_eq(Nob_String_View a, Nob_String_View b) { if (a.count != b.count) { return false; } else { return memcmp(a.data, b.data, a.count) == 0; } } NOBDEF bool nob_sv_end_with(Nob_String_View sv, const char *cstr) { return nob_sv_ends_with_cstr(sv, cstr); } NOBDEF bool nob_sv_ends_with_cstr(Nob_String_View sv, const char *cstr) { return nob_sv_ends_with(sv, nob_sv_from_cstr(cstr)); } NOBDEF bool nob_sv_ends_with(Nob_String_View sv, Nob_String_View suffix) { if (sv.count >= suffix.count) { Nob_String_View sv_tail = { .count = suffix.count, .data = sv.data + sv.count - suffix.count, }; return nob_sv_eq(sv_tail, suffix); } return false; } NOBDEF bool nob_sv_starts_with(Nob_String_View sv, Nob_String_View expected_prefix) { if (expected_prefix.count <= sv.count) { Nob_String_View actual_prefix = nob_sv_from_parts(sv.data, expected_prefix.count); return nob_sv_eq(expected_prefix, actual_prefix); } return false; } // RETURNS: // 0 - file does not exists // 1 - file exists NOBDEF int nob_file_exists(const char *file_path) { #if _WIN32 return GetFileAttributesA(file_path) != INVALID_FILE_ATTRIBUTES; #else return access(file_path, F_OK) == 0; #endif } NOBDEF const char *nob_get_current_dir_temp(void) { #ifdef _WIN32 DWORD nBufferLength = GetCurrentDirectory(0, NULL); if (nBufferLength == 0) { nob_log(NOB_ERROR, "could not get current directory: %s", nob_win32_error_message(GetLastError())); return NULL; } char *buffer = (char*) nob_temp_alloc(nBufferLength); if (GetCurrentDirectory(nBufferLength, buffer) == 0) { nob_log(NOB_ERROR, "could not get current directory: %s", nob_win32_error_message(GetLastError())); return NULL; } return buffer; #else char *buffer = (char*) nob_temp_alloc(PATH_MAX); if (getcwd(buffer, PATH_MAX) == NULL) { nob_log(NOB_ERROR, "could not get current directory: %s", strerror(errno)); return NULL; } return buffer; #endif // _WIN32 } NOBDEF bool nob_set_current_dir(const char *path) { #ifdef _WIN32 if (!SetCurrentDirectory(path)) { nob_log(NOB_ERROR, "could not set current directory to %s: %s", path, nob_win32_error_message(GetLastError())); return false; } return true; #else if (chdir(path) < 0) { nob_log(NOB_ERROR, "could not set current directory to %s: %s", path, strerror(errno)); return false; } return true; #endif // _WIN32 } NOBDEF char *nob_temp_dir_name(const char *path) { #ifndef _WIN32 // Stolen from the musl's implementation of dirname. // We are implementing our own one because libc vendors cannot agree on whether dirname(3) // modifies the path or not. if (!path || !*path) return nob_temp_strdup("."); size_t i = strlen(path) - 1; for (; path[i] == '/'; i--) if (!i) return nob_temp_strdup("/"); for (; path[i] != '/'; i--) if (!i) return nob_temp_strdup("."); for (; path[i] == '/'; i--) if (!i) return nob_temp_strdup("/"); return nob_temp_strndup(path, i + 1); #else if (!path) path = ""; // Treating NULL as empty. char *drive = (char*) nob_temp_alloc(_MAX_DRIVE); char *dir = (char*) nob_temp_alloc(_MAX_DIR); // https://learn.microsoft.com/en-us/previous-versions/visualstudio/visual-studio-2010/8e46eyt7(v=vs.100) errno_t ret = _splitpath_s(path, drive, _MAX_DRIVE, dir, _MAX_DIR, NULL, 0, NULL, 0); NOB_ASSERT(ret == 0); return nob_temp_sprintf("%s%s", drive, dir); #endif // _WIN32 } NOBDEF char *nob_temp_file_name(const char *path) { #ifndef _WIN32 // Stolen from the musl's implementation of dirname. // We are implementing our own one because libc vendors cannot agree on whether basename(3) // modifies the path or not. if (!path || !*path) return nob_temp_strdup("."); char *s = nob_temp_strdup(path); size_t i = strlen(s)-1; for (; i&&s[i]=='/'; i--) s[i] = 0; for (; i&&s[i-1]!='/'; i--); return s+i; #else if (!path) path = ""; // Treating NULL as empty. char *fname = (char*)nob_temp_alloc(_MAX_FNAME); char *ext = (char*)nob_temp_alloc(_MAX_EXT); // https://learn.microsoft.com/en-us/previous-versions/visualstudio/visual-studio-2010/8e46eyt7(v=vs.100) errno_t ret = _splitpath_s(path, NULL, 0, NULL, 0, fname, _MAX_FNAME, ext, _MAX_EXT); NOB_ASSERT(ret == 0); return nob_temp_sprintf("%s%s", fname, ext); #endif // _WIN32 } NOBDEF char *nob_temp_file_ext(const char *path) { #ifndef _WIN32 return strrchr(nob_temp_file_name(path), '.'); #else if (!path) path = ""; // Treating NULL as empty. char *ext = (char*)nob_temp_alloc(_MAX_EXT); // https://learn.microsoft.com/en-us/previous-versions/visualstudio/visual-studio-2010/8e46eyt7(v=vs.100) errno_t ret = _splitpath_s(path, NULL, 0, NULL, 0, NULL, 0, ext, _MAX_EXT); NOB_ASSERT(ret == 0); return ext; #endif // _WIN32 } NOBDEF char *nob_temp_running_executable_path(void) { #if defined(__linux__) char buf[4096]; int length = readlink("/proc/self/exe", buf, NOB_ARRAY_LEN(buf)); if (length < 0) return nob_temp_strdup(""); return nob_temp_strndup(buf, length); #elif defined(_WIN32) char buf[MAX_PATH]; int length = GetModuleFileNameA(NULL, buf, MAX_PATH); return nob_temp_strndup(buf, length); #elif defined(__APPLE__) char buf[4096]; uint32_t size = NOB_ARRAY_LEN(buf); if (_NSGetExecutablePath(buf, &size) != 0) return nob_temp_strdup(""); int length = strlen(buf); return nob_temp_strndup(buf, length); #elif defined(__FreeBSD__) char buf[4096]; int mib[4] = { CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, -1 }; size_t length = sizeof(buf); if (sysctl(mib, 4, buf, &length, NULL, 0) < 0) return nob_temp_strdup(""); return nob_temp_strndup(buf, length); #elif defined(__HAIKU__) int cookie = 0; image_info info; while (get_next_image_info(B_CURRENT_TEAM, &cookie, &info) == B_OK) if (info.type == B_APP_IMAGE) break; return nob_temp_strndup(info.name, strlen(info.name)); #else fprintf(stderr, "%s:%d: TODO: nob_temp_running_executable_path is not implemented for this platform\n", __FILE__, __LINE__); return nob_temp_strdup(""); #endif } #endif // NOB_IMPLEMENTATION #ifndef NOB_STRIP_PREFIX_GUARD_ #define NOB_STRIP_PREFIX_GUARD_ // NOTE: The name stripping should be part of the header so it's not accidentally included // several times. At the same time, it should be at the end of the file so to not create any // potential conflicts in the NOB_IMPLEMENTATION. The header obviously cannot be at the end // of the file because NOB_IMPLEMENTATION needs the forward declarations from there. So the // solution is to split the header into two parts where the name stripping part is at the // end of the file after the NOB_IMPLEMENTATION. #ifndef NOB_UNSTRIP_PREFIX #define TODO NOB_TODO #define UNREACHABLE NOB_UNREACHABLE #define UNUSED NOB_UNUSED #define ARRAY_LEN NOB_ARRAY_LEN #define ARRAY_GET NOB_ARRAY_GET #define INFO NOB_INFO #define WARNING NOB_WARNING #define ERROR NOB_ERROR #define NO_LOGS NOB_NO_LOGS #define Log_Level Nob_Log_Level #define minimal_log_level nob_minimal_log_level #define log_handler nob_log_handler #define Log_Handler Nob_Log_Handler #define set_log_handler nob_set_log_handler #define get_log_handler nob_get_log_handler #define null_log_handler nob_null_log_handler #define default_log_handler nob_default_log_handler #define cancer_log_handler nob_cancer_log_handler // NOTE: Name log is already defined in math.h and historically always was the natural logarithmic function. // So there should be no reason to strip the `nob_` prefix in this specific case. // #define log nob_log #define shift nob_shift #define shift_args nob_shift_args #define GO_REBUILD_URSELF NOB_GO_REBUILD_URSELF #define GO_REBUILD_URSELF_PLUS NOB_GO_REBUILD_URSELF_PLUS #define File_Paths Nob_File_Paths #define FILE_REGULAR NOB_FILE_REGULAR #define FILE_DIRECTORY NOB_FILE_DIRECTORY #define FILE_SYMLINK NOB_FILE_SYMLINK #define FILE_OTHER NOB_FILE_OTHER #define File_Type Nob_File_Type #define mkdir_if_not_exists nob_mkdir_if_not_exists #define copy_file nob_copy_file #define copy_directory_recursively nob_copy_directory_recursively #define read_entire_dir nob_read_entire_dir #define WALK_CONT NOB_WALK_CONT #define WALK_SKIP NOB_WALK_SKIP #define WALK_STOP NOB_WALK_STOP #define Walk_Action Nob_Walk_Action #define Walk_Entry Nob_Walk_Entry #define Walk_Func Nob_Walk_Func #define Walk_Dir_Opt Nob_Walk_Dir_Opt #define walk_dir nob_walk_dir #define walk_dir_opt nob_walk_dir_opt #define write_entire_file nob_write_entire_file #define get_file_type nob_get_file_type #define delete_file nob_delete_file #define Dir_Entry Nob_Dir_Entry #define dir_entry_open nob_dir_entry_open #define dir_entry_next nob_dir_entry_next #define dir_entry_close nob_dir_entry_close #define return_defer nob_return_defer #define da_append nob_da_append #define da_free nob_da_free #define da_append_many nob_da_append_many #define da_resize nob_da_resize #define da_reserve nob_da_reserve #define da_last nob_da_last #define da_first nob_da_first #define da_pop nob_da_pop #define da_remove_unordered nob_da_remove_unordered #define da_foreach nob_da_foreach #define fa_append nob_fa_append #define swap nob_swap #define String_Builder Nob_String_Builder #define read_entire_file nob_read_entire_file #define sb_appendf nob_sb_appendf #define sb_append_buf nob_sb_append_buf #define sb_append_sv nob_sb_append_sv #define sb_append_cstr nob_sb_append_cstr #define sb_append_null nob_sb_append_null #define sb_append nob_sb_append #define sb_pad_align nob_sb_pad_align #define sb_free nob_sb_free #define Proc Nob_Proc #define INVALID_PROC NOB_INVALID_PROC #define Fd Nob_Fd #define Pipe Nob_Pipe #define pipe_create nob_pipe_create #define Chain Nob_Chain #define Chain_Begin_Opt Nob_Chain_Begin_Opt #define chain_begin nob_chain_begin #define chain_begin_opt nob_chain_begin_opt #define Chain_Cmd_Opt Nob_Chain_Cmd_Opt #define chain_cmd nob_chain_cmd #define chain_cmd_opt nob_chain_cmd_opt #define Chain_End_Opt Nob_Chain_End_Opt #define chain_end nob_chain_end #define chain_end_opt nob_chain_end_opt #define INVALID_FD NOB_INVALID_FD #define fd_open_for_read nob_fd_open_for_read #define fd_open_for_write nob_fd_open_for_write #define fd_close nob_fd_close #define Procs Nob_Procs #define proc_wait nob_proc_wait #define procs_wait nob_procs_wait #define procs_wait_and_reset nob_procs_wait_and_reset #define procs_append_with_flush nob_procs_append_with_flush #define procs_flush nob_procs_flush #define CLIT NOB_CLIT #define Cmd Nob_Cmd #define Cmd_Redirect Nob_Cmd_Redirect #define Cmd_Opt Nob_Cmd_Opt #define cmd_run_opt nob_cmd_run_opt #define cmd_run nob_cmd_run #define cmd_render nob_cmd_render #define cmd_append nob_cmd_append #define cmd_extend nob_cmd_extend #define cmd_free nob_cmd_free #define cmd_run_async nob_cmd_run_async #define cmd_run_async_and_reset nob_cmd_run_async_and_reset #define cmd_run_async_redirect nob_cmd_run_async_redirect #define cmd_run_async_redirect_and_reset nob_cmd_run_async_redirect_and_reset #define cmd_run_sync nob_cmd_run_sync #define cmd_run_sync_and_reset nob_cmd_run_sync_and_reset #define cmd_run_sync_redirect nob_cmd_run_sync_redirect #define cmd_run_sync_redirect_and_reset nob_cmd_run_sync_redirect_and_reset #define temp_strdup nob_temp_strdup #define temp_strndup nob_temp_strndup #define temp_alloc nob_temp_alloc #define temp_sprintf nob_temp_sprintf #define temp_vsprintf nob_temp_vsprintf #define temp_reset nob_temp_reset #define temp_save nob_temp_save #define temp_rewind nob_temp_rewind #define path_name nob_path_name // NOTE: rename(2) is widely known POSIX function. We never wanna collide with it. // #define rename nob_rename #define needs_rebuild nob_needs_rebuild #define needs_rebuild1 nob_needs_rebuild1 #define file_exists nob_file_exists #define get_current_dir_temp nob_get_current_dir_temp #define set_current_dir nob_set_current_dir #define temp_dir_name nob_temp_dir_name #define temp_file_name nob_temp_file_name #define temp_file_ext nob_temp_file_ext #define temp_running_executable_path nob_temp_running_executable_path #define String_View Nob_String_View #define temp_sv_to_cstr nob_temp_sv_to_cstr #define sv_chop_by_delim nob_sv_chop_by_delim #define sv_chop_while nob_sv_chop_while #define sv_chop_prefix nob_sv_chop_prefix #define sv_chop_suffix nob_sv_chop_suffix #define sv_chop_left nob_sv_chop_left #define sv_chop_right nob_sv_chop_right #define sv_trim nob_sv_trim #define sv_trim_left nob_sv_trim_left #define sv_trim_right nob_sv_trim_right #define sv_eq nob_sv_eq #define sv_starts_with nob_sv_starts_with #define sv_end_with nob_sv_end_with #define sv_ends_with nob_sv_ends_with #define sv_ends_with_cstr nob_sv_ends_with_cstr #define sv_from_cstr nob_sv_from_cstr #define sv_from_parts nob_sv_from_parts #define sb_to_sv nob_sb_to_sv #define win32_error_message nob_win32_error_message #define nprocs nob_nprocs #define nanos_since_unspecified_epoch nob_nanos_since_unspecified_epoch #define NANOS_PER_SEC NOB_NANOS_PER_SEC #endif // NOB_STRIP_PREFIX #endif // NOB_STRIP_PREFIX_GUARD_ /* Revision history: 3.8.2 (2026-04-01) Fix the broken type safety of nob_cmd_append() (by @aalmkainzi) 3.8.1 (2026-04-01) Fix annoying clang warning 3.8.0 (2026-03-24) Add NOB_CLIT() Fix compliation on MSVC with /TP 3.7.0 (2026-03-20) Add nob_sb_append_sv() 3.6.0 (2026-03-16) Add nob_sv_chop_suffix() Deprecate nob_sv_end_with() Add nob_sv_ends_with_cstr() instead of nob_sv_end_with() Add nob_sv_ends_with() Add nob_sv_chop_right() 3.5.0 (2026-03-13) Add nob_null_log_handler() (by @rexim) Rename nob_log_handler to Nob_Log_Handler (by @rexim) 3.4.0 (2026-03-12) Add nob_da_first() (by @rexim) Add nob_da_pop() (by @rexim) Add nob_sv_chop_while() (by @rexim) 3.3.0 (2026-03-07) Add nob_sv_chop_prefix() (by @rexim) 3.2.2 (2026-02-06) Fix read_entire_dir crash on empty path (by @ysoftware) 3.2.1 (2026-01-29) Fix the implicit declaration error when nob is included as a header (by @ysoftware) 3.2.0 (2026-01-28) Introduce Chain API - Nob_Chain - Nob_Chain_Begin_Opt - nob_chain_begin() - nob_chain_begin_opt() - Nob_Chain_Cmd_Opt - nob_chain_cmd() - nob_chain_cmd_opt() - Nob_Chain_End_Opt - nob_chain_end() - nob_chain_end_opt() Introduce some auxiliary things that were used in Chain API implementation, but might be useful outside of it: - Nob_Pipe - nob_pipe_create() - nob_fa_append() 3.1.0 (2026-01-22) Make nob_delete_file() be able to delete empty dir on Windows (by @rexim) Introduce Directory Entry API - similar to POSIX dirent but with names that don't collide - Nob_Dir_Entry - nob_dir_entry_open() - nob_dir_entry_next() - nob_dir_entry_close() Rewrite Directory Walking API using Directory Entry API Introduce .post_order parameter to Nob_Walk_Dir_Opt which walks the directories in post order starting from leaf files Rewrite nob_read_entire_dir() using Directory Entry API 3.0.0 (2026-01-13) Improve C++ support (by @rexim) - Fix various C++ compilers warnings and complains throughout the code. - Reimplement nob_cmd_append() without taking a pointer to temporary array (some C++ compilers don't like that) - Make default NOB_REBUILD_URSELF() try to recompile with C++ if __cplusplus macro is defined Strip prefixes by default (by @rexim) - Ignore NOB_STRIP_PREFIX macro - Introduce NOB_UNSTRIP_PREFIX macro BACKWARD INCOMPATIBLE CHANGE!!! If you had code that intentionally didn't enable NOB_STRIP_PREFIX because all the names from nob.h were causing too many collisions for you, upgrading to 3.0.0 may break it. In that case you should go and explicitly enable NOB_UNSTRIP_PREFIX where needed after upgrading. Add nob_sb_append alias to nob_da_append (by @rexim) 2.0.1 (2026-01-07) Fix Walk_Entry naming (by @Sinha-Ujjawal) Using single String Builder in nob__walk_dir_opt_impl (by @Sinha-Ujjawal) Add tcc to nob_cc_*() and NOB_REBUILD_URSELF() macros (by @vylsaz) Fix building nob_read_entire_file() with tcc on windows (by @vylsaz) Fix Y2038 in nob_needs_rebuild() (by @lnvitesace) 2.0.0 (2026-01-06) Remove minirent.h (by @rexim) BACKWARD INCOMPATIBLE CHANGE!!! If you were using minirent.h from this library just use it directly from https://github.com/tsoding/minirent or consider using the New Directory Walking API. Introduce New Directory Walking API (by @rexim) - NOB_WALK_CONT - NOB_WALK_SKIP - NOB_WALK_STOP - Nob_Walk_Action - Nob_Walk_Entry - Nob_Walk_Func - Nob_Walk_Dir_Opt - nob_walk_dir() - nob_walk_dir_opt() Add support for Haiku to nob_temp_running_executable_path() (By @Cephon) Make nob_file_exists() unfailable (By @rexim) 1.27.0 (2025-12-30) Add .dont_reset option to cmd_run (by @Israel77) Fix support for FreeBSD (by @cqundefine) Strip prefixes from NOB_GO_REBUILD_URSELF and NOB_GO_REBUILD_URSELF_PLUS (by @huwwa) Add /Fo flag to MSVC version of nob_cc_output() (by @ratchetfreak) 1.26.0 (2025-12-28) Introduce customizable log handlers (by @rexim) - Add nob_log_handler - Add nob_set_log_handler - Add nob_get_log_handler - Add nob_default_log_handler - Add nob_cancer_log_handler Introduce nob_temp_vsprintf (by @rexim) Fix compilation error on Windows when NOB_NO_ECHO is enabled (by @mlorenc227) Do not redefine _CRT_SECURE_NO_WARNINGS if it's already defined (by @vylsaz) 1.25.1 (2025-11-06) Fix forward declaration of _NSGetExecutablePath on MacOS (by @agss0) 1.25.0 (2025-10-25) - Add nob_sb_pad_align() - Add nob_swap() - Add nob_temp_strndup() - Add nob_temp_dir_name() - Add nob_temp_file_name() - Add nob_temp_file_ext() - Add nob_temp_running_executable_path() 1.24.0 (2025-10-23) Introduce NOB_NO_ECHO macro flag (@rexim) 1.23.0 (2025-08-22) Introduce new API for running commands (by @rexim, @programmerlexi, @0x152a) - Add nob_cmd_run() - Add nob_cmd_run_opt() - Add struct Nob_Cmd_Opt - Add nob_procs_flush() - Add nob_nprocs() Deprecate old API for running commands. (by @rexim) We do not plan to delete this API any time, but we believe that the new one is more convenient. - Deprecate struct Nob_Cmd_Redirect{} (it's not explicitly marked with NOB_DEPRECATED, but functions that use it are) - Turn nob_cmd_run_async() into a function (otherwise it's not deprecatable with NOB_DEPRECATED) - Deprecate nob_cmd_run_async() - Deprecate nob_cmd_run_async_and_reset() - Deprecate nob_cmd_run_async_redirect() - Deprecate nob_cmd_run_async_redirect_and_reset() - Deprecate nob_cmd_run_sync() - Deprecate nob_cmd_run_sync_and_reset() - Deprecate nob_cmd_run_sync_redirect() - Deprecate nob_cmd_run_sync_redirect_and_reset() - Deprecate nob_procs_append_with_flush() - Deprecate nob_procs_wait_and_reset() Introduce deprecation mechanism (by @yuI4140, @rexim) By default, deprecation warnings are not reported. You have to #define NOB_WARN_DEPRECATED to enable them. - Add NOB_DEPRECATED() - Add NOB_WARN_DEPRECATED Add NOB_DECLTYPE_CAST() for C++-compatible casting of allocation results (by @rexim) Introduce basic performance measuring mechanism (By @mikmart) - Add nob_nanos_since_unspecified_epoch() - Add NOB_NANOS_PER_SEC 1.22.0 (2025-08-12) Add NOBDEF macro to the beginning of function declarations (by @minefreak19) Add more flags to MSVC nob_cc_flags() (by @PieVieRo) 1.21.0 (2025-08-11) Add NOB_NO_MINIRENT guard for "minirent.h" (by @fietec) 1.20.9 (2025-08-11) Fix warnings on Windows: Define _CRT_SECURE_NO_WARNINGS, Rename mkdir to _mkdir (by @OetkenPurveyorOfCode) 1.20.8 (2025-08-11) Fix the bug with nob_get_file_type() not identifying symlinks correctly on POSIX (By @samuellieberman) 1.20.7 (2025-07-29) Align nob_temp_alloc() allocations by the word size (By @rexim) 1.20.6 (2025-05-16) Never strip nob_* suffix from nob_rename (By @rexim) 1.20.5 (2025-05-16) NOB_PRINTF_FORMAT() support for MinGW (By @KillerxDBr) 1.20.4 (2025-05-16) More reliable rendering of the Windows command (By @vylsaz) 1.20.3 (2025-05-16) Add check for __clang__ along with _MSC_VER checks (By @nashiora) 1.20.2 (2025-04-24) Report the program name that failed to start up in nob_cmd_run_async_redirect() (By @rexim) 1.20.1 (2025-04-16) Use vsnprintf() in nob_sb_appendf() instead of vsprintf() (By @LainLayer) 1.20.0 (2025-04-16) Introduce nob_cc(), nob_cc_flags(), nob_cc_inputs(), nob_cc_output() macros (By @rexim) 1.19.0 (2025-03-25) Add nob_procs_append_with_flush() (By @rexim and @anion155) 1.18.0 (2025-03-24) Add nob_da_foreach() (By @rexim) Allow file sizes greater than 2GB to be read on windows (By @satchelfrost and @KillerxDBr) Fix nob_fd_open_for_write behaviour on windows so it truncates the opened files (By @twixuss) 1.17.0 (2025-03-16) Factor out nob_da_reserve() (By @rexim) Add nob_sb_appendf() (By @angelcaru) 1.16.1 (2025-03-16) Make nob_da_resize() exponentially grow capacity similar to no_da_append_many() 1.16.0 (2025-03-16) Introduce NOB_PRINTF_FORMAT 1.15.1 (2025-03-16) Make nob.h compilable in gcc/clang with -std=c99 on POSIX. This includes: not using strsignal() using S_IS* stat macros instead of S_IF* flags 1.15.0 (2025-03-03) Add nob_sv_chop_left() 1.14.1 (2025-03-02) Add NOB_EXPERIMENTAL_DELETE_OLD flag that enables deletion of nob.old in Go Rebuild Urself™ Technology 1.14.0 (2025-02-17) Add nob_da_last() Add nob_da_remove_unordered() 1.13.1 (2025-02-17) Fix segfault in nob_delete_file() (By @SileNce5k) 1.13.0 (2025-02-11) Add nob_da_resize() (By @satchelfrost) 1.12.0 (2025-02-04) Add nob_delete_file() Add nob_sv_start_with() 1.11.0 (2025-02-04) Add NOB_GO_REBUILD_URSELF_PLUS() (By @rexim) 1.10.0 (2025-02-04) Make NOB_ASSERT, NOB_REALLOC, and NOB_FREE redefinable (By @OleksiiBulba) 1.9.1 (2025-02-04) Fix signature of nob_get_current_dir_temp() (By @julianstoerig) 1.9.0 (2024-11-06) Add Nob_Cmd_Redirect mechanism (By @rexim) Add nob_path_name() (By @0dminnimda) 1.8.0 (2024-11-03) Add nob_cmd_extend() (By @0dminnimda) 1.7.0 (2024-11-03) Add nob_win32_error_message and NOB_WIN32_ERR_MSG_SIZE (By @KillerxDBr) 1.6.0 (2024-10-27) Add nob_cmd_run_sync_and_reset() Add nob_sb_to_sv() Add nob_procs_wait_and_reset() 1.5.1 (2024-10-25) Include limits.h for Linux musl libc (by @pgalkin) 1.5.0 (2024-10-23) Add nob_get_current_dir_temp() Add nob_set_current_dir() 1.4.0 (2024-10-21) Fix UX issues with NOB_GO_REBUILD_URSELF on Windows when you call nob without the .exe extension (By @pgalkin) Add nob_sv_end_with (By @pgalkin) 1.3.2 (2024-10-21) Fix unreachable error in nob_log on passing NOB_NO_LOGS 1.3.1 (2024-10-21) Fix redeclaration error for minimal_log_level (By @KillerxDBr) 1.3.0 (2024-10-17) Add NOB_UNREACHABLE 1.2.2 (2024-10-16) Fix compilation of nob_cmd_run_sync_and_reset on Windows (By @KillerxDBr) 1.2.1 (2024-10-16) Add a separate include guard for NOB_STRIP_PREFIX. 1.2.0 (2024-10-15) Make NOB_DA_INIT_CAP redefinable Add NOB_STRIP_PREFIX which strips off nob_* prefix from all the user facing names Add NOB_UNUSED macro Add NOB_TODO macro Add nob_sv_trim_left and nob_sv_trim_right declarations to the header part 1.1.1 (2024-10-15) Remove forward declaration for is_path1_modified_after_path2 1.1.0 (2024-10-15) nob_minimal_log_level nob_cmd_run_sync_and_reset 1.0.0 (2024-10-15) first release based on https://github.com/tsoding/musializer/blob/4ac7cce9874bc19e02d8c160c8c6229de8919401/nob.h */ /* Version Conventions: We are following https://semver.org/ so the version has a format MAJOR.MINOR.PATCH: - Modifying comments does not update the version. - PATCH is incremented in case of a bug fix or refactoring without touching the API. - MINOR is incremented when new functions and/or types are added in a way that does not break any existing user code. We want to do this in the majority of the situation. If we want to delete a certain function or type in favor of another one we should just add the new function/type and deprecate the old one in a backward compatible way and let them co-exist for a while. - MAJOR update should be just a periodic cleanup of the DEPRECATED functions and types without really modifying any existing functionality. - Breaking backward compatibility in a MINOR release should be considered a bug and should be promptly fixed in the next PATCH release. API conventions: - All the user facing names should be prefixed with `nob_`, `NOB_`, or `Nob_` depending on the case. - The prefixes of non-redefinable names should be stripped in NOB_STRIP_PREFIX_GUARD_ section, unless explicitly stated otherwise like in case of nob_log() or nob_rename(). - Internal (private) names should be prefixed with `nob__` (double underscore). The user code is discouraged from using such names since they are allowed to be broken in a backward incompatible way even in PATCH releases. (This is why they are internal) - If a public macro uses an private function internally such function must be forward declared in the NOB_H_ section. */ /* ------------------------------------------------------------------------------ This software is available under 2 licenses -- choose whichever you prefer. ------------------------------------------------------------------------------ ALTERNATIVE A - MIT License Copyright (c) 2024 Alexey Kutepov 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. ------------------------------------------------------------------------------ ALTERNATIVE B - Public Domain (www.unlicense.org) This is free and unencumbered software released into the public domain. Anyone is free to copy, modify, publish, use, compile, sell, or distribute this software, either in source code form or as a compiled binary, for any purpose, commercial or non-commercial, and by any means. In jurisdictions that recognize copyright laws, the author or authors of this software dedicate any and all copyright interest in the software to the public domain. We make this dedication for the benefit of the public at large and to the detriment of our heirs and successors. We intend this dedication to be an overt act of relinquishment in perpetuity of all present and future rights to this software under copyright law. 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 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. ------------------------------------------------------------------------------ */ ================================================ FILE: src/common.h ================================================ #pragma once #include #include typedef int8_t s8; typedef int16_t s16; typedef int32_t s32; typedef int64_t s64; typedef uint8_t u8; typedef uint16_t u16; typedef uint32_t u32; typedef uint64_t u64; typedef float f32; typedef double f64; typedef unsigned char uchar; typedef size_t size32; #define NO_ARG_STR "" #ifndef NULL #define NULL ((void*)0) #endif #define NOT_IMPLEMENTED() fprintf(stderr, "Not implemented at %s (%d)", __FILE__, __LINE__) #define NOT_USED(expr) do { (void)(expr); } while (0) #define arrayInit(type, ...) ((type[]){__VA_ARGS__}) #define arrayArg(type, ...) arrayInit(type, __VA_ARGS__) #define arrayLength(arr) (sizeof(arr) / sizeof((arr)[0])) #define chance(p) ((rand() % 100) < p) #define chancef01(p) ((rand() / RAND_MAX) < p) #define randomi(a, b) ((a) + (rand() % ((b) - (a)))) #define randomf(a, b) ((a) + ((f32)rand() / RAND_MAX) * ((b) - (a))) #define inRange(x, a, b) ((x) >= (a) && (x) < (b)) ================================================ FILE: src/war.h ================================================ #pragma once #include #include #include "war_color.h" #include "war_math.h" #include "war_fwd.h" #define FRAMES_PER_SECONDS 60 #define SECONDS_PER_FRAME (1.0f/FRAMES_PER_SECONDS) #define MOVE_EPSILON 0.5f #define MOVE_WAIT_INTENTS 2 #define MOVE_WAIT_TIME 1.0f #define MAP_EDGE_SCROLL_GAP 5.0f #define NEAR_ENEMY_RADIUS 5 #define NEAR_CATAPULT_RADIUS 2 #define NEAR_RAIN_OF_FIRE_RADIUS 1 #define RAIN_OF_FIRE_PROJECTILE_DAMAGE 10 #define POISON_CLOUD_DAMAGE 10 #define PLAYBACK_FREQ 44100 #define FOG_OF_WAR_UPDATE_TIME 1.0f // #define DEBUG_RENDER_MAP_GRID // #define DEBUG_RENDER_PASSABLE_INFO // #define DEBUG_RENDER_UNIT_PATHS // #define DEBUG_RENDER_UNIT_INFO // #define DEBUG_RENDER_UNIT_ANIMATIONS // #define DEBUG_RENDER_MAP_ANIMATIONS // #define DEBUG_RENDER_FONT // #define DEBUG_RENDER_PROJECTILES #define DATAWAR_FILE_PATH "./DATA.WAR" #define ONLINE_DEMO_DATAWAR_FILE_URL "http://ia801608.us.archive.org/view_archive.php?archive=/11/items/WarcraftOrcsHumansDemo/WCRFT.ZIP&file=DEMODATA%2FDATA.WAR" // Counts #define MAX_RESOURCES_COUNT 583 #define MAX_TEXTURES_COUNT 583 #define MAX_ENTITIES_COUNT 1024 #define MAX_COMPONENTS_COUNT 30 #define INVALID_COMP_INDEX 0 #define MAX_SPRITE_FRAME_COUNT 100 #define MAX_CONSTRUCTS_COUNT 100 #define MAX_CUSTOM_MAP_GOLDMINES_COUNT 10 #define MAX_CUSTOM_MAP_CONFIGURATIONS_COUNT 10 #define MAX_CUSTOM_MAP_ENTITIES_COUNT 100 // all palettes have 768 colors #define PALETTE_LENGTH 768 // size of mini-tiles from the tiles resources #define MINI_TILE_WIDTH 8 #define MINI_TILE_HEIGHT 8 // size of the mega-tiles (2x2 mini-tiles) from the tileset #define MEGA_TILE_WIDTH (MINI_TILE_WIDTH*2) #define MEGA_TILE_HEIGHT (MINI_TILE_HEIGHT*2) // size of the map in pixels #define MAP_WIDTH (64*MEGA_TILE_WIDTH) #define MAP_HEIGHT (64*MEGA_TILE_HEIGHT) // size of the map in tiles #define MAP_TILES_WIDTH (MAP_WIDTH/MEGA_TILE_WIDTH) #define MAP_TILES_HEIGHT (MAP_HEIGHT/MEGA_TILE_HEIGHT) // size of the viewport of the map in pixels #define MAP_VIEWPORT_WIDTH 240 #define MAP_VIEWPORT_HEIGHT 176 // size of the minimap in pixels #define MINIMAP_WIDTH 64 #define MINIMAP_HEIGHT 64 // ratio of the minimap and map sizes #define MINIMAP_MAP_WIDTH_RATIO ((f32)MINIMAP_WIDTH/MAP_WIDTH) #define MINIMAP_MAP_HEIGHT_RATIO ((f32)MINIMAP_HEIGHT/MAP_HEIGHT) // size of the viewport of the minimap in pixels #define MINIMAP_VIEWPORT_WIDTH (MAP_VIEWPORT_WIDTH*MINIMAP_MAP_WIDTH_RATIO) #define MINIMAP_VIEWPORT_HEIGHT (MAP_VIEWPORT_HEIGHT*MINIMAP_MAP_HEIGHT_RATIO) // size of the tileset for the terrain of the maps #define TILESET_WIDTH 512 #define TILESET_HEIGHT 256 #define TILESET_TILES_PER_ROW (TILESET_WIDTH/MEGA_TILE_WIDTH) #define MAX_OBJECTIVES_LENGTH 512 #define MAX_PLAYERS_COUNT 5 #define MAX_FEATURES_COUNT 22 #define MAX_UPGRADES_COUNT 10 #define MAX_TILES_COUNT 1024 // Game constants used across multiple modules #define TREE_MAX_WOOD 100 #define GOLDMINE_MAX_GOLD 300 #define UNIT_MAX_CARRY_WOOD 100 #define UNIT_MAX_CARRY_GOLD 100 // Maximum number of samples the audio mix buffer can hold. // Sized to cover any SDL3 audio device buffer at PLAYBACK_FREQ. #define AUDIO_MIX_BUFFER_MAX_SAMPLES 8192u // Maximum entity removals that the audio callback can queue per callback invocation. #define AUDIO_REMOVE_PENDING_MAX 64 #define MAX_RENDER_STATE_STACK 32 #define isRetail(context) ((context)->warFile->type == WAR_FILE_TYPE_RETAIL) #define isDemo(context) ((context)->warFile->type == WAR_FILE_TYPE_DEMO) #define isButtonHeld(input, btn) ((input)->buttons[btn].held) #define isButtonJustPressed(input, btn) ((input)->buttons[btn].justPressed) #define isButtonJustReleased(input, btn) ((input)->buttons[btn].justReleased) #define isKeyHeld(input, key) ((input)->keys[key].held) #define isKeyJustPressed(input, key) ((input)->keys[key].justPressed) #define isKeyJustReleased(input, key) ((input)->keys[key].justReleased) #define isMapDragging(input) ((input)->mapDragActive) #define getScaledSpeed(context, t) ((t) * (context)->globalSpeed) #define getScaledTime(context, t) ((t) / (context)->globalSpeed) struct _WarInputState { bool held; bool justPressed; bool justReleased; }; struct _WarInput { // current mouse position vec2 pos; // state of the mouse buttons WarInputState buttons[WAR_MOUSE_COUNT]; // state of the keys WarInputState keys[WAR_KEY_COUNT]; // button currently owning the mouse press WarEntityId capturedUIButtonId; // map selection drag that started inside mapPanel bool mapDragActive; vec2 mapDragStartPos; rect mapDragRect; }; struct _WarRenderState { f32 offsetX, offsetY; f32 scaleX, scaleY; f32 alpha; }; #include "war_sprites.h" #define IMUI_SPRITE_CACHE_SIZE 64 #define IMUI_TOOLTIP_TEXT_MAX 256 struct _WarImuiSpriteEntry { s32 resourceIndex; s32 frameIndex; s32 lastUsedFrame; // for LRU eviction WarSprite sprite; }; struct _WarImuiState { u32 active_item; u32 hot_item; bool is_mouse_over_ui; // Cursor: set by wui_changeCursorType each update, rendered in imui_end(). // Reset to WAR_CURSOR_ARROW at the start of every imui_begin(). WarCursorType cursor_type; // Hotkey suppression: set to false before retained-button updates when // the cheat panel is visible so buttons don't fire via keyboard shortcuts. // Reset to true at the start of every imui_begin(). bool hotkeys_enabled; // Tooltip deferral: set during a button call, drawn in imui_end() bool show_tooltip; char tooltip_text[IMUI_TOOLTIP_TEXT_MAX]; s32 tooltip_highlight_index; s32 tooltip_highlight_count; s32 tooltip_gold; s32 tooltip_wood; // Sprite cache: sprites are loaded on first use and reused across frames. // Keyed by (resourceIndex, frameIndex) — each unique pair has its own // SDL_Texture pre-loaded with the correct frame's pixel data. WarImuiSpriteEntry spriteCache[IMUI_SPRITE_CACHE_SIZE]; s32 spriteCacheCount; }; struct _WarContext { f32 time; f32 deltaTime; f32 waitTime; u32 fps; u32 frameCount; bool paused; f32 globalScale; f32 globalSpeed; s32 originalWindowWidth; s32 originalWindowHeight; s32 windowWidth; s32 windowHeight; String windowTitle; SDL_Window* window; SDL_Renderer* renderer; // render state stack for save/restore/translate/scale/alpha WarRenderState renderState[MAX_RENDER_STATE_STACK]; s32 renderStateTop; WarFile* warFile; WarResource* resources[MAX_RESOURCES_COUNT]; WarSprite fontSprites[2]; SDL_AudioStream* audioStream; tsf* soundFont; // this is shortcut to disable all audios in the map // to avoid crashes when freeing the map and the audio thread // trying to reproduce audios bool audioEnabled; bool musicEnabled; bool soundEnabled; f32 musicVolume; f32 soundVolume; // Pre-allocated mix buffer owned exclusively by the audio callback. // Allocated on the main thread before audio starts so that the audio // callback thread never calls wm_calloc / war_free, which would race // with main-thread allocations on globalZone. s16* audioMixBuffer; u32 audioMixBufferCapacity; // capacity in samples // Pending audio-entity removals queued by the audio callback thread. // The callback posts finished entity IDs here (under audioRemoveMutex) // instead of calling we_removeEntityById directly. The main thread drains // this queue at the top of each wg_updateGame tick. SDL_Mutex* audioRemoveMutex; WarEntityId audioRemovePending[AUDIO_REMOVE_PENDING_MAX]; s32 audioRemovePendingCount; bool cheatsEnabled; // this is a mutex used to make the deletion of the entities thread-safe // since the audio thread will delete audio entities, that could lead // to inconsistent states in the internal lists when the game try to also // delete other entities. SDL_Mutex* __mutex; WarInput input; f32 transitionDelay; WarScene* scene; WarScene* nextScene; WarMap* map; WarMap* nextMap; WarImuiState imui; }; void wg_setGlobalScale(WarContext* context, f32 scale); void wg_changeGlobalScale(WarContext* context, f32 deltaScale); void wg_setGlobalSpeed(WarContext* context, f32 speed); void wg_changeGlobalSpeed(WarContext* context, f32 deltaSpeed); void wg_setMusicVolume(WarContext* context, f32 volume); void wg_changeMusicVolume(WarContext* context, f32 deltaVolume); void wg_setSoundVolume(WarContext* context, f32 volume); void wg_changeSoundVolume(WarContext* context, f32 deltaVolume); void wg_setNextScene(WarContext* context, WarScene* scene, f32 transitionDelay); void wg_setNextMap(WarContext* context, WarMap* map, f32 transitionDelay); bool wg_loadDataFile(WarContext* context); #include "war_map.h" #include "war_scenes.h" ================================================ FILE: src/war1.c ================================================ #ifdef _MSC_VER #define _CRT_SECURE_NO_WARNINGS #endif #define _DEFAULT_SOURCE #include #include #include #include #include #include #include #include #if defined(_MSC_VER) && !defined(__clang__) #include #ifndef F_OK #define F_OK 0 #endif #define access _access #else #include #endif #include #if defined(_WIN32) && defined(_MSC_VER) && !defined(__clang__) #define WIN32_LEAN_AND_MEAN #include #define strcasecmp _stricmp #define strncasecmp _strnicmp #endif // #define NDEBUG // define this to deactivate assertions #include #include "SDL3/SDL.h" // Tracy profiler C API — all macros are no-ops unless TRACY_ENABLE is defined #include "TracyC.h" #define SHL_MZ_IMPLEMENTATION #ifdef SHL_MZ_DEBUG # define SHL_MZ_AUDIT_IMPLEMENTATION # include "shl/memzone_audit.h" #else # include "shl/memzone.h" #endif #include "war_alloc.h" // https://github.com/schellingb/TinySoundFont #define TSF_MALLOC(sz) wm_allocAudio(sz) #define TSF_REALLOC(p,sz) wm_reallocAudio((p),(sz)) #define TSF_FREE(p) wm_free(p) #define TSF_IMPLEMENTATION #include "TinySoundFont/tsf.h" #define TML_MALLOC(sz) wm_allocAudio(sz) #define TML_REALLOC(p,sz) wm_reallocAudio((p),(sz)) #define TML_FREE(p) wm_free(p) #define TML_ERROR(msg) printf("ERROR: %s\n", msg) #define TML_WARN(msg) printf("WARNING: %s\n", msg) #define TML_IMPLEMENTATION #include "TinySoundFont/tml.h" #define STBI_MALLOC(sz) wm_alloc(sz) #define STBI_REALLOC(p,newsz) wm_realloc(p,newsz) #define STBI_FREE(p) wm_free(p) #define STB_IMAGE_IMPLEMENTATION #include "stb/stb_image.h" #define STBIW_MALLOC(sz) wm_alloc(sz) #define STBIW_REALLOC(p,newsz) wm_realloc(p,newsz) #define STBIW_FREE(p) wm_free(p) #define STB_IMAGE_WRITE_IMPLEMENTATION #include "stb/stb_image_write.h" #define STBIR_MALLOC(sz,c) ((void)(c), wm_alloc(sz)) #define STBIR_FREE(p,c) ((void)(c), wm_free(p)) #define STB_IMAGE_RESIZE_IMPLEMENTATION #include "stb/stb_image_resize.h" #define SHL_MALLOC(sz) wm_alloc(sz) #define SHL_CALLOC(n, sz) wm_alloc((n) * (sz)) #define SHL_REALLOC(p, sz) wm_realloc((p), (sz)) #define SHL_FREE(p) wm_free(p) #include "shl/list.h" #include "shl/queue.h" #include "shl/binary_heap.h" #include "shl/map.h" #include "shl/set.h" #define SHL_MEMORY_BUFFER_IMPLEMENTATION #define MB_MALLOC(sz) wm_alloc(sz) #define MB_CALLOC(n, sz) wm_alloc((n) * (sz)) #define MB_FREE(p) wm_free(p) #include "shl/memory_buffer.h" #define SHL_WAV_IMPLEMENTATION #include "shl/wav.h" #define WSTR_MALLOC(sz) wm_alloc(sz) #define WSTR_REALLOC(p, sz) wm_realloc((p), (sz)) #define WSTR_FREE(p) wm_free(p) #define SHL_WSTR_IMPLEMENTATION #include "shl/wstr.h" #include "war_log.h" #include "war.h" #include "war_game.h" #define PERM_SIZE (536870912ULL) // 512 MB #define FRAME_SIZE (4194304ULL) // 4 MB #define AUDIO_SIZE (33554432ULL) // 32 MB int main(void) { if (!wm_allocInit(PERM_SIZE, FRAME_SIZE, AUDIO_SIZE)) { logError("Failed to initialize memory allocators!"); return -1; } srand((unsigned int)time(NULL)); SDL_SetLogPriorities(SDL_LOG_PRIORITY_DEBUG); if (!SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO)) { logError("Error initializing SDL: %s", SDL_GetError()); wm_allocFree(); return -1; } WarContext* context = (WarContext*)wm_alloc(sizeof(WarContext)); if (!context) { logError("Failed to allocate WarContext!"); wm_allocFree(); SDL_Quit(); return -1; } if (!wg_initGame(context)) { logError("Can't initialize the game!"); wm_allocFree(); SDL_Quit(); return -1; } bool running = true; s32 cachedFps = 0; f32 cachedDeltaTime = 0; f32 cachedWaitTime = 0; f32 lastFpsUpdateTime = 0; while (running) { wg_beginInputFrame(context); SDL_Event event; while (SDL_PollEvent(&event)) { wg_processGameEvent(context, &event); if (event.type == SDL_EVENT_QUIT) { running = false; } } // Update window title with FPS and timing info, // but only once per second to have more stable numbers. if (context->time - lastFpsUpdateTime >= 1.0f) { cachedFps = context->fps; cachedDeltaTime = context->deltaTime; cachedWaitTime = context->waitTime; lastFpsUpdateTime = context->time; } wstr_setFormat( &context->windowTitle, "War 1: %.2fs at %d fps (%.4fs) - Wait time: %.4fs - Frames: %u", context->time, cachedFps, cachedDeltaTime, cachedWaitTime, context->frameCount ); SDL_SetWindowTitle(context->window, wstr_cstr(&context->windowTitle)); wg_updateGame(context); wg_renderGame(context); wg_presentGame(context); TracyCFrameMark context->frameCount++; } wg_quitGame(context); wm_allocFree(); return 0; } #include "war_log.c" #include "war_alloc.c" #include "war_math.c" #include "war_file.c" #include "war_audio.c" #include "war_net.c" #include "war_actions.c" #include "war_render.c" #include "war_resources.c" #include "war_sprites.c" #include "war_font.c" #include "war_animations.c" #include "war_roads.c" #include "war_walls.c" #include "war_ruins.c" #include "war_trees.c" #include "war_commands.c" #include "war_units.c" #include "war_projectiles.c" #include "war_entities.c" #include "war_pathfinder.c" #include "war_state_machine_idle.c" #include "war_state_machine_move.c" #include "war_state_machine_follow.c" #include "war_state_machine_patrol.c" #include "war_state_machine_attack.c" #include "war_state_machine_death.c" #include "war_state_machine_collapse.c" #include "war_state_machine_wait.c" #include "war_state_machine_gather_gold.c" #include "war_state_machine_mining.c" #include "war_state_machine_gather_wood.c" #include "war_state_machine_chopping.c" #include "war_state_machine_deliver.c" #include "war_state_machine_train.c" #include "war_state_machine_upgrade.c" #include "war_state_machine_build.c" #include "war_state_machine_repair.c" #include "war_state_machine_repairing.c" #include "war_state_machine_cast.c" #include "war_state_machine.c" #include "war_campaigns.c" #include "war_cheats.c" #include "war_map_menu.c" #include "war_map_ui.c" #include "war_map.c" #include "war_cheats_panel.c" #include "war_scene_download.c" #include "war_scene_blizzard.c" #include "war_scene_menu.c" #include "war_scene_briefing.c" #include "war_scenes.c" #include "war_ui.c" #include "war_imui.c" #include "war_ai.c" #include "war_game.c" ================================================ FILE: src/war_actions.c ================================================ #include "war_actions.h" #include #include #include "war.h" #include "war_units.h" #define __frameCountToSeconds(f) ((f32)(f)/FRAMES_PER_SECONDS) static WarUnitActionDef gUnitActionDefs[WAR_UNIT_COUNT][WAR_ACTION_TYPE_COUNT]; typedef struct { s32 walkFramesCount; s32 walkFrames[5]; s32 attackFramesCount; s32 attackFrames[5]; s32 deathFramesCount; s32 deathFrames[5]; } WarUnitFrameNumbers; static WarUnitFrameNumbers wact_getFrameNumbers(s32 nbdir, s32 initCounter[]) { initCounter[0]--; s32 total = initCounter[0] + initCounter[1] + initCounter[2]; s32 counter[] = {initCounter[0] + 1, initCounter[1], initCounter[2]}; s32 itype = 0; s32 res[3][5] = {0}; for(s32 i = 0; i < total; i++) { counter[itype]--; do { itype++; if (itype == 3) itype = 0; } while (counter[itype] <= 0); res[itype][initCounter[itype] - counter[itype]] = (i + 1) * nbdir; } WarUnitFrameNumbers frameNumbers = (WarUnitFrameNumbers){0}; frameNumbers.walkFramesCount = initCounter[0]; memcpy(frameNumbers.walkFrames, res[0], initCounter[0] * sizeof(s32)); frameNumbers.attackFramesCount = initCounter[1]; memcpy(frameNumbers.attackFrames, res[1], initCounter[1] * sizeof(s32)); frameNumbers.deathFramesCount = initCounter[2]; memcpy(frameNumbers.deathFrames, res[2], initCounter[2] * sizeof(s32)); return frameNumbers; } static WarUnitActionDef createUnitActionDef(WarUnitActionType type, bool directional, bool loop) { WarUnitActionDef def = {0}; def.type = type; def.directional = directional; def.loop = loop; WarUnitActionStepListInit(&def.steps, WarUnitActionStepListDefaultOptions); return def; } static void addUnitActionDefStep(WarUnitActionDef* def, WarUnitActionStepType type, s32 param) { WarUnitActionStepListAdd(&def->steps, (WarUnitActionStep){type, param}); } static WarUnitActionDef createWalkActionDef(s32 nframes, s32 frames[], s32 walkSpeed, bool directional) { WarUnitActionDef def = createUnitActionDef(WAR_ACTION_TYPE_WALK, directional, true); s32 halfIndex = nframes % 2 == 0 ? nframes / 2 : (nframes + 1) / 2; // This code convert the frames sequence in this WAR_ACTION_STEP_FRAME sequence. // (this code is ported from the War1gus project, built with the Stratagus engine) // // 1 frame a => a 0 a 0 a 0 a 0 // 2 frames a b => a 0 b 0 a 0 b 0 // 3 frames a b c => a b a 0 c b c 0 // 4 frames a b c d => a b a 0 d c d 0 // 5 frames a b c d e => a b c b a e d c d e // // This code is used with a previous steps calling 'wact_getFrameNumbers' // and construct the base frame sequences for walk, attack and death animations. // // Is this way because of the layout of the spritesheets of the units: // (in reality is 5 frames per row, because of the directions of the units, // to keep it simple asume that there is only one direction NORTH) // // footman spritesheet: // 1 frame of walk // 1 frame of attack // 1 frame of death // 1 frame of walk // 1 frame of attack // 1 frame of death // 1 frame of walk // 1 frame of attack // 1 frame of death (death anim is only 3 frames for the footman) // 1 frame of walk // 1 frame of attack // 1 frame of walk // 1 frame of attack // // other spritesheets are similar, just with different frames count per animations s32 actionFrames = 8; while (actionFrames > 0) { for(s32 i = 0; i < halfIndex; i++) { addUnitActionDefStep(&def, WAR_ACTION_STEP_FRAME, frames[i]); addUnitActionDefStep(&def, WAR_ACTION_STEP_WAIT, walkSpeed); actionFrames--; } for(s32 i = halfIndex - 2; i >= 0; i--) { addUnitActionDefStep(&def, WAR_ACTION_STEP_FRAME, frames[i]); addUnitActionDefStep(&def, WAR_ACTION_STEP_WAIT, walkSpeed); actionFrames--; } addUnitActionDefStep(&def, WAR_ACTION_STEP_FRAME, 0); addUnitActionDefStep(&def, WAR_ACTION_STEP_WAIT, walkSpeed); actionFrames--; for(s32 i = 0; i < halfIndex; i++) { addUnitActionDefStep(&def, WAR_ACTION_STEP_FRAME, frames[nframes - 1 - i]); addUnitActionDefStep(&def, WAR_ACTION_STEP_WAIT, walkSpeed); actionFrames--; } for(s32 i = 1 + nframes - halfIndex; i < nframes; i++) { addUnitActionDefStep(&def, WAR_ACTION_STEP_FRAME, frames[i]); addUnitActionDefStep(&def, WAR_ACTION_STEP_WAIT, walkSpeed); actionFrames--; } addUnitActionDefStep(&def, WAR_ACTION_STEP_FRAME, 0); addUnitActionDefStep(&def, WAR_ACTION_STEP_WAIT, walkSpeed); actionFrames--; } addUnitActionDefStep(&def, WAR_ACTION_STEP_FRAME, 0); addUnitActionDefStep(&def, WAR_ACTION_STEP_WAIT, 1); assert(!actionFrames); return def; } static WarUnitActionDef createLinearWalkActionDef(s32 framesCount, s32 frames[], bool directional, s32 walkSpeed) { WarUnitActionDef def = createUnitActionDef(WAR_ACTION_TYPE_WALK, directional, true); for(s32 i = 0; i < framesCount; i++) { addUnitActionDefStep(&def, WAR_ACTION_STEP_FRAME, frames[i]); addUnitActionDefStep(&def, WAR_ACTION_STEP_WAIT, walkSpeed); } addUnitActionDefStep(&def, WAR_ACTION_STEP_FRAME, 0); addUnitActionDefStep(&def, WAR_ACTION_STEP_WAIT, 1); return def; } static WarUnitActionDef createAttackActionDef(s32 nframes, s32 frames[], s32 attackSpeed, s32 attackSound, s32 coolOffTime, bool directional) { WarUnitActionDef def = createUnitActionDef(WAR_ACTION_TYPE_ATTACK, directional, true); s32 halfIndex = nframes%2 == 0 ? nframes/2 : (nframes+1)/2; for(s32 i = 0; i < nframes; i++) { addUnitActionDefStep(&def, WAR_ACTION_STEP_FRAME, frames[i]); if (i == halfIndex) { addUnitActionDefStep(&def, WAR_ACTION_STEP_ATTACK, 0); addUnitActionDefStep(&def, attackSound, 0); } addUnitActionDefStep(&def, WAR_ACTION_STEP_WAIT, attackSpeed); } // make sure we don't attack faster just because we have fewer frames addUnitActionDefStep(&def, WAR_ACTION_STEP_WAIT, (5 - nframes) * attackSpeed); addUnitActionDefStep(&def, WAR_ACTION_STEP_FRAME, 0); addUnitActionDefStep(&def, WAR_ACTION_STEP_WAIT, coolOffTime); addUnitActionDefStep(&def, WAR_ACTION_STEP_FRAME, 0); addUnitActionDefStep(&def, WAR_ACTION_STEP_WAIT, 1); return def; } static WarUnitActionDef createRepairActionDef(s32 nframes, s32 frames[], s32 attackSpeed, s32 attackSound, s32 coolOffTime, bool directional) { WarUnitActionDef def = createUnitActionDef(WAR_ACTION_TYPE_REPAIR, directional, true); s32 halfIndex = nframes%2 == 0 ? nframes/2 : (nframes+1)/2; for(s32 i = 0; i < nframes; i++) { addUnitActionDefStep(&def, WAR_ACTION_STEP_FRAME, frames[i]); if (i == halfIndex) { addUnitActionDefStep(&def, WAR_ACTION_STEP_ATTACK, 0); addUnitActionDefStep(&def, attackSound, 0); } addUnitActionDefStep(&def, WAR_ACTION_STEP_WAIT, attackSpeed); } // make sure we don't attack faster just because we have fewer frames addUnitActionDefStep(&def, WAR_ACTION_STEP_WAIT, (5 - nframes) * attackSpeed); addUnitActionDefStep(&def, WAR_ACTION_STEP_FRAME, 0); addUnitActionDefStep(&def, WAR_ACTION_STEP_WAIT, coolOffTime); addUnitActionDefStep(&def, WAR_ACTION_STEP_FRAME, 0); addUnitActionDefStep(&def, WAR_ACTION_STEP_WAIT, 1); return def; } static WarUnitActionDef createHarvestActionDef(s32 nframes, s32 frames[], s32 harvestSpeed, s32 harvestSound, s32 coolOffTime, bool directional) { WarUnitActionDef def = createUnitActionDef(WAR_ACTION_TYPE_HARVEST, directional, true); s32 halfIndex = nframes%2 == 0 ? nframes/2 : (nframes+1)/2; addUnitActionDefStep(&def, WAR_ACTION_STEP_WAIT, 5); for(s32 i = 0; i < nframes; i++) { addUnitActionDefStep(&def, WAR_ACTION_STEP_FRAME, frames[i]); if (i == halfIndex) { addUnitActionDefStep(&def, WAR_ACTION_STEP_ATTACK, 0); addUnitActionDefStep(&def, harvestSound, 0); } addUnitActionDefStep(&def, WAR_ACTION_STEP_WAIT, harvestSpeed); } // make sure we don't attack faster just because we have fewer frames addUnitActionDefStep(&def, WAR_ACTION_STEP_WAIT, (5 - nframes) * harvestSpeed); addUnitActionDefStep(&def, WAR_ACTION_STEP_FRAME, 0); addUnitActionDefStep(&def, WAR_ACTION_STEP_WAIT, coolOffTime); addUnitActionDefStep(&def, WAR_ACTION_STEP_FRAME, 0); addUnitActionDefStep(&def, WAR_ACTION_STEP_WAIT, 1); return def; } static WarUnitActionDef createDeathActionDef(s32 nframes, s32 frames[], s32 waitTime, bool directional, bool doWait101Step) { WarUnitActionDef def = createUnitActionDef(WAR_ACTION_TYPE_DEATH, directional, true); for(s32 i = 0; i < nframes; i++) { addUnitActionDefStep(&def, WAR_ACTION_STEP_FRAME, frames[i]); addUnitActionDefStep(&def, WAR_ACTION_STEP_WAIT, waitTime); } if (doWait101Step) addUnitActionDefStep(&def, WAR_ACTION_STEP_WAIT, 101); addUnitActionDefStep(&def, WAR_ACTION_STEP_WAIT, 1); return def; } static WarUnitActionDef createBuildActionDef(s32 nframes, s32 frames[], s32 waitTime) { WarUnitActionDef def = createUnitActionDef(WAR_ACTION_TYPE_BUILD, false, false); for(s32 i = 0; i < nframes; i++) { addUnitActionDefStep(&def, WAR_ACTION_STEP_FRAME, frames[i]); addUnitActionDefStep(&def, WAR_ACTION_STEP_WAIT, waitTime); } addUnitActionDefStep(&def, WAR_ACTION_STEP_WAIT, 1); return def; } static WarUnitActionDef createIdleActionDef(s32 nframes, s32 frames[], s32 waitTime, bool directional) { WarUnitActionDef def = createUnitActionDef(WAR_ACTION_TYPE_IDLE, directional, true); for(s32 i = 0; i < nframes; i++) { addUnitActionDefStep(&def, WAR_ACTION_STEP_FRAME, frames[i]); addUnitActionDefStep(&def, WAR_ACTION_STEP_WAIT, waitTime); } addUnitActionDefStep(&def, WAR_ACTION_STEP_WAIT, 1); return def; } static WarUnitActionDef createDefaultIdleActionDef(s32 waitTime, bool directional) { s32 idleFrames[] = {0}; return createIdleActionDef(1, idleFrames, waitTime, directional); } static WarUnitActionDef createSpiderScorpionDeathActionDef(s32 framesCount, s32 frames[], bool directional, s32 waitTime) { assert(framesCount == 5); // Scorpions and Spiders have distinct wait times than other units, // so a custom death action is built for those cases WarUnitActionDef deathDef = createUnitActionDef(WAR_ACTION_TYPE_DEATH, directional, true); addUnitActionDefStep(&deathDef, WAR_ACTION_STEP_FRAME, frames[0]); addUnitActionDefStep(&deathDef, WAR_ACTION_STEP_WAIT, waitTime); addUnitActionDefStep(&deathDef, WAR_ACTION_STEP_FRAME, frames[1]); addUnitActionDefStep(&deathDef, WAR_ACTION_STEP_WAIT, waitTime); addUnitActionDefStep(&deathDef, WAR_ACTION_STEP_FRAME, frames[2]); addUnitActionDefStep(&deathDef, WAR_ACTION_STEP_WAIT, waitTime * 100); addUnitActionDefStep(&deathDef, WAR_ACTION_STEP_FRAME, frames[3]); addUnitActionDefStep(&deathDef, WAR_ACTION_STEP_WAIT, waitTime); addUnitActionDefStep(&deathDef, WAR_ACTION_STEP_FRAME, frames[4]); addUnitActionDefStep(&deathDef, WAR_ACTION_STEP_WAIT, waitTime); addUnitActionDefStep(&deathDef, WAR_ACTION_STEP_WAIT, 101); addUnitActionDefStep(&deathDef, WAR_ACTION_STEP_WAIT, 1); return deathDef; } static WarUnitActionDef createSlimeWalkActionDef(bool directional, s32 walkSpeed) { WarUnitActionDef def = createUnitActionDef(WAR_ACTION_TYPE_WALK, directional, true); s32 walkFrames[] = {15, 30, 45, 55, 65, 0}; for(s32 i = 0; i < arrayLength(walkFrames); i++) { addUnitActionDefStep(&def, WAR_ACTION_STEP_FRAME, walkFrames[i]); addUnitActionDefStep(&def, WAR_ACTION_STEP_WAIT, walkSpeed); } addUnitActionDefStep(&def, WAR_ACTION_STEP_FRAME, 0); addUnitActionDefStep(&def, WAR_ACTION_STEP_WAIT, 15); return def; } static WarUnitActionDef createFireElementalWalkActionDef(bool directional, s32 walkSpeed) { WarUnitActionDef def = createUnitActionDef(WAR_ACTION_TYPE_WALK, directional, true); s32 walkFrames[] = {10, 20, 30, 40, 50, 0}; for(s32 i = 0; i < arrayLength(walkFrames); i++) { addUnitActionDefStep(&def, WAR_ACTION_STEP_FRAME, walkFrames[i]); addUnitActionDefStep(&def, WAR_ACTION_STEP_WAIT, walkSpeed); } addUnitActionDefStep(&def, WAR_ACTION_STEP_FRAME, 0); addUnitActionDefStep(&def, WAR_ACTION_STEP_WAIT, 1); return def; } static void initFootmanGruntActionDefs(WarUnitFrameNumbers frames) { s32 walkSpeed = 6; s32 attackSpeed = 6; s32 coolOffTime = 1; s32 waitTime = 3; bool directional = true; WarUnitType unitTypes[] = {WAR_UNIT_FOOTMAN, WAR_UNIT_GRUNT}; WarUnitActionDef idleDef = createDefaultIdleActionDef(waitTime, directional); WarUnitActionDef walkDef = createWalkActionDef(frames.walkFramesCount, frames.walkFrames, walkSpeed, directional); WarUnitActionDef attackDef = createAttackActionDef(frames.attackFramesCount, frames.attackFrames, attackSpeed, WAR_ACTION_STEP_SOUND_SWORD, coolOffTime, directional); WarUnitActionDef deathDef = createDeathActionDef(frames.deathFramesCount, frames.deathFrames, waitTime, directional, true); for (s32 i = 0; i < arrayLength(unitTypes); i++) { WarUnitType unitType = unitTypes[i]; gUnitActionDefs[unitType][WAR_ACTION_TYPE_IDLE] = idleDef; gUnitActionDefs[unitType][WAR_ACTION_TYPE_WALK] = walkDef; gUnitActionDefs[unitType][WAR_ACTION_TYPE_ATTACK] = attackDef; gUnitActionDefs[unitType][WAR_ACTION_TYPE_DEATH] = deathDef; } } static void initPeasantPeonActionDefs(WarUnitFrameNumbers frames, WarUnitFrameNumbers framesHarvest) { s32 walkSpeed = 6; s32 attackSpeed = 6; s32 coolOffTime = 1; s32 waitTime = 3; bool directional = true; WarUnitType unitTypes[] = {WAR_UNIT_PEASANT, WAR_UNIT_PEON}; WarUnitActionDef defaultIdleDef = createDefaultIdleActionDef(waitTime, directional); WarUnitActionDef walkDef = createWalkActionDef(frames.walkFramesCount, frames.walkFrames, walkSpeed, directional); WarUnitActionDef attackDef = createAttackActionDef(frames.attackFramesCount, frames.attackFrames, attackSpeed, WAR_ACTION_STEP_SOUND_CHOPPING, coolOffTime, directional); WarUnitActionDef deathDef = createDeathActionDef(frames.deathFramesCount, frames.deathFrames, waitTime, directional, true); WarUnitActionDef repairDef = createRepairActionDef(framesHarvest.attackFramesCount, framesHarvest.attackFrames, attackSpeed, WAR_ACTION_STEP_SOUND_CHOPPING, coolOffTime, directional); WarUnitActionDef harvestDef = createHarvestActionDef(framesHarvest.attackFramesCount, framesHarvest.attackFrames, attackSpeed, WAR_ACTION_STEP_SOUND_CHOPPING, coolOffTime, directional); for (s32 i = 0; i < arrayLength(unitTypes); i++) { WarUnitType unitType = unitTypes[i]; gUnitActionDefs[unitType][WAR_ACTION_TYPE_IDLE] = defaultIdleDef; gUnitActionDefs[unitType][WAR_ACTION_TYPE_WALK] = walkDef; gUnitActionDefs[unitType][WAR_ACTION_TYPE_ATTACK] = attackDef; gUnitActionDefs[unitType][WAR_ACTION_TYPE_DEATH] = deathDef; gUnitActionDefs[unitType][WAR_ACTION_TYPE_REPAIR] = repairDef; gUnitActionDefs[unitType][WAR_ACTION_TYPE_HARVEST] = harvestDef; } } static void initCatapultActionDefs(WarUnitFrameNumbers frames) { s32 walkSpeed = 10; s32 attackSpeed = 25; s32 coolOffTime = 49; s32 waitTime = 3; bool directional = true; WarUnitType unitTypes[] = {WAR_UNIT_CATAPULT_HUMANS, WAR_UNIT_CATAPULT_ORCS}; WarUnitActionDef idleDef = createDefaultIdleActionDef(waitTime, directional); WarUnitActionDef walkDef = createWalkActionDef(frames.walkFramesCount, frames.walkFrames, walkSpeed, directional); WarUnitActionDef attackDef = createAttackActionDef(frames.attackFramesCount, frames.attackFrames, attackSpeed, WAR_ACTION_STEP_SOUND_CATAPULT, coolOffTime, directional); WarUnitActionDef deathDef = createDeathActionDef(frames.deathFramesCount, frames.deathFrames, waitTime, directional, true); for (s32 i = 0; i < arrayLength(unitTypes); i++) { WarUnitType unitType = unitTypes[i]; gUnitActionDefs[unitType][WAR_ACTION_TYPE_IDLE] = idleDef; gUnitActionDefs[unitType][WAR_ACTION_TYPE_WALK] = walkDef; gUnitActionDefs[unitType][WAR_ACTION_TYPE_ATTACK] = attackDef; gUnitActionDefs[unitType][WAR_ACTION_TYPE_DEATH] = deathDef; } } static void initKnightRaiderActionDefs(WarUnitFrameNumbers frames) { s32 walkSpeed = 10; s32 attackSpeed = 6; s32 coolOffTime = 1; s32 waitTime = 3; bool directional = true; WarUnitType unitTypes[] = {WAR_UNIT_KNIGHT, WAR_UNIT_RAIDER}; WarUnitActionDef idleDef = createDefaultIdleActionDef(waitTime, directional); s32 walkFrames[] = {15, 30, 45, 60, 0}; WarUnitActionDef walkDef = createLinearWalkActionDef(arrayLength(walkFrames), walkFrames, directional, walkSpeed); WarUnitActionDef attackDef = createAttackActionDef(frames.attackFramesCount, frames.attackFrames, attackSpeed, WAR_ACTION_STEP_SOUND_SWORD, coolOffTime, directional); WarUnitActionDef deathDef = createDeathActionDef(frames.deathFramesCount, frames.deathFrames, waitTime, directional, true); for (s32 i = 0; i < arrayLength(unitTypes); i++) { WarUnitType unitType = unitTypes[i]; gUnitActionDefs[unitType][WAR_ACTION_TYPE_IDLE] = idleDef; gUnitActionDefs[unitType][WAR_ACTION_TYPE_WALK] = walkDef; gUnitActionDefs[unitType][WAR_ACTION_TYPE_ATTACK] = attackDef; gUnitActionDefs[unitType][WAR_ACTION_TYPE_DEATH] = deathDef; } // These are probably when the knight and rider are upgraded? // // options.speed = 2; // buildActions(entity, frameNumbers_5_5_5_5, options); // options.speed = 1; // buildActions(entity, frameNumbers_5_5_5_5, options); } static void initArcherSpearmanActionDefs(WarUnitFrameNumbers frames) { s32 walkSpeed = 6; s32 attackSpeed = 10; s32 coolOffTime = 1; s32 waitTime = 3; bool directional = true; WarUnitType unitTypes[] = {WAR_UNIT_ARCHER, WAR_UNIT_SPEARMAN}; WarUnitActionDef idleDef = createDefaultIdleActionDef(waitTime, directional); WarUnitActionDef walkDef = createWalkActionDef(frames.walkFramesCount, frames.walkFrames, walkSpeed, directional); WarUnitActionDef attackDef = createAttackActionDef(frames.attackFramesCount, frames.attackFrames, attackSpeed, WAR_ACTION_STEP_SOUND_ARROW, coolOffTime, directional); WarUnitActionDef deathDef = createDeathActionDef(frames.deathFramesCount, frames.deathFrames, waitTime, directional, true); for (s32 i = 0; i < arrayLength(unitTypes); i++) { WarUnitType unitType = unitTypes[i]; gUnitActionDefs[unitType][WAR_ACTION_TYPE_IDLE] = idleDef; gUnitActionDefs[unitType][WAR_ACTION_TYPE_WALK] = walkDef; gUnitActionDefs[unitType][WAR_ACTION_TYPE_ATTACK] = attackDef; gUnitActionDefs[unitType][WAR_ACTION_TYPE_DEATH] = deathDef; } } static void initConjurerActionDefs(WarUnitFrameNumbers frames) { s32 walkSpeed = 7; s32 attackSpeed = 8; s32 coolOffTime = 0; s32 waitTime = 3; bool directional = true; s32 attackFrames[] = {5, 20, 35, 50}; WarUnitActionDef idleDef = createDefaultIdleActionDef(waitTime, directional); WarUnitActionDef walkDef = createWalkActionDef(frames.walkFramesCount, frames.walkFrames, walkSpeed, directional); WarUnitActionDef attackDef = createAttackActionDef(arrayLength(attackFrames), attackFrames, attackSpeed, WAR_ACTION_STEP_SOUND_FIREBALL, coolOffTime, directional); WarUnitActionDef deathDef = createDeathActionDef(frames.deathFramesCount, frames.deathFrames, waitTime, directional, true); gUnitActionDefs[WAR_UNIT_CONJURER][WAR_ACTION_TYPE_IDLE] = idleDef; gUnitActionDefs[WAR_UNIT_CONJURER][WAR_ACTION_TYPE_WALK] = walkDef; gUnitActionDefs[WAR_UNIT_CONJURER][WAR_ACTION_TYPE_ATTACK] = attackDef; gUnitActionDefs[WAR_UNIT_CONJURER][WAR_ACTION_TYPE_DEATH] = deathDef; } static void initWarlockActionDefs(WarUnitFrameNumbers frames) { s32 walkSpeed = 7; s32 attackSpeed = 8; s32 coolOffTime = 1; s32 waitTime = 3; bool directional = true; s32 attackFrames[] = {5, 20, 35, 50, 60}; WarUnitActionDef idleDef = createDefaultIdleActionDef(waitTime, directional); WarUnitActionDef walkDef = createWalkActionDef(frames.walkFramesCount, frames.walkFrames, walkSpeed, directional); WarUnitActionDef attackDef = createAttackActionDef(arrayLength(attackFrames), attackFrames, attackSpeed, WAR_ACTION_STEP_SOUND_FIREBALL, coolOffTime, directional); WarUnitActionDef deathDef = createDeathActionDef(frames.deathFramesCount, frames.deathFrames, waitTime, directional, true); gUnitActionDefs[WAR_UNIT_WARLOCK][WAR_ACTION_TYPE_IDLE] = idleDef; gUnitActionDefs[WAR_UNIT_WARLOCK][WAR_ACTION_TYPE_WALK] = walkDef; gUnitActionDefs[WAR_UNIT_WARLOCK][WAR_ACTION_TYPE_ATTACK] = attackDef; gUnitActionDefs[WAR_UNIT_WARLOCK][WAR_ACTION_TYPE_DEATH] = deathDef; } static void initClericActionDefs(WarUnitFrameNumbers frames) { s32 walkSpeed = 7; s32 attackSpeed = 6; s32 coolOffTime = 1; s32 waitTime = 3; bool directional = true; WarUnitActionDef idleDef = createDefaultIdleActionDef(waitTime, directional); WarUnitActionDef walkDef = createWalkActionDef(frames.walkFramesCount, frames.walkFrames, walkSpeed, directional); WarUnitActionDef attackDef = createAttackActionDef(frames.attackFramesCount, frames.attackFrames, attackSpeed, WAR_ACTION_STEP_SOUND_FIREBALL, coolOffTime, directional); WarUnitActionDef deathDef = createDeathActionDef(frames.deathFramesCount, frames.deathFrames, waitTime, directional, true); gUnitActionDefs[WAR_UNIT_CLERIC][WAR_ACTION_TYPE_IDLE] = idleDef; gUnitActionDefs[WAR_UNIT_CLERIC][WAR_ACTION_TYPE_WALK] = walkDef; gUnitActionDefs[WAR_UNIT_CLERIC][WAR_ACTION_TYPE_ATTACK] = attackDef; gUnitActionDefs[WAR_UNIT_CLERIC][WAR_ACTION_TYPE_DEATH] = deathDef; } static void initNecrolyteActionDefs(WarUnitFrameNumbers frames) { s32 walkSpeed = 7; s32 attackSpeed = 6; s32 coolOffTime = 1; s32 waitTime = 3; bool directional = true; WarUnitActionDef idleDef = createDefaultIdleActionDef(waitTime, directional); WarUnitActionDef walkDef = createWalkActionDef(frames.walkFramesCount, frames.walkFrames, walkSpeed, directional); WarUnitActionDef attackDef = createAttackActionDef(frames.attackFramesCount, frames.attackFrames, attackSpeed, WAR_ACTION_STEP_SOUND_FIREBALL, coolOffTime, directional); WarUnitActionDef deathDef = createDeathActionDef(frames.deathFramesCount, frames.deathFrames, waitTime, directional, true); gUnitActionDefs[WAR_UNIT_NECROLYTE][WAR_ACTION_TYPE_IDLE] = idleDef; gUnitActionDefs[WAR_UNIT_NECROLYTE][WAR_ACTION_TYPE_WALK] = walkDef; gUnitActionDefs[WAR_UNIT_NECROLYTE][WAR_ACTION_TYPE_ATTACK] = attackDef; gUnitActionDefs[WAR_UNIT_NECROLYTE][WAR_ACTION_TYPE_DEATH] = deathDef; } static void initMedivhActionDefs(WarUnitFrameNumbers frames) { s32 walkSpeed = 6; s32 attackSpeed = 6; s32 coolOffTime = 1; s32 waitTime = 3; bool directional = true; WarUnitActionDef idleDef = createDefaultIdleActionDef(waitTime, directional); WarUnitActionDef walkDef = createWalkActionDef(frames.walkFramesCount, frames.walkFrames, walkSpeed, directional); WarUnitActionDef attackDef = createAttackActionDef(frames.attackFramesCount, frames.attackFrames, attackSpeed, WAR_ACTION_STEP_SOUND_LIGHTNING, coolOffTime, directional); WarUnitActionDef deathDef = createDeathActionDef(frames.deathFramesCount, frames.deathFrames, waitTime, directional, true); gUnitActionDefs[WAR_UNIT_MEDIVH][WAR_ACTION_TYPE_IDLE] = idleDef; gUnitActionDefs[WAR_UNIT_MEDIVH][WAR_ACTION_TYPE_WALK] = walkDef; gUnitActionDefs[WAR_UNIT_MEDIVH][WAR_ACTION_TYPE_ATTACK] = attackDef; gUnitActionDefs[WAR_UNIT_MEDIVH][WAR_ACTION_TYPE_DEATH] = deathDef; } static void initLotharActionDefs(WarUnitFrameNumbers frames) { s32 walkSpeed = 6; s32 attackSpeed = 6; s32 coolOffTime = 1; s32 waitTime = 3; bool directional = true; WarUnitActionDef idleDef = createDefaultIdleActionDef(waitTime, directional); WarUnitActionDef walkDef = createWalkActionDef(frames.walkFramesCount, frames.walkFrames, walkSpeed, directional); WarUnitActionDef attackDef = createAttackActionDef(frames.attackFramesCount, frames.attackFrames, attackSpeed, WAR_ACTION_STEP_SOUND_SWORD, coolOffTime, directional); WarUnitActionDef deathDef = createDeathActionDef(frames.deathFramesCount, frames.deathFrames, waitTime, directional, true); gUnitActionDefs[WAR_UNIT_LOTHAR][WAR_ACTION_TYPE_IDLE] = idleDef; gUnitActionDefs[WAR_UNIT_LOTHAR][WAR_ACTION_TYPE_WALK] = walkDef; gUnitActionDefs[WAR_UNIT_LOTHAR][WAR_ACTION_TYPE_ATTACK] = attackDef; gUnitActionDefs[WAR_UNIT_LOTHAR][WAR_ACTION_TYPE_DEATH] = deathDef; } static void initGrizeldaGaronaActionDefs(void) { s32 walkSpeed = 6; s32 waitTime = 4; bool directional = true; s32 walkFrames[] = {10, 20, 30, 35}; s32 deathFrames[] = {5, 15, 25}; WarUnitType unitTypes[] = {WAR_UNIT_GRIZELDA, WAR_UNIT_GARONA}; WarUnitActionDef idleDef = createDefaultIdleActionDef(waitTime, directional); WarUnitActionDef walkDef = createWalkActionDef(arrayLength(walkFrames), walkFrames, walkSpeed, directional); WarUnitActionDef deathDef = createDeathActionDef(arrayLength(deathFrames), deathFrames, waitTime, directional, true); for (s32 i = 0; i < arrayLength(unitTypes); i++) { WarUnitType unitType = unitTypes[i]; gUnitActionDefs[unitType][WAR_ACTION_TYPE_IDLE] = idleDef; gUnitActionDefs[unitType][WAR_ACTION_TYPE_WALK] = walkDef; gUnitActionDefs[unitType][WAR_ACTION_TYPE_DEATH] = deathDef; } } static void initOgreActionDefs(WarUnitFrameNumbers frames) { s32 walkSpeed = 6; s32 attackSpeed = 6; s32 coolOffTime = 1; s32 waitTime = 3; bool directional = true; WarUnitActionDef idleDef = createDefaultIdleActionDef(waitTime, directional); WarUnitActionDef walkDef = createWalkActionDef(frames.walkFramesCount, frames.walkFrames, walkSpeed, directional); WarUnitActionDef attackDef = createAttackActionDef(frames.attackFramesCount, frames.attackFrames, attackSpeed, WAR_ACTION_STEP_SOUND_FIST, coolOffTime, directional); WarUnitActionDef deathDef = createDeathActionDef(frames.deathFramesCount, frames.deathFrames, waitTime, directional, true); gUnitActionDefs[WAR_UNIT_OGRE][WAR_ACTION_TYPE_IDLE] = idleDef; gUnitActionDefs[WAR_UNIT_OGRE][WAR_ACTION_TYPE_WALK] = walkDef; gUnitActionDefs[WAR_UNIT_OGRE][WAR_ACTION_TYPE_ATTACK] = attackDef; gUnitActionDefs[WAR_UNIT_OGRE][WAR_ACTION_TYPE_DEATH] = deathDef; } static void initSpiderActionDefs(WarUnitFrameNumbers frames) { s32 walkSpeed = 4; s32 attackSpeed = 6; s32 coolOffTime = 1; s32 waitTime = 3; bool directional = true; s32 walkFrames[] = {15, 30, 45, 60, 0}; WarUnitActionDef idleDef = createDefaultIdleActionDef(waitTime, directional); WarUnitActionDef walkDef = createLinearWalkActionDef(arrayLength(walkFrames), walkFrames, directional, walkSpeed); WarUnitActionDef attackDef = createAttackActionDef(frames.attackFramesCount, frames.attackFrames, attackSpeed, WAR_ACTION_STEP_SOUND_FIST, coolOffTime, directional); WarUnitActionDef deathDef = createSpiderScorpionDeathActionDef(frames.deathFramesCount, frames.deathFrames, directional, waitTime); gUnitActionDefs[WAR_UNIT_SPIDER][WAR_ACTION_TYPE_IDLE] = idleDef; gUnitActionDefs[WAR_UNIT_SPIDER][WAR_ACTION_TYPE_WALK] = walkDef; gUnitActionDefs[WAR_UNIT_SPIDER][WAR_ACTION_TYPE_ATTACK] = attackDef; gUnitActionDefs[WAR_UNIT_SPIDER][WAR_ACTION_TYPE_DEATH] = deathDef; } static void initSlimeActionDefs(WarUnitFrameNumbers frames) { s32 walkSpeed = 6; s32 attackSpeed = 15; s32 coolOffTime = 15; s32 waitTime = 8; bool directional = true; s32 idleFrames[] = {0, 70, 75, 80, 85, 90}; WarUnitActionDef idleDef = createIdleActionDef(arrayLength(idleFrames), idleFrames, waitTime, directional); WarUnitActionDef walkDef = createSlimeWalkActionDef(directional, walkSpeed); WarUnitActionDef attackDef = createAttackActionDef(frames.attackFramesCount, frames.attackFrames, attackSpeed, WAR_ACTION_STEP_SOUND_FIST, coolOffTime, directional); WarUnitActionDef deathDef = createDeathActionDef(frames.deathFramesCount, frames.deathFrames, 3, directional, true); gUnitActionDefs[WAR_UNIT_SLIME][WAR_ACTION_TYPE_IDLE] = idleDef; gUnitActionDefs[WAR_UNIT_SLIME][WAR_ACTION_TYPE_WALK] = walkDef; gUnitActionDefs[WAR_UNIT_SLIME][WAR_ACTION_TYPE_ATTACK] = attackDef; gUnitActionDefs[WAR_UNIT_SLIME][WAR_ACTION_TYPE_DEATH] = deathDef; } static void initFireElementalActionDefs(WarUnitFrameNumbers frames) { s32 walkSpeed = 5; s32 attackSpeed = 6; s32 coolOffTime = 24; s32 waitTime = 8; bool directional = true; s32 idleFrames[] = {5, 15, 25, 35, 50}; WarUnitActionDef idleDef = createIdleActionDef(arrayLength(idleFrames), idleFrames, waitTime, directional); WarUnitActionDef walkDef = createFireElementalWalkActionDef(directional, walkSpeed); WarUnitActionDef attackDef = createAttackActionDef(frames.attackFramesCount, frames.attackFrames, attackSpeed, WAR_ACTION_STEP_SOUND_FIREBALL, coolOffTime, directional); gUnitActionDefs[WAR_UNIT_FIRE_ELEMENTAL][WAR_ACTION_TYPE_IDLE] = idleDef; gUnitActionDefs[WAR_UNIT_FIRE_ELEMENTAL][WAR_ACTION_TYPE_WALK] = walkDef; gUnitActionDefs[WAR_UNIT_FIRE_ELEMENTAL][WAR_ACTION_TYPE_ATTACK] = attackDef; } static void initWaterElementalActionDefs(WarUnitFrameNumbers frames) { s32 walkSpeed = 4; s32 attackSpeed = 6; s32 coolOffTime = 24; s32 waitTime = 8; bool directional = true; s32 idleFrames[] = {0, 5, 15, 30}; WarUnitActionDef idleDef = createIdleActionDef(arrayLength(idleFrames), idleFrames, waitTime, directional); WarUnitActionDef walkDef = createWalkActionDef(frames.walkFramesCount, frames.walkFrames, walkSpeed, directional); WarUnitActionDef attackDef = createAttackActionDef(frames.attackFramesCount, frames.attackFrames, attackSpeed, WAR_ACTION_STEP_SOUND_FIREBALL, coolOffTime, directional); WarUnitActionDef deathDef = createDeathActionDef(frames.deathFramesCount, frames.deathFrames, 3, directional, true); gUnitActionDefs[WAR_UNIT_WATER_ELEMENTAL][WAR_ACTION_TYPE_IDLE] = idleDef; gUnitActionDefs[WAR_UNIT_WATER_ELEMENTAL][WAR_ACTION_TYPE_WALK] = walkDef; gUnitActionDefs[WAR_UNIT_WATER_ELEMENTAL][WAR_ACTION_TYPE_ATTACK] = attackDef; gUnitActionDefs[WAR_UNIT_WATER_ELEMENTAL][WAR_ACTION_TYPE_DEATH] = deathDef; } static void initScorpionActionDefs(WarUnitFrameNumbers frames) { s32 walkSpeed = 4; s32 attackSpeed = 6; s32 coolOffTime = 1; s32 waitTime = 3; bool directional = true; s32 walkFrames[] = {15, 30, 45, 60, 0}; WarUnitActionDef idleDef = createDefaultIdleActionDef(waitTime, directional); WarUnitActionDef walkDef = createLinearWalkActionDef(arrayLength(walkFrames), walkFrames, directional, walkSpeed); WarUnitActionDef attackDef = createAttackActionDef(frames.attackFramesCount, frames.attackFrames, attackSpeed, WAR_ACTION_STEP_SOUND_FIST, coolOffTime, directional); WarUnitActionDef deathDef = createSpiderScorpionDeathActionDef(frames.deathFramesCount, frames.deathFrames, directional, waitTime); gUnitActionDefs[WAR_UNIT_SCORPION][WAR_ACTION_TYPE_IDLE] = idleDef; gUnitActionDefs[WAR_UNIT_SCORPION][WAR_ACTION_TYPE_WALK] = walkDef; gUnitActionDefs[WAR_UNIT_SCORPION][WAR_ACTION_TYPE_ATTACK] = attackDef; gUnitActionDefs[WAR_UNIT_SCORPION][WAR_ACTION_TYPE_DEATH] = deathDef; } static void initBrigandActionDefs(WarUnitFrameNumbers frames) { s32 walkSpeed = 4; s32 attackSpeed = 6; s32 coolOffTime = 1; s32 waitTime = 3; bool directional = true; WarUnitActionDef idleDef = createDefaultIdleActionDef(waitTime, directional); WarUnitActionDef walkDef = createWalkActionDef(frames.walkFramesCount, frames.walkFrames, walkSpeed, directional); WarUnitActionDef attackDef = createAttackActionDef(frames.attackFramesCount, frames.attackFrames, attackSpeed, WAR_ACTION_STEP_SOUND_SWORD, coolOffTime, directional); WarUnitActionDef deathDef = createDeathActionDef(frames.deathFramesCount, frames.deathFrames, waitTime, directional, true); gUnitActionDefs[WAR_UNIT_BRIGAND][WAR_ACTION_TYPE_IDLE] = idleDef; gUnitActionDefs[WAR_UNIT_BRIGAND][WAR_ACTION_TYPE_WALK] = walkDef; gUnitActionDefs[WAR_UNIT_BRIGAND][WAR_ACTION_TYPE_ATTACK] = attackDef; gUnitActionDefs[WAR_UNIT_BRIGAND][WAR_ACTION_TYPE_DEATH] = deathDef; } static void initSkeletonActionDefs(WarUnitFrameNumbers frames) { s32 walkSpeed = 4; s32 attackSpeed = 6; s32 coolOffTime = 1; s32 waitTime = 3; bool directional = true; WarUnitActionDef idleDef = createDefaultIdleActionDef(waitTime, directional); WarUnitActionDef walkDef = createWalkActionDef(frames.walkFramesCount, frames.walkFrames, walkSpeed, directional); WarUnitActionDef attackDef = createAttackActionDef(frames.attackFramesCount, frames.attackFrames, attackSpeed, WAR_ACTION_STEP_SOUND_SWORD, coolOffTime, directional); WarUnitActionDef deathDef = createDeathActionDef(frames.deathFramesCount, frames.deathFrames, waitTime, directional, true); gUnitActionDefs[WAR_UNIT_SKELETON][WAR_ACTION_TYPE_IDLE] = idleDef; gUnitActionDefs[WAR_UNIT_SKELETON][WAR_ACTION_TYPE_WALK] = walkDef; gUnitActionDefs[WAR_UNIT_SKELETON][WAR_ACTION_TYPE_ATTACK] = attackDef; gUnitActionDefs[WAR_UNIT_SKELETON][WAR_ACTION_TYPE_DEATH] = deathDef; } static void initDaemonActionDefs(WarUnitFrameNumbers frames) { s32 walkSpeed = 6; s32 attackSpeed = 6; s32 coolOffTime = 24; s32 waitTime = 3; bool directional = true; WarUnitActionDef idleDef = createDefaultIdleActionDef(waitTime, directional); WarUnitActionDef walkDef = createWalkActionDef(frames.walkFramesCount, frames.walkFrames, walkSpeed, directional); WarUnitActionDef attackDef = createAttackActionDef(frames.attackFramesCount, frames.attackFrames, attackSpeed, WAR_ACTION_STEP_SOUND_SWORD, coolOffTime, directional); WarUnitActionDef deathDef = createDeathActionDef(frames.deathFramesCount, frames.deathFrames, waitTime, directional, true); gUnitActionDefs[WAR_UNIT_DAEMON][WAR_ACTION_TYPE_IDLE] = idleDef; gUnitActionDefs[WAR_UNIT_DAEMON][WAR_ACTION_TYPE_WALK] = walkDef; gUnitActionDefs[WAR_UNIT_DAEMON][WAR_ACTION_TYPE_ATTACK] = attackDef; gUnitActionDefs[WAR_UNIT_DAEMON][WAR_ACTION_TYPE_DEATH] = deathDef; } static void initTheDeadActionDefs(WarUnitFrameNumbers frames) { s32 walkSpeed = 6; s32 attackSpeed = 6; s32 coolOffTime = 1; s32 waitTime = 3; bool directional = true; WarUnitActionDef idleDef = createDefaultIdleActionDef(waitTime, directional); WarUnitActionDef walkDef = createWalkActionDef(frames.walkFramesCount, frames.walkFrames, walkSpeed, directional); WarUnitActionDef attackDef = createAttackActionDef(frames.attackFramesCount, frames.attackFrames, attackSpeed, WAR_ACTION_STEP_SOUND_SWORD, coolOffTime, directional); WarUnitActionDef deathDef = createDeathActionDef(frames.deathFramesCount, frames.deathFrames, waitTime, directional, true); gUnitActionDefs[WAR_UNIT_THE_DEAD][WAR_ACTION_TYPE_IDLE] = idleDef; gUnitActionDefs[WAR_UNIT_THE_DEAD][WAR_ACTION_TYPE_WALK] = walkDef; gUnitActionDefs[WAR_UNIT_THE_DEAD][WAR_ACTION_TYPE_ATTACK] = attackDef; gUnitActionDefs[WAR_UNIT_THE_DEAD][WAR_ACTION_TYPE_DEATH] = deathDef; } static void initWoundedActionDefs(void) { s32 idleFrames[] = {0}; WarUnitActionDef idleDef = createIdleActionDef(arrayLength(idleFrames), idleFrames, 5, true); gUnitActionDefs[WAR_UNIT_WOUNDED][WAR_ACTION_TYPE_IDLE] = idleDef; } static void initBuildableActionDefs(void) { s32 idleFrames[] = {0}; s32 buildFrames[] = {0, 1, 2}; WarUnitType unitTypes[] = { WAR_UNIT_FARM_HUMANS, WAR_UNIT_FARM_ORCS, WAR_UNIT_BARRACKS_HUMANS, WAR_UNIT_BARRACKS_ORCS, WAR_UNIT_CHURCH, WAR_UNIT_TEMPLE, WAR_UNIT_TOWER_HUMANS, WAR_UNIT_TOWER_ORCS, WAR_UNIT_TOWNHALL_HUMANS, WAR_UNIT_TOWNHALL_ORCS, WAR_UNIT_LUMBERMILL_HUMANS, WAR_UNIT_LUMBERMILL_ORCS, WAR_UNIT_STABLE, WAR_UNIT_KENNEL, WAR_UNIT_BLACKSMITH_HUMANS, WAR_UNIT_BLACKSMITH_ORCS, }; WarUnitActionDef idleDef = createIdleActionDef(arrayLength(idleFrames), idleFrames, 5, false); WarUnitActionDef buildDef = createBuildActionDef(arrayLength(buildFrames), buildFrames, 50); for (s32 i = 0; i < arrayLength(unitTypes); i++) { WarUnitType unitType = unitTypes[i]; gUnitActionDefs[unitType][WAR_ACTION_TYPE_IDLE] = idleDef; gUnitActionDefs[unitType][WAR_ACTION_TYPE_BUILD] = buildDef; } } static void initNonBuildableActionDefs(void) { s32 idleFrames[] = {0}; WarUnitType unitTypes[] = { WAR_UNIT_STORMWIND, WAR_UNIT_BLACKROCK, WAR_UNIT_GOLDMINE }; WarUnitActionDef idleDef = createIdleActionDef(arrayLength(idleFrames), idleFrames, 5, false); for (s32 i = 0; i < arrayLength(unitTypes); i++) { WarUnitType unitType = unitTypes[i]; gUnitActionDefs[unitType][WAR_ACTION_TYPE_IDLE] = idleDef; } } static void initHumanCorpseActionDefs(void) { s32 deathFrames[] = {0, 10, 15, 20}; WarUnitActionDef deathDef = createDeathActionDef(arrayLength(deathFrames), deathFrames, 300, true, false); gUnitActionDefs[WAR_UNIT_HUMAN_CORPSE][WAR_ACTION_TYPE_DEATH] = deathDef; } static void initOrcCorpseActionDefs(void) { s32 deathFrames[] = {5, 10, 15, 20}; WarUnitActionDef deathDef = createDeathActionDef(arrayLength(deathFrames), deathFrames, 300, true, false); gUnitActionDefs[WAR_UNIT_ORC_CORPSE][WAR_ACTION_TYPE_DEATH] = deathDef; } static void resetAction(WarUnitAction* action) { action->stepIndex = 0; action->status = WAR_ACTION_NOT_STARTED; } void wact_initUnitActionDefs(void) { WarUnitFrameNumbers frameNumbers_5_5_5_5 = wact_getFrameNumbers(5, arrayArg(s32, 5, 5, 5)); WarUnitFrameNumbers frameNumbers_5_5_5_4 = wact_getFrameNumbers(5, arrayArg(s32, 5, 5, 4)); WarUnitFrameNumbers frameNumbers_5_5_5_3 = wact_getFrameNumbers(5, arrayArg(s32, 5, 5, 3)); WarUnitFrameNumbers frameNumbers_5_5_4_5 = wact_getFrameNumbers(5, arrayArg(s32, 5, 4, 5)); WarUnitFrameNumbers frameNumbers_5_5_4_4 = wact_getFrameNumbers(5, arrayArg(s32, 5, 4, 4)); WarUnitFrameNumbers frameNumbers_5_5_4_3 = wact_getFrameNumbers(5, arrayArg(s32, 5, 4, 3)); WarUnitFrameNumbers frameNumbers_5_5_3_2 = wact_getFrameNumbers(5, arrayArg(s32, 5, 3, 2)); WarUnitFrameNumbers frameNumbers_5_5_2_3 = wact_getFrameNumbers(5, arrayArg(s32, 5, 2, 3)); WarUnitFrameNumbers frameNumbers_5_3_5_3 = wact_getFrameNumbers(5, arrayArg(s32, 3, 5, 3)); WarUnitFrameNumbers frameNumbers_5_2_5_3 = wact_getFrameNumbers(5, arrayArg(s32, 2, 5, 3)); WarUnitFrameNumbers frameNumbers_5_4_3_3 = wact_getFrameNumbers(5, arrayArg(s32, 4, 3, 3)); NOT_USED(frameNumbers_5_4_3_3); WarUnitFrameNumbers frameNumbers_5_5_5_0 = wact_getFrameNumbers(5, arrayArg(s32, 5, 5, 0)); for (s32 i = 0; i < WAR_UNIT_COUNT; i++) { for (s32 j = 0; j < WAR_ACTION_TYPE_COUNT; j++) { gUnitActionDefs[i][j].type = WAR_ACTION_TYPE_NONE; } } initFootmanGruntActionDefs(frameNumbers_5_5_5_3); initPeasantPeonActionDefs(frameNumbers_5_5_5_3, frameNumbers_5_5_4_3); initCatapultActionDefs(frameNumbers_5_2_5_3); initKnightRaiderActionDefs(frameNumbers_5_5_5_5); initArcherSpearmanActionDefs(frameNumbers_5_5_2_3); initConjurerActionDefs(frameNumbers_5_5_4_4); initWarlockActionDefs(frameNumbers_5_5_5_3); initClericActionDefs(frameNumbers_5_5_4_3); initNecrolyteActionDefs(frameNumbers_5_5_5_4); initMedivhActionDefs(frameNumbers_5_5_5_3); initLotharActionDefs(frameNumbers_5_5_5_3); initGrizeldaGaronaActionDefs(); initOgreActionDefs(frameNumbers_5_5_5_5); initSpiderActionDefs(frameNumbers_5_5_4_5); initSlimeActionDefs(frameNumbers_5_5_5_3); initFireElementalActionDefs(frameNumbers_5_5_5_0); initWaterElementalActionDefs(frameNumbers_5_3_5_3); initScorpionActionDefs(frameNumbers_5_5_5_5); initBrigandActionDefs(frameNumbers_5_5_3_2); initSkeletonActionDefs(frameNumbers_5_5_5_5); initDaemonActionDefs(frameNumbers_5_5_5_5); initTheDeadActionDefs(frameNumbers_5_5_5_5); initWoundedActionDefs(); initBuildableActionDefs(); initNonBuildableActionDefs(); initHumanCorpseActionDefs(); initOrcCorpseActionDefs(); } bool wact_equalsActionStep(const WarUnitActionStep step1, const WarUnitActionStep step2) { return step1.type == step2.type && step1.param == step2.param; } shlDefineList(WarUnitActionStepList, WarUnitActionStep) void wact_addUnitActions(WarContext* context, WarEntity* entity) { WarUnitComponent* unit = we_getUnitComponent(context, entity); for (s32 i = 0; i < WAR_ACTION_TYPE_COUNT; i++) { WarUnitAction* action = &unit->actions[i]; action->status = WAR_ACTION_NOT_STARTED; action->scale = 1.0f; action->waitCount = 0; action->stepIndex = -1; action->lastActionStep = WAR_ACTION_STEP_NONE; action->lastSoundStep = WAR_ACTION_STEP_NONE; } } s32 wact_getActionDuration(WarContext* context, WarEntity* entity, WarUnitActionType type) { assert(wu_isUnit(entity)); if (type == WAR_ACTION_TYPE_NONE) return 0; WarUnitComponent* unit = we_getUnitComponent(context, entity); assert(unit); WarUnitActionDef* actionDef = &gUnitActionDefs[unit->type][type]; s32 duration = 0; for (s32 i = 0; i < actionDef->steps.count; i++) { WarUnitActionStep step = actionDef->steps.items[i]; if (step.type == WAR_ACTION_STEP_WAIT) duration += step.param; } return duration; } void wact_setAction(WarContext* context, WarEntity* entity, WarUnitActionType type, bool reset, f32 scale) { NOT_USED(context); assert(wu_isUnit(entity)); WarUnitComponent* unit = we_getUnitComponent(context, entity); if (type != WAR_ACTION_TYPE_NONE) { WarUnitActionDef* actionDef = &gUnitActionDefs[unit->type][type]; assert(actionDef->type != WAR_ACTION_TYPE_NONE); unit->actionType = type; WarUnitAction* action = &unit->actions[unit->actionType]; if (scale >= 0) { action->scale = scale; } if (reset) { resetAction(action); } } else { unit->actionType = type; } } void wact_updateAction(WarContext* context, WarEntity* entity) { WarUnitComponent* unit = we_getUnitComponent(context, entity); if (!unit || unit->actionType == WAR_ACTION_TYPE_NONE) { return; } WarUnitAction* action = &unit->actions[unit->actionType]; if (!action || action->status == WAR_ACTION_FINISHED) { return; } if (action->stepIndex < 0) { resetAction(action); } action->status = WAR_ACTION_RUNNING; WarUnitActionDef* actionDef = &gUnitActionDefs[unit->type][unit->actionType]; WarUnitActionStep step = actionDef->steps.items[action->stepIndex]; if (step.type == WAR_ACTION_STEP_WAIT) { action->waitCount -= wmap_getMapScaledSpeed(context, context->deltaTime); if (action->waitCount > 0) { return; } action->waitCount = 0; action->stepIndex++; if (action->stepIndex >= actionDef->steps.count) { if (!actionDef->loop) { action->status = WAR_ACTION_FINISHED; return; } action->stepIndex = 0; } step = actionDef->steps.items[action->stepIndex]; } action->lastActionStep = WAR_ACTION_STEP_NONE; action->lastSoundStep = WAR_ACTION_STEP_NONE; while (step.type != WAR_ACTION_STEP_WAIT) { switch (step.type) { case WAR_ACTION_STEP_FRAME: { s32 frameIndex = step.param; if (actionDef->directional) { // super complicated math here: // // d d // N: 4 - ABS(4 - 0) = 4 - 4 = 0 // NE: 4 - ABS(4 - 1) = 4 - 3 = 1 // E: 4 - ABS(4 - 2) = 4 - 2 = 2 // SW: 4 - ABS(4 - 3) = 4 - 1 = 3 // S: 4 - ABS(4 - 4) = 4 - 0 = 4 // SW: 4 - ABS(4 - 5) = 4 - 1 = 3 // W: 4 - ABS(4 - 6) = 4 - 2 = 2 // NW: 4 - ABS(4 - 7) = 4 - 3 = 1 // // ... 4 - ABS(4 - d) frameIndex += (4 - ABS(4 - (s32)unit->direction)); WarTransformComponent* transform = we_getTransformComponent(context, entity); assert(transform); transform->scale.x = inRange(unit->direction, WAR_DIRECTION_SOUTH_WEST, WAR_DIRECTION_COUNT) ? -1.0f : 1.0f; } WarSpriteComponent* sprite = we_getSpriteComponent(context, entity); if (sprite) sprite->frameIndex = frameIndex; break; } case WAR_ACTION_STEP_ATTACK: { action->lastActionStep = WAR_ACTION_STEP_ATTACK; break; } case WAR_ACTION_STEP_SOUND_SWORD: case WAR_ACTION_STEP_SOUND_FIST: case WAR_ACTION_STEP_SOUND_FIREBALL: case WAR_ACTION_STEP_SOUND_CHOPPING: case WAR_ACTION_STEP_SOUND_CATAPULT: case WAR_ACTION_STEP_SOUND_ARROW: case WAR_ACTION_STEP_SOUND_LIGHTNING: { action->lastSoundStep = step.type; break; } default: { break; } } action->stepIndex++; if (action->stepIndex >= actionDef->steps.count) { if (!actionDef->loop) { action->status = WAR_ACTION_FINISHED; return; } action->stepIndex = 0; } step = actionDef->steps.items[action->stepIndex]; } action->waitCount = __frameCountToSeconds(step.param) * action->scale; } void wact_resetAction(WarContext* context, WarEntity* entity, WarUnitActionType type) { assert(wu_isUnit(entity)); WarUnitComponent* unit = we_getUnitComponent(context, entity); WarUnitAction* action = &unit->actions[type]; resetAction(action); } ================================================ FILE: src/war_actions.h ================================================ #pragma once #include "shl/list.h" #include "war_fwd.h" #include "war_math.h" struct _WarUnitActionStep { WarUnitActionStepType type; s32 param; }; #define WarUnitActionStepEmpty (WarUnitActionStep){WAR_ACTION_STEP_NONE} bool wact_equalsActionStep(const WarUnitActionStep step1, const WarUnitActionStep step2); shlDeclareList(WarUnitActionStepList, WarUnitActionStep) #define WarUnitActionStepListDefaultOptions (WarUnitActionStepListOptions){WarUnitActionStepEmpty, wact_equalsActionStep, NULL} struct _WarUnitActionDef { WarUnitActionType type; bool directional; bool loop; WarUnitActionStepList steps; }; struct _WarUnitAction { WarUnitActionStatus status; f32 scale; f32 waitCount; s32 stepIndex; WarUnitActionStepType lastActionStep; WarUnitActionStepType lastSoundStep; }; void wact_initUnitActionDefs(void); void wact_addUnitActions(WarContext* context, WarEntity* entity); s32 wact_getActionDuration(WarContext* context, WarEntity* entity, WarUnitActionType type); void wact_setAction(WarContext* context, WarEntity* entity, WarUnitActionType type, bool reset, f32 scale); void wact_updateAction(WarContext* context, WarEntity* entity); void wact_resetAction(WarContext* context, WarEntity* entity, WarUnitActionType type); ================================================ FILE: src/war_ai.c ================================================ #include "war_ai.h" #include bool wai_equalsAICommand(const WarAICommand* command1, const WarAICommand* command2) { return command1->id == command2->id; } void wai_freeAICommand(WarAICommand* command) { wm_free((void*)command); } shlDefineQueue(WarAICommandQueue, WarAICommand*) shlDefineList(WarAICommandList, WarAICommand*) WarAI* wai_createAI(WarContext* context) { NOT_USED(context); WarAI* ai = (WarAI*)wm_alloc(sizeof(WarAI)); ai->staticCommandId = 0; ai->customData = NULL; WarAICommandListInit(&ai->currentCommands, WarAICommandListDefaultOptions); WarAICommandQueueInit(&ai->nextCommands, WarAICommandQueueDefaultOptions); return ai; } WarAICommand* wai_createAICommand(WarContext* context, WarPlayerInfo* aiPlayer, WarAICommandType type) { NOT_USED(context); WarAI* ai = aiPlayer->ai; assert(ai); WarAICommand* command = (WarAICommand*)wm_alloc(sizeof(WarAICommand)); command->id = ++ai->staticCommandId; command->type = type; command->status = WAR_AI_COMMAND_STATUS_CREATED; return command; } WarAICommand* wai_createUnitRequest(WarContext* context, WarPlayerInfo* aiPlayer, WarUnitType unitType, s32 count) { WarAICommand* request = wai_createAICommand(context, aiPlayer, WAR_AI_COMMAND_REQUEST); request->request.unitType = unitType; request->request.count = count; return request; } WarAICommand* wai_createWaitForUnit(WarContext* context, WarPlayerInfo* aiPlayer, WarUnitType unitType, s32 count) { WarAICommand* wait = wai_createAICommand(context, aiPlayer, WAR_AI_COMMAND_WAIT); wait->wait.unitType = unitType; wait->wait.count = count; return wait; } WarAICommand* wai_createSleepForTime(WarContext* context, WarPlayerInfo* aiPlayer, f32 time) { WarAICommand* sleep = wai_createAICommand(context, aiPlayer, WAR_AI_COMMAND_SLEEP); sleep->sleep.time = time; return sleep; } typedef struct { s32 index; WarAICommandList commands; } WarAICustomData; void wai_initAI(WarContext* context, WarPlayerInfo* aiPlayer) { WarAI* ai = aiPlayer->ai; assert(ai); WarAICustomData* customData = (WarAICustomData*)wm_alloc(sizeof(WarAICustomData)); customData->index = 0; WarAICommandList* commands = &customData->commands; WarAICommandListInit(commands, WarAICommandListDefaultOptions); WarUnitType townHall = wu_getUnitTypeForRace(WAR_UNIT_TOWNHALL_HUMANS, aiPlayer->race); WarAICommandListAdd(commands, wai_createUnitRequest(context, aiPlayer, townHall, 1)); WarAICommandListAdd(commands, wai_createWaitForUnit(context, aiPlayer, townHall, 1)); WarUnitType worker = wu_getUnitTypeForRace(WAR_UNIT_PEASANT, aiPlayer->race); WarAICommandListAdd(commands, wai_createUnitRequest(context, aiPlayer, worker, 2)); WarAICommandListAdd(commands, wai_createWaitForUnit(context, aiPlayer, worker, 2)); WarAICommandListAdd(commands, wai_createUnitRequest(context, aiPlayer, worker, 2)); WarAICommandListAdd(commands, wai_createWaitForUnit(context, aiPlayer, worker, 4)); ai->customData = customData; } WarAICommand* wai_getNextAICommand(WarContext* context, WarPlayerInfo* aiPlayer) { WarAI* ai = aiPlayer->ai; assert(ai); WarAICustomData* customData = (WarAICustomData*)ai->customData; assert(customData); if (customData->index < customData->commands.count) { return customData->commands.items[customData->index++]; } return wai_createSleepForTime(context, aiPlayer, 10.0f); } void wai_initAIPlayer(WarContext* context, WarPlayerInfo* aiPlayer) { aiPlayer->ai = wai_createAI(context); wai_initAI(context, aiPlayer); } void wai_initAIPlayers(WarContext* context) { WarMap* map = context->map; // for now assume player 1 is the only AI wai_initAIPlayer(context, &map->players[1]); } bool wai_tryCreateUnit(WarContext* context, WarPlayerInfo* aiPlayer, WarUnitType unitType) { if (wu_isDudeUnitType(unitType)) { const WarUnitStats* stats = wu_getUnitStats(unitType); if (!we_enoughPlayerResources(context, aiPlayer, stats->goldCost, stats->woodCost)) { // there is not enough resources to create the unit return false; } // check if there is enough food if (!we_enoughFarmFood(context, aiPlayer)) { // set a request for supply because there is not enough food return false; } WarUnitType producerType = wu_getProducerUnitOfType(unitType); if (wu_isValidUnitType(producerType)) { WarEntityList* units = we_getUnitsOfType(context, producerType); for (s32 i = 0; i < units->count; i++) { WarEntity* entity = units->items[i]; if (entity) { WarUnitComponent* unit = we_getUnitComponent(context, entity); assert(unit); if (unit->player == aiPlayer->index) { if (!wst_isTraining(context, entity) && !wst_isUpgrading(context, entity)) { if (we_decreasePlayerResources(context, aiPlayer, stats->goldCost, stats->woodCost)) { WarState* trainState = wst_createTrainState(context, entity, unitType, (f32)stats->buildTime); wst_changeNextState(context, entity, trainState, true, true); } return true; } } } } } // if there is no building to train the unit or all of them are busy // let the request live to try again later return false; } if (wu_isBuildingUnitType(unitType)) { // find a free worker // find a place to build // send worker to build the building // if there is no free worker, try to get one assigned to a resource // at the worst case, the building can't be built right now, so // let the request live to try again later return true; } logWarning("Unkown unit type %d to be built by player %d", unitType, aiPlayer->index); return false; } bool wai_executeRequestAICommand(WarContext* context, WarPlayerInfo* aiPlayer, WarAICommand* command) { command->status = WAR_AI_COMMAND_STATUS_STARTED; if (wai_tryCreateUnit(context, aiPlayer, command->request.unitType)) { command->request.count--; if (command->request.count == 0) { command->status = WAR_AI_COMMAND_STATUS_COMPLETED; } } return true; } bool wai_executeWaitAICommand(WarContext* context, WarPlayerInfo* aiPlayer, WarAICommand* command) { command->status = WAR_AI_COMMAND_STATUS_STARTED; s32 numberOfUnits = wu_getNumberOfUnitsOfType(context, aiPlayer->index, command->wait.unitType); if (numberOfUnits >= command->wait.count) { command->status = WAR_AI_COMMAND_STATUS_COMPLETED; return true; } return false; } bool wai_executeSleepAICommand(WarContext* context, WarPlayerInfo* aiPlayer, WarAICommand* command) { NOT_USED(aiPlayer); command->status = WAR_AI_COMMAND_STATUS_STARTED; command->sleep.time -= context->deltaTime; if (command->sleep.time <= 0) { command->status = WAR_AI_COMMAND_STATUS_COMPLETED; return true; } return false; } bool wai_executeAICommand(WarContext* context, WarPlayerInfo* aiPlayer, WarAICommand* command) { if (command->status == WAR_AI_COMMAND_STATUS_COMPLETED) { return true; } switch (command->type) { case WAR_AI_COMMAND_REQUEST: { return wai_executeRequestAICommand(context, aiPlayer, command); } case WAR_AI_COMMAND_WAIT: { return wai_executeWaitAICommand(context, aiPlayer, command); } case WAR_AI_COMMAND_SLEEP: { return wai_executeSleepAICommand(context, aiPlayer, command); } default: { logWarning("AI commands of type %d are NOT handled yet", command->type); return true; } } } bool wai_updateAICurrentCommands(WarContext* context, WarPlayerInfo* aiPlayer) { WarAI* ai = aiPlayer->ai; assert(ai); bool updateNext = true; WarAICommandList* commands = &ai->currentCommands; for (s32 i = 0; i < commands->count; i++) { WarAICommand* command = commands->items[i]; if (!wai_executeAICommand(context, aiPlayer, command)) { updateNext = false; } } return updateNext; } void wai_updateAINextCommands(WarContext* context, WarPlayerInfo* aiPlayer) { NOT_USED(context); WarAI* ai = aiPlayer->ai; assert(ai); #define isWaitOrSleep(command) ((command)->type == WAR_AI_COMMAND_WAIT || (command)->type == WAR_AI_COMMAND_SLEEP) WarAICommandList* currentCommands = &ai->currentCommands; WarAICommandQueue* nextCommands = &ai->nextCommands; if (nextCommands->count > 0) { WarAICommand* command = NULL; do { command = WarAICommandQueuePop(nextCommands); WarAICommandListAdd(currentCommands, command); } while (nextCommands->count > 0 && !isWaitOrSleep(command)); } #undef isWaitOrSleep } void wai_removeCompletedAICommands(WarContext* context, WarPlayerInfo* aiPlayer) { NOT_USED(context); WarAI* ai = aiPlayer->ai; assert(ai); WarAICommandList* commands = &ai->currentCommands; for (s32 i = commands->count - 1; i >= 0; i--) { WarAICommand* command = commands->items[i]; if (command->status == WAR_AI_COMMAND_STATUS_COMPLETED) { WarAICommandListRemoveAt(commands, i); } } } void wai_updateAIPlayer(WarContext* context, WarPlayerInfo* aiPlayer) { WarAI* ai = aiPlayer->ai; assert(ai); if (wai_updateAICurrentCommands(context, aiPlayer)) { WarAICommand* command = wai_getNextAICommand(context, aiPlayer); if (command) { WarAICommandQueuePush(&ai->nextCommands, command); } wai_updateAINextCommands(context, aiPlayer); } wai_removeCompletedAICommands(context, aiPlayer); } void wai_updateAIPlayers(WarContext* context) { TracyCZoneN(ctx, "UpdateAI", 1); WarMap* map = context->map; // for now assume player 1 is the only AI wai_updateAIPlayer(context, &map->players[1]); TracyCZoneEnd(ctx); } ================================================ FILE: src/war_ai.h ================================================ #pragma once #include "shl/list.h" #include "shl/queue.h" #include "war_units.h" struct _WarAICommand { u32 id; WarAICommandType type; WarAICommandStatus status; union { struct { WarUnitType unitType; s32 count; } request; struct { WarUnitType unitType; s32 count; } wait; struct { f32 time; } sleep; }; }; bool wai_equalsAICommand(const WarAICommand* command1, const WarAICommand* command2); void wai_freeAICommand(WarAICommand* command); shlDeclareQueue(WarAICommandQueue, WarAICommand*) shlDeclareList(WarAICommandList, WarAICommand*) #define WarAICommandListDefaultOptions ((WarAICommandListOptions){NULL, wai_equalsAICommand, wai_freeAICommand}) #define WarAICommandQueueDefaultOptions ((WarAICommandQueueOptions){NULL, wai_equalsAICommand, wai_freeAICommand}) struct _WarAI { u32 staticCommandId; WarAICommandList currentCommands; WarAICommandQueue nextCommands; void* customData; }; WarAI* wai_createAI(WarContext* context); WarAICommand* wai_createAICommand(WarContext* context, WarPlayerInfo* aiPlayer, WarAICommandType type); WarAICommand* wai_createUnitRequest(WarContext* context, WarPlayerInfo* aiPlayer, WarUnitType unitType, s32 count); WarAICommand* wai_createWaitForUnit(WarContext* context, WarPlayerInfo* aiPlayer, WarUnitType unitType, s32 count); WarAICommand* wai_createSleepForTime(WarContext* context, WarPlayerInfo* aiPlayer, f32 time); void wai_initAIPlayers(WarContext* context); void wai_updateAIPlayers(WarContext* context); ================================================ FILE: src/war_alloc.c ================================================ #include #include #include #define SHL_MZ_IMPLEMENTATION #ifdef SHL_MZ_DEBUG # define SHL_MZ_AUDIT_IMPLEMENTATION # include "shl/memzone_audit.h" #else # include "shl/memzone.h" #endif #include "war_alloc.h" #include "war_log.h" memzone_t* globalZone = NULL; memzone_t* frameZone = NULL; memzone_t* audioZone = NULL; static void zoneReporter(const memzone_t* zone, mz_report_t report, const void* ptr, const char* message, void* userData) { NOT_USED(userData); const char* zoneName = "unknown"; if (zone == globalZone) zoneName = "globalZone"; else if (zone == frameZone) zoneName = "frameZone"; else if (zone == audioZone) zoneName = "audioZone"; const char* reportName = NULL; switch (report) { case MZ_REPORT_ALLOCATION_FAILURE: reportName = "allocation failure"; break; case MZ_REPORT_INVALID_FREE: reportName = "invalid free"; break; case MZ_REPORT_VALIDATION_FAILURE: reportName = "validation failure"; break; default: reportName = "unknown"; break; } logError("Memory zone report [%s]: %s, %s, for %p.", zoneName, reportName, message, ptr); } static bool initZone(size_t size, const char* logFileName, memzone_t** outZone) { #ifdef SHL_MZ_DEBUG *outZone = mz_initAudit(size, SHL_MZ_AUDIT_FORMAT_COMPACT, logFileName); #else *outZone = mz_init(size); #endif return *outZone; } static bool isInZone(memzone_t* zone, void* p) { if (!zone || !p) return false; uintptr_t ptr = (uintptr_t)p; uintptr_t z = (uintptr_t)zone; // maxSize is exactly the size of the whole allocated block return ptr >= z && ptr < (z + mz_maxSize(zone)); } static void* allocInZone(memzone_t* zone, size_t sz, const char* file, int line) { #ifdef SHL_MZ_DEBUG return mz__audit_alloc(zone, sz, file, line); #else NOT_USED(file); NOT_USED(line); return mz_alloc(zone, sz); #endif } static void* reallocInZone(memzone_t* zone, void* p, size_t sz, const char* file, int line) { #ifdef SHL_MZ_DEBUG return mz__audit_realloc(zone, p, sz, file, line); #else NOT_USED(file); NOT_USED(line); return mz_realloc(zone, p, sz); #endif } static void freeInZone(memzone_t* zone, void* p, const char* file, int line) { #ifdef SHL_MZ_DEBUG mz__audit_free(zone, p, file, line); #else NOT_USED(file); NOT_USED(line); mz_free(zone, p); #endif } bool wm_allocInit(size_t globalSize, size_t frameSize, size_t audioSize) { if (!initZone(globalSize, "global_zone.log", &globalZone)) { logError("Failed to initialize globalZone."); return false; } if (!initZone(frameSize, "frame_zone.log", &frameZone)) { logError("Failed to initialize frameZone."); mz_destroy(globalZone); globalZone = NULL; return false; } if (!initZone(audioSize, "audio_zone.log", &audioZone)) { logError("Failed to initialize audioZone."); mz_destroy(globalZone); mz_destroy(frameZone); globalZone = NULL; frameZone = NULL; return false; } mz_setReporter(globalZone, zoneReporter, NULL); mz_setReporter(frameZone, zoneReporter, NULL); mz_setReporter(audioZone, zoneReporter, NULL); return true; } void wm_allocFree(void) { if (globalZone) mz_destroy(globalZone); if (frameZone) mz_destroy(frameZone); if (audioZone) mz_destroy(audioZone); globalZone = NULL; frameZone = NULL; audioZone = NULL; } void* wm__alloc(size_t sz, const char* file, int line) { return allocInZone(globalZone, sz, file, line); } void* wm__allocFrame(size_t sz, const char* file, int line) { return allocInZone(frameZone, sz, file, line); } void* wm__allocAudio(size_t sz, const char* file, int line) { return allocInZone(audioZone, sz, file, line); } void* wm__realloc(void* p, size_t sz, const char* file, int line) { if (!p) return wm__alloc(sz, file, line); if (sz == 0) { wm__free(p, file, line); return NULL; } if (isInZone(globalZone, p)) { return reallocInZone(globalZone, p, sz, file, line); } if (isInZone(frameZone, p)) { return reallocInZone(frameZone, p, sz, file, line); } // fallback, if it's external or stdlib allocated NOT_USED(file); NOT_USED(line); return realloc(p, sz); } void* wm__reallocAudio(void* p, size_t sz, const char* file, int line) { if (!p) return wm__allocAudio(sz, file, line); if (sz == 0) { wm__free(p, file, line); return NULL; } return reallocInZone(audioZone, p, sz, file, line); } void wm__free(void* p, const char* file, int line) { if (!p) return; if (isInZone(globalZone, p)) { freeInZone(globalZone, p, file, line); } else if (isInZone(frameZone, p)) { freeInZone(frameZone, p, file, line); } else if (isInZone(audioZone, p)) { freeInZone(audioZone, p, file, line); } else { NOT_USED(file); NOT_USED(line); free(p); // fallback } } ================================================ FILE: src/war_alloc.h ================================================ #pragma once #include #include // Forward declare memzone_t typedef struct memzone_s memzone_t; // Global allocators extern memzone_t* globalZone; extern memzone_t* frameZone; extern memzone_t* audioZone; bool wm_allocInit(size_t globalSize, size_t frameSize, size_t audioSize); void wm_allocFree(void); // Internal macro targets; prefer the wm_* macros below. void* wm__alloc(size_t sz, const char* file, int line); void* wm__allocFrame(size_t sz, const char* file, int line); void* wm__allocAudio(size_t sz, const char* file, int line); void* wm__realloc(void* p, size_t sz, const char* file, int line); void* wm__reallocAudio(void* p, size_t sz, const char* file, int line); void wm__free(void* p, const char* file, int line); #define wm_alloc(sz) wm__alloc((sz), __FILE__, __LINE__) #define wm_allocFrame(sz) wm__allocFrame((sz), __FILE__, __LINE__) #define wm_allocAudio(sz) wm__allocAudio((sz), __FILE__, __LINE__) #define wm_realloc(p, sz) wm__realloc((p), (sz), __FILE__, __LINE__) #define wm_reallocAudio(p, sz) wm__reallocAudio((p), (sz), __FILE__, __LINE__) #define wm_free(p) wm__free((p), __FILE__, __LINE__) ================================================ FILE: src/war_animations.c ================================================ #include "shl/wstr.h" #include #include "war_animations.h" #include "war_sprites.h" #include "war_resources.h" #define ANIM_NAME_MAX_LENGTH 50 bool wanim_equalsSpriteAnimation(const WarSpriteAnimation* anim1, const WarSpriteAnimation* anim2) { return wsv_equals(wstr_view(&anim1->name), wstr_view(&anim2->name)); } shlDefineList(WarSpriteAnimationList, WarSpriteAnimation*) WarSpriteAnimation* wanim_createAnimation(WarContext* context, String name, WarSprite sprite, f32 frameDelay, bool loop) { NOT_USED(context); WarSpriteAnimation* anim = (WarSpriteAnimation*)wm_alloc(sizeof(WarSpriteAnimation)); anim->name = name; anim->loop = loop; anim->offset = VEC2_ZERO; anim->scale = VEC2_ONE; anim->frameDelay = frameDelay; anim->sprite = sprite; anim->animTime = 0; anim->loopTime = 0; anim->status = WAR_ANIM_STATUS_NOT_STARTED; s32ListInit(&anim->frames, s32ListDefaultOptions); return anim; } WarSpriteAnimation* wanim_createAnimationFromResourceIndex(WarContext* context, String name, WarSpriteResourceRef spriteResourceRef, f32 frameDelay, bool loop) { WarSprite sprite = wspr_createSpriteFromResourceIndex(context, spriteResourceRef); return wanim_createAnimation(context, name, sprite, frameDelay, loop); } void wanim_addAnimation(WarContext* context, WarEntity* entity, WarSpriteAnimation* animation) { WarAnimationsComponent* animations = we_getAnimationsComponent(context, entity); assert(animations); WarSpriteAnimationListAdd(&animations->animations, animation); } void wanim_addAnimationFrame(WarSpriteAnimation* animation, s32 frameIndex) { s32ListAdd(&animation->frames, frameIndex); } void wanim_addAnimationFrames(WarSpriteAnimation* animation, s32 count, s32 frameIndices[]) { if (frameIndices) { for(s32 i = 0; i < count; i++) wanim_addAnimationFrame(animation, frameIndices[i]); } else { for(s32 i = 0; i < count; i++) wanim_addAnimationFrame(animation, i); } } void wanim_addAnimationFramesRange(WarSpriteAnimation* animation, s32 from, s32 to) { if (from < to) { for (s32 i = from; i <= to; i++) wanim_addAnimationFrame(animation, i); } else { for (s32 i = from; i >= to; i--) wanim_addAnimationFrame(animation, i); } } f32 wanim_getAnimationDuration(WarSpriteAnimation* animation) { return animation->frameDelay * animation->frames.count; } void wanim_freeAnimation(WarSpriteAnimation* animation) { if (animation) { s32ListFree(&animation->frames); wm_free(animation); } } s32 wanim_findAnimationIndex(WarContext* context, WarEntity* entity, StringView name) { NOT_USED(context); s32 index = -1; WarAnimationsComponent* animations = we_getAnimationsComponent(context, entity); assert(animations); for(s32 i = 0; i < animations->animations.count; i++) { WarSpriteAnimation* anim = animations->animations.items[i]; if (wsv_equals(wstr_view(&anim->name), name)) { index = i; break; } } return index; } void wanim_removeAnimation(WarContext* context, WarEntity* entity, StringView name) { logInfo("Trying to remove animation: %s", name); s32 index = wanim_findAnimationIndex(context, entity, name); if (index >= 0) { WarAnimationsComponent* animations = we_getAnimationsComponent(context, entity); assert(animations); WarSpriteAnimationListRemoveAt(&animations->animations, index); } } void wanim_resetAnimation(WarSpriteAnimation* animation) { animation->animTime = 0; animation->loopTime = 0; animation->status = WAR_ANIM_STATUS_NOT_STARTED; } void wanim_updateAnimation(WarContext* context, WarEntity* entity, WarSpriteAnimation* animation) { if (animation->status == WAR_ANIM_STATUS_FINISHED) { wanim_removeAnimation(context, entity, wstr_view(&animation->name)); return; } animation->status = WAR_ANIM_STATUS_RUNNING; if (animation->loopTime > 0) { if (context->scene) animation->loopTime -= getScaledSpeed(context, context->deltaTime); else if (context->map) animation->loopTime -= wmap_getMapScaledSpeed(context, context->deltaTime); return; } f32 dt = context->deltaTime / wanim_getAnimationDuration(animation); if (context->scene) dt = getScaledSpeed(context, dt); else if (context->map) dt = wmap_getMapScaledSpeed(context, dt); animation->animTime += dt; if (animation->animTime >= 1) { animation->animTime = 1; animation->status = WAR_ANIM_STATUS_FINISHED; if(animation->loop) { wanim_resetAnimation(animation); animation->loopTime = animation->loopDelay; animation->status = WAR_ANIM_STATUS_RUNNING; } } } void wanim_updateAnimations(WarContext* context) { TracyCZoneN(ctx, "UpdateAnimations", 1); WarEntityManager* manager = we_getEntityManager(context); assert(manager); for(s32 i = 0; i < MAX_ENTITIES_COUNT; i++) { WarEntity* entity = &manager->entities[i]; if (entity->id != 0 && we_isComponentEnabled(context, entity, COMP_ANIMATIONS)) { WarAnimationsComponent* animations = we_getAnimationsComponent(context, entity); for(s32 k = 0; k < animations->animations.count; k++) { WarSpriteAnimation* anim = animations->animations.items[k]; wanim_updateAnimation(context, entity, anim); } } } TracyCZoneEnd(ctx); } WarSpriteAnimation* wanim_findAnimation(WarContext* context, WarEntity* entity, StringView name) { NOT_USED(context); WarAnimationsComponent* animations = we_getAnimationsComponent(context, entity); assert(animations); for(s32 i = 0; i < animations->animations.count; i++) { WarSpriteAnimation* anim = animations->animations.items[i]; if (wsv_equals(wstr_view(&anim->name), name)) { return anim; } } return NULL; } bool wanim_containsAnimation(WarContext* context, WarEntity* entity, StringView name) { return wanim_findAnimationIndex(context, entity, name) >= 0; } WarSpriteAnimation* wanim_createDamageAnimation(WarContext* context, WarEntity* entity, String name, int damageLevel) { s32 resourceIndex = damageLevel == 1 ? WAR_BUILDING_DAMAGE_1_RESOURCE : WAR_BUILDING_DAMAGE_2_RESOURCE; WarSpriteResourceRef spriteResourceRef = imageResourceRef(resourceIndex); WarSprite sprite = wspr_createSpriteFromResourceIndex(context, spriteResourceRef); WarSpriteAnimation* anim = wanim_createAnimation(context, name, sprite, 0.2f, true); anim->offset = vec2_subv(wu_getUnitSpriteCenter(context, entity), vec2i(sprite.frameWidth/2, sprite.frameHeight)); for(s32 i = 0; i < 4; i++) wanim_addAnimationFrame(anim, i); wanim_addAnimation(context, entity, anim); return anim; } WarSpriteAnimation* wanim_createCollapseAnimation(WarContext* context, WarEntity* entity, String name) { vec2 unitFrameSize = wu_getUnitFrameSize(context, entity); vec2 unitSpriteSize = wu_getUnitSpriteSize(context, entity); WarSpriteResourceRef spriteResourceRef = imageResourceRef(WAR_BUILDING_COLLAPSE_RESOURCE); WarSprite sprite = wspr_createSpriteFromResourceIndex(context, spriteResourceRef); WarSpriteAnimation* anim = wanim_createAnimation(context, name, sprite, 0.1f, false); vec2 animFrameSize = vec2i(anim->sprite.frameWidth, anim->sprite.frameHeight); // this is the scale of the explosion animation sprites with respect to the size of the building f32 animScale = unitSpriteSize.x / animFrameSize.x; // if the offset is based on the size of the frame, and it's scaled, then the offset must take into // account the scale to make the calculations f32 offsetx = 0.5f * (unitFrameSize.x - unitSpriteSize.x); f32 offsety = 0.5f * (unitFrameSize.y - unitSpriteSize.y) - (animFrameSize.y * animScale - unitSpriteSize.y); anim->scale = vec2f(animScale, animScale); anim->offset = vec2f(offsetx, offsety); for(s32 i = 0; i < 17; i++) wanim_addAnimationFrame(anim, i); wanim_addAnimation(context, entity, anim); return anim; } WarSpriteAnimation* wanim_createExplosionAnimation(WarContext* context, WarEntity* entity, vec2 position) { WarSpriteResourceRef spriteResourceRef = imageResourceRef(WAR_EXPLOSION_RESOURCE); WarSprite sprite = wspr_createSpriteFromResourceIndex(context, spriteResourceRef); String name = wstr_make(); wstr_appendFormat(&name, "explosion_%.2f_%.2f", position.x, position.y); WarSpriteAnimation* anim = wanim_createAnimation(context, name, sprite, 0.1f, false); f32 offsetx = position.x - 0.5f * sprite.frameWidth; f32 offsety = position.y - 0.5f * sprite.frameHeight; anim->offset = vec2f(offsetx, offsety); for(s32 i = 0; i < 6; i++) wanim_addAnimationFrame(anim, i); wanim_addAnimation(context, entity, anim); return anim; } WarSpriteAnimation* wanim_createRainOfFireExplosionAnimation(WarContext* context, WarEntity* entity, vec2 position) { WarSpriteResourceRef spriteResourceRef = imageResourceRef(WAR_RAIN_OF_FIRE_EXPLOSION_RESOURCE); WarSprite sprite = wspr_createSpriteFromResourceIndex(context, spriteResourceRef); String name = wstr_make(); wstr_appendFormat(&name, "explosion_%.2f_%.2f", position.x, position.y); WarSpriteAnimation* anim = wanim_createAnimation(context, name, sprite, 0.1f, false); f32 offsetx = position.x - 0.5f * sprite.frameWidth; f32 offsety = position.y - 0.5f * sprite.frameHeight; anim->offset = vec2f(offsetx, offsety); for(s32 i = 3; i < 6; i++) wanim_addAnimationFrame(anim, i); wanim_addAnimation(context, entity, anim); return anim; } WarSpriteAnimation* wanim_createSpellAnimation(WarContext* context, WarEntity* entity, vec2 position) { WarSpriteResourceRef spriteResourceRef = imageResourceRef(WAR_SPELL_RESOURCE); WarSprite sprite = wspr_createSpriteFromResourceIndex(context, spriteResourceRef); String name = wstr_make(); wstr_appendFormat(&name, "spell_%.2f_%.2f", position.x, position.y); WarSpriteAnimation* anim = wanim_createAnimation(context, name, sprite, 0.4f, false); f32 offsetx = position.x - 0.5f * sprite.frameWidth; f32 offsety = position.y - 0.5f * sprite.frameHeight; anim->offset = vec2f(offsetx, offsety); for(s32 i = 0; i < 6; i++) wanim_addAnimationFrame(anim, i); wanim_addAnimation(context, entity, anim); return anim; } WarSpriteAnimation* wanim_createPoisonCloudAnimation(WarContext* context, WarEntity* entity, vec2 position) { WarSpriteResourceRef spriteResourceRef = imageResourceRef(WAR_POISON_CLOUD_RESOURCE); WarSprite sprite = wspr_createSpriteFromResourceIndex(context, spriteResourceRef); String name = wstr_make(); wstr_appendFormat(&name, "poison_cloud_%.2f_%.2f", position.x, position.y); WarSpriteAnimation* anim = wanim_createAnimation(context, name, sprite, 0.5f, true); f32 offsetx = position.x - 0.5f * sprite.frameWidth; f32 offsety = position.y - 0.5f * sprite.frameHeight; anim->offset = vec2f(offsetx, offsety); for(s32 i = 0; i < 4; i++) wanim_addAnimationFrame(anim, i); wanim_addAnimation(context, entity, anim); return anim; } ================================================ FILE: src/war_animations.h ================================================ #pragma once #include "shl/list.h" #include "common.h" #include "war_sprites.h" struct _WarSpriteAnimation { String name; bool loop; f32 loopDelay; vec2 offset; vec2 scale; f32 frameDelay; s32List frames; WarSprite sprite; f32 animTime; f32 loopTime; WarAnimationStatus status; }; bool wanim_equalsSpriteAnimation(const WarSpriteAnimation* anim1, const WarSpriteAnimation* anim2); shlDeclareList(WarSpriteAnimationList, WarSpriteAnimation*) #define WarSpriteAnimationListDefaultOptions (WarSpriteAnimationListOptions){NULL, wanim_equalsSpriteAnimation, wanim_freeAnimation} WarSpriteAnimation* wanim_createAnimation(WarContext* context, String name, WarSprite sprite, f32 frameDelay, bool loop); WarSpriteAnimation* wanim_createAnimationFromResourceIndex(WarContext* context, String name, WarSpriteResourceRef spriteResourceRef, f32 frameDelay, bool loop); void wanim_addAnimation(WarContext* context, WarEntity* entity, WarSpriteAnimation* animation); void wanim_addAnimationFrame(WarSpriteAnimation* animation, s32 frameIndex); void wanim_addAnimationFrames(WarSpriteAnimation* animation, s32 count, s32 frameIndices[]); void wanim_addAnimationFramesRange(WarSpriteAnimation* animation, s32 from, s32 to); f32 wanim_getAnimationDuration(WarSpriteAnimation* animation); void wanim_freeAnimation(WarSpriteAnimation* animation); void wanim_removeAnimation(WarContext* context, WarEntity* entity, StringView name); void wanim_updateAnimations(WarContext* context); WarSpriteAnimation* wanim_findAnimation(WarContext* context, WarEntity* entity, StringView name); bool wanim_containsAnimation(WarContext* context, WarEntity* entity, StringView name); WarSpriteAnimation* wanim_createDamageAnimation(WarContext* context, WarEntity* entity, String name, int damageLevel); WarSpriteAnimation* wanim_createCollapseAnimation(WarContext* context, WarEntity* entity, String name); WarSpriteAnimation* wanim_createExplosionAnimation(WarContext* context, WarEntity* entity, vec2 position); WarSpriteAnimation* wanim_createRainOfFireExplosionAnimation(WarContext* context, WarEntity* entity, vec2 position); WarSpriteAnimation* wanim_createSpellAnimation(WarContext* context, WarEntity* entity, vec2 position); WarSpriteAnimation* wanim_createPoisonCloudAnimation(WarContext* context, WarEntity* entity, vec2 position); ================================================ FILE: src/war_audio.c ================================================ #include "war_audio.h" #include #include "SDL3/SDL.h" #include "shl/memory_buffer.h" #include "shl/memzone.h" #include "war_log.h" #include "war_math.h" #include "war_entities.h" #include "war_units.h" typedef struct { WarAudioId id; WarAudioType type; } WarAudioData; WarAudioData audioData[] = { { WAR_MUSIC_00, WAR_AUDIO_MIDI }, { WAR_MUSIC_01, WAR_AUDIO_MIDI }, { WAR_MUSIC_02, WAR_AUDIO_MIDI }, { WAR_MUSIC_03, WAR_AUDIO_MIDI }, { WAR_MUSIC_04, WAR_AUDIO_MIDI }, { WAR_MUSIC_05, WAR_AUDIO_MIDI }, { WAR_MUSIC_06, WAR_AUDIO_MIDI }, { WAR_MUSIC_07, WAR_AUDIO_MIDI }, { WAR_MUSIC_08, WAR_AUDIO_MIDI }, { WAR_MUSIC_09, WAR_AUDIO_MIDI }, { WAR_MUSIC_10, WAR_AUDIO_MIDI }, { WAR_MUSIC_11, WAR_AUDIO_MIDI }, { WAR_MUSIC_12, WAR_AUDIO_MIDI }, { WAR_MUSIC_13, WAR_AUDIO_MIDI }, { WAR_MUSIC_14, WAR_AUDIO_MIDI }, { WAR_MUSIC_15, WAR_AUDIO_MIDI }, { WAR_MUSIC_16, WAR_AUDIO_MIDI }, { WAR_MUSIC_17, WAR_AUDIO_MIDI }, { WAR_MUSIC_18, WAR_AUDIO_MIDI }, { WAR_MUSIC_19, WAR_AUDIO_MIDI }, { WAR_MUSIC_20, WAR_AUDIO_MIDI }, { WAR_MUSIC_21, WAR_AUDIO_MIDI }, { WAR_MUSIC_22, WAR_AUDIO_MIDI }, { WAR_MUSIC_23, WAR_AUDIO_MIDI }, { WAR_MUSIC_24, WAR_AUDIO_MIDI }, { WAR_MUSIC_25, WAR_AUDIO_MIDI }, { WAR_MUSIC_26, WAR_AUDIO_MIDI }, { WAR_MUSIC_27, WAR_AUDIO_MIDI }, { WAR_MUSIC_28, WAR_AUDIO_MIDI }, { WAR_MUSIC_29, WAR_AUDIO_MIDI }, { WAR_MUSIC_30, WAR_AUDIO_MIDI }, { WAR_MUSIC_31, WAR_AUDIO_MIDI }, { WAR_MUSIC_32, WAR_AUDIO_MIDI }, { WAR_MUSIC_33, WAR_AUDIO_MIDI }, { WAR_MUSIC_34, WAR_AUDIO_MIDI }, { WAR_MUSIC_35, WAR_AUDIO_MIDI }, { WAR_MUSIC_36, WAR_AUDIO_MIDI }, { WAR_MUSIC_37, WAR_AUDIO_MIDI }, { WAR_MUSIC_38, WAR_AUDIO_MIDI }, { WAR_MUSIC_39, WAR_AUDIO_MIDI }, { WAR_MUSIC_40, WAR_AUDIO_MIDI }, { WAR_MUSIC_41, WAR_AUDIO_MIDI }, { WAR_MUSIC_42, WAR_AUDIO_MIDI }, { WAR_MUSIC_43, WAR_AUDIO_MIDI }, { WAR_MUSIC_44, WAR_AUDIO_MIDI }, { WAR_LOGO, WAR_AUDIO_WAVE }, { WAR_INTRO_DOOR, WAR_AUDIO_WAVE }, { WAR_BUILDING, WAR_AUDIO_WAVE }, { WAR_EXPLOSION, WAR_AUDIO_WAVE }, { WAR_CATAPULT_ROCK_FIRED, WAR_AUDIO_WAVE }, { WAR_TREE_CHOPPING_1, WAR_AUDIO_WAVE }, { WAR_TREE_CHOPPING_2, WAR_AUDIO_WAVE }, { WAR_TREE_CHOPPING_3, WAR_AUDIO_WAVE }, { WAR_TREE_CHOPPING_4, WAR_AUDIO_WAVE }, { WAR_BUILDING_COLLAPSE_1, WAR_AUDIO_WAVE }, { WAR_BUILDING_COLLAPSE_2, WAR_AUDIO_WAVE }, { WAR_BUILDING_COLLAPSE_3, WAR_AUDIO_WAVE }, { WAR_UI_CHIME, WAR_AUDIO_WAVE }, { WAR_UI_CLICK, WAR_AUDIO_WAVE }, { WAR_UI_CANCEL, WAR_AUDIO_WAVE }, { WAR_SWORD_ATTACK_1, WAR_AUDIO_WAVE }, { WAR_SWORD_ATTACK_2, WAR_AUDIO_WAVE }, { WAR_SWORD_ATTACK_3, WAR_AUDIO_WAVE }, { WAR_FIST_ATTACK, WAR_AUDIO_WAVE }, { WAR_CATAPULT_FIRE_EXPLOSION, WAR_AUDIO_WAVE }, { WAR_FIREBALL, WAR_AUDIO_WAVE }, { WAR_ARROW_SPEAR, WAR_AUDIO_WAVE }, { WAR_ARROW_SPEAR_HIT, WAR_AUDIO_WAVE }, { WAR_ORC_HELP_1, WAR_AUDIO_WAVE }, { WAR_ORC_HELP_2, WAR_AUDIO_WAVE }, { WAR_HUMAN_HELP_2, WAR_AUDIO_WAVE }, { WAR_HUMAN_HELP_1, WAR_AUDIO_WAVE }, { WAR_ORC_DEAD, WAR_AUDIO_WAVE }, { WAR_HUMAN_DEAD, WAR_AUDIO_WAVE }, { WAR_ORC_WORK_COMPLETE, WAR_AUDIO_WAVE }, { WAR_HUMAN_WORK_COMPLETE, WAR_AUDIO_WAVE }, { WAR_ORC_HELP_3, WAR_AUDIO_WAVE }, { WAR_ORC_HELP_4, WAR_AUDIO_WAVE }, { WAR_HUMAN_HELP_3, WAR_AUDIO_WAVE }, { WAR_HUMAN_HELP_4, WAR_AUDIO_WAVE }, { WAR_ORC_READY, WAR_AUDIO_WAVE }, { WAR_HUMAN_READY, WAR_AUDIO_WAVE }, { WAR_ORC_ACKNOWLEDGEMENT_1, WAR_AUDIO_WAVE }, { WAR_ORC_ACKNOWLEDGEMENT_2, WAR_AUDIO_WAVE }, { WAR_ORC_ACKNOWLEDGEMENT_3, WAR_AUDIO_WAVE }, { WAR_ORC_ACKNOWLEDGEMENT_4, WAR_AUDIO_WAVE }, { WAR_HUMAN_ACKNOWLEDGEMENT_1, WAR_AUDIO_WAVE }, { WAR_HUMAN_ACKNOWLEDGEMENT_2, WAR_AUDIO_WAVE }, { WAR_ORC_SELECTED_1, WAR_AUDIO_WAVE }, { WAR_ORC_SELECTED_2, WAR_AUDIO_WAVE }, { WAR_ORC_SELECTED_3, WAR_AUDIO_WAVE }, { WAR_ORC_SELECTED_4, WAR_AUDIO_WAVE }, { WAR_ORC_SELECTED_5, WAR_AUDIO_WAVE }, { WAR_HUMAN_SELECTED_1, WAR_AUDIO_WAVE }, { WAR_HUMAN_SELECTED_2, WAR_AUDIO_WAVE }, { WAR_HUMAN_SELECTED_3, WAR_AUDIO_WAVE }, { WAR_HUMAN_SELECTED_4, WAR_AUDIO_WAVE }, { WAR_HUMAN_SELECTED_5, WAR_AUDIO_WAVE }, { WAR_ORC_ANNOYED_1, WAR_AUDIO_WAVE }, { WAR_ORC_ANNOYED_2, WAR_AUDIO_WAVE }, { WAR_ORC_ANNOYED_3, WAR_AUDIO_WAVE }, { WAR_HUMAN_ANNOYED_1, WAR_AUDIO_WAVE }, { WAR_HUMAN_ANNOYED_2, WAR_AUDIO_WAVE }, { WAR_HUMAN_ANNOYED_3, WAR_AUDIO_WAVE }, { WAR_DEAD_SPIDER_SCORPION, WAR_AUDIO_WAVE }, { WAR_NORMAL_SPELL, WAR_AUDIO_WAVE }, { WAR_BUILD_ROAD, WAR_AUDIO_WAVE }, { WAR_ORC_TEMPLE, WAR_AUDIO_WAVE }, { WAR_HUMAN_CHURCH, WAR_AUDIO_WAVE }, { WAR_ORC_KENNEL, WAR_AUDIO_WAVE }, { WAR_HUMAN_STABLE, WAR_AUDIO_WAVE }, { WAR_BLACKSMITH, WAR_AUDIO_WAVE }, { WAR_FIRE_CRACKLING, WAR_AUDIO_WAVE }, { WAR_CANNON, WAR_AUDIO_WAVE }, { WAR_CANNON2, WAR_AUDIO_WAVE }, { WAR_CAMPAIGNS_HUMAN_ENDING_1, WAR_AUDIO_WAVE }, { WAR_CAMPAIGNS_HUMAN_ENDING_2, WAR_AUDIO_WAVE }, { WAR_CAMPAIGNS_ORC_ENDING_1, WAR_AUDIO_WAVE }, { WAR_CAMPAIGNS_ORC_ENDING_2, WAR_AUDIO_WAVE }, { WAR_INTRO_1, WAR_AUDIO_WAVE }, { WAR_INTRO_2, WAR_AUDIO_WAVE }, { WAR_INTRO_3, WAR_AUDIO_WAVE }, { WAR_INTRO_4, WAR_AUDIO_WAVE }, { WAR_INTRO_5, WAR_AUDIO_WAVE }, { WAR_CAMPAIGNS_HUMAN_01_INTRO, WAR_AUDIO_WAVE }, { WAR_CAMPAIGNS_HUMAN_02_INTRO, WAR_AUDIO_WAVE }, { WAR_CAMPAIGNS_HUMAN_03_INTRO, WAR_AUDIO_WAVE }, { WAR_CAMPAIGNS_HUMAN_04_INTRO, WAR_AUDIO_WAVE }, { WAR_CAMPAIGNS_HUMAN_05_INTRO, WAR_AUDIO_WAVE }, { WAR_CAMPAIGNS_HUMAN_06_INTRO, WAR_AUDIO_WAVE }, { WAR_CAMPAIGNS_HUMAN_07_INTRO, WAR_AUDIO_WAVE }, { WAR_CAMPAIGNS_HUMAN_08_INTRO, WAR_AUDIO_WAVE }, { WAR_CAMPAIGNS_HUMAN_09_INTRO, WAR_AUDIO_WAVE }, { WAR_CAMPAIGNS_HUMAN_10_INTRO, WAR_AUDIO_WAVE }, { WAR_CAMPAIGNS_HUMAN_11_INTRO, WAR_AUDIO_WAVE }, { WAR_CAMPAIGNS_HUMAN_12_INTRO, WAR_AUDIO_WAVE }, { WAR_CAMPAIGNS_ORC_01_INTRO, WAR_AUDIO_WAVE }, { WAR_CAMPAIGNS_ORC_02_INTRO, WAR_AUDIO_WAVE }, { WAR_CAMPAIGNS_ORC_03_INTRO, WAR_AUDIO_WAVE }, { WAR_CAMPAIGNS_ORC_04_INTRO, WAR_AUDIO_WAVE }, { WAR_CAMPAIGNS_ORC_05_INTRO, WAR_AUDIO_WAVE }, { WAR_CAMPAIGNS_ORC_06_INTRO, WAR_AUDIO_WAVE }, { WAR_CAMPAIGNS_ORC_07_INTRO, WAR_AUDIO_WAVE }, { WAR_CAMPAIGNS_ORC_08_INTRO, WAR_AUDIO_WAVE }, { WAR_CAMPAIGNS_ORC_09_INTRO, WAR_AUDIO_WAVE }, { WAR_CAMPAIGNS_ORC_10_INTRO, WAR_AUDIO_WAVE }, { WAR_CAMPAIGNS_ORC_11_INTRO, WAR_AUDIO_WAVE }, { WAR_CAMPAIGNS_ORC_12_INTRO, WAR_AUDIO_WAVE }, { WAR_HUMAN_DEFEAT, WAR_AUDIO_WAVE }, { WAR_ORC_DEFEAT, WAR_AUDIO_WAVE }, { WAR_ORC_VICTORY_1, WAR_AUDIO_WAVE }, { WAR_ORC_VICTORY_2, WAR_AUDIO_WAVE }, { WAR_ORC_VICTORY_3, WAR_AUDIO_WAVE }, { WAR_HUMAN_VICTORY_1, WAR_AUDIO_WAVE }, { WAR_HUMAN_VICTORY_2, WAR_AUDIO_WAVE }, { WAR_HUMAN_VICTORY_3, WAR_AUDIO_WAVE }, }; WarAudioData wa_getAudioData(WarAudioId audioId) { s32 index = 0; s32 length = arrayLength(audioData); while (index < length && audioData[index].id != audioId) index++; assert(index < length); return audioData[index]; } bool wa_playMidi(WarContext* context, WarEntity* entity, u32 sampleCount, s16* outputStream, f32 volume) { WarAudioComponent* audio = we_getAudioComponent(context, entity); assert(audio); tsf* soundFont = context->soundFont; while (sampleCount) { //We progress the MIDI playback and then process TSF_RENDER_EFFECTSAMPLEBLOCK samples at once u32 sampleBlock = MIN(TSF_RENDER_EFFECTSAMPLEBLOCK, sampleCount); audio->playbackTime += sampleBlock * (1000.0f / PLAYBACK_FREQ); //Loop through all MIDI messages which need to be played up until the current playback time tml_message* midiMessage = audio->currentMessage; tml_message* prevMessage = midiMessage; while (midiMessage) { // end of track if (midiMessage->type == TML_EOT) { midiMessage = audio->loop ? audio->firstMessage : NULL; audio->playbackTime -= prevMessage->time; } if (!midiMessage || midiMessage->time > audio->playbackTime) { break; } u8 channel = midiMessage->channel; switch (midiMessage->type) { // channel program (preset) change (special handling for 10th MIDI channel with drums) case TML_PROGRAM_CHANGE: { s8 program = midiMessage->program; tsf_channel_set_presetnumber(soundFont, channel, program, (channel == 9)); break; } // play a note case TML_NOTE_ON: { s8 key = midiMessage->key; f32 velocity = midiMessage->velocity / 127.0f; tsf_channel_note_on(soundFont, channel, key, velocity * volume); break; } // wcmd_stop a note case TML_NOTE_OFF: { s8 key = midiMessage->key; tsf_channel_note_off(soundFont, channel, key); break; } // pitch wheel modification case TML_PITCH_BEND: { u16 pitchBend = midiMessage->pitch_bend; tsf_channel_set_pitchwheel(soundFont, channel, pitchBend); break; } // MIDI controller messages case TML_CONTROL_CHANGE: { s8 control = midiMessage->control; s8 controlValue = midiMessage->control_value; tsf_channel_midi_control(soundFont, channel, control, controlValue); break; } } prevMessage = midiMessage; midiMessage = midiMessage->next; } // Render the block of audio samples in float format tsf_render_short(soundFont, outputStream, sampleBlock, TSF_TRUE); sampleCount -= sampleBlock; outputStream += sampleBlock; audio->currentMessage = midiMessage; } return !audio->currentMessage && !audio->loop; } bool wa_playWave(WarContext* context, WarEntity* entity, u32 sampleCount, s16* outputStream, f32 volume) { WarAudioComponent* audio = we_getAudioComponent(context, entity); assert(audio); WarResource* resource = context->resources[audio->resourceIndex]; if (!resource) { logError("Can't play audio %d, resource: %d", entity->id, audio->resourceIndex); return false; } s32 waveLength = resource->audio.length; do { if (audio->sampleIndex >= waveLength) { audio->sampleIndex = 0; audio->playbackTime = 0; } u8* waveData = &resource->audio.data[audio->sampleIndex]; u32 sampleBlock = MIN(sampleCount, (u32)(waveLength - audio->sampleIndex)); for (u32 i = 0; i < sampleBlock; i++) { s32 value = *waveData; value = value - 128; value = value << 8; value = (s32)(value * volume); value += *outputStream; value = CLAMP(value, INT16_MIN, INT16_MAX); *outputStream = (s16)value; waveData++; outputStream++; } audio->playbackTime += sampleBlock * (1000.0f / PLAYBACK_FREQ); audio->sampleIndex += sampleBlock; sampleCount -= sampleBlock; } while (sampleCount > 0 && audio->loop); return audio->sampleIndex >= waveLength && !audio->loop; } void SDLCALL audioDataCallback(void* userdata, SDL_AudioStream* stream, int additionalAmount, int totalAmount) { NOT_USED(totalAmount); WarContext* context = (WarContext*)userdata; if (!context || additionalAmount <= 0) { return; } if (!context->audioEnabled || context->transitionDelay > 0) { tsf_note_off_all(context->soundFont, TSF_TRUE); return; } // additionalAmount is in bytes, format is S16 mono (2 bytes per sample) u32 sampleCount = (u32)(additionalAmount / sizeof(s16)); if (sampleCount == 0) { return; } // Use the pre-allocated mix buffer (owned by WarContext, never freed here). // Cap to the allocated capacity; if SDL requests more than expected, we mix // what we can and the stream will request the remainder on the next callback. if (sampleCount > context->audioMixBufferCapacity) { logWarning("Audio callback requested %u samples; capping to pre-allocated capacity %u.", sampleCount, context->audioMixBufferCapacity); sampleCount = context->audioMixBufferCapacity; } s16* outputBuffer = context->audioMixBuffer; memset(outputBuffer, 0, sampleCount * sizeof(s16)); f32 musicVolume = context->musicEnabled ? context->musicVolume : 0; f32 soundVolume = context->soundEnabled ? context->soundVolume : 0; // Fixed-size stack array: no heap allocation from the audio thread. WarEntityId toRemove[AUDIO_REMOVE_PENDING_MAX]; s32 toRemoveCount = 0; s16* outputStream = outputBuffer; WarEntityList* audios = we_getEntitiesOfType(context, WAR_ENTITY_TYPE_AUDIO); for (s32 i = 0; i < audios->count; i++) { WarEntity* entity = audios->items[i]; if (entity) { if (we_isComponentEnabled(context, entity, COMP_AUDIO)) { WarAudioComponent* audio = we_getAudioComponent(context, entity); assert(audio); switch (audio->type) { case WAR_AUDIO_MIDI: { if (musicVolume > 0 && wa_playMidi(context, entity, sampleCount, outputStream, musicVolume)) { // if the audio finish, mark it to remove it if (toRemoveCount < AUDIO_REMOVE_PENDING_MAX) toRemove[toRemoveCount++] = entity->id; } break; } case WAR_AUDIO_WAVE: { f32 volume = soundVolume; if (we_isComponentEnabled(context, entity, COMP_TRANSFORM)) { WarTransformComponent* transform = we_getTransformComponent(context, entity); assert(transform); // does positional audios only makes sense on maps? WarMap* map = context->map; assert(map); // it's a positional audio, so check if the audio is inside the viewport vec2 position = transform->position; rect viewport = map->viewport; if (!rect_containsf(viewport, position.x, position.y)) { vec2 viewportCenter = rect_center(viewport); f32 distance = vec2_distance(position, viewportCenter); // approximately the distances from the center of the viewport // begin at 120 pixels, I'm going to set an audible range of 120-200 // when the audios gets out of viewport // distance vol // < 120 -> 1 // > 120 && < 200 -> interpolate range 120-200 to range 0.75-0 // >= 200 -> 0 volume = 0.75f * (1 - ((distance - 120) / 80)); volume = MAX(volume, 0); } } if (wa_playWave(context, entity, sampleCount, outputStream, volume)) { // if the audio finish, mark it to remove it if (toRemoveCount < AUDIO_REMOVE_PENDING_MAX) toRemove[toRemoveCount++] = entity->id; } break; } default: { logWarning("Unkown audio type: %d", audio->type); break; } } } } } // Post finished entity IDs to the main thread for removal. // Never call we_removeEntityById from the audio thread: it calls wm_free which // would race with main-thread allocations on globalZone. if (toRemoveCount > 0) { SDL_LockMutex(context->audioRemoveMutex); for (s32 i = 0; i < toRemoveCount; i++) { if (context->audioRemovePendingCount < AUDIO_REMOVE_PENDING_MAX) context->audioRemovePending[context->audioRemovePendingCount++] = toRemove[i]; } SDL_UnlockMutex(context->audioRemoveMutex); } // push the mixed audio data into the stream SDL_PutAudioStreamData(stream, outputBuffer, (int)(sampleCount * sizeof(s16))); } bool wa_initAudio(WarContext* context) { context->soundFont = tsf_load_filename("GMGeneric.SF2"); if (!context->soundFont) { logError("Could not load SoundFont at %s", "GMGeneric.SF2"); return false; } //Initialize preset on special 10th MIDI channel to use percussion sound bank (128) if available tsf_channel_set_bank_preset(context->soundFont, 9, 128, 0); // Set the SoundFont rendering output mode tsf_set_output(context->soundFont, TSF_MONO, PLAYBACK_FREQ, 0.0f); // Pre-allocate the mix buffer on the main thread before audio starts. // This ensures the audio callback thread never needs to call wm_calloc // or wm_free, which would race with main-thread allocations on globalZone. context->audioMixBuffer = (s16*)wm_alloc(AUDIO_MIX_BUFFER_MAX_SAMPLES * sizeof(s16)); if (!context->audioMixBuffer) { logError("Failed to allocate audio mix buffer."); tsf_close(context->soundFont); context->soundFont = NULL; return false; } context->audioMixBufferCapacity = AUDIO_MIX_BUFFER_MAX_SAMPLES; // Mutex that guards audioRemovePending / audioRemovePendingCount. context->audioRemoveMutex = SDL_CreateMutex(); if (!context->audioRemoveMutex) { logError("Failed to create audio remove mutex: %s", SDL_GetError()); wm_free(context->audioMixBuffer); context->audioMixBuffer = NULL; tsf_close(context->soundFont); context->soundFont = NULL; return false; } context->audioRemovePendingCount = 0; // Open an SDL3 audio device stream with S16 mono at PLAYBACK_FREQ SDL_AudioSpec spec; spec.format = SDL_AUDIO_S16; spec.channels = 1; spec.freq = PLAYBACK_FREQ; context->audioStream = SDL_OpenAudioDeviceStream( SDL_AUDIO_DEVICE_DEFAULT_PLAYBACK, &spec, audioDataCallback, context ); if (!context->audioStream) { logError("Failed to open audio device stream: %s", SDL_GetError()); return false; } // SDL_OpenAudioDeviceStream opens paused; resume to start playback if (!SDL_ResumeAudioStreamDevice(context->audioStream)) { logError("Failed to resume audio stream device: %s", SDL_GetError()); SDL_DestroyAudioStream(context->audioStream); context->audioStream = NULL; return false; } context->musicEnabled = true; context->soundEnabled = true; context->musicVolume = 1.0f; context->soundVolume = 1.0f; return true; } void wa_removeAudiosOfType(WarContext* context, WarAudioType type) { WarEntityIdList toRemove; WarEntityIdListInit(&toRemove, WarEntityIdListDefaultOptions); WarEntityList* audios = we_getEntitiesOfType(context, WAR_ENTITY_TYPE_AUDIO); for (s32 i = 0; i < audios->count; i++) { WarEntity* entity = audios->items[i]; if (entity) { WarAudioComponent* audio = we_getAudioComponent(context, entity); assert(audio); if (audio->type == type) { WarEntityIdListAdd(&toRemove, entity->id); } } } for (s32 i = 0; i < toRemove.count; i++) { WarEntityId entityId = toRemove.items[i]; we_removeEntityById(context, entityId); } WarEntityIdListFree(&toRemove); if (type == WAR_AUDIO_MIDI) { // at this point the audio callback shouldn't be playing any midi audio // so turn of notes off tsf_note_off_all(context->soundFont, TSF_TRUE); } } WarEntity* wa_createAudio(WarContext* context, const CreateAudioArgs* args) { WarAudioId audioId = args->audioId; bool loop = args->loop; WarAudioData data = wa_getAudioData(audioId); s32 resourceIndex = (s32)audioId; WarAudioType type = data.type; WarEntity* entity = we_createEntity(context, WAR_ENTITY_TYPE_AUDIO, true); we_addAudioComponent(context, entity, WAR_AUDIO_COMPONENT_INIT( .type = type, .resourceIndex = resourceIndex, .loop = loop, )); return entity; } WarEntity* wa_createAudioWithPosition(WarContext* context, const CreateAudioArgs* args) { WarAudioId audioId = args->audioId; vec2 position = args->position; bool loop = args->loop; WarAudioData data = wa_getAudioData(audioId); s32 resourceIndex = (s32)audioId; WarAudioType type = data.type; WarEntity* entity = we_createEntity(context, WAR_ENTITY_TYPE_AUDIO, true); we_addAudioComponent(context, entity, WAR_AUDIO_COMPONENT_INIT( .type = type, .resourceIndex = resourceIndex, .loop = loop, )); we_addTransformComponent(context, entity, WAR_TRANSFORM_COMPONENT_INIT( .position = position, )); return entity; } WarEntity* wa_createAudioRandom(WarContext* context, const CreateAudioArgs* args) { WarAudioId fromId = args->randomFromId; WarAudioId toId = args->randomToId; bool loop = args->loop; return wa_createAudio(context, CREATE_AUDIO_ARGS_INIT(.audioId=randomi(fromId, toId + 1), .loop=loop)); } WarEntity* wa_createAudioRandomWithPosition(WarContext* context, const CreateAudioArgs* args) { WarAudioId fromId = args->randomFromId; WarAudioId toId = args->randomToId; vec2 position = args->position; bool loop = args->loop; return wa_createAudioWithPosition(context, CREATE_AUDIO_ARGS_INIT(.audioId=randomi(fromId, toId + 1), .position=position, .hasPosition=true, .loop=loop)); } WarEntity* wa_playAttackSound(WarContext* context, vec2 position, WarUnitActionStepType soundStep) { switch (soundStep) { case WAR_ACTION_STEP_SOUND_SWORD: return wa_createAudioRandomWithPosition(context, CREATE_AUDIO_ARGS_INIT(.randomFromId=WAR_SWORD_ATTACK_1, .randomToId=WAR_SWORD_ATTACK_3, .position=position, .hasPosition=true, .loop=false)); case WAR_ACTION_STEP_SOUND_FIST: return wa_createAudioWithPosition(context, CREATE_AUDIO_ARGS_INIT(.audioId=WAR_FIST_ATTACK, .position=position, .hasPosition=true, .loop=false)); case WAR_ACTION_STEP_SOUND_FIREBALL: return wa_createAudioWithPosition(context, CREATE_AUDIO_ARGS_INIT(.audioId=WAR_FIREBALL, .position=position, .hasPosition=true, .loop=false)); case WAR_ACTION_STEP_SOUND_CATAPULT: return wa_createAudioWithPosition(context, CREATE_AUDIO_ARGS_INIT(.audioId=WAR_CATAPULT_ROCK_FIRED, .position=position, .hasPosition=true, .loop=false)); case WAR_ACTION_STEP_SOUND_ARROW: return wa_createAudioWithPosition(context, CREATE_AUDIO_ARGS_INIT(.audioId=WAR_ARROW_SPEAR, .position=position, .hasPosition=true, .loop=false)); default: logWarning("Trying to play sound with step: %d", soundStep); return NULL; } } WarEntity* wa_playDudeSelectionSound(WarContext* context, WarEntity* entity) { assert(wu_isDudeUnit(context, entity)); WarMap* map = context->map; if (map->selectedEntities.count == 1) { WarEntityId selectedEntityId = map->selectedEntities.items[0]; if (selectedEntityId == entity->id) { return wu_isHumanUnit(context, entity) ? wa_createAudioRandom(context, CREATE_AUDIO_ARGS_INIT(.randomFromId=WAR_HUMAN_ANNOYED_1, .randomToId=WAR_HUMAN_ANNOYED_3, .loop=false)) : wa_createAudioRandom(context, CREATE_AUDIO_ARGS_INIT(.randomFromId=WAR_ORC_ANNOYED_1, .randomToId=WAR_ORC_ANNOYED_3, .loop=false)); } } return wu_isHumanUnit(context, entity) ? wa_createAudioRandom(context, CREATE_AUDIO_ARGS_INIT(.randomFromId=WAR_HUMAN_SELECTED_1, .randomToId=WAR_HUMAN_SELECTED_5, .loop=false)) : wa_createAudioRandom(context, CREATE_AUDIO_ARGS_INIT(.randomFromId=WAR_ORC_SELECTED_1, .randomToId=WAR_ORC_SELECTED_5, .loop=false)); } WarEntity* wa_playBuildingSelectionSound(WarContext* context, WarEntity* entity) { assert(wu_isBuildingUnit(context, entity)); if (wst_isBuilding(context, entity) || wst_isGoingToBuild(context, entity)) return wa_createAudio(context, CREATE_AUDIO_ARGS_INIT(.audioId=WAR_BUILDING, .loop=false)); WarUnitComponent* unit = we_getUnitComponent(context, entity); assert(unit); s32 hpPercent = PERCENTABI(unit->hp, unit->maxhp); if(hpPercent <= 33) return wa_createAudio(context, CREATE_AUDIO_ARGS_INIT(.audioId=WAR_FIRE_CRACKLING, .loop=false)); switch (unit->type) { case WAR_UNIT_CHURCH: return wa_createAudio(context, CREATE_AUDIO_ARGS_INIT(.audioId=WAR_HUMAN_CHURCH, .loop=false)); case WAR_UNIT_TEMPLE: return wa_createAudio(context, CREATE_AUDIO_ARGS_INIT(.audioId=WAR_ORC_TEMPLE, .loop=false)); case WAR_UNIT_STABLE: return wa_createAudio(context, CREATE_AUDIO_ARGS_INIT(.audioId=WAR_HUMAN_STABLE, .loop=false)); case WAR_UNIT_KENNEL: return wa_createAudio(context, CREATE_AUDIO_ARGS_INIT(.audioId=WAR_ORC_KENNEL, .loop=false)); case WAR_UNIT_BLACKSMITH_HUMANS: case WAR_UNIT_BLACKSMITH_ORCS: return wa_createAudio(context, CREATE_AUDIO_ARGS_INIT(.audioId=WAR_BLACKSMITH, .loop=false)); default: return wa_createAudio(context, CREATE_AUDIO_ARGS_INIT(.audioId=WAR_UI_CLICK, .loop=false)); } } WarEntity* wa_playAcknowledgementSound(WarContext* context, WarPlayerInfo* player) { return isHumanPlayer(player) ? wa_createAudioRandom(context, CREATE_AUDIO_ARGS_INIT(.randomFromId=WAR_HUMAN_ACKNOWLEDGEMENT_1, .randomToId=WAR_HUMAN_ACKNOWLEDGEMENT_2, .loop=false)) : wa_createAudioRandom(context, CREATE_AUDIO_ARGS_INIT(.randomFromId=WAR_ORC_ACKNOWLEDGEMENT_1, .randomToId=WAR_ORC_ACKNOWLEDGEMENT_4, .loop=false)); } /** * Extension function of memory_buffer_t to read variable lengths integer values. */ bool wa_mb_readUIntVar(memory_buffer_t* buffer, u32* value) { u32 v = 0; u8 byte; for(s32 i = 0; i < 4; ++i) { if(!mb_read(buffer, &byte)) return false; v = (v << 7) | (u32)(byte & 0x7F); if((byte & 0x80) == 0) break; } *value = v; return true; } /** * Extension function of memory_buffer_t to write variable lengths integer values. */ bool wa_mb_writeUIntVar(memory_buffer_t* buffer, u32 value) { s32 byteCount = 1; u32 v = value & 0x7F; value >>= 7; while (value) { v = (v << 8) | 0x80 | (value & 0x7F); ++byteCount; value >>= 7; } for(s32 i = 0; i < byteCount; ++i) { u8 byte = v & 0xFF; if(!mb_write(buffer, byte)) return false; v >>= 8; } return true; } typedef struct _MidiToken { s32 time; u32 bufferLength; u8* buffer; u8 type; u8 data; } MidiToken; static s32 wa_compareTokens(const MidiToken left, const MidiToken right, void* userdata) { NOT_USED(userdata); return left.time - right.time; } shlDeclareList(MidiTokenList, MidiToken) shlDefineList(MidiTokenList, MidiToken) static MidiToken* MidiTokenListAppend(MidiTokenList* list, s32 time, u8 type) { MidiToken token = {0}; token.time = time; token.type = type; MidiTokenListAdd(list, token); return &list->items[list->count - 1]; } /** * This code is a port in C of the XMI2MID converter by Peter "Corsix" Cawley * in the War1gus repository. You can find the original C++ code here: * https://github.com/Wargus/war1gus/blob/master/xmi2mid.cpp. * * To understand more about these formats see: * http://www.shikadi.net/moddingwiki/XMI_Format * http://www.shikadi.net/moddingwiki/MID_Format * https://github.com/colxi/midi-parser-js/wiki/MIDI-File-Format-Specifications */ u8* wa_transcodeXmiToMid(WarContext* context, u8* xmiData, size_t xmiLength, size_t* midLength) { NOT_USED(context); memory_buffer_t bufInput = {0}; mb_initFromMemory(&bufInput, xmiData, xmiLength); memory_buffer_t bufOutput = {0}; mb_initEmpty(&bufOutput); if (!mb_scanTo(&bufInput, "EVNT", 4)) { mb_free(&bufOutput); return NULL; } if (!mb_skip(&bufInput, 8)) { mb_free(&bufOutput); return NULL; } MidiTokenListOptions options = {0}; MidiTokenList lstTokens; MidiTokenListInit(&lstTokens, options); MidiToken* token; s32 tokenTime = 0; s32 tempo = 500000; bool tempoSet = false; bool end = false; u8 tokenType, extendedType; u32 intVar; while (!mb_isEOF(&bufInput) && !end) { while (true) { if (!mb_read(&bufInput, &tokenType)) { mb_free(&bufOutput); return NULL; } if (tokenType & 0x80) break; tokenTime += (s32)tokenType * 3; } token = MidiTokenListAppend(&lstTokens, tokenTime, tokenType); token->buffer = bufInput._pointer + 1; switch (tokenType & 0xF0) { case 0xC0: case 0xD0: { if (!mb_read(&bufInput, &token->data)) { mb_free(&bufOutput); return NULL; } token->buffer = NULL; break; } case 0x80: case 0xA0: case 0xB0: case 0xE0: { if (!mb_read(&bufInput, &token->data)) { mb_free(&bufOutput); return NULL; } if (!mb_skip(&bufInput, 1)) { mb_free(&bufOutput); return NULL; } break; } case 0x90: { if (!mb_read(&bufInput, &extendedType)) { mb_free(&bufOutput); return NULL; } token->data = extendedType; if (!mb_skip(&bufInput, 1)) { mb_free(&bufOutput); return NULL; } assert(wa_mb_readUIntVar(&bufInput, &intVar)); token = MidiTokenListAppend(&lstTokens, tokenTime + intVar * 3, tokenType); token->data = extendedType; token->buffer = (u8*)"\0"; break; } case 0xF0: { extendedType = 0; if (tokenType == 0xFF) { if (!mb_read(&bufInput, &extendedType)) { mb_free(&bufOutput); return NULL; } if (extendedType == 0x2F) end = true; else if (extendedType == 0x51) { if (!tempoSet) { assert(mb_skip(&bufInput, 1)); assert(mb_readInt24BE(&bufInput, &tempo)); tempo *= 3; tempoSet = true; assert(mb_skip(&bufInput, -4)); } else { MidiTokenListRemoveAt(&lstTokens, lstTokens.count - 1); assert(wa_mb_readUIntVar(&bufInput, &intVar)); if (!mb_skip(&bufInput, intVar)) { mb_free(&bufOutput); return NULL; } break; } } } token->data = extendedType; assert(wa_mb_readUIntVar(&bufInput, &token->bufferLength)); token->buffer = bufInput._pointer; if (!mb_skip(&bufInput, token->bufferLength)) { mb_free(&bufOutput); return NULL; } break; } } } if (lstTokens.count == 0) { mb_free(&bufOutput); return NULL; } if (!mb_writeString(&bufOutput, "MThd\0\0\0\x06\0\0\0\x01", 12)) { mb_free(&bufOutput); return NULL; } if (!mb_writeUInt16BE(&bufOutput, (u16)((tempo * 3) / 25000))) { mb_free(&bufOutput); return NULL; } if (!mb_writeString(&bufOutput, "MTrk\xBA\xAD\xF0\x0D", 8)) { mb_free(&bufOutput); return NULL; } MidiTokenListSort(&lstTokens, wa_compareTokens, NULL); tokenTime = 0; tokenType = 0; end = false; for (s32 i = 0; i < lstTokens.count && !end; i++) { MidiToken t = lstTokens.items[i]; if (!wa_mb_writeUIntVar(&bufOutput, t.time - tokenTime)) { mb_free(&bufOutput); return NULL; } tokenTime = t.time; if (t.type >= 0xF0) { tokenType = t.type; if (!mb_write(&bufOutput, tokenType)) { mb_free(&bufOutput); return NULL; } if (tokenType == 0xFF) { if (!mb_write(&bufOutput, t.data)) { mb_free(&bufOutput); return NULL; } if (t.data == 0x2F) end = true; } if (!wa_mb_writeUIntVar(&bufOutput, t.bufferLength)) { mb_free(&bufOutput); return NULL; } if (!mb_writeBytes(&bufOutput, t.buffer, t.bufferLength)) { mb_free(&bufOutput); return NULL; } } else { if (t.type != tokenType) { tokenType = t.type; if (!mb_write(&bufOutput, tokenType)) { mb_free(&bufOutput); return NULL; } } if (!mb_write(&bufOutput, t.data)) { mb_free(&bufOutput); return NULL; } if (t.buffer) { if (!mb_writeBytes(&bufOutput, t.buffer, 1)) { mb_free(&bufOutput); return NULL; } } } } size32 length = mb_position(&bufOutput) - 22; assert(length <= UINT32_MAX); assert(mb_seek(&bufOutput, 18)); assert(mb_writeUInt32BE(&bufOutput, (u32)length)); u8* midData = mb_data(&bufOutput, midLength); mb_free(&bufOutput); return midData; } u8* wa_changeSampleRate(WarContext* context, u8* samplesIn, s32 length, s32 factor) { NOT_USED(context); assert(factor >= 1); s32 newLength = length * factor; u8* samplesOut = (u8*)wm_alloc(newLength); samplesOut[0] = samplesIn[0]; for (s32 i = 1, j = 0; i < length; i++) { u8 a = samplesIn[i - 1]; u8 b = samplesIn[i]; f32 dt = 1.0f / (f32)factor; for (s32 k = 0; k < factor - 1; k++) { // linear interpolation: a + (b - a) * t f32 t = dt * (f32)(k + 1); samplesOut[j++] = (u8)(a + (b - a) * t); } samplesOut[j++] = b; } return samplesOut; } ================================================ FILE: src/war_audio.h ================================================ #pragma once #include #include "war_math.h" #include "war_actions.h" typedef struct tsf tsf; typedef struct tml_message tml_message; struct _WarAudioComponent { bool enabled; WarAudioType type; s32 resourceIndex; bool loop; f32 playbackTime; s32 sampleIndex; tml_message* firstMessage; tml_message* currentMessage; }; #define WAR_AUDIO_COMPONENT_INIT_FIELDS(...) { \ .enabled = false, \ .type = 0, \ .resourceIndex = -1, \ .loop = false, \ .playbackTime = 0, \ .sampleIndex = 0, \ .firstMessage = NULL, \ .currentMessage = NULL, \ __VA_ARGS__ \ } #define WAR_AUDIO_COMPONENT_INIT(...) ((WarAudioComponent)WAR_AUDIO_COMPONENT_INIT_FIELDS(__VA_ARGS__)) bool wa_initAudio(WarContext* context); void wa_removeAudiosOfType(WarContext* context, WarAudioType type); typedef struct { WarAudioId audioId; WarAudioId randomFromId; WarAudioId randomToId; vec2 position; bool hasPosition; bool loop; } CreateAudioArgs; #define CREATE_AUDIO_ARGS_INIT_CONST(...) { \ .audioId = -1, \ .randomFromId = -1, \ .randomToId = -1, \ .hasPosition = false, \ .loop = false, \ __VA_ARGS__ \ } #define CREATE_AUDIO_ARGS_INIT(...) (&(CreateAudioArgs)CREATE_AUDIO_ARGS_INIT_CONST(__VA_ARGS__)) WarEntity* wa_createAudio(WarContext* context, const CreateAudioArgs* args); WarEntity* wa_createAudioWithPosition(WarContext* context, const CreateAudioArgs* args); WarEntity* wa_createAudioRandom(WarContext* context, const CreateAudioArgs* args); WarEntity* wa_createAudioRandomWithPosition(WarContext* context, const CreateAudioArgs* args); WarEntity* wa_playAttackSound(WarContext* context, vec2 position, WarUnitActionStepType soundStep); WarEntity* wa_playDudeSelectionSound(WarContext* context, WarEntity* entity); WarEntity* wa_playBuildingSelectionSound(WarContext* context, WarEntity* entity); WarEntity* wa_playAcknowledgementSound(WarContext* context, WarPlayerInfo* player); u8* wa_transcodeXmiToMid(WarContext* context, u8* xmiData, size_t xmiLength, size_t* midLength); u8* wa_changeSampleRate(WarContext* context, u8* samplesIn, s32 length, s32 factor); ================================================ FILE: src/war_campaigns.c ================================================ #include "war_campaigns.h" #include #include "shl/wstr.h" #include "war_entities.h" #include "war_units.h" WarLevelResult wcamp_checkMap01Objectives(WarContext* context); WarLevelResult wcamp_checkMap02Objectives(WarContext* context); WarLevelResult wcamp_checkCustomMapObjectives(WarContext* context); typedef struct { WarCampaignMapType type; WarCheckObjectivesFunc checkObjectivesFunc; const char* objectives; WarAudioId briefingAudioId; const char* briefingText; f32 briefingDuration; } WarCampaignMapRawData; static const WarCampaignMapRawData campaignsData[] = { { WAR_CAMPAIGN_HUMANS_01, wcamp_checkMap01Objectives, "Build:\n\t6 farms\n\t1 barracks", WAR_CAMPAIGNS_HUMAN_01_INTRO, "As a test of your abilities, the King has appointed\n" "you as Regent over a small parcel of land. Since\n" "we must keep our armies in the field well supplied,\n" "you are to build the town into a farming center of\n" "no less than 6 farms. Construction of a barracks\n" "for defense is also advised, as our scouts have\n" "reported Orc patrols in the area.", 24.0f }, { WAR_CAMPAIGN_ORCS_01, wcamp_checkMap01Objectives, "Build:\n 6 farms\n 1 barracks", WAR_CAMPAIGNS_ORC_01_INTRO, "Blackhand has assigned you to an outpost in the\n" "Swamps of Sorrow. Your task is simple enough\n" "that even the War Chief feels that you are capable\n" "of it. Construct at least 6 farms, so that we may\n" "keep our troops well fed and ready to do battle.\n" "Only a fool would leave his treasures unguarded,\n" "so you must also build a barracks for the defense\n" "of these farms.", 28.0f }, { WAR_CAMPAIGN_HUMANS_02, wcamp_checkMap02Objectives, "Defend town and\ndestroy orcs", WAR_CAMPAIGNS_HUMAN_02_INTRO, "The Orcs around Grand Hamlet are becoming\n" "increasingly brazen in their attacks, and our\n" "spies inform us that they are amassing a large\n" "army to march against the town.\n" "The King is sending you, along with a small\n" "detachment of troops, to rally the people and\n" "defend the town against all opposition.", 20.0f }, { WAR_CAMPAIGN_ORCS_02, wcamp_checkMap02Objectives, "Crush all opposition", WAR_CAMPAIGNS_ORC_02_INTRO, "Like the stinging of a wasp, the attacks from the\n" "humans grow more and more bothersome.\n" "You have been assigned to a small outpost on the\n" "Borderlands of the Swamps of Sorrow.\n" "You are to defend our lands from the incursions\n" "of these ravenous dogs by crushing any opposition\n" "that you encounter.", 22.0f }, { WAR_CAMPAIGN_HUMANS_03, NULL, "Destroy outpost", WAR_CAMPAIGNS_HUMAN_03_INTRO, "With Blackhand's raiding parties routed, now is the time for\n" "us to secure a lasting peace in the area around Grand Hamlet.\n" "You must seek out the Orcish outpost of Kyross that lies deep\n" "within the Swamps of Sorrow, and destroy it.", 22.0f }, { WAR_CAMPAIGN_ORCS_03, NULL, "Demolish Grand Hamlet", WAR_CAMPAIGNS_ORC_03_INTRO, "The Humans are growing strong in Grand Hamlet. An outpost will\n" "be placed under your dictatorship to use as you see fit. You must\n" "then prepare and lead a force to destroy Grand Hamlet and all that\n" "dwell there. Blackhand will brook no survivors - these Humans must\n" "be taught a hard lesson in the ways of humility.", 22.0f }, { WAR_CAMPAIGN_HUMANS_04, NULL, "Find lothar,\nheal him and bring\nthem out", WAR_CAMPAIGNS_HUMAN_04_INTRO, "It has been some twenty months since Sir Lothar, one of the crown's\n" "greatest heroes, led an expedition into the Dead Mines to search for\n" "the Lost Tome of Divinity. They were never heard from again.\n" "However, the great knight has recently appeared to the Abbot of\n" "Northshire in a vision - battered and pleading for assistance.\n" "King Llane has ordered you to lead a detachment of warriors and healers\n" "into the mines in an attempt to find Sir Lothar, heal him, and bring him\n" "and any other survivors back alive.", 22.0f }, { WAR_CAMPAIGN_ORCS_04, NULL, "Kill griselda and\nher minions", WAR_CAMPAIGNS_ORC_04_INTRO, "You are wakened from your nights sleep by a runner from the War Chief.\n" "Blackhand's daughter Griselda has run off with the outlaw Turok's band of Ogres.\n" "Our wolfriders have tracked them to the dungeons hidden beneath the Dead Mines.\n" "Find Turok's band of rebellious pigs and kill them all --- including Griselda.\n" "She must not disobey the commands of her father... ever again.", 22.0f }, { WAR_CAMPAIGN_HUMANS_05, NULL, "Destroy orcs", WAR_CAMPAIGNS_HUMAN_05_INTRO, "The Forest of Elwynn is a strategic key to securing the Borderlands.\n" "An outpost near the southeast edge of the forest will serve as your stronghold.\n" "The King has assigned one of his knights to aid you, so that your task of ridding\n" "the area of Blackhand's dark minions may be more readily completed.", 22.0f }, { WAR_CAMPAIGN_ORCS_05, NULL, "Save the outpost\nSlay all humans", WAR_CAMPAIGNS_ORC_05_INTRO, "On your return from the dungeon, you receive word from advance scouts that the\n" "recently established outpost near the Red Ridge Mountains is under siege.\n" "A group of raiders have been dispatched to assist you in taking back the\n" "outpost and crushing the Human opposition. Your secondary objective is to seek\n" "out and completely destroy their encampment, putting an end to this threat for good.", 22.0f }, { WAR_CAMPAIGN_HUMANS_06, NULL, "Save the abbey and\ndestroy the traitors", WAR_CAMPAIGNS_HUMAN_06_INTRO, "The monks of Northshire Abbey are under siege by a band of warriors that have been\n" "convinced by enemy agents to fight against the crown. You will be given a complement\n" "of knights to lead to the Abbey, which is already under attack. Ride hard and fast,\n" "as you must prevent its destruction. When you have secured the Abbey and beaten back\n" "these treacherous curs, you must then move to destroy the enemy at their source.", 22.0f }, { WAR_CAMPAIGN_ORCS_06, NULL, "Raze sunnyglade\nSave tower", WAR_CAMPAIGNS_ORC_06_INTRO, "The Humans of Sunnyglade have become fat and lazy with their prosperity.\n" "The town is like a ripe plum waiting to be plucked. You will march upon their\n" "weak Human armies and smash them to pieces. Somewhere in the town is a tower that\n" "you must keep intact so that we may study how their magiks are created. Fail me,\n" "and I will have your head on a pike at the gates of Black Rock Spire.", 22.0f }, { WAR_CAMPAIGN_HUMANS_07, NULL, "Rescue peasants\nDemolish orcs", WAR_CAMPAIGNS_HUMAN_07_INTRO, "A raiding party has completely overrun the village of Sunnyglade.\n" "Our scouts report that the survivors have been taken to a hidden Orcish\n" "compound to serve as slaves. You must take a detachment of warriors and\n" "rescue the group of peasants that are imprisoned somewhere in the Orc camp.\n" "Our intelligence confirms that all of the prisoners are together, and that\n" "you must destroy the enclosure to open a path for their escape.\n" "The rebuilding of Sunnyglade is also of the utmost importance,\n" "as you will need their assistance in destroying the Orcish slavers.", 22.0f }, { WAR_CAMPAIGN_ORCS_07, NULL, "Kill Blackhand's troops", WAR_CAMPAIGNS_ORC_07_INTRO, "The time has come for you to seize control of the Orcish hordes for yourself.\n" "Blackhand has become foolish in the deployment of his personal troops, and has\n" "left an opening that you can now exploit. A key outpost in the Black Morass is\n" "the core of Blackhand's supply lines - not only to his foremost battle groups,\n" "but to his castle at Black Rock Spire, as well. The complete destruction of this\n" "outpost will disrupt his power base long enough for you to secure his overthrow.", 22.0f }, { WAR_CAMPAIGN_HUMANS_08, NULL, "Slay Medivh and\nall minions", WAR_CAMPAIGNS_HUMAN_08_INTRO, "A new crisis has arisen that threatens to end the lives of all who would\n" "serve the King. The evil warlock Medivh has begun draining the soul of\n" "the land itself to increase his dark powers. You must take a party into\n" "his tower and destroy him before he summons enough energies to devastate\n" "all who would oppose him. Beware his mastery of the black arts, for\n" "legend speaks of his ability to command the daemons of Hell.", 22.0f }, { WAR_CAMPAIGN_ORCS_08, NULL, "Save garona\nDestroy the abbey", WAR_CAMPAIGNS_ORC_08_INTRO, "The destruction of Blackhand's outpost has left him in a weak position.\n" "The Shadow Council, sensing your rise in power, orders the assassination\n" "of Blackhand and elevates you to the position of War Chief.\n" "A wolfrider brings you news that our best spy, the half-orc Garona,\n" "has been discovered by the Humans of Northshire Abbey and imprisoned there.\n" "She has valuable information concerning new and powerful magiks that would\n" "aid you in the destruction of your counterpart - King Llane.\n" "Trusting no one to complete this vital mission in time, you must find her,\n" "and then completely destroy the Abbey to protect her secrets.", 22.0f }, { WAR_CAMPAIGN_HUMANS_09, NULL, "Destroy all traces\nof the orcs", WAR_CAMPAIGNS_HUMAN_09_INTRO, "The time has come to take the battle into Blackhand's own domain.\n" "King Llane has ordered a full assault upon the Orcs, demanding\n" "that this plague that spreads across the kingdom be eradicated.\n" "To the east of the Borderlands lies the Black Morass where the\n" "Orcish hordes make their encampments. You are to lead an army into\n" "this foul region and destroy every trace of their dark presence.", 22.0f }, { WAR_CAMPAIGN_ORCS_09, NULL, "Crush the two human\noutposts", WAR_CAMPAIGNS_ORC_09_INTRO, "With your new found magiks, the time is ripe to burn the Human\n" "occupation from our lands. There are two Human outposts to the\n" "south that pose the greatest threat to our security.\n" "Reports from scouts near these towns show that the key to your\n" "success in this confrontation is to hold back the Human forces\n" "at their bridges while you strengthen your attack force.\n" "The glories of combat will be yours as you personally lead the\n" "armies that will reclaim your homelands.", 22.0f }, { WAR_CAMPAIGN_HUMANS_10, NULL, "Destroy temple raze town\nKill orcs", WAR_CAMPAIGNS_HUMAN_10_INTRO, "Runners have arrived and informed you of grave news. King Llane\n" "lies dead this day, assassinated by the treacherous Garona, at\n" "Stormwind Keep. His last command was that you should assume the\n" "mantle of War Leader, and end this battle that has drained the land\n" "of its resources, and now its king. Scouts report that deep within\n" "the Black Morass lies one of Blackhand's darkest seats of power ---\n" "the Temple of the Damned. No peasants dare approach the vile temple,\n" "and only the bravest of your soldiers have agreed to accompany you on\n" "this mission. You must strike boldly and without err, for there will\n" "be no reinforcements.", 22.0f }, { WAR_CAMPAIGN_ORCS_10, NULL, "Destroy the human camp", WAR_CAMPAIGNS_ORC_10_INTRO, "You have tasted victory, and the craving for more is upon you.\n" "It is clear that one decisive blow to the Humans will make the total\n" "and complete domination of this race a simple matter.\n" "Your spies have gathered intelligence that points to an encampment\n" "near the center of the Human lands where their knights and soldiers\n" "are sent to train. Although they will not be expecting an attack,\n" "they should prove a good fight. The destruction of this site would\n" "greatly weaken their forces, and etch your position as War Chief\n" "in stone. None shall survive!", 22.0f }, { WAR_CAMPAIGN_HUMANS_11, NULL, "Destroy rockard\nDestroy stonard", WAR_CAMPAIGNS_HUMAN_11_INTRO, "Here beats the diseased and malevolent heart of Blackhand's plagued lands.\n" "The sister towns of Rockard and Stonard are all that stand between the\n" "forces of the kingdom and Blackhand's stronghold - Black Rock Spire.\n" "After conferring with your warchiefs, the path to victory lays clear.\n" "You must destroy Rockard and Stonard, thereby cutting off all lines of\n" "support and supplies, so that the final offensive can be made upon Black Rock Spire.", 22.0f }, { WAR_CAMPAIGN_ORCS_11, NULL, "Raze moonbrook\nRaze goldshire", WAR_CAMPAIGNS_ORC_11_INTRO, "The final march to King Llane's home, Stormwind Keep, is at hand.\n" "Only two pathetic settlements stand in the way of the awesome\n" "juggernaut your cruel leadership has created. The Humans have proved\n" "to be amusing opposition, but the hour of doom has come for them.\n" "The complete and utter demolition of the twin cities Goldshire and\n" "Moonbrook will sever the lifeline between the King and his people,\n" "making him a figurehead waiting to be lopped off.", 22.0f }, { WAR_CAMPAIGN_HUMANS_12, NULL, "Destroy Black Rock Spire\nand all orcs!", WAR_CAMPAIGNS_HUMAN_12_INTRO, "Black Rock Spire stands before us! The skies above the reeking swamp\n" "fill with the gathering thunderheads that spell doom for the loser in\n" "this final confrontation. Tension hangs like a heavy cloak on your\n" "shoulders as your troops prepare for the battle ahead. Above the din\n" "and chaos that swirls about the battlefield stands the Castle of Blackhand,\n" "its gaze sweeping down upon the battlefield where the destiny of the land\n" "will be decided. Destroy the stronghold and those who would seek to defend it,\n" "and Azeroth will be freed from Blackhand's poisoned grip forever!", 22.0f }, { WAR_CAMPAIGN_ORCS_12, NULL, "Destroy Stormwind Keep\nand all humans!", WAR_CAMPAIGNS_ORC_12_INTRO, "Stormwind Keep is ours to take! The Orcish hordes gather like buzzards to\n" "carrion, as the moment of destiny is close at hand. A low growl fills the\n" "air as your wolfriders whip their savage mounts into a frenzy. The earth\n" "shakes as catapults are loaded and moved into position. The fires of the\n" "burning rubble about you dance in your eyes as you gaze upon the pristine,\n" "white towers of Castle Stormwind. White that will soon be washed with the\n" "red of King Llane's blood. With his fall, all of Azeroth will be yours!", 22.0f }, { WAR_CAMPAIGN_CUSTOM, wcamp_checkCustomMapObjectives, "Destroy enemy", 0, NULL, 0.0f } }; WarCampaignMapData wcamp_getCampaignData(WarCampaignMapType type) { s32 index = 0; s32 length = arrayLength(campaignsData); while (index < length && campaignsData[index].type != type) index++; assert(index < length); const WarCampaignMapRawData* rawData = &campaignsData[index]; WarCampaignMapData data; data.type = rawData->type; data.checkObjectivesFunc = rawData->checkObjectivesFunc; data.objectives = wsv_fromCString(rawData->objectives); data.briefingAudioId = rawData->briefingAudioId; data.briefingText = wsv_fromCString(rawData->briefingText); data.briefingDuration = rawData->briefingDuration; return data; } WarLevelResult wcamp_checkMap01Objectives(WarContext* context) { WarMap* map = context->map; WarPlayerInfo* player = &map->players[0]; WarUnitType farmType = isHumanPlayer(player) ? WAR_UNIT_FARM_HUMANS : WAR_UNIT_FARM_ORCS; WarUnitType barracksType = isHumanPlayer(player) ? WAR_UNIT_BARRACKS_HUMANS : WAR_UNIT_BARRACKS_ORCS; if (wu_getNumberOfBuildingsOfType(context, player->index, farmType, true) >= 6 && wu_getNumberOfBuildingsOfType(context, player->index, barracksType, true) >= 1) { return WAR_LEVEL_RESULT_WIN; } if (wu_getTotalNumberOfUnits(context, player->index) == 0) { return WAR_LEVEL_RESULT_LOSE; } return WAR_LEVEL_RESULT_NONE; } WarLevelResult wcamp_checkMap02Objectives(WarContext* context) { WarMap* map = context->map; WarPlayerInfo* player = &map->players[0]; WarPlayerInfo* enemy = &map->players[1]; if (wu_getTotalNumberOfDudes(context, enemy->index) == 0) { return WAR_LEVEL_RESULT_WIN; } if (wu_getTotalNumberOfUnits(context, player->index) == 0) { return WAR_LEVEL_RESULT_LOSE; } return WAR_LEVEL_RESULT_NONE; } WarLevelResult wcamp_checkCustomMapObjectives(WarContext* context) { WarMap* map = context->map; WarPlayerInfo* player = &map->players[0]; WarPlayerInfo* enemy = &map->players[1]; if (wu_getTotalNumberOfUnits(context, enemy->index) == 0) { return WAR_LEVEL_RESULT_WIN; } if (wu_getTotalNumberOfUnits(context, player->index) == 0) { return WAR_LEVEL_RESULT_LOSE; } return WAR_LEVEL_RESULT_NONE; } ================================================ FILE: src/war_campaigns.h ================================================ #pragma once #include "war_audio.h" struct _WarCampaignMapData { WarCampaignMapType type; WarCheckObjectivesFunc checkObjectivesFunc; StringView objectives; WarAudioId briefingAudioId; StringView briefingText; f32 briefingDuration; }; WarCampaignMapData wcamp_getCampaignData(WarCampaignMapType type); ================================================ FILE: src/war_cheats.c ================================================ #include "war_cheats.h" #include "shl/wstr.h" #include "war_audio.h" #include "war_entities.h" #include "war_game.h" #include "war_scenes.h" #include "war_units.h" #include "war_map_menu.h" const WarCheatDescriptor cheatDescriptors[] = { // original cheats { WAR_CHEAT_GOLD, "Pot of gold", false, wcheat_applyGoldCheat }, { WAR_CHEAT_SPELLS, "Eye of newt", false, wcheat_applySpellsCheat }, { WAR_CHEAT_UPGRADES, "Iron forge", false, wcheat_applyUpgradesCheat }, { WAR_CHEAT_END, "Ides of march", false, wcheat_applyEndCheat }, { WAR_CHEAT_ENABLE, "Corwin of Amber", false, wcheat_applyEnableCheat }, { WAR_CHEAT_GOD_MODE, "There can be only one", false, wcheat_applyGodModeCheat }, { WAR_CHEAT_WIN, "Yours truly", false, wcheat_applyWinCheat }, { WAR_CHEAT_LOSS, "Crushing defeat", false, wcheat_applyLossCheat }, { WAR_CHEAT_FOG, "Sally Shears", false, wcheat_applyFogOfWarCheat }, { WAR_CHEAT_SKIP_HUMAN, "Human", true, wcheat_applySkipHumanCheat }, { WAR_CHEAT_SKIP_ORC, "Orc", true, wcheat_applySkipOrcCheat }, { WAR_CHEAT_SPEED, "Hurry up guys", false, wcheat_applySpeedCheat }, // custom cheats { WAR_CHEAT_MUSIC_VOL, "Music vol", true, wcheat_applyMusicVolCheat }, { WAR_CHEAT_SOUND_VOL, "Sound vol", true, wcheat_applySoundVolCheat }, { WAR_CHEAT_MUSIC, "Music", true, wcheat_applyMusicCheat }, { WAR_CHEAT_SOUND, "Sound", true, wcheat_applySoundCheat }, { WAR_CHEAT_GLOBAL_SCALE, "Scale", true, wcheat_applyGlobalScaleCheat }, { WAR_CHEAT_GLOBAL_SPEED, "Speed", true, wcheat_applyGlobalSpeedCheat }, { WAR_CHEAT_EDIT, "Edit", true, wcheat_applyEditCheat }, { WAR_CHEAT_ADD_UNIT, "Add unit", true, wcheat_applyAddUnitCheat }, { WAR_CHEAT_RAIN_OF_FIRE, "Rain of fire", false, wcheat_applyRainOfFireCheat }, }; void wcheat_applyCheat(WarContext* context, StringView text) { for (s32 i = 0; i < arrayLength(cheatDescriptors); i++) { WarCheatDescriptor desc = cheatDescriptors[i]; StringView descText = wsv_fromCString(desc.text); if (!desc.argument) { if (wsv_equalsIgnoreCase(text, descText)) { desc.cheatFunc(context, wsv_empty()); return; } } else { if (wsv_startsWithIgnoreCase(text, descText)) { StringView argument = wsv_subview(text, descText.length); argument = wsv_trimLeft(argument); // skip whitespace characters desc.cheatFunc(context, argument); return; } } } // if we reach here no cheat was applied logInfo("Unknown cheat: %.*s", (int)text.length, text.data); } void wcheat_applyGoldCheat(WarContext* context, StringView argument) { NOT_USED(argument); if (!context->cheatsEnabled) return; WarMap* map = context->map; if (!map) return; we_increasePlayerResources(context, &map->players[0], CHEAT_GOLD_INCREASE, CHEAT_WOOD_INCREASE); wcheatp_setCheatsFeedback(context, wstr_fromCString(CHEAT_FEEDBACK_WASCALLY_WABBIT)); } void wcheat_applySpellsCheat(WarContext* context, StringView argument) { NOT_USED(argument); if (!context->cheatsEnabled) return; WarMap* map = context->map; if (!map) return; WarPlayerInfo* player = &map->players[0]; WarFeatureType spellFeatures[] = { WAR_FEATURE_SPELL_HEALING, WAR_FEATURE_SPELL_RAISE_DEAD, WAR_FEATURE_SPELL_FAR_SIGHT, WAR_FEATURE_SPELL_DARK_VISION, WAR_FEATURE_SPELL_INVISIBILITY, WAR_FEATURE_SPELL_UNHOLY_ARMOR, WAR_FEATURE_SPELL_SCORPION, WAR_FEATURE_SPELL_SPIDER, WAR_FEATURE_SPELL_RAIN_OF_FIRE, WAR_FEATURE_SPELL_POISON_CLOUD, WAR_FEATURE_SPELL_WATER_ELEMENTAL, WAR_FEATURE_SPELL_DAEMON, }; for (s32 i = 0; i < arrayLength(spellFeatures); i++) { setFeatureAllowed(player, spellFeatures[i], true); } WarUpgradeType upgradeFeatures[] = { WAR_UPGRADE_SCORPIONS, WAR_UPGRADE_SPIDERS, WAR_UPGRADE_RAIN_OF_FIRE, WAR_UPGRADE_POISON_CLOUD, WAR_UPGRADE_WATER_ELEMENTAL, WAR_UPGRADE_DAEMON, WAR_UPGRADE_HEALING, WAR_UPGRADE_RAISE_DEAD, WAR_UPGRADE_FAR_SIGHT, WAR_UPGRADE_DARK_VISION, WAR_UPGRADE_INVISIBILITY, WAR_UPGRADE_UNHOLY_ARMOR }; for (s32 i = 0; i < arrayLength(upgradeFeatures); i++) { const WarUpgradeData* upgradeData = wu_getUpgradeData(upgradeFeatures[i]); setUpgradeAllowed(player, upgradeFeatures[i], upgradeData->maxLevelAllowed); while (hasRemainingUpgrade(player, upgradeFeatures[i])) { we_increaseUpgradeLevel(context, player, upgradeFeatures[i]); } } wcheatp_setCheatsFeedback(context, wstr_fromCString(CHEAT_FEEDBACK_WASCALLY_WABBIT)); } void wcheat_applyUpgradesCheat(WarContext* context, StringView argument) { NOT_USED(argument); if (!context->cheatsEnabled) return; WarMap* map = context->map; if (!map) return; WarPlayerInfo* player = &map->players[0]; WarUpgradeType upgrades[] = { WAR_UPGRADE_ARROWS, WAR_UPGRADE_SPEARS, WAR_UPGRADE_SWORDS, WAR_UPGRADE_AXES, WAR_UPGRADE_SHIELD }; for (s32 i = 0; i < arrayLength(upgrades); i++) { const WarUpgradeData* upgradeData = wu_getUpgradeData(upgrades[i]); setUpgradeAllowed(player, upgrades[i], upgradeData->maxLevelAllowed); while (hasRemainingUpgrade(player, upgrades[i])) { we_increaseUpgradeLevel(context, player, upgrades[i]); } } wcheatp_setCheatsFeedback(context, wstr_fromCString(CHEAT_FEEDBACK_WASCALLY_WABBIT)); } void wcheat_applyEndCheat(WarContext* context, StringView argument) { NOT_USED(argument); if (!context->cheatsEnabled) return; WarMap* map = context->map; if (!map) return; map->playing = false; wmm_showDemoEndMenu(context, true); } void wcheat_applyEnableCheat(WarContext* context, StringView argument) { NOT_USED(argument); if (!context->cheatsEnabled) { context->cheatsEnabled = true; wcheatp_setCheatsFeedback(context, wstr_fromCString("cheats enabled")); } else { context->cheatsEnabled = false; wcheatp_setCheatsFeedback(context, wstr_fromCString("cheats disabled")); } } void wcheat_applyGodModeCheat(WarContext* context, StringView argument) { NOT_USED(argument); if (!context->cheatsEnabled) return; WarMap* map = context->map; if (!map) return; WarPlayerInfo* player = &map->players[0]; player->godMode = !player->godMode; wcheatp_setCheatsFeedback(context, wstr_fromCString(CHEAT_FEEDBACK_WASCALLY_WABBIT)); } void wcheat_applyWinCheat(WarContext* context, StringView argument) { NOT_USED(argument); if (!context->cheatsEnabled) return; WarMap* map = context->map; if (!map) return; map->result = WAR_LEVEL_RESULT_WIN; wcheatp_setCheatsFeedback(context, wstr_fromCString(CHEAT_FEEDBACK_WASCALLY_WABBIT)); } void wcheat_applyLossCheat(WarContext* context, StringView argument) { NOT_USED(argument); if (!context->cheatsEnabled) return; WarMap* map = context->map; if (!map) return; map->result = WAR_LEVEL_RESULT_LOSE; wcheatp_setCheatsFeedback(context, wstr_fromCString(CHEAT_FEEDBACK_WASCALLY_WABBIT)); } void wcheat_applyFogOfWarCheat(WarContext* context, StringView argument) { NOT_USED(argument); if (!context->cheatsEnabled) return; WarMap* map = context->map; if (!map) return; map->fowEnabled = !map->fowEnabled; wcheatp_setCheatsFeedback(context, wstr_fromCString(CHEAT_FEEDBACK_WASCALLY_WABBIT)); } void wcheat_applySkipHumanCheat(WarContext* context, StringView argument) { if (!context->cheatsEnabled) return; WarMap* map = context->map; if (!map) return; s32 level; if (wsv_tryParseS32(argument, &level)) { // TODO: remove this check when more levels are allowed if (level <= 0 || level > 2) return; WarScene* scene = wsc_createScene(context, WAR_SCENE_BRIEFING); scene->briefing.race = WAR_RACE_HUMANS; scene->briefing.mapType = WAR_CAMPAIGN_HUMANS_01 + 2 * (level - 1); wg_setNextScene(context, scene, 1.0f); } } void wcheat_applySkipOrcCheat(WarContext* context, StringView argument) { if (!context->cheatsEnabled) return; WarMap* map = context->map; if (!map) return; s32 level; if (wsv_tryParseS32(argument, &level)) { // TODO: remove this check when more levels are allowed if (level <= 0 || level > 2) return; WarScene* scene = wsc_createScene(context, WAR_SCENE_BRIEFING); scene->briefing.race = WAR_RACE_ORCS; scene->briefing.mapType = WAR_CAMPAIGN_ORCS_01 + 2 * (level - 1); wg_setNextScene(context, scene, 1.0f); } } void wcheat_applySpeedCheat(WarContext* context, StringView argument) { NOT_USED(argument); if (!context->cheatsEnabled) return; WarMap* map = context->map; if (!map) return; map->hurryUp = !map->hurryUp; wcheatp_setCheatsFeedback(context, wstr_fromCString(CHEAT_FEEDBACK_WASCALLY_WABBIT)); } void wcheat_applyMusicCheat(WarContext* context, StringView argument) { if (!context->cheatsEnabled) return; if (wsv_equalsIgnoreCase(argument, wsv_fromCString("on"))) { context->musicEnabled = true; wcheatp_setCheatsFeedback(context, wstr_fromCString("Music on")); } else if (wsv_equalsIgnoreCase(argument, wsv_fromCString("off"))) { context->musicEnabled = false; wcheatp_setCheatsFeedback(context, wstr_fromCString("Music off")); } else if (!isDemo(context)) { s32 musicId; if (wsv_tryParseS32(argument, &musicId)) { // argument is expected in the range 1-45, so convert it to the range 0-44 musicId--; if (musicId >= WAR_MUSIC_00 && musicId <= WAR_MUSIC_44) { // before changing the music, remove the current one // almost all the time there should only one active // but I really don't if that will hold true in the future // // for now remove all the active music (audios of type WAR_AUDIO_MIDI) // and the create the new one wa_removeAudiosOfType(context, WAR_AUDIO_MIDI); wa_createAudio(context, CREATE_AUDIO_ARGS_INIT(.audioId=musicId, .loop=true)); wcheatp_setCheatsFeedback(context, wstr_fromCStringFormat("Music %d set", musicId + 1)); } } } } void wcheat_applySoundCheat(WarContext* context, StringView argument) { if (!context->cheatsEnabled) return; if (wsv_equalsIgnoreCase(argument, wsv_fromCString("on"))) { context->soundEnabled = true; wcheatp_setCheatsFeedback(context, wstr_fromCString("Sounds on")); } else if (wsv_equalsIgnoreCase(argument, wsv_fromCString("off"))) { context->soundEnabled = false; wcheatp_setCheatsFeedback(context, wstr_fromCString("Sounds off")); } } void wcheat_applyMusicVolCheat(WarContext* context, StringView argument) { if (!context->cheatsEnabled) return; s32 musicVol; if (wsv_tryParseS32(argument, &musicVol)) { musicVol = CLAMP(musicVol, 0, 100); // round the argument to a value multiple of 5 switch (musicVol % 5) { case 1: { musicVol -= 1; break; } case 2: { musicVol -= 2; break; } case 3: { musicVol += 2; break; } case 4: { musicVol += 1; break; } default: { // do nothing, it's already a multiple of 5 break; } } context->audioEnabled = true; context->musicEnabled = true; wg_setMusicVolume(context, (f32)musicVol / 100.0f); wcheatp_setCheatsFeedback(context, wstr_fromCStringFormat("Music volume set to %d", musicVol)); } } void wcheat_applySoundVolCheat(WarContext* context, StringView argument) { if (!context->cheatsEnabled) return; s32 sfxVol; if (wsv_tryParseS32(argument, &sfxVol)) { sfxVol = CLAMP(sfxVol, 0, 100); // round the argument to a value multiple of 5 switch (sfxVol % 5) { case 1: { sfxVol -= 1; break; } case 2: { sfxVol -= 2; break; } case 3: { sfxVol += 2; break; } case 4: { sfxVol += 1; break; } default: { // do nothing, it's already a multiple of 5 break; } } context->audioEnabled = true; context->soundEnabled = true; wg_setSoundVolume(context, (f32)sfxVol / 100.0f); wcheatp_setCheatsFeedback(context, wstr_fromCStringFormat("Sounds volume set to %d", sfxVol)); } } void wcheat_applyGlobalScaleCheat(WarContext* context, StringView argument) { if (!context->cheatsEnabled) return; s32 scale; if (wsv_tryParseS32(argument, &scale)) { scale = CLAMP(scale, 1, 5); wg_setGlobalScale(context, (f32)scale); wcheatp_setCheatsFeedback(context, wstr_fromCStringFormat("Global scale set to %d", scale)); } } void wcheat_applyGlobalSpeedCheat(WarContext* context, StringView argument) { if (!context->cheatsEnabled) return; s32 speed; if (wsv_tryParseS32(argument, &speed)) { speed = CLAMP(speed, 1, 5); wg_setGlobalSpeed(context, (f32)speed); wcheatp_setCheatsFeedback(context, wstr_fromCStringFormat("Global speed set to %d", speed)); } } void wcheat_applyEditCheat(WarContext* context, StringView argument) { if (!context->cheatsEnabled) return; WarMap* map = context->map; if (!map) return; map->editingTrees = false; map->editingWalls = false; map->editingRoads = false; map->editingRuins = false; map->editingRainOfFire = false; map->addingUnit = false; if (wsv_equalsIgnoreCase(argument, wsv_fromCString("off"))) { wcheatp_setCheatsFeedback(context, wstr_fromCString("Edit off")); return; } if (wsv_equalsIgnoreCase(argument, wsv_fromCString("trees"))) { map->editingTrees = true; wcheatp_setCheatsFeedback(context, wstr_fromCString("Edit trees on")); } else if (wsv_equalsIgnoreCase(argument, wsv_fromCString("walls"))) { map->editingWalls = true; wcheatp_setCheatsFeedback(context, wstr_fromCString("Edit walls on")); } else if (wsv_equalsIgnoreCase(argument, wsv_fromCString("roads"))) { map->editingRoads = true; wcheatp_setCheatsFeedback(context, wstr_fromCString("Edit roads on")); } else if (wsv_equalsIgnoreCase(argument, wsv_fromCString("ruins"))) { map->editingRuins = true; wcheatp_setCheatsFeedback(context, wstr_fromCString("Edit ruins on")); } } void wcheat_applyRainOfFireCheat(WarContext* context, StringView argument) { NOT_USED(argument); if (!context->cheatsEnabled) return; WarMap* map = context->map; if (!map) return; map->editingTrees = false; map->editingWalls = false; map->editingRoads = false; map->editingRuins = false; map->editingRainOfFire = !map->editingRainOfFire; map->addingUnit = false; if (map->editingRainOfFire) wcheatp_setCheatsFeedback(context, wstr_fromCString("Rain of fire on")); else wcheatp_setCheatsFeedback(context, wstr_fromCString("Rain of fire off")); } void wcheat_applyAddUnitCheat(WarContext* context, StringView argument) { if (!context->cheatsEnabled) return; WarMap* map = context->map; if (!map) return; map->editingTrees = false; map->editingWalls = false; map->editingRoads = false; map->editingRuins = false; map->editingRainOfFire = false; map->addingUnit = false; if (wsv_startsWithIgnoreCase(argument, wsv_fromCString("off"))) { wcheatp_setCheatsFeedback(context, wstr_fromCString("Add unit off")); return; } StringView part1, part2; if (!wsv_nextToken(&argument, wsv_fromCString(" "), &part1)) { part1 = argument; } wsv_nextToken(&argument, wsv_fromCString(" "), &part2); if (wsv_equalsIgnoreCase(part1, wsv_fromCString("CATAPULT"))) { if (wsv_startsWithIgnoreCase(part2, wsv_fromCString("HUMANS"))) { map->addingUnit = true; map->addingUnitType = WAR_UNIT_CATAPULT_HUMANS; } else if (wsv_startsWithIgnoreCase(part2, wsv_fromCString("ORCS"))) { map->addingUnit = true; map->addingUnitType = WAR_UNIT_CATAPULT_ORCS; } } else if (wsv_equalsIgnoreCase(part1, wsv_fromCString("FARM"))) { if (wsv_startsWithIgnoreCase(part2, wsv_fromCString("HUMANS"))) { map->addingUnit = true; map->addingUnitType = WAR_UNIT_FARM_HUMANS; } else if (wsv_startsWithIgnoreCase(part2, wsv_fromCString("ORCS"))) { map->addingUnit = true; map->addingUnitType = WAR_UNIT_FARM_ORCS; } } else if (wsv_equalsIgnoreCase(part1, wsv_fromCString("BARRACKS"))) { if (wsv_startsWithIgnoreCase(part2, wsv_fromCString("HUMANS"))) { map->addingUnit = true; map->addingUnitType = WAR_UNIT_BARRACKS_HUMANS; } else if (wsv_startsWithIgnoreCase(part2, wsv_fromCString("ORCS"))) { map->addingUnit = true; map->addingUnitType = WAR_UNIT_BARRACKS_ORCS; } } else if (wsv_equalsIgnoreCase(part1, wsv_fromCString("TOWER"))) { if (wsv_startsWithIgnoreCase(part2, wsv_fromCString("HUMANS"))) { map->addingUnit = true; map->addingUnitType = WAR_UNIT_TOWER_HUMANS; } else if (wsv_startsWithIgnoreCase(part2, wsv_fromCString("ORCS"))) { map->addingUnit = true; map->addingUnitType = WAR_UNIT_TOWER_ORCS; } } else if (wsv_equalsIgnoreCase(part1, wsv_fromCString("TOWN")) && wsv_equalsIgnoreCase(part2, wsv_fromCString("HALL"))) { StringView part3; wsv_nextToken(&argument, wsv_fromCString(" "), &part3); if (wsv_startsWithIgnoreCase(part3, wsv_fromCString("HUMANS"))) { map->addingUnit = true; map->addingUnitType = WAR_UNIT_TOWNHALL_HUMANS; } else if (wsv_startsWithIgnoreCase(part3, wsv_fromCString("ORCS"))) { map->addingUnit = true; map->addingUnitType = WAR_UNIT_TOWNHALL_ORCS; } } else if (wsv_equalsIgnoreCase(part1, wsv_fromCString("MILL"))) { if (wsv_startsWithIgnoreCase(part2, wsv_fromCString("HUMANS"))) { map->addingUnit = true; map->addingUnitType = WAR_UNIT_LUMBERMILL_HUMANS; } else if (wsv_startsWithIgnoreCase(part2, wsv_fromCString("ORCS"))) { map->addingUnit = true; map->addingUnitType = WAR_UNIT_LUMBERMILL_ORCS; } } else if (wsv_equalsIgnoreCase(part1, wsv_fromCString("BLACKSMITH"))) { if (wsv_startsWithIgnoreCase(part2, wsv_fromCString("HUMANS"))) { map->addingUnit = true; map->addingUnitType = WAR_UNIT_BLACKSMITH_HUMANS; } else if (wsv_startsWithIgnoreCase(part2, wsv_fromCString("ORCS"))) { map->addingUnit = true; map->addingUnitType = WAR_UNIT_BLACKSMITH_ORCS; } } else if (wsv_equalsIgnoreCase(part1, wsv_fromCString("CORPSE"))) { if (wsv_startsWithIgnoreCase(part2, wsv_fromCString("HUMANS"))) { map->addingUnit = true; map->addingUnitType = WAR_UNIT_HUMAN_CORPSE; } else if (wsv_startsWithIgnoreCase(part2, wsv_fromCString("ORCS"))) { map->addingUnit = true; map->addingUnitType = WAR_UNIT_ORC_CORPSE; } } else { for (s32 i = 0; i < arrayLength(unitsData); i++) { if (wsv_equalsIgnoreCase(part1, unitsData[i].name)) { map->addingUnit = true; map->addingUnitType = (WarUnitType)i; break; } } } if (map->addingUnit) { wcheatp_setCheatsFeedback(context, wstr_fromCStringFormat("Add unit %.*s", (int)argument.length, argument.data)); } } ================================================ FILE: src/war_cheats.h ================================================ #pragma once #include "war_math.h" #include "war_fwd.h" #define STATUS_TEXT_MAX_LENGTH 40 #define CHEAT_TEXT_MAX_LENGTH 32 #define CHEAT_FEEDBACK_TEXT_MAX_LENGTH 50 struct _WarFlashStatus { bool enabled; f32 startTime; f32 duration; String text; }; struct _WarCheatStatus { bool enabled; bool visible; s32 position; String text; bool feedback; f32 feedbackTime; String feedbackText; // X offset (relative to panel.x + 2) of the blinking cursor rect. // Written by the update function; read by the render function. // Negative value means cursor is not visible. f32 cursorX; }; #define CHEAT_GOLD_INCREASE 10000 #define CHEAT_WOOD_INCREASE 5000 #define CHEAT_SPEED_UP_FACTOR 100.0f #define CHEAT_FEEDBACK_WASCALLY_WABBIT "cheat enabled you wascally wabbit" struct _WarCheatDescriptor { WarCheat cheat; char text[CHEAT_TEXT_MAX_LENGTH]; bool argument; WarCheatFunc cheatFunc; }; void wcheat_applyCheat(WarContext* context, StringView text); #define cheatsEnabledAndVisible(mapOrScene) ((mapOrScene)->cheatStatus.enabled && (mapOrScene)->cheatStatus.visible) // original cheats void wcheat_applyGoldCheat(WarContext* context, StringView argument); void wcheat_applySpellsCheat(WarContext* context, StringView argument); void wcheat_applyUpgradesCheat(WarContext* context, StringView argument); void wcheat_applyEndCheat(WarContext* context, StringView argument); void wcheat_applyEnableCheat(WarContext* context, StringView argument); void wcheat_applyGodModeCheat(WarContext* context, StringView argument); void wcheat_applyWinCheat(WarContext* context, StringView argument); void wcheat_applyLossCheat(WarContext* context, StringView argument); void wcheat_applyFogOfWarCheat(WarContext* context, StringView argument); void wcheat_applySkipHumanCheat(WarContext* context, StringView argument); void wcheat_applySkipOrcCheat(WarContext* context, StringView argument); void wcheat_applySpeedCheat(WarContext* context, StringView argument); // custom cheats void wcheat_applyMusicCheat(WarContext* context, StringView argument); void wcheat_applySoundCheat(WarContext* context, StringView argument); void wcheat_applyMusicVolCheat(WarContext* context, StringView argument); void wcheat_applySoundVolCheat(WarContext* context, StringView argument); void wcheat_applyGlobalScaleCheat(WarContext* context, StringView argument); void wcheat_applyGlobalSpeedCheat(WarContext* context, StringView argument); void wcheat_applyEditCheat(WarContext* context, StringView argument); void wcheat_applyRainOfFireCheat(WarContext* context, StringView argument); void wcheat_applyAddUnitCheat(WarContext* context, StringView argument); // ui void wcheatp_setCheatsPanelVisible(WarContext* context, bool visible); void wcheatp_setCheatsFeedback(WarContext* context, String feedbackText); void wcheatp_createCheatsPanel(WarContext* context); void wcheatp_setCheatText(WarContext* context, String text); void wcheatp_updateCheatsPanel(WarContext* context); void wcheatp_renderCheatsPanel(WarContext* context); ================================================ FILE: src/war_cheats_panel.c ================================================ #include "war_cheats.h" #include #include #include #include "SDL3/SDL.h" #include "shl/wstr.h" #include "war_font.h" #include "war_imui.h" void wcheatp_setCheatsPanelVisible(WarContext* context, bool visible) { WarScene* scene = context->scene; WarMap* map = context->map; assert(scene || map); WarCheatStatus* cheatStatus = scene ? &scene->cheatStatus : &map->cheatStatus; wstr_clear(&cheatStatus->text); cheatStatus->position = 0; cheatStatus->cursorX = -1.0f; cheatStatus->visible = visible; if (visible) { SDL_StartTextInput(context->window); } else { SDL_StopTextInput(context->window); } } void wcheatp_setCheatsFeedback(WarContext* context, String feedbackText) { WarScene* scene = context->scene; WarMap* map = context->map; assert(scene || map); WarCheatStatus* cheatStatus = scene ? &scene->cheatStatus : &map->cheatStatus; if (cheatStatus->feedbackText.data) { wstr_free(cheatStatus->feedbackText); cheatStatus->feedbackText = wstr_make(); } if (feedbackText.data) { cheatStatus->feedback = true; cheatStatus->feedbackTime = 3.0f; cheatStatus->feedbackText = feedbackText; } else { cheatStatus->feedback = false; cheatStatus->feedbackTime = 0.0f; } } void wcheatp_createCheatsPanel(WarContext* context) { WarScene* scene = context->scene; assert(scene); WarCheatStatus* cheatStatus = &scene->cheatStatus; cheatStatus->enabled = true; cheatStatus->visible = false; cheatStatus->position = 0; cheatStatus->cursorX = -1.0f; wstr_clear(&cheatStatus->text); // NOTE: No retained entities are created; the panel is rendered each // frame by wcheatp_renderCheatsPanel() called from wsc_renderScene(). } void wcheatp_setCheatText(WarContext* context, String text) { NOT_USED(context); // Text is now derived directly from cheatStatus->text in wcheatp_renderCheatsPanel. // Free the String to avoid leaks if callers still pass one. wstr_free(text); } void wcheatp_updateCheatsPanel(WarContext* context) { WarScene* scene = context->scene; assert(scene); WarInput* input = &context->input; WarCheatStatus* cheatStatus = &scene->cheatStatus; if (!cheatStatus->enabled) return; // Tick feedback timer. if (cheatStatus->feedback) { cheatStatus->feedbackTime -= context->deltaTime; if (cheatStatus->feedbackTime <= 0) { cheatStatus->feedbackTime = 0; cheatStatus->feedback = false; } } if (cheatStatus->visible) { if (isKeyJustReleased(input, WAR_KEY_ESC) || isKeyJustReleased(input, WAR_KEY_ENTER)) { if (isKeyJustReleased(input, WAR_KEY_ENTER)) { wcheat_applyCheat(context, wstr_view(&cheatStatus->text)); } wcheatp_setCheatsPanelVisible(context, false); return; } if (isKeyJustReleased(input, WAR_KEY_TAB)) { s32 length = (s32)cheatStatus->text.length; if (TAB_WIDTH <= STATUS_TEXT_MAX_LENGTH - length) { wstr_insert(&cheatStatus->text, cheatStatus->position, wsv_fromCString("\t")); cheatStatus->position++; } } else if (isKeyJustReleased(input, WAR_KEY_BACKSPACE)) { if (cheatStatus->position > 0) { wstr_removeRange(&cheatStatus->text, cheatStatus->position - 1, 1); cheatStatus->position--; } } else if (isKeyJustReleased(input, WAR_KEY_DELETE)) { s32 length = (s32)cheatStatus->text.length; if (cheatStatus->position < length) { wstr_removeRange(&cheatStatus->text, cheatStatus->position, 1); } } else if (isKeyJustReleased(input, WAR_KEY_RIGHT)) { s32 length = (s32)cheatStatus->text.length; if (cheatStatus->position < length) { cheatStatus->position++; } } else if (isKeyJustReleased(input, WAR_KEY_LEFT)) { if (cheatStatus->position > 0) { cheatStatus->position--; } } else if (isKeyJustReleased(input, WAR_KEY_HOME)) { cheatStatus->position = 0; } else if (isKeyJustReleased(input, WAR_KEY_END)) { s32 length = (s32)cheatStatus->text.length; cheatStatus->position = length; } // Compute cursor X for the render step. StringView prefix = wsv_fromCString("MSG: "); StringView cheatStatusText = wstr_view(&cheatStatus->text); WarFontParams params = {0}; params.fontSize = 6.0f; params.fontData = getFontData(0); vec2 prefixSize = wfont_measureSingleSpriteText(prefix, (s32)wsv_length(prefix), params); vec2 textSize = wfont_measureSingleSpriteText(cheatStatusText, cheatStatus->position, params); cheatStatus->cursorX = 2.0f + prefixSize.x + textSize.x; } else { cheatStatus->cursorX = -1.0f; if (isKeyJustReleased(input, WAR_KEY_ENTER)) { wcheatp_setCheatsPanelVisible(context, true); } } } void wcheatp_renderCheatsPanel(WarContext* context) { WarScene* scene = context->scene; assert(scene); WarCheatStatus* cheatStatus = &scene->cheatStatus; if (!cheatStatus->enabled) return; // --- Cheat panel background + input line --- if (cheatStatus->visible) { // Gray translucent background bar at the top of the screen. imui_rect(context, "panelCheat", CREATE_UI_RECT_ARGS_INIT( .position = VEC2_ZERO, .size = vec2f((f32)context->originalWindowWidth, 12.0f), .color = WAR_COLOR_RGBA(100, 100, 100, 160), )); // "MSG: " — built into a local buffer to avoid a heap alloc. char inputBuf[8 + CHEAT_TEXT_MAX_LENGTH]; StringView cheatText = wstr_view(&cheatStatus->text); snprintf(inputBuf, sizeof(inputBuf), "MSG: %.*s", (int)cheatText.length, cheatText.data ? cheatText.data : ""); imui_text(context, "txtCheat", CREATE_UI_TEXT_ARGS_INIT( .position = vec2i(2, 4), .fontSize = 6, .text = wsv_fromCString(inputBuf) )); // Blinking cursor rect — position computed in wcheatp_updateCheatsPanel. if (cheatStatus->cursorX >= 0.0f) { imui_rect(context, "cursorCheat", CREATE_UI_RECT_ARGS_INIT( .position = vec2f(cheatStatus->cursorX, 3.0f), .size = vec2i(1, 7), .color = WAR_COLOR_WHITE, )); } } // --- Cheat feedback text (shown for a few seconds after a cheat is applied) --- if (cheatStatus->feedback && cheatStatus->feedbackText.data) { imui_text(context, "txtCheatFeedback", CREATE_UI_TEXT_ARGS_INIT( .position = vec2i(10, 20), .fontIndex = 1, .fontSize = 8, .fontColor = WAR_COLOR_YELLOW, .text = wstr_view(&cheatStatus->feedbackText) )); } } ================================================ FILE: src/war_color.h ================================================ #pragma once #include typedef union { uint32_t packed; uint8_t rgba[4]; struct { uint8_t r, g, b, a; }; } WarColor; #define WAR_COLOR_RGBA_INIT(r_, g_, b_, a_) {.r = r_, .g = g_, .b = b_, .a = a_} #define WAR_COLOR_RGBA(r_, g_, b_, a_) ((WarColor)WAR_COLOR_RGBA_INIT(r_, g_, b_, a_)) #define WAR_COLOR_RGB_INIT(r_, g_, b_) WAR_COLOR_RGBA_INIT(r_, g_, b_, 255) #define WAR_COLOR_RGB(r_, g_, b_) WAR_COLOR_RGBA(r_, g_, b_, 255) #define WAR_COLOR_PACKED_INIT(value) { .packed = (uint32_t)(value) } #define WAR_COLOR_PACKED(value) ((WarColor)WAR_COLOR_PACKED_INIT(value)) #define WAR_COLOR_TRANSPARENT WAR_COLOR_PACKED(0x00000000) #define WAR_COLOR_WHITE WAR_COLOR_PACKED(0xFFFFFFFF) #define WAR_COLOR_BLACK WAR_COLOR_PACKED(0xFF000000) #define WAR_COLOR_RED WAR_COLOR_PACKED(0xFF0000C7) #define WAR_COLOR_GREEN WAR_COLOR_PACKED(0xFF00C700) #define WAR_COLOR_BLUE WAR_COLOR_PACKED(0xFFC70000) #define WAR_COLOR_YELLOW WAR_COLOR_PACKED(0xFFC7C700) #define WAR_COLOR_GRAY_TRANSPARENT WAR_COLOR_PACKED(0x80808080) #define WAR_COLOR_RED_TRANSPARENT WAR_COLOR_PACKED(0x80000080) #define WAR_COLOR_GREEN_SELECTION WAR_COLOR_PACKED(0xFF00C700) #define WAR_COLOR_RED_SELECTION WAR_COLOR_PACKED(0xFF0000C7) #define WAR_COLOR_WHITE_SELECTION WAR_COLOR_PACKED(0xFFC7C7C7) #define WAR_COLOR_BLUE_INVULNERABLE WAR_COLOR_PACKED(0xFFC70000) #define WAR_COLOR_FOG WAR_COLOR_PACKED(0x80000000) ================================================ FILE: src/war_commands.c ================================================ #include "war_commands.h" #include #include #include "war_audio.h" #include "war_entities.h" #include "war_projectiles.h" #include "war_state_machine.h" #include "war_ui.h" #include "war_units.h" void wcmd_executeMoveCommand(WarContext* context, vec2 targetPoint) { WarMap* map = context->map; WarInput* input = &context->input; WarPlayerInfo* player = &map->players[0]; bool goingToMove = false; s32 selEntitiesCount = map->selectedEntities.count; // move the selected units to the target point, // but keeping the bounding box that the // selected units make, this is an intent to keep the // formation of the selected units // rect* rs = (rect*)wm_allocFrame(selEntitiesCount * sizeof(rect)); for(s32 i = 0; i < selEntitiesCount; i++) { WarEntityId entityId = map->selectedEntities.items[i]; WarEntity* entity = we_findEntity(context, entityId); assert(entity); rs[i] = wu_getUnitRect(context, entity); } rect bbox = rs[0]; for(s32 i = 1; i < selEntitiesCount; i++) { if (rs[i].x < bbox.x) bbox.x = rs[i].x; if (rs[i].y < bbox.y) bbox.y = rs[i].y; if (rs[i].x + rs[i].width > bbox.x + bbox.width) bbox.width = (rs[i].x + rs[i].width) - bbox.x; if (rs[i].y + rs[i].height > bbox.y + bbox.height) bbox.height = (rs[i].y + rs[i].height) - bbox.y; } rect targetbbox = rectf( targetPoint.x - 0.5f * bbox.width, targetPoint.y - 0.5f * bbox.height, bbox.width, bbox.height); for(s32 i = 0; i < selEntitiesCount; i++) { WarEntityId entityId = map->selectedEntities.items[i]; WarEntity* entity = we_findEntity(context, entityId); assert(entity); vec2 position = vec2f( rs[i].x + 0.5f * rs[i].width, rs[i].y + 0.5f * rs[i].height); position = wmap_mapToTileCoordinatesV(position); rect targetRect = rectf( targetbbox.x + (rs[i].x - bbox.x), targetbbox.y + (rs[i].y - bbox.y), rs[i].width, rs[i].height); vec2 target = vec2f( targetRect.x + 0.5f * targetRect.width, targetRect.y + 0.5f * targetRect.height); target = wmap_mapToTileCoordinatesV(target); if (wu_isDudeUnit(context, entity) && wu_isFriendlyUnit(context, entity)) { if (isKeyHeld(input, WAR_KEY_SHIFT)) { if (wst_isPatrolling(context, entity)) { if(wst_isMoving(context, entity)) { WarState* moveState = wst_getMoveState(context, entity); vec2ListAdd(&moveState->move.positions, target); } WarState* patrolState = wst_getPatrolState(context, entity); vec2ListAdd(&patrolState->patrol.positions, target); } else if(wst_isMoving(context, entity) && !wst_isAttacking(context, entity)) { WarState* moveState = wst_getMoveState(context, entity); vec2ListAdd(&moveState->move.positions, target); } else { WarState* moveState = wst_createMoveState(context, entity, 2, arrayArg(vec2, position, target)); wst_changeNextState(context, entity, moveState, true, true); } } else { WarState* moveState = wst_createMoveState(context, entity, 2, arrayArg(vec2, position, target)); wst_changeNextState(context, entity, moveState, true, true); // WarState* patrolState = wst_createPatrolState(context, entity, 2, arrayArg(vec2, position, target)); // wst_changeNextState(context, entity, patrolState, true, true); } goingToMove = true; } } if (goingToMove) { wa_playAcknowledgementSound(context, player); } } void wcmd_executeFollowCommand(WarContext* context, WarEntity* targetEntity) { WarMap* map = context->map; WarPlayerInfo* player = &map->players[0]; bool goingToFollow = false; s32 selEntitiesCount = map->selectedEntities.count; for (s32 i = 0; i < selEntitiesCount; i++) { WarEntityId entityId = map->selectedEntities.items[i]; WarEntity* entity = we_findEntity(context, entityId); assert(entity); if (wu_isFriendlyUnit(context, entity)) { WarState* followState = wst_createFollowState(context, entity, targetEntity->id, VEC2_ZERO, 1); wst_changeNextState(context, entity, followState, true, true); goingToFollow = true; } } if (goingToFollow) { wa_playAcknowledgementSound(context, player); } } void wcmd_executeStopCommand(WarContext* context) { WarMap* map = context->map; s32 selEntitiesCount = map->selectedEntities.count; for (s32 i = 0; i < selEntitiesCount; i++) { WarEntityId entityId = map->selectedEntities.items[i]; WarEntity* entity = we_findEntity(context, entityId); assert(entity); if (wu_isFriendlyUnit(context, entity)) { WarState* idleState = wst_createIdleState(context, entity, true); wst_changeNextState(context, entity, idleState, true, true); } } } void wcmd_executeHarvestCommand(WarContext* context, WarEntity* targetEntity, vec2 targetTile) { WarMap* map = context->map; WarPlayerInfo* player = &map->players[0]; assert(wu_isUnitOfType(context, targetEntity, WAR_UNIT_GOLDMINE) || isEntityOfType(targetEntity, WAR_ENTITY_TYPE_FOREST)); bool goingToHarvest = false; s32 selEntitiesCount = map->selectedEntities.count; for(s32 i = 0; i < selEntitiesCount; i++) { WarEntityId entityId = map->selectedEntities.items[i]; WarEntity* entity = we_findEntity(context, entityId); assert(entity); if (wu_isFriendlyUnit(context, entity)) { if (wu_isWorkerUnit(context, entity)) { if (wu_isCarryingResources(context, entity)) { // find the closest town hall to deliver the gold WarRace race = wu_getUnitRace(context, entity); WarUnitType townHallType = wu_getTownHallOfRace(race); WarEntity* townHall = we_findClosestUnitOfType(context, entity, townHallType); if (townHall) { WarState* deliverState = wst_createDeliverState(context, entity, townHall->id); deliverState->nextState = isEntityOfType(targetEntity, WAR_ENTITY_TYPE_FOREST) ? wst_createGatherWoodState(context, entity, targetEntity->id, targetTile) : wst_createGatherGoldState(context, entity, targetEntity->id); wst_changeNextState(context, entity, deliverState, true, true); } } else { WarState* gatherGoldOrWoodState = isEntityOfType(targetEntity, WAR_ENTITY_TYPE_FOREST) ? wst_createGatherWoodState(context, entity, targetEntity->id, targetTile) : wst_createGatherGoldState(context, entity, targetEntity->id); wst_changeNextState(context, entity, gatherGoldOrWoodState, true, true); } goingToHarvest = true; } else if (wu_isDudeUnit(context, entity)) { vec2 position = wu_getUnitCenterPosition(context, entity, true); WarState* moveState = wst_createMoveState(context, entity, 2, arrayArg(vec2, position, targetTile)); wst_changeNextState(context, entity, moveState, true, true); goingToHarvest = true; } } } if (goingToHarvest) { wa_playAcknowledgementSound(context, player); } } void wcmd_executeDeliverCommand(WarContext* context, WarEntity* targetEntity) { WarMap* map = context->map; WarPlayerInfo* player = &map->players[0]; bool goingToDeliver = false; s32 selEntitiesCount = map->selectedEntities.count; for(s32 i = 0; i < selEntitiesCount; i++) { WarEntityId entityId = map->selectedEntities.items[i]; WarEntity* entity = we_findEntity(context, entityId); assert(entity); if (wu_isFriendlyUnit(context, entity)) { WarEntity* townHall = targetEntity; if (!townHall) { WarRace race = wu_getUnitRace(context, entity); WarUnitType townHallType = wu_getTownHallOfRace(race); townHall = we_findClosestUnitOfType(context, entity, townHallType); assert(townHall); } if (wu_isWorkerUnit(context, entity) && wu_isCarryingResources(context, entity)) { WarState* deliverState = wst_createDeliverState(context, entity, townHall->id); wst_changeNextState(context, entity, deliverState, true, true); goingToDeliver = true; } else if (wu_isDudeUnit(context, entity)) { WarState* followState = wst_createFollowState(context, entity, townHall->id, VEC2_ZERO, 1); wst_changeNextState(context, entity, followState, true, true); goingToDeliver = true; } } } if (goingToDeliver) { wa_playAcknowledgementSound(context, player); } } void wcmd_executeRepairCommand(WarContext* context, WarEntity* targetEntity) { WarMap* map = context->map; WarPlayerInfo* player = &map->players[0]; bool goingToRepair = false; s32 selEntitiesCount = map->selectedEntities.count; for(s32 i = 0; i < selEntitiesCount; i++) { WarEntityId entityId = map->selectedEntities.items[i]; WarEntity* entity = we_findEntity(context, entityId); assert(entity); if (wu_isFriendlyUnit(context, entity)) { // the unit can't repair itself if (entity->id == targetEntity->id) { continue; } if (wu_isWorkerUnit(context, entity)) { WarState* repairState = wst_createRepairState(context, entity, targetEntity->id); wst_changeNextState(context, entity, repairState, true, true); goingToRepair = true; } } } if (goingToRepair) { wa_playAcknowledgementSound(context, player); } } void wcmd_executeSummonCommand(WarContext* context, WarUnitCommandType summonType) { WarMap* map = context->map; bool casted = false; s32 selEntitiesCount = map->selectedEntities.count; for(s32 i = 0; i < selEntitiesCount; i++) { WarEntityId entityId = map->selectedEntities.items[i]; WarEntity* entity = we_findEntity(context, entityId); assert(entity); if (wu_isConjurerOrWarlockUnit(context, entity)) { WarUnitComponent* unit = we_getUnitComponent(context, entity); // when the unit summon another unit, it is not invisible anymore unit->invisible = false; unit->invisibilityTime = 0; const WarUnitCommandMapping* commandMapping = wu_getCommandMapping(summonType); const WarSpellMapping* spellMapping = wu_getSpellMapping(commandMapping->mappedType); const WarSpellStats* stats = wu_getSpellStats(commandMapping->mappedType); while (we_decreaseUnitMana(context, entity, stats->manaCost)) { vec2 position = wu_getUnitCenterPosition(context, entity, true); vec2 spawnPosition = wpath_findEmptyPosition(map->finder, position); WarEntity* summonedUnit = we_createUnit(context, CREATE_UNIT_ARGS_INIT( .type = spellMapping->mappedType, .x = (s32)spawnPosition.x, .y = (s32)spawnPosition.y, .player = unit->player, .resourceKind = WAR_RESOURCE_NONE, .amount = 0, .addToMap = true )); vec2 unitSize = wu_getUnitSize(context, summonedUnit); setStaticEntity(map->finder, (s32)spawnPosition.x, (s32)spawnPosition.y, (s32)unitSize.x, (s32)unitSize.y, summonedUnit->id); WarEntity* animEntity = we_createEntity(context, WAR_ENTITY_TYPE_ANIMATION, true); wanim_createSpellAnimation(context, animEntity, wmap_tileToMapCoordinatesV(spawnPosition, true)); casted = true; } } } if (casted) { wa_createAudio(context, CREATE_AUDIO_ARGS_INIT(.audioId=WAR_NORMAL_SPELL, .loop=false)); } } void wcmd_executeRainOfFireCommand(WarContext* context, vec2 targetTile) { WarMap* map = context->map; s32 selEntitiesCount = map->selectedEntities.count; for(s32 i = 0; i < selEntitiesCount; i++) { WarEntityId entityId = map->selectedEntities.items[i]; WarEntity* entity = we_findEntity(context, entityId); assert(entity); if (wu_isConjurerOrWarlockUnit(context, entity)) { WarState* castState = wst_createCastState(context, entity, WAR_SPELL_RAIN_OF_FIRE, 0, targetTile); wst_changeNextState(context, entity, castState, true, true); } } } void wcmd_executePoisonCloudCommand(WarContext* context, vec2 targetTile) { WarMap* map = context->map; s32 selEntitiesCount = map->selectedEntities.count; for(s32 i = 0; i < selEntitiesCount; i++) { WarEntityId entityId = map->selectedEntities.items[i]; WarEntity* entity = we_findEntity(context, entityId); assert(entity); if (wu_isConjurerOrWarlockUnit(context, entity)) { WarState* castState = wst_createCastState(context, entity, WAR_SPELL_POISON_CLOUD, 0, targetTile); wst_changeNextState(context, entity, castState, true, true); } } } void wcmd_executeHealingCommand(WarContext* context, WarEntity* targetEntity, vec2 targetTile) { WarMap* map = context->map; if (targetEntity && wu_isDudeUnit(context, targetEntity)) { s32 selEntitiesCount = map->selectedEntities.count; for(s32 i = 0; i < selEntitiesCount; i++) { WarEntityId entityId = map->selectedEntities.items[i]; WarEntity* entity = we_findEntity(context, entityId); assert(entity); if (wu_isClericOrNecrolyteUnit(context, entity)) { // the unit can't heal itself if (entity->id != targetEntity->id) { WarState* castState = wst_createCastState(context, entity, WAR_SPELL_HEALING, targetEntity->id, targetTile); wst_changeNextState(context, entity, castState, true, true); } } } } } void wcmd_executeInvisiblityCommand(WarContext* context, WarEntity* targetEntity, vec2 targetTile) { WarMap* map = context->map; if (targetEntity && wu_isDudeUnit(context, targetEntity)) { s32 selEntitiesCount = map->selectedEntities.count; for(s32 i = 0; i < selEntitiesCount; i++) { WarEntityId entityId = map->selectedEntities.items[i]; WarEntity* entity = we_findEntity(context, entityId); assert(entity); if (wu_isClericOrNecrolyteUnit(context, entity)) { WarState* castState = wst_createCastState(context, entity, WAR_SPELL_INVISIBILITY, targetEntity->id, targetTile); wst_changeNextState(context, entity, castState, true, true); } } } } void wcmd_executeUnholyArmorCommand(WarContext* context, WarEntity* targetEntity, vec2 targetTile) { WarMap* map = context->map; if (targetEntity && wu_isDudeUnit(context, targetEntity)) { s32 selEntitiesCount = map->selectedEntities.count; for(s32 i = 0; i < selEntitiesCount; i++) { WarEntityId entityId = map->selectedEntities.items[i]; WarEntity* entity = we_findEntity(context, entityId); assert(entity); if (wu_isClericOrNecrolyteUnit(context, entity)) { WarState* castState = wst_createCastState(context, entity, WAR_SPELL_UNHOLY_ARMOR, targetEntity->id, targetTile); wst_changeNextState(context, entity, castState, true, true); } } } } void wcmd_executeRaiseDeadCommand(WarContext* context, vec2 targetTile) { WarMap* map = context->map; s32 selEntitiesCount = map->selectedEntities.count; for(s32 i = 0; i < selEntitiesCount; i++) { WarEntityId entityId = map->selectedEntities.items[i]; WarEntity* entity = we_findEntity(context, entityId); assert(entity); if (wu_isClericOrNecrolyteUnit(context, entity)) { WarState* castState = wst_createCastState(context, entity, WAR_SPELL_RAISE_DEAD, 0, targetTile); wst_changeNextState(context, entity, castState, true, true); } } } void wcmd_executeSightCommand(WarContext* context, vec2 targetTile) { WarMap* map = context->map; s32 selEntitiesCount = map->selectedEntities.count; for(s32 i = 0; i < selEntitiesCount; i++) { WarEntityId entityId = map->selectedEntities.items[i]; WarEntity* entity = we_findEntity(context, entityId); assert(entity); if (wu_isClericOrNecrolyteUnit(context, entity)) { WarSpellType spellType = wu_isHumanUnit(context, entity) ? WAR_SPELL_FAR_SIGHT : WAR_SPELL_DARK_VISION; WarState* castState = wst_createCastState(context, entity, spellType, 0, targetTile); wst_changeNextState(context, entity, castState, true, true); } } } void wcmd_executeAttackCommand(WarContext* context, WarEntity* targetEntity, vec2 targetTile) { WarMap* map = context->map; WarPlayerInfo* player = &map->players[0]; bool playSound = false; s32 selEntitiesCount = map->selectedEntities.count; for(s32 i = 0; i < selEntitiesCount; i++) { WarEntityId entityId = map->selectedEntities.items[i]; WarEntity* entity = we_findEntity(context, entityId); assert(entity); if (wu_isFriendlyUnit(context, entity)) { if (targetEntity) { // the unit can't attack itself if (entity->id != targetEntity->id) { if (wu_canAttack(context, entity, targetEntity)) { WarState* attackState = wst_createAttackState(context, entity, targetEntity->id, targetTile); wst_changeNextState(context, entity, attackState, true, true); playSound = true; } else if (wu_isWorkerUnit(context, entity)) { WarState* followState = wst_createFollowState(context, entity, targetEntity->id, VEC2_ZERO, 1); wst_changeNextState(context, entity, followState, true, true); } } } else { WarState* attackState = wst_createAttackState(context, entity, 0, targetTile); wst_changeNextState(context, entity, attackState, true, true); playSound = true; } } } if (playSound) { wa_playAcknowledgementSound(context, player); } } bool wcmd_executeCommand(WarContext* context) { WarMap* map = context->map; WarInput* input = &context->input; WarPlayerInfo* player = &map->players[0]; WarUnitCommand* command = &map->command; if (command->type == WAR_COMMAND_NONE) { return false; } switch (command->type) { case WAR_COMMAND_MOVE: { if (isButtonJustPressed(input, WAR_MOUSE_LEFT)) { if(rect_containsf(map->mapPanel, input->pos.x, input->pos.y)) { vec2 targetPoint = wmap_screenToMapCoordinatesV(context, input->pos); wcmd_executeMoveCommand(context, targetPoint); command->type = WAR_COMMAND_NONE; return true; } else if (rect_containsf(map->minimapPanel, input->pos.x, input->pos.y)) { vec2 targetTile = wmap_screenToMinimapCoordinatesV(context, input->pos); vec2 targetPoint = wmap_tileToMapCoordinatesV(targetTile, true); wcmd_executeMoveCommand(context, targetPoint); command->type = WAR_COMMAND_NONE; return true; } } return false; } case WAR_COMMAND_STOP: { wcmd_executeStopCommand(context); command->type = WAR_COMMAND_NONE; return true; } case WAR_COMMAND_HARVEST: { if (isButtonJustPressed(input, WAR_MOUSE_LEFT)) { if(rect_containsf(map->mapPanel, input->pos.x, input->pos.y)) { vec2 targetPoint = wmap_screenToMapCoordinatesV(context, input->pos); vec2 targetTile = wmap_mapToTileCoordinatesV(targetPoint); WarEntityId targetEntityId = getTileEntityId(map->finder, (s32)targetTile.x, (s32)targetTile.y); WarEntity* targetEntity = we_findEntity(context, targetEntityId); if (targetEntity) { if (wu_isUnitOfType(context, targetEntity, WAR_UNIT_GOLDMINE)) { if (!wmap_isUnitUnknown(context, map, targetEntity)) wcmd_executeHarvestCommand(context, targetEntity, targetTile); else wcmd_executeMoveCommand(context, targetPoint); } else if (isEntityOfType(targetEntity, WAR_ENTITY_TYPE_FOREST)) { if (!wmap_isTileUnkown(map, (s32)targetTile.x, (s32)targetTile.y)) { wcmd_executeHarvestCommand(context, targetEntity, targetTile); } else { WarTree* tree = we_findAccesibleTree(context, targetEntity, targetTile); if (tree) { targetTile = vec2i(tree->tilex, tree->tiley); wcmd_executeHarvestCommand(context, targetEntity, targetTile); } else { wcmd_executeMoveCommand(context, targetPoint); } } } } command->type = WAR_COMMAND_NONE; return true; } } return false; } case WAR_COMMAND_DELIVER: { wcmd_executeDeliverCommand(context, NULL); command->type = WAR_COMMAND_NONE; return true; } case WAR_COMMAND_REPAIR: { if (isButtonJustPressed(input, WAR_MOUSE_LEFT)) { if(rect_containsf(map->mapPanel, input->pos.x, input->pos.y)) { vec2 targetPoint = wmap_screenToMapCoordinatesV(context, input->pos); vec2 targetTile = wmap_mapToTileCoordinatesV(targetPoint); if (wmap_isTileVisible(map, (s32)targetTile.x, (s32)targetTile.y) || wmap_isTileFog(map, (s32)targetTile.x, (s32)targetTile.y)) { WarEntityId targetEntityId = getTileEntityId(map->finder, (s32)targetTile.x, (s32)targetTile.y); WarEntity* targetEntity = we_findEntity(context, targetEntityId); if (targetEntity && wu_isBuildingUnit(context, targetEntity)) { wcmd_executeRepairCommand(context, targetEntity); } } command->type = WAR_COMMAND_NONE; return true; } } return false; } case WAR_COMMAND_ATTACK: { if (isButtonJustPressed(input, WAR_MOUSE_LEFT)) { if(rect_containsf(map->mapPanel, input->pos.x, input->pos.y)) { vec2 targetPoint = wmap_screenToMapCoordinatesV(context, input->pos); vec2 targetTile = wmap_mapToTileCoordinatesV(targetPoint); WarEntityId targetEntityId = getTileEntityId(map->finder, (s32)targetTile.x, (s32)targetTile.y); WarEntity* targetEntity = we_findEntity(context, targetEntityId); if (targetEntity) { if (wu_isUnit(targetEntity)) { // if the target entity is not visible or partially visible, just attack to the point if (wmap_isUnitUnknown(context, map, targetEntity)) targetEntity = NULL; } else if (wu_isWall(targetEntity)) { // if the target wall piece is not visible, just attack to the point if (!wmap_isTileVisible(map, (s32)targetTile.x, (s32)targetTile.y)) targetEntity = NULL; } } wcmd_executeAttackCommand(context, targetEntity, targetTile); command->type = WAR_COMMAND_NONE; return true; } else if (rect_containsf(map->minimapPanel, input->pos.x, input->pos.y)) { vec2 targetTile = wmap_screenToMinimapCoordinatesV(context, input->pos); wcmd_executeAttackCommand(context, NULL, targetTile); command->type = WAR_COMMAND_NONE; return true; } } return false; } case WAR_COMMAND_TRAIN_FOOTMAN: case WAR_COMMAND_TRAIN_GRUNT: case WAR_COMMAND_TRAIN_PEASANT: case WAR_COMMAND_TRAIN_PEON: case WAR_COMMAND_TRAIN_CATAPULT_HUMANS: case WAR_COMMAND_TRAIN_CATAPULT_ORCS: case WAR_COMMAND_TRAIN_KNIGHT: case WAR_COMMAND_TRAIN_RAIDER: case WAR_COMMAND_TRAIN_ARCHER: case WAR_COMMAND_TRAIN_SPEARMAN: case WAR_COMMAND_TRAIN_CONJURER: case WAR_COMMAND_TRAIN_WARLOCK: case WAR_COMMAND_TRAIN_CLERIC: case WAR_COMMAND_TRAIN_NECROLYTE: { WarUnitType unitToTrain = command->train.unitToTrain; WarUnitType buildingUnit = command->train.buildingUnit; assert(map->selectedEntities.count == 1); WarEntity* selectedEntity = we_findEntity(context, map->selectedEntities.items[0]); assert(selectedEntity && wu_isBuildingUnit(context, selectedEntity)); WarUnitComponent* selectedUnit = we_getUnitComponent(context, selectedEntity); assert(selectedUnit); assert(selectedUnit->type == buildingUnit); NOT_USED(buildingUnit); NOT_USED(selectedUnit); const WarUnitStats* stats = wu_getUnitStats(unitToTrain); if (we_checkFarmFood(context, player) && we_decreasePlayerResources(context, player, stats->goldCost, stats->woodCost)) { WarState* trainState = wst_createTrainState(context, selectedEntity, unitToTrain, (f32)stats->buildTime); wst_changeNextState(context, selectedEntity, trainState, true, true); } command->type = WAR_COMMAND_NONE; return true; } case WAR_COMMAND_UPGRADE_SWORDS: case WAR_COMMAND_UPGRADE_AXES: case WAR_COMMAND_UPGRADE_SHIELD_HUMANS: case WAR_COMMAND_UPGRADE_SHIELD_ORCS: case WAR_COMMAND_UPGRADE_ARROWS: case WAR_COMMAND_UPGRADE_SPEARS: case WAR_COMMAND_UPGRADE_HORSES: case WAR_COMMAND_UPGRADE_WOLVES: case WAR_COMMAND_UPGRADE_SCORPION: case WAR_COMMAND_UPGRADE_SPIDER: case WAR_COMMAND_UPGRADE_RAIN_OF_FIRE: case WAR_COMMAND_UPGRADE_POISON_CLOUD: case WAR_COMMAND_UPGRADE_WATER_ELEMENTAL: case WAR_COMMAND_UPGRADE_DAEMON: case WAR_COMMAND_UPGRADE_HEALING: case WAR_COMMAND_UPGRADE_RAISE_DEAD: case WAR_COMMAND_UPGRADE_FAR_SIGHT: case WAR_COMMAND_UPGRADE_DARK_VISION: case WAR_COMMAND_UPGRADE_INVISIBILITY: case WAR_COMMAND_UPGRADE_UNHOLY_ARMOR: { WarUpgradeType upgradeToBuild = command->upgrade.upgradeToBuild; WarUnitType buildingUnit = command->upgrade.buildingUnit; assert(map->selectedEntities.count == 1); WarEntity* selectedEntity = we_findEntity(context, map->selectedEntities.items[0]); assert(selectedEntity && wu_isBuildingUnit(context, selectedEntity)); WarUnitComponent* selectedUnit = we_getUnitComponent(context, selectedEntity); assert(selectedUnit); assert(selectedUnit->type == buildingUnit); NOT_USED(buildingUnit); NOT_USED(selectedUnit); assert(hasRemainingUpgrade(player, upgradeToBuild)); const WarUpgradeStats* stats = wu_getUpgradeStats(upgradeToBuild); s32 level = getUpgradeLevel(player, upgradeToBuild); if (we_decreasePlayerResources(context, player, stats->goldCost[level], 0)) { WarState* upgradeState = wst_createUpgradeState(context, selectedEntity, upgradeToBuild, (f32)stats->buildTime); wst_changeNextState(context, selectedEntity, upgradeState, true, true); } command->type = WAR_COMMAND_NONE; return true; } case WAR_COMMAND_BUILD_FARM_HUMANS: case WAR_COMMAND_BUILD_FARM_ORCS: case WAR_COMMAND_BUILD_BARRACKS_HUMANS: case WAR_COMMAND_BUILD_BARRACKS_ORCS: case WAR_COMMAND_BUILD_CHURCH: case WAR_COMMAND_BUILD_TEMPLE: case WAR_COMMAND_BUILD_TOWER_HUMANS: case WAR_COMMAND_BUILD_TOWER_ORCS: case WAR_COMMAND_BUILD_TOWNHALL_HUMANS: case WAR_COMMAND_BUILD_TOWNHALL_ORCS: case WAR_COMMAND_BUILD_LUMBERMILL_HUMANS: case WAR_COMMAND_BUILD_LUMBERMILL_ORCS: case WAR_COMMAND_BUILD_STABLE: case WAR_COMMAND_BUILD_KENNEL: case WAR_COMMAND_BUILD_BLACKSMITH_HUMANS: case WAR_COMMAND_BUILD_BLACKSMITH_ORCS: { if (isButtonJustPressed(input, WAR_MOUSE_LEFT)) { if(rect_containsf(map->mapPanel, input->pos.x, input->pos.y)) { assert(map->selectedEntities.count > 0); WarEntityId workerId = map->selectedEntities.items[0]; WarEntity* worker = we_findEntity(context, workerId); assert(worker); vec2 targetPoint = wmap_screenToMapCoordinatesV(context, input->pos); vec2 targetTile = wmap_mapToTileCoordinatesV(targetPoint); WarUnitType buildingToBuild = command->build.buildingToBuild; const WarBuildingStats* stats = wu_getBuildingStats(buildingToBuild); if (we_checkTileToBuild(context, buildingToBuild, (s32)targetTile.x, (s32)targetTile.y)) { if (we_decreasePlayerResources(context, player, stats->goldCost, stats->woodCost)) { WarEntity* building = we_createBuilding(context, CREATE_UNIT_ARGS_INIT( .type=buildingToBuild, .x=(s32)targetTile.x, .y=(s32)targetTile.y, .player=0, .isGoingToBuild=true )); WarState* repairState = wst_createRepairState(context, worker, building->id); wst_changeNextState(context, worker, repairState, true, true); command->type = WAR_COMMAND_NONE; } } else { wa_createAudio(context, CREATE_AUDIO_ARGS_INIT(.audioId=WAR_UI_CANCEL, .loop=false)); } return true; } } return false; } case WAR_COMMAND_BUILD_WALL: { if (isButtonJustPressed(input, WAR_MOUSE_LEFT)) { if (rect_containsf(map->mapPanel, input->pos.x, input->pos.y)) { assert(map->selectedEntities.count > 0); WarEntityId townHallId = map->selectedEntities.items[0]; WarEntity* townHall = we_findEntity(context, townHallId); assert(townHall); WarUnitType townHallType = wu_getTownHallOfRace(player->race); assert(wu_isUnitOfType(context, townHall, townHallType)); NOT_USED(townHall); NOT_USED(townHallType); vec2 targetPoint = wmap_screenToMapCoordinatesV(context, input->pos); vec2 targetTile = wmap_mapToTileCoordinatesV(targetPoint); if (we_checkTileToBuildRoadOrWall(context, (s32)targetTile.x, (s32)targetTile.y)) { if (we_decreasePlayerResources(context, player, WAR_WALL_GOLD_COST, WAR_WALL_WOOD_COST)) { WarEntity* wall = map->wall; WarWallPiece* piece = we_addWallPiece(context, wall, (s32)targetTile.x, (s32)targetTile.y, 0); piece->hp = WAR_WALL_MAX_HP; piece->maxhp = WAR_WALL_MAX_HP; we_determineWallTypes(context, wall); // don't reset the current command if the player is building // roads or walls, to allow rapid construction of those structures // // command->type = WAR_COMMAND_NONE; wa_createAudio(context, CREATE_AUDIO_ARGS_INIT(.audioId=WAR_BUILD_ROAD, .loop=false)); } } else { wa_createAudio(context, CREATE_AUDIO_ARGS_INIT(.audioId=WAR_UI_CANCEL, .loop=false)); } return true; } } return false; } case WAR_COMMAND_BUILD_ROAD: { if (isButtonJustPressed(input, WAR_MOUSE_LEFT)) { if (rect_containsf(map->mapPanel, input->pos.x, input->pos.y)) { assert(map->selectedEntities.count > 0); WarEntityId townHallId = map->selectedEntities.items[0]; WarEntity* townHall = we_findEntity(context, townHallId); assert(townHall); WarUnitType townHallType = wu_getTownHallOfRace(player->race); assert(wu_isUnitOfType(context, townHall, townHallType)); NOT_USED(townHall); NOT_USED(townHallType); vec2 targetPoint = wmap_screenToMapCoordinatesV(context, input->pos); vec2 targetTile = wmap_mapToTileCoordinatesV(targetPoint); if (we_checkTileToBuildRoadOrWall(context, (s32)targetTile.x, (s32)targetTile.y)) { if (we_decreasePlayerResources(context, player, WAR_ROAD_GOLD_COST, WAR_ROAD_WOOD_COST)) { WarEntity* road = map->road; we_addRoadPiece(context, road, (s32)targetTile.x, (s32)targetTile.y, 0); we_determineRoadTypes(context, road); // don't reset the current command if the player is building // roads or walls, to allow rapid construction of those structures // // command->type = WAR_COMMAND_NONE; wa_createAudio(context, CREATE_AUDIO_ARGS_INIT(.audioId=WAR_BUILD_ROAD, .loop=false)); } } else { wa_createAudio(context, CREATE_AUDIO_ARGS_INIT(.audioId=WAR_UI_CANCEL, .loop=false)); } return true; } } return false; } case WAR_COMMAND_SUMMON_SPIDER: case WAR_COMMAND_SUMMON_SCORPION: case WAR_COMMAND_SUMMON_DAEMON: case WAR_COMMAND_SUMMON_WATER_ELEMENTAL: { wcmd_executeSummonCommand(context, command->type); command->type = WAR_COMMAND_NONE; return true; } case WAR_COMMAND_SPELL_RAIN_OF_FIRE: { if (isButtonJustPressed(input, WAR_MOUSE_LEFT)) { if(rect_containsf(map->mapPanel, input->pos.x, input->pos.y)) { vec2 targetPoint = wmap_screenToMapCoordinatesV(context, input->pos); vec2 targetTile = wmap_mapToTileCoordinatesV(targetPoint); wcmd_executeRainOfFireCommand(context, targetTile); command->type = WAR_COMMAND_NONE; return true; } else if (rect_containsf(map->minimapPanel, input->pos.x, input->pos.y)) { vec2 targetTile = wmap_screenToMinimapCoordinatesV(context, input->pos); wcmd_executeRainOfFireCommand(context, targetTile); command->type = WAR_COMMAND_NONE; return true; } } return false; } case WAR_COMMAND_SPELL_POISON_CLOUD: { if (isButtonJustPressed(input, WAR_MOUSE_LEFT)) { if(rect_containsf(map->mapPanel, input->pos.x, input->pos.y)) { vec2 targetPoint = wmap_screenToMapCoordinatesV(context, input->pos); vec2 targetTile = wmap_mapToTileCoordinatesV(targetPoint); wcmd_executePoisonCloudCommand(context, targetTile); command->type = WAR_COMMAND_NONE; return true; } else if (rect_containsf(map->minimapPanel, input->pos.x, input->pos.y)) { vec2 targetTile = wmap_screenToMinimapCoordinatesV(context, input->pos); wcmd_executePoisonCloudCommand(context, targetTile); command->type = WAR_COMMAND_NONE; return true; } } return false; } case WAR_COMMAND_SPELL_HEALING: { if (isButtonJustPressed(input, WAR_MOUSE_LEFT)) { if(rect_containsf(map->mapPanel, input->pos.x, input->pos.y)) { vec2 targetPoint = wmap_screenToMapCoordinatesV(context, input->pos); vec2 targetTile = wmap_mapToTileCoordinatesV(targetPoint); WarEntityId targetEntityId = getTileEntityId(map->finder, (s32)targetTile.x, (s32)targetTile.y); WarEntity* targetEntity = we_findEntity(context, targetEntityId); wcmd_executeHealingCommand(context, targetEntity, targetTile); command->type = WAR_COMMAND_NONE; return true; } } return false; } case WAR_COMMAND_SPELL_INVISIBILITY: { if (isButtonJustPressed(input, WAR_MOUSE_LEFT)) { if(rect_containsf(map->mapPanel, input->pos.x, input->pos.y)) { vec2 targetPoint = wmap_screenToMapCoordinatesV(context, input->pos); vec2 targetTile = wmap_mapToTileCoordinatesV(targetPoint); WarEntityId targetEntityId = getTileEntityId(map->finder, (s32)targetTile.x, (s32)targetTile.y); WarEntity* targetEntity = we_findEntity(context, targetEntityId); wcmd_executeInvisiblityCommand(context, targetEntity, targetTile); command->type = WAR_COMMAND_NONE; return true; } } return false; } case WAR_COMMAND_SPELL_UNHOLY_ARMOR: { if (isButtonJustPressed(input, WAR_MOUSE_LEFT)) { if(rect_containsf(map->mapPanel, input->pos.x, input->pos.y)) { vec2 targetPoint = wmap_screenToMapCoordinatesV(context, input->pos); vec2 targetTile = wmap_mapToTileCoordinatesV(targetPoint); WarEntityId targetEntityId = getTileEntityId(map->finder, (s32)targetTile.x, (s32)targetTile.y); WarEntity* targetEntity = we_findEntity(context, targetEntityId); wcmd_executeUnholyArmorCommand(context, targetEntity, targetTile); command->type = WAR_COMMAND_NONE; return true; } } return false; } case WAR_COMMAND_SPELL_RAISE_DEAD: { if (isButtonJustPressed(input, WAR_MOUSE_LEFT)) { if(rect_containsf(map->mapPanel, input->pos.x, input->pos.y)) { vec2 targetPoint = wmap_screenToMapCoordinatesV(context, input->pos); vec2 targetTile = wmap_mapToTileCoordinatesV(targetPoint); wcmd_executeRaiseDeadCommand(context, targetTile); command->type = WAR_COMMAND_NONE; return true; } } return false; } case WAR_COMMAND_SPELL_FAR_SIGHT: case WAR_COMMAND_SPELL_DARK_VISION: { if (isButtonJustPressed(input, WAR_MOUSE_LEFT)) { if(rect_containsf(map->mapPanel, input->pos.x, input->pos.y)) { vec2 targetPoint = wmap_screenToMapCoordinatesV(context, input->pos); vec2 targetTile = wmap_mapToTileCoordinatesV(targetPoint); wcmd_executeSightCommand(context, targetTile); command->type = WAR_COMMAND_NONE; return true; } else if (rect_containsf(map->minimapPanel, input->pos.x, input->pos.y)) { vec2 targetTile = wmap_screenToMinimapCoordinatesV(context, input->pos); wcmd_executeSightCommand(context, targetTile); command->type = WAR_COMMAND_NONE; return true; } } return false; } case WAR_COMMAND_BUILD_BASIC: case WAR_COMMAND_BUILD_ADVANCED: { // do nothing here break; } default: { logError("Not implemented command: %d", command->type); return false; } } return false; } // train units void wcmd_trainUnit(WarContext* context, WarUnitCommandType commandType, WarUnitType unitToTrain, WarUnitType buildingUnit) { WarMap* map = context->map; map->command.type = commandType; map->command.train.unitToTrain = unitToTrain; map->command.train.buildingUnit = buildingUnit; } void wcmd_trainFootman(WarContext* context, WarEntity* entity) { NOT_USED(entity); wcmd_trainUnit(context, WAR_COMMAND_TRAIN_FOOTMAN, WAR_UNIT_FOOTMAN, WAR_UNIT_BARRACKS_HUMANS); } void wcmd_trainGrunt(WarContext* context, WarEntity* entity) { NOT_USED(entity); wcmd_trainUnit(context, WAR_COMMAND_TRAIN_GRUNT, WAR_UNIT_GRUNT, WAR_UNIT_BARRACKS_ORCS); } void wcmd_trainPeasant(WarContext* context, WarEntity* entity) { NOT_USED(entity); wcmd_trainUnit(context, WAR_COMMAND_TRAIN_PEASANT, WAR_UNIT_PEASANT, WAR_UNIT_TOWNHALL_HUMANS); } void wcmd_trainPeon(WarContext* context, WarEntity* entity) { NOT_USED(entity); wcmd_trainUnit(context, WAR_COMMAND_TRAIN_PEON, WAR_UNIT_PEON, WAR_UNIT_TOWNHALL_ORCS); } void wcmd_trainHumanCatapult(WarContext* context, WarEntity* entity) { NOT_USED(entity); wcmd_trainUnit(context, WAR_COMMAND_TRAIN_CATAPULT_HUMANS, WAR_UNIT_CATAPULT_HUMANS, WAR_UNIT_BARRACKS_HUMANS); } void wcmd_trainOrcCatapult(WarContext* context, WarEntity* entity) { NOT_USED(entity); wcmd_trainUnit(context, WAR_COMMAND_TRAIN_CATAPULT_ORCS, WAR_UNIT_CATAPULT_ORCS, WAR_UNIT_BARRACKS_ORCS); } void wcmd_trainKnight(WarContext* context, WarEntity* entity) { NOT_USED(entity); wcmd_trainUnit(context, WAR_COMMAND_TRAIN_KNIGHT, WAR_UNIT_KNIGHT, WAR_UNIT_BARRACKS_HUMANS); } void wcmd_trainRaider(WarContext* context, WarEntity* entity) { NOT_USED(entity); wcmd_trainUnit(context, WAR_COMMAND_TRAIN_RAIDER, WAR_UNIT_RAIDER, WAR_UNIT_BARRACKS_ORCS); } void wcmd_trainArcher(WarContext* context, WarEntity* entity) { NOT_USED(entity); wcmd_trainUnit(context, WAR_COMMAND_TRAIN_ARCHER, WAR_UNIT_ARCHER, WAR_UNIT_BARRACKS_HUMANS); } void wcmd_trainSpearman(WarContext* context, WarEntity* entity) { NOT_USED(entity); wcmd_trainUnit(context, WAR_COMMAND_TRAIN_SPEARMAN, WAR_UNIT_SPEARMAN, WAR_UNIT_BARRACKS_ORCS); } void wcmd_trainConjurer(WarContext* context, WarEntity* entity) { NOT_USED(entity); wcmd_trainUnit(context, WAR_COMMAND_TRAIN_CONJURER, WAR_UNIT_CONJURER, WAR_UNIT_TOWER_HUMANS); } void wcmd_trainWarlock(WarContext* context, WarEntity* entity) { NOT_USED(entity); wcmd_trainUnit(context, WAR_COMMAND_TRAIN_WARLOCK, WAR_UNIT_WARLOCK, WAR_UNIT_TOWER_ORCS); } void wcmd_trainCleric(WarContext* context, WarEntity* entity) { NOT_USED(entity); wcmd_trainUnit(context, WAR_COMMAND_TRAIN_CLERIC, WAR_UNIT_CLERIC, WAR_UNIT_CHURCH); } void wcmd_trainNecrolyte(WarContext* context, WarEntity* entity) { NOT_USED(entity); wcmd_trainUnit(context, WAR_COMMAND_TRAIN_NECROLYTE, WAR_UNIT_NECROLYTE, WAR_UNIT_TEMPLE); } // upgrades void wcmd_upgradeUpgrade(WarContext* context, WarUnitCommandType commandType, WarUpgradeType upgradeToBuild, WarUnitType buildingUnit) { WarMap* map = context->map; map->command.type = commandType; map->command.upgrade.upgradeToBuild = upgradeToBuild; map->command.upgrade.buildingUnit = buildingUnit; } void wcmd_upgradeSwords(WarContext* context, WarEntity* entity) { NOT_USED(entity); wcmd_upgradeUpgrade(context, WAR_COMMAND_UPGRADE_SWORDS, WAR_UPGRADE_SWORDS, WAR_UNIT_BLACKSMITH_HUMANS); } void wcmd_upgradeAxes(WarContext* context, WarEntity* entity) { NOT_USED(entity); wcmd_upgradeUpgrade(context, WAR_COMMAND_UPGRADE_AXES, WAR_UPGRADE_AXES, WAR_UNIT_BLACKSMITH_ORCS); } void wcmd_upgradeHumanShields(WarContext* context, WarEntity* entity) { NOT_USED(entity); wcmd_upgradeUpgrade(context, WAR_COMMAND_UPGRADE_SHIELD_HUMANS, WAR_UPGRADE_SHIELD, WAR_UNIT_BLACKSMITH_HUMANS); } void wcmd_upgradeOrcsShields(WarContext* context, WarEntity* entity) { NOT_USED(entity); wcmd_upgradeUpgrade(context, WAR_COMMAND_UPGRADE_SHIELD_ORCS, WAR_UPGRADE_SHIELD, WAR_UNIT_BLACKSMITH_ORCS); } void wcmd_upgradeArrows(WarContext* context, WarEntity* entity) { NOT_USED(entity); wcmd_upgradeUpgrade(context, WAR_COMMAND_UPGRADE_ARROWS, WAR_UPGRADE_ARROWS, WAR_UNIT_LUMBERMILL_HUMANS); } void wcmd_upgradeSpears(WarContext* context, WarEntity* entity) { NOT_USED(entity); wcmd_upgradeUpgrade(context, WAR_COMMAND_UPGRADE_SPEARS, WAR_UPGRADE_SPEARS, WAR_UNIT_LUMBERMILL_ORCS); } void wcmd_upgradeHorses(WarContext* context, WarEntity* entity) { NOT_USED(entity); wcmd_upgradeUpgrade(context, WAR_COMMAND_UPGRADE_HORSES, WAR_UPGRADE_HORSES, WAR_UNIT_STABLE); } void wcmd_upgradeWolves(WarContext* context, WarEntity* entity) { NOT_USED(entity); wcmd_upgradeUpgrade(context, WAR_COMMAND_UPGRADE_WOLVES, WAR_UPGRADE_WOLVES, WAR_UNIT_KENNEL); } void wcmd_upgradeScorpions(WarContext* context, WarEntity* entity) { NOT_USED(entity); wcmd_upgradeUpgrade(context, WAR_COMMAND_UPGRADE_SCORPION, WAR_UPGRADE_SCORPIONS, WAR_UNIT_TOWER_HUMANS); } void wcmd_upgradeSpiders(WarContext* context, WarEntity* entity) { NOT_USED(entity); wcmd_upgradeUpgrade(context, WAR_COMMAND_UPGRADE_SPIDER, WAR_UPGRADE_SPIDERS, WAR_UNIT_TOWER_ORCS); } void wcmd_upgradeRainOfFire(WarContext* context, WarEntity* entity) { NOT_USED(entity); wcmd_upgradeUpgrade(context, WAR_COMMAND_UPGRADE_RAIN_OF_FIRE, WAR_UPGRADE_RAIN_OF_FIRE, WAR_UNIT_TOWER_HUMANS); } void wcmd_upgradePoisonCloud(WarContext* context, WarEntity* entity) { NOT_USED(entity); wcmd_upgradeUpgrade(context, WAR_COMMAND_UPGRADE_POISON_CLOUD, WAR_UPGRADE_POISON_CLOUD, WAR_UNIT_TOWER_ORCS); } void wcmd_upgradeWaterElemental(WarContext* context, WarEntity* entity) { NOT_USED(entity); wcmd_upgradeUpgrade(context, WAR_COMMAND_UPGRADE_WATER_ELEMENTAL, WAR_UPGRADE_WATER_ELEMENTAL, WAR_UNIT_TOWER_HUMANS); } void wcmd_upgradeDaemon(WarContext* context, WarEntity* entity) { NOT_USED(entity); wcmd_upgradeUpgrade(context, WAR_COMMAND_UPGRADE_DAEMON, WAR_UPGRADE_DAEMON, WAR_UNIT_TOWER_ORCS); } void wcmd_upgradeHealing(WarContext* context, WarEntity* entity) { NOT_USED(entity); wcmd_upgradeUpgrade(context, WAR_COMMAND_UPGRADE_HEALING, WAR_UPGRADE_HEALING, WAR_UNIT_CHURCH); } void wcmd_upgradeRaiseDead(WarContext* context, WarEntity* entity) { NOT_USED(entity); wcmd_upgradeUpgrade(context, WAR_COMMAND_UPGRADE_RAISE_DEAD, WAR_UPGRADE_RAISE_DEAD, WAR_UNIT_TEMPLE); } void wcmd_upgradeFarSight(WarContext* context, WarEntity* entity) { NOT_USED(entity); wcmd_upgradeUpgrade(context, WAR_COMMAND_UPGRADE_FAR_SIGHT, WAR_UPGRADE_FAR_SIGHT, WAR_UNIT_CHURCH); } void wcmd_upgradeDarkVision(WarContext* context, WarEntity* entity) { NOT_USED(entity); wcmd_upgradeUpgrade(context, WAR_COMMAND_UPGRADE_DARK_VISION, WAR_UPGRADE_DARK_VISION, WAR_UNIT_TEMPLE); } void wcmd_upgradeInvisibility(WarContext* context, WarEntity* entity) { NOT_USED(entity); wcmd_upgradeUpgrade(context, WAR_COMMAND_UPGRADE_INVISIBILITY, WAR_UPGRADE_INVISIBILITY, WAR_UNIT_CHURCH); } void wcmd_upgradeUnholyArmor(WarContext* context, WarEntity* entity) { NOT_USED(entity); wcmd_upgradeUpgrade(context, WAR_COMMAND_UPGRADE_UNHOLY_ARMOR, WAR_UPGRADE_UNHOLY_ARMOR, WAR_UNIT_TEMPLE); } // wcmd_cancel void wcmd_cancel(WarContext* context, WarEntity* entity) { NOT_USED(entity); WarMap* map = context->map; WarPlayerInfo* player = &map->players[0]; map->command.type = WAR_COMMAND_NONE; for (s32 i = 0; i < map->selectedEntities.count; i++) { WarEntityId selectedEntityId = map->selectedEntities.items[i]; WarEntity* selectedEntity = we_findEntity(context, selectedEntityId); assert(selectedEntity); if (wu_isBuildingUnit(context, selectedEntity)) { WarUnitComponent* unit = we_getUnitComponent(context, selectedEntity); assert(unit); if (wst_isBuilding(context, selectedEntity) || wst_isGoingToBuild(context, selectedEntity)) { const WarBuildingStats* stats = wu_getBuildingStats(unit->type); we_increasePlayerResources(context, player, stats->goldCost, stats->woodCost); WarState* collapseState = wst_createCollapseState(context, selectedEntity); wst_changeNextState(context, selectedEntity, collapseState, true, true); wa_createAudioRandom(context, CREATE_AUDIO_ARGS_INIT(.randomFromId=WAR_BUILDING_COLLAPSE_1, .randomToId=WAR_BUILDING_COLLAPSE_3, .loop=false)); } else if (unit->building) { if (wst_isTraining(context, selectedEntity) || wst_isGoingToTrain(context, selectedEntity)) { WarState* trainState = wst_getTrainState(context, selectedEntity); WarUnitType unitToBuild = trainState->train.unitToBuild; const WarUnitStats* stats = wu_getUnitStats(unitToBuild); we_increasePlayerResources(context, player, stats->goldCost, stats->woodCost); } else if (wst_isUpgrading(context, selectedEntity) || wst_isGoingToUpgrade(context, selectedEntity)) { WarState* upgradeState = wst_getUpgradeState(context, selectedEntity); WarUpgradeType upgradeToBuild = upgradeState->upgrade.upgradeToBuild; assert(hasRemainingUpgrade(player, upgradeToBuild)); s32 upgradeLevel = getUpgradeLevel(player, upgradeToBuild); const WarUpgradeStats* stats = wu_getUpgradeStats(upgradeToBuild); we_increasePlayerResources(context, player, stats->goldCost[upgradeLevel], 0); } WarState* idleState = wst_createIdleState(context, selectedEntity, false); wst_changeNextState(context, selectedEntity, idleState, true, true); } } } } // basic void move(WarContext* context, WarEntity* entity) { NOT_USED(entity); WarMap* map = context->map; map->command.type = WAR_COMMAND_MOVE; } void wcmd_stop(WarContext* context, WarEntity* entity) { NOT_USED(entity); WarMap* map = context->map; map->command.type = WAR_COMMAND_STOP; } void wcmd_harvest(WarContext* context, WarEntity* entity) { NOT_USED(entity); WarMap* map = context->map; map->command.type = WAR_COMMAND_HARVEST; } void deliver(WarContext* context, WarEntity* entity) { NOT_USED(entity); WarMap* map = context->map; map->command.type = WAR_COMMAND_DELIVER; } void repair(WarContext* context, WarEntity* entity) { NOT_USED(entity); WarMap* map = context->map; map->command.type = WAR_COMMAND_REPAIR; } void attack(WarContext* context, WarEntity* entity) { NOT_USED(entity); WarMap* map = context->map; map->command.type = WAR_COMMAND_ATTACK; } void wcmd_buildBasic(WarContext* context, WarEntity* entity) { NOT_USED(entity); WarMap* map = context->map; map->command.type = WAR_COMMAND_BUILD_BASIC; } void wcmd_buildAdvanced(WarContext* context, WarEntity* entity) { NOT_USED(entity); WarMap* map = context->map; map->command.type = WAR_COMMAND_BUILD_ADVANCED; } void wcmd_buildBuilding(WarContext* context, WarUnitCommandType commandType, WarUnitType buildingToBuild) { WarMap* map = context->map; map->command.type = commandType; map->command.build.buildingToBuild = buildingToBuild; } void wcmd_buildFarmHumans(WarContext* context, WarEntity* entity) { NOT_USED(entity); wcmd_buildBuilding(context, WAR_COMMAND_BUILD_FARM_HUMANS, WAR_UNIT_FARM_HUMANS); } void wcmd_buildFarmOrcs(WarContext* context, WarEntity* entity) { NOT_USED(entity); wcmd_buildBuilding(context, WAR_COMMAND_BUILD_FARM_ORCS, WAR_UNIT_FARM_ORCS); } void wcmd_buildBarracksHumans(WarContext* context, WarEntity* entity) { NOT_USED(entity); wcmd_buildBuilding(context, WAR_COMMAND_BUILD_BARRACKS_HUMANS, WAR_UNIT_BARRACKS_HUMANS); } void wcmd_buildBarracksOrcs(WarContext* context, WarEntity* entity) { NOT_USED(entity); wcmd_buildBuilding(context, WAR_COMMAND_BUILD_BARRACKS_ORCS, WAR_UNIT_BARRACKS_ORCS); } void wcmd_buildChurch(WarContext* context, WarEntity* entity) { NOT_USED(entity); wcmd_buildBuilding(context, WAR_COMMAND_BUILD_CHURCH, WAR_UNIT_CHURCH); } void wcmd_buildTemple(WarContext* context, WarEntity* entity) { NOT_USED(entity); wcmd_buildBuilding(context, WAR_COMMAND_BUILD_TEMPLE, WAR_UNIT_TEMPLE); } void wcmd_buildTowerHumans(WarContext* context, WarEntity* entity) { NOT_USED(entity); wcmd_buildBuilding(context, WAR_COMMAND_BUILD_TOWER_HUMANS, WAR_UNIT_TOWER_HUMANS); } void wcmd_buildTowerOrcs(WarContext* context, WarEntity* entity) { NOT_USED(entity); wcmd_buildBuilding(context, WAR_COMMAND_BUILD_TOWER_ORCS, WAR_UNIT_TOWER_ORCS); } void wcmd_buildTownHallHumans(WarContext* context, WarEntity* entity) { NOT_USED(entity); wcmd_buildBuilding(context, WAR_COMMAND_BUILD_TOWNHALL_HUMANS, WAR_UNIT_TOWNHALL_HUMANS); } void wcmd_buildTownHallOrcs(WarContext* context, WarEntity* entity) { NOT_USED(entity); wcmd_buildBuilding(context, WAR_COMMAND_BUILD_TOWNHALL_ORCS, WAR_UNIT_TOWNHALL_ORCS); } void wcmd_buildLumbermillHumans(WarContext* context, WarEntity* entity) { NOT_USED(entity); wcmd_buildBuilding(context, WAR_COMMAND_BUILD_LUMBERMILL_HUMANS, WAR_UNIT_LUMBERMILL_HUMANS); } void wcmd_buildLumbermillOrcs(WarContext* context, WarEntity* entity) { NOT_USED(entity); wcmd_buildBuilding(context, WAR_COMMAND_BUILD_LUMBERMILL_ORCS, WAR_UNIT_LUMBERMILL_ORCS); } void wcmd_buildStable(WarContext* context, WarEntity* entity) { NOT_USED(entity); wcmd_buildBuilding(context, WAR_COMMAND_BUILD_STABLE, WAR_UNIT_STABLE); } void wcmd_buildKennel(WarContext* context, WarEntity* entity) { NOT_USED(entity); wcmd_buildBuilding(context, WAR_COMMAND_BUILD_KENNEL, WAR_UNIT_KENNEL); } void wcmd_buildBlacksmithHumans(WarContext* context, WarEntity* entity) { NOT_USED(entity); wcmd_buildBuilding(context, WAR_COMMAND_BUILD_BLACKSMITH_HUMANS, WAR_UNIT_BLACKSMITH_HUMANS); } void wcmd_buildBlacksmithOrcs(WarContext* context, WarEntity* entity) { NOT_USED(entity); wcmd_buildBuilding(context, WAR_COMMAND_BUILD_BLACKSMITH_ORCS, WAR_UNIT_BLACKSMITH_ORCS); } void wcmd_buildWall(WarContext* context, WarEntity* entity) { NOT_USED(entity); WarMap* map = context->map; map->command.type = WAR_COMMAND_BUILD_WALL; } void wcmd_buildRoad(WarContext* context, WarEntity* entity) { NOT_USED(entity); WarMap* map = context->map; map->command.type = WAR_COMMAND_BUILD_ROAD; } // spells void wcmd_castRainOfFire(WarContext* context, WarEntity* entity) { NOT_USED(entity); WarMap* map = context->map; map->command.type = WAR_COMMAND_SPELL_RAIN_OF_FIRE; } void wcmd_castPoisonCloud(WarContext* context, WarEntity* entity) { NOT_USED(entity); WarMap* map = context->map; map->command.type = WAR_COMMAND_SPELL_POISON_CLOUD; } void wcmd_castHeal(WarContext* context, WarEntity* entity) { NOT_USED(entity); WarMap* map = context->map; map->command.type = WAR_COMMAND_SPELL_HEALING; } void wcmd_castFarSight(WarContext* context, WarEntity* entity) { NOT_USED(entity); WarMap* map = context->map; map->command.type = WAR_COMMAND_SPELL_FAR_SIGHT; } void wcmd_castDarkVision(WarContext* context, WarEntity* entity) { NOT_USED(entity); WarMap* map = context->map; map->command.type = WAR_COMMAND_SPELL_DARK_VISION; } void wcmd_castInvisibility(WarContext* context, WarEntity* entity) { NOT_USED(entity); WarMap* map = context->map; map->command.type = WAR_COMMAND_SPELL_INVISIBILITY; } void wcmd_castUnHolyArmor(WarContext* context, WarEntity* entity) { NOT_USED(entity); WarMap* map = context->map; map->command.type = WAR_COMMAND_SPELL_UNHOLY_ARMOR; } void wcmd_castRaiseDead(WarContext* context, WarEntity* entity) { NOT_USED(entity); WarMap* map = context->map; map->command.type = WAR_COMMAND_SPELL_RAISE_DEAD; } // summons void wcmd_summonSpider(WarContext* context, WarEntity* entity) { NOT_USED(entity); WarMap* map = context->map; map->command.type = WAR_COMMAND_SUMMON_SPIDER; } void wcmd_summonScorpion(WarContext* context, WarEntity* entity) { NOT_USED(entity); WarMap* map = context->map; map->command.type = WAR_COMMAND_SUMMON_SCORPION; } void wcmd_summonDaemon(WarContext* context, WarEntity* entity) { NOT_USED(entity); WarMap* map = context->map; map->command.type = WAR_COMMAND_SUMMON_DAEMON; } void wcmd_summonWaterElemental(WarContext* context, WarEntity* entity) { NOT_USED(entity); WarMap* map = context->map; map->command.type = WAR_COMMAND_SUMMON_WATER_ELEMENTAL; } ================================================ FILE: src/war_commands.h ================================================ #pragma once #include "common.h" #include "war_fwd.h" #include "war_units.h" struct _WarUnitCommand { WarUnitCommandType type; union { struct { WarUnitType unitToTrain; WarUnitType buildingUnit; } train; struct { WarUpgradeType upgradeToBuild; WarUnitType buildingUnit; } upgrade; struct { WarUnitType buildingToBuild; } build; }; }; bool wcmd_executeCommand(WarContext* context); // train units void wcmd_trainFootman(WarContext* context, WarEntity* entity); void wcmd_trainGrunt(WarContext* context, WarEntity* entity); void wcmd_trainPeasant(WarContext* context, WarEntity* entity); void wcmd_trainPeon(WarContext* context, WarEntity* entity); void wcmd_trainHumanCatapult(WarContext* context, WarEntity* entity); void wcmd_trainOrcCatapult(WarContext* context, WarEntity* entity); void wcmd_trainKnight(WarContext* context, WarEntity* entity); void wcmd_trainRaider(WarContext* context, WarEntity* entity); void wcmd_trainArcher(WarContext* context, WarEntity* entity); void wcmd_trainSpearman(WarContext* context, WarEntity* entity); void wcmd_trainConjurer(WarContext* context, WarEntity* entity); void wcmd_trainWarlock(WarContext* context, WarEntity* entity); void wcmd_trainCleric(WarContext* context, WarEntity* entity); void wcmd_trainNecrolyte(WarContext* context, WarEntity* entity); // upgrades void wcmd_upgradeSwords(WarContext* context, WarEntity* entity); void wcmd_upgradeAxes(WarContext* context, WarEntity* entity); void wcmd_upgradeHumanShields(WarContext* context, WarEntity* entity); void wcmd_upgradeOrcsShields(WarContext* context, WarEntity* entity); void wcmd_upgradeArrows(WarContext* context, WarEntity* entity); void wcmd_upgradeSpears(WarContext* context, WarEntity* entity); void wcmd_upgradeHorses(WarContext* context, WarEntity* entity); void wcmd_upgradeWolves(WarContext* context, WarEntity* entity); void wcmd_upgradeScorpions(WarContext* context, WarEntity* entity); void wcmd_upgradeSpiders(WarContext* context, WarEntity* entity); void wcmd_upgradeRainOfFire(WarContext* context, WarEntity* entity); void wcmd_upgradePoisonCloud(WarContext* context, WarEntity* entity); void wcmd_upgradeWaterElemental(WarContext* context, WarEntity* entity); void wcmd_upgradeDaemon(WarContext* context, WarEntity* entity); void wcmd_upgradeHealing(WarContext* context, WarEntity* entity); void wcmd_upgradeRaiseDead(WarContext* context, WarEntity* entity); void wcmd_upgradeFarSight(WarContext* context, WarEntity* entity); void wcmd_upgradeDarkVision(WarContext* context, WarEntity* entity); void wcmd_upgradeInvisibility(WarContext* context, WarEntity* entity); void wcmd_upgradeUnholyArmor(WarContext* context, WarEntity* entity); // wcmd_cancel void wcmd_cancel(WarContext* context, WarEntity* entity); // basic void move(WarContext* context, WarEntity* entity); void wcmd_stop(WarContext* context, WarEntity* entity); void wcmd_harvest(WarContext* context, WarEntity* entity); void deliver(WarContext* context, WarEntity* entity); void repair(WarContext* context, WarEntity* entity); void attack(WarContext* context, WarEntity* entity); void wcmd_buildBasic(WarContext* context, WarEntity* entity); void wcmd_buildAdvanced(WarContext* context, WarEntity* entity); // build buildings void wcmd_buildFarmHumans(WarContext* context, WarEntity* entity); void wcmd_buildFarmOrcs(WarContext* context, WarEntity* entity); void wcmd_buildBarracksHumans(WarContext* context, WarEntity* entity); void wcmd_buildBarracksOrcs(WarContext* context, WarEntity* entity); void wcmd_buildChurch(WarContext* context, WarEntity* entity); void wcmd_buildTemple(WarContext* context, WarEntity* entity); void wcmd_buildTowerHumans(WarContext* context, WarEntity* entity); void wcmd_buildTowerOrcs(WarContext* context, WarEntity* entity); void wcmd_buildTownHallHumans(WarContext* context, WarEntity* entity); void wcmd_buildTownHallOrcs(WarContext* context, WarEntity* entity); void wcmd_buildLumbermillHumans(WarContext* context, WarEntity* entity); void wcmd_buildLumbermillOrcs(WarContext* context, WarEntity* entity); void wcmd_buildStable(WarContext* context, WarEntity* entity); void wcmd_buildKennel(WarContext* context, WarEntity* entity); void wcmd_buildBlacksmithHumans(WarContext* context, WarEntity* entity); void wcmd_buildBlacksmithOrcs(WarContext* context, WarEntity* entity); void wcmd_buildWall(WarContext* context, WarEntity* entity); void wcmd_buildRoad(WarContext* context, WarEntity* entity); // spells void wcmd_castRainOfFire(WarContext* context, WarEntity* entity); void wcmd_castPoisonCloud(WarContext* context, WarEntity* entity); void wcmd_castHeal(WarContext* context, WarEntity* entity); void wcmd_castFarSight(WarContext* context, WarEntity* entity); void wcmd_castDarkVision(WarContext* context, WarEntity* entity); void wcmd_castInvisibility(WarContext* context, WarEntity* entity); void wcmd_castUnHolyArmor(WarContext* context, WarEntity* entity); void wcmd_castRaiseDead(WarContext* context, WarEntity* entity); // summons void wcmd_summonSpider(WarContext* context, WarEntity* entity); void wcmd_summonScorpion(WarContext* context, WarEntity* entity); void wcmd_summonDaemon(WarContext* context, WarEntity* entity); void wcmd_summonWaterElemental(WarContext* context, WarEntity* entity); ================================================ FILE: src/war_database.h ================================================ #pragma once #include "common.h" #include "war_fwd.h" typedef struct { s32 index; DatabaseEntryType type; char *name; u16 param1; u16 param2; u16 param3; } DatabaseEntry; DatabaseEntry assets[] = { // Music { 0, DB_ENTRY_TYPE_XMID, "00", 0, 0, 0 }, { 1, DB_ENTRY_TYPE_XMID, "01", 0, 0, 0 }, { 2, DB_ENTRY_TYPE_XMID, "02", 0, 0, 0 }, // demo { 3, DB_ENTRY_TYPE_XMID, "03", 0, 0, 0 }, { 4, DB_ENTRY_TYPE_XMID, "04", 0, 0, 0 }, // demo { 5, DB_ENTRY_TYPE_XMID, "05", 0, 0, 0 }, { 6, DB_ENTRY_TYPE_XMID, "06", 0, 0, 0 }, { 7, DB_ENTRY_TYPE_XMID, "07", 0, 0, 0 }, { 8, DB_ENTRY_TYPE_XMID, "08", 0, 0, 0 }, { 9, DB_ENTRY_TYPE_XMID, "09", 0, 0, 0 }, { 10, DB_ENTRY_TYPE_XMID, "10", 0, 0, 0 }, { 11, DB_ENTRY_TYPE_XMID, "11", 0, 0, 0 }, { 12, DB_ENTRY_TYPE_XMID, "12", 0, 0, 0 }, { 13, DB_ENTRY_TYPE_XMID, "13", 0, 0, 0 }, { 14, DB_ENTRY_TYPE_XMID, "14", 0, 0, 0 }, { 15, DB_ENTRY_TYPE_XMID, "15", 0, 0, 0 }, { 16, DB_ENTRY_TYPE_XMID, "16", 0, 0, 0 }, { 17, DB_ENTRY_TYPE_XMID, "17", 0, 0, 0 }, // demo { 18, DB_ENTRY_TYPE_XMID, "18", 0, 0, 0 }, { 19, DB_ENTRY_TYPE_XMID, "19", 0, 0, 0 }, // demo { 20, DB_ENTRY_TYPE_XMID, "20", 0, 0, 0 }, { 21, DB_ENTRY_TYPE_XMID, "21", 0, 0, 0 }, { 22, DB_ENTRY_TYPE_XMID, "22", 0, 0, 0 }, { 23, DB_ENTRY_TYPE_XMID, "23", 0, 0, 0 }, { 24, DB_ENTRY_TYPE_XMID, "24", 0, 0, 0 }, { 25, DB_ENTRY_TYPE_XMID, "25", 0, 0, 0 }, { 26, DB_ENTRY_TYPE_XMID, "26", 0, 0, 0 }, { 27, DB_ENTRY_TYPE_XMID, "27", 0, 0, 0 }, { 28, DB_ENTRY_TYPE_XMID, "28", 0, 0, 0 }, { 29, DB_ENTRY_TYPE_XMID, "29", 0, 0, 0 }, { 30, DB_ENTRY_TYPE_XMID, "30", 0, 0, 0 }, { 31, DB_ENTRY_TYPE_XMID, "31", 0, 0, 0 }, { 32, DB_ENTRY_TYPE_XMID, "32", 0, 0, 0 }, // demo { 33, DB_ENTRY_TYPE_XMID, "33", 0, 0, 0 }, { 34, DB_ENTRY_TYPE_XMID, "34", 0, 0, 0 }, // demo { 35, DB_ENTRY_TYPE_XMID, "35", 0, 0, 0 }, { 36, DB_ENTRY_TYPE_XMID, "36", 0, 0, 0 }, { 37, DB_ENTRY_TYPE_XMID, "37", 0, 0, 0 }, { 38, DB_ENTRY_TYPE_XMID, "38", 0, 0, 0 }, { 39, DB_ENTRY_TYPE_XMID, "39", 0, 0, 0 }, { 40, DB_ENTRY_TYPE_XMID, "40", 0, 0, 0 }, { 41, DB_ENTRY_TYPE_XMID, "41", 0, 0, 0 }, { 42, DB_ENTRY_TYPE_XMID, "42", 0, 0, 0 }, { 43, DB_ENTRY_TYPE_XMID, "43", 0, 0, 0 }, { 44, DB_ENTRY_TYPE_XMID, "44", 0, 0, 0 }, // Levels info { 45, DB_ENTRY_TYPE_LEVEL_VISUAL, "FileLevelVisual", 0, 0, 0 }, { 46, DB_ENTRY_TYPE_LEVEL_PASSABLE, "FileLevelPassable", 0, 0, 0 }, { 47, DB_ENTRY_TYPE_LEVEL_VISUAL, "FileLevelVisual", 0, 0, 0 }, { 48, DB_ENTRY_TYPE_LEVEL_PASSABLE, "FileLevelPassable", 0, 0, 0 }, { 49, DB_ENTRY_TYPE_LEVEL_VISUAL, "FileLevelVisual", 0, 0, 0 }, // demo { 50, DB_ENTRY_TYPE_LEVEL_PASSABLE, "FileLevelPassable", 0, 0, 0 }, // demo { 51, DB_ENTRY_TYPE_LEVEL_VISUAL, "FileLevelVisual", 0, 0, 0 }, // demo { 52, DB_ENTRY_TYPE_LEVEL_PASSABLE, "FileLevelPassable", 0, 0, 0 }, // demo { 53, DB_ENTRY_TYPE_LEVEL_VISUAL, "FileLevelVisual", 0, 0, 0 }, { 54, DB_ENTRY_TYPE_LEVEL_PASSABLE, "FileLevelPassable", 0, 0, 0 }, { 55, DB_ENTRY_TYPE_LEVEL_VISUAL, "FileLevelVisual", 0, 0, 0 }, // demo { 56, DB_ENTRY_TYPE_LEVEL_PASSABLE, "FileLevelPassable", 0, 0, 0 }, // demo { 57, DB_ENTRY_TYPE_LEVEL_VISUAL, "FileLevelVisual", 0, 0, 0 }, { 58, DB_ENTRY_TYPE_LEVEL_PASSABLE, "FileLevelPassable", 0, 0, 0 }, { 59, DB_ENTRY_TYPE_LEVEL_VISUAL, "FileLevelVisual", 0, 0, 0 }, { 60, DB_ENTRY_TYPE_LEVEL_PASSABLE, "FileLevelPassable", 0, 0, 0 }, { 61, DB_ENTRY_TYPE_LEVEL_VISUAL, "FileLevelVisual", 0, 0, 0 }, { 62, DB_ENTRY_TYPE_LEVEL_PASSABLE, "FileLevelPassable", 0, 0, 0 }, { 63, DB_ENTRY_TYPE_LEVEL_VISUAL, "FileLevelVisual", 0, 0, 0 }, // demo { 64, DB_ENTRY_TYPE_LEVEL_PASSABLE, "FileLevelPassable", 0, 0, 0 }, // demo { 65, DB_ENTRY_TYPE_LEVEL_VISUAL, "FileLevelVisual", 0, 0, 0 }, { 66, DB_ENTRY_TYPE_LEVEL_PASSABLE, "FileLevelPassable", 0, 0, 0 }, { 67, DB_ENTRY_TYPE_LEVEL_VISUAL, "FileLevelVisual", 0, 0, 0 }, { 68, DB_ENTRY_TYPE_LEVEL_PASSABLE, "FileLevelPassable", 0, 0, 0 }, { 69, DB_ENTRY_TYPE_LEVEL_VISUAL, "FileLevelVisual", 0, 0, 0 }, // demo { 70, DB_ENTRY_TYPE_LEVEL_PASSABLE, "FileLevelPassable", 0, 0, 0 }, // demo { 71, DB_ENTRY_TYPE_LEVEL_VISUAL, "FileLevelVisual", 0, 0, 0 }, { 72, DB_ENTRY_TYPE_LEVEL_PASSABLE, "FileLevelPassable", 0, 0, 0 }, { 73, DB_ENTRY_TYPE_LEVEL_VISUAL, "FileLevelVisual", 0, 0, 0 }, { 74, DB_ENTRY_TYPE_LEVEL_PASSABLE, "FileLevelPassable", 0, 0, 0 }, { 75, DB_ENTRY_TYPE_LEVEL_VISUAL, "FileLevelVisual", 0, 0, 0 }, { 76, DB_ENTRY_TYPE_LEVEL_PASSABLE, "FileLevelPassable", 0, 0, 0 }, { 77, DB_ENTRY_TYPE_LEVEL_VISUAL, "FileLevelVisual", 0, 0, 0 }, { 78, DB_ENTRY_TYPE_LEVEL_PASSABLE, "FileLevelPassable", 0, 0, 0 }, { 79, DB_ENTRY_TYPE_LEVEL_VISUAL, "FileLevelVisual", 0, 0, 0 }, // demo { 80, DB_ENTRY_TYPE_LEVEL_PASSABLE, "FileLevelPassable", 0, 0, 0 }, // demo { 81, DB_ENTRY_TYPE_LEVEL_VISUAL, "FileLevelVisual", 0, 0, 0 }, // demo { 82, DB_ENTRY_TYPE_LEVEL_PASSABLE, "FileLevelPassable", 0, 0, 0 }, // demo { 83, DB_ENTRY_TYPE_LEVEL_VISUAL, "FileLevelVisual", 0, 0, 0 }, { 84, DB_ENTRY_TYPE_LEVEL_PASSABLE, "FileLevelPassable", 0, 0, 0 }, { 85, DB_ENTRY_TYPE_LEVEL_VISUAL, "FileLevelVisual", 0, 0, 0 }, { 86, DB_ENTRY_TYPE_LEVEL_PASSABLE, "FileLevelPassable", 0, 0, 0 }, { 87, DB_ENTRY_TYPE_LEVEL_VISUAL, "FileLevelVisual", 0, 0, 0 }, { 88, DB_ENTRY_TYPE_LEVEL_PASSABLE, "FileLevelPassable", 0, 0, 0 }, { 89, DB_ENTRY_TYPE_LEVEL_VISUAL, "FileLevelVisual", 0, 0, 0 }, // demo { 90, DB_ENTRY_TYPE_LEVEL_PASSABLE, "FileLevelPassable", 0, 0, 0 }, // demo { 91, DB_ENTRY_TYPE_LEVEL_VISUAL, "FileLevelVisual", 0, 0, 0 }, { 92, DB_ENTRY_TYPE_LEVEL_PASSABLE, "FileLevelPassable", 0, 0, 0 }, { 93, DB_ENTRY_TYPE_LEVEL_VISUAL, "FileLevelVisual", 0, 0, 0 }, // demo { 94, DB_ENTRY_TYPE_LEVEL_PASSABLE, "FileLevelPassable", 0, 0, 0 }, // demo { 95, DB_ENTRY_TYPE_LEVEL_VISUAL, "FileLevelVisual", 0, 0, 0 }, { 96, DB_ENTRY_TYPE_LEVEL_PASSABLE, "FileLevelPassable", 0, 0, 0 }, { 97, DB_ENTRY_TYPE_LEVEL_VISUAL, "FileLevelVisual", 0, 0, 0 }, { 98, DB_ENTRY_TYPE_LEVEL_PASSABLE, "FileLevelPassable", 0, 0, 0 }, { 99, DB_ENTRY_TYPE_LEVEL_VISUAL, "FileLevelVisual", 0, 0, 0 }, { 100, DB_ENTRY_TYPE_LEVEL_PASSABLE, "FileLevelPassable", 0, 0, 0 }, { 101, DB_ENTRY_TYPE_LEVEL_VISUAL, "FileLevelVisual", 0, 0, 0 }, { 102, DB_ENTRY_TYPE_LEVEL_PASSABLE, "FileLevelPassable", 0, 0, 0 }, { 103, DB_ENTRY_TYPE_LEVEL_VISUAL, "FileLevelVisual", 0, 0, 0 }, { 104, DB_ENTRY_TYPE_LEVEL_PASSABLE, "FileLevelPassable", 0, 0, 0 }, { 105, DB_ENTRY_TYPE_LEVEL_VISUAL, "FileLevelVisual", 0, 0, 0 }, { 106, DB_ENTRY_TYPE_LEVEL_PASSABLE, "FileLevelPassable", 0, 0, 0 }, { 107, DB_ENTRY_TYPE_LEVEL_VISUAL, "FileLevelVisual", 0, 0, 0 }, { 108, DB_ENTRY_TYPE_LEVEL_PASSABLE, "FileLevelPassable", 0, 0, 0 }, { 109, DB_ENTRY_TYPE_LEVEL_VISUAL, "FileLevelVisual", 0, 0, 0 }, { 110, DB_ENTRY_TYPE_LEVEL_PASSABLE, "FileLevelPassable", 0, 0, 0 }, { 111, DB_ENTRY_TYPE_LEVEL_VISUAL, "FileLevelVisual", 0, 0, 0 }, { 112, DB_ENTRY_TYPE_LEVEL_PASSABLE, "FileLevelPassable", 0, 0, 0 }, { 113, DB_ENTRY_TYPE_LEVEL_VISUAL, "FileLevelVisual", 0, 0, 0 }, { 114, DB_ENTRY_TYPE_LEVEL_PASSABLE, "FileLevelPassable", 0, 0, 0 }, { 115, DB_ENTRY_TYPE_LEVEL_VISUAL, "FileLevelVisual", 0, 0, 0 }, { 116, DB_ENTRY_TYPE_LEVEL_PASSABLE, "FileLevelPassable", 0, 0, 0 }, // Levels { 117, DB_ENTRY_TYPE_LEVEL_INFO, "humans_01", 0, 0, 0 }, // demo { 118, DB_ENTRY_TYPE_LEVEL_INFO, "orcs_01", 1, 0, 0 }, // demo { 119, DB_ENTRY_TYPE_LEVEL_INFO, "humans_02", 0, 0, 0 }, // demo { 120, DB_ENTRY_TYPE_LEVEL_INFO, "orcs_02", 1, 0, 0 }, // demo { 121, DB_ENTRY_TYPE_LEVEL_INFO, "humans_03", 1, 0, 0 }, // demo { 122, DB_ENTRY_TYPE_LEVEL_INFO, "orcs_03", 0, 0, 0 }, // demo { 123, DB_ENTRY_TYPE_LEVEL_INFO, "humans_04", 2, 0, 0 }, { 124, DB_ENTRY_TYPE_LEVEL_INFO, "orcs_04", 2, 0, 0 }, { 125, DB_ENTRY_TYPE_LEVEL_INFO, "humans_05", 0, 0, 0 }, { 126, DB_ENTRY_TYPE_LEVEL_INFO, "orcs_05", 1, 0, 0 }, { 127, DB_ENTRY_TYPE_LEVEL_INFO, "humans_06", 0, 0, 0 }, { 128, DB_ENTRY_TYPE_LEVEL_INFO, "orcs_06", 0, 0, 0 }, { 129, DB_ENTRY_TYPE_LEVEL_INFO, "humans_07", 0, 0, 0 }, { 130, DB_ENTRY_TYPE_LEVEL_INFO, "orcs_07", 1, 0, 0 }, { 131, DB_ENTRY_TYPE_LEVEL_INFO, "humans_08", 2, 0, 0 }, { 132, DB_ENTRY_TYPE_LEVEL_INFO, "orcs_08", 2, 0, 0 }, { 133, DB_ENTRY_TYPE_LEVEL_INFO, "humans_09", 1, 0, 0 }, { 134, DB_ENTRY_TYPE_LEVEL_INFO, "orcs_09", 1, 0, 0 }, { 135, DB_ENTRY_TYPE_LEVEL_INFO, "humans_10", 1, 0, 0 }, { 136, DB_ENTRY_TYPE_LEVEL_INFO, "orcs_10", 0, 0, 0 }, { 137, DB_ENTRY_TYPE_LEVEL_INFO, "humans_11", 1, 0, 0 }, { 138, DB_ENTRY_TYPE_LEVEL_INFO, "orcs_11", 0, 0, 0 }, { 139, DB_ENTRY_TYPE_LEVEL_INFO, "humans_12", 1, 0, 0 }, { 140, DB_ENTRY_TYPE_LEVEL_INFO, "orcs_12", 0, 0, 0 }, // Custom { 141, DB_ENTRY_TYPE_UNKNOWN, "battle_test_map_1", 1, 0, 0 }, // test map, just several footmans and archers against grunts and spearmans, player control humans { 142, DB_ENTRY_TYPE_UNKNOWN, "battle_test_map_2", 1, 0, 0 }, // test map, several footmans and archers attacking an orc camp with few grunts and spearmans, player controls humans { 143, DB_ENTRY_TYPE_UNKNOWN, "battle_test_map_3", 1, 0, 0 }, // test map, several footmans and archers attacking an orc camp with few grunts and spearmans, player controls orcs { 144, DB_ENTRY_TYPE_UNKNOWN, "battle_test_map_4", 1, 0, 0 }, // test map, several grunts and spearmans attacking a human camp with few footmans and archers, player controls orcs { 147, DB_ENTRY_TYPE_LEVEL_INFO, "forest_1", 0, 1, 0 }, { 148, DB_ENTRY_TYPE_LEVEL_INFO, "forest_2", 0, 1, 0 }, { 149, DB_ENTRY_TYPE_LEVEL_INFO, "forest_3", 0, 1, 0 }, { 150, DB_ENTRY_TYPE_LEVEL_INFO, "forest_4", 0, 1, 0 }, { 151, DB_ENTRY_TYPE_LEVEL_INFO, "forest_5", 0, 1, 0 }, { 152, DB_ENTRY_TYPE_LEVEL_INFO, "forest_6", 0, 1, 0 }, { 153, DB_ENTRY_TYPE_LEVEL_INFO, "forest_7", 0, 1, 0 }, { 154, DB_ENTRY_TYPE_LEVEL_INFO, "swamp_6", 1, 1, 0 }, { 155, DB_ENTRY_TYPE_LEVEL_INFO, "swamp_7", 1, 1, 0 }, { 156, DB_ENTRY_TYPE_LEVEL_INFO, "swamp_1", 1, 1, 0 }, { 157, DB_ENTRY_TYPE_LEVEL_INFO, "swamp_2", 1, 1, 0 }, { 158, DB_ENTRY_TYPE_LEVEL_INFO, "swamp_3", 1, 1, 0 }, { 159, DB_ENTRY_TYPE_LEVEL_INFO, "swamp_4", 1, 1, 0 }, { 160, DB_ENTRY_TYPE_LEVEL_INFO, "swamp_5", 1, 1, 0 }, { 161, DB_ENTRY_TYPE_LEVEL_INFO, "dungeon_1", 2, 1, 0 }, { 162, DB_ENTRY_TYPE_LEVEL_INFO, "dungeon_2", 2, 1, 0 }, { 163, DB_ENTRY_TYPE_LEVEL_INFO, "dungeon_3", 2, 1, 0 }, { 164, DB_ENTRY_TYPE_LEVEL_INFO, "dungeon_4", 2, 1, 0 }, { 165, DB_ENTRY_TYPE_LEVEL_INFO, "dungeon_5", 2, 1, 0 }, { 166, DB_ENTRY_TYPE_LEVEL_INFO, "dungeon_6", 2, 1, 0 }, { 167, DB_ENTRY_TYPE_LEVEL_INFO, "dungeon_7", 2, 1, 0 }, { 168, DB_ENTRY_TYPE_LEVEL_INFO, "forest_1_big_enemy", 0, 1, 0 }, { 169, DB_ENTRY_TYPE_LEVEL_INFO, "forest_2_big_enemy", 0, 1, 0 }, { 170, DB_ENTRY_TYPE_LEVEL_INFO, "forest_3_big_enemy", 0, 1, 0 }, { 171, DB_ENTRY_TYPE_LEVEL_INFO, "forest_4_big_enemy", 0, 1, 0 }, { 172, DB_ENTRY_TYPE_LEVEL_INFO, "forest_5_big_enemy", 0, 1, 0 }, { 173, DB_ENTRY_TYPE_LEVEL_INFO, "forest_6_big_enemy", 0, 1, 0 }, { 174, DB_ENTRY_TYPE_LEVEL_INFO, "forest_7_big_enemy", 0, 1, 0 }, { 175, DB_ENTRY_TYPE_LEVEL_INFO, "swamp_6_big_enemy", 1, 1, 0 }, { 176, DB_ENTRY_TYPE_LEVEL_INFO, "swamp_7_big_enemy", 1, 1, 0 }, { 177, DB_ENTRY_TYPE_LEVEL_INFO, "swamp_1_big_enemy", 1, 1, 0 }, { 178, DB_ENTRY_TYPE_LEVEL_INFO, "swamp_2_big_enemy", 1, 1, 0 }, { 179, DB_ENTRY_TYPE_LEVEL_INFO, "swamp_3_big_enemy", 1, 1, 0 }, { 180, DB_ENTRY_TYPE_LEVEL_INFO, "swamp_4_big_enemy", 1, 1, 0 }, { 181, DB_ENTRY_TYPE_LEVEL_INFO, "swamp_5_big_enemy", 1, 1, 0 }, { 182, DB_ENTRY_TYPE_LEVEL_INFO, "dungeon_1_big_enemy", 2, 1, 0 }, { 183, DB_ENTRY_TYPE_LEVEL_INFO, "dungeon_2_big_enemy", 2, 1, 0 }, { 184, DB_ENTRY_TYPE_LEVEL_INFO, "dungeon_3_big_enemy", 2, 1, 0 }, { 185, DB_ENTRY_TYPE_LEVEL_INFO, "dungeon_4_big_enemy", 2, 1, 0 }, { 186, DB_ENTRY_TYPE_LEVEL_INFO, "dungeon_5_big_enemy", 2, 1, 0 }, { 187, DB_ENTRY_TYPE_LEVEL_INFO, "dungeon_6_big_enemy", 2, 1, 0 }, { 188, DB_ENTRY_TYPE_LEVEL_INFO, "dungeon_7_big_enemy", 2, 1, 0 }, // Palettes { 191, DB_ENTRY_TYPE_PALETTE, "forest", 0, 0, 0 }, // demo { 194, DB_ENTRY_TYPE_PALETTE, "swamp", 0, 0, 0 }, // demo { 197, DB_ENTRY_TYPE_PALETTE, "dungeon", 0, 0, 0 }, { 217, DB_ENTRY_TYPE_PALETTE, "background", 0, 0, 0 }, // demo { 255, DB_ENTRY_TYPE_PALETTE, "humans", 0, 0, 0 }, // demo { 260, DB_ENTRY_TYPE_PALETTE, "ui", 0, 0, 0 }, // demo { 262, DB_ENTRY_TYPE_PALETTE, "pointer", 0, 0, 0 }, // demo { 413, DB_ENTRY_TYPE_PALETTE, "summary", 0, 0, 0 }, // demo { 416, DB_ENTRY_TYPE_PALETTE, "for 415", 0, 0, 0 }, // demo { 418, DB_ENTRY_TYPE_PALETTE, "for 417", 0, 0, 0 }, // demo { 423, DB_ENTRY_TYPE_PALETTE, "briefing", 0, 0, 0 }, // demo { 424, DB_ENTRY_TYPE_PALETTE, "briefing", 0, 0, 0 }, // demo { 457, DB_ENTRY_TYPE_PALETTE, "for 456", 0, 0, 0 }, { 459, DB_ENTRY_TYPE_PALETTE, "for 458", 0, 0, 0 }, // Tiles { 190, DB_ENTRY_TYPE_TILES, "forest", 191, 217, 0 }, // demo { 193, DB_ENTRY_TYPE_TILES, "swamp", 194, 217, 0 }, // demo { 196, DB_ENTRY_TYPE_TILES, "dungeon", 197, 217, 0 }, // Tilesets { 189, DB_ENTRY_TYPE_TILESET, "forest", 190, 0, 0 }, // demo { 192, DB_ENTRY_TYPE_TILESET, "swamp", 193, 0, 0 }, // demo { 195, DB_ENTRY_TYPE_TILESET, "dungeon", 196, 0, 0 }, // Cursors { 263, DB_ENTRY_TYPE_CURSOR, "arrow", 262, 0, 0 }, // demo { 264, DB_ENTRY_TYPE_CURSOR, "invalid_command", 262, 0, 0 }, // demo { 265, DB_ENTRY_TYPE_CURSOR, "yellow_crosshair", 262, 0, 0 }, // demo { 266, DB_ENTRY_TYPE_CURSOR, "red_crosshair", 262, 0, 0 }, // demo { 267, DB_ENTRY_TYPE_CURSOR, "yellow_crosshair_2", 262, 0, 0 }, // demo { 268, DB_ENTRY_TYPE_CURSOR, "magnifying_glass", 262, 0, 0 }, // demo { 269, DB_ENTRY_TYPE_CURSOR, "small_green_crosshair", 262, 0, 0 }, // demo { 270, DB_ENTRY_TYPE_CURSOR, "watch", 262, 0, 0 }, // demo { 271, DB_ENTRY_TYPE_CURSOR, "up_arrow", 262, 0, 0 }, // demo { 272, DB_ENTRY_TYPE_CURSOR, "upper_right_arrow", 262, 0, 0 }, // demo { 273, DB_ENTRY_TYPE_CURSOR, "right_arrow", 262, 0, 0 }, // demo { 274, DB_ENTRY_TYPE_CURSOR, "lower_right_arrow", 262, 0, 0 }, // demo { 275, DB_ENTRY_TYPE_CURSOR, "down_arrow", 262, 0, 0 }, // demo { 276, DB_ENTRY_TYPE_CURSOR, "lower_left_arrow", 262, 0, 0 }, // demo { 277, DB_ENTRY_TYPE_CURSOR, "left_arrow", 262, 0, 0 }, // demo { 278, DB_ENTRY_TYPE_CURSOR, "upper_left_arrow", 262, 0, 0 }, // demo // Sprites { 279, DB_ENTRY_TYPE_SPRITE, "footman_humans", 191, 217, 0 }, // demo { 280, DB_ENTRY_TYPE_SPRITE, "grunt_orcs", 191, 217, 0 }, // demo { 281, DB_ENTRY_TYPE_SPRITE, "peasant_humans", 191, 217, 0 }, // demo { 282, DB_ENTRY_TYPE_SPRITE, "peon_orcs", 191, 217, 0 }, // demo { 283, DB_ENTRY_TYPE_SPRITE, "catapult_humans", 191, 217, 0 }, { 284, DB_ENTRY_TYPE_SPRITE, "catapult_orcs", 191, 217, 0 }, { 285, DB_ENTRY_TYPE_SPRITE, "knight_humans", 191, 217, 0 }, { 286, DB_ENTRY_TYPE_SPRITE, "raider_orcs", 191, 217, 0 }, { 287, DB_ENTRY_TYPE_SPRITE, "archer_humans", 191, 217, 0 }, // demo { 288, DB_ENTRY_TYPE_SPRITE, "axethrower_orcs", 191, 217, 0 }, // demo { 289, DB_ENTRY_TYPE_SPRITE, "wizard_humans", 191, 217, 0 }, { 290, DB_ENTRY_TYPE_SPRITE, "wizard_orcs", 191, 217, 0 }, { 291, DB_ENTRY_TYPE_SPRITE, "priest_humans", 191, 217, 0 }, // demo { 292, DB_ENTRY_TYPE_SPRITE, "necrolyte_orcs", 191, 217, 0 }, // demo { 293, DB_ENTRY_TYPE_SPRITE, "medivh", 191, 217, 0 }, { 294, DB_ENTRY_TYPE_SPRITE, "lothar", 191, 217, 0 }, { 295, DB_ENTRY_TYPE_SPRITE, "wounded", 191, 217, 0 }, { 296, DB_ENTRY_TYPE_SPRITE, "garona", 191, 217, 0 }, { 297, DB_ENTRY_TYPE_SPRITE, "ogre", 191, 217, 0 }, { 298, DB_ENTRY_TYPE_SPRITE, "spider", 191, 217, 0 }, { 299, DB_ENTRY_TYPE_SPRITE, "slime", 191, 217, 0 }, { 300, DB_ENTRY_TYPE_SPRITE, "fire_elemental", 191, 217, 0 }, { 301, DB_ENTRY_TYPE_SPRITE, "scorpion", 191, 217, 0 }, { 302, DB_ENTRY_TYPE_SPRITE, "brigand", 191, 217, 0 }, { 303, DB_ENTRY_TYPE_SPRITE, "the_dead", 191, 217, 0 }, // demo { 304, DB_ENTRY_TYPE_SPRITE, "skeleton_02", 191, 217, 0 }, { 305, DB_ENTRY_TYPE_SPRITE, "demon", 191, 217, 0 }, { 306, DB_ENTRY_TYPE_SPRITE, "water_elemental", 191, 217, 0 }, { 307, DB_ENTRY_TYPE_SPRITE, "farm_humans", 191, 217, 0 }, // demo { 308, DB_ENTRY_TYPE_SPRITE, "farm_orcs", 191, 217, 0 }, // demo { 309, DB_ENTRY_TYPE_SPRITE, "barracks_humans", 191, 217, 0 }, // demo { 310, DB_ENTRY_TYPE_SPRITE, "barracks_orcs", 191, 217, 0 }, // demo { 311, DB_ENTRY_TYPE_SPRITE, "church_humans", 191, 217, 0 }, // demo { 312, DB_ENTRY_TYPE_SPRITE, "temple_orcs", 191, 217, 0 }, // demo { 313, DB_ENTRY_TYPE_SPRITE, "tower_humns", 191, 217, 0 }, { 314, DB_ENTRY_TYPE_SPRITE, "skull_orcs", 191, 217, 0 }, { 315, DB_ENTRY_TYPE_SPRITE, "town_hall_humans", 191, 217, 0 }, // demo { 316, DB_ENTRY_TYPE_SPRITE, "town_hall_orcs", 191, 217, 0 }, // demo { 317, DB_ENTRY_TYPE_SPRITE, "lumbermill_humans", 191, 217, 0 }, // demo { 318, DB_ENTRY_TYPE_SPRITE, "lumbermill_orcs", 191, 217, 0 }, // demo { 319, DB_ENTRY_TYPE_SPRITE, "stable_humans", 191, 217, 0 }, { 320, DB_ENTRY_TYPE_SPRITE, "stable_orcs", 191, 217, 0 }, { 321, DB_ENTRY_TYPE_SPRITE, "blacksmith_humans", 191, 217, 0 }, { 322, DB_ENTRY_TYPE_SPRITE, "blacksmith_orcs", 191, 217, 0 }, { 323, DB_ENTRY_TYPE_SPRITE, "stormwind_humans", 191, 217, 0 }, { 324, DB_ENTRY_TYPE_SPRITE, "black_spire_orcs", 191, 217, 0 }, { 325, DB_ENTRY_TYPE_SPRITE, "goldmine", 191, 217, 0 }, // demo { 326, DB_ENTRY_TYPE_SPRITE, "corpse", 191, 217, 0 }, // demo { 327, DB_ENTRY_TYPE_SPRITE, "peasant_with_lumber_humans", 191, 217, 0 }, // demo { 328, DB_ENTRY_TYPE_SPRITE, "peon_with_lumber_orcs", 191, 217, 0 }, // demo { 329, DB_ENTRY_TYPE_SPRITE, "peasant_with_gold_humans", 191, 217, 0 }, // demo { 330, DB_ENTRY_TYPE_SPRITE, "peon_with_gold_orcs", 191, 217, 0 }, // demo { 331, DB_ENTRY_TYPE_SPRITE, "farm_construction_humans", 191, 217, 0 }, // demo { 332, DB_ENTRY_TYPE_SPRITE, "farm_construction_orcs", 191, 217, 0 }, // demo { 333, DB_ENTRY_TYPE_SPRITE, "barracks_construction_humans", 191, 217, 0 }, // demo { 334, DB_ENTRY_TYPE_SPRITE, "barracks_construction_orcs", 191, 217, 0 }, // demo { 335, DB_ENTRY_TYPE_SPRITE, "church_construction_humans", 191, 217, 0 }, // demo { 336, DB_ENTRY_TYPE_SPRITE, "temple_construction_orcs", 191, 217, 0 }, // demo { 337, DB_ENTRY_TYPE_SPRITE, "tower_construction_humans", 191, 217, 0 }, { 338, DB_ENTRY_TYPE_SPRITE, "tower_construction_orcs", 191, 217, 0 }, { 339, DB_ENTRY_TYPE_SPRITE, "town_hall_construction_humans", 191, 217, 0 }, // demo { 340, DB_ENTRY_TYPE_SPRITE, "town_hall_construction_orcs", 191, 217, 0 }, // demo { 341, DB_ENTRY_TYPE_SPRITE, "lumber_mill_construction_humans", 191, 217, 0 }, // demo { 342, DB_ENTRY_TYPE_SPRITE, "lumber_mill_construction_orcs", 191, 217, 0 }, // demo { 343, DB_ENTRY_TYPE_SPRITE, "stable_construction_humans", 191, 217, 0 }, { 344, DB_ENTRY_TYPE_SPRITE, "stable_construction_orcs", 191, 217, 0 }, { 345, DB_ENTRY_TYPE_SPRITE, "blacksmith_construction_humans", 191, 217, 0 }, { 346, DB_ENTRY_TYPE_SPRITE, "blacksmith_construction_orcs", 191, 217, 0 }, { 350, DB_ENTRY_TYPE_SPRITE, "poison_cloud", 191, 217, 0 }, { 352, DB_ENTRY_TYPE_SPRITE, "small_fire", 191, 217, 0 }, // demo { 353, DB_ENTRY_TYPE_SPRITE, "large_fire", 191, 217, 0 }, // demo { 354, DB_ENTRY_TYPE_SPRITE, "explosion", 191, 217, 0 }, { 355, DB_ENTRY_TYPE_SPRITE, "healing", 191, 217, 0 }, // demo { 356, DB_ENTRY_TYPE_SPRITE, "building_collapse", 191, 217, 0 }, // demo { 359, DB_ENTRY_TYPE_SPRITE, "ui_pictures_orcs", 191, 217, 0 }, // demo { 360, DB_ENTRY_TYPE_SPRITE, "ui_pictures_humans", 255, 0, 0 }, // demo { 361, DB_ENTRY_TYPE_SPRITE, "ui_pictures_icons", 191, 217, 0 }, // demo { 425, DB_ENTRY_TYPE_SPRITE, "burning_fire", 424, 0, 0 }, { 426, DB_ENTRY_TYPE_SPRITE, "talking_orc_01", 424, 0, 0 }, // demo { 427, DB_ENTRY_TYPE_SPRITE, "talking_orc_02", 424, 0, 0 }, // demo { 428, DB_ENTRY_TYPE_SPRITE, "eating_human", 423, 0, 0 }, // demo { 429, DB_ENTRY_TYPE_SPRITE, "human_wizard", 423, 0, 0 }, // demo { 430, DB_ENTRY_TYPE_SPRITE, "anim_01", 423, 0, 0 }, // demo { 431, DB_ENTRY_TYPE_SPRITE, "anim_02", 423, 0, 0 }, // demo { 460, DB_ENTRY_TYPE_SPRITE, "anim_03", 459, 0, 0 }, // Projectiles { 347, DB_ENTRY_TYPE_SPRITE, "missiles_fireball", 191, 217, 0 }, // demo { 348, DB_ENTRY_TYPE_SPRITE, "missiles_catapult_projectile", 191, 217, 0 }, { 349, DB_ENTRY_TYPE_SPRITE, "missiles_arrow", 191, 217, 0 }, // demo { 351, DB_ENTRY_TYPE_SPRITE, "missiles_rain_of_fire", 191, 217, 0 }, { 357, DB_ENTRY_TYPE_SPRITE, "missiles_water_elemental_projectile", 191, 217, 0 }, { 358, DB_ENTRY_TYPE_SPRITE, "missiles_fireball_2", 191, 217, 0 }, // Images { 216, DB_ENTRY_TYPE_IMAGE, "background 'Blizzard'", 217, 0, 0 }, // demo { 218, DB_ENTRY_TYPE_IMAGE, "topbar_humans", 255, 0, 0 }, // demo { 219, DB_ENTRY_TYPE_IMAGE, "topbar_orcs", 191, 217, 0 }, // demo { 220, DB_ENTRY_TYPE_IMAGE, "sidebar_right_humans", 255, 0, 0 }, // demo { 221, DB_ENTRY_TYPE_IMAGE, "sidebar_right_orcs", 217, 0, 0 }, // demo { 222, DB_ENTRY_TYPE_IMAGE, "lower_bar_humans", 255, 0, 0 }, // demo { 223, DB_ENTRY_TYPE_IMAGE, "lower_bar_orcs", 217, 0, 0 }, // demo { 224, DB_ENTRY_TYPE_IMAGE, "sidebar_left_minimap_empty_humans", 255, 0, 0 }, // demo { 225, DB_ENTRY_TYPE_IMAGE, "sidebar_left_minimap_empty_orcs", 217, 0, 0 }, // demo { 226, DB_ENTRY_TYPE_IMAGE, "sidebar_left_humans", 255, 0, 0 }, // demo { 227, DB_ENTRY_TYPE_IMAGE, "sidebar_left_orcs", 217, 0, 0 }, // demo { 228, DB_ENTRY_TYPE_IMAGE, "sidebar_left_minimap_black_humans", 255, 0, 0 }, // demo { 229, DB_ENTRY_TYPE_IMAGE, "sidebar_left_minimap_black_orcs", 217, 0, 0 }, // demo { 233, DB_ENTRY_TYPE_IMAGE, "large_box_humans", 255, 0, 0 }, // demo { 234, DB_ENTRY_TYPE_IMAGE, "large_box_orcs", 217, 0, 0 }, // demo { 235, DB_ENTRY_TYPE_IMAGE, "small_box_humans", 255, 0, 0 }, // demo { 236, DB_ENTRY_TYPE_IMAGE, "smal_box_orcs", 217, 0, 0 }, // demo { 237, DB_ENTRY_TYPE_IMAGE, "large_button", 260, 0, 0 }, // demo { 238, DB_ENTRY_TYPE_IMAGE, "large_button_pressed", 260, 0, 0 }, // demo { 239, DB_ENTRY_TYPE_IMAGE, "medium_button", 260, 0, 0 }, // demo { 240, DB_ENTRY_TYPE_IMAGE, "medium_button_pressed", 260, 0, 0 }, // demo { 241, DB_ENTRY_TYPE_IMAGE, "small_button", 260, 0, 0 }, // demo { 242, DB_ENTRY_TYPE_IMAGE, "small_button_pressed", 260, 0, 0 }, // demo { 243, DB_ENTRY_TYPE_IMAGE, "menu_background_lower", 260, 0, 0 }, // demo { 244, DB_ENTRY_TYPE_IMAGE, "arrow_left_button", 255, 0, 0 }, // demo { 245, DB_ENTRY_TYPE_IMAGE, "arrow_left_button_grey", 255, 0, 0 }, // demo { 246, DB_ENTRY_TYPE_IMAGE, "arrow_right_button", 255, 0, 0 }, // demo { 247, DB_ENTRY_TYPE_IMAGE, "arrow_right_button_grey", 255, 0, 0 }, // demo { 248, DB_ENTRY_TYPE_IMAGE, "window_border", 255, 0, 0 }, // demo { 249, DB_ENTRY_TYPE_IMAGE, "saving_loading_humans", 255, 0, 0 }, // demo { 250, DB_ENTRY_TYPE_IMAGE, "saving_loading_orcs", 217, 0, 0 }, // demo { 254, DB_ENTRY_TYPE_IMAGE, "hot_keys", 255, 0, 0 }, // demo { 256, DB_ENTRY_TYPE_IMAGE, "ok1_button", 255, 0, 0 }, // demo { 257, DB_ENTRY_TYPE_IMAGE, "ok2_button", 255, 0, 0 }, // demo { 258, DB_ENTRY_TYPE_IMAGE, "warcraft_text", 260, 0, 0 }, // demo { 261, DB_ENTRY_TYPE_IMAGE, "menu_background", 260, 0, 0 }, // demo { 362, DB_ENTRY_TYPE_IMAGE, "menu_button", 217, 0, 0 }, // demo { 363, DB_ENTRY_TYPE_IMAGE, "menu_button_pressed", 217, 0, 0 }, // demo { 364, DB_ENTRY_TYPE_IMAGE, "empty_button", 255, 0, 0 }, // demo { 365, DB_ENTRY_TYPE_IMAGE, "empty_button_pressed", 217, 0, 0 }, // demo { 406, DB_ENTRY_TYPE_IMAGE, "gold_1", 191, 217, 0 }, // demo { 407, DB_ENTRY_TYPE_IMAGE, "lumber_1", 217, 0, 0 }, // demo { 408, DB_ENTRY_TYPE_IMAGE, "gold_2", 191, 217, 0 }, // demo { 409, DB_ENTRY_TYPE_IMAGE, "lumber_2", 217, 0, 0 }, // demo { 410, DB_ENTRY_TYPE_IMAGE, "percent_complete", 191, 217, 0 }, // demo { 411, DB_ENTRY_TYPE_IMAGE, "points_summary_humans", 413, 0, 0 }, // demo { 412, DB_ENTRY_TYPE_IMAGE, "points_summary_orcs", 413, 0, 0 }, // demo { 415, DB_ENTRY_TYPE_IMAGE, "victory_background", 416, 0, 0 }, // demo { 417, DB_ENTRY_TYPE_IMAGE, "defeat_background", 418, 0, 0 }, // demo { 419, DB_ENTRY_TYPE_IMAGE, "victory_text", 423, 0, 0 }, // demo { 420, DB_ENTRY_TYPE_IMAGE, "defeat_text", 423, 0, 0 }, // demo { 421, DB_ENTRY_TYPE_IMAGE, "briefing_humans", 423, 0, 0 }, // demo { 422, DB_ENTRY_TYPE_IMAGE, "briefing_orcs", 424, 0, 0 }, // demo { 456, DB_ENTRY_TYPE_IMAGE, "win_humans", 457, 0, 0 }, { 458, DB_ENTRY_TYPE_IMAGE, "win_orcs", 459, 0, 0 }, { 470, DB_ENTRY_TYPE_IMAGE, "win_anim_humans", 457, 0, 0 }, { 471, DB_ENTRY_TYPE_IMAGE, "win_anim_orcs", 260, 0, 0 }, // Text { 432, DB_ENTRY_TYPE_TEXT, "01_intro_orcs", 0, 0, 0 }, // demo { 433, DB_ENTRY_TYPE_TEXT, "02_intro_orcs", 0, 0, 0 }, // demo { 434, DB_ENTRY_TYPE_TEXT, "03_intro_orcs", 0, 0, 0 }, // demo { 435, DB_ENTRY_TYPE_TEXT, "04_intro_orcs", 0, 0, 0 }, // demo { 436, DB_ENTRY_TYPE_TEXT, "05_intro_orcs", 0, 0, 0 }, { 437, DB_ENTRY_TYPE_TEXT, "06_intro_orcs", 0, 0, 0 }, { 438, DB_ENTRY_TYPE_TEXT, "07_intro_orcs", 0, 0, 0 }, { 439, DB_ENTRY_TYPE_TEXT, "08_intro_orcs", 0, 0, 0 }, { 440, DB_ENTRY_TYPE_TEXT, "09_intro_orcs", 0, 0, 0 }, { 441, DB_ENTRY_TYPE_TEXT, "10_intro_orcs", 0, 0, 0 }, { 442, DB_ENTRY_TYPE_TEXT, "11_intro_orcs", 0, 0, 0 }, { 443, DB_ENTRY_TYPE_TEXT, "12_intro_orcs", 0, 0, 0 }, { 444, DB_ENTRY_TYPE_TEXT, "01_intro_humans", 0, 0, 0 }, // demo { 445, DB_ENTRY_TYPE_TEXT, "02_intro_humans", 0, 0, 0 }, // demo { 446, DB_ENTRY_TYPE_TEXT, "03_intro_humans", 0, 0, 0 }, // demo { 447, DB_ENTRY_TYPE_TEXT, "04_intro_humans", 0, 0, 0 }, // demo { 448, DB_ENTRY_TYPE_TEXT, "05_intro_humans", 0, 0, 0 }, { 449, DB_ENTRY_TYPE_TEXT, "06_intro_humans", 0, 0, 0 }, { 450, DB_ENTRY_TYPE_TEXT, "07_intro_humans", 0, 0, 0 }, { 451, DB_ENTRY_TYPE_TEXT, "08_intro_humans", 0, 0, 0 }, { 452, DB_ENTRY_TYPE_TEXT, "09_intro_humans", 0, 0, 0 }, { 453, DB_ENTRY_TYPE_TEXT, "10_intro_humans", 0, 0, 0 }, { 454, DB_ENTRY_TYPE_TEXT, "11_intro_humans", 0, 0, 0 }, { 455, DB_ENTRY_TYPE_TEXT, "12_intro_humans", 0, 0, 0 }, { 461, DB_ENTRY_TYPE_TEXT, "ending_1_humans", 0, 0, 0 }, { 462, DB_ENTRY_TYPE_TEXT, "ending_1_orcs", 0, 0, 0 }, { 463, DB_ENTRY_TYPE_TEXT, "ending_2_humans", 0, 0, 0 }, { 464, DB_ENTRY_TYPE_TEXT, "ending_2_orcs", 0, 0, 0 }, { 465, DB_ENTRY_TYPE_TEXT, "credits", 0, 0, 0 }, { 466, DB_ENTRY_TYPE_TEXT, "victory_dialog_1", 0, 0, 0 }, // demo { 467, DB_ENTRY_TYPE_TEXT, "victory_dialog_2", 0, 0, 0 }, // demo { 468, DB_ENTRY_TYPE_TEXT, "defeat_dialog_1", 0, 0, 0 }, // demo { 469, DB_ENTRY_TYPE_TEXT, "defeat_dialog_2", 0, 0, 0 }, // demo // Sounds { 472, DB_ENTRY_TYPE_WAVE, "logo", 0, 0, 0 }, // demo { 473, DB_ENTRY_TYPE_WAVE, "intro_door", 0, 0, 0 }, { 474, DB_ENTRY_TYPE_VOC, "misc_building", 0, 0, 0 }, // demo { 475, DB_ENTRY_TYPE_VOC, "misc_explosion", 0, 0, 0 }, // demo { 476, DB_ENTRY_TYPE_VOC, "missiles_catapult_rock_fired", 0, 0, 0 }, { 477, DB_ENTRY_TYPE_VOC, "misc_tree_chopping_1", 0, 0, 0 }, // demo { 478, DB_ENTRY_TYPE_VOC, "misc_tree_chopping_2", 0, 0, 0 }, // demo { 479, DB_ENTRY_TYPE_VOC, "misc_tree_chopping_3", 0, 0, 0 }, // demo { 480, DB_ENTRY_TYPE_VOC, "misc_tree_chopping_4", 0, 0, 0 }, // demo { 481, DB_ENTRY_TYPE_VOC, "misc_building_collapse_1", 0, 0, 0 }, { 482, DB_ENTRY_TYPE_VOC, "misc_building_collapse_2", 0, 0, 0 }, { 483, DB_ENTRY_TYPE_VOC, "misc_building_collapse_3", 0, 0, 0 }, { 484, DB_ENTRY_TYPE_VOC, "ui_chime", 0, 0, 0 }, // demo { 485, DB_ENTRY_TYPE_WAVE, "ui_click", 0, 0, 0 }, // demo { 486, DB_ENTRY_TYPE_VOC, "ui_cancel", 0, 0, 0 }, // demo { 487, DB_ENTRY_TYPE_VOC, "missiles_sword_attack_1", 0, 0, 0 }, // demo { 488, DB_ENTRY_TYPE_VOC, "missiles_sword_attack_2", 0, 0, 0 }, // demo { 489, DB_ENTRY_TYPE_VOC, "missiles_sword_attack_3", 0, 0, 0 }, // demo { 490, DB_ENTRY_TYPE_VOC, "missiles_fist_attack", 0, 0, 0 }, { 491, DB_ENTRY_TYPE_VOC, "missiles_catapult_fire_explosion", 0, 0, 0 }, // demo { 492, DB_ENTRY_TYPE_VOC, "missiles_fireball", 0, 0, 0 }, // demo { 493, DB_ENTRY_TYPE_VOC, "missiles_arrow_spear", 0, 0, 0 }, // demo { 494, DB_ENTRY_TYPE_VOC, "missiles_arrow_spear_hit", 0, 0, 0 }, // demo { 495, DB_ENTRY_TYPE_VOC, "orc_help_1", 0, 0, 0 }, // demo { 496, DB_ENTRY_TYPE_VOC, "orc_help_2", 0, 0, 0 }, { 497, DB_ENTRY_TYPE_WAVE, "human_help_2", 0, 0, 0 }, // demo { 498, DB_ENTRY_TYPE_WAVE, "human_help_1", 0, 0, 0 }, { 499, DB_ENTRY_TYPE_VOC, "orc_dead", 0, 0, 0 }, // demo { 500, DB_ENTRY_TYPE_VOC, "human_dead", 0, 0, 0 }, // demo { 501, DB_ENTRY_TYPE_VOC, "orc_work_complete", 0, 0, 0 }, // demo { 502, DB_ENTRY_TYPE_WAVE, "human_work_complete", 0, 0, 0 }, // demo { 503, DB_ENTRY_TYPE_VOC, "orc_help_3", 0, 0, 0 }, // demo { 504, DB_ENTRY_TYPE_WAVE, "orc_help_4", 0, 0, 0 }, { 505, DB_ENTRY_TYPE_WAVE, "human_help_3", 0, 0, 0 }, // demo { 506, DB_ENTRY_TYPE_WAVE, "human_help_4", 0, 0, 0 }, // demo { 507, DB_ENTRY_TYPE_VOC, "orc_ready", 0, 0, 0 }, // demo { 508, DB_ENTRY_TYPE_WAVE, "human_ready", 0, 0, 0 }, // demo { 509, DB_ENTRY_TYPE_VOC, "orc_acknowledgement_1", 0, 0, 0 }, // demo { 510, DB_ENTRY_TYPE_VOC, "orc_acknowledgement_2", 0, 0, 0 }, // demo { 511, DB_ENTRY_TYPE_VOC, "orc_acknowledgement_3", 0, 0, 0 }, // demo { 512, DB_ENTRY_TYPE_VOC, "orc_acknowledgement_4", 0, 0, 0 }, // demo { 513, DB_ENTRY_TYPE_WAVE, "human_acknowledgement_1", 0, 0, 0 }, // demo { 514, DB_ENTRY_TYPE_WAVE, "human_acknowledgement_2", 0, 0, 0 }, // demo { 515, DB_ENTRY_TYPE_VOC, "orc_selected_1", 0, 0, 0 }, // demo { 516, DB_ENTRY_TYPE_VOC, "orc_selected_2", 0, 0, 0 }, // demo { 517, DB_ENTRY_TYPE_VOC, "orc_selected_3", 0, 0, 0 }, // demo { 518, DB_ENTRY_TYPE_VOC, "orc_selected_4", 0, 0, 0 }, // demo { 519, DB_ENTRY_TYPE_VOC, "orc_selected_5", 0, 0, 0 }, // demo { 520, DB_ENTRY_TYPE_WAVE, "human_selected_1", 0, 0, 0 }, // demo { 521, DB_ENTRY_TYPE_WAVE, "human_selected_2", 0, 0, 0 }, // demo { 522, DB_ENTRY_TYPE_WAVE, "human_selected_3", 0, 0, 0 }, // demo { 523, DB_ENTRY_TYPE_WAVE, "human_selected_4", 0, 0, 0 }, // demo { 524, DB_ENTRY_TYPE_WAVE, "human_selected_5", 0, 0, 0 }, // demo { 525, DB_ENTRY_TYPE_VOC, "orc_annoyed_1", 0, 0, 0 }, // demo { 526, DB_ENTRY_TYPE_VOC, "orc_annoyed_2", 0, 0, 0 }, // demo { 527, DB_ENTRY_TYPE_WAVE, "orc_annoyed_3", 0, 0, 0 }, { 528, DB_ENTRY_TYPE_WAVE, "human_annoyed_1", 0, 0, 0 }, // demo { 529, DB_ENTRY_TYPE_WAVE, "human_annoyed_2", 0, 0, 0 }, // demo { 530, DB_ENTRY_TYPE_WAVE, "human_annoyed_3", 0, 0, 0 }, { 531, DB_ENTRY_TYPE_WAVE, "dead_spider_scorpion", 0, 0, 0 }, { 532, DB_ENTRY_TYPE_WAVE, "normal_spell", 0, 0, 0 }, // demo { 533, DB_ENTRY_TYPE_WAVE, "misc_build_road", 0, 0, 0 }, // demo { 534, DB_ENTRY_TYPE_WAVE, "orc_temple", 0, 0, 0 }, { 535, DB_ENTRY_TYPE_WAVE, "human_church", 0, 0, 0 }, { 536, DB_ENTRY_TYPE_WAVE, "orc_kennel", 0, 0, 0 }, { 537, DB_ENTRY_TYPE_WAVE, "human_stable", 0, 0, 0 }, { 538, DB_ENTRY_TYPE_WAVE, "blacksmith", 0, 0, 0 }, { 539, DB_ENTRY_TYPE_WAVE, "misc_fire_crackling", 0, 0, 0 }, { 540, DB_ENTRY_TYPE_WAVE, "cannon", 0, 0, 0 }, { 541, DB_ENTRY_TYPE_WAVE, "cannon2", 0, 0, 0 }, { 542, DB_ENTRY_TYPE_WAVE, "campaigns_human_ending_1", 0, 0, 0 }, { 543, DB_ENTRY_TYPE_WAVE, "campaigns_human_ending_2", 0, 0, 0 }, { 544, DB_ENTRY_TYPE_WAVE, "campaigns_orc_ending_1", 0, 0, 0 }, { 545, DB_ENTRY_TYPE_WAVE, "campaigns_orc_ending_2", 0, 0, 0 }, { 546, DB_ENTRY_TYPE_WAVE, "intro_1", 0, 0, 0 }, { 547, DB_ENTRY_TYPE_WAVE, "intro_2", 0, 0, 0 }, { 548, DB_ENTRY_TYPE_WAVE, "intro_3", 0, 0, 0 }, { 549, DB_ENTRY_TYPE_WAVE, "intro_4", 0, 0, 0 }, { 550, DB_ENTRY_TYPE_WAVE, "intro_5", 0, 0, 0 }, { 551, DB_ENTRY_TYPE_WAVE, "campaigns_human_01_intro", 0, 0, 0 }, { 552, DB_ENTRY_TYPE_WAVE, "campaigns_human_02_intro", 0, 0, 0 }, { 553, DB_ENTRY_TYPE_WAVE, "campaigns_human_03_intro", 0, 0, 0 }, { 554, DB_ENTRY_TYPE_WAVE, "campaigns_human_04_intro", 0, 0, 0 }, { 555, DB_ENTRY_TYPE_WAVE, "campaigns_human_05_intro", 0, 0, 0 }, { 556, DB_ENTRY_TYPE_WAVE, "campaigns_human_06_intro", 0, 0, 0 }, { 557, DB_ENTRY_TYPE_WAVE, "campaigns_human_07_intro", 0, 0, 0 }, { 558, DB_ENTRY_TYPE_WAVE, "campaigns_human_08_intro", 0, 0, 0 }, { 559, DB_ENTRY_TYPE_WAVE, "campaigns_human_09_intro", 0, 0, 0 }, { 560, DB_ENTRY_TYPE_WAVE, "campaigns_human_10_intro", 0, 0, 0 }, { 561, DB_ENTRY_TYPE_WAVE, "campaigns_human_11_intro", 0, 0, 0 }, { 562, DB_ENTRY_TYPE_WAVE, "campaigns_human_12_intro", 0, 0, 0 }, { 563, DB_ENTRY_TYPE_WAVE, "campaigns_orc_01_intro", 0, 0, 0 }, { 564, DB_ENTRY_TYPE_WAVE, "campaigns_orc_02_intro", 0, 0, 0 }, { 565, DB_ENTRY_TYPE_WAVE, "campaigns_orc_03_intro", 0, 0, 0 }, { 566, DB_ENTRY_TYPE_WAVE, "campaigns_orc_04_intro", 0, 0, 0 }, { 567, DB_ENTRY_TYPE_WAVE, "campaigns_orc_05_intro", 0, 0, 0 }, { 568, DB_ENTRY_TYPE_WAVE, "campaigns_orc_06_intro", 0, 0, 0 }, { 569, DB_ENTRY_TYPE_WAVE, "campaigns_orc_07_intro", 0, 0, 0 }, { 570, DB_ENTRY_TYPE_WAVE, "campaigns_orc_08_intro", 0, 0, 0 }, { 571, DB_ENTRY_TYPE_WAVE, "campaigns_orc_09_intro", 0, 0, 0 }, { 572, DB_ENTRY_TYPE_WAVE, "campaigns_orc_10_intro", 0, 0, 0 }, { 573, DB_ENTRY_TYPE_WAVE, "campaigns_orc_11_intro", 0, 0, 0 }, { 574, DB_ENTRY_TYPE_WAVE, "campaigns_orc_12_intro", 0, 0, 0 }, { 575, DB_ENTRY_TYPE_WAVE, "human_defeat", 0, 0, 0 }, { 576, DB_ENTRY_TYPE_WAVE, "orc_defeat", 0, 0, 0 }, { 577, DB_ENTRY_TYPE_WAVE, "orc_victory_1", 0, 0, 0 }, { 578, DB_ENTRY_TYPE_WAVE, "orc_victory_2", 0, 0, 0 }, { 579, DB_ENTRY_TYPE_WAVE, "orc_victory_3", 0, 0, 0 }, { 580, DB_ENTRY_TYPE_WAVE, "human_victory_1", 0, 0, 0 }, { 581, DB_ENTRY_TYPE_WAVE, "human_victory_2", 0, 0, 0 }, { 582, DB_ENTRY_TYPE_WAVE, "human_victory_3", 0, 0, 0 }, // NOTE: these are resources included in the demo version // not sure what are they, a little investigation is required // { 198, DB_ENTRY_TYPE_UNKNOWN, "", 0, 0, 0 }, { 199, DB_ENTRY_TYPE_UNKNOWN, "", 0, 0, 0 }, { 200, DB_ENTRY_TYPE_UNKNOWN, "", 0, 0, 0 }, { 201, DB_ENTRY_TYPE_UNKNOWN, "", 0, 0, 0 }, { 202, DB_ENTRY_TYPE_UNKNOWN, "", 0, 0, 0 }, { 203, DB_ENTRY_TYPE_UNKNOWN, "", 0, 0, 0 }, { 204, DB_ENTRY_TYPE_UNKNOWN, "", 0, 0, 0 }, { 205, DB_ENTRY_TYPE_UNKNOWN, "", 0, 0, 0 }, { 206, DB_ENTRY_TYPE_UNKNOWN, "", 0, 0, 0 }, { 207, DB_ENTRY_TYPE_UNKNOWN, "", 0, 0, 0 }, { 208, DB_ENTRY_TYPE_UNKNOWN, "", 0, 0, 0 }, { 209, DB_ENTRY_TYPE_UNKNOWN, "", 0, 0, 0 }, { 210, DB_ENTRY_TYPE_UNKNOWN, "", 0, 0, 0 }, { 211, DB_ENTRY_TYPE_UNKNOWN, "", 0, 0, 0 }, { 212, DB_ENTRY_TYPE_UNKNOWN, "", 0, 0, 0 }, { 213, DB_ENTRY_TYPE_UNKNOWN, "", 0, 0, 0 }, { 214, DB_ENTRY_TYPE_UNKNOWN, "", 0, 0, 0 }, { 215, DB_ENTRY_TYPE_UNKNOWN, "", 0, 0, 0 }, { 230, DB_ENTRY_TYPE_UNKNOWN, "", 0, 0, 0 }, { 251, DB_ENTRY_TYPE_UNKNOWN, "", 0, 0, 0 }, { 252, DB_ENTRY_TYPE_UNKNOWN, "", 0, 0, 0 }, { 253, DB_ENTRY_TYPE_UNKNOWN, "", 0, 0, 0 }, { 259, DB_ENTRY_TYPE_UNKNOWN, "", 0, 0, 0 }, { 366, DB_ENTRY_TYPE_UNKNOWN, "", 0, 0, 0 }, { 367, DB_ENTRY_TYPE_UNKNOWN, "", 0, 0, 0 }, { 368, DB_ENTRY_TYPE_UNKNOWN, "", 0, 0, 0 }, { 369, DB_ENTRY_TYPE_UNKNOWN, "", 0, 0, 0 }, { 370, DB_ENTRY_TYPE_UNKNOWN, "", 0, 0, 0 }, { 371, DB_ENTRY_TYPE_UNKNOWN, "", 0, 0, 0 }, { 372, DB_ENTRY_TYPE_UNKNOWN, "", 0, 0, 0 }, { 373, DB_ENTRY_TYPE_UNKNOWN, "", 0, 0, 0 }, { 374, DB_ENTRY_TYPE_UNKNOWN, "", 0, 0, 0 }, { 375, DB_ENTRY_TYPE_UNKNOWN, "", 0, 0, 0 }, { 376, DB_ENTRY_TYPE_UNKNOWN, "", 0, 0, 0 }, { 377, DB_ENTRY_TYPE_UNKNOWN, "", 0, 0, 0 }, { 378, DB_ENTRY_TYPE_UNKNOWN, "", 0, 0, 0 }, { 379, DB_ENTRY_TYPE_UNKNOWN, "", 0, 0, 0 }, { 380, DB_ENTRY_TYPE_UNKNOWN, "", 0, 0, 0 }, { 381, DB_ENTRY_TYPE_UNKNOWN, "", 0, 0, 0 }, { 382, DB_ENTRY_TYPE_UNKNOWN, "", 0, 0, 0 }, { 383, DB_ENTRY_TYPE_UNKNOWN, "", 0, 0, 0 }, { 384, DB_ENTRY_TYPE_UNKNOWN, "", 0, 0, 0 }, { 385, DB_ENTRY_TYPE_UNKNOWN, "", 0, 0, 0 }, { 386, DB_ENTRY_TYPE_UNKNOWN, "", 0, 0, 0 }, { 387, DB_ENTRY_TYPE_UNKNOWN, "", 0, 0, 0 }, { 388, DB_ENTRY_TYPE_UNKNOWN, "", 0, 0, 0 }, { 389, DB_ENTRY_TYPE_UNKNOWN, "", 0, 0, 0 }, { 390, DB_ENTRY_TYPE_UNKNOWN, "", 0, 0, 0 }, { 391, DB_ENTRY_TYPE_UNKNOWN, "", 0, 0, 0 }, { 392, DB_ENTRY_TYPE_UNKNOWN, "", 0, 0, 0 }, { 393, DB_ENTRY_TYPE_UNKNOWN, "", 0, 0, 0 }, { 394, DB_ENTRY_TYPE_UNKNOWN, "", 0, 0, 0 }, { 395, DB_ENTRY_TYPE_UNKNOWN, "", 0, 0, 0 }, { 396, DB_ENTRY_TYPE_UNKNOWN, "", 0, 0, 0 }, { 397, DB_ENTRY_TYPE_UNKNOWN, "", 0, 0, 0 }, { 398, DB_ENTRY_TYPE_UNKNOWN, "", 0, 0, 0 }, { 399, DB_ENTRY_TYPE_UNKNOWN, "", 0, 0, 0 }, { 400, DB_ENTRY_TYPE_UNKNOWN, "", 0, 0, 0 }, { 401, DB_ENTRY_TYPE_UNKNOWN, "", 0, 0, 0 }, { 402, DB_ENTRY_TYPE_UNKNOWN, "", 0, 0, 0 }, { 403, DB_ENTRY_TYPE_UNKNOWN, "", 0, 0, 0 }, { 404, DB_ENTRY_TYPE_UNKNOWN, "", 0, 0, 0 }, { 405, DB_ENTRY_TYPE_UNKNOWN, "", 0, 0, 0 }, { 414, DB_ENTRY_TYPE_UNKNOWN, "", 0, 0, 0 }, }; ================================================ FILE: src/war_entities.c ================================================ #include #include #include "shl/wstr.h" #include "war_entities.h" #include "war_animations.h" #include "war_audio.h" #include "war_font.h" #include "war_map.h" #include "war_map_ui.h" #include "war_render.h" #include "war_sprites.h" #include "war_units.h" shlDefineList(WarRoadPieceList, WarRoadPiece) shlDefineList(WarWallPieceList, WarWallPiece) shlDefineList(WarRuinPieceList, WarRuinPiece) shlDefineList(WarTreeList, WarTree) shlDefineList(WarEntityIdList, WarEntityId) shlDefineSet(WarEntityIdSet, WarEntityId) shlDefineList(WarEntityList, WarEntity*) shlDefineMap(WarEntityMap, WarEntityType, WarEntityList*) shlDefineMap(WarUnitMap, WarUnitType, WarEntityList*) shlDefineMap(WarEntityIdMap, WarEntityId, WarEntity*) bool we_equalsRoadPiece(const WarRoadPiece r1, const WarRoadPiece r2) { return r1.type == r2.type && r1.player == r2.player && r1.tilex == r2.tilex && r1.tiley == r2.tiley; } bool we_equalsWallPiece(const WarWallPiece w1, const WarWallPiece w2) { return w1.type == w2.type && w1.player == w2.player && w1.tilex == w2.tilex && w1.tiley == w2.tiley; } bool we_equalsRuinPiece(const WarRuinPiece r1, const WarRuinPiece r2) { return r1.type == r2.type && r1.tilex == r2.tilex && r1.tiley == r2.tiley; } bool we_equalsTree(const WarTree t1, const WarTree t2) { return t1.tilex == t2.tilex && t1.tiley == t2.tiley; } bool we_equalsEntityId(const WarEntityId id1, const WarEntityId id2) { return id1 == id2; } u32 we_hashEntityId(const WarEntityId id) { return id; } bool we_equalsEntity(const WarEntity* e1, const WarEntity* e2) { return e1->id == e2->id; } void we_freeEntity(WarEntity* e) { // Entities are now stored in the flat pool inside WarEntityManager. // Memory is NOT individually heap-allocated; this is intentionally a no-op. NOT_USED(e); } u32 we_hashEntityType(const WarEntityType type) { return type; } bool we_equalsEntityType(const WarEntityType t1, const WarEntityType t2) { return t1 == t2; } void we_freeEntityList(WarEntityList* list) { WarEntityListFree(list); } bool we_isComponentEnabled(WarContext* context, WarEntity* entity, WarComponentType componentType) { assert(context); assert(entity); assert(componentType >= 0 && componentType < COMP_COUNT); u16 idx = entity->components[(s32)componentType]; if (idx == INVALID_COMP_INDEX) { // Component not present; return false; } WarEntityManager* manager = we_getEntityManager(context); assert(manager); switch (componentType) { case COMP_TRANSFORM: return manager->transforms.enabled[idx]; case COMP_SPRITE: return manager->sprites.enabled[idx]; case COMP_UNIT: return manager->units.enabled[idx]; case COMP_ANIMATIONS: return manager->animations.enabled[idx]; case COMP_ROAD: return manager->roads.enabled[idx]; case COMP_WALL: return manager->walls.enabled[idx]; case COMP_RUIN: return manager->ruins.enabled[idx]; case COMP_FOREST: return manager->forests.enabled[idx]; case COMP_STATE_MACHINE: return manager->stateMachines.enabled[idx]; case COMP_UI: return manager->uis.enabled[idx]; case COMP_TEXT: return manager->texts.enabled[idx]; case COMP_RECT: return manager->rects.enabled[idx]; case COMP_BUTTON: return manager->buttons.enabled[idx]; case COMP_AUDIO: return manager->audios.enabled[idx]; case COMP_CURSOR: return manager->cursors.enabled[idx]; case COMP_PROJECTILE: return manager->projectiles.enabled[idx]; case COMP_POISON_CLOUD: return manager->poisonClouds.enabled[idx]; case COMP_SIGHT: return manager->sights.enabled[idx]; default: assert(false && "Invalid component type"); return false; break; } } void we_setComponentEnabled(WarContext* context, WarEntity* entity, WarComponentType componentType, bool enabled) { assert(context); assert(entity); assert(componentType >= 0 && componentType < COMP_COUNT); u16 idx = entity->components[(s32)componentType]; if (idx == INVALID_COMP_INDEX) { // Component not present; nothing to enable/disable return; } WarEntityManager* manager = we_getEntityManager(context); assert(manager); switch (componentType) { case COMP_TRANSFORM: manager->transforms.enabled[idx] = enabled; break; case COMP_SPRITE: manager->sprites.enabled[idx] = enabled; break; case COMP_UNIT: manager->units.enabled[idx] = enabled; break; case COMP_ANIMATIONS: manager->animations.enabled[idx] = enabled; break; case COMP_ROAD: manager->roads.enabled[idx] = enabled; break; case COMP_WALL: manager->walls.enabled[idx] = enabled; break; case COMP_RUIN: manager->ruins.enabled[idx] = enabled; break; case COMP_FOREST: manager->forests.enabled[idx] = enabled; break; case COMP_STATE_MACHINE: manager->stateMachines.enabled[idx] = enabled; break; case COMP_UI: manager->uis.enabled[idx] = enabled; break; case COMP_TEXT: manager->texts.enabled[idx] = enabled; break; case COMP_RECT: manager->rects.enabled[idx] = enabled; break; case COMP_BUTTON: manager->buttons.enabled[idx] = enabled; break; case COMP_AUDIO: manager->audios.enabled[idx] = enabled; break; case COMP_CURSOR: manager->cursors.enabled[idx] = enabled; break; case COMP_PROJECTILE: manager->projectiles.enabled[idx] = enabled; break; case COMP_POISON_CLOUD: manager->poisonClouds.enabled[idx] = enabled; break; case COMP_SIGHT: manager->sights.enabled[idx] = enabled; break; default: assert(false && "Invalid component type"); break; } } void we_enableComponent(WarContext* context, WarEntity* entity, WarComponentType componentType) { we_setComponentEnabled(context, entity, componentType, true); } void we_disableComponent(WarContext* context, WarEntity* entity, WarComponentType componentType) { we_setComponentEnabled(context, entity, componentType, false); } WarTransformComponent* we_getTransformComponent(WarContext* context, const WarEntity* entity) { if (!entity) return NULL; u16 idx = entity->components[COMP_TRANSFORM]; if (idx == INVALID_COMP_INDEX) return NULL; WarEntityManager* manager = we_getEntityManager(context); return &manager->transforms.dense[idx]; } WarSpriteComponent* we_getSpriteComponent(WarContext* context, const WarEntity* entity) { if (!entity) return NULL; u16 idx = entity->components[COMP_SPRITE]; if (idx == INVALID_COMP_INDEX) return NULL; WarEntityManager* manager = we_getEntityManager(context); return &manager->sprites.dense[idx]; } WarUnitComponent* we_getUnitComponent(WarContext* context, const WarEntity* entity) { if (!entity) return NULL; u16 idx = entity->components[COMP_UNIT]; if (idx == INVALID_COMP_INDEX) return NULL; WarEntityManager* manager = we_getEntityManager(context); return &manager->units.dense[idx]; } WarAnimationsComponent* we_getAnimationsComponent(WarContext* context, const WarEntity* entity) { if (!entity) return NULL; u16 idx = entity->components[COMP_ANIMATIONS]; if (idx == INVALID_COMP_INDEX) return NULL; WarEntityManager* manager = we_getEntityManager(context); return &manager->animations.dense[idx]; } WarRoadComponent* we_getRoadComponent(WarContext* context, const WarEntity* entity) { if (!entity) return NULL; u16 idx = entity->components[COMP_ROAD]; if (idx == INVALID_COMP_INDEX) return NULL; WarEntityManager* manager = we_getEntityManager(context); return &manager->roads.dense[idx]; } WarWallComponent* we_getWallComponent(WarContext* context, const WarEntity* entity) { if (!entity) return NULL; u16 idx = entity->components[COMP_WALL]; if (idx == INVALID_COMP_INDEX) return NULL; WarEntityManager* manager = we_getEntityManager(context); return &manager->walls.dense[idx]; } WarRuinComponent* we_getRuinComponent(WarContext* context, const WarEntity* entity) { if (!entity) return NULL; u16 idx = entity->components[COMP_RUIN]; if (idx == INVALID_COMP_INDEX) return NULL; WarEntityManager* manager = we_getEntityManager(context); return &manager->ruins.dense[idx]; } WarForestComponent* we_getForestComponent(WarContext* context, const WarEntity* entity) { if (!entity) return NULL; u16 idx = entity->components[COMP_FOREST]; if (idx == INVALID_COMP_INDEX) return NULL; WarEntityManager* manager = we_getEntityManager(context); return &manager->forests.dense[idx]; } WarStateMachineComponent* we_getStateMachineComponent(WarContext* context, const WarEntity* entity) { if (!entity) return NULL; u16 idx = entity->components[COMP_STATE_MACHINE]; if (idx == INVALID_COMP_INDEX) return NULL; WarEntityManager* manager = we_getEntityManager(context); return &manager->stateMachines.dense[idx]; } WarUIComponent* we_getUIComponent(WarContext* context, const WarEntity* entity) { if (!entity) return NULL; u16 idx = entity->components[COMP_UI]; if (idx == INVALID_COMP_INDEX) return NULL; WarEntityManager* manager = we_getEntityManager(context); return &manager->uis.dense[idx]; } WarTextComponent* we_getTextComponent(WarContext* context, const WarEntity* entity) { if (!entity) return NULL; u16 idx = entity->components[COMP_TEXT]; if (idx == INVALID_COMP_INDEX) return NULL; WarEntityManager* manager = we_getEntityManager(context); return &manager->texts.dense[idx]; } WarRectComponent* we_getRectComponent(WarContext* context, const WarEntity* entity) { if (!entity) return NULL; u16 idx = entity->components[COMP_RECT]; if (idx == INVALID_COMP_INDEX) return NULL; WarEntityManager* manager = we_getEntityManager(context); return &manager->rects.dense[idx]; } WarButtonComponent* we_getButtonComponent(WarContext* context, const WarEntity* entity) { if (!entity) return NULL; u16 idx = entity->components[COMP_BUTTON]; if (idx == INVALID_COMP_INDEX) return NULL; WarEntityManager* manager = we_getEntityManager(context); return &manager->buttons.dense[idx]; } WarAudioComponent* we_getAudioComponent(WarContext* context, const WarEntity* entity) { if (!entity) return NULL; u16 idx = entity->components[COMP_AUDIO]; if (idx == INVALID_COMP_INDEX) return NULL; WarEntityManager* manager = we_getEntityManager(context); return &manager->audios.dense[idx]; } WarCursorComponent* we_getCursorComponent(WarContext* context, const WarEntity* entity) { if (!entity) return NULL; u16 idx = entity->components[COMP_CURSOR]; if (idx == INVALID_COMP_INDEX) return NULL; WarEntityManager* manager = we_getEntityManager(context); return &manager->cursors.dense[idx]; } WarProjectileComponent* we_getProjectileComponent(WarContext* context, const WarEntity* entity) { if (!entity) return NULL; u16 idx = entity->components[COMP_PROJECTILE]; if (idx == INVALID_COMP_INDEX) return NULL; WarEntityManager* manager = we_getEntityManager(context); return &manager->projectiles.dense[idx]; } WarPoisonCloudComponent* we_getPoisonCloudComponent(WarContext* context, const WarEntity* entity) { if (!entity) return NULL; u16 idx = entity->components[COMP_POISON_CLOUD]; if (idx == INVALID_COMP_INDEX) return NULL; WarEntityManager* manager = we_getEntityManager(context); return &manager->poisonClouds.dense[idx]; } WarSightComponent* we_getSightComponent(WarContext* context, const WarEntity* entity) { if (!entity) return NULL; u16 idx = entity->components[COMP_SIGHT]; if (idx == INVALID_COMP_INDEX) return NULL; WarEntityManager* manager = we_getEntityManager(context); return &manager->sights.dense[idx]; } WarTransformComponent* we_addTransformComponent(WarContext* context, WarEntity* entity, WarTransformComponent params) { TracyCZoneN(ctx, "we_addTransformComponent", 1); if (!entity) { TracyCZoneEnd(ctx); return NULL; } WarEntityManager* manager = we_getEntityManager(context); assert(manager); WarTransformStorage* store = &manager->transforms; assert(store->count < MAX_ENTITIES_COUNT); u16 idx = (u16)store->count; store->dense[idx] = params; store->enabled[idx] = true; store->owners[idx] = entity->id; store->count++; entity->components[COMP_TRANSFORM] = idx; TracyCZoneEnd(ctx); return &store->dense[idx]; } void we_removeTransformComponent(WarContext* context, WarEntity* entity) { if (!entity) return; u16 idx = entity->components[COMP_TRANSFORM]; if (idx == INVALID_COMP_INDEX) return; WarEntityManager* manager = we_getEntityManager(context); assert(manager); WarTransformStorage* store = &manager->transforms; u16 lastIdx = (u16)(store->count - 1); if (idx != lastIdx) { store->dense[idx] = store->dense[lastIdx]; store->enabled[idx] = store->enabled[lastIdx]; store->owners[idx] = store->owners[lastIdx]; WarEntity* movedEntity = we_findEntity(context, store->owners[idx]); assert(movedEntity != NULL); movedEntity->components[COMP_TRANSFORM] = idx; } store->enabled[lastIdx] = false; store->owners[lastIdx] = 0; store->count--; entity->components[COMP_TRANSFORM] = INVALID_COMP_INDEX; } WarSpriteComponent* we_addSpriteComponent(WarContext* context, WarEntity* entity, WarSpriteComponent params) { TracyCZoneN(ctx, "we_addSpriteComponent", 1); if (!entity) { TracyCZoneEnd(ctx); return NULL; } WarEntityManager* manager = we_getEntityManager(context); assert(manager); WarSpriteStorage* store = &manager->sprites; assert(store->count < MAX_ENTITIES_COUNT); u16 idx = (u16)store->count; store->dense[idx] = params; store->enabled[idx] = true; store->owners[idx] = entity->id; store->count++; entity->components[COMP_SPRITE] = idx; TracyCZoneEnd(ctx); return &store->dense[idx]; } WarSpriteComponent* we_addSpriteComponentFromResource(WarContext* context, WarEntity* entity, WarSpriteResourceRef spriteResourceRef) { TracyCZoneN(ctx, "we_addSpriteComponentFromResource", 1); if (!entity) { TracyCZoneEnd(ctx); return NULL; } if (spriteResourceRef.resourceIndex < 0) { logWarning("Trying to create a sprite component with invalid resource index: %d", spriteResourceRef.resourceIndex); TracyCZoneEnd(ctx); return NULL; } WarSprite sprite = wspr_createSpriteFromResourceIndex(context, spriteResourceRef); WarSpriteComponent* comp = we_addSpriteComponent(context, entity, WAR_SPRITE_COMPONENT_INIT( .resourceIndex = spriteResourceRef.resourceIndex, .sprite = sprite )); TracyCZoneEnd(ctx); return comp; } void we_removeSpriteComponent(WarContext* context, WarEntity* entity) { if (!entity) return; u16 idx = entity->components[COMP_SPRITE]; if (idx == INVALID_COMP_INDEX) return; WarEntityManager* manager = we_getEntityManager(context); assert(manager); WarSpriteStorage* store = &manager->sprites; wspr_freeSprite(context, store->dense[idx].sprite); u16 lastIdx = (u16)(store->count - 1); if (idx != lastIdx) { store->dense[idx] = store->dense[lastIdx]; store->enabled[idx] = store->enabled[lastIdx]; store->owners[idx] = store->owners[lastIdx]; WarEntity* movedEntity = we_findEntity(context, store->owners[idx]); assert(movedEntity != NULL); movedEntity->components[COMP_SPRITE] = idx; } store->enabled[lastIdx] = false; store->owners[lastIdx] = 0; store->count--; entity->components[COMP_SPRITE] = INVALID_COMP_INDEX; } WarUnitComponent* we_addUnitComponent(WarContext* context, WarEntity* entity, WarUnitComponent params) { TracyCZoneN(ctx, "we_addUnitComponent", 1); if (!entity) { TracyCZoneEnd(ctx); return NULL; } WarEntityManager* manager = we_getEntityManager(context); assert(manager); WarUnitStorage* store = &manager->units; assert(store->count < MAX_ENTITIES_COUNT); u16 idx = (u16)store->count; store->dense[idx] = params; store->enabled[idx] = true; store->owners[idx] = entity->id; store->count++; entity->components[COMP_UNIT] = idx; TracyCZoneEnd(ctx); return &store->dense[idx]; } void we_removeUnitComponent(WarContext* context, WarEntity* entity) { if (!entity) return; u16 idx = entity->components[COMP_UNIT]; if (idx == INVALID_COMP_INDEX) return; WarEntityManager* manager = we_getEntityManager(context); assert(manager); WarUnitStorage* store = &manager->units; u16 lastIdx = (u16)(store->count - 1); if (idx != lastIdx) { store->dense[idx] = store->dense[lastIdx]; store->enabled[idx] = store->enabled[lastIdx]; store->owners[idx] = store->owners[lastIdx]; WarEntity* movedEntity = we_findEntity(context, store->owners[idx]); assert(movedEntity != NULL); movedEntity->components[COMP_UNIT] = idx; } store->enabled[lastIdx] = false; store->owners[lastIdx] = 0; store->count--; entity->components[COMP_UNIT] = INVALID_COMP_INDEX; } WarRoadComponent* we_addRoadComponent(WarContext* context, WarEntity* entity, WarRoadPieceList pieces) { TracyCZoneN(ctx, "we_addRoadComponent", 1); if (!entity) { TracyCZoneEnd(ctx); return NULL; } WarEntityManager* manager = we_getEntityManager(context); assert(manager); WarRoadStorage* store = &manager->roads; assert(store->count < MAX_ENTITIES_COUNT); u16 idx = (u16)store->count; WarRoadComponent* comp = &store->dense[idx]; *comp = (WarRoadComponent){0}; comp->pieces = pieces; store->enabled[idx] = true; store->owners[idx] = entity->id; store->count++; entity->components[COMP_ROAD] = idx; TracyCZoneEnd(ctx); return &store->dense[idx]; } void we_removeRoadComponent(WarContext* context, WarEntity* entity) { if (!entity) return; u16 idx = entity->components[COMP_ROAD]; if (idx == INVALID_COMP_INDEX) return; WarEntityManager* manager = we_getEntityManager(context); assert(manager); WarRoadStorage* store = &manager->roads; WarRoadPieceListFree(&store->dense[idx].pieces); u16 lastIdx = (u16)(store->count - 1); if (idx != lastIdx) { store->dense[idx] = store->dense[lastIdx]; store->enabled[idx] = store->enabled[lastIdx]; store->owners[idx] = store->owners[lastIdx]; WarEntity* movedEntity = we_findEntity(context, store->owners[idx]); assert(movedEntity != NULL); movedEntity->components[COMP_ROAD] = idx; } store->enabled[lastIdx] = false; store->owners[lastIdx] = 0; store->count--; entity->components[COMP_ROAD] = INVALID_COMP_INDEX; } WarWallComponent* we_addWallComponent(WarContext* context, WarEntity* entity, WarWallPieceList pieces) { TracyCZoneN(ctx, "we_addWallComponent", 1); if (!entity) { TracyCZoneEnd(ctx); return NULL; } WarEntityManager* manager = we_getEntityManager(context); assert(manager); WarWallStorage* store = &manager->walls; assert(store->count < MAX_ENTITIES_COUNT); u16 idx = (u16)store->count; WarWallComponent* comp = &store->dense[idx]; *comp = (WarWallComponent){0}; comp->pieces = pieces; store->enabled[idx] = true; store->owners[idx] = entity->id; store->count++; entity->components[COMP_WALL] = idx; TracyCZoneEnd(ctx); return &store->dense[idx]; } void we_removeWallComponent(WarContext* context, WarEntity* entity) { if (!entity) return; u16 idx = entity->components[COMP_WALL]; if (idx == INVALID_COMP_INDEX) return; WarEntityManager* manager = we_getEntityManager(context); assert(manager); WarWallStorage* store = &manager->walls; WarWallPieceListFree(&store->dense[idx].pieces); u16 lastIdx = (u16)(store->count - 1); if (idx != lastIdx) { store->dense[idx] = store->dense[lastIdx]; store->enabled[idx] = store->enabled[lastIdx]; store->owners[idx] = store->owners[lastIdx]; WarEntity* movedEntity = we_findEntity(context, store->owners[idx]); assert(movedEntity != NULL); movedEntity->components[COMP_WALL] = idx; } store->enabled[lastIdx] = false; store->owners[lastIdx] = 0; store->count--; entity->components[COMP_WALL] = INVALID_COMP_INDEX; } WarRuinComponent* we_addRuinComponent(WarContext* context, WarEntity* entity, WarRuinPieceList pieces) { TracyCZoneN(ctx, "we_addRuinComponent", 1); if (!entity) { TracyCZoneEnd(ctx); return NULL; } WarEntityManager* manager = we_getEntityManager(context); assert(manager); WarRuinStorage* store = &manager->ruins; assert(store->count < MAX_ENTITIES_COUNT); u16 idx = (u16)store->count; WarRuinComponent* comp = &store->dense[idx]; *comp = (WarRuinComponent){0}; comp->pieces = pieces; store->enabled[idx] = true; store->owners[idx] = entity->id; store->count++; entity->components[COMP_RUIN] = idx; TracyCZoneEnd(ctx); return &store->dense[idx]; } void we_removeRuinComponent(WarContext* context, WarEntity* entity) { if (!entity) return; u16 idx = entity->components[COMP_RUIN]; if (idx == INVALID_COMP_INDEX) return; WarEntityManager* manager = we_getEntityManager(context); assert(manager); WarRuinStorage* store = &manager->ruins; WarRuinPieceListFree(&store->dense[idx].pieces); u16 lastIdx = (u16)(store->count - 1); if (idx != lastIdx) { store->dense[idx] = store->dense[lastIdx]; store->enabled[idx] = store->enabled[lastIdx]; store->owners[idx] = store->owners[lastIdx]; WarEntity* movedEntity = we_findEntity(context, store->owners[idx]); assert(movedEntity != NULL); movedEntity->components[COMP_RUIN] = idx; } store->enabled[lastIdx] = false; store->owners[lastIdx] = 0; store->count--; entity->components[COMP_RUIN] = INVALID_COMP_INDEX; } WarForestComponent* we_addForestComponent(WarContext* context, WarEntity* entity, WarTreeList trees) { TracyCZoneN(ctx, "we_addForestComponent", 1); if (!entity) { TracyCZoneEnd(ctx); return NULL; } WarEntityManager* manager = we_getEntityManager(context); assert(manager); WarForestStorage* store = &manager->forests; assert(store->count < MAX_ENTITIES_COUNT); u16 idx = (u16)store->count; WarForestComponent* comp = &store->dense[idx]; *comp = (WarForestComponent){0}; comp->trees = trees; store->enabled[idx] = true; store->owners[idx] = entity->id; store->count++; entity->components[COMP_FOREST] = idx; TracyCZoneEnd(ctx); return &store->dense[idx]; } void we_removeForestComponent(WarContext* context, WarEntity* entity) { if (!entity) return; u16 idx = entity->components[COMP_FOREST]; if (idx == INVALID_COMP_INDEX) return; WarEntityManager* manager = we_getEntityManager(context); assert(manager); WarForestStorage* store = &manager->forests; WarTreeListFree(&store->dense[idx].trees); u16 lastIdx = (u16)(store->count - 1); if (idx != lastIdx) { store->dense[idx] = store->dense[lastIdx]; store->enabled[idx] = store->enabled[lastIdx]; store->owners[idx] = store->owners[lastIdx]; WarEntity* movedEntity = we_findEntity(context, store->owners[idx]); assert(movedEntity != NULL); movedEntity->components[COMP_FOREST] = idx; } store->enabled[lastIdx] = false; store->owners[lastIdx] = 0; store->count--; entity->components[COMP_FOREST] = INVALID_COMP_INDEX; } WarStateMachineComponent* we_addStateMachineComponent(WarContext* context, WarEntity* entity) { TracyCZoneN(ctx, "we_addStateMachineComponent", 1); if (!entity) { TracyCZoneEnd(ctx); return NULL; } WarEntityManager* manager = we_getEntityManager(context); assert(manager); WarStateMachineStorage* store = &manager->stateMachines; assert(store->count < MAX_ENTITIES_COUNT); u16 idx = (u16)store->count; WarStateMachineComponent* comp = &store->dense[idx]; *comp = (WarStateMachineComponent){0}; comp->currentState = NULL; comp->nextState = NULL; comp->leaveState = false; comp->enterState = false; store->enabled[idx] = true; store->owners[idx] = entity->id; store->count++; entity->components[COMP_STATE_MACHINE] = idx; TracyCZoneEnd(ctx); return &store->dense[idx]; } void we_removeStateMachineComponent(WarContext* context, WarEntity* entity) { if (!entity) return; u16 idx = entity->components[COMP_STATE_MACHINE]; if (idx == INVALID_COMP_INDEX) return; WarEntityManager* manager = we_getEntityManager(context); assert(manager); WarStateMachineStorage* store = &manager->stateMachines; WarStateMachineComponent* comp = &store->dense[idx]; if (comp->currentState) wst_leaveState(context, entity, comp->currentState); if (comp->nextState) wst_leaveState(context, entity, comp->nextState); u16 lastIdx = (u16)(store->count - 1); if (idx != lastIdx) { store->dense[idx] = store->dense[lastIdx]; store->enabled[idx] = store->enabled[lastIdx]; store->owners[idx] = store->owners[lastIdx]; WarEntity* movedEntity = we_findEntity(context, store->owners[idx]); assert(movedEntity != NULL); movedEntity->components[COMP_STATE_MACHINE] = idx; } store->enabled[lastIdx] = false; store->owners[lastIdx] = 0; store->count--; entity->components[COMP_STATE_MACHINE] = INVALID_COMP_INDEX; } WarAnimationsComponent* we_addAnimationsComponent(WarContext* context, WarEntity* entity) { TracyCZoneN(ctx, "we_addAnimationsComponent", 1); if (!entity) { TracyCZoneEnd(ctx); return NULL; } WarEntityManager* manager = we_getEntityManager(context); assert(manager); WarAnimationsStorage* store = &manager->animations; assert(store->count < MAX_ENTITIES_COUNT); u16 idx = (u16)store->count; WarAnimationsComponent* comp = &store->dense[idx]; *comp = (WarAnimationsComponent){0}; WarSpriteAnimationListInit(&comp->animations, WarSpriteAnimationListDefaultOptions); store->enabled[idx] = true; store->owners[idx] = entity->id; store->count++; entity->components[COMP_ANIMATIONS] = idx; TracyCZoneEnd(ctx); return &store->dense[idx]; } void we_removeAnimationsComponent(WarContext* context, WarEntity* entity) { if (!entity) return; u16 idx = entity->components[COMP_ANIMATIONS]; if (idx == INVALID_COMP_INDEX) return; WarEntityManager* manager = we_getEntityManager(context); assert(manager); WarAnimationsStorage* store = &manager->animations; WarSpriteAnimationListFree(&store->dense[idx].animations); u16 lastIdx = (u16)(store->count - 1); if (idx != lastIdx) { store->dense[idx] = store->dense[lastIdx]; store->enabled[idx] = store->enabled[lastIdx]; store->owners[idx] = store->owners[lastIdx]; WarEntity* movedEntity = we_findEntity(context, store->owners[idx]); assert(movedEntity != NULL); movedEntity->components[COMP_ANIMATIONS] = idx; } store->enabled[lastIdx] = false; store->owners[lastIdx] = 0; store->count--; entity->components[COMP_ANIMATIONS] = INVALID_COMP_INDEX; } WarUIComponent* we_addUIComponent(WarContext* context, WarEntity* entity, String name) { TracyCZoneN(ctx, "we_addUIComponent", 1); if (!entity) { TracyCZoneEnd(ctx); return NULL; } WarEntityManager* manager = we_getEntityManager(context); assert(manager); WarUIStorage* store = &manager->uis; assert(store->count < MAX_ENTITIES_COUNT); u16 idx = (u16)store->count; WarUIComponent* comp = &store->dense[idx]; *comp = (WarUIComponent){0}; comp->name = name; store->enabled[idx] = true; store->owners[idx] = entity->id; store->count++; entity->components[COMP_UI] = idx; TracyCZoneEnd(ctx); return &store->dense[idx]; } void we_removeUIComponent(WarContext* context, WarEntity* entity) { if (!entity) return; u16 idx = entity->components[COMP_UI]; if (idx == INVALID_COMP_INDEX) return; WarEntityManager* manager = we_getEntityManager(context); assert(manager); WarUIStorage* store = &manager->uis; u16 lastIdx = (u16)(store->count - 1); if (idx != lastIdx) { store->dense[idx] = store->dense[lastIdx]; store->enabled[idx] = store->enabled[lastIdx]; store->owners[idx] = store->owners[lastIdx]; WarEntity* movedEntity = we_findEntity(context, store->owners[idx]); assert(movedEntity != NULL); movedEntity->components[COMP_UI] = idx; } store->enabled[lastIdx] = false; store->owners[lastIdx] = 0; store->count--; entity->components[COMP_UI] = INVALID_COMP_INDEX; } WarTextComponent* we_addTextComponent(WarContext* context, WarEntity* entity, WarTextComponent params) { TracyCZoneN(ctx, "we_addTextComponent", 1); if (!entity) { TracyCZoneEnd(ctx); return NULL; } WarEntityManager* manager = we_getEntityManager(context); assert(manager); WarTextStorage* store = &manager->texts; assert(store->count < MAX_ENTITIES_COUNT); u16 idx = (u16)store->count; store->dense[idx] = params; store->dense[idx].text = wstr_make(); // NOTE: text ownership is transferred via wui_setUIText below store->enabled[idx] = true; store->owners[idx] = entity->id; store->count++; entity->components[COMP_TEXT] = idx; wui_setUIText(context, entity, params.text); TracyCZoneEnd(ctx); return &store->dense[idx]; } void we_removeTextComponent(WarContext* context, WarEntity* entity) { if (!entity) return; u16 idx = entity->components[COMP_TEXT]; if (idx == INVALID_COMP_INDEX) return; WarEntityManager* manager = we_getEntityManager(context); assert(manager); WarTextStorage* store = &manager->texts; wui_clearUIText(context, entity); u16 lastIdx = (u16)(store->count - 1); if (idx != lastIdx) { store->dense[idx] = store->dense[lastIdx]; store->enabled[idx] = store->enabled[lastIdx]; store->owners[idx] = store->owners[lastIdx]; WarEntity* movedEntity = we_findEntity(context, store->owners[idx]); assert(movedEntity != NULL); movedEntity->components[COMP_TEXT] = idx; } store->enabled[lastIdx] = false; store->owners[lastIdx] = 0; store->count--; entity->components[COMP_TEXT] = INVALID_COMP_INDEX; } WarRectComponent* we_addRectComponent(WarContext* context, WarEntity* entity, WarRectComponent params) { TracyCZoneN(ctx, "we_addRectComponent", 1); if (!entity) { TracyCZoneEnd(ctx); return NULL; } WarEntityManager* manager = we_getEntityManager(context); assert(manager); WarRectStorage* store = &manager->rects; assert(store->count < MAX_ENTITIES_COUNT); u16 idx = (u16)store->count; store->dense[idx] = params; store->enabled[idx] = true; store->owners[idx] = entity->id; store->count++; entity->components[COMP_RECT] = idx; TracyCZoneEnd(ctx); return &store->dense[idx]; } void we_removeRectComponent(WarContext* context, WarEntity* entity) { if (!entity) return; u16 idx = entity->components[COMP_RECT]; if (idx == INVALID_COMP_INDEX) return; WarEntityManager* manager = we_getEntityManager(context); assert(manager); WarRectStorage* store = &manager->rects; u16 lastIdx = (u16)(store->count - 1); if (idx != lastIdx) { store->dense[idx] = store->dense[lastIdx]; store->enabled[idx] = store->enabled[lastIdx]; store->owners[idx] = store->owners[lastIdx]; WarEntity* movedEntity = we_findEntity(context, store->owners[idx]); assert(movedEntity != NULL); movedEntity->components[COMP_RECT] = idx; } store->enabled[lastIdx] = false; store->owners[lastIdx] = 0; store->count--; entity->components[COMP_RECT] = INVALID_COMP_INDEX; } WarButtonComponent* we_addButtonComponent(WarContext* context, WarEntity* entity, WarButtonComponent params) { TracyCZoneN(ctx, "we_addButtonComponent", 1); if (!entity) { TracyCZoneEnd(ctx); return NULL; } WarEntityManager* manager = we_getEntityManager(context); assert(manager); WarButtonStorage* store = &manager->buttons; assert(store->count < MAX_ENTITIES_COUNT); u16 idx = (u16)store->count; store->dense[idx] = params; store->enabled[idx] = true; store->owners[idx] = entity->id; store->count++; entity->components[COMP_BUTTON] = idx; TracyCZoneEnd(ctx); return &store->dense[idx]; } WarButtonComponent* we_addButtonComponentFromResource(WarContext* context, WarEntity* entity, WarSpriteResourceRef normalRef, WarSpriteResourceRef pressedRef) { TracyCZoneN(ctx, "we_addButtonComponentFromResource", 1); if (normalRef.resourceIndex < 0) { logWarning("Trying to create a button component with invalid resource index: %d", normalRef.resourceIndex); TracyCZoneEnd(ctx); return NULL; } if (pressedRef.resourceIndex < 0) { logWarning("Trying to create a button component with invalid resource index: %d", pressedRef.resourceIndex); TracyCZoneEnd(ctx); return NULL; } WarSprite normalSprite = wspr_createSpriteFromResourceIndex(context, normalRef); WarSprite pressedSprite = wspr_createSpriteFromResourceIndex(context, pressedRef); WarButtonComponent* comp = we_addButtonComponent(context, entity, WAR_BUTTON_COMPONENT_INIT( .normalSprite = normalSprite, .pressedSprite = pressedSprite, )); TracyCZoneEnd(ctx); return comp; } void we_removeButtonComponent(WarContext* context, WarEntity* entity) { if (!entity) return; u16 idx = entity->components[COMP_BUTTON]; if (idx == INVALID_COMP_INDEX) return; WarEntityManager* manager = we_getEntityManager(context); assert(manager); WarButtonStorage* store = &manager->buttons; WarButtonComponent* comp = &store->dense[idx]; wui_clearUITooltip(context, entity); wspr_freeSprite(context, comp->normalSprite); wspr_freeSprite(context, comp->pressedSprite); u16 lastIdx = (u16)(store->count - 1); if (idx != lastIdx) { store->dense[idx] = store->dense[lastIdx]; store->enabled[idx] = store->enabled[lastIdx]; store->owners[idx] = store->owners[lastIdx]; WarEntity* movedEntity = we_findEntity(context, store->owners[idx]); assert(movedEntity != NULL); movedEntity->components[COMP_BUTTON] = idx; } store->enabled[lastIdx] = false; store->owners[lastIdx] = 0; store->count--; entity->components[COMP_BUTTON] = INVALID_COMP_INDEX; } WarAudioComponent* we_addAudioComponent(WarContext* context, WarEntity* entity, WarAudioComponent params) { TracyCZoneN(ctx, "we_addAudioComponent", 1); if (!entity) { TracyCZoneEnd(ctx); return NULL; } WarEntityManager* manager = we_getEntityManager(context); assert(manager); WarAudioStorage* store = &manager->audios; assert(store->count < MAX_ENTITIES_COUNT); u16 idx = (u16)store->count; store->dense[idx] = params; if (store->dense[idx].type == WAR_AUDIO_MIDI) { assert(store->dense[idx].resourceIndex >= 0); WarResource* resource = context->resources[store->dense[idx].resourceIndex]; assert(resource); u8* midiData = resource->audio.data; s32 midiLength = resource->audio.length; store->dense[idx].firstMessage = tml_load_memory(midiData, midiLength); store->dense[idx].currentMessage = store->dense[idx].firstMessage; if (!store->dense[idx].firstMessage) { logError("Could not load MIDI from resource: %d", store->dense[idx].resourceIndex); } } store->enabled[idx] = true; store->owners[idx] = entity->id; store->count++; entity->components[COMP_AUDIO] = idx; TracyCZoneEnd(ctx); return &store->dense[idx]; } void we_removeAudioComponent(WarContext* context, WarEntity* entity) { NOT_USED(context); if (!entity) return; u16 idx = entity->components[COMP_AUDIO]; if (idx == INVALID_COMP_INDEX) return; WarEntityManager* manager = we_getEntityManager(context); assert(manager); WarAudioStorage* store = &manager->audios; WarAudioComponent* comp = &store->dense[idx]; if (comp->firstMessage) { // Deallocates the whole array of messages tml_free(comp->firstMessage); } comp->firstMessage = NULL; comp->currentMessage = NULL; u16 lastIdx = (u16)(store->count - 1); if (idx != lastIdx) { store->dense[idx] = store->dense[lastIdx]; store->enabled[idx] = store->enabled[lastIdx]; store->owners[idx] = store->owners[lastIdx]; WarEntity* movedEntity = we_findEntity(context, store->owners[idx]); assert(movedEntity != NULL); movedEntity->components[COMP_AUDIO] = idx; } store->enabled[lastIdx] = false; store->owners[lastIdx] = 0; store->count--; entity->components[COMP_AUDIO] = INVALID_COMP_INDEX; } WarProjectileComponent* we_addProjectileComponent(WarContext* context, WarEntity* entity, WarProjectileComponent params) { TracyCZoneN(ctx, "we_addProjectileComponent", 1); if (!entity) { TracyCZoneEnd(ctx); return NULL; } WarEntityManager* manager = we_getEntityManager(context); assert(manager); WarProjectileStorage* store = &manager->projectiles; assert(store->count < MAX_ENTITIES_COUNT); u16 idx = (u16)store->count; store->dense[idx] = params; store->enabled[idx] = true; store->owners[idx] = entity->id; store->count++; entity->components[COMP_PROJECTILE] = idx; TracyCZoneEnd(ctx); return &store->dense[idx]; } void we_removeProjectileComponent(WarContext* context, WarEntity* entity) { if (!entity) return; u16 idx = entity->components[COMP_PROJECTILE]; if (idx == INVALID_COMP_INDEX) return; WarEntityManager* manager = we_getEntityManager(context); assert(manager); WarProjectileStorage* store = &manager->projectiles; u16 lastIdx = (u16)(store->count - 1); if (idx != lastIdx) { store->dense[idx] = store->dense[lastIdx]; store->enabled[idx] = store->enabled[lastIdx]; store->owners[idx] = store->owners[lastIdx]; WarEntity* movedEntity = we_findEntity(context, store->owners[idx]); assert(movedEntity != NULL); movedEntity->components[COMP_PROJECTILE] = idx; } store->enabled[lastIdx] = false; store->owners[lastIdx] = 0; store->count--; entity->components[COMP_PROJECTILE] = INVALID_COMP_INDEX; } WarCursorComponent* we_addCursorComponent(WarContext* context, WarEntity* entity, WarCursorComponent params) { TracyCZoneN(ctx, "we_addCursorComponent", 1); if (!entity) { TracyCZoneEnd(ctx); return NULL; } WarEntityManager* manager = we_getEntityManager(context); assert(manager); WarCursorStorage* store = &manager->cursors; assert(store->count < MAX_ENTITIES_COUNT); u16 idx = (u16)store->count; store->dense[idx] = params; store->enabled[idx] = true; store->owners[idx] = entity->id; store->count++; entity->components[COMP_CURSOR] = idx; TracyCZoneEnd(ctx); return &store->dense[idx]; } void we_removeCursorComponent(WarContext* context, WarEntity* entity) { if (!entity) return; u16 idx = entity->components[COMP_CURSOR]; if (idx == INVALID_COMP_INDEX) return; WarEntityManager* manager = we_getEntityManager(context); assert(manager); WarCursorStorage* store = &manager->cursors; u16 lastIdx = (u16)(store->count - 1); if (idx != lastIdx) { store->dense[idx] = store->dense[lastIdx]; store->enabled[idx] = store->enabled[lastIdx]; store->owners[idx] = store->owners[lastIdx]; WarEntity* movedEntity = we_findEntity(context, store->owners[idx]); assert(movedEntity != NULL); movedEntity->components[COMP_CURSOR] = idx; } store->enabled[lastIdx] = false; store->owners[lastIdx] = 0; store->count--; entity->components[COMP_CURSOR] = INVALID_COMP_INDEX; } WarPoisonCloudComponent* we_addPoisonCloudComponent(WarContext* context, WarEntity* entity, WarPoisonCloudComponent params) { TracyCZoneN(ctx, "we_addPoisonCloudComponent", 1); if (!entity) { TracyCZoneEnd(ctx); return NULL; } WarEntityManager* manager = we_getEntityManager(context); assert(manager); WarPoisonCloudStorage* store = &manager->poisonClouds; assert(store->count < MAX_ENTITIES_COUNT); u16 idx = (u16)store->count; store->dense[idx] = params; store->enabled[idx] = true; store->owners[idx] = entity->id; store->count++; entity->components[COMP_POISON_CLOUD] = idx; TracyCZoneEnd(ctx); return &store->dense[idx]; } void we_removePoisonCloudComponent(WarContext* context, WarEntity* entity) { if (!entity) return; u16 idx = entity->components[COMP_POISON_CLOUD]; if (idx == INVALID_COMP_INDEX) return; WarEntityManager* manager = we_getEntityManager(context); assert(manager); WarPoisonCloudStorage* store = &manager->poisonClouds; u16 lastIdx = (u16)(store->count - 1); if (idx != lastIdx) { store->dense[idx] = store->dense[lastIdx]; store->enabled[idx] = store->enabled[lastIdx]; store->owners[idx] = store->owners[lastIdx]; WarEntity* movedEntity = we_findEntity(context, store->owners[idx]); assert(movedEntity != NULL); movedEntity->components[COMP_POISON_CLOUD] = idx; } store->enabled[lastIdx] = false; store->owners[lastIdx] = 0; store->count--; entity->components[COMP_POISON_CLOUD] = INVALID_COMP_INDEX; } WarSightComponent* we_addSightComponent(WarContext* context, WarEntity* entity, WarSightComponent params) { TracyCZoneN(ctx, "we_addSightComponent", 1); if (!entity) { TracyCZoneEnd(ctx); return NULL; } WarEntityManager* manager = we_getEntityManager(context); assert(manager); WarSightStorage* store = &manager->sights; assert(store->count < MAX_ENTITIES_COUNT); u16 idx = (u16)store->count; store->dense[idx] = params; store->enabled[idx] = true; store->owners[idx] = entity->id; store->count++; entity->components[COMP_SIGHT] = idx; TracyCZoneEnd(ctx); return &store->dense[idx]; } void we_removeSightComponent(WarContext* context, WarEntity* entity) { if (!entity) return; u16 idx = entity->components[COMP_SIGHT]; if (idx == INVALID_COMP_INDEX) return; WarEntityManager* manager = we_getEntityManager(context); assert(manager); WarSightStorage* store = &manager->sights; u16 lastIdx = (u16)(store->count - 1); if (idx != lastIdx) { store->dense[idx] = store->dense[lastIdx]; store->enabled[idx] = store->enabled[lastIdx]; store->owners[idx] = store->owners[lastIdx]; WarEntity* movedEntity = we_findEntity(context, store->owners[idx]); assert(movedEntity != NULL); movedEntity->components[COMP_SIGHT] = idx; } store->enabled[lastIdx] = false; store->owners[lastIdx] = 0; store->count--; entity->components[COMP_SIGHT] = INVALID_COMP_INDEX; } // Entities WarEntity* we_createEntity(WarContext* context, WarEntityType type, bool addToScene) { TracyCZoneN(ctx, "we_createEntity", 1); WarEntityManager* manager = we_getEntityManager(context); // Find first empty slot (id == 0 means unused; slot 0 is permanently reserved) WarEntity* entity = NULL; for (u32 i = 1; i < MAX_ENTITIES_COUNT; i++) { if (manager->entities[i].id == 0) { entity = &manager->entities[i]; break; } } if (!entity) { logError("Entity pool exhausted (MAX_ENTITIES_COUNT=%d)", MAX_ENTITIES_COUNT); TracyCZoneEnd(ctx); return NULL; } entity->id = (u16)++manager->nextEntityId; entity->type = (u16)type; manager->entityCount++; if (addToScene) { WarEntityIdMapSet(&manager->entitiesById, entity->id, entity); WarEntityList* entitiesOfType = we_getEntitiesOfType(context, type); WarEntityListAdd(entitiesOfType, entity); if (wui_isUIEntity(entity)) { WarEntityListAdd(&manager->uiEntities, entity); } } TracyCZoneEnd(ctx); return entity; } WarEntity* we_createUnit(WarContext* context, const CreateUnitArgs* args) { WarUnitType type = args->type; s32 x = args->x; s32 y = args->y; u8 player = args->player; WarResourceKind resourceKind = args->resourceKind; u32 amount = args->amount; bool addToMap = args->addToMap; TracyCZoneN(ctx, "we_createUnit", 1); WarMap* map = context->map; const WarUnitData* unitData = wu_getUnitData(type); WarEntity* entity = we_createEntity(context, WAR_ENTITY_TYPE_UNIT, addToMap); we_addTransformComponent(context, entity, WAR_TRANSFORM_COMPONENT_INIT( .position = vec2i(x * MEGA_TILE_WIDTH, y * MEGA_TILE_HEIGHT) )); we_addUnitComponent(context, entity, WAR_UNIT_COMPONENT_INIT( .type = type, .direction = rand() % WAR_DIRECTION_COUNT, .tilex = x, .tiley = y, .sizex = unitData->sizex, .sizey = unitData->sizey, .player = player, .resourceKind = resourceKind, .amount = amount, )); s32 spriteIndex = unitData->resourceIndex; if (spriteIndex == 0) { logError("Sprite for unit of type %d is not configure properly. Default to footman sprite.", type); spriteIndex = 279; } we_addSpriteComponentFromResource(context, entity, imageResourceRef(spriteIndex)); wact_addUnitActions(context, entity); we_addAnimationsComponent(context, entity); we_addStateMachineComponent(context, entity); if (wu_isDudeUnit(context, entity)) { const WarUnitStats* stats = wu_getUnitStats(type); WarUnitComponent* uc = we_getUnitComponent(context, entity); assert(uc); uc->maxhp = stats->hp; uc->hp = stats->hp; uc->maxMana = stats->mana; uc->mana = wu_isSummonUnit(context, entity) ? stats->mana : 100; uc->armor = stats->armor; uc->range = stats->range; uc->minDamage = stats->minDamage; uc->rndDamage = stats->rndDamage; uc->decay = stats->decay; uc->manaTime = 1; } else if(wu_isBuildingUnit(context, entity)) { const WarBuildingStats* stats = wu_getBuildingStats(type); WarUnitComponent* uc = we_getUnitComponent(context, entity); assert(uc); uc->maxhp = stats->hp; uc->hp = stats->hp; uc->armor = stats->armor; } WarState* idleState = wst_createIdleState(context, entity, wu_isDudeUnit(context, entity)); wst_changeNextState(context, entity, idleState, true, true); if (addToMap) { WarEntityManager* manager = &map->entityManager; WarEntityList* list = WarUnitMapGet(&manager->unitsByType, type); WarEntityListAdd(list, entity); } TracyCZoneEnd(ctx); return entity; } WarEntity* we_createDude(WarContext* context, const CreateUnitArgs* args) { WarUnitType type = args->type; s32 x = args->x; s32 y = args->y; u8 player = args->player; bool isGoingToTrain = args->isGoingToTrain; assert(wu_isDudeUnitType(type)); return we_createUnit(context, CREATE_UNIT_ARGS_INIT(.type=type, .x=x, .y=y, .player=player, .addToMap=!isGoingToTrain)); } WarEntity* we_createBuilding(WarContext* context, const CreateUnitArgs* args) { WarUnitType type = args->type; s32 x = args->x; s32 y = args->y; u8 player = args->player; bool isGoingToBuild = args->isGoingToBuild; assert(wu_isBuildingUnitType(type)); WarEntity* entity = we_createUnit(context, CREATE_UNIT_ARGS_INIT(.type=type, .x=x, .y=y, .player=player, .addToMap=true)); if (isGoingToBuild) { const WarBuildingStats* stats = wu_getBuildingStats(type); WarState* buildState = wst_createBuildState(context, entity, (f32)stats->buildTime); wst_changeNextState(context, entity, buildState, true, true); } return entity; } WarEntity* we_findEntity(WarContext* context, WarEntityId id) { TracyCZoneN(ctx, "we_findEntity", 1); WarEntity* result = NULL; if (id != 0) { WarEntityManager* manager = we_getEntityManager(context); for (u32 i = 1; i < MAX_ENTITIES_COUNT; i++) { if (manager->entities[i].id == id) { result = &manager->entities[i]; break; } } } TracyCZoneEnd(ctx); return result; } WarEntity* we_findClosestUnitOfType(WarContext* context, WarEntity* entity, WarUnitType type) { TracyCZoneN(ctx, "we_findClosestUnitOfType", 1); WarEntity* result = NULL; s32 minDst = INT32_MAX; WarEntityList* units = we_getEntitiesOfType(context, WAR_ENTITY_TYPE_UNIT); assert(units); for (s32 i = 0; i < units->count; i++) { WarEntity* target = units->items[i]; if (wu_isUnitOfType(context, target, type)) { s32 dst = wu_unitDistanceInTiles(context, entity, target); if (dst < minDst) { result = target; minDst = dst; } } } TracyCZoneEnd(ctx); return result; } WarEntity* we_findUIEntity(WarContext* context, StringView name) { TracyCZoneN(ctx, "we_findUIEntity", 1); WarEntity* result = NULL; WarEntityList* entities = we_getUIEntities(context); for (s32 i = 0; i < entities->count; i++) { WarEntity* entity = entities->items[i]; if (entity && wui_isUIEntity(entity)) { WarUIComponent* uiComp = we_getUIComponent(context, entity); assert(uiComp); if (wsv_equals(wsv_fromString(&uiComp->name), name)) { result = entity; break; } } } TracyCZoneEnd(ctx); return result; } WarEntity* we_findEntityUnderCursor(WarContext* context, bool includeTrees, bool includeWalls) { TracyCZoneN(ctx, "we_findEntityUnderCursor", 1); WarInput* input = &context->input; WarMap* map = context->map; assert(map); vec2 targetPoint = wmap_screenToMapCoordinatesV(context, input->pos); vec2 targetTile = wmap_mapToTileCoordinatesV(targetPoint); WarEntity* entityUnderCursor = NULL; WarEntityList* units = we_getEntitiesOfType(context, WAR_ENTITY_TYPE_UNIT); for(s32 i = 0; i < units->count; i++) { WarEntity* entity = units->items[i]; if (entity) { WarUnitComponent* unit = we_getUnitComponent(context, entity); if (unit) { // don't change the cursor for dead units or corpses if (wst_isDead(context, entity) || wst_isGoingToDie(context, entity) || wu_isCorpseUnit(context, entity)) { continue; } // don't change the cursor for collased buildings if (wst_isCollapsing(context, entity) || wst_isGoingToCollapse(context, entity)) { continue; } // don't change the cursor for non-visible units if (!wmap_isUnitPartiallyVisible(context, map, entity)) { continue; } } rect unitRect = wu_getUnitRect(context, entity); if (rect_containsf(unitRect, targetPoint.x, targetPoint.y)) { entityUnderCursor = entity; break; } } } if (includeTrees && !entityUnderCursor) { WarEntityList* forests = we_getEntitiesOfType(context, WAR_ENTITY_TYPE_FOREST); for (s32 i = 0; i < forests->count; i++) { WarEntity* forest = forests->items[i]; if (forest) { WarForestComponent* forestComp = we_getForestComponent(context, forest); assert(forestComp); WarTreeList* trees = &forestComp->trees; for (s32 k = 0; k < trees->count; k++) { WarTree tree = trees->items[k]; if (tree.tilex == (s32)targetTile.x && tree.tiley == (s32)targetTile.y) { if (tree.type != WAR_TREE_NONE && tree.type != WAR_TREE_CHOPPED) { entityUnderCursor = forest; } break; } } } if (entityUnderCursor) { break; } } } // if there is no unit under the cursor, check the walls if (includeWalls && !entityUnderCursor) { WarEntityList* walls = we_getEntitiesOfType(context, WAR_ENTITY_TYPE_WALL); for (s32 i = 0; i < walls->count; i++) { WarEntity* wall = walls->items[i]; if (wall) { WarWallComponent* wallComp = we_getWallComponent(context, wall); assert(wallComp); WarWallPieceList* pieces = &wallComp->pieces; for (s32 k = 0; k < pieces->count; k++) { WarWallPiece piece = pieces->items[k]; if (piece.tilex == (s32)targetTile.x && piece.tiley == (s32)targetTile.y) { if (piece.hp > 0) { entityUnderCursor = wall; } break; } } } if (entityUnderCursor) { break; } } } TracyCZoneEnd(ctx); return entityUnderCursor; } void we_removeEntity(WarContext* context, WarEntity* entity) { TracyCZoneN(ctx, "we_removeEntity", 1); WarEntityManager* manager = we_getEntityManager(context); // Cache secondary-index metadata BEFORE any component is stripped. bool isUI = wui_isUIEntity(entity); bool isUnitEnt = wu_isUnit(entity); WarEntityType entityType = (WarEntityType)entity->type; WarEntityId entityId = entity->id; WarUnitType unitType = WAR_UNIT_FOOTMAN; // safe default if (isUnitEnt) { WarUnitComponent* uc = we_getUnitComponent(context, entity); if (uc) unitType = uc->type; } // Strip all 18 components (dense storage, each is a no-op if absent) we_removeTransformComponent(context, entity); we_removeSpriteComponent(context, entity); we_removeUnitComponent(context, entity); we_removeRoadComponent(context, entity); we_removeWallComponent(context, entity); we_removeRuinComponent(context, entity); we_removeForestComponent(context, entity); we_removeStateMachineComponent(context, entity); we_removeAnimationsComponent(context, entity); we_removeUIComponent(context, entity); we_removeTextComponent(context, entity); we_removeRectComponent(context, entity); we_removeButtonComponent(context, entity); we_removeAudioComponent(context, entity); we_removeCursorComponent(context, entity); we_removeProjectileComponent(context, entity); we_removePoisonCloudComponent(context, entity); we_removeSightComponent(context, entity); // Update secondary indices if (isUI) WarEntityListRemove(&manager->uiEntities, entity); if (isUnitEnt) { WarEntityList* unitTypeList = WarUnitMapGet(&manager->unitsByType, unitType); if (unitTypeList) WarEntityListRemove(unitTypeList, entity); } WarEntityList* entityTypeList = WarEntityMapGet(&manager->entitiesByType, entityType); if (entityTypeList) WarEntityListRemove(entityTypeList, entity); WarEntityIdMapRemove(&manager->entitiesById, entityId); // Free the flat-pool slot and return it for reuse *entity = (WarEntity){0}; manager->entityCount--; TracyCZoneEnd(ctx); } void we_removeEntityById(WarContext* context, WarEntityId id) { TracyCZoneN(ctx, "we_removeEntityById", 1); WarEntity* entity = we_findEntity(context, id); if (entity) { SDL_LockMutex(context->__mutex); we_removeEntity(context, entity); SDL_UnlockMutex(context->__mutex); } TracyCZoneEnd(ctx); } void we_initEntityManager(WarContext* context, WarEntityManager* manager) { TracyCZoneN(ctx, "we_initEntityManager", 1); NOT_USED(context); // Zero the entire flat entity pool (id==0 marks every slot as empty) memset(manager->entities, 0, sizeof(manager->entities)); manager->entityCount = 0; manager->nextEntityId = 0; // Reserve slot 0 in every dense storage (idx==0 == INVALID_COMP_INDEX == "absent"). // The first real component added to any store will go to index 1. manager->transforms.count = 1; manager->sprites.count = 1; manager->units.count = 1; manager->animations.count = 1; manager->roads.count = 1; manager->walls.count = 1; manager->ruins.count = 1; manager->forests.count = 1; manager->stateMachines.count = 1; manager->uis.count = 1; manager->texts.count = 1; manager->rects.count = 1; manager->buttons.count = 1; manager->audios.count = 1; manager->cursors.count = 1; manager->projectiles.count = 1; manager->poisonClouds.count = 1; manager->sights.count = 1; // initialize entity by type map WarEntityMapOptions entitiesByTypeOptions = (WarEntityMapOptions){0}; entitiesByTypeOptions.defaultValue = NULL; entitiesByTypeOptions.hashFn = we_hashEntityType; entitiesByTypeOptions.equalsFn = we_equalsEntityType; entitiesByTypeOptions.freeFn = we_freeEntityList; WarEntityMapInit(&manager->entitiesByType, entitiesByTypeOptions); for (WarEntityType type = WAR_ENTITY_TYPE_IMAGE; type < WAR_ENTITY_TYPE_COUNT; type++) { WarEntityList* list = (WarEntityList*)wm_alloc(sizeof(WarEntityList)); WarEntityListInit(list, WarEntityListNonFreeOptions); WarEntityMapSet(&manager->entitiesByType, type, list); } // initialize unit by type map WarUnitMapOptions unitsByTypeOptions = (WarUnitMapOptions){0}; unitsByTypeOptions.defaultValue = NULL; unitsByTypeOptions.hashFn = wu_hashUnitType; unitsByTypeOptions.equalsFn = wu_equalsUnitType; unitsByTypeOptions.freeFn = we_freeEntityList; WarUnitMapInit(&manager->unitsByType, unitsByTypeOptions); for (WarUnitType type = WAR_UNIT_FOOTMAN; type < WAR_UNIT_COUNT; type++) { WarEntityList* list = (WarEntityList*)wm_alloc(sizeof(WarEntityList)); WarEntityListInit(list, WarEntityListNonFreeOptions); WarUnitMapSet(&manager->unitsByType, type, list); } // initialize the entities by id map WarEntityIdMapOptions entitiesByIdOptions = (WarEntityIdMapOptions){0}; entitiesByIdOptions.defaultValue = NULL; entitiesByIdOptions.hashFn = we_hashEntityId; entitiesByIdOptions.equalsFn = we_equalsEntityId; WarEntityIdMapInit(&manager->entitiesById, entitiesByIdOptions); // initialize ui entities list WarEntityListInit(&manager->uiEntities, WarEntityListNonFreeOptions); TracyCZoneEnd(ctx); } WarEntityManager* we_getEntityManager(WarContext* context) { if (context->scene) return &context->scene->entityManager; if (context->map) return &context->map->entityManager; logError("There is no map or scene active."); return NULL; } WarEntityList* we_getEntitiesOfType(WarContext* context, WarEntityType type) { TracyCZoneN(ctx, "we_getEntitiesOfType", 1); WarEntityManager* manager = we_getEntityManager(context); WarEntityList* list = WarEntityMapGet(&manager->entitiesByType, type); TracyCZoneEnd(ctx); return list; } WarEntityList* we_getUnitsOfType(WarContext* context, WarUnitType type) { TracyCZoneN(ctx, "we_getUnitsOfType", 1); WarEntityManager* manager = we_getEntityManager(context); WarEntityList* list = WarUnitMapGet(&manager->unitsByType, type); TracyCZoneEnd(ctx); return list; } WarEntityList* we_getUIEntities(WarContext* context) { WarEntityManager* manager = we_getEntityManager(context); return &manager->uiEntities; } // Render entities s32 renderCompareUnits(const WarEntity* e1, const WarEntity* e2, void* userdata) { WarContext* context = (WarContext*)userdata; assert(context != NULL); assert(wu_isUnit(e1)); assert(wu_isUnit(e2)); bool isDead1 = wu_isCorpseUnit(context, (WarEntity*)e1) || wst_isDead(context, (WarEntity*)e1) || wst_isGoingToDie(context, (WarEntity*)e1); bool isDead2 = wu_isCorpseUnit(context, (WarEntity*)e2) || wst_isDead(context, (WarEntity*)e2) || wst_isGoingToDie(context, (WarEntity*)e2); if (isDead1 && !isDead2) return -1; if (!isDead1 && isDead2) return 1; vec2 p1 = wu_getUnitPosition(context, (WarEntity*)e1, false); vec2 p2 = wu_getUnitPosition(context, (WarEntity*)e2, false); return (s32)(p1.y - p2.y); } s32 renderCompareProjectiles(const WarEntity* e1, const WarEntity* e2, void* userdata) { WarContext* context = (WarContext*)userdata; assert(context != NULL); WarTransformComponent* t1 = we_getTransformComponent(context, (WarEntity*)e1); WarTransformComponent* t2 = we_getTransformComponent(context, (WarEntity*)e2); vec2 p1 = t1 ? t1->position : VEC2_ZERO; vec2 p2 = t2 ? t2->position : VEC2_ZERO; return (s32)(p1.y - p2.y); } void renderImage(WarContext* context, WarEntity* entity) { TracyCZoneN(ctx, "renderImage", 1); WarTransformComponent* transform = we_getTransformComponent(context, entity); assert(transform); if (we_isComponentEnabled(context, entity, COMP_UI) && we_isComponentEnabled(context, entity, COMP_SPRITE)) { WarSpriteComponent* sprite = we_getSpriteComponent(context, entity); assert(sprite); WarUIComponent* ui = we_getUIComponent(context, entity); assert(ui); if (sprite->frameIndex >= 0) { wr_save(context); if (sprite->sprite.framesCount > 1) { WarSpriteFrame frame = wspr_getSpriteFrame(context, sprite->sprite, sprite->frameIndex); wspr_updateSpriteImage(context, sprite->sprite, frame.data); wr_translate(context, -(f32)frame.dx, -(f32)frame.dy); } wr_translate(context, transform->position.x, transform->position.y); wspr_renderSprite(context, sprite->sprite, VEC2_ZERO, VEC2_ONE); wr_restore(context); } } TracyCZoneEnd(ctx); } void renderRoad(WarContext* context, WarEntity* entity) { TracyCZoneN(ctx, "renderRoad", 1); if (we_isComponentEnabled(context, entity, COMP_SPRITE) && we_isComponentEnabled(context, entity, COMP_ROAD)) { WarSpriteComponent* sprite = we_getSpriteComponent(context, entity); assert(sprite); WarRoadComponent* road = we_getRoadComponent(context, entity); assert(road); // the roads are only for forest and swamp maps WarMapTilesetType tilesetType = context->map->tilesetType; assert(tilesetType == MAP_TILESET_FOREST || tilesetType == MAP_TILESET_SWAMP); WarRoadPieceList* pieces = &road->pieces; for (s32 i = 0; i < pieces->count; i++) { // get the index of the tile in the spritesheet of the map, // corresponding to the current tileset type (forest, swamp) const WarRoadData* roadData = wu_getRoadData(pieces->items[i].type); s32 tileIndex = (tilesetType == MAP_TILESET_FOREST) ? roadData->tileIndexForest : roadData->tileIndexSwamp; // the position in the world of the road piece tile s32 x = pieces->items[i].tilex; s32 y = pieces->items[i].tiley; // coordinates in pixels of the road piece tile s32 tilePixelX = (tileIndex % TILESET_TILES_PER_ROW) * MEGA_TILE_WIDTH; s32 tilePixelY = ((tileIndex / TILESET_TILES_PER_ROW) * MEGA_TILE_HEIGHT); wr_save(context); wr_translate(context, (f32)(x * MEGA_TILE_WIDTH), (f32)(y * MEGA_TILE_HEIGHT)); rect rs = recti(tilePixelX, tilePixelY, MEGA_TILE_WIDTH, MEGA_TILE_HEIGHT); rect rd = recti(0, 0, MEGA_TILE_WIDTH, MEGA_TILE_HEIGHT); wr_subImage(context, sprite->sprite.texture, rs, rd, VEC2_ONE); wr_restore(context); } } TracyCZoneEnd(ctx); } void renderWall(WarContext* context, WarEntity* entity) { TracyCZoneN(ctx, "renderWall", 1); if (we_isComponentEnabled(context, entity, COMP_SPRITE) && we_isComponentEnabled(context, entity, COMP_WALL)) { WarSpriteComponent* sprite = we_getSpriteComponent(context, entity); assert(sprite); WarWallComponent* wall = we_getWallComponent(context, entity); assert(wall); // the walls are only for forest and swamp maps WarMapTilesetType tilesetType = context->map->tilesetType; assert(tilesetType == MAP_TILESET_FOREST || tilesetType == MAP_TILESET_SWAMP); WarWallPieceList* pieces = &wall->pieces; for (s32 i = 0; i < pieces->count; i++) { WarWallPiece* piece = &pieces->items[i]; // get the index of the tile in the spritesheet of the map, // corresponding to the current tileset type (forest, swamp) const WarWallData* wallData = wu_getWallData(piece->type); s32 tileIndex = 0; s32 hpPercent = PERCENTABI(piece->hp, piece->maxhp); if (hpPercent <= 0) { tileIndex = (tilesetType == MAP_TILESET_FOREST) ? wallData->tileDestroyedForest : wallData->tileDestroyedSwamp; } else if(hpPercent < 50) { tileIndex = (tilesetType == MAP_TILESET_FOREST) ? wallData->tileDamagedForest : wallData->tileDamagedSwamp; } else { tileIndex = (tilesetType == MAP_TILESET_FOREST) ? wallData->tileForest : wallData->tileSwamp; } // the position in the world of the wall piece tile s32 x = piece->tilex; s32 y = piece->tiley; // coordinates in pixels of the wall piece tile s32 tilePixelX = (tileIndex % TILESET_TILES_PER_ROW) * MEGA_TILE_WIDTH; s32 tilePixelY = ((tileIndex / TILESET_TILES_PER_ROW) * MEGA_TILE_HEIGHT); wr_save(context); wr_translate(context, (f32)(x * MEGA_TILE_WIDTH), (f32)(y * MEGA_TILE_HEIGHT)); rect rs = recti(tilePixelX, tilePixelY, MEGA_TILE_WIDTH, MEGA_TILE_HEIGHT); rect rd = recti(0, 0, MEGA_TILE_WIDTH, MEGA_TILE_HEIGHT); wr_subImage(context, sprite->sprite.texture, rs, rd, VEC2_ONE); wr_restore(context); } } TracyCZoneEnd(ctx); } void renderRuin(WarContext* context, WarEntity* entity) { TracyCZoneN(ctx, "renderRuin", 1); if (we_isComponentEnabled(context, entity, COMP_SPRITE) && we_isComponentEnabled(context, entity, COMP_RUIN)) { WarSpriteComponent* sprite = we_getSpriteComponent(context, entity); assert(sprite); WarRuinComponent* ruin = we_getRuinComponent(context, entity); assert(ruin); // the walls are only for forest and swamp maps WarMapTilesetType tilesetType = context->map->tilesetType; assert(tilesetType == MAP_TILESET_FOREST || tilesetType == MAP_TILESET_SWAMP); WarRuinPieceList* pieces = &ruin->pieces; for (s32 i = 0; i < ruin->pieces.count; i++) { WarRuinPiece* piece = &pieces->items[i]; if (piece->type == WAR_RUIN_PIECE_NONE) continue; // get the index of the tile in the spritesheet of the map, // corresponding to the current tileset type (forest, swamp) const WarRuinData* ruinData = wu_getRuinData(piece->type); s32 tileIndex = (tilesetType == MAP_TILESET_FOREST) ? ruinData->tileIndexForest : ruinData->tileIndexSwamp; // the position in the world of the road piece tile s32 x = piece->tilex; s32 y = piece->tiley; // coordinates in pixels of the road piece tile s32 tilePixelX = (tileIndex % TILESET_TILES_PER_ROW) * MEGA_TILE_WIDTH; s32 tilePixelY = ((tileIndex / TILESET_TILES_PER_ROW) * MEGA_TILE_HEIGHT); wr_save(context); wr_translate(context, (f32)(x * MEGA_TILE_WIDTH), (f32)(y * MEGA_TILE_HEIGHT)); rect rs = recti(tilePixelX, tilePixelY, MEGA_TILE_WIDTH, MEGA_TILE_HEIGHT); rect rd = recti(0, 0, MEGA_TILE_WIDTH, MEGA_TILE_HEIGHT); wr_subImage(context, sprite->sprite.texture, rs, rd, VEC2_ONE); wr_restore(context); } } TracyCZoneEnd(ctx); } void renderForest(WarContext* context, WarEntity* entity) { TracyCZoneN(ctx, "renderForest", 1); if (we_isComponentEnabled(context, entity, COMP_FOREST)) { WarForestComponent* forest = we_getForestComponent(context, entity); assert(forest); // the wood are only for forest and swamp maps WarMapTilesetType tilesetType = context->map->tilesetType; assert(tilesetType == MAP_TILESET_FOREST || tilesetType == MAP_TILESET_SWAMP); WarTreeList* trees = &forest->trees; for (s32 i = 0; i < trees->count; i++) { WarTree* tree = &trees->items[i]; if (tree->type == WAR_TREE_NONE) continue; const WarTreeData* data = wu_getTreeData(tree->type); // the position in the world of the wood tile s32 x = tree->tilex; s32 y = tree->tiley; s32 prevTileIndex = wmap_getMapTileIndex(context, x, y); s32 newTileIndex = (tilesetType == MAP_TILESET_FOREST) ? data->tileIndexForest : data->tileIndexSwamp; if (prevTileIndex != newTileIndex) logDebug("different tile index for tree (%d, %d), prev: %d, new: %d", x, y, prevTileIndex, newTileIndex); wmap_setMapTileIndex(context, x, y, newTileIndex); } } TracyCZoneEnd(ctx); } void renderUnit(WarContext* context, WarEntity* entity) { TracyCZoneN(ctx, "renderUnit", 1); WarMap* map = context->map; WarUnitComponent* unit = we_getUnitComponent(context, entity); assert(unit); WarTransformComponent* transform = we_getTransformComponent(context, entity); assert(transform); // position of the unit in the map vec2 position = transform->position; // scale of the unit: this is modified by animations when the animation indicates that it // should flip horizontally or vertically or both vec2 scale = transform->scale; // size of the original sprite vec2 frameSize = wu_getUnitFrameSize(context, entity); // size of the unit vec2 unitSize = wu_getUnitSpriteSize(context, entity); // the unit is visible if it's partially on the clear areas of the fog bool isVisible = wmap_isUnitPartiallyVisible(context, map, entity); wr_translate(context, -0.5f * frameSize.x, -0.5f * frameSize.y); wr_translate(context, 0.5f * unitSize.x, 0.5f * unitSize.y); wr_translate(context, position.x, position.y); #ifdef DEBUG_RENDER_UNIT_INFO wr_fillRect(context, wu_getUnitFrameRect(context, entity), WAR_COLOR_RGBA(0, 0, 128, 128)); wr_fillRect(context, wu_getUnitSpriteRect(context, entity), WAR_COLOR_GRAY_TRANSPARENT); wr_fillRect(context, rectv(wu_getUnitSpriteCenter(context, entity), VEC2_ONE), WAR_COLOR_RGB(255, 0, 0)); #endif if (we_isComponentEnabled(context, entity, COMP_SPRITE) && (isVisible || unit->hasBeenSeen)) { WarSpriteComponent* sprite = we_getSpriteComponent(context, entity); assert(sprite); wr_save(context); if (wu_isDudeUnit(context, entity)) { if (unit->invisible) { wr_globalAlpha(context, 0.5f); } if (unit->invulnerable) { rect unitRect = wu_getUnitSpriteRect(context, entity); unitRect = rect_expand(unitRect, -1, -1); wr_strokeRect(context, unitRect, WAR_COLOR_BLUE_INVULNERABLE, 1); } } WarSpriteFrame frame = wspr_getSpriteFrame(context, sprite->sprite, sprite->frameIndex); wspr_updateSpriteImage(context, sprite->sprite, frame.data); wspr_renderSprite(context, sprite->sprite, VEC2_ZERO, scale); wr_restore(context); } if (we_isComponentEnabled(context, entity, COMP_ANIMATIONS) && isVisible) { WarAnimationsComponent* animations = we_getAnimationsComponent(context, entity); assert(animations); for (s32 i = 0; i < animations->animations.count; i++) { WarSpriteAnimation* anim = animations->animations.items[i]; if (anim->status == WAR_ANIM_STATUS_RUNNING) { wr_save(context); wr_translate(context, anim->offset.x, anim->offset.y); wr_scale(context, anim->scale.x, anim->scale.y); #ifdef DEBUG_RENDER_UNIT_ANIMATIONS // size of the original sprite vec2 animFrameSize = vec2i(anim->sprite.frameWidth, anim->sprite.frameHeight); wr_fillRect(context, rectv(VEC2_ZERO, animFrameSize), WAR_COLOR_GRAY_TRANSPARENT); #endif s32 animFrameIndex = (s32)(anim->animTime * anim->frames.count); animFrameIndex = CLAMP(animFrameIndex, 0, anim->frames.count - 1); s32 spriteFrameIndex = anim->frames.items[animFrameIndex]; WarSpriteFrame frame = wspr_getSpriteFrame(context, anim->sprite, spriteFrameIndex); wspr_updateSpriteImage(context, anim->sprite, frame.data); wspr_renderSprite(context, anim->sprite, VEC2_ZERO, VEC2_ONE); wr_restore(context); } } } TracyCZoneEnd(ctx); } void renderText(WarContext* context, WarEntity* entity) { TracyCZoneN(ctx, "renderText", 1); if (we_isComponentEnabled(context, entity, COMP_UI) && we_isComponentEnabled(context, entity, COMP_TEXT)) { WarTransformComponent* transform = we_getTransformComponent(context, entity); assert(transform); WarTextComponent* text = we_getTextComponent(context, entity); wr_save(context); wr_translate(context, transform->position.x, transform->position.y); wr_scale(context, transform->scale.x, transform->scale.y); WarFontParams params; params.fontIndex = text->fontIndex; params.fontSize = text->fontSize; params.lineHeight = text->lineHeight; params.fontColor = text->fontColor; params.highlightColor = text->highlightColor; params.highlightIndex = text->highlightIndex; params.highlightCount = text->highlightCount; params.boundings = text->boundings; params.horizontalAlign = text->horizontalAlign; params.verticalAlign = text->verticalAlign; params.lineAlign = text->lineAlign; params.wrapping = text->wrapping; params.trimming = text->trimming; params.fontSprite = context->fontSprites[text->fontIndex]; params.fontData = getFontData(text->fontIndex); if (text->multiline) wfont_renderMultiSpriteText(context, wstr_view(&text->text), 0, 0, params); else wfont_renderSingleSpriteText(context, wstr_view(&text->text), 0, 0, params); wr_restore(context); } TracyCZoneEnd(ctx); } void renderRect(WarContext* context, WarEntity* entity) { TracyCZoneN(ctx, "renderRect", 1); if (we_isComponentEnabled(context, entity, COMP_UI) && we_isComponentEnabled(context, entity, COMP_RECT)) { WarTransformComponent* transform = we_getTransformComponent(context, entity); assert(transform); WarRectComponent* rectComp = we_getRectComponent(context, entity); wr_save(context); wr_translate(context, transform->position.x, transform->position.y); wr_scale(context, transform->scale.x, transform->scale.y); wr_fillRect(context, rectf(0.0f, 0.0f, rectComp->size.x, rectComp->size.y), rectComp->color); wr_restore(context); } TracyCZoneEnd(ctx); } void renderButton(WarContext* context, WarEntity* entity) { TracyCZoneN(ctx, "renderButton", 1); WarTransformComponent* transform = we_getTransformComponent(context, entity); assert(transform); WarButtonComponent* button = we_getButtonComponent(context, entity); WarTextComponent* text = we_getTextComponent(context, entity); WarSpriteComponent* sprite = we_getSpriteComponent(context, entity); if (we_isComponentEnabled(context, entity, COMP_UI) && we_isComponentEnabled(context, entity, COMP_BUTTON)) { wr_save(context); wr_translate(context, transform->position.x, transform->position.y); wr_scale(context, transform->scale.x, transform->scale.y); // render background { WarSprite backgroundSprite = button->active ? button->pressedSprite : button->normalSprite; wspr_renderSprite(context, backgroundSprite, VEC2_ZERO, VEC2_ONE); } // render foreground { if (we_isComponentEnabled(context, entity, COMP_SPRITE)) { vec2 backgroundSize = vec2i(button->normalSprite.frameWidth, button->normalSprite.frameHeight); vec2 foregroundSize = vec2i(sprite->sprite.frameWidth, sprite->sprite.frameHeight); vec2 offset = vec2_half(vec2_subv(backgroundSize, foregroundSize)); if (button->active) offset = vec2_addv(offset, vec2i(0, 1)); wr_translate(context, offset.x, offset.y); WarSpriteFrame frame = wspr_getSpriteFrame(context, sprite->sprite, sprite->frameIndex); wspr_updateSpriteImage(context, sprite->sprite, frame.data); wspr_renderSprite(context, sprite->sprite, VEC2_ZERO, VEC2_ONE); } } // render text { if (we_isComponentEnabled(context, entity, COMP_TEXT)) { WarFontParams params; params.fontIndex = text->fontIndex; params.fontSize = text->fontSize; params.fontColor = text->fontColor; params.highlightColor = text->highlightColor; params.highlightIndex = button->hot ? ALL_HIGHLIGHT : text->highlightIndex; params.highlightCount = text->highlightCount; params.boundings = text->boundings; params.horizontalAlign = text->horizontalAlign; params.verticalAlign = text->verticalAlign; params.lineAlign = text->lineAlign; params.wrapping = text->wrapping; params.fontSprite = context->fontSprites[text->fontIndex]; params.fontData = getFontData(text->fontIndex); wfont_renderSingleSpriteText(context, wstr_view(&text->text), 0, 0, params); } } wr_restore(context); } TracyCZoneEnd(ctx); } void renderProjectile(WarContext* context, WarEntity* entity) { TracyCZoneN(ctx, "renderProjectile", 1); if (we_isComponentEnabled(context, entity, COMP_SPRITE)) { WarTransformComponent* transform = we_getTransformComponent(context, entity); assert(transform); WarSpriteComponent* sprite = we_getSpriteComponent(context, entity); assert(sprite); vec2 position = transform->position; vec2 scale = transform->scale; WarSpriteFrame frame = wspr_getSpriteFrame(context, sprite->sprite, sprite->frameIndex); #ifdef DEBUG_RENDER_PROJECTILES { wr_save(context); wr_translate(context, -sprite->sprite.frameWidth/2,-sprite->sprite.frameHeight/2); wr_translate(context, position.x, position.y); rect r = rectf(0, 0, sprite->sprite.frameWidth, sprite->sprite.frameHeight); wr_fillRect(context, r, WAR_COLOR_GRAY_TRANSPARENT); wr_restore(context); } { wr_save(context); wr_translate(context, -frame.w/2,-frame.h/2); wr_translate(context, position.x, position.y); rect r = rectf(0, 0, frame.w, frame.h); wr_fillRect(context, r, WAR_COLOR_RED_TRANSPARENT); wr_restore(context); } { WarProjectileComponent* projectile = we_getProjectileComponent(context, entity); assert(projectile); wr_save(context); wr_strokeLine(context, projectile->origin, projectile->target, wr_getColorFromList(entity->id), 0.5f); wr_fillRect(context, rectv(projectile->origin, VEC2_ONE), WAR_COLOR_RGB(255, 0, 255)); wr_fillRect(context, rectv(projectile->target, VEC2_ONE), WAR_COLOR_RGB(255, 0, 255)); wr_restore(context); } #endif wr_translate(context, -(f32)frame.dx, -(f32)frame.dy); wr_translate(context, -0.5f * frame.w, -0.5f * frame.h); wr_translate(context, position.x, position.y); wspr_updateSpriteImage(context, sprite->sprite, frame.data); wspr_renderSprite(context, sprite->sprite, VEC2_ZERO, scale); } TracyCZoneEnd(ctx); } void renderMinimap(WarContext* context, WarEntity* entity) { TracyCZoneN(ctx, "RenderMinimap", 1); WarMap* map = context->map; WarTransformComponent* minimapTransform = we_getTransformComponent(context, entity); assert(minimapTransform); vec2 position = minimapTransform->position; WarSpriteFrame* frame0 = &map->minimapSprite.frames[0]; WarSpriteFrame* frame1 = &map->minimapSprite.frames[1]; // copy the minimap base to the first frame which is the one that will be rendered // copy only the visible tiles/pixels for(s32 y = 0; y < MAP_TILES_HEIGHT; y++) { for(s32 x = 0; x < MAP_TILES_WIDTH; x++) { s32 index = y * MAP_TILES_WIDTH + x; WarMapTile* tile = &map->tiles[index]; if (!map->fowEnabled || tile->state == MAP_TILE_STATE_VISIBLE || tile->state == MAP_TILE_STATE_FOG) { frame0->data[index * 4 + 0] = frame1->data[index * 4 + 0]; frame0->data[index * 4 + 1] = frame1->data[index * 4 + 1]; frame0->data[index * 4 + 2] = frame1->data[index * 4 + 2]; frame0->data[index * 4 + 3] = frame1->data[index * 4 + 3]; } else { frame0->data[index * 4 + 0] = 0; frame0->data[index * 4 + 1] = 0; frame0->data[index * 4 + 2] = 0; frame0->data[index * 4 + 3] = 255; } } } WarEntityList* units = we_getEntitiesOfType(context, WAR_ENTITY_TYPE_UNIT); for(s32 i = 0; i < units->count; i++) { WarEntity* unitEntity = units->items[i]; if (unitEntity) { WarUnitComponent* unit = we_getUnitComponent(context, unitEntity); WarTransformComponent* transform = we_getTransformComponent(context, unitEntity); if (unit && transform && wu_displayUnitOnMinimap(context, unitEntity) && (wmap_isUnitPartiallyVisible(context, map, unitEntity) || unit->hasBeenSeen)) { s32 tileX = (s32)(transform->position.x / MEGA_TILE_WIDTH); s32 tileY = (s32)(transform->position.y / MEGA_TILE_HEIGHT); WarColor color = wu_getUnitColorOnMinimap(context, unitEntity); for(s32 y = 0; y < unit->sizey; y++) { for(s32 x = 0; x < unit->sizex; x++) { s32 pixel = (tileY + y) * MINIMAP_WIDTH + (tileX + x); frame0->data[pixel * 4 + 0] = color.r; frame0->data[pixel * 4 + 1] = color.g; frame0->data[pixel * 4 + 2] = color.b; } } } } } wr_save(context); wr_translate(context, position.x, position.y); // render base wspr_updateSpriteImage(context, map->minimapSprite, map->minimapSprite.frames[0].data); wspr_renderSprite(context, map->minimapSprite, VEC2_ZERO, VEC2_ONE); // render viewport wr_translate(context, (f32)map->viewport.x * MINIMAP_MAP_WIDTH_RATIO, (f32)map->viewport.y * MINIMAP_MAP_HEIGHT_RATIO); wr_strokeRect(context, rectf(0.0f, 0.0f, (f32)MINIMAP_VIEWPORT_WIDTH, (f32)MINIMAP_VIEWPORT_HEIGHT), WAR_COLOR_WHITE, 1.0f); wr_restore(context); TracyCZoneEnd(ctx); } void renderAnimation(WarContext* context, WarEntity* entity) { TracyCZoneN(ctx, "RenderAnimation", 1); if (we_isComponentEnabled(context, entity, COMP_ANIMATIONS)) { WarAnimationsComponent* animations = we_getAnimationsComponent(context, entity); assert(animations); WarTransformComponent* transform = we_getTransformComponent(context, entity); if (transform) { wr_translate(context, transform->position.x, transform->position.y); } for (s32 i = 0; i < animations->animations.count; i++) { WarSpriteAnimation* anim = animations->animations.items[i]; if (anim->status == WAR_ANIM_STATUS_RUNNING) { wr_save(context); wr_translate(context, anim->offset.x, anim->offset.y); wr_scale(context, anim->scale.x, anim->scale.y); s32 animFrameIndex = (s32)(anim->animTime * anim->frames.count); animFrameIndex = CLAMP(animFrameIndex, 0, anim->frames.count - 1); s32 spriteFrameIndex = anim->frames.items[animFrameIndex]; WarSpriteFrame frame = wspr_getSpriteFrame(context, anim->sprite, spriteFrameIndex); wspr_updateSpriteImage(context, anim->sprite, frame.data); wspr_renderSprite(context, anim->sprite, VEC2_ZERO, VEC2_ONE); wr_restore(context); } } } TracyCZoneEnd(ctx); } void we_renderEntity(WarContext* context, WarEntity* entity) { static WarRenderFunc renderFuncs[WAR_ENTITY_TYPE_COUNT] = { NULL, // WAR_ENTITY_TYPE_NONE renderImage, // WAR_ENTITY_TYPE_IMAGE renderUnit, // WAR_ENTITY_TYPE_UNIT renderRoad, // WAR_ENTITY_TYPE_ROAD renderWall, // WAR_ENTITY_TYPE_WALL renderRuin, // WAR_ENTITY_TYPE_RUIN renderForest, // WAR_ENTITY_TYPE_FOREST renderText, // WAR_ENTITY_TYPE_TEXT renderRect, // WAR_ENTITY_TYPE_RECT renderButton, // WAR_ENTITY_TYPE_BUTTON renderImage, // WAR_ENTITY_TYPE_CURSOR NULL, // WAR_ENTITY_TYPE_AUDIO renderProjectile, // WAR_ENTITY_TYPE_PROJECTILE NULL, // WAR_ENTITY_TYPE_RAIN_OF_FIRE renderAnimation, // WAR_ENTITY_TYPE_POISON_CLOUD NULL, // WAR_ENTITY_TYPE_SIGHT renderMinimap, // WAR_ENTITY_TYPE_MINIMAP renderAnimation, // WAR_ENTITY_TYPE_ANIMATION }; TracyCZoneN(ctx, "we_renderEntity", 1); if (entity->id != 0) { WarRenderFunc renderFunc = renderFuncs[(s32)entity->type]; if (!renderFunc) { logError("Entity of type %d can't be render. renderFunc = NULL", entity->type); return; } wr_save(context); renderFunc(context, entity); wr_restore(context); } TracyCZoneEnd(ctx); } void we_renderEntitiesOfType(WarContext* context, WarEntityType type) { static WarRenderCompareFunc renderCompareFuncs[WAR_ENTITY_TYPE_COUNT] = { NULL, // WAR_ENTITY_TYPE_NONE, NULL, // WAR_ENTITY_TYPE_IMAGE, renderCompareUnits, // WAR_ENTITY_TYPE_UNIT, NULL, // WAR_ENTITY_TYPE_ROAD, NULL, // WAR_ENTITY_TYPE_WALL, NULL, // WAR_ENTITY_TYPE_RUIN, NULL, // WAR_ENTITY_TYPE_FOREST, NULL, // WAR_ENTITY_TYPE_TEXT, NULL, // WAR_ENTITY_TYPE_RECT, NULL, // WAR_ENTITY_TYPE_BUTTON, NULL, // WAR_ENTITY_TYPE_CURSOR, NULL, // WAR_ENTITY_TYPE_AUDIO, renderCompareProjectiles, // WAR_ENTITY_TYPE_PROJECTILE, NULL, // WAR_ENTITY_TYPE_RAIN_OF_FIRE, NULL, // WAR_ENTITY_TYPE_POISON_CLOUD, NULL, // WAR_ENTITY_TYPE_SIGHT, NULL, // WAR_ENTITY_TYPE_MINIMAP, NULL, // WAR_ENTITY_TYPE_ANIMATION, }; TracyCZoneN(ctx, "we_renderEntitiesOfType", 1); WarEntityList* entities = we_getEntitiesOfType(context, type); // lookup the render compare function and sort the list if (inRange(type, WAR_ENTITY_TYPE_NONE, WAR_ENTITY_TYPE_COUNT)) { WarRenderCompareFunc compareFunc = renderCompareFuncs[type]; if (compareFunc) { // the idea of sorting the entities before render is // to allow render order to be the most correct as possible // for instance, corpses need to render before every other unit // and then render units by the `y` position on the map WarEntityListSort(entities, compareFunc, context); } } for(s32 i = 0; i < entities->count; i++) { WarEntity* entity = entities->items[i]; if (entity) { we_renderEntity(context, entity); } } TracyCZoneEnd(ctx); } void we_renderUnitSelection(WarContext* context) { TracyCZoneN(ctx, "RenderUnitSelection", 1); WarMap* map = context->map; WarEntityIdList* selectedEntities = &map->selectedEntities; for (s32 i = 0; i < selectedEntities->count; i++) { WarEntityId entityId = selectedEntities->items[i]; WarEntity* entity = we_findEntity(context, entityId); if (entity && we_isComponentEnabled(context, entity, COMP_UNIT) && we_isComponentEnabled(context, entity, COMP_SPRITE)) { WarTransformComponent* transform = we_getTransformComponent(context, entity); assert(transform); // size of the original sprite vec2 frameSize = wu_getUnitFrameSize(context, entity); // size of the unit vec2 unitSize = wu_getUnitSpriteSize(context, entity); // position of the unit in the map vec2 position = transform->position; wr_save(context); wr_translate(context, -0.5f * frameSize.x, -0.5f * frameSize.y); wr_translate(context, 0.5f * unitSize.x, 0.5f * unitSize.y); wr_translate(context, position.x, position.y); rect selr = rectf( 0.5f * (frameSize.x - unitSize.x), 0.5f * (frameSize.y - unitSize.y), unitSize.x, unitSize.y ); WarColor color = WAR_COLOR_WHITE_SELECTION; if (wu_isFriendlyUnit(context, entity)) color = WAR_COLOR_GREEN_SELECTION; else if (wu_isEnemyUnit(context, entity)) color = WAR_COLOR_RED_SELECTION; wr_strokeRect(context, selr, color, 1.0f); wr_restore(context); } } TracyCZoneEnd(ctx); } void we_increaseUpgradeLevel(WarContext* context, WarPlayerInfo* player, WarUpgradeType upgrade) { assert(hasRemainingUpgrade(player, upgrade)); incrementUpgradeLevel(player, upgrade); switch (upgrade) { case WAR_UPGRADE_ARROWS: case WAR_UPGRADE_SPEARS: { WarEntityList* units = we_getEntitiesOfType(context, WAR_ENTITY_TYPE_UNIT); for (s32 i = 0; i < units->count; i++) { WarEntity* entity = units->items[i]; WarUnitComponent* uc = entity ? we_getUnitComponent(context, entity) : NULL; if (uc && uc->player == player->index) { if (uc->type == WAR_UNIT_ARCHER || uc->type == WAR_UNIT_SPEARMAN) { uc->minDamage += 2; } } } break; } case WAR_UPGRADE_SWORDS: case WAR_UPGRADE_AXES: { WarEntityList* units = we_getEntitiesOfType(context, WAR_ENTITY_TYPE_UNIT); for (s32 i = 0; i < units->count; i++) { WarEntity* entity = units->items[i]; WarUnitComponent* uc = entity ? we_getUnitComponent(context, entity) : NULL; if (uc && uc->player == player->index) { if (uc->type == WAR_UNIT_FOOTMAN || uc->type == WAR_UNIT_GRUNT || uc->type == WAR_UNIT_KNIGHT || uc->type == WAR_UNIT_RAIDER) { if (getUpgradeLevel(player, upgrade) == 1) { uc->minDamage += 1; uc->rndDamage += 1; } else if (getUpgradeLevel(player, upgrade) == 2) { uc->minDamage += 2; uc->rndDamage += 2; } } } } break; } case WAR_UPGRADE_HORSES: case WAR_UPGRADE_WOLVES: { WarEntityList* units = we_getEntitiesOfType(context, WAR_ENTITY_TYPE_UNIT); for (s32 i = 0; i < units->count; i++) { WarEntity* entity = units->items[i]; WarUnitComponent* uc = entity ? we_getUnitComponent(context, entity) : NULL; if (uc && uc->player == player->index) { if (wu_isDudeUnit(context, entity)) { uc->speed++; } } } break; } case WAR_UPGRADE_SHIELD: { WarEntityList* units = we_getEntitiesOfType(context, WAR_ENTITY_TYPE_UNIT); for (s32 i = 0; i < units->count; i++) { WarEntity* entity = units->items[i]; WarUnitComponent* uc = entity ? we_getUnitComponent(context, entity) : NULL; if (uc && uc->player == player->index) { if (getUpgradeLevel(player, upgrade) == 1) { uc->armor += 1; } else if (getUpgradeLevel(player, upgrade) == 2) { uc->armor += 2; } } } break; } default: { logInfo("This upgrade type %d doesn't increase any value of the units", upgrade); break; } } } bool we_enoughPlayerResources(WarContext* context, WarPlayerInfo* player, s32 gold, s32 wood) { NOT_USED(context); return player->gold >= gold && player->wood >= wood; } bool we_decreasePlayerResources(WarContext* context, WarPlayerInfo* player, s32 gold, s32 wood) { if (player->gold < gold) { wmui_setFlashStatus(context, 1.5f, wstr_fromCString("NOT ENOUGH GOLD... MINE MORE GOLD")); return false; } if (player->wood < wood) { wmui_setFlashStatus(context, 1.5f, wstr_fromCString("NOT ENOUGH LUMBER... CHOP MORE TREES")); return false; } player->gold -= gold; player->wood -= wood; return true; } void we_increasePlayerResources(WarContext* context, WarPlayerInfo* player, s32 gold, s32 wood) { NOT_USED(context); player->gold += gold; player->wood += wood; } bool we_increaseUnitHp(WarContext* context, WarEntity* entity, s32 hp) { assert(wu_isUnit(entity)); WarUnitComponent* unit = we_getUnitComponent(context, entity); assert(unit); unit->hp += hp; unit->hp = MIN(unit->hp, unit->maxhp); return true; } bool we_decreaseUnitHp(WarContext* context, WarEntity* entity, s32 hp) { assert(wu_isUnit(entity)); WarUnitComponent* unit = we_getUnitComponent(context, entity); assert(unit); unit->hp -= hp; unit->hp = MAX(unit->hp, 0); return true; } bool we_decreaseUnitMana(WarContext* context, WarEntity* entity, s32 mana) { assert(wu_isUnit(entity)); WarUnitComponent* unit = we_getUnitComponent(context, entity); assert(unit); if (unit->mana < mana) { wmui_setFlashStatus(context, 1.5f, wstr_fromCString("NOT ENOUGH MANA")); return false; } unit->mana = MAX(unit->mana - mana, 0); return true; } void we_increaseUnitMana(WarContext* context, WarEntity* entity, s32 mana) { assert(wu_isUnit(entity)); WarUnitComponent* unit = we_getUnitComponent(context, entity); assert(unit); unit->mana = CLAMP(unit->mana + mana, 0, unit->maxMana); } bool we_enoughFarmFood(WarContext* context, WarPlayerInfo* player) { WarUnitType farmType = wu_getUnitTypeForRace(WAR_UNIT_FARM_HUMANS, player->race); s32 farmCount = wu_getNumberOfBuildingsOfType(context, player->index, farmType, true); s32 foodCount = farmCount * 4 + 1; s32 dudesCount = wu_getTotalNumberOfDudes(context, player->index); return dudesCount + 1 <= foodCount; } bool we_checkFarmFood(WarContext* context, WarPlayerInfo* player) { if (!we_enoughFarmFood(context, player)) { wmui_setFlashStatus(context, 1.5f, wstr_fromCString("NOT ENOUGH FOOD... BUILD MORE FARMS")); return false; } return true; } bool we_checkRectToBuild(WarContext* context, s32 x, s32 y, s32 w, s32 h) { WarMap* map = context->map; for (s32 dy = 0; dy < h; dy++) { for (s32 dx = 0; dx < w; dx++) { s32 xx = x + dx; s32 yy = y + dy; if (inRange(xx, 0, MAP_TILES_WIDTH) && inRange(yy, 0, MAP_TILES_HEIGHT)) { if (!isEmpty(map->finder, xx, yy) || wmap_isTileUnkown(map, xx, yy)) { return false; } } } } return true; } bool we_checkTileToBuild(WarContext* context, WarUnitType buildingToBuild, s32 x, s32 y) { const WarUnitData* unitData = wu_getUnitData(buildingToBuild); if (!we_checkRectToBuild(context, x, y, unitData->sizex, unitData->sizey)) { wmui_setFlashStatus(context, 1.5f, wstr_fromCString("CAN'T BUILD THERE")); return false; } return true; } bool we_checkTileToBuildRoadOrWall(WarContext* context, s32 x, s32 y) { if (!we_checkRectToBuild(context, x, y, 1, 1)) { wmui_setFlashStatus(context, 1.5f, wstr_fromCString("CAN'T BUILD THERE")); return false; } return true; } WarEntityList* we_getNearUnits(WarContext* context, vec2 tilePosition, s32 distance) { TracyCZoneN(ctx, "GetNearUnits", 1); WarEntityList* nearUnits = (WarEntityList*)wm_alloc(sizeof(WarEntityList)); WarEntityListInit(nearUnits, WarEntityListNonFreeOptions); WarEntityList* units = we_getEntitiesOfType(context, WAR_ENTITY_TYPE_UNIT); for(s32 i = 0; i < units->count; i++) { WarEntity* other = units->items[i]; if (other && wu_tileInRange(context, other, tilePosition, distance)) { WarEntityListAdd(nearUnits, other); } } TracyCZoneEnd(ctx); return nearUnits; } WarEntity* we_getNearEnemy(WarContext* context, WarEntity* entity) { TracyCZoneN(ctx, "GetNearEnemy", 1); vec2 position = wu_getUnitCenterPosition(context, entity, true); WarEntityList* units = we_getEntitiesOfType(context, WAR_ENTITY_TYPE_UNIT); for(s32 i = 0; i < units->count; i++) { WarEntity* other = units->items[i]; if (other && wu_areEnemies(context, entity, other) && wu_canAttack(context, entity, other)) { if (wu_isUnit(other)) { WarUnitComponent* uc = we_getUnitComponent(context, other); if (uc && uc->invisible) continue; } if (wu_tileInRange(context, other, position, NEAR_ENEMY_RADIUS)) { TracyCZoneEnd(ctx); return other; } } } TracyCZoneEnd(ctx); return NULL; } bool we_isBeingAttackedBy(WarContext* context, WarEntity* entity, WarEntity* other) { if (!wst_isFollowing(context, other) && !wst_isMoving(context, other)) { WarState* attackState = wst_getAttackState(context, other); return attackState && attackState->attack.targetEntityId == entity->id; } return false; } bool we_isBeingAttacked(WarContext* context, WarEntity* entity) { TracyCZoneN(ctx, "we_isBeingAttacked", 1); bool result = false; WarEntityList* units = we_getEntitiesOfType(context, WAR_ENTITY_TYPE_UNIT); for(s32 i = 0; i < units->count; i++) { WarEntity* other = units->items[i]; if (we_isBeingAttackedBy(context, entity, other)) { result = true; break; } } TracyCZoneEnd(ctx); return result; } WarEntity* we_getAttacker(WarContext* context, WarEntity* entity) { TracyCZoneN(ctx, "we_getAttacker", 1); WarEntity* result = NULL; WarEntityList* units = we_getEntitiesOfType(context, WAR_ENTITY_TYPE_UNIT); for(s32 i = 0; i < units->count; i++) { WarEntity* other = units->items[i]; if (other && we_isBeingAttackedBy(context, entity, other)) { result = other; break; } } TracyCZoneEnd(ctx); return result; } WarEntity* we_getAttackTarget(WarContext* context, WarEntity* entity) { if (!wst_isFollowing(context, entity) && !wst_isMoving(context, entity)) { WarState* attackState = wst_getAttackState(context, entity); if (attackState) { WarEntityId targetEntityId = (WarEntityId)attackState->attack.targetEntityId; return we_findEntity(context, targetEntityId); } } return NULL; } s32 we_getTotalDamage(s32 minDamage, s32 rndDamage, s32 armor) { return minDamage + MAX(rndDamage - armor, 0); } void we_takeDamage(WarContext* context, WarEntity *entity, s32 minDamage, s32 rndDamage) { WarMap* map = context->map; assert(wu_isUnit(entity)); WarUnitComponent* unit = we_getUnitComponent(context, entity); assert(unit); if (unit->invulnerable) return; WarPlayerInfo* player = &map->players[unit->player]; if (player->godMode) return; // Minimal damage + [Random damage - Enemy's Armor] s32 damage = we_getTotalDamage(minDamage, rndDamage, unit->armor); we_decreaseUnitHp(context, entity, damage); if (unit->hp == 0) { if (wu_isBuildingUnit(context, entity)) { WarState* collapseState = wst_createCollapseState(context, entity); wst_changeNextState(context, entity, collapseState, true, true); wa_createAudioRandom(context, CREATE_AUDIO_ARGS_INIT(.randomFromId=WAR_BUILDING_COLLAPSE_1, .randomToId=WAR_BUILDING_COLLAPSE_3, .loop=false)); } else { vec2 position = wu_getUnitCenterPosition(context, entity, false); WarState* deathState = wst_createDeathState(context, entity); wst_changeNextState(context, entity, deathState, true, true); if (unit->type == WAR_UNIT_SCORPION || unit->type == WAR_UNIT_SPIDER) { wa_createAudioWithPosition(context, CREATE_AUDIO_ARGS_INIT(.audioId=WAR_DEAD_SPIDER_SCORPION, .position=position, .hasPosition=true, .loop=false)); } else if (unit->type == WAR_UNIT_CATAPULT_HUMANS || unit->type == WAR_UNIT_CATAPULT_ORCS) { wa_createAudioRandomWithPosition(context, CREATE_AUDIO_ARGS_INIT(.randomFromId=WAR_BUILDING_COLLAPSE_1, .randomToId=WAR_BUILDING_COLLAPSE_3, .position=position, .hasPosition=true, .loop=false)); } else { WarAudioId audioId = wu_isHumanUnit(context, entity)? WAR_HUMAN_DEAD : WAR_ORC_DEAD; wa_createAudioWithPosition(context, CREATE_AUDIO_ARGS_INIT(.audioId=audioId, .position=position, .hasPosition=true, .loop=false)); } } } else if (wu_isBuildingUnit(context, entity)) { s32 hpPercent = PERCENTABI(unit->hp, unit->maxhp); if(hpPercent <= 33) { if (!wanim_containsAnimation(context, entity, wsv_fromCString("hugeDamage"))) { wanim_removeAnimation(context, entity, wsv_fromCString("littleDamage")); wanim_createDamageAnimation(context, entity, wstr_fromCString("hugeDamage"), 2); } } else if(hpPercent <= 66) { if (!wanim_containsAnimation(context, entity, wsv_fromCString("littleDamage"))) { wanim_createDamageAnimation(context, entity, wstr_fromCString("littleDamage"), 1); } } } } void we_takeWallDamage(WarContext* context, WarEntity* entity, WarWallPiece* piece, s32 minDamage, s32 rndDamage) { NOT_USED(context); assert(wu_isWall(entity)); // Minimal damage + [Random damage - Enemy's Armor] s32 damage = we_getTotalDamage(minDamage, rndDamage, 0); piece->hp -= damage; piece->hp = MAX(piece->hp, 0); } void we_rangeAttack(WarContext* context, WarEntity* entity, WarEntity* targetEntity) { assert(wu_isUnit(entity)); WarUnitComponent* unit = we_getUnitComponent(context, entity); assert(unit); if (wu_isMagicUnit(context, entity)) { // Since the attack of magic units are considered "kind of spells" // it will consume mana, at 2 per shot. if (we_decreaseUnitMana(context, entity, 2)) { vec2 origin = wu_getUnitCenterPosition(context, entity, false); vec2 target = wu_getUnitCenterPosition(context, targetEntity, false); WarProjectileType projectileType = wu_getProjectileType(unit->type); wproj_createProjectile(context, projectileType, entity->id, targetEntity->id, origin, target); } else { // wcmd_stop attacking if the magic unit rans out of mana WarState* idleState = wst_createIdleState(context, entity, true); wst_changeNextState(context, entity, idleState, true, true); } } else { vec2 origin = wu_getUnitCenterPosition(context, entity, false); vec2 target = wu_getUnitCenterPosition(context, targetEntity, false); WarProjectileType projectileType = wu_getProjectileType(unit->type); wproj_createProjectile(context, projectileType, entity->id, targetEntity->id, origin, target); } } void we_rangeWallAttack(WarContext* context, WarEntity* entity, WarEntity* targetEntity, WarWallPiece* piece) { assert(wu_isUnit(entity)); WarUnitComponent* unit = we_getUnitComponent(context, entity); assert(unit); if (wu_isMagicUnit(context, entity)) { // Since the attack of magic units are considered "kind of spells" // it will consume mana, at 2 per shot. if (we_decreaseUnitMana(context, entity, 2)) { vec2 origin = wu_getUnitCenterPosition(context, entity, false); vec2 target = wmap_tileToMapCoordinatesV(vec2i(piece->tilex, piece->tiley), true); WarProjectileType projectileType = wu_getProjectileType(unit->type); wproj_createProjectile(context, projectileType, entity->id, targetEntity->id, origin, target); } else { // wcmd_stop attacking if the magic unit rans out of mana WarState* idleState = wst_createIdleState(context, entity, true); wst_changeNextState(context, entity, idleState, true, true); } } else { vec2 origin = wu_getUnitCenterPosition(context, entity, false); vec2 target = wmap_tileToMapCoordinatesV(vec2i(piece->tilex, piece->tiley), true); WarProjectileType projectileType = wu_getProjectileType(unit->type); wproj_createProjectile(context, projectileType, entity->id, targetEntity->id, origin, target); } } void we_meleeAttack(WarContext* context, WarEntity* entity, WarEntity* targetEntity) { WarMap* map = context->map; assert(wu_isUnit(entity)); WarUnitComponent* unit = we_getUnitComponent(context, entity); assert(unit); // every unit has a 20 percent chance to miss (except catapults) if (wu_isCatapultUnit(context, entity) || chance(80)) { s32 minDamage = unit->minDamage; s32 rndDamage = unit->rndDamage; WarPlayerInfo* player = &map->players[unit->player]; if (player->godMode) { minDamage = GOD_MODE_MIN_DAMAGE; } we_takeDamage(context, targetEntity, minDamage, rndDamage); } } void we_meleeWallAttack(WarContext* context, WarEntity* entity, WarEntity* targetEntity, WarWallPiece* piece) { WarMap* map = context->map; assert(wu_isUnit(entity)); WarUnitComponent* unit = we_getUnitComponent(context, entity); assert(unit); // every unit has a 20 percent chance to miss (except catapults) if (wu_isCatapultUnit(context, entity) || chance(80)) { s32 minDamage = unit->minDamage; s32 rndDamage = unit->rndDamage; WarPlayerInfo* player = &map->players[unit->player]; if (player->godMode) { minDamage = GOD_MODE_MIN_DAMAGE; } we_takeWallDamage(context, targetEntity, piece, minDamage, rndDamage); } } s32 mine(WarContext* context, WarEntity* goldmine, s32 amount) { assert(goldmine); assert(wu_isUnit(goldmine)); WarUnitComponent* unit = we_getUnitComponent(context, goldmine); assert(unit); if (unit->amount < amount) amount = unit->amount; unit->amount -= amount; unit->amount = MAX(unit->amount, 0); if (unit->amount == 0) { if (!wst_isCollapsing(context, goldmine) && !wst_isGoingToCollapse(context, goldmine)) { WarState* collapseState = wst_createCollapseState(context, goldmine); wst_changeNextState(context, goldmine, collapseState, true, true); wa_createAudioRandom(context, CREATE_AUDIO_ARGS_INIT(.randomFromId=WAR_BUILDING_COLLAPSE_1, .randomToId=WAR_BUILDING_COLLAPSE_3, .loop=false)); } } return amount; } ================================================ FILE: src/war_entities.h ================================================ #pragma once #include "shl/memzone.h" #include "shl/list.h" #include "shl/set.h" #include "shl/map.h" #include "common.h" #include "war.h" #include "war_animations.h" #include "war_audio.h" #include "war_font.h" #include "war_state_machine.h" #include "war_units.h" #include "war_resources.h" #define isEntityOfType(entity, entityType) ((entity)->type == (entityType)) struct _WarRoadPiece { WarRoadPieceType type; s32 tilex, tiley; u8 player; }; struct _WarWallPiece { WarWallPieceType type; s32 hp; s32 maxhp; s32 tilex, tiley; u8 player; }; struct _WarRuinPiece { WarRuinPieceType type; s32 tilex, tiley; }; struct _WarTree { WarTreeTileType type; s32 tilex, tiley; s32 amount; }; #define WarRoadPieceEmpty (WarRoadPiece){0} #define WarWallPieceEmpty (WarWallPiece){0} #define WarRuinPieceEmpty (WarRuinPiece){0} #define WarTreeEmpty (WarTree){0} #define createRoadPiece(x, y, player) ((WarRoadPiece){0, (x), (y), (u8)(player)}) #define createWallPiece(x, y, player) ((WarWallPiece){0, 0, 0, (x), (y), (u8)(player)}) #define createRuinPiece(x, y) ((WarRuinPiece){0, (x), (y)}) #define createTree(x, y, amount) ((WarTree){0, (x), (y), (amount)}) shlDeclareList(WarRoadPieceList, WarRoadPiece) shlDeclareList(WarWallPieceList, WarWallPiece) shlDeclareList(WarRuinPieceList, WarRuinPiece) shlDeclareList(WarTreeList, WarTree) shlDeclareList(WarEntityIdList, WarEntityId) shlDeclareSet(WarEntityIdSet, WarEntityId) shlDeclareList(WarEntityList, WarEntity*) shlDeclareMap(WarEntityMap, WarEntityType, WarEntityList*) shlDeclareMap(WarUnitMap, WarUnitType, WarEntityList*) shlDeclareMap(WarEntityIdMap, WarEntityId, WarEntity*) bool we_equalsRoadPiece(const WarRoadPiece r1, const WarRoadPiece r2); bool we_equalsWallPiece(const WarWallPiece w1, const WarWallPiece w2); bool we_equalsRuinPiece(const WarRuinPiece r1, const WarRuinPiece r2); bool we_equalsTree(const WarTree t1, const WarTree t2); bool we_equalsEntity(const WarEntity* e1, const WarEntity* e2); bool we_equalsEntityType(const WarEntityType t1, const WarEntityType t2); bool we_equalsEntityId(const WarEntityId id1, const WarEntityId id2); u32 we_hashEntityType(const WarEntityType type); u32 we_hashEntityId(const WarEntityId id); void we_freeEntity(WarEntity* e); void we_freeEntityList(WarEntityList* list); #define WarRoadPieceListDefaultOptions (WarRoadPieceListOptions){WarRoadPieceEmpty, we_equalsRoadPiece, NULL} #define WarWallPieceListDefaultOptions (WarWallPieceListOptions){WarWallPieceEmpty, we_equalsWallPiece, NULL} #define WarRuinPieceListDefaultOptions (WarRuinPieceListOptions){WarRuinPieceEmpty, we_equalsRuinPiece, NULL} #define WarTreeListDefaultOptions (WarTreeListOptions){WarTreeEmpty, we_equalsTree, NULL} #define WarEntityIdListDefaultOptions (WarEntityIdListOptions){0, we_equalsEntityId, NULL} #define WarEntityIdSetDefaultOptions (WarEntityIdSetOptions){0, we_hashEntityId, we_equalsEntityId, NULL} #define WarEntityListDefaultOptions (WarEntityListOptions){NULL, we_equalsEntity, we_freeEntity} #define WarEntityListNonFreeOptions (WarEntityListOptions){NULL, we_equalsEntity} struct _WarTransformComponent { vec2 position; vec2 rotation; vec2 scale; }; #define WAR_TRANSFORM_COMPONENT_INIT_CONST(...) { \ .position = {0}, \ .rotation = {0}, \ .scale = {1, 1}, \ __VA_ARGS__ \ } #define WAR_TRANSFORM_COMPONENT_INIT(...) ((WarTransformComponent)WAR_TRANSFORM_COMPONENT_INIT_CONST(__VA_ARGS__)) struct _WarSpriteComponent { s32 resourceIndex; s32 frameIndex; WarSprite sprite; }; #define WAR_SPRITE_COMPONENT_INIT_CONST(...) { \ .resourceIndex = 0, \ .frameIndex = 0, \ .sprite = {0}, \ __VA_ARGS__ \ } #define WAR_SPRITE_COMPONENT_INIT(...) ((WarSpriteComponent)WAR_SPRITE_COMPONENT_INIT_CONST(__VA_ARGS__)) struct _WarUnitComponent { WarUnitType type; WarUnitDirection direction; // position in tiles s32 tilex, tiley; // size in tiles s32 sizex, sizey; // index of the player this unit belongs to u8 player; // the units that can carry resources are // peasants, peons, goldmines and trees WarResourceKind resourceKind; s32 amount; // indicate if the unit is building something bool building; f32 buildPercent; // hit points, magic and armor s32 maxhp; s32 hp; s32 maxMana; s32 mana; s32 armor; s32 range; s32 minDamage; s32 rndDamage; s32 decay; bool invisible; bool invulnerable; bool hasBeenSeen; // index of the array of speeds of the unit s32 speed; // the current action index and per-unit mutable action states WarUnitActionType actionType; WarUnitAction actions[WAR_ACTION_TYPE_COUNT]; // time remainder (in seconds) until mana is affected f32 manaTime; // time remainder (in seconds) until the unit invisiblity ceases f32 invisibilityTime; // time remainder (in seconds) until the unit invulnerability ceases f32 invulnerabilityTime; }; #define WAR_UNIT_COMPONENT_INIT_CONST(...) { \ .type = 0, \ .direction = 0, \ .tilex = 0, \ .tiley = 0, \ .sizex = 1, \ .sizey = 1, \ .player = 0, \ .resourceKind = WAR_RESOURCE_NONE, \ .amount = 0, \ .building = false, \ .buildPercent = 0, \ .maxhp = 0, \ .hp = 0, \ .maxMana = 0, \ .mana = 0, \ .armor = 0, \ .range = 0, \ .minDamage = 0, \ .rndDamage = 0, \ .decay = 0, \ .invisible = false, \ .invulnerable = false, \ .hasBeenSeen = false, \ .speed = 0, \ .actionType = WAR_ACTION_TYPE_IDLE, \ .manaTime = 0, \ .invisibilityTime = 0, \ .invulnerabilityTime = 0, \ __VA_ARGS__ \ } #define WAR_UNIT_COMPONENT_INIT(...) ((WarUnitComponent)WAR_UNIT_COMPONENT_INIT_CONST(__VA_ARGS__)) struct _WarAnimationsComponent { WarSpriteAnimationList animations; }; struct _WarRoadComponent { WarRoadPieceList pieces; }; struct _WarWallComponent { WarWallPieceList pieces; }; struct _WarRuinComponent { WarRuinPieceList pieces; }; struct _WarForestComponent { WarTreeList trees; }; struct _WarStateMachineComponent { WarState* currentState; WarState* nextState; bool leaveState; bool enterState; }; #define WAR_STATE_MACHINE_COMPONENT_INIT_CONST(...) { \ .currentState = NULL, \ .nextState = NULL, \ .leaveState = false, \ .enterState = false, \ __VA_ARGS__ \ } #define WAR_STATE_MACHINE_COMPONENT_INIT(...) ((WarStateMachineComponent)WAR_STATE_MACHINE_COMPONENT_INIT_CONST(__VA_ARGS__)) struct _WarUIComponent { String name; }; struct _WarTextComponent { String text; s32 fontIndex; f32 fontSize; f32 lineHeight; WarColor fontColor; WarColor highlightColor; s32 highlightIndex; s32 highlightCount; vec2 boundings; WarTextAlignment horizontalAlign; WarTextAlignment verticalAlign; WarTextAlignment lineAlign; WarTextWrapping wrapping; WarTextTrimming trimming; bool multiline; }; #define WAR_TEXT_COMPONENT_INIT_CONST(...) { \ .fontIndex = 0, \ .fontSize = 10, \ .lineHeight = 0, \ .fontColor = FONT_NORMAL_COLOR_INIT, \ .highlightColor = FONT_HIGHLIGHT_COLOR_INIT, \ .highlightIndex = NO_HIGHLIGHT, \ .highlightCount = 0, \ .boundings = {0}, \ .horizontalAlign = WAR_TEXT_ALIGN_LEFT, \ .verticalAlign = WAR_TEXT_ALIGN_TOP, \ .lineAlign = WAR_TEXT_ALIGN_LEFT, \ .wrapping = WAR_TEXT_WRAP_NONE, \ .trimming = WAR_TEXT_TRIM_NONE, \ .multiline = false, \ __VA_ARGS__ \ } #define WAR_TEXT_COMPONENT_INIT(...) ((WarTextComponent)WAR_TEXT_COMPONENT_INIT_CONST(__VA_ARGS__)) struct _WarRectComponent { vec2 size; WarColor color; }; #define WAR_RECT_COMPONENT_INIT_CONST(...) { \ .size = {0}, \ .color = {0}, \ __VA_ARGS__ \ } #define WAR_RECT_COMPONENT_INIT(...) ((WarRectComponent)WAR_RECT_COMPONENT_INIT_CONST(__VA_ARGS__)) struct _WarButtonComponent { bool interactive; bool hot; bool active; WarKeys hotKey; s32 highlightIndex; s32 highlightCount; String tooltip; s32 gold; s32 wood; WarSprite normalSprite; WarSprite pressedSprite; WarClickHandler clickHandler; }; #define WAR_BUTTON_COMPONENT_INIT_CONST(...) { \ .interactive = true, \ .hot = false, \ .active = false, \ .hotKey = WAR_KEY_NONE, \ .highlightIndex = NO_HIGHLIGHT, \ .highlightCount = 0, \ .tooltip = {0}, \ .gold = 0, \ .wood = 0, \ .normalSprite = {0}, \ .pressedSprite = {0}, \ .clickHandler = NULL, \ __VA_ARGS__ \ } #define WAR_BUTTON_COMPONENT_INIT(...) ((WarButtonComponent)WAR_BUTTON_COMPONENT_INIT_CONST(__VA_ARGS__)) struct _WarCursorComponent { WarCursorType type; vec2 hot; }; #define WAR_CURSOR_COMPONENT_INIT_CONST(...) { \ .type = WAR_CURSOR_ARROW, \ .hot = {0}, \ __VA_ARGS__ \ } #define WAR_CURSOR_COMPONENT_INIT(...) ((WarCursorComponent)WAR_CURSOR_COMPONENT_INIT_CONST(__VA_ARGS__)) struct _WarProjectileComponent { WarProjectileType type; WarEntityId sourceEntityId; WarEntityId targetEntityId; vec2 origin; vec2 target; s32 speed; }; #define WAR_PROJECTILE_COMPONENT_INIT_CONST(...) { \ .type = 0, \ .sourceEntityId = 0, \ .targetEntityId = 0, \ .origin = {0}, \ .target = {0}, \ .speed = 0, \ __VA_ARGS__ \ } #define WAR_PROJECTILE_COMPONENT_INIT(...) ((WarProjectileComponent)WAR_PROJECTILE_COMPONENT_INIT_CONST(__VA_ARGS__)) struct _WarPoisonCloudComponent { vec2 position; f32 time; // time in seconds left of the spell f32 damageTime; // time in seconds left to inflict damage String animName; }; #define WAR_POISON_CLOUD_COMPONENT_INIT_CONST(...) { \ .position = {0}, \ .time = 0, \ .damageTime = 0, \ .animName = {0}, \ __VA_ARGS__ \ } #define WAR_POISON_CLOUD_COMPONENT_INIT(...) ((WarPoisonCloudComponent)WAR_POISON_CLOUD_COMPONENT_INIT_CONST(__VA_ARGS__)) struct _WarSightComponent { vec2 position; f32 time; // time in seconds left of the spell }; #define WAR_SIGHT_COMPONENT_INIT_CONST(...) { \ .position = {0}, \ .time = 0, \ __VA_ARGS__ \ } #define WAR_SIGHT_COMPONENT_INIT(...) ((WarSightComponent)WAR_SIGHT_COMPONENT_INIT_CONST(__VA_ARGS__)) struct _WarEntity { WarEntityId id; u16 type; // WarEntityType cast to u16 u16 components[MAX_COMPONENTS_COUNT]; // INVALID_COMP_INDEX = absent }; static_assert(sizeof(WarEntity) == 64, "WarEntity must be 64 bytes"); #define DEFINE_COMPONENT_STORAGE(name, type) typedef struct \ { \ bool enabled[MAX_ENTITIES_COUNT]; \ type dense[MAX_ENTITIES_COUNT]; \ WarEntityId owners[MAX_ENTITIES_COUNT]; \ s32 count; \ } name DEFINE_COMPONENT_STORAGE(WarTransformStorage, WarTransformComponent); DEFINE_COMPONENT_STORAGE(WarSpriteStorage, WarSpriteComponent); DEFINE_COMPONENT_STORAGE(WarUnitStorage, WarUnitComponent); DEFINE_COMPONENT_STORAGE(WarAnimationsStorage, WarAnimationsComponent); DEFINE_COMPONENT_STORAGE(WarRoadStorage, WarRoadComponent); DEFINE_COMPONENT_STORAGE(WarWallStorage, WarWallComponent); DEFINE_COMPONENT_STORAGE(WarRuinStorage, WarRuinComponent); DEFINE_COMPONENT_STORAGE(WarForestStorage, WarForestComponent); DEFINE_COMPONENT_STORAGE(WarStateMachineStorage, WarStateMachineComponent); DEFINE_COMPONENT_STORAGE(WarUIStorage, WarUIComponent); DEFINE_COMPONENT_STORAGE(WarTextStorage, WarTextComponent); DEFINE_COMPONENT_STORAGE(WarRectStorage, WarRectComponent); DEFINE_COMPONENT_STORAGE(WarButtonStorage, WarButtonComponent); DEFINE_COMPONENT_STORAGE(WarAudioStorage, WarAudioComponent); DEFINE_COMPONENT_STORAGE(WarCursorStorage, WarCursorComponent); DEFINE_COMPONENT_STORAGE(WarProjectileStorage, WarProjectileComponent); DEFINE_COMPONENT_STORAGE(WarPoisonCloudStorage, WarPoisonCloudComponent); DEFINE_COMPONENT_STORAGE(WarSightStorage, WarSightComponent); struct _WarEntityManager { // --- Entity pool (flat array, slot 0 reserved/empty) --- WarEntity entities[MAX_ENTITIES_COUNT]; s32 entityCount; s32 nextEntityId; // monotonic; replaces staticEntityId // --- Secondary indices (kept for O(1) typed queries) --- WarEntityMap entitiesByType; // WarEntityType -> WarEntityList* WarUnitMap unitsByType; // WarUnitType -> WarEntityList* WarEntityIdMap entitiesById; // WarEntityId -> WarEntity* WarEntityList uiEntities; // subset of entities with COMP_UI present // --- Per-component dense storage --- WarTransformStorage transforms; WarSpriteStorage sprites; WarUnitStorage units; WarAnimationsStorage animations; WarRoadStorage roads; WarWallStorage walls; WarRuinStorage ruins; WarForestStorage forests; WarStateMachineStorage stateMachines; WarUIStorage uis; WarTextStorage texts; WarRectStorage rects; WarButtonStorage buttons; WarAudioStorage audios; WarCursorStorage cursors; WarProjectileStorage projectiles; WarPoisonCloudStorage poisonClouds; WarSightStorage sights; }; bool we_isComponentEnabled(WarContext* context, WarEntity* entity, WarComponentType componentType); void we_setComponentEnabled(WarContext* context, WarEntity* entity, WarComponentType componentType, bool enabled); void we_enableComponent(WarContext* context, WarEntity* entity, WarComponentType componentType); void we_disableComponent(WarContext* context, WarEntity* entity, WarComponentType componentType); WarTransformComponent* we_getTransformComponent(WarContext* context, const WarEntity* entity); WarSpriteComponent* we_getSpriteComponent(WarContext* context, const WarEntity* entity); WarUnitComponent* we_getUnitComponent(WarContext* context, const WarEntity* entity); WarAnimationsComponent* we_getAnimationsComponent(WarContext* context, const WarEntity* entity); WarRoadComponent* we_getRoadComponent(WarContext* context, const WarEntity* entity); WarWallComponent* we_getWallComponent(WarContext* context, const WarEntity* entity); WarRuinComponent* we_getRuinComponent(WarContext* context, const WarEntity* entity); WarForestComponent* we_getForestComponent(WarContext* context, const WarEntity* entity); WarStateMachineComponent* we_getStateMachineComponent(WarContext* context, const WarEntity* entity); WarUIComponent* we_getUIComponent(WarContext* context, const WarEntity* entity); WarTextComponent* we_getTextComponent(WarContext* context, const WarEntity* entity); WarRectComponent* we_getRectComponent(WarContext* context, const WarEntity* entity); WarButtonComponent* we_getButtonComponent(WarContext* context, const WarEntity* entity); WarAudioComponent* we_getAudioComponent(WarContext* context, const WarEntity* entity); WarCursorComponent* we_getCursorComponent(WarContext* context, const WarEntity* entity); WarProjectileComponent* we_getProjectileComponent(WarContext* context, const WarEntity* entity); WarPoisonCloudComponent* we_getPoisonCloudComponent(WarContext* context, const WarEntity* entity); WarSightComponent* we_getSightComponent(WarContext* context, const WarEntity* entity); WarTransformComponent* we_addTransformComponent(WarContext* context, WarEntity* entity, WarTransformComponent params); void we_removeTransformComponent(WarContext* context, WarEntity* entity); WarSpriteComponent* we_addSpriteComponent(WarContext* context, WarEntity* entity, WarSpriteComponent params); WarSpriteComponent* we_addSpriteComponentFromResource(WarContext* context, WarEntity* entity, WarSpriteResourceRef spriteResourceRef); void we_removeSpriteComponent(WarContext* context, WarEntity* entity); WarUnitComponent* we_addUnitComponent(WarContext* context, WarEntity* entity, WarUnitComponent params); void we_removeUnitComponent(WarContext* context, WarEntity* entity); WarRoadComponent* we_addRoadComponent(WarContext* context, WarEntity* entity, WarRoadPieceList pieces); void we_removeRoadComponent(WarContext* context, WarEntity* entity); WarWallComponent* we_addWallComponent(WarContext* context, WarEntity* entity, WarWallPieceList pieces); void we_removeWallComponent(WarContext* context, WarEntity* entity); WarRuinComponent* we_addRuinComponent(WarContext* context, WarEntity* entity, WarRuinPieceList pieces); void we_removeRuinComponent(WarContext* context, WarEntity* entity); WarForestComponent* we_addForestComponent(WarContext* context, WarEntity* entity, WarTreeList trees); void we_removeForestComponent(WarContext* context, WarEntity* entity); WarStateMachineComponent* we_addStateMachineComponent(WarContext* context, WarEntity* entity); void we_removeStateMachineComponent(WarContext* context, WarEntity* entity); WarAnimationsComponent* we_addAnimationsComponent(WarContext* context, WarEntity* entity); void we_removeAnimationsComponent(WarContext* context, WarEntity* entity); WarUIComponent* we_addUIComponent(WarContext* context, WarEntity* entity, String name); void we_removeUIComponent(WarContext* context, WarEntity* entity); WarTextComponent* we_addTextComponent(WarContext* context, WarEntity* entity, WarTextComponent params); void we_removeTextComponent(WarContext* context, WarEntity* entity); WarRectComponent* we_addRectComponent(WarContext* context, WarEntity* entity, WarRectComponent params); void we_removeRectComponent(WarContext* context, WarEntity* entity); WarButtonComponent* we_addButtonComponent(WarContext* context, WarEntity* entity, WarButtonComponent params); WarButtonComponent* we_addButtonComponentFromResource(WarContext* context, WarEntity* entity, WarSpriteResourceRef normalRef, WarSpriteResourceRef pressedRef); void we_removeButtonComponent(WarContext* context, WarEntity* entity); WarAudioComponent* we_addAudioComponent(WarContext* context, WarEntity* entity, WarAudioComponent params); void we_removeAudioComponent(WarContext* context, WarEntity* entity); WarCursorComponent* we_addCursorComponent(WarContext* context, WarEntity* entity, WarCursorComponent params); void we_removeCursorComponent(WarContext* context, WarEntity* entity); WarProjectileComponent* we_addProjectileComponent(WarContext* context, WarEntity* entity, WarProjectileComponent params); void we_removeProjectileComponent(WarContext* context, WarEntity* entity); WarPoisonCloudComponent* we_addPoisonCloudComponent(WarContext* context, WarEntity* entity, WarPoisonCloudComponent params); void we_removePoisonCloudComponent(WarContext* context, WarEntity* entity); WarSightComponent* we_addSightComponent(WarContext* context, WarEntity* entity, WarSightComponent params); void we_removeSightComponent(WarContext* context, WarEntity* entity); // Roads WarEntity* we_createRoad(WarContext* context); void we_addRoadPiece(WarContext* context, WarEntity* entity, s32 x, s32 y, s32 player); void we_addRoadPiecesFromConstruct(WarContext* context, WarEntity* entity, WarLevelConstruct *construct); bool we_hasRoadPieceAtPosition(WarContext* context, WarEntity* entity, s32 x, s32 y); WarRoadPiece* we_getRoadPieceAtPosition(WarContext* context, WarEntity* entity, s32 x, s32 y); void we_removeRoadPiece(WarContext* context, WarEntity* entity, WarRoadPiece* piece); void we_determineRoadTypes(WarContext* context, WarEntity* entity); // Walls WarEntity* we_createWall(WarContext* context); WarWallPiece* we_addWallPiece(WarContext* context, WarEntity* entity, s32 x, s32 y, s32 player); void we_addWallPiecesFromConstruct(WarContext* context, WarEntity* entity, WarLevelConstruct *construct); bool we_hasWallPieceAtPosition(WarContext* context, WarEntity* entity, s32 x, s32 y); WarWallPiece* we_getWallPieceAtPosition(WarContext* context, WarEntity* entity, s32 x, s32 y); void we_removeWallPiece(WarContext* context, WarEntity* entity, WarWallPiece* piece); void we_determineWallTypes(WarContext* context, WarEntity* entity); void we_takeWallDamage(WarContext* context, WarEntity* entity, WarWallPiece* piece, s32 minDamage, s32 rndDamage); // Ruins WarEntity* we_createRuins(WarContext* context); void we_addRuinsPieces(WarContext* context, WarEntity* entity, s32 x, s32 y, s32 dim); bool we_hasRuinPieceAtPosition(WarContext* context, WarEntity* ruins, s32 x, s32 y); WarRuinPiece* we_getRuinPieceAtPosition(WarContext* context, WarEntity* ruins, s32 x, s32 y); void we_removeRuinPiece(WarContext* context, WarEntity* entity, WarRuinPiece* piece); void we_determineRuinTypes(WarContext* context, WarEntity* entity); // Trees bool we_hasTreeAtPosition(WarContext* context, WarEntity* forest, s32 x, s32 y); WarTree* we_getTreeAtPosition(WarContext* context, WarEntity* forest, s32 x, s32 y); void we_determineTreeTiles(WarContext* context, WarEntity* forest); void we_determineAllTreeTiles(WarContext* context); WarTree* we_findAccesibleTree(WarContext* context, WarEntity* forest, vec2 position); void we_plantTree(WarContext* context, WarEntity* forest, s32 x, s32 y); bool we_validTree(WarContext* context, WarEntity* forest, WarTree* tree); s32 we_chopTree(WarContext* context, WarEntity* forest, WarTree* tree, s32 amount); // Entities WarEntity* we_createEntity(WarContext* context, WarEntityType type, bool addToMap); typedef struct { WarUnitType type; s32 x; s32 y; u8 player; WarResourceKind resourceKind; u32 amount; bool addToMap; bool isGoingToTrain; bool isGoingToBuild; } CreateUnitArgs; #define CREATE_UNIT_ARGS_INIT_CONST(...) { \ .type = 0, \ .x = 0, \ .y = 0, \ .player = 0, \ .resourceKind = WAR_RESOURCE_NONE, \ .amount = 0, \ .addToMap = true, \ .isGoingToTrain = false, \ .isGoingToBuild = false, \ __VA_ARGS__ \ } #define CREATE_UNIT_ARGS_INIT(...) (&(CreateUnitArgs)CREATE_UNIT_ARGS_INIT_CONST(__VA_ARGS__)) WarEntity* we_createUnit(WarContext* context, const CreateUnitArgs* args); WarEntity* we_createDude(WarContext* context, const CreateUnitArgs* args); WarEntity* we_createBuilding(WarContext* context, const CreateUnitArgs* args); WarEntity* we_findEntity(WarContext* context, WarEntityId id); WarEntity* we_findClosestUnitOfType(WarContext* context, WarEntity* entity, WarUnitType type); WarEntity* we_findUIEntity(WarContext* context, StringView name); WarEntity* we_findEntityUnderCursor(WarContext* context, bool includeTrees, bool includeWalls); void we_removeEntity(WarContext* context, WarEntity* entity); void we_removeEntityById(WarContext* context, WarEntityId id); void we_renderEntity(WarContext* context, WarEntity* entity); void we_renderEntitiesOfType(WarContext* context, WarEntityType type); void we_renderUnitSelection(WarContext* context); void we_initEntityManager(WarContext* context, WarEntityManager* manager); WarEntityManager* we_getEntityManager(WarContext* context); WarEntityList* we_getEntitiesOfType(WarContext* context, WarEntityType type); WarEntityList* we_getUnitsOfType(WarContext* context, WarUnitType type); WarEntityList* we_getUIEntities(WarContext* context); void we_increaseUpgradeLevel(WarContext* context, WarPlayerInfo* player, WarUpgradeType upgrade); bool we_enoughPlayerResources(WarContext* context, WarPlayerInfo* player, s32 gold, s32 wood); bool we_decreasePlayerResources(WarContext* context, WarPlayerInfo* player, s32 gold, s32 wood); void we_increasePlayerResources(WarContext* context, WarPlayerInfo* player, s32 gold, s32 wood); bool we_increaseUnitHp(WarContext* context, WarEntity* entity, s32 hp); bool we_decreaseUnitHp(WarContext* context, WarEntity* entity, s32 hp); bool we_decreaseUnitMana(WarContext* context, WarEntity* entity, s32 mana); void we_increaseUnitMana(WarContext* context, WarEntity* entity, s32 mana); bool we_enoughFarmFood(WarContext* context, WarPlayerInfo* player); bool we_checkFarmFood(WarContext* context, WarPlayerInfo* player); bool we_checkRectToBuild(WarContext* context, s32 x, s32 y, s32 w, s32 h); bool we_checkTileToBuild(WarContext* context, WarUnitType buildingToBuild, s32 x, s32 y); bool we_checkTileToBuildRoadOrWall(WarContext* context, s32 x, s32 y); WarEntityList* we_getNearUnits(WarContext* context, vec2 tilePosition, s32 distance); WarEntity* we_getNearEnemy(WarContext* context, WarEntity* entity); bool we_isBeingAttackedBy(WarContext* context, WarEntity* entity, WarEntity* other); bool we_isBeingAttacked(WarContext* context, WarEntity* entity); WarEntity* we_getAttacker(WarContext* context, WarEntity* entity); WarEntity* we_getAttackTarget(WarContext* context, WarEntity* entity); s32 we_getTotalDamage(s32 minDamage, s32 rndDamage, s32 armor); void we_takeDamage(WarContext* context, WarEntity *entity, s32 minDamage, s32 rndDamage); void we_rangeAttack(WarContext* context, WarEntity* entity, WarEntity* targetEntity); void we_rangeWallAttack(WarContext* context, WarEntity* entity, WarEntity* targetEntity, WarWallPiece* piece); void we_meleeAttack(WarContext* context, WarEntity* entity, WarEntity* targetEntity); void we_meleeWallAttack(WarContext* context, WarEntity* entity, WarEntity* targetEntity, WarWallPiece* piece); s32 mine(WarContext* context, WarEntity* goldmine, s32 amount); ================================================ FILE: src/war_enums.h ================================================ #pragma once // NOTE: All the enums in the game are defined here // Cannot forward declare enums in C, as it's not allowed by the C standard typedef enum { DB_ENTRY_TYPE_UNKNOWN, DB_ENTRY_TYPE_IMAGE, DB_ENTRY_TYPE_PALETTE, DB_ENTRY_TYPE_XMID, DB_ENTRY_TYPE_CURSOR, DB_ENTRY_TYPE_UI, DB_ENTRY_TYPE_TEXT, DB_ENTRY_TYPE_LEVEL_INFO, DB_ENTRY_TYPE_LEVEL_VISUAL, DB_ENTRY_TYPE_LEVEL_PASSABLE, DB_ENTRY_TYPE_SPRITE, DB_ENTRY_TYPE_WAVE, DB_ENTRY_TYPE_VOC, DB_ENTRY_TYPE_TILESET, DB_ENTRY_TYPE_TILES } DatabaseEntryType; typedef enum _WarMouseButtons { WAR_MOUSE_LEFT, WAR_MOUSE_RIGHT, WAR_MOUSE_COUNT } WarMouseButtons; typedef enum _WarKeys { WAR_KEY_NONE, WAR_KEY_SPACE, WAR_KEY_APOSTROPHE, WAR_KEY_ASTERISK, WAR_KEY_PLUS, WAR_KEY_COMMA, WAR_KEY_MINUS, WAR_KEY_PERIOD, WAR_KEY_SLASH, WAR_KEY_0, WAR_KEY_1, WAR_KEY_2, WAR_KEY_3, WAR_KEY_4, WAR_KEY_5, WAR_KEY_6, WAR_KEY_7, WAR_KEY_8, WAR_KEY_9, WAR_KEY_SEMICOLON, WAR_KEY_EQUAL, WAR_KEY_A, WAR_KEY_B, WAR_KEY_C, WAR_KEY_D, WAR_KEY_E, WAR_KEY_F, WAR_KEY_G, WAR_KEY_H, WAR_KEY_I, WAR_KEY_J, WAR_KEY_K, WAR_KEY_L, WAR_KEY_M, WAR_KEY_N, WAR_KEY_O, WAR_KEY_P, WAR_KEY_Q, WAR_KEY_R, WAR_KEY_S, WAR_KEY_T, WAR_KEY_U, WAR_KEY_V, WAR_KEY_W, WAR_KEY_X, WAR_KEY_Y, WAR_KEY_Z, WAR_KEY_LEFT_BRACKET, WAR_KEY_BACKSLASH, WAR_KEY_RIGHT_BRACKET, WAR_KEY_GRAVE_ACCENT, WAR_KEY_ESC, WAR_KEY_ENTER, WAR_KEY_TAB, WAR_KEY_BACKSPACE, WAR_KEY_INSERT, WAR_KEY_DELETE, WAR_KEY_RIGHT, WAR_KEY_LEFT, WAR_KEY_DOWN, WAR_KEY_UP, WAR_KEY_PAGE_UP, WAR_KEY_PAGE_DOWN, WAR_KEY_HOME, WAR_KEY_END, WAR_KEY_F1, WAR_KEY_F2, WAR_KEY_F3, WAR_KEY_F4, WAR_KEY_F5, WAR_KEY_F6, WAR_KEY_F7, WAR_KEY_F8, WAR_KEY_F9, WAR_KEY_F10, WAR_KEY_F11, WAR_KEY_F12, WAR_KEY_SHIFT, WAR_KEY_CTRL, WAR_KEY_ALT, WAR_KEY_COUNT } WarKeys; typedef enum _WarFileType { WAR_FILE_TYPE_UNKNOWN, WAR_FILE_TYPE_DEMO, WAR_FILE_TYPE_RETAIL } WarFileType; typedef enum _WarResourceType { WAR_RESOURCE_TYPE_UNKNOWN, WAR_RESOURCE_TYPE_IMAGE, WAR_RESOURCE_TYPE_PALETTE, WAR_RESOURCE_TYPE_XMID, WAR_RESOURCE_TYPE_CURSOR, WAR_RESOURCE_TYPE_UI, WAR_RESOURCE_TYPE_TEXT, WAR_RESOURCE_TYPE_LEVEL_INFO, WAR_RESOURCE_TYPE_LEVEL_VISUAL, WAR_RESOURCE_TYPE_LEVEL_PASSABLE, WAR_RESOURCE_TYPE_SPRITE, WAR_RESOURCE_TYPE_WAVE, WAR_RESOURCE_TYPE_VOC, WAR_RESOURCE_TYPE_TILESET, WAR_RESOURCE_TYPE_TILES } WarResourceType; typedef enum _WarLevelInfoType { WAR_LEVEL_TYPE_UNKOWN, WAR_LEVEL_TYPE_1, WAR_LEVEL_TYPE_2, WAR_LEVEL_TYPE_3 } WarLevelInfoType; typedef enum _WarRace { WAR_RACE_NEUTRAL, WAR_RACE_HUMANS, WAR_RACE_ORCS } WarRace; typedef enum _WarUnitDirection { WAR_DIRECTION_NORTH, WAR_DIRECTION_NORTH_EAST, WAR_DIRECTION_EAST, WAR_DIRECTION_SOUTH_EAST, WAR_DIRECTION_SOUTH, WAR_DIRECTION_SOUTH_WEST, WAR_DIRECTION_WEST, WAR_DIRECTION_NORTH_WEST, WAR_DIRECTION_COUNT } WarUnitDirection; typedef enum _WarUnitType { // units WAR_UNIT_FOOTMAN, WAR_UNIT_GRUNT, WAR_UNIT_PEASANT, WAR_UNIT_PEON, WAR_UNIT_CATAPULT_HUMANS, WAR_UNIT_CATAPULT_ORCS, WAR_UNIT_KNIGHT, WAR_UNIT_RAIDER, WAR_UNIT_ARCHER, WAR_UNIT_SPEARMAN, WAR_UNIT_CONJURER, WAR_UNIT_WARLOCK, WAR_UNIT_CLERIC, WAR_UNIT_NECROLYTE, WAR_UNIT_MEDIVH, WAR_UNIT_LOTHAR, WAR_UNIT_WOUNDED, WAR_UNIT_GRIZELDA, WAR_UNIT_GARONA, WAR_UNIT_OGRE, WAR_UNIT_SPIDER, WAR_UNIT_SLIME, WAR_UNIT_FIRE_ELEMENTAL, WAR_UNIT_SCORPION, WAR_UNIT_BRIGAND, WAR_UNIT_THE_DEAD, WAR_UNIT_SKELETON, WAR_UNIT_DAEMON, WAR_UNIT_WATER_ELEMENTAL, WAR_UNIT_DRAGON_CYCLOPS_GIANT, WAR_UNIT_26, WAR_UNIT_30, // buildings WAR_UNIT_FARM_HUMANS, WAR_UNIT_FARM_ORCS, WAR_UNIT_BARRACKS_HUMANS, WAR_UNIT_BARRACKS_ORCS, WAR_UNIT_CHURCH, WAR_UNIT_TEMPLE, WAR_UNIT_TOWER_HUMANS, WAR_UNIT_TOWER_ORCS, WAR_UNIT_TOWNHALL_HUMANS, WAR_UNIT_TOWNHALL_ORCS, WAR_UNIT_LUMBERMILL_HUMANS, WAR_UNIT_LUMBERMILL_ORCS, WAR_UNIT_STABLE, WAR_UNIT_KENNEL, WAR_UNIT_BLACKSMITH_HUMANS, WAR_UNIT_BLACKSMITH_ORCS, WAR_UNIT_STORMWIND, WAR_UNIT_BLACKROCK, // neutral WAR_UNIT_GOLDMINE, WAR_UNIT_51, // others WAR_UNIT_HUMAN_CORPSE, WAR_UNIT_ORC_CORPSE, WAR_UNIT_COUNT } WarUnitType; typedef enum _WarAnimationStatus { WAR_ANIM_STATUS_NOT_STARTED, WAR_ANIM_STATUS_RUNNING, WAR_ANIM_STATUS_FINISHED } WarAnimationStatus; typedef enum _WarResourceKind { WAR_RESOURCE_NONE, WAR_RESOURCE_GOLD, WAR_RESOURCE_WOOD } WarResourceKind; typedef enum _WarConstructType { WAR_CONSTRUCT_UNKOWN, WAR_CONSTRUCT_ROAD, WAR_CONSTRUCT_WALL } WarConstructType; typedef enum _WarCampaignMapType { WAR_CAMPAIGN_HUMANS_01 = 117, WAR_CAMPAIGN_ORCS_01, WAR_CAMPAIGN_HUMANS_02, WAR_CAMPAIGN_ORCS_02, WAR_CAMPAIGN_HUMANS_03, WAR_CAMPAIGN_ORCS_03, WAR_CAMPAIGN_HUMANS_04, WAR_CAMPAIGN_ORCS_04, WAR_CAMPAIGN_HUMANS_05, WAR_CAMPAIGN_ORCS_05, WAR_CAMPAIGN_HUMANS_06, WAR_CAMPAIGN_ORCS_06, WAR_CAMPAIGN_HUMANS_07, WAR_CAMPAIGN_ORCS_07, WAR_CAMPAIGN_HUMANS_08, WAR_CAMPAIGN_ORCS_08, WAR_CAMPAIGN_HUMANS_09, WAR_CAMPAIGN_ORCS_09, WAR_CAMPAIGN_HUMANS_10, WAR_CAMPAIGN_ORCS_10, WAR_CAMPAIGN_HUMANS_11, WAR_CAMPAIGN_ORCS_11, WAR_CAMPAIGN_HUMANS_12, WAR_CAMPAIGN_ORCS_12, WAR_CAMPAIGN_CUSTOM } WarCampaignMapType; typedef enum _WarLevelResult { WAR_LEVEL_RESULT_NONE, WAR_LEVEL_RESULT_WIN, WAR_LEVEL_RESULT_LOSE } WarLevelResult; typedef enum _WarMenuState { WAR_MENU_STATE_NONE, WAR_MENU_STATE_MAIN, WAR_MENU_STATE_OPTIONS, WAR_MENU_STATE_OBJECTIVES, WAR_MENU_STATE_RESTART, WAR_MENU_STATE_GAME_OVER, WAR_MENU_STATE_QUIT, WAR_MENU_STATE_DEMO_END } WarMenuState; typedef enum _WarFeatureType { WAR_FEATURE_UNIT_FOOTMAN, WAR_FEATURE_UNIT_GRUNT, WAR_FEATURE_UNIT_PEASANT, WAR_FEATURE_UNIT_PEON, WAR_FEATURE_UNIT_CATAPULT_HUMANS, WAR_FEATURE_UNIT_CATAPULT_ORCS, WAR_FEATURE_UNIT_KNIGHT, WAR_FEATURE_UNIT_RAIDER, WAR_FEATURE_UNIT_ARCHER, WAR_FEATURE_UNIT_SPEARMAN, WAR_FEATURE_UNIT_CONJURER, WAR_FEATURE_UNIT_WARLOCK, WAR_FEATURE_UNIT_CLERIC, WAR_FEATURE_UNIT_NECROLYTE, WAR_FEATURE_UNIT_FARM_HUMANS, WAR_FEATURE_UNIT_FARM_ORCS, WAR_FEATURE_UNIT_BARRACKS_HUMANS, WAR_FEATURE_UNIT_BARRACKS_ORCS, WAR_FEATURE_UNIT_CHURCH, WAR_FEATURE_UNIT_TEMPLE, WAR_FEATURE_UNIT_TOWER_HUMANS, WAR_FEATURE_UNIT_TOWER_ORCS, WAR_FEATURE_UNIT_TOWN_HALL_HUMANS, WAR_FEATURE_UNIT_TOWN_HALL_ORCS, WAR_FEATURE_UNIT_LUMBER_MILL_HUMANS, WAR_FEATURE_UNIT_LUMBER_MILL_ORCS, WAR_FEATURE_UNIT_STABLE, WAR_FEATURE_UNIT_KENNEL, WAR_FEATURE_UNIT_BLACKSMITH_HUMANS, WAR_FEATURE_UNIT_BLACKSMITH_ORCS, WAR_FEATURE_SPELL_HEALING, WAR_FEATURE_SPELL_RAISE_DEAD, WAR_FEATURE_SPELL_FAR_SIGHT, WAR_FEATURE_SPELL_DARK_VISION, WAR_FEATURE_SPELL_INVISIBILITY, WAR_FEATURE_SPELL_UNHOLY_ARMOR, WAR_FEATURE_SPELL_SCORPION, WAR_FEATURE_SPELL_SPIDER, WAR_FEATURE_SPELL_RAIN_OF_FIRE, WAR_FEATURE_SPELL_POISON_CLOUD, WAR_FEATURE_SPELL_WATER_ELEMENTAL, WAR_FEATURE_SPELL_DAEMON, WAR_FEATURE_UNIT_ROAD, WAR_FEATURE_UNIT_WALL, } WarFeatureType; typedef enum _WarUpgradeType { WAR_UPGRADE_ARROWS, WAR_UPGRADE_SPEARS, WAR_UPGRADE_SWORDS, WAR_UPGRADE_AXES, WAR_UPGRADE_HORSES, WAR_UPGRADE_WOLVES, WAR_UPGRADE_SCORPIONS, WAR_UPGRADE_SPIDERS, WAR_UPGRADE_RAIN_OF_FIRE, WAR_UPGRADE_POISON_CLOUD, WAR_UPGRADE_WATER_ELEMENTAL, WAR_UPGRADE_DAEMON, WAR_UPGRADE_HEALING, WAR_UPGRADE_RAISE_DEAD, WAR_UPGRADE_FAR_SIGHT, WAR_UPGRADE_DARK_VISION, WAR_UPGRADE_INVISIBILITY, WAR_UPGRADE_UNHOLY_ARMOR, WAR_UPGRADE_SHIELD } WarUpgradeType; typedef enum _WarSpellType { // spells WAR_SPELL_HEALING, WAR_SPELL_FAR_SIGHT, WAR_SPELL_INVISIBILITY, WAR_SPELL_RAIN_OF_FIRE, WAR_SPELL_POISON_CLOUD, WAR_SPELL_RAISE_DEAD, WAR_SPELL_DARK_VISION, WAR_SPELL_UNHOLY_ARMOR, // summons WAR_SUMMON_SPIDER, WAR_SUMMON_SCORPION, WAR_SUMMON_DAEMON, WAR_SUMMON_WATER_ELEMENTAL, } WarSpellType; typedef enum _WarUnitCommandType { WAR_COMMAND_NONE, // 0 // unit commands WAR_COMMAND_MOVE, // 1 WAR_COMMAND_STOP, WAR_COMMAND_HARVEST, WAR_COMMAND_DELIVER, WAR_COMMAND_REPAIR, WAR_COMMAND_ATTACK, // train commands WAR_COMMAND_TRAIN_FOOTMAN, // 7 WAR_COMMAND_TRAIN_GRUNT, WAR_COMMAND_TRAIN_PEASANT, WAR_COMMAND_TRAIN_PEON, WAR_COMMAND_TRAIN_CATAPULT_HUMANS, WAR_COMMAND_TRAIN_CATAPULT_ORCS, WAR_COMMAND_TRAIN_KNIGHT, WAR_COMMAND_TRAIN_RAIDER, WAR_COMMAND_TRAIN_ARCHER, WAR_COMMAND_TRAIN_SPEARMAN, WAR_COMMAND_TRAIN_CONJURER, WAR_COMMAND_TRAIN_WARLOCK, WAR_COMMAND_TRAIN_CLERIC, WAR_COMMAND_TRAIN_NECROLYTE, // spell commands WAR_COMMAND_SPELL_HEALING, // 21 WAR_COMMAND_SPELL_FAR_SIGHT, WAR_COMMAND_SPELL_INVISIBILITY, WAR_COMMAND_SPELL_RAIN_OF_FIRE, WAR_COMMAND_SPELL_POISON_CLOUD, WAR_COMMAND_SPELL_RAISE_DEAD, WAR_COMMAND_SPELL_DARK_VISION, WAR_COMMAND_SPELL_UNHOLY_ARMOR, // summons WAR_COMMAND_SUMMON_SPIDER, // 29 WAR_COMMAND_SUMMON_SCORPION, WAR_COMMAND_SUMMON_DAEMON, WAR_COMMAND_SUMMON_WATER_ELEMENTAL, // build commands WAR_COMMAND_BUILD_BASIC, // 33 WAR_COMMAND_BUILD_ADVANCED, WAR_COMMAND_BUILD_FARM_HUMANS, WAR_COMMAND_BUILD_FARM_ORCS, WAR_COMMAND_BUILD_BARRACKS_HUMANS, WAR_COMMAND_BUILD_BARRACKS_ORCS, WAR_COMMAND_BUILD_CHURCH, WAR_COMMAND_BUILD_TEMPLE, WAR_COMMAND_BUILD_TOWER_HUMANS, WAR_COMMAND_BUILD_TOWER_ORCS, WAR_COMMAND_BUILD_TOWNHALL_HUMANS, WAR_COMMAND_BUILD_TOWNHALL_ORCS, WAR_COMMAND_BUILD_LUMBERMILL_HUMANS, WAR_COMMAND_BUILD_LUMBERMILL_ORCS, WAR_COMMAND_BUILD_STABLE, WAR_COMMAND_BUILD_KENNEL, WAR_COMMAND_BUILD_BLACKSMITH_HUMANS, WAR_COMMAND_BUILD_BLACKSMITH_ORCS, WAR_COMMAND_BUILD_ROAD, WAR_COMMAND_BUILD_WALL, // upgrades WAR_COMMAND_UPGRADE_SWORDS, // 53 WAR_COMMAND_UPGRADE_AXES, WAR_COMMAND_UPGRADE_SHIELD_HUMANS, WAR_COMMAND_UPGRADE_SHIELD_ORCS, WAR_COMMAND_UPGRADE_ARROWS, WAR_COMMAND_UPGRADE_SPEARS, WAR_COMMAND_UPGRADE_HORSES, WAR_COMMAND_UPGRADE_WOLVES, WAR_COMMAND_UPGRADE_SCORPION, WAR_COMMAND_UPGRADE_SPIDER, WAR_COMMAND_UPGRADE_RAIN_OF_FIRE, WAR_COMMAND_UPGRADE_POISON_CLOUD, WAR_COMMAND_UPGRADE_WATER_ELEMENTAL, WAR_COMMAND_UPGRADE_DAEMON, WAR_COMMAND_UPGRADE_HEALING, WAR_COMMAND_UPGRADE_RAISE_DEAD, WAR_COMMAND_UPGRADE_FAR_SIGHT, WAR_COMMAND_UPGRADE_DARK_VISION, WAR_COMMAND_UPGRADE_INVISIBILITY, WAR_COMMAND_UPGRADE_UNHOLY_ARMOR, // wcmd_cancel WAR_COMMAND_CANCEL // 73 } WarUnitCommandType; typedef enum _WarEntityType { WAR_ENTITY_TYPE_NONE, WAR_ENTITY_TYPE_IMAGE, WAR_ENTITY_TYPE_UNIT, WAR_ENTITY_TYPE_ROAD, WAR_ENTITY_TYPE_WALL, WAR_ENTITY_TYPE_RUIN, WAR_ENTITY_TYPE_FOREST, WAR_ENTITY_TYPE_TEXT, WAR_ENTITY_TYPE_RECT, WAR_ENTITY_TYPE_BUTTON, WAR_ENTITY_TYPE_CURSOR, WAR_ENTITY_TYPE_AUDIO, WAR_ENTITY_TYPE_PROJECTILE, WAR_ENTITY_TYPE_RAIN_OF_FIRE, WAR_ENTITY_TYPE_POISON_CLOUD, WAR_ENTITY_TYPE_SIGHT, WAR_ENTITY_TYPE_MINIMAP, WAR_ENTITY_TYPE_ANIMATION, WAR_ENTITY_TYPE_COUNT } WarEntityType; typedef enum _WarRoadPieceType { WAR_ROAD_PIECE_LEFT, WAR_ROAD_PIECE_TOP, WAR_ROAD_PIECE_RIGHT, WAR_ROAD_PIECE_BOTTOM, WAR_ROAD_PIECE_BOTTOM_LEFT, WAR_ROAD_PIECE_VERTICAL, WAR_ROAD_PIECE_BOTTOM_RIGHT, WAR_ROAD_PIECE_T_LEFT, WAR_ROAD_PIECE_T_BOTTOM, WAR_ROAD_PIECE_T_RIGHT, WAR_ROAD_PIECE_CROSS, WAR_ROAD_PIECE_TOP_LEFT, WAR_ROAD_PIECE_HORIZONTAL, WAR_ROAD_PIECE_T_TOP, WAR_ROAD_PIECE_TOP_RIGHT, } WarRoadPieceType; typedef enum _WarWallPieceType { WAR_WALL_PIECE_LEFT, WAR_WALL_PIECE_TOP, WAR_WALL_PIECE_RIGHT, WAR_WALL_PIECE_BOTTOM, WAR_WALL_PIECE_BOTTOM_LEFT, WAR_WALL_PIECE_VERTICAL, WAR_WALL_PIECE_BOTTOM_RIGHT, WAR_WALL_PIECE_T_LEFT, WAR_WALL_PIECE_T_BOTTOM, WAR_WALL_PIECE_T_RIGHT, WAR_WALL_PIECE_CROSS, WAR_WALL_PIECE_TOP_LEFT, WAR_WALL_PIECE_HORIZONTAL, WAR_WALL_PIECE_T_TOP, WAR_WALL_PIECE_TOP_RIGHT, } WarWallPieceType; typedef enum _WarRuinPieceType { WAR_RUIN_PIECE_NONE, WAR_RUIN_PIECE_TOP_LEFT, WAR_RUIN_PIECE_TOP, WAR_RUIN_PIECE_TOP_RIGHT, WAR_RUIN_PIECE_LEFT, WAR_RUIN_PIECE_CENTER, WAR_RUIN_PIECE_RIGHT, WAR_RUIN_PIECE_BOTTOM_LEFT, WAR_RUIN_PIECE_BOTTOM, WAR_RUIN_PIECE_BOTTOM_RIGHT, WAR_RUIN_PIECE_TOP_LEFT_INSIDE, WAR_RUIN_PIECE_TOP_RIGHT_INSIDE, WAR_RUIN_PIECE_BOTTOM_LEFT_INSIDE, WAR_RUIN_PIECE_BOTTOM_RIGHT_INSIDE, WAR_RUIN_PIECE_DIAG_1, WAR_RUIN_PIECE_DIAG_2, } WarRuinPieceType; typedef enum _WarTreeTileType { WAR_TREE_NONE, WAR_TREE_TOP_LEFT, WAR_TREE_TOP, WAR_TREE_TOP_RIGHT, WAR_TREE_LEFT, WAR_TREE_CENTER, WAR_TREE_RIGHT, WAR_TREE_BOTTOM_LEFT, WAR_TREE_BOTTOM, WAR_TREE_BOTTOM_RIGHT, WAR_TREE_TOP_LEFT_INSIDE, WAR_TREE_TOP_RIGHT_INSIDE, WAR_TREE_BOTTOM_LEFT_INSIDE, WAR_TREE_BOTTOM_RIGHT_INSIDE, WAR_TREE_TOP_END, WAR_TREE_BOTTOM_END, WAR_TREE_VERTICAL, WAR_TREE_DIAG_1, WAR_TREE_DIAG_2, WAR_TREE_CHOPPED, } WarTreeTileType; typedef enum _WarUnitActionStepType { WAR_ACTION_STEP_NONE, WAR_ACTION_STEP_FRAME, WAR_ACTION_STEP_WAIT, WAR_ACTION_STEP_ATTACK, WAR_ACTION_STEP_SOUND_SWORD, WAR_ACTION_STEP_SOUND_FIST, WAR_ACTION_STEP_SOUND_FIREBALL, WAR_ACTION_STEP_SOUND_CHOPPING, WAR_ACTION_STEP_SOUND_CATAPULT, WAR_ACTION_STEP_SOUND_ARROW, WAR_ACTION_STEP_SOUND_LIGHTNING, } WarUnitActionStepType; typedef enum _WarUnitActionType { WAR_ACTION_TYPE_NONE = -1, WAR_ACTION_TYPE_IDLE, WAR_ACTION_TYPE_WALK, WAR_ACTION_TYPE_ATTACK, WAR_ACTION_TYPE_DEATH, WAR_ACTION_TYPE_HARVEST, WAR_ACTION_TYPE_REPAIR, WAR_ACTION_TYPE_BUILD, WAR_ACTION_TYPE_COUNT } WarUnitActionType; typedef enum _WarUnitActionStatus { WAR_ACTION_NOT_STARTED, WAR_ACTION_RUNNING, WAR_ACTION_FINISHED, } WarUnitActionStatus; typedef enum _PathFindingType { PATH_FINDING_BFS, PATH_FINDING_ASTAR } PathFindingType; typedef enum _WarPathFinderDataType { PATH_FINDER_DATA_EMPTY = 0, PATH_FINDER_DATA_STATIC = 1, PATH_FINDER_DATA_DYNAMIC = 2, } WarPathFinderDataType; typedef enum _WarStateType { WAR_STATE_IDLE, WAR_STATE_MOVE, WAR_STATE_PATROL, WAR_STATE_FOLLOW, WAR_STATE_ATTACK, WAR_STATE_GOLD, WAR_STATE_MINING, WAR_STATE_WOOD, WAR_STATE_CHOPPING, WAR_STATE_DELIVER, WAR_STATE_DEATH, WAR_STATE_COLLAPSE, WAR_STATE_TRAIN, WAR_STATE_UPGRADE, WAR_STATE_BUILD, WAR_STATE_REPAIR, WAR_STATE_REPAIRING, WAR_STATE_CAST, WAR_STATE_WAIT, WAR_STATE_COUNT } WarStateType; typedef enum _WarTextAlignment { WAR_TEXT_ALIGN_LEFT, WAR_TEXT_ALIGN_CENTER, WAR_TEXT_ALIGN_RIGHT, WAR_TEXT_ALIGN_TOP, WAR_TEXT_ALIGN_MIDDLE, WAR_TEXT_ALIGN_BOTTOM, WAR_TEXT_ALIGN_COUNT } WarTextAlignment; typedef enum _WarTextWrapping { WAR_TEXT_WRAP_NONE, WAR_TEXT_WRAP_CHAR } WarTextWrapping; typedef enum _WarTextTrimming { WAR_TEXT_TRIM_NONE, WAR_TEXT_TRIM_SPACES, WAR_TEXT_TRIM_ALL } WarTextTrimming; typedef enum _WarAudioId { WAR_MUSIC_00 = 0, WAR_MUSIC_01 = 1, WAR_MUSIC_02 = 2, WAR_MUSIC_03 = 3, WAR_MUSIC_04 = 4, WAR_MUSIC_05 = 5, WAR_MUSIC_06 = 6, WAR_MUSIC_07 = 7, WAR_MUSIC_08 = 8, WAR_MUSIC_09 = 9, WAR_MUSIC_10 = 10, WAR_MUSIC_11 = 11, WAR_MUSIC_12 = 12, WAR_MUSIC_13 = 13, WAR_MUSIC_14 = 14, WAR_MUSIC_15 = 15, WAR_MUSIC_16 = 16, WAR_MUSIC_17 = 17, WAR_MUSIC_18 = 18, WAR_MUSIC_19 = 19, WAR_MUSIC_20 = 20, WAR_MUSIC_21 = 21, WAR_MUSIC_22 = 22, WAR_MUSIC_23 = 23, WAR_MUSIC_24 = 24, WAR_MUSIC_25 = 25, WAR_MUSIC_26 = 26, WAR_MUSIC_27 = 27, WAR_MUSIC_28 = 28, WAR_MUSIC_29 = 29, WAR_MUSIC_30 = 30, WAR_MUSIC_31 = 31, WAR_MUSIC_32 = 32, WAR_MUSIC_33 = 33, WAR_MUSIC_34 = 34, WAR_MUSIC_35 = 35, WAR_MUSIC_36 = 36, WAR_MUSIC_37 = 37, WAR_MUSIC_38 = 38, WAR_MUSIC_39 = 39, WAR_MUSIC_40 = 40, WAR_MUSIC_41 = 41, WAR_MUSIC_42 = 42, WAR_MUSIC_43 = 43, WAR_MUSIC_44 = 44, WAR_LOGO = 472, WAR_INTRO_DOOR = 473, WAR_BUILDING = 474, WAR_EXPLOSION = 475, WAR_CATAPULT_ROCK_FIRED = 476, WAR_TREE_CHOPPING_1 = 477, WAR_TREE_CHOPPING_2 = 478, WAR_TREE_CHOPPING_3 = 479, WAR_TREE_CHOPPING_4 = 480, WAR_BUILDING_COLLAPSE_1 = 481, WAR_BUILDING_COLLAPSE_2 = 482, WAR_BUILDING_COLLAPSE_3 = 483, WAR_UI_CHIME = 484, WAR_UI_CLICK = 485, WAR_UI_CANCEL = 486, WAR_SWORD_ATTACK_1 = 487, WAR_SWORD_ATTACK_2 = 488, WAR_SWORD_ATTACK_3 = 489, WAR_FIST_ATTACK = 490, WAR_CATAPULT_FIRE_EXPLOSION = 491, WAR_FIREBALL = 492, WAR_ARROW_SPEAR = 493, WAR_ARROW_SPEAR_HIT = 494, WAR_ORC_HELP_1 = 495, // "The humans draw near" WAR_ORC_HELP_2 = 496, // "The pale dogs approach" WAR_HUMAN_HELP_1 = 497, // "The Orcs are approaching" WAR_HUMAN_HELP_2 = 498, // "There are enemies nearby" WAR_ORC_DEAD = 499, WAR_HUMAN_DEAD = 500, WAR_ORC_WORK_COMPLETE = 501, // "Work completed" WAR_HUMAN_WORK_COMPLETE = 502, // "Work completed" WAR_ORC_HELP_3 = 503, // "We are being attacked" WAR_ORC_HELP_4 = 504, // "They're destroying our city" WAR_HUMAN_HELP_3 = 505, // "We are under attack" WAR_HUMAN_HELP_4 = 506, // "The town is under attack" WAR_ORC_READY = 507, // "Your command, master" WAR_HUMAN_READY = 508, // "Your command" WAR_ORC_ACKNOWLEDGEMENT_1 = 509, WAR_ORC_ACKNOWLEDGEMENT_2 = 510, WAR_ORC_ACKNOWLEDGEMENT_3 = 511, WAR_ORC_ACKNOWLEDGEMENT_4 = 512, WAR_HUMAN_ACKNOWLEDGEMENT_1 = 513, // "Yes" WAR_HUMAN_ACKNOWLEDGEMENT_2 = 514, // "Yes, mylord" WAR_ORC_SELECTED_1 = 515, WAR_ORC_SELECTED_2 = 516, WAR_ORC_SELECTED_3 = 517, WAR_ORC_SELECTED_4 = 518, WAR_ORC_SELECTED_5 = 519, WAR_HUMAN_SELECTED_1 = 520, // "Yes?" WAR_HUMAN_SELECTED_2 = 521, // "Your will, sire?" WAR_HUMAN_SELECTED_3 = 522, // "Mylord?" WAR_HUMAN_SELECTED_4 = 523, // "My liege?" WAR_HUMAN_SELECTED_5 = 524, // "Your bidding?" WAR_ORC_ANNOYED_1 = 525, WAR_ORC_ANNOYED_2 = 526, WAR_ORC_ANNOYED_3 = 527, // "Stop poking me" WAR_HUMAN_ANNOYED_1 = 528, // "What?!" WAR_HUMAN_ANNOYED_2 = 529, // "What do you want?!" WAR_HUMAN_ANNOYED_3 = 530, // "Why do you keep touching me?!" WAR_DEAD_SPIDER_SCORPION = 531, WAR_NORMAL_SPELL = 532, WAR_BUILD_ROAD = 533, WAR_ORC_TEMPLE = 534, WAR_HUMAN_CHURCH = 535, WAR_ORC_KENNEL = 536, WAR_HUMAN_STABLE = 537, WAR_BLACKSMITH = 538, WAR_FIRE_CRACKLING = 539, WAR_CANNON = 540, WAR_CANNON2 = 541, WAR_CAMPAIGNS_HUMAN_ENDING_1 = 542, WAR_CAMPAIGNS_HUMAN_ENDING_2 = 543, WAR_CAMPAIGNS_ORC_ENDING_1 = 544, WAR_CAMPAIGNS_ORC_ENDING_2 = 545, WAR_INTRO_1 = 546, // "In the age of chaos..." WAR_INTRO_2 = 547, // "The kingdom of Azeroth was..." WAR_INTRO_3 = 548, // "No one knew where these..." WAR_INTRO_4 = 549, // "With an ingenious..." WAR_INTRO_5 = 550, // "Welcome to the World of Warcraft" WAR_CAMPAIGNS_HUMAN_01_INTRO = 551, WAR_CAMPAIGNS_HUMAN_02_INTRO = 552, WAR_CAMPAIGNS_HUMAN_03_INTRO = 553, WAR_CAMPAIGNS_HUMAN_04_INTRO = 554, WAR_CAMPAIGNS_HUMAN_05_INTRO = 555, WAR_CAMPAIGNS_HUMAN_06_INTRO = 556, WAR_CAMPAIGNS_HUMAN_07_INTRO = 557, WAR_CAMPAIGNS_HUMAN_08_INTRO = 558, WAR_CAMPAIGNS_HUMAN_09_INTRO = 559, WAR_CAMPAIGNS_HUMAN_10_INTRO = 560, WAR_CAMPAIGNS_HUMAN_11_INTRO = 561, WAR_CAMPAIGNS_HUMAN_12_INTRO = 562, WAR_CAMPAIGNS_ORC_01_INTRO = 563, WAR_CAMPAIGNS_ORC_02_INTRO = 564, WAR_CAMPAIGNS_ORC_03_INTRO = 565, WAR_CAMPAIGNS_ORC_04_INTRO = 566, WAR_CAMPAIGNS_ORC_05_INTRO = 567, WAR_CAMPAIGNS_ORC_06_INTRO = 568, WAR_CAMPAIGNS_ORC_07_INTRO = 569, WAR_CAMPAIGNS_ORC_08_INTRO = 570, WAR_CAMPAIGNS_ORC_09_INTRO = 571, WAR_CAMPAIGNS_ORC_10_INTRO = 572, WAR_CAMPAIGNS_ORC_11_INTRO = 573, WAR_CAMPAIGNS_ORC_12_INTRO = 574, WAR_HUMAN_DEFEAT = 575, // "Your failure in battle" WAR_ORC_DEFEAT = 576, // "You pitiful" WAR_ORC_VICTORY_1 = 577, // "The feel of bones" WAR_ORC_VICTORY_2 = 578, // "If only the worthless" WAR_ORC_VICTORY_3 = 579, // "Gaze upon the destruction" WAR_HUMAN_VICTORY_1 = 580, // "The forces of darkness" WAR_HUMAN_VICTORY_2 = 581, // "Even these children" WAR_HUMAN_VICTORY_3 = 582, // "Cheers of victory" } WarAudioId; typedef enum _WarAudioType { WAR_AUDIO_MIDI, WAR_AUDIO_WAVE } WarAudioType; typedef enum _WarCursorType { WAR_CURSOR_ARROW = 263, WAR_CURSOR_INVALID = 264, WAR_CURSOR_YELLOW_CROSSHAIR = 265, WAR_CURSOR_RED_CROSSHAIR = 266, WAR_CURSOR_YELLOW_CROSSHAIR_2 = 267, WAR_CURSOR_MAGNIFYING_GLASS = 268, WAR_CURSOR_GREEN_CROSSHAIR = 269, WAR_CURSOR_WATCH = 270, WAR_CURSOR_ARROW_UP = 271, WAR_CURSOR_ARROW_UP_RIGHT = 272, WAR_CURSOR_ARROW_RIGHT = 273, WAR_CURSOR_ARROW_BOTTOM_RIGHT = 274, WAR_CURSOR_ARROW_BOTTOM = 275, WAR_CURSOR_ARROW_BOTTOM_LEFT = 276, WAR_CURSOR_ARROW_LEFT = 277, WAR_CURSOR_ARROW_UP_LEFT = 278 } WarCursorType; typedef enum _WarProjectileType { WAR_PROJECTILE_ARROW, WAR_PROJECTILE_CATAPULT, WAR_PROJECTILE_FIREBALL, WAR_PROJECTILE_FIREBALL_2, WAR_PROJECTILE_WATER_ELEMENTAL, WAR_PROJECTILE_RAIN_OF_FIRE } WarProjectileType; typedef enum _WarMapTilesetType { MAP_TILESET_FOREST, MAP_TILESET_SWAMP, MAP_TILESET_DUNGEON } WarMapTilesetType; typedef enum _WarFogPieceType { WAR_FOG_PIECE_NONE, WAR_FOG_PIECE_TOP_LEFT, WAR_FOG_PIECE_TOP, WAR_FOG_PIECE_TOP_RIGHT, WAR_FOG_PIECE_LEFT, WAR_FOG_PIECE_CENTER, WAR_FOG_PIECE_RIGHT, WAR_FOG_PIECE_BOTTOM_LEFT, WAR_FOG_PIECE_BOTTOM, WAR_FOG_PIECE_BOTTOM_RIGHT } WarFogPieceType; typedef enum _WarFogBoundaryType { WAR_FOG_BOUNDARY_NONE, WAR_FOG_BOUNDARY_UNKOWN, WAR_FOG_BOUNDARY_FOG, } WarFogBoundaryType; typedef enum _WarUnitPortraits { WAR_PORTRAIT_FOOTMAN, WAR_PORTRAIT_GRUNT, WAR_PORTRAIT_CONJURER, WAR_PORTRAIT_WARLOCK, WAR_PORTRAIT_PEASANT, WAR_PORTRAIT_PEON, WAR_PORTRAIT_CATAPULT_HUMANS, WAR_PORTRAIT_CATAPULT_ORCS, WAR_PORTRAIT_KNIGHT, WAR_PORTRAIT_RAIDER, WAR_PORTRAIT_ARCHER, WAR_PORTRAIT_SPEARMAN, WAR_PORTRAIT_CLERIC, WAR_PORTRAIT_NECROLYTE, WAR_PORTRAIT_FARM_HUMANS, WAR_PORTRAIT_FARM_ORCS, WAR_PORTRAIT_BARRACKS_HUMANS, WAR_PORTRAIT_BARRACKS_ORCS, WAR_PORTRAIT_TOWER_HUMANS, WAR_PORTRAIT_TOWER_ORCS, WAR_PORTRAIT_TOWNHALL_HUMANS, WAR_PORTRAIT_TOWNHALL_ORCS, WAR_PORTRAIT_LUMBERMILL_HUMANS, WAR_PORTRAIT_LUMBERMILL_ORCS, WAR_PORTRAIT_STABLE, WAR_PORTRAIT_KENNEL, WAR_PORTRAIT_BLACKSMITH_HUMANS, WAR_PORTRAIT_BLACKSMITH_ORCS, WAR_PORTRAIT_CHURCH, WAR_PORTRAIT_TEMPLE, WAR_PORTRAIT_GOLDMINE, WAR_PORTRAIT_STORMWIND, WAR_PORTRAIT_BLACKROCK, WAR_PORTRAIT_MOVE_HUMANS, WAR_PORTRAIT_MOVE_ORCS, WAR_PORTRAIT_REPAIR, WAR_PORTRAIT_HARVEST, WAR_PORTRAIT_BUILD_BASIC, WAR_PORTRAIT_BUILD_ADVANCED, WAR_PORTRAIT_DELIVER, WAR_PORTRAIT_CANCEL, WAR_PORTRAIT_WALL, WAR_PORTRAIT_ROAD, WAR_PORTRAIT_UNKOWN, WAR_PORTRAIT_OGRE, WAR_PORTRAIT_SPIDER, WAR_PORTRAIT_SLIME, WAR_PORTRAIT_FIRE_ELEMENTAL, WAR_PORTRAIT_SCORPION, WAR_PORTRAIT_SKELETON, WAR_PORTRAIT_DEAD, WAR_PORTRAIT_DAEMON, WAR_PORTRAIT_WATER_ELEMENTAL, WAR_PORTRAIT_LOTHAR, WAR_PORTRAIT_MEDIVH, WAR_PORTRAIT_GRIZELDA, WAR_PORTRAIT_GARONA, WAR_PORTRAIT_WOUNDED, WAR_PORTRAIT_BRIGAND, WAR_PORTRAIT_HOLY_LANCE, WAR_PORTRAIT_ELEMENTAL_BLAST, WAR_PORTRAIT_SHADOW_SPEAR, WAR_PORTRAIT_FIREBALL, WAR_PORTRAIT_SWORD_1, WAR_PORTRAIT_SWORD_2, WAR_PORTRAIT_SWORD_3, WAR_PORTRAIT_AXE_1, WAR_PORTRAIT_AXE_2, WAR_PORTRAIT_AXE_3, WAR_PORTRAIT_WOLVES_1, WAR_PORTRAIT_WOLVES_2, WAR_PORTRAIT_ARROW_1, WAR_PORTRAIT_ARROW_2, WAR_PORTRAIT_ARROW_3, WAR_PORTRAIT_SPEAR_1, WAR_PORTRAIT_SPEAR_2, WAR_PORTRAIT_SPEAR_3, WAR_PORTRAIT_HORSE_1, WAR_PORTRAIT_HORSE_2, WAR_PORTRAIT_SHIELD_1_HUMANS, WAR_PORTRAIT_SHIELD_2_HUMANS, WAR_PORTRAIT_SHIELD_3_HUMANS, WAR_PORTRAIT_SHIELD_1_ORCS, WAR_PORTRAIT_SHIELD_2_ORCS, WAR_PORTRAIT_SHIELD_3_ORCS, WAR_PORTRAIT_HEALING, WAR_PORTRAIT_FAR_SIGHT, WAR_PORTRAIT_INVISIBILITY, WAR_PORTRAIT_RAIN_OF_FIRE, WAR_PORTRAIT_RAISE_DEAD, WAR_PORTRAIT_DARK_VISION, WAR_PORTRAIT_UNHOLY_ARMOR, WAR_PORTRAIT_POISON_CLOUD } WarUnitPortraits; typedef enum _WarMapTileState { MAP_TILE_STATE_UNKOWN = 1, MAP_TILE_STATE_FOG = 2, MAP_TILE_STATE_VISIBLE = 4 } WarMapTileState; typedef enum _WarAICommandStatus { WAR_AI_COMMAND_STATUS_CREATED, WAR_AI_COMMAND_STATUS_STARTED, WAR_AI_COMMAND_STATUS_COMPLETED, } WarAICommandStatus; typedef enum _WarAICommandType { WAR_AI_COMMAND_REQUEST, WAR_AI_COMMAND_WAIT, WAR_AI_COMMAND_ATTACK, WAR_AI_COMMAND_DEFEND, WAR_AI_COMMAND_SLEEP, WAR_AI_COMMAND_COUNT } WarAICommandType; typedef enum _WarCheat { WAR_CHEAT_NONE, // original cheats WAR_CHEAT_GOLD, WAR_CHEAT_SPELLS, WAR_CHEAT_UPGRADES, WAR_CHEAT_END, WAR_CHEAT_ENABLE, WAR_CHEAT_GOD_MODE, WAR_CHEAT_WIN, WAR_CHEAT_LOSS, WAR_CHEAT_FOG, WAR_CHEAT_SKIP_HUMAN, WAR_CHEAT_SKIP_ORC, WAR_CHEAT_SPEED, // custom cheats WAR_CHEAT_MUSIC, WAR_CHEAT_SOUND, WAR_CHEAT_MUSIC_VOL, WAR_CHEAT_SOUND_VOL, WAR_CHEAT_GLOBAL_SCALE, WAR_CHEAT_GLOBAL_SPEED, WAR_CHEAT_EDIT, WAR_CHEAT_ADD_UNIT, WAR_CHEAT_RAIN_OF_FIRE, WAR_CHEAT_COUNT } WarCheat; typedef enum _WarMapSpeed { WAR_SPEED_SLOWEST, WAR_SPEED_SLOW, WAR_SPEED_NORMAL, WAR_SPEED_FASTER, WAR_SPEED_FASTEST } WarMapSpeed; typedef enum _WarSceneType { WAR_SCENE_DOWNLOAD, WAR_SCENE_BLIZZARD, WAR_SCENE_MAIN_MENU, WAR_SCENE_BRIEFING, WAR_SCENE_COUNT } WarSceneType; typedef enum _WarSceneDownloadState { WAR_SCENE_DOWNLOAD_DOWNLOAD, WAR_SCENE_DOWNLOAD_CONFIRM, WAR_SCENE_DOWNLOAD_DOWNLOADING, WAR_SCENE_DOWNLOAD_DOWNLOADED, WAR_SCENE_DOWNLOAD_FILE_LOADED, WAR_SCENE_DOWNLOAD_FAILED, } WarSceneDownloadState; typedef enum _WarMainMenuPanel { WAR_MAIN_MENU_PANEL_MAIN, WAR_MAIN_MENU_PANEL_SINGLE_PLAYER, WAR_MAIN_MENU_PANEL_CUSTOM_GAME, } WarMainMenuPanel; typedef enum _WarComponentType { COMP_TRANSFORM = 0, COMP_SPRITE = 1, COMP_UNIT = 2, COMP_ANIMATIONS = 3, COMP_ROAD = 4, COMP_WALL = 5, COMP_RUIN = 6, COMP_FOREST = 7, COMP_STATE_MACHINE = 8, COMP_UI = 9, COMP_TEXT = 10, COMP_RECT = 11, COMP_BUTTON = 12, COMP_AUDIO = 13, COMP_CURSOR = 14, COMP_PROJECTILE = 15, COMP_POISON_CLOUD = 16, COMP_SIGHT = 17, COMP_COUNT = 18 } WarComponentType; ================================================ FILE: src/war_file.c ================================================ #include "war_file.h" #include "war_log.h" WarFile* wfile_loadWarFile(WarContext* context, StringView filePath) { NOT_USED(context); SDL_IOStream *stream = SDL_IOFromFile(wsv_data(filePath), "rb"); if (!stream) { logError("Couldn't process the DATA.WAR file. The file doesn't exists at %s.", wsv_data(filePath)); return NULL; } Sint64 fileLength = SDL_GetIOSize(stream); WarFile *warFile = (WarFile*)wm_alloc(sizeof(WarFile)); SDL_ReadU32LE(stream, &warFile->archiveID); SDL_ReadU32LE(stream, &warFile->numberOfEntries); switch (warFile->archiveID) { case 0x18: case 0x1A: { warFile->type = WAR_FILE_TYPE_RETAIL; break; } case 0x19: { warFile->type = WAR_FILE_TYPE_DEMO; break; } default: { warFile->type = WAR_FILE_TYPE_UNKNOWN; break; } } if (warFile->type == WAR_FILE_TYPE_UNKNOWN) { logError("Couldn't process the DATA.WAR file. The file type %u is not the RETAIL or DEMO version of the game.", warFile->archiveID); wm_free(warFile); SDL_CloseIO(stream); return NULL; } SDL_ReadIO(stream, warFile->offsets, warFile->numberOfEntries * sizeof(u32)); for (s32 i = 0; i < (s32)warFile->numberOfEntries; ++i) { // placeholders in demo versions if (warFile->offsets[i] == 0xFFFFFFFF || warFile->offsets[i] == 0x00000000) { warFile->resources[i].placeholder = true; continue; } u32 compressedLength; if (i == (s32)warFile->numberOfEntries - 1) { compressedLength = (u32)fileLength - warFile->offsets[i]; } else { s32 j = i + 1; u32 nextOffset = warFile->offsets[j]; while (nextOffset == 0xFFFFFFFF || nextOffset == 0x00000000) { if (j + 1 >= (s32)warFile->numberOfEntries) { nextOffset = (u32)fileLength; break; } nextOffset = warFile->offsets[++j]; } compressedLength = nextOffset - warFile->offsets[i]; } SDL_SeekIO(stream, warFile->offsets[i], SDL_IO_SEEK_SET); u32 size; SDL_ReadU32LE(stream, &size); u32 length = (size & 0x1FFFFFFF); bool compressed = (size & 0xE0000000) != 0; u8 *data = (u8*)wm_alloc(length * sizeof(u8)); if (!compressed) { SDL_ReadIO(stream, data, length); } else { /* decompression algorithm as described in The File Formats of WarCraft: Orcs & Humans December 4, 2015 http://www.blizzardarchive.com/pub/Misc/Wc1Book_041215.pdf for o:=0 to 4095 do bufwin[o] := 0; // init our 4096 byte buffer with zero i :=0; while (i < filesize) do begin; warfile.read(cmask, 1); i := i + 1; for a:=0 to 7 do begin; if (cmask mod 2 = 1) then // uncompressed byte begin; warfile.read(bufbyte, 1); bufwin[tmp.position mod 4096] := bufbyte; tmp.write(bufbyte, 1); i := i + 1; end; else // compressed block begin; warfile.read(offset, 2); numbytes := offset div 4096; offset := offset mod 4096; i := i + 2; for m := 0 to numbytes + 2 do begin; bufbyte := bufwin[(offset + m) mod 4096]; bufwin[(tmp.position) mod 4096] := bufbyte; tmp.write(bufbyte, 1); end; end; cmask := cmask div 2; end; end; tmp.size := finalsize; // Crop the file, just in case */ #define BUFWIN_SIZE 4096 u8 bufwin[BUFWIN_SIZE]; memset(bufwin, 0, BUFWIN_SIZE); s32 b = 0; s32 bufwinPos = 0; while (b < (s32)compressedLength) { u8 cmask; SDL_ReadU8(stream, &cmask); b++; for (s32 a = 0; a < 8 && bufwinPos < (s32)length; ++a) { if (cmask % 2 == 1) // uncompressed byte { u8 bufbyte; SDL_ReadU8(stream, &bufbyte); b++; bufwin[bufwinPos % BUFWIN_SIZE] = bufbyte; data[bufwinPos] = bufbyte; bufwinPos++; } else // compressed block begin { u16 offset; SDL_ReadU16LE(stream, &offset); u16 numbytes = offset / BUFWIN_SIZE; offset = offset % BUFWIN_SIZE; b += 2; for (s32 m = 0; m <= numbytes + 2 && bufwinPos < (s32)length; ++m) { u8 bufbyte = bufwin[(offset + m) % BUFWIN_SIZE]; bufwin[bufwinPos % BUFWIN_SIZE] = bufbyte; data[bufwinPos] = bufbyte; bufwinPos++; } } cmask /= 2; } } } warFile->resources[i].placeholder = false; warFile->resources[i].index = i; warFile->resources[i].offset = warFile->offsets[i]; warFile->resources[i].compressed = compressed; warFile->resources[i].compressedLength = compressedLength; warFile->resources[i].length = length; warFile->resources[i].data = data; } SDL_CloseIO(stream); return warFile; } ================================================ FILE: src/war_file.h ================================================ #pragma once #include "shl/wstr.h" #include "war.h" #include "war_resources.h" WarFile* wfile_loadWarFile(WarContext* context, StringView filePath); ================================================ FILE: src/war_font.c ================================================ #include "war_font.h" #include "war_sprites.h" #include "shl/wstr.h" // the fonts was created in a 64x64 (64x96 for the second font) // sprite but for the actual game a 512x512 (512x768) was used, // so the original dimensions of this array are actually multiplied by 8 // WarFontData fontsData[2] = { // font 0 for in game texts { 512, 512, 48, 8, { { 0, 0, 24, 48 }, // { 40, 0, 16, 48 }, // ! { 56, 0, 32, 48 }, // " { 88, 0, 48, 48 }, // # { 136, 0, 40, 48 }, // $ { 176, 0, 48, 48 }, // % { 224, 0, 40, 48 }, // & { 264, 0, 24, 48 }, // ' { 288, 0, 24, 48 }, // ( { 312, 0, 24, 48 }, // ) { 336, 0, 32, 48 }, // * { 368, 0, 32, 48 }, // + { 400, 0, 24, 48 }, // ' { 424, 0, 32, 48 }, // - { 456, 0, 16, 48 }, // . { 0, 48, 48, 48 }, // / { 48, 48, 40, 48 }, // 0 { 88, 48, 32, 48 }, // 1 { 120, 48, 40, 48 }, // 2 { 160, 48, 40, 48 }, // 3 { 200, 48, 40, 48 }, // 4 { 240, 48, 40, 48 }, // 5 { 280, 48, 40, 48 }, // 6 { 320, 48, 40, 48 }, // 7 { 360, 48, 40, 48 }, // 8 { 400, 48, 40, 48 }, // 9 { 440, 48, 32, 48 }, // : { 472, 48, 16, 48 }, // ; { 0, 96, 32, 48 }, // < { 32, 96, 32, 48 }, // = { 64, 96, 32, 48 }, // > { 96, 96, 40, 48 }, // ? { 136, 96, 48, 48 }, // @ { 184, 96, 40, 48 }, // A { 224, 96, 40, 48 }, // B { 264, 96, 40, 48 }, // C { 304, 96, 40, 48 }, // D { 344, 96, 40, 48 }, // E { 384, 96, 40, 48 }, // F { 424, 96, 40, 48 }, // G { 464, 96, 40, 48 }, // H { 0, 144, 32, 48 }, // I { 32, 144, 40, 48 }, // J { 72, 144, 40, 48 }, // K { 112, 144, 40, 48 }, // L { 152, 144, 48, 48 }, // M { 200, 144, 48, 48 }, // N { 248, 144, 40, 48 }, // O { 288, 144, 40, 48 }, // P { 328, 144, 40, 48 }, // Q { 368, 144, 40, 48 }, // R { 408, 144, 40, 48 }, // S { 448, 144, 32, 48 }, // T { 0, 192, 40, 48 }, // U { 40, 192, 48, 48 }, // V { 88, 192, 48, 48 }, // W { 136, 192, 48, 48 }, // X { 184, 192, 48, 48 }, // Y { 232, 192, 48, 48 }, // Z { 280, 192, 24, 48 }, // [ { 304, 192, 48, 48 }, // backslash { 352, 192, 24, 48 }, // ] { 376, 192, 32, 48 }, // ^ { 408, 192, 40, 48 }, // _ { 448, 192, 24, 48 }, // ` { 0, 240, 40, 48 }, // a { 40, 240, 40, 48 }, // b { 80, 240, 40, 48 }, // c { 120, 240, 40, 48 }, // d { 160, 240, 40, 48 }, // e { 200, 240, 40, 48 }, // f { 240, 240, 40, 48 }, // g { 280, 240, 40, 48 }, // h { 320, 240, 32, 48 }, // i { 352, 240, 40, 48 }, // j { 392, 240, 40, 48 }, // k { 432, 240, 40, 48 }, // l { 0, 288, 48, 48 }, // m { 48, 288, 48, 48 }, // n { 96, 288, 40, 48 }, // o { 136, 288, 40, 48 }, // p { 176, 288, 40, 48 }, // q { 216, 288, 40, 48 }, // r { 256, 288, 40, 48 }, // s { 296, 288, 32, 48 }, // t { 328, 288, 40, 48 }, // u { 360, 288, 48, 48 }, // v { 408, 288, 48, 48 }, // w { 0, 336, 48, 48 }, // x { 48, 336, 48, 48 }, // y { 96, 336, 48, 48 }, // z { 144, 336, 32, 48 }, // { { 176, 336, 16, 48 }, // | { 192, 336, 32, 48 }, // } { 224, 336, 48, 48 }, // ~ } }, // font 1 for menu texts { 512, 768, 80, 8, { { 0, 0, 30, 80 }, // space { 48, 0, 16, 80 }, // ! { 64, 0, 32, 80 }, // " { 96, 0, 48, 80 }, // # { 144, 0, 48, 80 }, // $ { 192, 0, 64, 80 }, // % { 256, 0, 40, 80 }, // & { 296, 0, 24, 80 }, // ' { 320, 0, 32, 80 }, // ( { 352, 0, 32, 80 }, // ) { 384, 0, 56, 80 }, // * { 440, 0, 48, 80 }, // + { 488, 0, 24, 80 }, // ' { 0, 80, 32, 80 }, // - { 32, 80, 24, 80 }, // . { 56, 80, 56, 80 }, // / { 112, 80, 48, 80 }, // 0 { 160, 80, 32, 80 }, // 1 { 192, 80, 48, 80 }, // 2 { 240, 80, 48, 80 }, // 3 { 288, 80, 48, 80 }, // 4 { 336, 80, 48, 80 }, // 5 { 384, 80, 48, 80 }, // 6 { 432, 80, 48, 80 }, // 7 { 0, 160, 48, 80 }, // 8 { 48, 160, 48, 80 }, // 9 { 96, 160, 24, 80 }, // : { 120, 160, 24, 80 }, // ; { 144, 160, 40, 80 }, // < { 184, 160, 40, 80 }, // = { 224, 160, 40, 80 }, // > { 264, 160, 40, 80 }, // ? { 304, 160, 64, 80 }, // @ { 368, 160, 48, 80 }, // A { 416, 160, 48, 80 }, // B { 464, 160, 48, 80 }, // C { 0, 240, 48, 80 }, // D { 48, 240, 48, 80 }, // E { 96, 240, 48, 80 }, // F { 144, 240, 48, 80 }, // G { 192, 240, 48, 80 }, // H { 240, 240, 32, 80 }, // I { 272, 240, 48, 80 }, // J { 320, 240, 48, 80 }, // K { 368, 240, 48, 80 }, // L { 416, 240, 64, 80 }, // M { 0, 320, 56, 80 }, // N { 56, 320, 48, 80 }, // O { 104, 320, 48, 80 }, // P { 152, 320, 48, 80 }, // Q { 200, 320, 48, 80 }, // R { 248, 320, 48, 80 }, // S { 296, 320, 48, 80 }, // T { 344, 320, 48, 80 }, // U { 392, 320, 48, 80 }, // V { 440, 320, 64, 80 }, // W { 0, 400, 48, 80 }, // X { 48, 400, 48, 80 }, // Y { 96, 400, 48, 80 }, // Z { 144, 400, 32, 80 }, // [ { 176, 400, 56, 80 }, // backslash { 232, 400, 32, 80 }, // ] { 264, 400, 48, 80 }, // ^ { 312, 400, 48, 80 }, // _ { 360, 400, 32, 80 }, // ` { 392, 400, 40, 80 }, // a { 432, 400, 40, 80 }, // b { 472, 400, 40, 80 }, // c { 0, 480, 40, 80 }, // d { 40, 480, 40, 80 }, // e { 80, 480, 32, 80 }, // f { 112, 480, 40, 80 }, // g { 152, 480, 40, 80 }, // h { 192, 480, 16, 80 }, // i { 208, 480, 24, 80 }, // j { 232, 480, 40, 80 }, // k { 272, 480, 16, 80 }, // l { 288, 480, 64, 80 }, // m { 352, 480, 40, 80 }, // n { 392, 480, 40, 80 }, // o { 432, 480, 40, 80 }, // p { 0, 560, 48, 80 }, // q { 48, 560, 40, 80 }, // r { 88, 560, 40, 80 }, // s { 128, 560, 32, 80 }, // t { 160, 560, 40, 80 }, // u { 200, 560, 48, 80 }, // v { 248, 560, 64, 80 }, // w { 312, 560, 48, 80 }, // x { 360, 560, 40, 80 }, // y { 400, 560, 48, 80 }, // z { 0, 640, 32, 80 }, // { { 32, 560, 16, 80 }, // | { 48, 560, 32, 80 }, // } { 80, 640, 56, 80 }, // ~ } } }; #define getCharIndex(c) ((s32)((c) > 0 ? (c) - 32 : 0)) WarSprite wfont_loadFontSprite(WarContext* context, StringView fontPath) { WarSprite sprite = {0}; s32 width, height, bitsPerPixel; u8* data = stbi_load(wsv_data(fontPath), &width, &height, &bitsPerPixel, 0); if (data) { sprite = wspr_createSprite(context, width, height, data); stbi_image_free(data); } return sprite; } WarFontData getFontData(s32 fontIndex) { if (fontIndex < 0 || fontIndex >= arrayLength(fontsData)) { logError("Invalid font index: %d", fontIndex); return (WarFontData){0}; } return fontsData[fontIndex]; } vec2 wfont_getAlignmentOffset(WarTextAlignment horizontalAlign, WarTextAlignment verticalAlign, vec2 boundings, vec2 textSize) { vec2 offset = VEC2_ZERO; switch (horizontalAlign) { case WAR_TEXT_ALIGN_LEFT: { // nothing here break; } case WAR_TEXT_ALIGN_CENTER: { offset.x = ceilf(0.5f * (boundings.x - textSize.x)); break; } case WAR_TEXT_ALIGN_RIGHT: { offset.x = ceilf(0.5f * (boundings.x - textSize.x)); break; } default: { logError("Invalid horizontal alignment value: %d", horizontalAlign); break; } } switch (verticalAlign) { case WAR_TEXT_ALIGN_TOP: { // nothing here break; } case WAR_TEXT_ALIGN_MIDDLE: { offset.y = ceilf(0.5f * (boundings.y - textSize.y)); break; } case WAR_TEXT_ALIGN_BOTTOM: { offset.y = ceilf(boundings.y - textSize.y); break; } default: { logError("Invalid vertical alignment value: %d", verticalAlign); break; } } return offset; } f32 wfont_getLineAlignmentOffset(WarTextAlignment lineAlign, f32 width, f32 lineWidth) { f32 offset = 0; switch (lineAlign) { case WAR_TEXT_ALIGN_LEFT: { // nothing here break; } case WAR_TEXT_ALIGN_CENTER: { offset = ceilf(0.5f * (width - lineWidth)); break; } case WAR_TEXT_ALIGN_RIGHT: { offset = ceilf(width - lineWidth); break; } default: { logError("Invalid horizontal alignment value: %d", lineAlign); break; } } return offset; } typedef struct { s32 start; s32 length; f32 width; } WarTextSpan; static s32 wfont_splitTextIntoLines(StringView text, s32 maxLines, WarTextSpan lines[], f32 width, WarFontParams params) { f32 scale = params.fontSize / params.fontData.lineHeight; bool wrap = params.wrapping == WAR_TEXT_WRAP_CHAR; f32 x = 0; s32 k = 0; s32 s = 0; s32 n = (s32)wsv_length(text); for (s32 i = 0; i < n && k < maxLines; i++) { char c = text.data[i]; // a new line is generated for each \n if (c == '\n') { lines[k].start = s; lines[k].length = i - s; lines[k].width = x; k++; s = i + 1; x = 0; } else if (c == '\t') { rect rs = params.fontData.data[getCharIndex(' ')]; f32 dx = (TAB_WIDTH * rs.width + params.fontData.advance) * scale; // if the current character doesn't fit in the line generate a new line if (x + dx > width && wrap) { lines[k].start = s; lines[k].length = i - s; lines[k].width = x; k++; s = i; x = 0; } x += dx; } else { rect rs = params.fontData.data[getCharIndex(c)]; f32 dx = (rs.width + params.fontData.advance) * scale; // if the current character doesn't fit in the line generate a new line if (x + dx > width && wrap) { lines[k].start = s; lines[k].length = i - s; lines[k].width = x; k++; s = i; x = 0; } x += dx; } } if (s < n && k < maxLines) { lines[k].start = s; lines[k].length = n - s; lines[k].width = x; k++; } // trim start and end spaces on lines if (params.trimming != WAR_TEXT_TRIM_NONE) { rect whiteSpaceData = params.fontData.data[getCharIndex(' ')]; f32 whiteSpaceWidth = (whiteSpaceData.width + params.fontData.advance) * scale; for (s32 j = 0; j < k; j++) { while (lines[j].length > 0) { char first = text.data[lines[j].start]; if (first == ' ' && params.trimming >= WAR_TEXT_TRIM_SPACES) { lines[j].width -= whiteSpaceWidth; lines[j].start++; lines[j].length--; } else if (first == '\t' && params.trimming >= WAR_TEXT_TRIM_ALL) { lines[j].width -= TAB_WIDTH * whiteSpaceWidth; lines[j].start++; lines[j].length--; } else break; } while (lines[j].length > 0) { char last = text.data[lines[j].start + lines[j].length - 1]; if (last == ' ' && params.trimming >= WAR_TEXT_TRIM_SPACES) { lines[j].width -= whiteSpaceWidth; lines[j].length--; } else if (last == '\t' && params.trimming >= WAR_TEXT_TRIM_ALL) { lines[j].width -= TAB_WIDTH * whiteSpaceWidth; lines[j].length--; } else break; } } } return k; } vec2 wfont_measureSingleSpriteText(StringView text, s32 length, WarFontParams params) { f32 scale = params.fontSize / params.fontData.lineHeight; vec2 size = VEC2_ZERO; StringView sv = wsv_slice(text, 0, (size_t)length); for (size_t i = 0; i < sv.length; i++) { char c = sv.data[i]; if (c == '\n') { size.x += params.fontData.advance * scale; } else if (c == '\t') { rect rs = params.fontData.data[getCharIndex(' ')]; size.x += (TAB_WIDTH * rs.width + params.fontData.advance) * scale; } else { rect rs = params.fontData.data[getCharIndex(c)]; size.x += (rs.width + params.fontData.advance) * scale; size.y = MAX(size.y, rs.height * scale); } } return size; } vec2 wfont_measureMultiSpriteText(StringView text, f32 width, WarFontParams params) { NOT_USED(width); f32 scale = params.fontSize / params.fontData.lineHeight; f32 lineHeight = params.lineHeight > 0 ? params.lineHeight : params.fontData.lineHeight; WarTextSpan lines[MAX_LINES]; s32 linesCount = wfont_splitTextIntoLines(text, MAX_LINES, lines, params.boundings.x, params); vec2 size = VEC2_ZERO; for (s32 i = 0; i < linesCount; i++) { size.x = MAX(size.x, lines[i].width); size.y += lineHeight * scale; } return size; } // Render a span of characters from the font sprite. // Uses SDL_SetTextureColorMod for tinting instead of nvgFillColor. f32 wfont_renderSingleSpriteTextSpan(WarContext* context, StringView text, s32 index, s32 count, f32 x, f32 y, WarColor fontColor, WarSprite fontSprite, WarFontData fontData, vec2 boundings, f32 scale) { if (count > 0) { wr_save(context); // Apply font color tint to the texture SDL_SetTextureColorMod(fontSprite.texture, fontColor.r, fontColor.g, fontColor.b); SDL_SetTextureAlphaMod(fontSprite.texture, fontColor.a); for (s32 i = 0; i < count; i++) { if (boundings.x > 0 && x * scale > boundings.x) break; const char c = text.data[index + i]; if (c == '\n') { // when we are rendering a single text span, all newline characters // are rendered as ' ' since a single text span is considered // a one line of text, it won't go to the next line rect rs = fontData.data[getCharIndex(' ')]; x += rs.width + fontData.advance; } else if (c == '\t') { rect rs = fontData.data[getCharIndex(' ')]; x += TAB_WIDTH * rs.width + fontData.advance; } else { rect rs = fontData.data[getCharIndex(c)]; rect rd = rectf(x, y, rs.width, rs.height); #ifdef DEBUG_RENDER_FONT wr_fillRect(context, rd, WAR_COLOR_GREEN_SELECTION); #endif if (c != ' ') { wr_subImage(context, fontSprite.texture, rs, rd, VEC2_ONE); } x += rs.width + fontData.advance; } } // Reset texture color mod to white SDL_SetTextureColorMod(fontSprite.texture, 255, 255, 255); SDL_SetTextureAlphaMod(fontSprite.texture, 255); wr_restore(context); } return x; } void wfont_renderSingleSpriteText(WarContext* context, StringView text, f32 x, f32 y, WarFontParams params) { f32 scale = params.fontSize / params.fontData.lineHeight; vec2 textSize = wfont_measureSingleSpriteText(text, -1, params); s32 length = (s32)wsv_length(text); wr_save(context); wr_translate(context, x, y); if (!VEC2_IS_ZERO(params.boundings)) { vec2 textOffset = wfont_getAlignmentOffset(params.horizontalAlign, params.verticalAlign, params.boundings, textSize); wr_translate(context, textOffset.x, textOffset.y); } wr_scale(context, scale, scale); #ifdef DEBUG_RENDER_FONT rect outline = rectf(0, 0, textSize.x / scale, 1.5f); wr_strokeRect(context, outline, WAR_COLOR_GREEN_SELECTION, 3); #endif if (params.highlightIndex >= 0) { x = wfont_renderSingleSpriteTextSpan(context, text, 0, params.highlightIndex, 0, 0, params.fontColor, params.fontSprite, params.fontData, params.boundings, scale); x = wfont_renderSingleSpriteTextSpan(context, text, params.highlightIndex, params.highlightCount, x, 0, params.highlightColor, params.fontSprite, params.fontData, params.boundings, scale); x = wfont_renderSingleSpriteTextSpan(context, text, params.highlightIndex + params.highlightCount, length - params.highlightIndex - params.highlightCount, x, 0, params.fontColor, params.fontSprite, params.fontData, params.boundings, scale); } else { // No highlight, highlightIndex = -1 // All highlight, highlightIndex = -2 WarColor fontColor = params.highlightIndex == ALL_HIGHLIGHT ? params.highlightColor : params.fontColor; wfont_renderSingleSpriteTextSpan(context, text, 0, length, 0, 0, fontColor, params.fontSprite, params.fontData, params.boundings, scale); } wr_restore(context); } void wfont_renderMultiSpriteText(WarContext* context, StringView text, f32 x, f32 y, WarFontParams params) { f32 scale = params.fontSize / params.fontData.lineHeight; f32 lineHeight = params.lineHeight > 0 ? params.lineHeight : params.fontData.lineHeight; WarTextSpan lines[MAX_LINES]; s32 linesCount = wfont_splitTextIntoLines(text, MAX_LINES, lines, params.boundings.x, params); wr_save(context); wr_translate(context, x, y); vec2 textSize = wfont_measureMultiSpriteText(text, params.boundings.x, params); vec2 textOffset = wfont_getAlignmentOffset(params.horizontalAlign, params.verticalAlign, params.boundings, textSize); wr_translate(context, textOffset.x, textOffset.y); #ifdef DEBUG_RENDER_FONT rect outline = rectf(0, 0, textSize.x, textSize.y); wr_strokeRect(context, outline, WAR_COLOR_RED_SELECTION, 1); #endif s32 lineStartIndex = 0; for (s32 i = 0; i < linesCount; i++) { s32 lineLength = lines[i].length; StringView lineView = wsv_slice(text, (size_t)lines[i].start, (size_t)lineLength); f32 lineAlignOffset = wfont_getLineAlignmentOffset(params.lineAlign, textSize.x, lines[i].width); vec2 lineOffset = vec2f(lineAlignOffset, i * lineHeight); if (lineOffset.y * scale > params.boundings.y) break; wr_save(context); wr_translate(context, lineOffset.x, 0); wr_scale(context, scale, scale); wr_translate(context, 0, lineOffset.y); #ifdef DEBUG_RENDER_FONT rect outline = rectf(0, 0, lines[i].width / scale, lineHeight); wr_strokeRect(context, outline, WAR_COLOR_GREEN_SELECTION, 1); #endif if (params.highlightIndex >= lineStartIndex && params.highlightIndex < lineStartIndex + lineLength) { s32 highlightIndex = params.highlightIndex - lineStartIndex; s32 highlightCount = MIN(params.highlightCount, lineLength - highlightIndex); x = wfont_renderSingleSpriteTextSpan(context, lineView, 0, highlightIndex, 0, 0, params.fontColor, params.fontSprite, params.fontData, params.boundings, scale); x = wfont_renderSingleSpriteTextSpan(context, lineView, highlightIndex, highlightCount, x, 0, params.highlightColor, params.fontSprite, params.fontData, params.boundings, scale); x = wfont_renderSingleSpriteTextSpan(context, lineView, highlightIndex + highlightCount, lineLength - highlightIndex - highlightCount, x, 0, params.fontColor, params.fontSprite, params.fontData, params.boundings, scale); } else if (params.highlightIndex < lineStartIndex && params.highlightIndex + params.highlightCount >= lineStartIndex) { s32 highlightCount = MIN(params.highlightIndex + params.highlightCount - lineStartIndex, lineLength); x = wfont_renderSingleSpriteTextSpan(context, lineView, 0, highlightCount, 0, 0, params.highlightColor, params.fontSprite, params.fontData, params.boundings, scale); x = wfont_renderSingleSpriteTextSpan(context, lineView, highlightCount, lineLength - highlightCount, x, 0, params.fontColor, params.fontSprite, params.fontData, params.boundings, scale); } else { // No highlight, highlightIndex = -1 // All highlight, highlightIndex = -2 WarColor fontColor = params.highlightIndex == ALL_HIGHLIGHT ? params.highlightColor : params.fontColor; wfont_renderSingleSpriteTextSpan(context, lineView, 0, lineLength, 0, 0, fontColor, params.fontSprite, params.fontData, params.boundings, scale); } wr_restore(context); lineStartIndex += lineLength; } wr_restore(context); } ================================================ FILE: src/war_font.h ================================================ #pragma once #include "war_math.h" #include "war_color.h" #include "war_sprites.h" #define FONT_NORMAL_COLOR_INIT WAR_COLOR_PACKED_INIT(0xFFDBFFEF) #define FONT_NORMAL_COLOR WAR_COLOR_PACKED(0xFFDBFFEF) #define FONT_HIGHLIGHT_COLOR_INIT WAR_COLOR_PACKED_INIT(0xFF49E3FF) #define FONT_HIGHLIGHT_COLOR WAR_COLOR_PACKED(0xFF49E3FF) #define NO_HIGHLIGHT -1 #define ALL_HIGHLIGHT -2 #define TAB_WIDTH 2 #define MAX_LINES 48 struct _WarFontData { s32 spriteWidth; s32 spriteHeight; s32 lineHeight; s32 advance; rect data[95]; }; typedef struct { s32 fontIndex; f32 fontSize; f32 lineHeight; WarColor fontColor; WarColor highlightColor; s32 highlightIndex; s32 highlightCount; vec2 boundings; WarTextAlignment horizontalAlign; WarTextAlignment verticalAlign; WarTextAlignment lineAlign; WarTextWrapping wrapping; WarTextTrimming trimming; WarSprite fontSprite; WarFontData fontData; } WarFontParams; WarSprite wfont_loadFontSprite(WarContext* context, StringView fontPath); WarFontData getFontData(s32 fontIndex); vec2 wfont_measureSingleSpriteText(StringView text, s32 length, WarFontParams params); vec2 wfont_measureMultiSpriteText(StringView text, f32 width, WarFontParams params); void wfont_renderSingleSpriteText(WarContext* context, StringView text, f32 x, f32 y, WarFontParams params); void wfont_renderMultiSpriteText(WarContext* context, StringView text, f32 x, f32 y, WarFontParams params); ================================================ FILE: src/war_fwd.h ================================================ #pragma once #include #include "war_enums.h" struct _WarInput; typedef struct _WarInput WarInput; struct _WarInputState; typedef struct _WarInputState WarInputState; struct _WarFontData; typedef struct _WarFontData WarFontData; struct _WarRawResource; typedef struct _WarRawResource WarRawResource; struct _WarFile; typedef struct _WarFile WarFile; struct _WarSpriteFrame; typedef struct _WarSpriteFrame WarSpriteFrame; struct _WarSprite; typedef struct _WarSprite WarSprite; struct _WarSpriteResourceRef; typedef struct _WarSpriteResourceRef WarSpriteResourceRef; struct _WarSpriteAnimation; typedef struct _WarSpriteAnimation WarSpriteAnimation; struct _WarLevelUnit; typedef struct _WarLevelUnit WarLevelUnit; struct _WarLevelConstruct; typedef struct _WarLevelConstruct WarLevelConstruct; struct _WarTilesetTile; typedef struct _WarTilesetTile WarTilesetTile; struct _WarCustomMapConfiguration; typedef struct _WarCustomMapConfiguration WarCustomMapConfiguration; struct _WarResource; typedef struct _WarResource WarResource; struct _WarUnitCommand; typedef struct _WarUnitCommand WarUnitCommand; struct _WarRoadPiece; typedef struct _WarRoadPiece WarRoadPiece; struct _WarWallPiece; typedef struct _WarWallPiece WarWallPiece; struct _WarRuinPiece; typedef struct _WarRuinPiece WarRuinPiece; struct _WarTree; typedef struct _WarTree WarTree; struct _WarUnitActionStep; typedef struct _WarUnitActionStep WarUnitActionStep; struct _WarUnitActionDef; typedef struct _WarUnitActionDef WarUnitActionDef; struct _WarUnitAction; typedef struct _WarUnitAction WarUnitAction; struct _WarUnitData; typedef struct _WarUnitData WarUnitData; struct _WarWorkerData; typedef struct _WarWorkerData WarWorkerData; struct _WarBuildingData; typedef struct _WarBuildingData WarBuildingData; struct _WarRoadData; typedef struct _WarRoadData WarRoadData; struct _WarWallData; typedef struct _WarWallData WarWallData; struct _WarRuinData; typedef struct _WarRuinData WarRuinData; struct _WarTreeData; typedef struct _WarTreeData WarTreeData; struct _WarUnitStats; typedef struct _WarUnitStats WarUnitStats; struct _WarBuildingStats; typedef struct _WarBuildingStats WarBuildingStats; struct _WarUpgradeData; typedef struct _WarUpgradeData WarUpgradeData; struct _WarUpgradeStats; typedef struct _WarUpgradeStats WarUpgradeStats; struct _WarSpellData; typedef struct _WarSpellData WarSpellData; struct _WarSpellStats; typedef struct _WarSpellStats WarSpellStats; struct _WarSpellMapping; typedef struct _WarSpellMapping WarSpellMapping; struct _WarUnitCommandBaseData; typedef struct _WarUnitCommandBaseData WarUnitCommandBaseData; struct _WarUnitCommandMapping; typedef struct _WarUnitCommandMapping WarUnitCommandMapping; struct _WarUnitCommandData; typedef struct _WarUnitCommandData WarUnitCommandData; struct _WarMapNode; typedef struct _WarMapNode WarMapNode; struct _WarMapPath; typedef struct _WarMapPath WarMapPath; struct _WarPathFinder; typedef struct _WarPathFinder WarPathFinder; struct _WarState; typedef struct _WarState WarState; struct _WarCampaignMapData; typedef struct _WarCampaignMapData WarCampaignMapData; struct _WarSpriteComponent; typedef struct _WarSpriteComponent WarSpriteComponent; struct _WarUnitComponent; typedef struct _WarUnitComponent WarUnitComponent; struct _WarAnimationsComponent; typedef struct _WarAnimationsComponent WarAnimationsComponent; struct _WarRoadComponent; typedef struct _WarRoadComponent WarRoadComponent; struct _WarWallComponent; typedef struct _WarWallComponent WarWallComponent; struct _WarRuinComponent; typedef struct _WarRuinComponent WarRuinComponent; struct _WarForestComponent; typedef struct _WarForestComponent WarForestComponent; struct _WarStateMachineComponent; typedef struct _WarStateMachineComponent WarStateMachineComponent; struct _WarUIComponent; typedef struct _WarUIComponent WarUIComponent; struct _WarTextComponent; typedef struct _WarTextComponent WarTextComponent; struct _WarRectComponent; typedef struct _WarRectComponent WarRectComponent; struct _WarButtonComponent; typedef struct _WarButtonComponent WarButtonComponent; struct _WarAudioComponent; typedef struct _WarAudioComponent WarAudioComponent; struct _WarCursorComponent; typedef struct _WarCursorComponent WarCursorComponent; struct _WarProjectileComponent; typedef struct _WarProjectileComponent WarProjectileComponent; struct _WarPoisonCloudComponent; typedef struct _WarPoisonCloudComponent WarPoisonCloudComponent; struct _WarSightComponent; typedef struct _WarSightComponent WarSightComponent; struct _WarEntity; typedef struct _WarEntity WarEntity; struct _WarMapTile; typedef struct _WarMapTile WarMapTile; struct _WarUpgrade; typedef struct _WarUpgrade WarUpgrade; struct _WarAICommand; typedef struct _WarAICommand WarAICommand; struct _WarAI; typedef struct _WarAI WarAI; struct _WarPlayerInfo; typedef struct _WarPlayerInfo WarPlayerInfo; struct _WarFlashStatus; typedef struct _WarFlashStatus WarFlashStatus; struct _WarCheatStatus; typedef struct _WarCheatStatus WarCheatStatus; struct _WarMapSettings; typedef struct _WarMapSettings WarMapSettings; struct _WarEntityManager; typedef struct _WarEntityManager WarEntityManager; struct _WarMap; typedef struct _WarMap WarMap; struct _WarScene; typedef struct _WarScene WarScene; struct _WarCheatDescriptor; typedef struct _WarCheatDescriptor WarCheatDescriptor; struct _WarSceneDescriptor; typedef struct _WarSceneDescriptor WarSceneDescriptor; struct _WarTransformComponent; typedef struct _WarTransformComponent WarTransformComponent; struct _WarRenderState; typedef struct _WarRenderState WarRenderState; struct _WarImuiSpriteEntry; typedef struct _WarImuiSpriteEntry WarImuiSpriteEntry; struct _WarImuiState; typedef struct _WarImuiState WarImuiState; struct _WarContext; typedef struct _WarContext WarContext; typedef uint16_t WarEntityId; typedef void (*WarClickHandler)(WarContext* context, WarEntity* entity); typedef WarLevelResult (*WarCheckObjectivesFunc)(WarContext* context); typedef void (*WarCheatFunc)(WarContext* context, StringView argument); typedef void (*WarRenderFunc)(WarContext* context, WarEntity* entity); typedef int32_t (*WarRenderCompareFunc)(const WarEntity* e1, const WarEntity* e2, void* userdata); typedef void (*WarSceneFunc)(WarContext* context); ================================================ FILE: src/war_game.c ================================================ #include "war_game.h" #include #include #if defined(_MSC_VER) && !defined(__clan_) #include #ifndef F_OK #define F_OK 0 #endif #define access _access #else #include #endif #include "shl/memzone.h" #include "shl/wstr.h" #include "war_alloc.h" #include "war_actions.h" #include "war_audio.h" #include "war_file.h" #include "war_font.h" #include "war.h" #include "war_imui.h" #include "war_map.h" #include "war_resources.h" #include "war_scenes.h" static WarKeys wg_getWarKeyFromSDLKey(SDL_Keycode key) { switch (key) { case SDLK_SPACE: return WAR_KEY_SPACE; case SDLK_APOSTROPHE: return WAR_KEY_APOSTROPHE; case SDLK_COMMA: return WAR_KEY_COMMA; case SDLK_MINUS: return WAR_KEY_MINUS; case SDLK_PERIOD: return WAR_KEY_PERIOD; case SDLK_SLASH: return WAR_KEY_SLASH; case SDLK_0: return WAR_KEY_0; case SDLK_1: return WAR_KEY_1; case SDLK_2: return WAR_KEY_2; case SDLK_3: return WAR_KEY_3; case SDLK_4: return WAR_KEY_4; case SDLK_5: return WAR_KEY_5; case SDLK_6: return WAR_KEY_6; case SDLK_7: return WAR_KEY_7; case SDLK_8: return WAR_KEY_8; case SDLK_9: return WAR_KEY_9; case SDLK_SEMICOLON: return WAR_KEY_SEMICOLON; case SDLK_EQUALS: return WAR_KEY_EQUAL; case SDLK_A: return WAR_KEY_A; case SDLK_B: return WAR_KEY_B; case SDLK_C: return WAR_KEY_C; case SDLK_D: return WAR_KEY_D; case SDLK_E: return WAR_KEY_E; case SDLK_F: return WAR_KEY_F; case SDLK_G: return WAR_KEY_G; case SDLK_H: return WAR_KEY_H; case SDLK_I: return WAR_KEY_I; case SDLK_J: return WAR_KEY_J; case SDLK_K: return WAR_KEY_K; case SDLK_L: return WAR_KEY_L; case SDLK_M: return WAR_KEY_M; case SDLK_N: return WAR_KEY_N; case SDLK_O: return WAR_KEY_O; case SDLK_P: return WAR_KEY_P; case SDLK_Q: return WAR_KEY_Q; case SDLK_R: return WAR_KEY_R; case SDLK_S: return WAR_KEY_S; case SDLK_T: return WAR_KEY_T; case SDLK_U: return WAR_KEY_U; case SDLK_V: return WAR_KEY_V; case SDLK_W: return WAR_KEY_W; case SDLK_X: return WAR_KEY_X; case SDLK_Y: return WAR_KEY_Y; case SDLK_Z: return WAR_KEY_Z; case SDLK_LEFTBRACKET: return WAR_KEY_LEFT_BRACKET; case SDLK_BACKSLASH: return WAR_KEY_BACKSLASH; case SDLK_RIGHTBRACKET: return WAR_KEY_RIGHT_BRACKET; case SDLK_GRAVE: return WAR_KEY_GRAVE_ACCENT; case SDLK_ESCAPE: return WAR_KEY_ESC; case SDLK_RETURN: return WAR_KEY_ENTER; case SDLK_KP_ENTER: return WAR_KEY_ENTER; case SDLK_TAB: return WAR_KEY_TAB; case SDLK_BACKSPACE: return WAR_KEY_BACKSPACE; case SDLK_INSERT: return WAR_KEY_INSERT; case SDLK_DELETE: return WAR_KEY_DELETE; case SDLK_RIGHT: return WAR_KEY_RIGHT; case SDLK_LEFT: return WAR_KEY_LEFT; case SDLK_DOWN: return WAR_KEY_DOWN; case SDLK_UP: return WAR_KEY_UP; case SDLK_PAGEUP: return WAR_KEY_PAGE_UP; case SDLK_PAGEDOWN: return WAR_KEY_PAGE_DOWN; case SDLK_HOME: return WAR_KEY_HOME; case SDLK_END: return WAR_KEY_END; case SDLK_F1: return WAR_KEY_F1; case SDLK_F2: return WAR_KEY_F2; case SDLK_F3: return WAR_KEY_F3; case SDLK_F4: return WAR_KEY_F4; case SDLK_F5: return WAR_KEY_F5; case SDLK_F6: return WAR_KEY_F6; case SDLK_F7: return WAR_KEY_F7; case SDLK_F8: return WAR_KEY_F8; case SDLK_F9: return WAR_KEY_F9; case SDLK_F10: return WAR_KEY_F10; case SDLK_F11: return WAR_KEY_F11; case SDLK_F12: return WAR_KEY_F12; case SDLK_KP_MULTIPLY: return WAR_KEY_ASTERISK; case SDLK_KP_PLUS: return WAR_KEY_PLUS; case SDLK_KP_0: return WAR_KEY_0; case SDLK_KP_1: return WAR_KEY_1; case SDLK_KP_2: return WAR_KEY_2; case SDLK_KP_3: return WAR_KEY_3; case SDLK_KP_4: return WAR_KEY_4; case SDLK_KP_5: return WAR_KEY_5; case SDLK_KP_6: return WAR_KEY_6; case SDLK_KP_7: return WAR_KEY_7; case SDLK_KP_8: return WAR_KEY_8; case SDLK_KP_9: return WAR_KEY_9; case SDLK_KP_MINUS: return WAR_KEY_MINUS; case SDLK_KP_PERIOD: return WAR_KEY_PERIOD; case SDLK_KP_DIVIDE: return WAR_KEY_SLASH; case SDLK_KP_EQUALS: return WAR_KEY_EQUAL; case SDLK_LSHIFT: case SDLK_RSHIFT: return WAR_KEY_SHIFT; case SDLK_LCTRL: case SDLK_RCTRL: return WAR_KEY_CTRL; case SDLK_LALT: case SDLK_RALT: return WAR_KEY_ALT; default: return WAR_KEY_NONE; } } static void wg_appendCheatTextInput(WarContext* context, StringView text) { WarScene* scene = context->scene; WarMap* map = context->map; assert(scene || map); WarCheatStatus* cheatStatus = scene ? &scene->cheatStatus : &map->cheatStatus; if (!cheatStatus->enabled || !cheatStatus->visible) { return; } const char* cursor = wsv_data(text); size_t remaining = text.length; while (remaining > 0) { Uint32 codepoint = SDL_StepUTF8(&cursor, &remaining); if (codepoint >= 32 && codepoint <= 126) { s32 length = (s32)cheatStatus->text.length; if (length + 1 < CHEAT_TEXT_MAX_LENGTH) { char c = (char)codepoint; wstr_insert(&cheatStatus->text, cheatStatus->position, wsv_fromParts(&c, 1)); cheatStatus->position++; } } } } bool wg_initGame(WarContext* context) { context->globalScale = 3; context->globalSpeed = 1; context->originalWindowWidth = 320; context->originalWindowHeight = 200; context->windowWidth = (s32)(context->originalWindowWidth * context->globalScale); context->windowHeight = (s32)(context->originalWindowHeight * context->globalScale); wstr_assignCString(&context->windowTitle, "War 1"); context->window = SDL_CreateWindow(wstr_cstr(&context->windowTitle), context->windowWidth, context->windowHeight, 0); if (!context->window) { logError("Error creating SDL window: %s", SDL_GetError()); SDL_Quit(); return false; } context->renderer = SDL_CreateRenderer(context->window, NULL); if (!context->renderer) { logError("Error creating SDL renderer: %s", SDL_GetError()); SDL_DestroyWindow(context->window); SDL_Quit(); return false; } // Set logical presentation so all rendering is in 320x200 space. // SDL handles upscaling to the actual window size. if (!SDL_SetRenderLogicalPresentation(context->renderer, context->originalWindowWidth, context->originalWindowHeight, SDL_LOGICAL_PRESENTATION_INTEGER_SCALE)) { logError("Error setting logical presentation: %s", SDL_GetError()); SDL_DestroyRenderer(context->renderer); SDL_DestroyWindow(context->window); SDL_Quit(); return false; } // Initialize render state stack wr_init(context); context->transitionDelay = 0.0f; context->cheatsEnabled = true; context->__mutex = SDL_CreateMutex(); SDL_HideCursor(); // init audio if (!wa_initAudio(context)) { logError("Could not initialize audio."); return false; } // load fonts context->fontSprites[0] = wfont_loadFontSprite(context, wsv_fromCString("./war1_font_1.png")); context->fontSprites[1] = wfont_loadFontSprite(context, wsv_fromCString("./war1_font_2.png")); // check if the DATA.WAR file exists bool dataFileExists = access(DATAWAR_FILE_PATH, F_OK) == 0; if (dataFileExists) { // load DATA.WAR file if (!wg_loadDataFile(context)) { logError("Could not load file: %s", DATAWAR_FILE_PATH); return false; } WarScene* scene = wsc_createScene(context, WAR_SCENE_BLIZZARD); wg_setNextScene(context, scene, 0.0f); } else { WarScene* scene = wsc_createScene(context, WAR_SCENE_DOWNLOAD); wg_setNextScene(context, scene, 0.0f); } wact_initUnitActionDefs(); context->time = SDL_GetTicks() / 1000.0f; return true; } void wg_quitGame(WarContext* context) { // Destroy audio stream (this also closes the audio device) if (context->audioStream) { SDL_DestroyAudioStream(context->audioStream); context->audioStream = NULL; } if (context->soundFont) { tsf_close(context->soundFont); context->soundFont = NULL; } if (context->audioRemoveMutex) { SDL_DestroyMutex(context->audioRemoveMutex); context->audioRemoveMutex = NULL; } if (context->audioMixBuffer) { wm_free(context->audioMixBuffer); context->audioMixBuffer = NULL; context->audioMixBufferCapacity = 0; } if (context->__mutex) { SDL_DestroyMutex(context->__mutex); context->__mutex = NULL; } if (context->renderer) { SDL_DestroyRenderer(context->renderer); context->renderer = NULL; } if (context->window) { SDL_DestroyWindow(context->window); context->window = NULL; } wstr_free(context->windowTitle); SDL_Quit(); } bool wg_loadDataFile(WarContext* context) { context->warFile = wfile_loadWarFile(context, wsv_fromCString(DATAWAR_FILE_PATH)); if (!context->warFile) { return false; } for (int i = 0; i < arrayLength(assets); ++i) { DatabaseEntry entry = assets[i]; wres_loadResource(context, &entry); } return true; } void wg_setWindowSize(WarContext* context, s32 width, s32 height) { context->windowWidth = width; context->windowHeight = height; SDL_SetWindowSize(context->window, context->windowWidth, context->windowHeight); } void wg_setGlobalScale(WarContext* context, f32 scale) { context->globalScale = MAX(scale, 1.0f); logDebug("set global scale to: %.2f", context->globalScale); s32 newWidth = (s32)(context->originalWindowWidth * context->globalScale); s32 newHeight = (s32)(context->originalWindowHeight * context->globalScale); wg_setWindowSize(context, newWidth, newHeight); } void wg_changeGlobalScale(WarContext* context, f32 deltaScale) { wg_setGlobalScale(context, context->globalScale + deltaScale); } void wg_setGlobalSpeed(WarContext* context, f32 speed) { context->globalSpeed = MAX(speed, 1.0f); logDebug("set global speed to: %.2f", context->globalSpeed); } void wg_changeGlobalSpeed(WarContext* context, f32 deltaSpeed) { wg_setGlobalSpeed(context, context->globalSpeed + deltaSpeed); } void wg_setMusicVolume(WarContext* context, f32 volume) { context->musicVolume = CLAMP(volume, 0.0f, 1.0f); logDebug("set music volume to: %.2f", context->musicVolume); } void wg_changeMusicVolume(WarContext* context, f32 deltaVolume) { wg_setMusicVolume(context, context->musicVolume + deltaVolume); } void wg_setSoundVolume(WarContext* context, f32 volume) { context->soundVolume = CLAMP(volume, 0.0f, 1.0f); logDebug("set sound volume to: %.2f", context->soundVolume); } void wg_changeSoundVolume(WarContext* context, f32 deltaVolume) { wg_setSoundVolume(context, context->soundVolume + deltaVolume); } void wg_setNextScene(WarContext* context, WarScene* scene, f32 transitionDelay) { context->nextScene = scene; context->transitionDelay = transitionDelay; } void wg_setNextMap(WarContext* context, WarMap* map, f32 transitionDelay) { context->nextMap = map; context->transitionDelay = transitionDelay; } void wg_setInputButton(WarContext* context, s32 button, bool pressed) { WarInput* input = &context->input; WarInputState* state = &input->buttons[button]; if (pressed && !state->held) { state->justPressed = true; } else if (!pressed && state->held) { state->justReleased = true; } state->held = pressed; } void wg_setInputKey(WarContext* context, s32 key, bool pressed) { WarInput* input = &context->input; WarInputState* state = &input->keys[key]; if (pressed && !state->held) { state->justPressed = true; } else if (!pressed && state->held) { state->justReleased = true; } state->held = pressed; } void wg_beginInputFrame(WarContext* context) { WarInput* input = &context->input; for (s32 i = 0; i < WAR_MOUSE_COUNT; ++i) { input->buttons[i].justPressed = false; input->buttons[i].justReleased = false; } for (s32 i = 0; i < WAR_KEY_COUNT; ++i) { input->keys[i].justPressed = false; input->keys[i].justReleased = false; } } void wg_processGameEvent(WarContext* context, SDL_Event* event) { WarInput* input = &context->input; // NOTE: Convert event coordinates from window space to logical render space (320x200). // SDL_SetRenderLogicalPresentation does NOT do this automatically in SDL3. SDL_ConvertEventToRenderCoordinates(context->renderer, event); switch (event->type) { case SDL_EVENT_MOUSE_MOTION: { input->pos = vec2f((f32)floorf(event->motion.x), (f32)floorf(event->motion.y)); break; } case SDL_EVENT_MOUSE_BUTTON_DOWN: case SDL_EVENT_MOUSE_BUTTON_UP: { input->pos = vec2f((f32)floorf(event->button.x), (f32)floorf(event->button.y)); if (event->button.button == SDL_BUTTON_LEFT) { wg_setInputButton(context, WAR_MOUSE_LEFT, event->button.down); } else if (event->button.button == SDL_BUTTON_RIGHT) { wg_setInputButton(context, WAR_MOUSE_RIGHT, event->button.down); } break; } case SDL_EVENT_KEY_DOWN: case SDL_EVENT_KEY_UP: { WarKeys key = wg_getWarKeyFromSDLKey(event->key.key); if (key != WAR_KEY_NONE) { bool pressed = event->type == SDL_EVENT_KEY_DOWN; if (key == WAR_KEY_SHIFT) { wg_setInputKey(context, key, (event->key.mod & SDL_KMOD_SHIFT) != 0); } else if (key == WAR_KEY_CTRL) { wg_setInputKey(context, key, (event->key.mod & SDL_KMOD_CTRL) != 0); } else if (key == WAR_KEY_ALT) { wg_setInputKey(context, key, (event->key.mod & SDL_KMOD_ALT) != 0); } else { wg_setInputKey(context, key, pressed); } } break; } case SDL_EVENT_TEXT_INPUT: wg_appendCheatTextInput(context, wsv_fromCString(event->text.text)); break; case SDL_EVENT_WINDOW_FOCUS_GAINED: if (!SDL_SetWindowMouseGrab(context->window, true)) { logError("Error setting window mouse grab: %s", SDL_GetError()); } break; case SDL_EVENT_WINDOW_FOCUS_LOST: case SDL_EVENT_WINDOW_MINIMIZED: case SDL_EVENT_WINDOW_HIDDEN: { for (s32 i = 0; i < WAR_MOUSE_COUNT; ++i) { input->buttons[i].held = false; input->buttons[i].justPressed = false; input->buttons[i].justReleased = false; } for (s32 i = 0; i < WAR_KEY_COUNT; ++i) { input->keys[i].held = false; input->keys[i].justPressed = false; input->keys[i].justReleased = false; } input->capturedUIButtonId = 0; input->mapDragActive = false; input->mapDragStartPos = VEC2_ZERO; input->mapDragRect = RECT_EMPTY; if (!SDL_SetWindowMouseGrab(context->window, false)) { logError("Error setting window mouse grab: %s", SDL_GetError()); } break; } default: break; } } void wg_updateGame(WarContext* context) { TracyCZoneN(ctx, "UpdateGame", 1); mz_reset(frameZone); // Drain entity removals that the audio callback thread queued while we were // in the previous tick. We do this on the main thread (before any scene or // map update) so that we_removeEntityById never runs concurrently with audio. if (context->audioRemoveMutex) { SDL_LockMutex(context->audioRemoveMutex); s32 drainCount = context->audioRemovePendingCount; WarEntityId drainIds[AUDIO_REMOVE_PENDING_MAX]; for (s32 i = 0; i < drainCount; i++) drainIds[i] = context->audioRemovePending[i]; context->audioRemovePendingCount = 0; SDL_UnlockMutex(context->audioRemoveMutex); for (s32 i = 0; i < drainCount; i++) we_removeEntityById(context, drainIds[i]); } WarInput* input = &context->input; if (isKeyHeld(input, WAR_KEY_CTRL) && isKeyJustReleased(input, WAR_KEY_P)) { context->paused = !context->paused; } if (context->paused) { TracyCZoneEnd(ctx); return; } if (context->nextScene) { context->audioEnabled = false; if (context->scene) wsc_leaveScene(context); else if (context->map) wmap_leaveMap(context); context->scene = context->nextScene; context->nextScene = NULL; wsc_enterScene(context); context->audioEnabled = true; } else if (context->nextMap) { context->audioEnabled = false; if (context->scene) wsc_leaveScene(context); else if (context->map) wmap_leaveMap(context); context->map = context->nextMap; context->nextMap = NULL; wmap_enterMap(context); context->audioEnabled = true; } if (context->transitionDelay > 0) { context->transitionDelay = MAX(context->transitionDelay - context->deltaTime, 0.0f); TracyCZoneEnd(ctx); return; } if (context->scene) { wsc_updateScene(context); } else if (context->map) { wmap_updateMap(context); } else { logError("There is no map or scene active."); } TracyCZoneEnd(ctx); } void wg_renderGame(WarContext *context) { TracyCZoneN(ctx, "RenderGame", 1); // Clear the screen (black) SDL_SetRenderDrawColor(context->renderer, 0, 0, 0, 255); SDL_RenderClear(context->renderer); // don't render anything if it's transitioning if (context->transitionDelay > 0) { TracyCZoneEnd(ctx); return; } // Reset render state for this frame wr_init(context); // Begin IMGUI pass — resets hot item, tooltip deferral, and is_mouse_over_ui. imui_begin(context); if (context->scene) { wsc_renderScene(context); } else if (context->map) { wmap_renderMap(context); } // End IMGUI pass — draws deferred tooltip on top of everything, clears active item. imui_end(context); TracyCZoneEnd(ctx); } void wg_presentGame(WarContext *context) { SDL_RenderPresent(context->renderer); f32 currentTime = SDL_GetTicks() / 1000.0f; context->deltaTime = (currentTime - context->time); TracyCZoneN(waitCtx, "FrameWait", 1); // sleep until the end of the frame to save CPU and battery, but only if we have time left in the frame SDL_Delay((s32)(MAX(0.0f, SECONDS_PER_FRAME - context->deltaTime) * 1000)); context->waitTime = SDL_GetTicks() / 1000.0f - currentTime; TracyCZoneEnd(waitCtx); context->time = currentTime; context->fps = (u32)(1.0f / context->deltaTime); TracyCPlotI("FPS", (s64)context->fps); TracyCPlotF("DeltaTime_ms", context->deltaTime * 1000.0f); } ================================================ FILE: src/war_game.h ================================================ #pragma once #include "SDL3/SDL_events.h" #include "common.h" #include "war_fwd.h" bool wg_initGame(WarContext* context); void wg_quitGame(WarContext* context); bool wg_loadDataFile(WarContext* context); void wg_setWindowSize(WarContext* context, s32 width, s32 height); void wg_setGlobalScale(WarContext* context, f32 scale); void wg_changeGlobalScale(WarContext* context, f32 deltaScale); void wg_setGlobalSpeed(WarContext* context, f32 speed); void wg_changeGlobalSpeed(WarContext* context, f32 deltaSpeed); void wg_setMusicVolume(WarContext* context, f32 volume); void wg_changeMusicVolume(WarContext* context, f32 deltaVolume); void wg_setSoundVolume(WarContext* context, f32 volume); void wg_changeSoundVolume(WarContext* context, f32 deltaVolume); void wg_setNextScene(WarContext* context, WarScene* scene, f32 transitionDelay); void wg_setNextMap(WarContext* context, WarMap* map, f32 transitionDelay); void wg_setInputButton(WarContext* context, s32 button, bool pressed); void wg_setInputKey(WarContext* context, s32 key, bool pressed); void wg_beginInputFrame(WarContext* context); void wg_processGameEvent(WarContext* context, SDL_Event* event); void wg_updateGame(WarContext* context); void wg_renderGame(WarContext *context); void wg_presentGame(WarContext *context); ================================================ FILE: src/war_imui.c ================================================ #include "war_imui.h" #include #include #include "war_audio.h" #include "war_font.h" #include "war_render.h" #include "war_resources.h" #include "war_sprites.h" // --------------------------------------------------------------------------- // Internal helpers // --------------------------------------------------------------------------- // Return the cached WarSprite for the given (resourceIndex, frameIndex) pair, // creating it on first use. Each unique pair has its own SDL_Texture // pre-loaded with the correct frame's pixel data so multiple frames of the // same resource can be rendered in a single pass without SDL_UpdateTexture // conflicts. A ref with resourceIndex < 0 (invalidRef) returns a // zero-initialised sprite. static WarSprite imui_getOrCreateSprite(WarContext* context, WarSpriteResourceRef ref, s32 frameIndex) { if (ref.resourceIndex < 0) { return (WarSprite){0}; } WarImuiState* imui = &context->imui; // Search for an existing cache entry. // Track the least recently used entry for eviction if needed. s32 lruIndex = 0; for (s32 i = 0; i < imui->spriteCacheCount; i++) { WarImuiSpriteEntry* entry = &imui->spriteCache[i]; if (entry->resourceIndex == ref.resourceIndex && entry->frameIndex == frameIndex) { return entry->sprite; } if (entry->lastUsedFrame < imui->spriteCache[lruIndex].lastUsedFrame) { lruIndex = i; } } WarSprite sprite = wspr_createSpriteFromResourceIndex(context, ref); if (frameIndex >= 0 && frameIndex < sprite.framesCount) { WarSpriteFrame frame = wspr_getSpriteFrame(context, sprite, frameIndex); wspr_updateSpriteImage(context, sprite, frame.data); } if (imui->spriteCacheCount < IMUI_SPRITE_CACHE_SIZE) { imui->spriteCache[imui->spriteCacheCount].resourceIndex = ref.resourceIndex; imui->spriteCache[imui->spriteCacheCount].frameIndex = frameIndex; imui->spriteCache[imui->spriteCacheCount].sprite = sprite; imui->spriteCacheCount++; return sprite; } logDebug("IMUI sprite cache full, evicting resource %d frame %d last used at frame %u", imui->spriteCache[lruIndex].resourceIndex, imui->spriteCache[lruIndex].frameIndex, imui->spriteCache[lruIndex].lastUsedFrame); // Evict the least recently used sprite. WarImuiSpriteEntry* lruEntry = &imui->spriteCache[lruIndex]; wspr_freeSprite(context, lruEntry->sprite); lruEntry->resourceIndex = ref.resourceIndex; lruEntry->frameIndex = frameIndex; lruEntry->lastUsedFrame = context->frameCount; lruEntry->sprite = sprite; return sprite; } // Store tooltip deferral data from a hovered button. void imui_deferTooltip(WarContext* context, StringView tooltip, s32 highlightIndex, s32 highlightCount, s32 gold, s32 wood) { WarImuiState* imui = &context->imui; imui->show_tooltip = true; imui->tooltip_highlight_index = highlightIndex; imui->tooltip_highlight_count = highlightCount; imui->tooltip_gold = gold; imui->tooltip_wood = wood; if (tooltip.data && tooltip.length > 0) { size_t copyLen = MIN(tooltip.length, IMUI_TOOLTIP_TEXT_MAX - 1); memcpy(imui->tooltip_text, tooltip.data, copyLen); imui->tooltip_text[copyLen] = '\0'; } else { imui->tooltip_text[0] = '\0'; } } // --------------------------------------------------------------------------- // Lifecycle // --------------------------------------------------------------------------- void imui_begin(WarContext* context) { WarImuiState* imui = &context->imui; imui->hot_item = 0; imui->is_mouse_over_ui = false; imui->show_tooltip = false; imui->tooltip_text[0] = '\0'; imui->tooltip_highlight_index = NO_HIGHLIGHT; imui->tooltip_highlight_count = 0; imui->tooltip_gold = 0; imui->tooltip_wood = 0; imui->cursor_type = WAR_CURSOR_ARROW; imui->hotkeys_enabled = true; // NOTE: active_item and spriteCache are intentionally NOT reset here. // active_item persists until the mouse button is released (cleared in imui_end). // spriteCache persists for the lifetime of the context. } void imui_end(WarContext* context) { WarImuiState* imui = &context->imui; WarInput* input = &context->input; WarMap* map = context->map; // Clear the active item once the left mouse button is fully released. if (!isButtonHeld(input, WAR_MOUSE_LEFT)) { imui->active_item = 0; } // Draw deferred tooltip text on top of all other rendered content. // The tooltip is rendered at the map's status-bar position (bottom panel, // offset vec2i(2, 5) relative to recti(72, 188, 240, 12)). if (imui->show_tooltip && imui->tooltip_text[0] != '\0' && context->map) { WarFontParams params; params.fontIndex = 0; params.fontSize = 6.0f; params.lineHeight = 0.0f; params.fontColor = FONT_NORMAL_COLOR; params.highlightColor = FONT_HIGHLIGHT_COLOR; params.highlightIndex = imui->tooltip_highlight_index; params.highlightCount = imui->tooltip_highlight_count; params.boundings = vec2f(0.0f, 0.0f); params.horizontalAlign = WAR_TEXT_ALIGN_LEFT; params.verticalAlign = WAR_TEXT_ALIGN_TOP; params.lineAlign = WAR_TEXT_ALIGN_LEFT; params.wrapping = WAR_TEXT_WRAP_NONE; params.trimming = WAR_TEXT_TRIM_NONE; params.fontSprite = context->fontSprites[0]; params.fontData = getFontData(0); StringView tooltipView = wsv_fromCString(imui->tooltip_text); // Render directly at the status-bar text position to match the retained UI. wr_save(context); wfont_renderSingleSpriteText(context, tooltipView, 74.0f, 193.0f, params); wr_restore(context); // If the tooltip includes gold or wood costs, render those icons + amounts to the right of the text. if (imui->tooltip_gold > 0 || imui->tooltip_wood > 0) { vec2 bottomPanel = RECT_TOP_LEFT(map->bottomPanel); if (imui->tooltip_wood > 0) { WarSprite woodSprite = imui_getOrCreateSprite(context, imageResourceRef(407), 0); if (woodSprite.texture) { vec2 iconPos = vec2_addv(bottomPanel, vec2i(163, 3)); vec2 textPos = vec2_addv(bottomPanel, vec2i(179, 5)); wr_save(context); wr_translate(context, iconPos.x, iconPos.y); wspr_renderSprite(context, woodSprite, VEC2_ZERO, VEC2_ONE); wr_restore(context); char woodText[16]; StringView woodTextStr = wsv_fromCStringFormat(woodText, arrayLength(woodText), "%d", imui->tooltip_wood); wfont_renderSingleSpriteText(context, woodTextStr, textPos.x, textPos.y, params); } } if (imui->tooltip_gold > 0) { WarSprite goldSprite = imui_getOrCreateSprite(context, imageResourceRef(406), 0); if (goldSprite.texture) { vec2 iconPos = vec2_addv(bottomPanel, vec2i(200, 5)); vec2 textPos = vec2_addv(bottomPanel, vec2i(218, 5)); wr_save(context); wr_translate(context, iconPos.x, iconPos.y); wspr_renderSprite(context, goldSprite, VEC2_ZERO, VEC2_ONE); wr_restore(context); char goldText[16]; StringView goldTextStr = wsv_fromCStringFormat(goldText, arrayLength(goldText), "%d", imui->tooltip_gold); wfont_renderSingleSpriteText(context, goldTextStr, textPos.x, textPos.y, params); } } } } // Draw the cursor sprite on top of everything else. // The hotspot offset is read from the cursor resource so the sprite is // positioned so that the logical pointer tip sits at the mouse coordinates. { WarSpriteResourceRef cursorRef = imageResourceRef(imui->cursor_type); WarSprite cursorSprite = imui_getOrCreateSprite(context, cursorRef, 0); if (cursorSprite.texture) { WarResource* resource = wres_getOrCreateResource(context, imui->cursor_type); assert(resource->type == WAR_RESOURCE_TYPE_CURSOR); vec2 hotspot = vec2i(resource->cursor.hotx, resource->cursor.hoty); vec2 pos = vec2_subv(input->pos, hotspot); wr_save(context); wr_translate(context, pos.x, pos.y); wspr_renderSprite(context, cursorSprite, VEC2_ZERO, VEC2_ONE); wr_restore(context); } } } // --------------------------------------------------------------------------- // Primitives // --------------------------------------------------------------------------- void imui_text(WarContext* context, const char* id, const CreateUITextArgs* args) { NOT_USED(id); assert(args); WarFontParams params; params.fontIndex = args->fontIndex; params.fontSize = args->fontSize; params.lineHeight = args->lineHeight; params.fontColor = args->fontColor; params.highlightColor = args->highlightColor; params.highlightIndex = args->highlightIndex; params.highlightCount = args->highlightCount; params.boundings = args->boundings; params.horizontalAlign = args->horizontalAlign; params.verticalAlign = args->verticalAlign; params.lineAlign = args->lineAlign; params.wrapping = args->wrapping; params.trimming = args->trimming; params.fontSprite = context->fontSprites[args->fontIndex]; params.fontData = getFontData(args->fontIndex); wr_save(context); wr_translate(context, args->position.x, args->position.y); wr_scale(context, args->scale.x, args->scale.y); if (args->multiline) { wfont_renderMultiSpriteText(context, args->text, 0.0f, 0.0f, params); } else { wfont_renderSingleSpriteText(context, args->text, 0.0f, 0.0f, params); } wr_restore(context); } void imui_rect(WarContext* context, const char* id, const CreateUIRectArgs* args) { NOT_USED(id); assert(args); wr_save(context); wr_translate(context, args->position.x, args->position.y); wr_scale(context, args->scale.x, args->scale.y); rect r = rectv(VEC2_ZERO, args->size); wr_fillRect(context, r, args->color); wr_restore(context); } void imui_image(WarContext* context, const char* id, const CreateUIImageArgs* args) { NOT_USED(id); assert(args); WarSprite sprite = imui_getOrCreateSprite(context, args->spriteRef, 0); if (!sprite.texture) { return; } wr_save(context); wr_translate(context, args->position.x, args->position.y); wr_scale(context, args->scale.x, args->scale.y); wspr_renderSprite(context, sprite, VEC2_ZERO, VEC2_ONE); wr_restore(context); } // Draw a specific frame of a sprite resource. Unlike imui_image (which always // renders frame 0), this function keys the cache on (resourceIndex, frameIndex) // so multiple frames of the same resource can be drawn in a single pass. void imui_image_frame(WarContext* context, const char* id, const CreateUIImageArgs* args, s32 frameIndex) { NOT_USED(id); assert(args); WarSprite sprite = imui_getOrCreateSprite(context, args->spriteRef, frameIndex); if (!sprite.texture) { return; } WarSpriteFrame frame = wspr_getSpriteFrame(context, sprite, frameIndex); wr_save(context); wr_translate(context, -(f32)frame.dx, -(f32)frame.dy); wr_translate(context, args->position.x, args->position.y); wr_scale(context, args->scale.x, args->scale.y); wspr_renderSprite(context, sprite, VEC2_ZERO, VEC2_ONE); wr_restore(context); } // --------------------------------------------------------------------------- // Internal: shared button click/hover logic // --------------------------------------------------------------------------- // Evaluate hover + active state for a button rect. // Sets hot_item / active_item, updates is_mouse_over_ui. // Returns true the frame the button is considered clicked. static bool imui_evalButton(WarContext* context, u32 itemId, rect buttonRect, WarKeys hotKey) { WarInput* input = &context->input; WarImuiState* imui = &context->imui; bool isHovered = rect_containsf(buttonRect, input->pos.x, input->pos.y); if (isHovered) { imui->hot_item = itemId; imui->is_mouse_over_ui = true; if (isButtonJustPressed(input, WAR_MOUSE_LEFT)) { imui->active_item = itemId; } } // Hot-key: fires immediately on key release regardless of mouse position. // Suppressed when hotkeys_enabled is false (e.g. cheat panel is open). if (imui->hotkeys_enabled && hotKey != WAR_KEY_NONE && isKeyJustReleased(input, hotKey)) { return true; } // Mouse click: fires when released over the same item that was pressed. if (isButtonJustReleased(input, WAR_MOUSE_LEFT) && imui->active_item == itemId) { if (isHovered) { wa_createAudio(context, CREATE_AUDIO_ARGS_INIT(.audioId = WAR_UI_CLICK, .loop = false)); return true; } } return false; } // --------------------------------------------------------------------------- // Interactive elements // --------------------------------------------------------------------------- bool imui_image_button(WarContext* context, const char* id, const CreateUIImageButtonArgs* args) { assert(id); assert(args); if (!args->interactive) { return false; } u32 itemId = imui_hashCString(id); WarSprite normalSprite = imui_getOrCreateSprite(context, args->backgroundNormalRef, 0); WarSprite pressedSprite = imui_getOrCreateSprite(context, args->backgroundPressedRef, 0); WarSprite fgSprite = imui_getOrCreateSprite(context, args->foregroundRef, args->foregroundFrameIndex); f32 btnW = normalSprite.frameWidth > 0 ? (f32)normalSprite.frameWidth : 16.0f; f32 btnH = normalSprite.frameHeight > 0 ? (f32)normalSprite.frameHeight : 16.0f; rect buttonRect = rectf( args->position.x * args->scale.x, args->position.y * args->scale.y, btnW * args->scale.x, btnH * args->scale.y ); bool clicked = imui_evalButton(context, itemId, buttonRect, args->hotKey); bool isActive = (context->imui.active_item == itemId) && isButtonHeld(&context->input, WAR_MOUSE_LEFT) && (context->imui.hot_item == itemId); // Tooltip deferral if (context->imui.hot_item == itemId && args->tooltip.length > 0) { imui_deferTooltip(context, args->tooltip, args->tooltipHighlightIndex, args->tooltipHighlightCount, args->gold, args->wood); } // Render wr_save(context); wr_translate(context, args->position.x, args->position.y); wr_scale(context, args->scale.x, args->scale.y); // Background { WarSprite bg = isActive ? pressedSprite : normalSprite; if (bg.texture) { wspr_renderSprite(context, bg, VEC2_ZERO, VEC2_ONE); } } // Foreground icon, centred inside the background if (fgSprite.texture && fgSprite.framesCount > 0) { vec2 bgSize = vec2i(normalSprite.frameWidth, normalSprite.frameHeight); vec2 fgSize = vec2i(fgSprite.frameWidth, fgSprite.frameHeight); vec2 offset = vec2_half(vec2_subv(bgSize, fgSize)); if (isActive) { offset = vec2_addv(offset, vec2i(0, 1)); } wr_translate(context, offset.x, offset.y); wspr_renderSprite(context, fgSprite, VEC2_ZERO, VEC2_ONE); } wr_restore(context); return clicked; } bool imui_text_button(WarContext* context, const char* id, const CreateUITextButtonArgs* args) { assert(id); assert(args); if (!args->interactive) { return false; } u32 itemId = imui_hashCString(id); WarSprite normalSprite = imui_getOrCreateSprite(context, args->backgroundNormalRef, 0); WarSprite pressedSprite = imui_getOrCreateSprite(context, args->backgroundPressedRef, 0); f32 btnW = normalSprite.frameWidth > 0 ? (f32)normalSprite.frameWidth : 64.0f; f32 btnH = normalSprite.frameHeight > 0 ? (f32)normalSprite.frameHeight : 16.0f; rect buttonRect = rectf( args->position.x * args->scale.x, args->position.y * args->scale.y, btnW * args->scale.x, btnH * args->scale.y ); bool clicked = imui_evalButton(context, itemId, buttonRect, args->hotKey); bool isActive = (context->imui.active_item == itemId) && isButtonHeld(&context->input, WAR_MOUSE_LEFT) && (context->imui.hot_item == itemId); bool isHot = (context->imui.hot_item == itemId); // Tooltip deferral if (isHot && args->tooltip.length > 0) { imui_deferTooltip(context, args->tooltip, args->tooltipHighlightIndex, args->tooltipHighlightCount, args->gold, args->wood); } // Render wr_save(context); wr_translate(context, args->position.x, args->position.y); wr_scale(context, args->scale.x, args->scale.y); // Background { WarSprite bg = isActive ? pressedSprite : normalSprite; if (bg.texture) { wspr_renderSprite(context, bg, VEC2_ZERO, VEC2_ONE); } } // Text label, centred inside background bounds if (args->text.data && args->text.length > 0) { WarFontParams params; params.fontIndex = args->fontIndex; params.fontSize = args->fontSize; params.lineHeight = args->lineHeight; params.fontColor = args->fontColor; params.highlightColor = args->highlightColor; // Highlight the full label when hovered (matches retained-mode button behaviour) params.highlightIndex = isHot ? ALL_HIGHLIGHT : args->highlightIndex; params.highlightCount = args->highlightCount; params.boundings = vec2f(btnW, btnH); params.horizontalAlign = args->horizontalAlign; params.verticalAlign = args->verticalAlign; params.lineAlign = args->lineAlign; params.wrapping = args->wrapping; params.trimming = args->trimming; params.fontSprite = context->fontSprites[args->fontIndex]; params.fontData = getFontData(args->fontIndex); wfont_renderSingleSpriteText(context, args->text, 0.0f, 0.0f, params); } wr_restore(context); return clicked; } ================================================ FILE: src/war_imui.h ================================================ #pragma once #include "war.h" #include "war_ui.h" // --------------------------------------------------------------------------- // FNV-1a hash — converts a null-terminated string ID to a u32 item ID. // --------------------------------------------------------------------------- static inline u32 imui_hashCString(const char* str) { u32 hash = 2166136261u; while (*str) { hash ^= (u32)(unsigned char)(*str++); hash *= 16777619u; } return hash; } // --------------------------------------------------------------------------- // Lifecycle // --------------------------------------------------------------------------- // Call once at the start of the render pass, before any imui_* draw calls. // Resets hot_item, is_mouse_over_ui, and tooltip deferral state. void imui_begin(WarContext* context); // Call once at the very end of the render pass, after all imui_* draw calls. // Renders any deferred tooltip and clears active_item when the mouse is up. void imui_end(WarContext* context); // --------------------------------------------------------------------------- // Primitives (stateless draw calls — no input handling) // --------------------------------------------------------------------------- // Draw a text label. Uses CreateUITextArgs (see war_ui.h / CREATE_UI_TEXT_ARGS_INIT). void imui_text(WarContext* context, const char* id, const CreateUITextArgs* args); // Draw a filled rectangle. Uses CreateUIRectArgs (see CREATE_UI_RECT_ARGS_INIT). void imui_rect(WarContext* context, const char* id, const CreateUIRectArgs* args); // Draw a static sprite image. Uses CreateUIImageArgs (see CREATE_UI_IMAGE_ARGS_INIT). void imui_image(WarContext* context, const char* id, const CreateUIImageArgs* args); // Draw a specific frame of a sprite resource. Unlike imui_image (frame 0), // this keys the cache on (resourceIndex, frameIndex) so multiple frames of the // same sprite resource can be drawn in a single render pass without conflicts. void imui_image_frame(WarContext* context, const char* id, const CreateUIImageArgs* args, s32 frameIndex); // Set a tooltip to be drawn in imui_end() if the current item is hovered. // The tooltip text will be rendered with the same highlight range and gold/wood cost indicators as the hovered item. void imui_deferTooltip(WarContext* context, StringView tooltip, s32 highlightIndex, s32 highlightCount, s32 gold, s32 wood); // --------------------------------------------------------------------------- // Interactive elements — return true the frame the element is clicked // --------------------------------------------------------------------------- // Image button (icon + background sprite). // Uses CreateUIImageButtonArgs (see CREATE_UI_IMAGE_BUTTON_ARGS_INIT). // The tooltip field, if non-empty, is deferred and drawn by imui_end(). bool imui_image_button(WarContext* context, const char* id, const CreateUIImageButtonArgs* args); // Text button (text label + background sprite). // Uses CreateUITextButtonArgs (see CREATE_UI_TEXT_BUTTON_ARGS_INIT). // The tooltip field, if non-empty, is deferred and drawn by imui_end(). bool imui_text_button(WarContext* context, const char* id, const CreateUITextButtonArgs* args); ================================================ FILE: src/war_log.c ================================================ #include "war_log.h" #include #include void wlog_log(SDL_LogPriority priority, const char* file, int line, const char* fmt, ...) { // Find short filename by stripping directory prefix const char* shortFile = file; for (const char* p = file; *p; p++) if (*p == '/' || *p == '\\') shortFile = p + 1; // Format the message into a local buffer char buf[4096]; va_list args; va_start(args, fmt); vsnprintf(buf, sizeof(buf), fmt, args); va_end(args); // Strip trailing newlines — SDL_LogMessage appends its own int len = (int)strlen(buf); while (len > 0 && buf[len - 1] == '\n') buf[--len] = '\0'; SDL_LogMessage(SDL_LOG_CATEGORY_APPLICATION, priority, "[%s:(%d)]: %s", shortFile, line, buf); } ================================================ FILE: src/war_log.h ================================================ #pragma once #include "SDL3/SDL.h" void wlog_log(SDL_LogPriority priority, const char* file, int line, const char* fmt, ...); #define logCritical(...) wlog_log(SDL_LOG_PRIORITY_CRITICAL, __FILE__, __LINE__, __VA_ARGS__) #define logError(...) wlog_log(SDL_LOG_PRIORITY_ERROR, __FILE__, __LINE__, __VA_ARGS__) #define logWarning(...) wlog_log(SDL_LOG_PRIORITY_WARN, __FILE__, __LINE__, __VA_ARGS__) #define logInfo(...) wlog_log(SDL_LOG_PRIORITY_INFO, __FILE__, __LINE__, __VA_ARGS__) #define logDebug(...) wlog_log(SDL_LOG_PRIORITY_DEBUG, __FILE__, __LINE__, __VA_ARGS__) ================================================ FILE: src/war_map.c ================================================ #include "war_map.h" #include #include "shl/memzone.h" #include "shl/wstr.h" #include "war_actions.h" #include "war_animations.h" #include "war_audio.h" #include "war_campaigns.h" #include "war_entities.h" #include "war_font.h" #include "war_map_menu.h" #include "war_map_ui.h" #include "war_projectiles.h" #include "war_render.h" #include "war_resources.h" #include "war_sprites.h" #include "war_state_machine.h" #include "war_units.h" #include "war_pathfinder.h" #define MAP_SELECTION_DRAG_THRESHOLD 3.0f void wmap_addEntityToSelection(WarContext* context, WarEntityId id) { WarMap* map = context->map; // subtitute this with a set data structure that doesn't allow duplicates if (!WarEntityIdListContains(&map->selectedEntities, id)) WarEntityIdListAdd(&map->selectedEntities, id); } void wmap_removeEntityFromSelection(WarContext* context, WarEntityId id) { WarMap* map = context->map; WarEntityIdListRemove(&map->selectedEntities, id); } void wmap_clearSelection(WarContext* context) { WarMap* map = context->map; WarEntityIdListClear(&map->selectedEntities); } vec2 wmap_getDirFromArrowKeys(WarContext* context) { WarInput* input = &context->input; vec2 dir = VEC2_ZERO; if (isKeyHeld(input, WAR_KEY_LEFT)) dir.x = -1; else if (isKeyHeld(input, WAR_KEY_RIGHT)) dir.x = 1; if (isKeyHeld(input, WAR_KEY_DOWN)) dir.y = 1; else if (isKeyHeld(input, WAR_KEY_UP)) dir.y = -1; dir = vec2_normalize(dir); return dir; } vec2 wmap_getDirFromMousePos(WarContext* context) { WarInput* input = &context->input; vec2 dir = VEC2_ZERO; if (input->pos.x < MAP_EDGE_SCROLL_GAP) dir.x = -1; else if (input->pos.x > context->originalWindowWidth - MAP_EDGE_SCROLL_GAP) dir.x = 1; if (input->pos.y < MAP_EDGE_SCROLL_GAP) dir.y = -1; else if (input->pos.y > context->originalWindowHeight - MAP_EDGE_SCROLL_GAP) dir.y = 1; dir = vec2_normalize(dir); return dir; } vec2 wmap_screenToMapCoordinatesV(WarContext* context, vec2 v) { WarMap* map = context->map; rect mapPanel = map->mapPanel; rect viewport = map->viewport; v = vec2_translatef(v, -mapPanel.x, -mapPanel.y); v = vec2_translatef(v, viewport.x, viewport.y); return v; } vec2 wmap_screenToMinimapCoordinatesV(WarContext* context, vec2 v) { WarMap* map = context->map; rect minimapPanel = map->minimapPanel; v = vec2_translatef(v, -minimapPanel.x, -minimapPanel.y); return v; } rect wmap_screenToMapCoordinatesR(WarContext* context, rect r) { WarMap* map = context->map; rect mapPanel = map->mapPanel; rect viewport = map->viewport; r = rect_translatef(r, -mapPanel.x, -mapPanel.y); r = rect_translatef(r, viewport.x, viewport.y); return r; } vec2 wmap_mapToScreenCoordinatesV(WarContext* context, vec2 v) { WarMap* map = context->map; v = vec2_translatef(v, -map->viewport.x, -map->viewport.y); v = vec2_translatef(v, map->mapPanel.x, map->mapPanel.y); return v; } rect wmap_mapToScreenCoordinatesR(WarContext* context, rect r) { WarMap* map = context->map; r = rect_translatef(r, -map->viewport.x, -map->viewport.y); r = rect_translatef(r, map->mapPanel.x, map->mapPanel.y); return r; } vec2 wmap_mapToTileCoordinatesV(vec2 v) { v.x = floorf(v.x / MEGA_TILE_WIDTH); v.y = floorf(v.y / MEGA_TILE_HEIGHT); return v; } vec2 wmap_tileToMapCoordinatesV(vec2 v, bool centeredInTile) { v.x *= MEGA_TILE_WIDTH; v.y *= MEGA_TILE_HEIGHT; if (centeredInTile) { v.x += MEGA_TILE_WIDTH/2; v.y += MEGA_TILE_HEIGHT/2; } return v; } vec2 wmap_minimapToViewportCoordinatesV(WarContext* context, vec2 v) { WarMap* map = context->map; rect minimapPanel = map->minimapPanel; vec2 minimapPanelSize = vec2f(minimapPanel.width, minimapPanel.height); vec2 minimapViewportSize = vec2f(MINIMAP_VIEWPORT_WIDTH, MINIMAP_VIEWPORT_HEIGHT); v = vec2_translatef(v, -minimapViewportSize.x / 2, -minimapViewportSize.y / 2); v = vec2_clampv(v, VEC2_ZERO, vec2_subv(minimapPanelSize, minimapViewportSize)); return v; } WarMapTile* wmap_getMapTileState(WarMap* map, s32 x, s32 y) { assert(inRange(x, 0, MAP_TILES_WIDTH) && inRange(y, 0, MAP_TILES_HEIGHT)); return &map->tiles[y * MAP_TILES_WIDTH + x]; } void wmap_setMapTileState(WarMap* map, s32 startX, s32 startY, s32 width, s32 height, WarMapTileState tileState) { if (startX <= 0) startX = 0; if (startY <= 0) startY = 0; if (startX + width >= MAP_TILES_WIDTH) width = MAP_TILES_WIDTH - startX; if (startY + height >= MAP_TILES_HEIGHT) height = MAP_TILES_HEIGHT - startY; s32 endX = startX + width; s32 endY = startY + height; for(s32 y = startY; y < endY; y++) { for(s32 x = startX; x < endX; x++) { // exclude the corners of the area to get a more "rounded" shape if ((y == startY || y == endY - 1) && (x == startX || x == endX - 1)) continue; WarMapTile* tile = wmap_getMapTileState(map, x, y); tile->state = tileState; } } } void wmap_setUnitMapTileState(WarContext* context, WarMap* map, WarEntity* entity, WarMapTileState tileState) { assert(wu_isUnit(entity)); s32 sight = wu_getUnitSightRange(context, entity); vec2 position = wu_getUnitPosition(context, entity, true); vec2 unitSize = wu_getUnitSize(context, entity); rect unitRect = rectv(position, unitSize); unitRect = rect_expand(unitRect, (f32)sight, (f32)sight); wmap_setMapTileState(map, (s32)unitRect.x, (s32)unitRect.y, (s32)unitRect.width, (s32)unitRect.height, tileState); } bool wmap_isTileInState(WarMap* map, s32 x, s32 y, WarMapTileState state) { if (!map->fowEnabled) { switch (state) { case MAP_TILE_STATE_UNKOWN: return false; case MAP_TILE_STATE_FOG: return false; case MAP_TILE_STATE_VISIBLE: return true; default: { logError("Unkown state: %d. Defaulting to true.", state); return true; } } } WarMapTile* tile = wmap_getMapTileState(map, x, y); return tile->state == state; } bool wmap_isAnyTileInStates(WarMap* map, s32 startX, s32 startY, s32 width, s32 height, WarMapTileState state) { if (!map->fowEnabled) { switch (state) { case MAP_TILE_STATE_UNKOWN: return false; case MAP_TILE_STATE_FOG: return false; case MAP_TILE_STATE_VISIBLE: return true; default: { logError("Unkown state: %d. Defaulting to true.", state); return true; } } } if (startX <= 0) startX = 0; if (startY <= 0) startY = 0; if (startX + width >= MAP_TILES_WIDTH) width = MAP_TILES_WIDTH - startX; if (startY + height >= MAP_TILES_HEIGHT) height = MAP_TILES_HEIGHT - startY; s32 endX = startX + width; s32 endY = startY + height; for(s32 y = startY; y < endY; y++) { for(s32 x = startX; x < endX; x++) { WarMapTile* tile = wmap_getMapTileState(map, x, y); if (tile->state == state) { return true; } } } return false; } bool wmap_isAnyUnitTileInStates(WarContext* context, WarMap* map, WarEntity* entity, WarMapTileState state) { assert(wu_isUnit(entity)); WarUnitComponent* unit = we_getUnitComponent(context, entity); assert(unit); vec2 position = wu_getUnitPosition(context, entity, true); return wmap_isAnyTileInStates(map, (s32)position.x, (s32)position.y, unit->sizex, unit->sizey, state); } bool wmap_areAllTilesInState(WarMap* map, s32 startX, s32 startY, s32 width, s32 height, WarMapTileState state) { if (!map->fowEnabled) { switch (state) { case MAP_TILE_STATE_UNKOWN: return false; case MAP_TILE_STATE_FOG: return false; case MAP_TILE_STATE_VISIBLE: return true; default: { logError("Unkown state: %d. Defaulting to true.", state); return true; } } } if (startX <= 0) startX = 0; if (startY <= 0) startY = 0; if (startX + width >= MAP_TILES_WIDTH) width = MAP_TILES_WIDTH - startX; if (startY + height >= MAP_TILES_HEIGHT) height = MAP_TILES_HEIGHT - startY; s32 endX = startX + width; s32 endY = startY + height; for(s32 y = startY; y < endY; y++) { for(s32 x = startX; x < endX; x++) { WarMapTile* tile = wmap_getMapTileState(map, x, y); if (tile->state != state) { return false; } } } return true; } bool wmap_areAllUnitTilesInState(WarContext* context, WarMap* map, WarEntity* entity, WarMapTileState state) { assert(wu_isUnit(entity)); WarUnitComponent* unit = we_getUnitComponent(context, entity); assert(unit); vec2 position = wu_getUnitPosition(context, entity, true); return wmap_areAllTilesInState(map, (s32)position.x, (s32)position.y, unit->sizex, unit->sizey, state); } bool wmap_isUnitPartiallyVisible(WarContext* context, WarMap* map, WarEntity* entity) { return wmap_isAnyUnitTileInStates(context, map, entity, MAP_TILE_STATE_VISIBLE); } bool wmap_isUnitVisible(WarContext* context, WarMap* map, WarEntity* entity) { return wmap_areAllUnitTilesInState(context, map, entity, MAP_TILE_STATE_VISIBLE); } bool wmap_isUnitPartiallyFog(WarContext* context, WarMap* map, WarEntity* entity) { return wmap_isAnyUnitTileInStates(context, map, entity, MAP_TILE_STATE_FOG); } bool wmap_isUnitFog(WarContext* context, WarMap* map, WarEntity* entity) { return wmap_areAllUnitTilesInState(context, map, entity, MAP_TILE_STATE_FOG); } bool wmap_isUnitPartiallyUnkown(WarContext* context, WarMap* map, WarEntity* entity) { return wmap_isAnyUnitTileInStates(context, map, entity, MAP_TILE_STATE_UNKOWN); } bool wmap_isUnitUnknown(WarContext* context, WarMap* map, WarEntity* entity) { return wmap_areAllUnitTilesInState(context, map, entity, MAP_TILE_STATE_UNKOWN); } bool wmap_isTileUnkown(WarMap* map, s32 x, s32 y) { return wmap_isTileInState(map, x, y, MAP_TILE_STATE_UNKOWN); } bool wmap_isTileFog(WarMap* map, s32 x, s32 y) { return wmap_isTileInState(map, x, y, MAP_TILE_STATE_FOG); } bool wmap_isTileVisible(WarMap* map, s32 x, s32 y) { return wmap_isTileInState(map, x, y, MAP_TILE_STATE_VISIBLE); } WarColor wmap_getMapTileAverage(WarResource* levelVisual, WarResource* tileset, s32 x, s32 y) { s32 index = y * MAP_TILES_WIDTH + x; u16 tileIndex = levelVisual->levelVisual.data[index]; s32 tilePixelX = (tileIndex % TILESET_TILES_PER_ROW) * MEGA_TILE_WIDTH; s32 tilePixelY = ((tileIndex / TILESET_TILES_PER_ROW) * MEGA_TILE_HEIGHT); s32 r = 0, g = 0, b = 0; for(s32 ty = 0; ty < MEGA_TILE_HEIGHT; ty++) { for(s32 tx = 0; tx < MEGA_TILE_WIDTH; tx++) { s32 pixel = (tilePixelY + ty) * TILESET_WIDTH + (tilePixelX + tx); r += tileset->tilesetData.data[pixel * 4 + 0]; g += tileset->tilesetData.data[pixel * 4 + 1]; b += tileset->tilesetData.data[pixel * 4 + 2]; } } r /= 256; g /= 256; b /= 256; WarColor color = {0}; color.r = (u8)r; color.g = (u8)g; color.b = (u8)b; color.a = 255; return color; } void wmap_updateMinimapTile(WarContext* context, WarResource* levelVisual, WarResource* tileset, s32 x, s32 y) { WarMap* map = context->map; WarSpriteFrame* minimapFrame = &map->minimapSprite.frames[1]; WarColor color = WAR_COLOR_BLACK; s32 index = y * MAP_TILES_WIDTH + x; WarMapTile* tile = &map->tiles[index]; if (!map->fowEnabled || tile->state == MAP_TILE_STATE_VISIBLE || tile->state == MAP_TILE_STATE_FOG) { color = wmap_getMapTileAverage(levelVisual, tileset, x, y); } minimapFrame->data[index * 4 + 0] = color.r; minimapFrame->data[index * 4 + 1] = color.g; minimapFrame->data[index * 4 + 2] = color.b; minimapFrame->data[index * 4 + 3] = color.a; } s32 wmap_getMapTileIndex(WarContext* context, s32 x, s32 y) { WarMap* map = context->map; WarResource* levelInfo = wres_getOrCreateResource(context, map->levelInfoIndex); assert(levelInfo && levelInfo->type == WAR_RESOURCE_TYPE_LEVEL_INFO); WarResource* levelVisual = wres_getOrCreateResource(context, levelInfo->levelInfo.visualIndex); assert(levelVisual && levelVisual->type == WAR_RESOURCE_TYPE_LEVEL_VISUAL); WarMapTilesetType tilesetType = map->tilesetType; assert(tilesetType == MAP_TILESET_FOREST || tilesetType == MAP_TILESET_SWAMP); return levelVisual->levelVisual.data[y * MAP_TILES_WIDTH + x]; } void wmap_setMapTileIndex(WarContext* context, s32 x, s32 y, s32 tile) { WarMap* map = context->map; WarResource* levelInfo = wres_getOrCreateResource(context, map->levelInfoIndex); assert(levelInfo && levelInfo->type == WAR_RESOURCE_TYPE_LEVEL_INFO); WarResource* levelVisual = wres_getOrCreateResource(context, levelInfo->levelInfo.visualIndex); assert(levelVisual && levelVisual->type == WAR_RESOURCE_TYPE_LEVEL_VISUAL); WarResource* tileset = wres_getOrCreateResource(context, levelInfo->levelInfo.tilesetIndex); assert(tileset && tileset->type == WAR_RESOURCE_TYPE_TILESET); assert(tile >= 0 && tile <= UINT16_MAX); levelVisual->levelVisual.data[y * MAP_TILES_WIDTH + x] = (u16)tile; wmap_updateMinimapTile(context, levelVisual, tileset, x, y); } f32 wmap_getMapScaledSpeed(WarContext* context, f32 t) { WarMap* map = context->map; t = getScaledSpeed(context, t); if (map->settings.gameSpeed < WAR_SPEED_NORMAL) t *= 1.0f - (WAR_SPEED_NORMAL - map->settings.gameSpeed) * 0.25f; else if (map->settings.gameSpeed > WAR_SPEED_NORMAL) t *= 1.0f + (map->settings.gameSpeed - WAR_SPEED_NORMAL) * 0.5f; return t; } f32 wmap_getMapScaledTime(WarContext* context, f32 t) { WarMap* map = context->map; t = getScaledTime(context, t); if (map->settings.gameSpeed < WAR_SPEED_NORMAL) t /= 1.0f - (WAR_SPEED_NORMAL - map->settings.gameSpeed) * 0.25f; else if (map->settings.gameSpeed > WAR_SPEED_NORMAL) t /= 1.0f + (map->settings.gameSpeed - WAR_SPEED_NORMAL) * 0.5f; return t; } WarMap* wmap_createMap(WarContext* context, s32 levelInfoIndex) { WarMap *map = (WarMap*)wm_alloc(sizeof(WarMap)); map->levelInfoIndex = levelInfoIndex; we_initEntityManager(context, &map->entityManager); WarEntityIdListInit(&map->selectedEntities, WarEntityIdListDefaultOptions); return map; } WarMap* createCustomMap(WarContext* context, s32 levelInfoIndex, WarRace yourRace, WarRace enemyRace) { WarMap* map = wmap_createMap(context, levelInfoIndex); WarResource* levelInfo = wres_getOrCreateResource(context, levelInfoIndex); assert(levelInfo && levelInfo->type == WAR_RESOURCE_TYPE_LEVEL_INFO && levelInfo->levelInfo.customMap); levelInfo->levelInfo.startEntitiesCount = 0; memset(levelInfo->levelInfo.startEntities, 0, sizeof(levelInfo->levelInfo.startEntities)); levelInfo->levelInfo.races[0] = yourRace; levelInfo->levelInfo.races[1] = enemyRace; for (s32 i = 0; i < (s32)levelInfo->levelInfo.startGoldminesCount; i++) { WarLevelUnit* startUnitConf = &levelInfo->levelInfo.startGoldmines[i]; WarLevelUnit* startUnit = &levelInfo->levelInfo.startEntities[levelInfo->levelInfo.startEntitiesCount]; startUnit->x = startUnitConf->x; startUnit->y = startUnitConf->y; startUnit->type = startUnitConf->type; startUnit->player = startUnitConf->player; startUnit->resourceKind = WAR_RESOURCE_GOLD; startUnit->amount = randomi(20000, 30000); levelInfo->levelInfo.startEntitiesCount++; } s32 configurationIndex = randomi(0, (s32)levelInfo->levelInfo.startConfigurationsCount); WarCustomMapConfiguration* configuration = &levelInfo->levelInfo.startConfigurations[configurationIndex]; for (s32 i = 0; i < (s32)configuration->startEntitiesCount; i++) { WarLevelUnit* startUnitConf = &configuration->startEntities[i]; WarLevelUnit* startUnit = &levelInfo->levelInfo.startEntities[levelInfo->levelInfo.startEntitiesCount]; startUnit->x = startUnitConf->x; startUnit->y = startUnitConf->y; startUnit->player = startUnitConf->player; startUnit->type = startUnit->player == 0 ? wu_getUnitTypeForRace(startUnitConf->type, yourRace) : wu_getUnitTypeForRace(startUnitConf->type, enemyRace); levelInfo->levelInfo.startEntitiesCount++; } return map; } void wmap_freeMap(WarContext* context, WarMap* map) { wspr_freeSprite(context, map->sprite); wspr_freeSprite(context, map->minimapSprite); wspr_freeSprite(context, map->blackSprite); WarEntityManager* manager = &map->entityManager; WarEntityMapFree(&manager->entitiesByType); WarUnitMapFree(&manager->unitsByType); WarEntityIdMapFree(&manager->entitiesById); WarEntityListFree(&manager->uiEntities); WarEntityIdListFree(&map->selectedEntities); // these are already free when the lists and maps are // we_freeEntity(map->forest); // we_freeEntity(map->wall); // we_freeEntity(map->road); // we_freeEntity(map->ruin); wm_free(map->finder.data); } void wmap_enterMap(WarContext* context) { WarMap* map = context->map; s32 levelInfoIndex = map->levelInfoIndex; WarResource* levelInfo = wres_getOrCreateResource(context, levelInfoIndex); assert(levelInfo && levelInfo->type == WAR_RESOURCE_TYPE_LEVEL_INFO); WarResource* levelPassable = wres_getOrCreateResource(context, levelInfo->levelInfo.passableIndex); assert(levelPassable && levelPassable->type == WAR_RESOURCE_TYPE_LEVEL_PASSABLE); map->playing = true; map->custom = levelInfo->levelInfo.customMap; map->tilesetType = levelInfo->levelInfo.tilesetType; map->fowEnabled = true; map->result = WAR_LEVEL_RESULT_NONE; map->objectivesTime = 1; map->settings.gameSpeed = WAR_SPEED_NORMAL; map->settings.mouseScrollSpeed = WAR_SPEED_NORMAL; map->settings.keyScrollSpeed = WAR_SPEED_NORMAL; map->leftTopPanel = recti(0, 0, 72, 72); map->leftBottomPanel = recti(0, 72, 72, 128); map->rightPanel = recti(312, 0, 8, 200); map->topPanel = recti(72, 0, 240, 12); map->bottomPanel = recti(72, 188, 240, 12); map->mapPanel = recti(72, 12, MAP_VIEWPORT_WIDTH, MAP_VIEWPORT_HEIGHT); map->minimapPanel = recti(3, 6, MINIMAP_WIDTH, MINIMAP_HEIGHT); map->menuPanel = recti(84, 32, 152, 136); map->messagePanel = recti(17, 76, 286, 48); map->saveLoadPanel = recti(48, 27, 223, 146); s32 startX = levelInfo->levelInfo.startX * MEGA_TILE_WIDTH; s32 startY = levelInfo->levelInfo.startY * MEGA_TILE_HEIGHT; map->viewport = recti(startX, startY, MAP_VIEWPORT_WIDTH, MAP_VIEWPORT_HEIGHT); map->finder = wpath_initPathFinder(context, PATH_FINDING_ASTAR, MAP_TILES_WIDTH, MAP_TILES_HEIGHT, levelPassable->levelPassable.data); const s32 dirC = 8; const s32 dirX[] = { 0, 1, 1, 1, 0, -1, -1, -1 }; const s32 dirY[] = { -1, -1, 0, 1, 1, 1, 0, -1 }; // create the black sprite { u8 data[MEGA_TILE_WIDTH * MEGA_TILE_HEIGHT * 4]; memset(data, 0, MEGA_TILE_WIDTH * MEGA_TILE_HEIGHT * 4); for (s32 i = 0; i < MEGA_TILE_WIDTH * MEGA_TILE_HEIGHT; i++) data[4 * i + 3] = 255; map->blackSprite = wspr_createSprite(context, MEGA_TILE_WIDTH, MEGA_TILE_HEIGHT, data); } // set the initial state for the tiles { for (s32 i = 0; i < MAP_TILES_WIDTH * MAP_TILES_HEIGHT; i++) { WarMapTile* tile = &map->tiles[i]; tile->state = MAP_TILE_STATE_UNKOWN; tile->type = WAR_FOG_PIECE_NONE; tile->boundary = WAR_FOG_BOUNDARY_NONE; } } // create the map sprite { WarResource* levelVisual = wres_getOrCreateResource(context, levelInfo->levelInfo.visualIndex); assert(levelVisual && levelVisual->type == WAR_RESOURCE_TYPE_LEVEL_VISUAL); WarResource* tileset = wres_getOrCreateResource(context, levelInfo->levelInfo.tilesetIndex); assert(tileset && tileset->type == WAR_RESOURCE_TYPE_TILESET); // DEBUG: // print level visual data to console to see the sprites of the map // // for(s32 y = 0; y < MAP_TILES_HEIGHT; y++) // { // for(s32 x = 0; x < MAP_TILES_WIDTH; x++) // { // // index of the tile in the tilesheet // u16 tileIndex = levelVisual->levelVisual.data[y * MAP_TILES_WIDTH + x]; // printf("%d ", tileIndex); // } // printf("\n"); // } map->sprite = wspr_createSprite(context, TILESET_WIDTH, TILESET_HEIGHT, tileset->tilesetData.data); // the minimap sprite will be a 2 frames sprite // the first one will be the frame that actually render // the second one will be the minimap for the terrain, created at startup time, // that way I only have to memcpy to the first frame and do the work only for the units // that way I also don't have to allocate memory for the minimap each frame WarSpriteFrame minimapFrames[2]; for(s32 i = 0; i < 2; i++) { minimapFrames[i].dx = 0; minimapFrames[i].dy = 0; minimapFrames[i].w = MINIMAP_WIDTH; minimapFrames[i].h = MINIMAP_HEIGHT; minimapFrames[i].off = 0; minimapFrames[i].data = (u8*)wm_alloc(MINIMAP_WIDTH * MINIMAP_HEIGHT * 4 * sizeof(u8)); // make the frame black for (s32 k = 0; k < MINIMAP_WIDTH * MINIMAP_HEIGHT; k++) minimapFrames[i].data[k * 4 + 3] = 255; } for(s32 y = 0; y < MAP_TILES_HEIGHT; y++) { for(s32 x = 0; x < MAP_TILES_WIDTH; x++) { WarColor color = wmap_getMapTileAverage(levelVisual, tileset, x, y); s32 index = y * MAP_TILES_WIDTH + x; minimapFrames[1].data[index * 4 + 0] = color.r; minimapFrames[1].data[index * 4 + 1] = color.g; minimapFrames[1].data[index * 4 + 2] = color.b; minimapFrames[1].data[index * 4 + 3] = color.a; } } map->minimapSprite = wspr_createSpriteFromFrames(context, MINIMAP_WIDTH, MINIMAP_HEIGHT, arrayLength(minimapFrames), minimapFrames); } // create the forest entities { bool processed[MAP_TILES_WIDTH * MAP_TILES_HEIGHT]; for(s32 i = 0; i < MAP_TILES_WIDTH * MAP_TILES_HEIGHT; i++) processed[i] = false; u16* passableData = levelPassable->levelPassable.data; for(s32 i = 0; i < MAP_TILES_WIDTH * MAP_TILES_HEIGHT; i++) { if (!processed[i] && passableData[i] == 128) { s32 x = i % MAP_TILES_WIDTH; s32 y = i / MAP_TILES_WIDTH; WarTreeList trees; WarTreeListInit(&trees, WarTreeListDefaultOptions); WarTreeListAdd(&trees, createTree(x, y, TREE_MAX_WOOD)); processed[i] = true; for(s32 j = 0; j < trees.count; j++) { WarTree tree = trees.items[j]; for(s32 d = 0; d < dirC; d++) { s32 xx = tree.tilex + dirX[d]; s32 yy = tree.tiley + dirY[d]; if (wpath_isInside(map->finder, xx, yy)) { s32 k = yy * MAP_TILES_WIDTH + xx; if (!processed[k] && passableData[k] == 128) { // mark it processed right away, to not process it later processed[k] = true; WarTree newTree = createTree(xx, yy, TREE_MAX_WOOD); WarTreeListAdd(&trees, newTree); } } } } WarEntity* forest = we_createEntity(context, WAR_ENTITY_TYPE_FOREST, true); we_addSpriteComponent(context, forest, WAR_SPRITE_COMPONENT_INIT( .sprite = map->sprite )); we_addForestComponent(context, forest, trees); for (s32 treeIndex = 0; treeIndex < trees.count; treeIndex++) { WarTree* tree = &trees.items[treeIndex]; setStaticEntity(map->finder, tree->tilex, tree->tiley, 1, 1, forest->id); } we_determineTreeTiles(context, forest); } } map->forest = we_createForest(context);; } // create the starting roads { WarEntity* road = we_createRoad(context); for(s32 i = 0; i < (s32)levelInfo->levelInfo.startRoadsCount; i++) { WarLevelConstruct *construct = &levelInfo->levelInfo.startRoads[i]; if (construct->type == WAR_CONSTRUCT_ROAD) { we_addRoadPiecesFromConstruct(context, road, construct); } } we_determineRoadTypes(context, road); map->road = road; } // create the starting walls { WarEntity* wall = we_createWall(context); for(s32 i = 0; i < (s32)levelInfo->levelInfo.startWallsCount; i++) { WarLevelConstruct *construct = &levelInfo->levelInfo.startWalls[i]; if (construct->type == WAR_CONSTRUCT_WALL) { we_addWallPiecesFromConstruct(context, wall, construct); } } we_determineWallTypes(context, wall); WarWallComponent* wallComp = we_getWallComponent(context, wall); assert(wallComp); for(s32 i = 0; i < wallComp->pieces.count; i++) { WarWallPiece* piece = &wallComp->pieces.items[i]; piece->hp = WAR_WALL_MAX_HP; piece->maxhp = WAR_WALL_MAX_HP; } we_addStateMachineComponent(context, wall); WarState* idleState = wst_createIdleState(context, wall, false); wst_changeNextState(context, wall, idleState, true, true); map->wall = wall; } // create ruins { map->ruin = we_createRuins(context); } // create players info { for (s32 i = 0; i < MAX_PLAYERS_COUNT; i++) { WarPlayerInfo* player = &map->players[i]; player->index = (u8)i; player->race = levelInfo->levelInfo.races[i]; player->gold = 4000; // levelInfo->levelInfo.gold[i]; player->wood = 4000; // levelInfo->levelInfo.lumber[i]; player->godMode = false; for (s32 j = 0; j < MAX_FEATURES_COUNT; j++) { player->features[j] = levelInfo->levelInfo.allowedFeatures[j]; } for (s32 j = 0; j < MAX_UPGRADES_COUNT; j++) { player->upgrades[j].allowed = levelInfo->levelInfo.allowedUpgrades[j][i]; player->upgrades[j].level = 0; } } } // create the starting entities { for (s32 i = 0; i < (s32)levelInfo->levelInfo.startEntitiesCount; i++) { WarLevelUnit startUnit = levelInfo->levelInfo.startEntities[i]; we_createUnit(context, CREATE_UNIT_ARGS_INIT( .type=startUnit.type, .x=startUnit.x, .y=startUnit.y, .player=startUnit.player, .resourceKind=startUnit.resourceKind, .amount=startUnit.amount, .addToMap=true )); } } // init AI wai_initAIPlayers(context); // add ui entities wmui_createMapUI(context); if (!isDemo(context)) wa_createAudio(context, CREATE_AUDIO_ARGS_INIT(.audioId=WAR_MUSIC_00, .loop=true)); } void wmap_leaveMap(WarContext* context) { if (context->map) { wmap_freeMap(context, context->map); context->map = NULL; } } static void updateViewport(WarContext *context) { WarMap* map = context->map; WarInput* input = &context->input; map->wasScrolling = false; vec2 dir = VEC2_ZERO; bool wasScrolling = map->isScrolling; bool mouseScroll = false; bool keyScroll = false; // if there was a click in the minimap, then update the position of the viewport if (isButtonHeld(input, WAR_MOUSE_LEFT)) { // check if the click is inside the minimap panel if (rect_containsf(map->minimapPanel, input->pos.x, input->pos.y)) { vec2 minimapSize = vec2i(MINIMAP_WIDTH, MINIMAP_HEIGHT); vec2 offset = wmap_screenToMinimapCoordinatesV(context, input->pos); offset = wmap_minimapToViewportCoordinatesV(context, offset); map->viewport.x = offset.x * MAP_WIDTH / minimapSize.x; map->viewport.y = offset.y * MAP_HEIGHT / minimapSize.y; } } // check for the arrows keys and update the position of the viewport else { if (!isMapDragging(input)) { dir = wmap_getDirFromMousePos(context); mouseScroll = !VEC2_IS_ZERO(dir); } // don't scroll with arrow keys if Control or Shift are pressed // don't scroll with arrow keys if the cheat status is active if (!mouseScroll && !isKeyHeld(input, WAR_KEY_CTRL) && !isKeyHeld(input, WAR_KEY_SHIFT) && !cheatsEnabledAndVisible(map)) { dir = wmap_getDirFromArrowKeys(context); keyScroll = !VEC2_IS_ZERO(dir); } } map->isScrolling = !VEC2_IS_ZERO(dir); if (map->isScrolling) { assert(mouseScroll || keyScroll); f32 scrollSpeed = 0.0f; if (mouseScroll) scrollSpeed = getMapScrollSpeed(map->settings.mouseScrollSpeed); else if (keyScroll) scrollSpeed = getMapScrollSpeed(map->settings.keyScrollSpeed); map->viewport.x += scrollSpeed * dir.x * context->deltaTime; map->viewport.x = CLAMP(map->viewport.x, 0.0f, MAP_WIDTH - map->viewport.width); map->viewport.y += scrollSpeed * dir.y * context->deltaTime; map->viewport.y = CLAMP(map->viewport.y, 0.0f, MAP_HEIGHT - map->viewport.height); } else { map->wasScrolling = wasScrolling; } } static void updateDragRect(WarContext* context) { WarMap* map = context->map; WarInput* input = &context->input; if (map->isScrolling) { input->mapDragActive = false; input->mapDragStartPos = VEC2_ZERO; input->mapDragRect = RECT_EMPTY; return; } if (isButtonJustPressed(input, WAR_MOUSE_LEFT)) { if (!input->capturedUIButtonId && rect_containsf(map->mapPanel, input->pos.x, input->pos.y)) { input->mapDragActive = true; input->mapDragStartPos = input->pos; input->mapDragRect = rectv(input->pos, VEC2_ZERO); } } else if (input->mapDragActive && isButtonHeld(input, WAR_MOUSE_LEFT)) { input->mapDragRect = rectpf(input->mapDragStartPos.x, input->mapDragStartPos.y, input->pos.x, input->pos.y); } } static bool isMapSelectionDrag(rect dragRect) { return dragRect.width >= MAP_SELECTION_DRAG_THRESHOLD || dragRect.height >= MAP_SELECTION_DRAG_THRESHOLD; } static void updateSelectionFromList(WarContext* context, WarEntityList* newSelectedEntities) { WarMap* map = context->map; bool areDudesSelected = false; bool areBuildingSelected = false; // calculate the number of dudes and buildings in the selection for (s32 i = 0; i < newSelectedEntities->count; i++) { WarEntity* entity = newSelectedEntities->items[i]; if (wu_isDudeUnit(context, entity)) areDudesSelected = true; else if (wu_isBuildingUnit(context, entity)) areBuildingSelected = true; } if (areDudesSelected) { // remove all new selected buildings for (s32 i = newSelectedEntities->count - 1; i >= 0; i--) { WarEntity* entity = newSelectedEntities->items[i]; if (wu_isBuildingUnit(context, entity)) WarEntityListRemoveAt(newSelectedEntities, i); } } else if (areBuildingSelected) { // remove all other new selected buildings WarEntityListRemoveAtRange(newSelectedEntities, 1, newSelectedEntities->count - 1); } if (areDudesSelected) { if (newSelectedEntities->count == 1) { WarEntity* newSelectedEntity = newSelectedEntities->items[0]; if (wu_isFriendlyUnit(context, newSelectedEntity)) { wa_playDudeSelectionSound(context, newSelectedEntity); } else { wa_createAudio(context, CREATE_AUDIO_ARGS_INIT(.audioId=WAR_UI_CLICK, .loop=false)); } } } else if (areBuildingSelected) { WarEntity* newSelectedEntity = newSelectedEntities->items[0]; if (wu_isFriendlyUnit(context, newSelectedEntity)) { wa_playBuildingSelectionSound(context, newSelectedEntity); } } // if the new selected entity is the same one, don't clear the command, otherwise do if (newSelectedEntities->count == 1 && map->selectedEntities.count == 1) { WarEntity* newSelectedEntity = newSelectedEntities->items[0]; WarEntityId selectedEntityId = map->selectedEntities.items[0]; if (selectedEntityId != newSelectedEntity->id) { map->command.type = WAR_COMMAND_NONE; } } else { map->command.type = WAR_COMMAND_NONE; } // clear the current selection wmap_clearSelection(context); // and add the new selection s32 selectedEntitiesCount = MIN(newSelectedEntities->count, 4); for (s32 i = 0; i < selectedEntitiesCount; i++) { WarEntity* entity = newSelectedEntities->items[i]; wmap_addEntityToSelection(context, entity->id); } } static void updateSelection(WarContext* context) { WarMap* map = context->map; WarInput* input = &context->input; if (isButtonJustReleased(input, WAR_MOUSE_LEFT) && input->mapDragActive) { // if it was scrolling last frame, don't perform any selection this frame if (!map->wasScrolling) { input->mapDragRect = rectpf(input->mapDragStartPos.x, input->mapDragStartPos.y, input->pos.x, input->pos.y); WarEntityList newSelectedEntities; WarEntityListInit(&newSelectedEntities, WarEntityListNonFreeOptions); if (isMapSelectionDrag(input->mapDragRect)) { rect pointerRect = wmap_screenToMapCoordinatesR(context, input->mapDragRect); // select the entities inside the dragging rect WarEntityList* units = we_getEntitiesOfType(context, WAR_ENTITY_TYPE_UNIT); for (s32 i = 0; i < units->count; i++) { WarEntity* entity = units->items[i]; if (entity) { WarUnitComponent* unit = we_getUnitComponent(context, entity); assert(unit); if (we_isComponentEnabled(context, entity, COMP_UNIT)) { // don't select dead units or corpses if (wst_isDead(context, entity) || wst_isGoingToDie(context, entity) || wu_isCorpseUnit(context, entity)) { continue; } // don't select collased buildings if (wst_isCollapsing(context, entity) || wst_isGoingToCollapse(context, entity)) { continue; } // don't select workers inside buildings if (wu_isWorkerUnit(context, entity) && wst_isInsideBuilding(context, entity)) { continue; } // don't select non-visible units if (!wmap_isUnitPartiallyVisible(context, map, entity)) { continue; } rect unitRect = wu_getUnitRect(context, entity); if (rect_intersects(pointerRect, unitRect)) { WarEntityListAdd(&newSelectedEntities, entity); } } } } } else { WarEntity* entityUnderCursor = we_findEntityUnderCursor(context, false, false); if (entityUnderCursor) { WarUnitComponent* unit = we_getUnitComponent(context, entityUnderCursor); assert(unit); if (we_isComponentEnabled(context, entityUnderCursor, COMP_UNIT) && !wst_isDead(context, entityUnderCursor) && !wst_isGoingToDie(context, entityUnderCursor) && !wu_isCorpseUnit(context, entityUnderCursor) && !wst_isCollapsing(context, entityUnderCursor) && !wst_isGoingToCollapse(context, entityUnderCursor) && !( wu_isWorkerUnit(context, entityUnderCursor) && wst_isInsideBuilding(context, entityUnderCursor) ) && wmap_isUnitPartiallyVisible(context, map, entityUnderCursor)) { WarEntityListAdd(&newSelectedEntities, entityUnderCursor); } } } // include the already selected entities if the Ctrl key is pressed if (isKeyHeld(input, WAR_KEY_CTRL)) { // the max number of selected entities is 4, so there is no much // throuble looking for the actual entities here, it will also // improve when a hash is make for looking up the entities for (s32 i = 0; i < map->selectedEntities.count; i++) { WarEntity* entity = we_findEntity(context, map->selectedEntities.items[i]); if (entity) WarEntityListAdd(&newSelectedEntities, entity); } } updateSelectionFromList(context, &newSelectedEntities); WarEntityListFree(&newSelectedEntities); } input->mapDragActive = false; input->mapDragStartPos = VEC2_ZERO; input->mapDragRect = RECT_EMPTY; } } static void updateTreesEdit(WarContext* context) { WarMap* map = context->map; WarInput* input = &context->input; if (!map->editingTrees) return; if (isButtonJustPressed(input, WAR_MOUSE_LEFT)) { if (rect_containsf(map->mapPanel, input->pos.x, input->pos.y)) { vec2 pointerPos = wmap_screenToMapCoordinatesV(context, input->pos); pointerPos = wmap_mapToTileCoordinatesV(pointerPos); s32 x = (s32)pointerPos.x; s32 y = (s32)pointerPos.y; WarEntityId entityId = getTileEntityId(map->finder, x, y); WarEntity* entity = we_findEntity(context, entityId); if (!entity) { entity = map->forest; we_plantTree(context, entity, x, y); we_determineAllTreeTiles(context); } else if (entity->type == WAR_ENTITY_TYPE_FOREST) { WarTree* tree = we_getTreeAtPosition(context, entity, x, y); if (tree) { we_chopTree(context, entity, tree, TREE_MAX_WOOD); we_determineAllTreeTiles(context); } } } } } void updateRoadsEdit(WarContext* context) { WarMap* map = context->map; WarInput* input = &context->input; if (!map->editingRoads) return; if (isButtonJustPressed(input, WAR_MOUSE_LEFT)) { if (rect_containsf(map->mapPanel, input->pos.x, input->pos.y)) { vec2 pointerPos = wmap_screenToMapCoordinatesV(context, input->pos); pointerPos = wmap_mapToTileCoordinatesV(pointerPos); s32 x = (s32)pointerPos.x; s32 y = (s32)pointerPos.y; WarEntity* road = map->road; WarRoadPiece* piece = we_getRoadPieceAtPosition(context, road, x, y); if (!piece) { we_addRoadPiece(context, road, x, y, 0); we_determineRoadTypes(context, road); } else { we_removeRoadPiece(context, road, piece); we_determineRoadTypes(context, road); } } } } static void updateWallsEdit(WarContext* context) { WarMap* map = context->map; WarInput* input = &context->input; if (!map->editingWalls) return; if (isButtonJustPressed(input, WAR_MOUSE_LEFT)) { if (rect_containsf(map->mapPanel, input->pos.x, input->pos.y)) { vec2 pointerPos = wmap_screenToMapCoordinatesV(context, input->pos); pointerPos = wmap_mapToTileCoordinatesV(pointerPos); s32 x = (s32)pointerPos.x; s32 y = (s32)pointerPos.y; WarEntity* wall = map->wall; WarWallPiece* piece = we_getWallPieceAtPosition(context, wall, x, y); if (!piece) { WarWallPiece* newPiece = we_addWallPiece(context, wall, x, y, 0); newPiece->hp = WAR_WALL_MAX_HP; newPiece->maxhp = WAR_WALL_MAX_HP; we_determineWallTypes(context, wall); } else { setFreeTiles(map->finder, piece->tilex, piece->tiley, 1, 1); we_removeWallPiece(context, wall, piece); we_determineWallTypes(context, wall); } } } } void updateRuinsEdit(WarContext* context) { WarMap* map = context->map; WarInput* input = &context->input; if (!map->editingRuins) return; if (isButtonJustPressed(input, WAR_MOUSE_LEFT)) { if (rect_containsf(map->mapPanel, input->pos.x, input->pos.y)) { vec2 pointerPos = wmap_screenToMapCoordinatesV(context, input->pos); pointerPos = wmap_mapToTileCoordinatesV(pointerPos); s32 x = (s32)pointerPos.x; s32 y = (s32)pointerPos.y; WarEntity* ruin = map->ruin; WarRuinPiece* piece = we_getRuinPieceAtPosition(context, ruin, x, y); if (!piece) { we_addRuinsPieces(context, ruin, x, y, 2); we_determineRuinTypes(context, ruin); } else { we_removeRuinPiece(context, ruin, piece); we_determineRuinTypes(context, ruin); } } } } static void updateRainOfFireEdit(WarContext* context) { WarMap* map = context->map; WarInput* input = &context->input; if (!map->editingRainOfFire) return; if (isButtonJustPressed(input, WAR_MOUSE_LEFT)) { if (rect_containsf(map->mapPanel, input->pos.x, input->pos.y)) { rect viewport = map->viewport; vec2 target = wmap_screenToMapCoordinatesV(context, input->pos); vec2 origin = vec2f(target.x, viewport.y); wproj_createProjectile(context, WAR_PROJECTILE_RAIN_OF_FIRE, 0, 0, origin, target); } } } static void updateAddUnit(WarContext* context) { WarMap* map = context->map; WarInput* input = &context->input; if (!map->addingUnit) return; if (isButtonJustPressed(input, WAR_MOUSE_LEFT)) { if (rect_containsf(map->mapPanel, input->pos.x, input->pos.y)) { vec2 pointerPos = wmap_screenToMapCoordinatesV(context, input->pos); pointerPos = wmap_mapToTileCoordinatesV(pointerPos); s32 x = (s32)pointerPos.x; s32 y = (s32)pointerPos.y; WarEntityId entityId = getTileEntityId(map->finder, x, y); if (!entityId) { WarRace addingUnitRace = wu_getUnitTypeRace(map->addingUnitType); for (s32 i = 0; i < MAX_PLAYERS_COUNT; i++) { if (map->players[i].race == addingUnitRace) { we_createUnit(context, CREATE_UNIT_ARGS_INIT(.type=map->addingUnitType, .x=x, .y=y, .player=map->players[i].index, .resourceKind=WAR_RESOURCE_NONE, .amount=0, .addToMap=true)); break; } } } } } } static void updateCommandButtons(WarContext* context) { TracyCZoneN(ctx, "UpdateCommandButtons", 1); WarMap* map = context->map; // Reset all IMGUI command panel state. for (s32 i = 0; i < 6; i++) { map->commandSlotActive[i] = false; map->commandSlots[i] = (WarUnitCommandData){0}; } for (s32 i = 0; i < 4; i++) { map->commandTextVisible[i] = false; map->commandTexts[i][0] = '\0'; map->commandTextHighlightIndex[i] = NO_HIGHLIGHT; map->commandTextHighlightCount[i] = 0; } s32 selectedEntitiesCount = map->selectedEntities.count; if (selectedEntitiesCount == 0) { TracyCZoneEnd(ctx); return; } WarEntity* entity = we_findEntity(context, map->selectedEntities.items[0]); assert(entity && wu_isUnit(entity)); WarUnitComponent* unit = we_getUnitComponent(context, entity); assert(unit); // if the selected unit is a farm, // just show the text about the food consumtion // // FIX: this information shouldn't be visible if the selected unit is not friendly if (unit->type == WAR_UNIT_FARM_HUMANS || unit->type == WAR_UNIT_FARM_ORCS) { if (!unit->building) { s32 farmsCount = wu_getNumberOfBuildingsOfType(context, unit->player, unit->type, true); s32 dudesCount = wu_getTotalNumberOfDudes(context, unit->player); snprintf(map->commandTexts[0], sizeof(map->commandTexts[0]), "FOOD USAGE:"); map->commandTextVisible[0] = true; snprintf(map->commandTexts[1], sizeof(map->commandTexts[1]), "GROWN %d", farmsCount * 4 + 1); map->commandTextVisible[1] = true; snprintf(map->commandTexts[2], sizeof(map->commandTexts[2]), " USED %d", dudesCount); map->commandTextVisible[2] = true; TracyCZoneEnd(ctx); return; } } // if the selected unit is a goldmine, // just add the text with the remaining gold if (unit->type == WAR_UNIT_GOLDMINE) { s32 gold = unit->amount; snprintf(map->commandTexts[0], sizeof(map->commandTexts[0]), "GOLD LEFT"); map->commandTextVisible[0] = true; snprintf(map->commandTexts[3], sizeof(map->commandTexts[3]), "%d", gold); map->commandTextVisible[3] = true; TracyCZoneEnd(ctx); return; } // determine the commands for the selected unit(s) WarUnitCommandType commands[6] = {0}; wu_getUnitCommands(context, entity, commands); if (selectedEntitiesCount > 1) { WarUnitCommandType selectedCommands[6] = {0}; for (s32 i = 1; i < selectedEntitiesCount; i++) { WarEntity* selectedEntity = we_findEntity(context, map->selectedEntities.items[i]); assert(selectedEntity && wu_isUnit(selectedEntity)); memset(selectedCommands, 0, sizeof(selectedCommands)); wu_getUnitCommands(context, selectedEntity, selectedCommands); for (s32 j = 0; j < arrayLength(commands); j++) { if (commands[j] != selectedCommands[j]) { commands[j] = WAR_COMMAND_NONE; } } } } for (s32 i = 0; i < arrayLength(commands); i++) { if (commands[i] != WAR_COMMAND_NONE) { map->commandSlots[i] = wu_getUnitCommandData(context, entity, commands[i]); map->commandSlotActive[i] = true; } } TracyCZoneEnd(ctx); } void updateCommandFromRightClick(WarContext* context) { TracyCZoneN(ctx, "UpdateCommandFromRightClick", 1); WarMap* map = context->map; WarUnitCommand* command = &map->command; WarInput* input = &context->input; if (isButtonJustPressed(input, WAR_MOUSE_RIGHT)) { if (command->type == WAR_COMMAND_NONE) { s32 selEntitiesCount = map->selectedEntities.count; if (selEntitiesCount > 0) { // if the right click was on the map if (rect_containsf(map->mapPanel, input->pos.x, input->pos.y)) { vec2 targetPoint = wmap_screenToMapCoordinatesV(context, input->pos); vec2 targetTile = wmap_mapToTileCoordinatesV(targetPoint); WarEntityId targetEntityId = getTileEntityId(map->finder, (s32)targetTile.x, (s32)targetTile.y); WarEntity* targetEntity = we_findEntity(context, targetEntityId); if (targetEntity) { if (wu_isUnitOfType(context, targetEntity, WAR_UNIT_GOLDMINE)) { if (!wmap_isUnitUnknown(context, map, targetEntity)) wcmd_executeHarvestCommand(context, targetEntity, targetTile); else wcmd_executeMoveCommand(context, targetPoint); } else if (isEntityOfType(targetEntity, WAR_ENTITY_TYPE_FOREST)) { if (wmap_isTileVisible(map, (s32)targetTile.x, (s32)targetTile.y)) { wcmd_executeHarvestCommand(context, targetEntity, targetTile); } else { WarTree* tree = we_findAccesibleTree(context, targetEntity, targetTile); if (tree) { targetTile = vec2i(tree->tilex, tree->tiley); wcmd_executeHarvestCommand(context, targetEntity, targetTile); } else { wcmd_executeMoveCommand(context, targetPoint); } } } else if (wu_isUnitOfType(context, targetEntity, WAR_UNIT_TOWNHALL_HUMANS) || wu_isUnitOfType(context, targetEntity, WAR_UNIT_TOWNHALL_ORCS)) { if (!wmap_isUnitUnknown(context, map, targetEntity)) { if (wu_isEnemyUnit(context, targetEntity)) { wcmd_executeAttackCommand(context, targetEntity, targetTile); } else { wcmd_executeDeliverCommand(context, targetEntity); } } else { wcmd_executeMoveCommand(context, targetPoint); } } else if (wu_isWall(targetEntity)) { // it doesn't matter if the wall piece is visible or not, // the unit will walk to it wcmd_executeMoveCommand(context, targetPoint); } else { if (wu_isEnemyUnit(context, targetEntity)) { wcmd_executeAttackCommand(context, targetEntity, targetTile); } else { wcmd_executeFollowCommand(context, targetEntity); } } } else { wcmd_executeMoveCommand(context, targetPoint); } } // if the right click was on the minimap else if (rect_containsf(map->minimapPanel, input->pos.x, input->pos.y)) { vec2 offset = wmap_screenToMinimapCoordinatesV(context, input->pos); vec2 targetPoint = wmap_tileToMapCoordinatesV(offset, true); wcmd_executeMoveCommand(context, targetPoint); } } } else { wcmd_cancel(context, NULL); } } TracyCZoneEnd(ctx); } static void updateStatus(WarContext* context) { TracyCZoneN(ctx, "UpdateStatus", 1); WarMap* map = context->map; WarInput* input = &context->input; WarCheatStatus* cheatStatus = &map->cheatStatus; WarFlashStatus* flashStatus = &map->flashStatus; memset(map->hudStatusText, 0, sizeof(map->hudStatusText)); map->hudStatusHighlightIndex = NO_HIGHLIGHT; map->hudStatusHighlightCount = 0; map->hudStatusGold = 0; map->hudStatusWood = 0; if (cheatStatus->enabled) { if (cheatStatus->feedback) { cheatStatus->feedbackTime -= context->deltaTime; if (cheatStatus->feedbackTime <= 0) { cheatStatus->feedbackTime = 0; cheatStatus->feedback = false; } } if (cheatStatus->visible) { if (isKeyJustReleased(input, WAR_KEY_ESC) || isKeyJustReleased(input, WAR_KEY_ENTER)) { if (isKeyJustReleased(input, WAR_KEY_ENTER)) { wcheat_applyCheat(context, wsv_fromString(&cheatStatus->text)); } wcheatp_setCheatsPanelVisible(context, false); TracyCZoneEnd(ctx); return; } if (isKeyJustReleased(input, WAR_KEY_TAB)) { s32 length = (s32)cheatStatus->text.length; if (TAB_WIDTH <= STATUS_TEXT_MAX_LENGTH - length) { wstr_insert(&cheatStatus->text, cheatStatus->position, wsv_fromCString("\t")); cheatStatus->position++; } } else if (isKeyJustReleased(input, WAR_KEY_BACKSPACE)) { if (cheatStatus->position > 0) { wstr_removeRange(&cheatStatus->text, cheatStatus->position - 1, 1); cheatStatus->position--; } } else if (isKeyJustReleased(input, WAR_KEY_DELETE)) { s32 length = (s32)cheatStatus->text.length; if (cheatStatus->position < length) { wstr_removeRange(&cheatStatus->text, cheatStatus->position, 1); } } else if (isKeyJustReleased(input, WAR_KEY_RIGHT)) { s32 length = (s32)cheatStatus->text.length; if (cheatStatus->position < length) { cheatStatus->position++; } } else if (isKeyJustReleased(input, WAR_KEY_LEFT)) { if (cheatStatus->position > 0) { cheatStatus->position--; } } else if (isKeyJustReleased(input, WAR_KEY_HOME)) { cheatStatus->position = 0; } else if (isKeyJustReleased(input, WAR_KEY_END)) { s32 length = (s32)cheatStatus->text.length; cheatStatus->position = length; } StringView statusText = wsv_fromCStringFormat(map->hudStatusText, arrayLength(map->hudStatusText), "MSG: %.*s", (s32)cheatStatus->text.length, cheatStatus->text.data); WarFontParams params = { .fontSize = 6.0f, .fontData = getFontData(0) }; vec2 statusTextSize = wfont_measureSingleSpriteText(statusText, (s32)statusText.length, params); // Store cursor X offset (relative to bottomPanel.x + 2) for renderHUD. map->cheatStatus.cursorX = 2.0f + statusTextSize.x; TracyCZoneEnd(ctx); return; } map->cheatStatus.cursorX = -1.0f; // sentinel: cursor not visible if (isKeyJustReleased(input, WAR_KEY_ENTER)) { wcheatp_setCheatsPanelVisible(context, true); } } if (flashStatus->enabled) { if (flashStatus->startTime + flashStatus->duration >= context->time) { wsv_copyToBuffer(wstr_view(&flashStatus->text), map->hudStatusText, arrayLength(map->hudStatusText)); map->hudStatusHighlightIndex = NO_HIGHLIGHT; map->hudStatusHighlightCount = 0; map->hudStatusGold = 0; map->hudStatusWood = 0; TracyCZoneEnd(ctx); return; } // if the time for the flash status is over, just disabled it flashStatus->enabled = false; } if (map->selectedEntities.count > 0) { for (s32 i = 0; i < map->selectedEntities.count; i++) { WarEntityId selectedEntityId = map->selectedEntities.items[i]; WarEntity* selectedEntity = we_findEntity(context, selectedEntityId); assert(selectedEntity); if (wu_isBuildingUnit(context, selectedEntity)) { if (wst_isTraining(context, selectedEntity) || wst_isGoingToTrain(context, selectedEntity)) { WarState* trainState = wst_getTrainState(context, selectedEntity); WarUnitType unitToBuild = trainState->train.unitToBuild; const WarUnitCommandMapping* commandMapping = wu_getCommandMappingFromUnitType(unitToBuild); const WarUnitCommandBaseData* commandData = wu_getCommandBaseData(commandMapping->type); wsv_copyToBuffer(commandData->tooltip2, map->hudStatusText, arrayLength(map->hudStatusText)); } else if (wst_isUpgrading(context, selectedEntity) || wst_isGoingToUpgrade(context, selectedEntity)) { WarState* upgradeState = wst_getUpgradeState(context, selectedEntity); WarUpgradeType upgradeToBuild = upgradeState->upgrade.upgradeToBuild; const WarUnitCommandMapping* commandMapping = wu_getCommandMappingFromUpgradeType(upgradeToBuild); const WarUnitCommandBaseData* commandData = wu_getCommandBaseData(commandMapping->type); wsv_copyToBuffer(commandData->tooltip2, map->hudStatusText, arrayLength(map->hudStatusText)); } else { WarUnitComponent* selUnit = we_getUnitComponent(context, selectedEntity); assert(selUnit); s32 hp = selUnit->hp; s32 maxhp = selUnit->maxhp; if (hp < maxhp) { // to calculate the amount of wood and gold needed to repair a // building I'm taking the 12% of the damage of the building, // so for the a FARM if it has a damage of 200, the amount of // wood and gold would be 200 * 0.12 = 24. // s32 repairCost = (s32)ceil((maxhp - hp) * 0.12f); wsv_fromCStringFormat(map->hudStatusText, arrayLength(map->hudStatusText), "FULL REPAIRS WILL COST %d GOLD & LUMBER", repairCost); } } } else if (wu_isWorkerUnit(context, selectedEntity)) { if (wu_isCarryingResources(context, selectedEntity)) { WarUnitComponent* selUnit = we_getUnitComponent(context, selectedEntity); assert(selUnit); if (selUnit->resourceKind == WAR_RESOURCE_GOLD) { wsv_copyToBuffer(wsv_fromCString("CARRYING GOLD"), map->hudStatusText, arrayLength(map->hudStatusText)); } else if (selUnit->resourceKind == WAR_RESOURCE_WOOD) { wsv_copyToBuffer(wsv_fromCString("CARRYING LUMBER"), map->hudStatusText, arrayLength(map->hudStatusText)); } } } } } WarEntityList* buttons = we_getEntitiesOfType(context, WAR_ENTITY_TYPE_BUTTON); for(s32 i = 0; i < buttons->count; i++) { WarEntity* entity = buttons->items[i]; if (entity) { if (we_isComponentEnabled(context, entity, COMP_UI) && we_isComponentEnabled(context, entity, COMP_BUTTON)) { WarButtonComponent* button = we_getButtonComponent(context, entity); assert(button); if (button->interactive && button->hot) { memset(map->hudStatusText, 0, sizeof(map->hudStatusText)); wsv_copyToBuffer(wstr_view(&button->tooltip), map->hudStatusText, arrayLength(map->hudStatusText)); map->hudStatusHighlightIndex = button->highlightIndex; map->hudStatusHighlightCount = button->highlightCount; map->hudStatusGold = button->gold; map->hudStatusWood = button->wood; break; } } } } TracyCZoneEnd(ctx); } static void updateMapCursor(WarContext* context) { TracyCZoneN(ctx, "UpdateMapCursor", 1); WarMap* map = context->map; WarInput* input = &context->input; if (!map->playing) { wui_changeCursorType(context, WAR_CURSOR_ARROW); TracyCZoneEnd(ctx); return; } if (isMapDragging(input)) { wui_changeCursorType(context, WAR_CURSOR_GREEN_CROSSHAIR); TracyCZoneEnd(ctx); return; } if (rect_containsf(map->mapPanel, input->pos.x, input->pos.y)) { WarUnitCommand* command = &map->command; switch (command->type) { case WAR_COMMAND_ATTACK: case WAR_COMMAND_SPELL_RAIN_OF_FIRE: case WAR_COMMAND_SPELL_POISON_CLOUD: { wui_changeCursorType(context, WAR_CURSOR_RED_CROSSHAIR); break; } case WAR_COMMAND_MOVE: case WAR_COMMAND_STOP: case WAR_COMMAND_HARVEST: case WAR_COMMAND_DELIVER: case WAR_COMMAND_REPAIR: case WAR_COMMAND_SPELL_HEALING: case WAR_COMMAND_SPELL_FAR_SIGHT: case WAR_COMMAND_SPELL_INVISIBILITY: case WAR_COMMAND_SPELL_RAISE_DEAD: case WAR_COMMAND_SPELL_DARK_VISION: case WAR_COMMAND_SPELL_UNHOLY_ARMOR: { wui_changeCursorType(context, WAR_CURSOR_YELLOW_CROSSHAIR); break; } case WAR_COMMAND_BUILD_FARM_HUMANS: case WAR_COMMAND_BUILD_FARM_ORCS: case WAR_COMMAND_BUILD_BARRACKS_HUMANS: case WAR_COMMAND_BUILD_BARRACKS_ORCS: case WAR_COMMAND_BUILD_CHURCH: case WAR_COMMAND_BUILD_TEMPLE: case WAR_COMMAND_BUILD_TOWER_HUMANS: case WAR_COMMAND_BUILD_TOWER_ORCS: case WAR_COMMAND_BUILD_TOWNHALL_HUMANS: case WAR_COMMAND_BUILD_TOWNHALL_ORCS: case WAR_COMMAND_BUILD_LUMBERMILL_HUMANS: case WAR_COMMAND_BUILD_LUMBERMILL_ORCS: case WAR_COMMAND_BUILD_STABLE: case WAR_COMMAND_BUILD_KENNEL: case WAR_COMMAND_BUILD_BLACKSMITH_HUMANS: case WAR_COMMAND_BUILD_BLACKSMITH_ORCS: case WAR_COMMAND_BUILD_ROAD: case WAR_COMMAND_BUILD_WALL: { wui_changeCursorType(context, WAR_CURSOR_ARROW); break; } default: { vec2 targetPoint = wmap_screenToMapCoordinatesV(context, input->pos); vec2 targetTile = wmap_mapToTileCoordinatesV(targetPoint); WarEntity* entityUnderCursor = we_findEntityUnderCursor(context, true, true); if (!entityUnderCursor) { wui_changeCursorType(context, WAR_CURSOR_ARROW); break; } WarEntityIdList* selectedEntities = &map->selectedEntities; if (selectedEntities->count > 0) { WarEntity* selectedEntity = we_findEntity(context, selectedEntities->items[0]); if (selectedEntity && wu_isFriendlyUnit(context, selectedEntity) && wu_isDudeUnit(context, selectedEntity)) { if (wu_isUnitOfType(context, entityUnderCursor, WAR_UNIT_GOLDMINE) && !wmap_isUnitUnknown(context, map, entityUnderCursor) && wu_isWorkerUnit(context, selectedEntity)) { wui_changeCursorType(context, WAR_CURSOR_YELLOW_CROSSHAIR); } else if (isEntityOfType(entityUnderCursor, WAR_ENTITY_TYPE_FOREST) && !wmap_isTileUnkown(map, (s32)targetTile.x, (s32)targetTile.y) && wu_isWorkerUnit(context, selectedEntity)) { wui_changeCursorType(context, WAR_CURSOR_YELLOW_CROSSHAIR); } else if (isEntityOfType(entityUnderCursor, WAR_ENTITY_TYPE_WALL) && !wmap_isTileUnkown(map, (s32)targetTile.x, (s32)targetTile.y) && wu_isWarriorUnit(context, selectedEntity) && wu_canAttack(context, selectedEntity, entityUnderCursor)) { wui_changeCursorType(context, WAR_CURSOR_RED_CROSSHAIR); } else if (!wu_isFriendlyUnit(context, entityUnderCursor) && wu_isWarriorUnit(context, selectedEntity) && wu_canAttack(context, selectedEntity, entityUnderCursor)) { wui_changeCursorType(context, WAR_CURSOR_RED_CROSSHAIR); } else if (isEntityOfType(entityUnderCursor, WAR_ENTITY_TYPE_FOREST) || isEntityOfType(entityUnderCursor, WAR_ENTITY_TYPE_WALL)) { wui_changeCursorType(context, WAR_CURSOR_ARROW); } else { wui_changeCursorType(context, WAR_CURSOR_MAGNIFYING_GLASS); } } else if (isEntityOfType(entityUnderCursor, WAR_ENTITY_TYPE_FOREST) || isEntityOfType(entityUnderCursor, WAR_ENTITY_TYPE_WALL)) { wui_changeCursorType(context, WAR_CURSOR_ARROW); } else { wui_changeCursorType(context, WAR_CURSOR_MAGNIFYING_GLASS); } } else if (isEntityOfType(entityUnderCursor, WAR_ENTITY_TYPE_FOREST) || isEntityOfType(entityUnderCursor, WAR_ENTITY_TYPE_WALL)) { wui_changeCursorType(context, WAR_CURSOR_ARROW); } else { wui_changeCursorType(context, WAR_CURSOR_MAGNIFYING_GLASS); } break; } } } else if (rect_containsf(map->minimapPanel, input->pos.x, input->pos.y)) { WarUnitCommand* command = &map->command; switch (command->type) { case WAR_COMMAND_ATTACK: case WAR_COMMAND_SPELL_RAIN_OF_FIRE: case WAR_COMMAND_SPELL_POISON_CLOUD: { wui_changeCursorType(context, WAR_CURSOR_RED_CROSSHAIR); break; } case WAR_COMMAND_MOVE: case WAR_COMMAND_SPELL_FAR_SIGHT: case WAR_COMMAND_SPELL_DARK_VISION: { wui_changeCursorType(context, WAR_CURSOR_YELLOW_CROSSHAIR); break; } default: { wui_changeCursorType(context, WAR_CURSOR_ARROW); break; } } } else { vec2 dir = wmap_getDirFromMousePos(context); if (dir.x < 0 && dir.y < 0) // -1, -1 wui_changeCursorType(context, WAR_CURSOR_ARROW_UP_LEFT); else if (dir.x < 0 && dir.y > 0) // -1, 1 wui_changeCursorType(context, WAR_CURSOR_ARROW_BOTTOM_LEFT); else if (dir.x > 0 && dir.y < 0) // 1, -1 wui_changeCursorType(context, WAR_CURSOR_ARROW_UP_RIGHT); else if (dir.x > 0 && dir.y > 0) // 1, 1 wui_changeCursorType(context, WAR_CURSOR_ARROW_BOTTOM_RIGHT); else if (dir.x < 0) // -1, 0 wui_changeCursorType(context, WAR_CURSOR_ARROW_LEFT); else if (dir.x > 0) // 1, 0 wui_changeCursorType(context, WAR_CURSOR_ARROW_RIGHT); else if (dir.y < 0) // 0, -1 wui_changeCursorType(context, WAR_CURSOR_ARROW_UP); else if (dir.y > 0) // 0, 1 wui_changeCursorType(context, WAR_CURSOR_ARROW_BOTTOM); else // 0, 0 wui_changeCursorType(context, WAR_CURSOR_ARROW); } TracyCZoneEnd(ctx); } static void updateStateMachines(WarContext* context) { TracyCZoneN(ctx, "UpdateStateMachines", 1); WarEntityManager* manager = we_getEntityManager(context); assert(manager); for(s32 i = 0; i < MAX_ENTITIES_COUNT; i++) { WarEntity* entity = &manager->entities[i]; if (entity->id != 0) { wst_updateStateMachine(context, entity); } } TracyCZoneEnd(ctx); } static void updateActions(WarContext* context) { TracyCZoneN(ctx, "UpdateActions", 1); WarEntityList* units = we_getEntitiesOfType(context, WAR_ENTITY_TYPE_UNIT); for(s32 i = 0; i < units->count; i++) { WarEntity* entity = units->items[i]; if (entity) { wact_updateAction(context, entity); } } TracyCZoneEnd(ctx); } static void updateProjectiles(WarContext* context) { TracyCZoneN(ctx, "UpdateProjectiles", 1); WarEntityList* projectiles = we_getEntitiesOfType(context, WAR_ENTITY_TYPE_PROJECTILE); for (s32 i = 0; i < projectiles->count; i++) { WarEntity* entity = projectiles->items[i]; if (entity) { wproj_updateProjectile(context, entity); } } TracyCZoneEnd(ctx); } static void updateMagic(WarContext* context) { TracyCZoneN(ctx, "UpdateMagic", 1); WarEntityList* units = we_getEntitiesOfType(context, WAR_ENTITY_TYPE_UNIT); for (s32 i = 0; i < units->count; i++) { WarEntity* entity = units->items[i]; if (entity && wu_isMagicUnit(context, entity)) { if (wst_isDead(context, entity) || wst_isGoingToDie(context, entity)) continue; WarUnitComponent* unit = we_getUnitComponent(context, entity); assert(unit); if (unit->manaTime <= 0) { if (wu_isSummonUnit(context, entity)) { unit->mana = MAX(unit->mana - 1, 0); // when the mana runs out the summoned units will die if (unit->mana == 0) { vec2 position = wu_getUnitCenterPosition(context, entity, false); WarState* deathState = wst_createDeathState(context, entity); wst_changeNextState(context, entity, deathState, true, true); if (unit->type == WAR_UNIT_SCORPION || unit->type == WAR_UNIT_SPIDER) { wa_createAudioWithPosition(context, CREATE_AUDIO_ARGS_INIT(.audioId=WAR_DEAD_SPIDER_SCORPION, .position=position, .hasPosition=true, .loop=false)); } } } else { // the magic units have a mana regeneration rate of roughly 1 point/sec // so a magic unit will spend almost 4 minutes to fill its mana when its rans out unit->mana = MIN(unit->mana + 1, unit->maxMana); } unit->manaTime = 1.0f; } else { unit->manaTime -= wmap_getMapScaledSpeed(context, context->deltaTime); } } } TracyCZoneEnd(ctx); } static bool updatePoisonCloud(WarContext* context, WarEntity* entity) { TracyCZoneN(ctx, "UpdatePoisonCloud", 1); WarPoisonCloudComponent* poisonCloud = we_getPoisonCloudComponent(context, entity); assert(poisonCloud); poisonCloud->time -= wmap_getMapScaledSpeed(context, context->deltaTime); poisonCloud->damageTime -= wmap_getMapScaledSpeed(context, context->deltaTime); if (poisonCloud->damageTime <= 0) { WarEntityList* nearUnits = we_getNearUnits(context, poisonCloud->position, 2); for (s32 i = 0; i < nearUnits->count; i++) { WarEntity* targetEntity = nearUnits->items[i]; if (targetEntity && !wst_isDead(context, targetEntity) && !wst_isGoingToDie(context, targetEntity) && !wst_isCollapsing(context, targetEntity) && !wst_isGoingToCollapse(context, targetEntity)) { we_takeDamage(context, targetEntity, 0, POISON_CLOUD_DAMAGE); } } WarEntityListFree(nearUnits); poisonCloud->damageTime = 1.0f; } TracyCZoneEnd(ctx); return poisonCloud->time <= 0; } static bool updateSight(WarContext* context, WarEntity* entity) { TracyCZoneN(ctx, "UpdateSight", 1); WarSightComponent* sight = we_getSightComponent(context, entity); assert(sight); sight->time -= wmap_getMapScaledSpeed(context, context->deltaTime); TracyCZoneEnd(ctx); return sight->time <= 0; } static void updateSpells(WarContext* context) { TracyCZoneN(ctx, "UpdateSpells", 1); WarEntityList* poisonCloudSpells = we_getEntitiesOfType(context, WAR_ENTITY_TYPE_POISON_CLOUD); WarEntityList* sightSpells = we_getEntitiesOfType(context, WAR_ENTITY_TYPE_SIGHT); s32 spellsToRemoveCount = 0; WarEntityId* spellsToRemove = (WarEntityId*)wm_allocFrame(sizeof(WarEntityId) * (poisonCloudSpells->count + sightSpells->count)); for (s32 i = 0; i < poisonCloudSpells->count; i++) { WarEntity* entity = poisonCloudSpells->items[i]; assert(entity); if (updatePoisonCloud(context, entity)) { spellsToRemove[spellsToRemoveCount++] = entity->id; } } for (s32 i = 0; i < sightSpells->count; i++) { WarEntity* entity = sightSpells->items[i]; assert(entity); if (updateSight(context, entity)) { spellsToRemove[spellsToRemoveCount++] = entity->id; } } WarEntityList* units = we_getEntitiesOfType(context, WAR_ENTITY_TYPE_UNIT); for (s32 i = 0; i < units->count; i++) { WarEntity* entity = units->items[i]; assert(entity); WarUnitComponent* unit = we_getUnitComponent(context, entity); assert(unit); if (unit->invisible) { unit->invisibilityTime -= wmap_getMapScaledSpeed(context, context->deltaTime); if (unit->invisibilityTime <= 0) { unit->invisible = false; unit->invisibilityTime = 0; } } if (unit->invulnerable) { unit->invulnerabilityTime -= wmap_getMapScaledSpeed(context, context->deltaTime); if (unit->invulnerabilityTime <= 0) { unit->invulnerable = false; unit->invulnerabilityTime = 0; } } } for (s32 i = 0; i < spellsToRemoveCount; i++) { we_removeEntityById(context, spellsToRemove[i]); } TracyCZoneEnd(ctx); } void updateFoW(WarContext* context) { TracyCZoneN(ctx, "UpdateFoW", 1); WarMap* map = context->map; for (s32 i = 0; i < MAP_TILES_WIDTH * MAP_TILES_HEIGHT; i++) { WarMapTile* tile = &map->tiles[i]; tile->type = WAR_FOG_PIECE_NONE; tile->boundary = WAR_FOG_BOUNDARY_NONE; if (tile->state == MAP_TILE_STATE_VISIBLE) tile->state = MAP_TILE_STATE_FOG; } // the Holy Sight and Dark Vision spells are the first entities that change FoW WarEntityList* sightSpells = we_getEntitiesOfType(context, WAR_ENTITY_TYPE_SIGHT); for (s32 i = 0; i < sightSpells->count; i++) { WarEntity* entity = sightSpells->items[i]; if (entity) { WarSightComponent* sight = we_getSightComponent(context, entity); assert(sight); rect r = rect_expand(rectv(sight->position, VEC2_ONE), 3, 3); wmap_setMapTileState(map, (s32)r.x, (s32)r.y, (s32)r.width, (s32)r.height, MAP_TILE_STATE_VISIBLE); } } WarEntityList* units = we_getEntitiesOfType(context, WAR_ENTITY_TYPE_UNIT); // do the update of the FoW for friendly units first for (s32 i = 0; i < units->count; i++) { WarEntity* entity = units->items[i]; if (entity && wu_isFriendlyUnit(context, entity)) { WarUnitComponent* unit = we_getUnitComponent(context, entity); assert(unit); vec2 position = wu_getUnitCenterPosition(context, entity, true); vec2 unitSize = wu_getUnitSize(context, entity); s32 sight = wu_getUnitSightRange(context, entity); rect unitRect = rectv(position, unitSize); unitRect = rect_expand(unitRect, (f32)sight, (f32)sight); if (wu_isBuildingUnit(context, entity)) { // the friendly buildings are always seen by the player unit->hasBeenSeen = true; } // mark the tiles of the unit as visible wmap_setMapTileState(map, (s32)unitRect.x, (s32)unitRect.y, (s32)unitRect.width, (s32)unitRect.height, MAP_TILE_STATE_VISIBLE); // reveal the attack target of the unit WarEntity* targetEntity = we_getAttackTarget(context, entity); if (targetEntity) { const WarUnitStats* stats = wu_getUnitStats(unit->type); if (wu_isUnit(targetEntity)) { if (wu_unitInRange(context, entity, targetEntity, stats->range)) { wmap_setUnitMapTileState(context, map, targetEntity, MAP_TILE_STATE_VISIBLE); } } else if (wu_isWall(targetEntity)) { WarState* attackState = wst_getAttackState(context, entity); vec2 targetTile = attackState->attack.targetTile; if (wu_tileInRange(context, entity, targetTile, stats->range)) { WarWallPiece* piece = we_getWallPieceAtPosition(context, targetEntity, (s32)targetTile.x, (s32)targetTile.y); if (piece) { wmap_setMapTileState(map, (s32)targetTile.x, (s32)targetTile.y, 1, 1, MAP_TILE_STATE_VISIBLE); } } } } // reveal the attacker WarEntity* attacker = we_getAttacker(context, entity); if (attacker) { // if the attacker is the same the unit is attacking to // don't change tile state because already happened above if (!targetEntity || attacker->id != targetEntity->id) { wmap_setUnitMapTileState(context, map, attacker, MAP_TILE_STATE_VISIBLE); } } } } // and then do the update of the FoW for enemies and neutrals units for (s32 i = 0; i < units->count; i++) { WarEntity* entity = units->items[i]; if (entity && !wu_isFriendlyUnit(context, entity)) { if (!wmap_isUnitPartiallyVisible(context, map, entity)) { // remove from selection enemy or neutral units that goes into fog wmap_removeEntityFromSelection(context, entity->id); } else if (wu_isBuildingUnit(context, entity)) { WarUnitComponent* unit = we_getUnitComponent(context, entity); assert(unit); unit->hasBeenSeen = true; } } } TracyCZoneEnd(ctx); } void determineFoWTypes(WarContext* context) { TracyCZoneN(ctx, "DetermineFoWTypes", 1); WarMap* map = context->map; if (!map->fowEnabled) { TracyCZoneEnd(ctx); return; } const s32 dirC = 8; const s32 dirX[] = { -1, 0, 1, 1, 1, 0, -1, -1 }; const s32 dirY[] = { -1, -1, -1, 0, 1, 1, 1, 0 }; for(s32 y = 0; y < MAP_TILES_HEIGHT; y++) { for(s32 x = 0; x < MAP_TILES_WIDTH; x++) { WarMapTile* tile = wmap_getMapTileState(map, x, y); if (tile->state == MAP_TILE_STATE_VISIBLE) { s32 index = 0; s32 unkownCount = 0; s32 fogCount = 0; for (s32 d = 0; d < dirC; d++) { s32 xx = x + dirX[d]; s32 yy = y + dirY[d]; if (inRange(xx, 0, MAP_TILES_WIDTH) && inRange(yy, 0, MAP_TILES_HEIGHT)) { WarMapTile* neighborTile = wmap_getMapTileState(map, xx, yy); if (neighborTile->state == MAP_TILE_STATE_VISIBLE) index = index | (1 << d); else if (neighborTile->state == MAP_TILE_STATE_FOG) fogCount++; else unkownCount++; } } if (index != 0xFF) { tile->type = fogTileTypeMap[index]; } if (fogCount > 0) tile->boundary = WAR_FOG_BOUNDARY_FOG; else if (unkownCount > 0) tile->boundary = WAR_FOG_BOUNDARY_UNKOWN; } else if (tile->state == MAP_TILE_STATE_FOG) { s32 index = 0; s32 unkownCount = 0; for (s32 d = 0; d < dirC; d++) { s32 xx = x + dirX[d]; s32 yy = y + dirY[d]; if (inRange(xx, 0, MAP_TILES_WIDTH) && inRange(yy, 0, MAP_TILES_HEIGHT)) { WarMapTile* neighborTile = wmap_getMapTileState(map, xx, yy); if (neighborTile->state == MAP_TILE_STATE_VISIBLE || neighborTile->state == MAP_TILE_STATE_FOG) { index = index | (1 << d); } else { unkownCount++; } } } if (index != 0xFF) { tile->type = fogTileTypeMap[index]; } if (unkownCount > 0) { tile->boundary = WAR_FOG_BOUNDARY_UNKOWN; } } else { s32 index = 0; for (s32 d = 0; d < dirC; d++) { s32 xx = x + dirX[d]; s32 yy = y + dirY[d]; if (inRange(xx, 0, MAP_TILES_WIDTH) && inRange(yy, 0, MAP_TILES_HEIGHT)) { WarMapTile* neighborTile = wmap_getMapTileState(map, xx, yy); if (neighborTile->state == MAP_TILE_STATE_VISIBLE || neighborTile->state == MAP_TILE_STATE_FOG) { index = index | (1 << d); } } } if (index == 0xFF) { tile->type = fogTileTypeMap[index]; } } } } TracyCZoneEnd(ctx); } WarCampaignMapType wmap_getCampaignMapTypeByLevelInfoIndex(s32 levelInfoIndex) { return levelInfoIndex >= WAR_CAMPAIGN_HUMANS_01 && levelInfoIndex <= WAR_CAMPAIGN_ORCS_12 ? (WarCampaignMapType)levelInfoIndex : WAR_CAMPAIGN_CUSTOM; } WarLevelResult checkObjectives(WarContext* context) { WarMap* map = context->map; map->objectivesTime -= context->deltaTime; if (map->objectivesTime <= 0) { WarCampaignMapData data = wcamp_getCampaignData (wmap_getCampaignMapTypeByLevelInfoIndex(map->levelInfoIndex) ); if (data.checkObjectivesFunc) { return data.checkObjectivesFunc(context); } map->objectivesTime = 1; } return WAR_LEVEL_RESULT_NONE; } void updateObjectives(WarContext* context) { TracyCZoneN(ctx, "UpdateObjectives", 1); WarMap* map = context->map; if (map->result == WAR_LEVEL_RESULT_NONE) { map->result = checkObjectives(context); TracyCZoneEnd(ctx); return; } map->playing = false; bool isLastLevel = map->levelInfoIndex == WAR_CAMPAIGN_HUMANS_02 || map->levelInfoIndex == WAR_CAMPAIGN_ORCS_02; if (map->result == WAR_LEVEL_RESULT_WIN && isLastLevel) { wmm_showDemoEndMenu(context, true); } else { wmm_showOrHideGameOverMenu(context, true); } TracyCZoneEnd(ctx); } void wmap_updateMap(WarContext* context) { TracyCZoneN(ctx, "UpdateMap", 1); WarMap* map = context->map; if (!map->playing) { WarInput* input = &context->input; input->mapDragActive = false; input->mapDragStartPos = VEC2_ZERO; input->mapDragRect = RECT_EMPTY; wui_updateUIButtons(context, !map->cheatStatus.visible); TracyCZoneEnd(ctx); return; } updateViewport(context); updateDragRect(context); if (!wcmd_executeCommand(context)) { // only update the selection if the current command doesn't get // executed or there is no command at all. // the reason is because some commands are executed by the left click // as well as the selection, and if a command get executed the current // selection shouldn't be lost updateSelection(context); } wai_updateAIPlayers(context); updateStateMachines(context); updateActions(context); wanim_updateAnimations(context); updateProjectiles(context); updateMagic(context); updateSpells(context); updateFoW(context); determineFoWTypes(context); updateCommandButtons(context); updateCommandFromRightClick(context); updateStatus(context); updateTreesEdit(context); updateRoadsEdit(context); updateWallsEdit(context); updateRuinsEdit(context); updateRainOfFireEdit(context); updateAddUnit(context); updateObjectives(context); TracyCZoneEnd(ctx); } static void renderTerrain(WarContext* context) { TracyCZoneN(ctx, "RenderTerrain", 1); WarMap *map = context->map; WarResource* levelInfo = wres_getOrCreateResource(context, map->levelInfoIndex); assert(levelInfo && levelInfo->type == WAR_RESOURCE_TYPE_LEVEL_INFO); WarResource* levelVisual = wres_getOrCreateResource(context, levelInfo->levelInfo.visualIndex); assert(levelVisual && levelVisual->type == WAR_RESOURCE_TYPE_LEVEL_VISUAL); for(s32 y = 0; y < MAP_TILES_HEIGHT; y++) { for(s32 x = 0; x < MAP_TILES_WIDTH; x++) { WarMapTile* tile = wmap_getMapTileState(map, x, y); if (!map->fowEnabled || tile->state == MAP_TILE_STATE_VISIBLE || tile->state == MAP_TILE_STATE_FOG) { // index of the tile in the tilesheet u16 tileIndex = levelVisual->levelVisual.data[y * MAP_TILES_WIDTH + x]; // coordinates in pixels of the terrain tile s32 tilePixelX = (tileIndex % TILESET_TILES_PER_ROW) * MEGA_TILE_WIDTH; s32 tilePixelY = ((tileIndex / TILESET_TILES_PER_ROW) * MEGA_TILE_HEIGHT); wr_save(context); wr_translate(context, (f32)(x * MEGA_TILE_WIDTH), (f32)(y * MEGA_TILE_HEIGHT)); rect rs = recti(tilePixelX, tilePixelY, MEGA_TILE_WIDTH, MEGA_TILE_HEIGHT); rect rd = recti(0, 0, MEGA_TILE_WIDTH, MEGA_TILE_HEIGHT); wr_subImage(context, map->sprite.texture, rs, rd, VEC2_ONE); wr_restore(context); } } } TracyCZoneEnd(ctx); } static void renderFoW(WarContext* context) { TracyCZoneN(ctx, "RenderFoW", 1); WarMap* map = context->map; if (!map->fowEnabled) { TracyCZoneEnd(ctx); return; } // Pass 1: render unknown boundary and unknown tiles at full opacity for(s32 y = 0; y < MAP_TILES_HEIGHT; y++) { for(s32 x = 0; x < MAP_TILES_WIDTH; x++) { WarMapTile* tile = wmap_getMapTileState(map, x, y); if (tile->type != WAR_FOG_PIECE_NONE && tile->boundary == WAR_FOG_BOUNDARY_UNKOWN) { s32 tileIndex = (s32)tile->type; s32 tilePixelX = (tileIndex % TILESET_TILES_PER_ROW) * MEGA_TILE_WIDTH; s32 tilePixelY = (tileIndex / TILESET_TILES_PER_ROW) * MEGA_TILE_HEIGHT; rect rs = recti(tilePixelX, tilePixelY, MEGA_TILE_WIDTH, MEGA_TILE_HEIGHT); rect rd = recti(x * MEGA_TILE_WIDTH, y * MEGA_TILE_HEIGHT, MEGA_TILE_WIDTH, MEGA_TILE_HEIGHT); wr_subImage(context, map->sprite.texture, rs, rd, VEC2_ONE); } if (tile->state == MAP_TILE_STATE_UNKOWN) { rect rs = recti(0, 0, MEGA_TILE_WIDTH, MEGA_TILE_HEIGHT); rect rd = recti(x * MEGA_TILE_WIDTH, y * MEGA_TILE_HEIGHT, MEGA_TILE_WIDTH, MEGA_TILE_HEIGHT); wr_subImage(context, map->blackSprite.texture, rs, rd, VEC2_ONE); } } } // Pass 2: render fog boundary and fog tiles at half opacity wr_save(context); wr_globalAlpha(context, 0.5f); for(s32 y = 0; y < MAP_TILES_HEIGHT; y++) { for(s32 x = 0; x < MAP_TILES_WIDTH; x++) { WarMapTile* tile = wmap_getMapTileState(map, x, y); if (tile->type != WAR_FOG_PIECE_NONE && tile->state == MAP_TILE_STATE_VISIBLE && tile->boundary == WAR_FOG_BOUNDARY_FOG) { s32 tileIndex = (s32)tile->type; s32 tilePixelX = (tileIndex % TILESET_TILES_PER_ROW) * MEGA_TILE_WIDTH; s32 tilePixelY = (tileIndex / TILESET_TILES_PER_ROW) * MEGA_TILE_HEIGHT; rect rs = recti(tilePixelX, tilePixelY, MEGA_TILE_WIDTH, MEGA_TILE_HEIGHT); rect rd = recti(x * MEGA_TILE_WIDTH, y * MEGA_TILE_HEIGHT, MEGA_TILE_WIDTH, MEGA_TILE_HEIGHT); wr_subImage(context, map->sprite.texture, rs, rd, VEC2_ONE); } if (tile->state == MAP_TILE_STATE_FOG) { rect rs = recti(0, 0, MEGA_TILE_WIDTH, MEGA_TILE_HEIGHT); rect rd = recti(x * MEGA_TILE_WIDTH, y * MEGA_TILE_HEIGHT, MEGA_TILE_WIDTH, MEGA_TILE_HEIGHT); wr_subImage(context, map->blackSprite.texture, rs, rd, VEC2_ONE); } } } wr_restore(context); TracyCZoneEnd(ctx); } static void renderUnitPaths(WarContext* context) { WarEntityList* units = we_getEntitiesOfType(context, WAR_ENTITY_TYPE_UNIT); for(s32 i = 0; i < units->count; i++) { WarEntity *entity = units->items[i]; if (entity) { WarState* moveState = wst_getDirectState(context, entity, WAR_STATE_MOVE); if (moveState) { vec2List positions = moveState->move.positions; for(s32 k = moveState->move.positionIndex; k < positions.count; k++) { vec2 pos = wmap_tileToMapCoordinatesV(positions.items[k], true); pos = vec2_subv(pos, vec2i(2, 2)); wr_fillRect(context, rectv(pos, vec2i(4, 4)), wr_getColorFromList(entity->id)); } s32 index = moveState->move.pathNodeIndex; WarMapPath path = moveState->move.path; if (index >= 0) { vec2 prevPos = VEC2_ZERO; for(s32 k = 0; k < path.nodes.count; k++) { vec2 pos = wmap_tileToMapCoordinatesV(path.nodes.items[k], true); if (k > 0) wr_strokeLine(context, prevPos, pos, wr_getColorFromList(entity->id), 0.5f); wr_fillRect(context, rectv(pos, VEC2_ONE), k == index ? WAR_COLOR_RGB(255, 0, 255) : WAR_COLOR_RGB(255, 255, 0)); prevPos = pos; } } } } } } static void renderPassableInfo(WarContext* context) { WarMap *map = context->map; for(s32 y = 0; y < MAP_TILES_HEIGHT; y++) { for(s32 x = 0; x < MAP_TILES_WIDTH; x++) { if (isStatic(map->finder, x, y)) { vec2 pos = vec2i(x * MEGA_TILE_WIDTH, y * MEGA_TILE_HEIGHT); vec2 size = vec2i(MEGA_TILE_WIDTH, MEGA_TILE_HEIGHT); wr_fillRect(context, rectv(pos, size), WAR_COLOR_RGBA(255, 0, 0, 100)); } else if(isDynamic(map->finder, x, y)) { vec2 pos = vec2i(x * MEGA_TILE_WIDTH, y * MEGA_TILE_HEIGHT); vec2 size = vec2i(MEGA_TILE_WIDTH, MEGA_TILE_HEIGHT); wr_fillRect(context, rectv(pos, size), WAR_COLOR_RGBA(255, 150, 100, 100)); } } } } static void renderMapGrid(WarContext* context) { for(s32 x = 1; x < MAP_TILES_WIDTH; x++) { vec2 p1 = vec2i(x * MEGA_TILE_WIDTH, 0); vec2 p2 = vec2i(x * MEGA_TILE_WIDTH, MAP_TILES_HEIGHT * MEGA_TILE_HEIGHT); wr_strokeLine(context, p1, p2, WAR_COLOR_WHITE, 0.25f); } for(s32 y = 1; y < MAP_TILES_HEIGHT; y++) { vec2 p1 = vec2i(0, y * MEGA_TILE_HEIGHT); vec2 p2 = vec2i(MAP_TILES_WIDTH * MAP_TILES_WIDTH, y * MEGA_TILE_HEIGHT); wr_strokeLine(context, p1, p2, WAR_COLOR_WHITE, 0.25f); } } static void renderMapPanel(WarContext *context) { TracyCZoneN(ctx, "RenderMapPanel", 1); WarMap *map = context->map; wr_save(context); wr_translate(context, map->mapPanel.x, map->mapPanel.y); wr_translate(context, -map->viewport.x, -map->viewport.y); renderTerrain(context); we_renderEntitiesOfType(context, WAR_ENTITY_TYPE_RUIN); we_renderEntitiesOfType(context, WAR_ENTITY_TYPE_ROAD); we_renderEntitiesOfType(context, WAR_ENTITY_TYPE_WALL); we_renderEntitiesOfType(context, WAR_ENTITY_TYPE_FOREST); #ifdef DEBUG_RENDER_UNIT_PATHS renderUnitPaths(context); #endif #ifdef DEBUG_RENDER_PASSABLE_INFO renderPassableInfo(context); #endif #ifdef DEBUG_RENDER_MAP_GRID renderMapGrid(context); #endif we_renderEntitiesOfType(context, WAR_ENTITY_TYPE_UNIT); we_renderUnitSelection(context); we_renderEntitiesOfType(context, WAR_ENTITY_TYPE_PROJECTILE); we_renderEntitiesOfType(context, WAR_ENTITY_TYPE_POISON_CLOUD); we_renderEntitiesOfType(context, WAR_ENTITY_TYPE_ANIMATION); renderFoW(context); wr_restore(context); TracyCZoneEnd(ctx); } void wmap_renderMap(WarContext *context) { TracyCZoneN(ctx, "RenderMap", 1); updateMapCursor(context); renderMapPanel(context); wmui_renderMapUI(context); TracyCZoneEnd(ctx); } ================================================ FILE: src/war_map.h ================================================ #pragma once #include "war_ai.h" #include "war_campaigns.h" #include "war_cheats.h" #include "war_entities.h" #include "war_resources.h" struct _WarMapTile { WarMapTileState state; WarFogPieceType type; WarFogBoundaryType boundary; }; struct _WarUpgrade { s32 allowed; s32 level; }; struct _WarPlayerInfo { u8 index; WarRace race; s32 gold; s32 wood; bool godMode; bool features[MAX_FEATURES_COUNT]; WarUpgrade upgrades[MAX_UPGRADES_COUNT]; WarAI* ai; }; #define isHumanPlayer(player) ((player)->race == WAR_RACE_HUMANS) #define isOrcPlayer(player) ((player)->race == WAR_RACE_ORCS) #define isNeutralPlayer(player) ((player)->race == WAR_RACE_NEUTRAL) #define isFeatureAllowed(player, feature) ((player)->features[(feature)/2]) #define setFeatureAllowed(player, feature, allowed) ((player)->features[(feature/2)] = (allowed)) #define incrementUpgradeLevel(player, upgrade) ((player)->upgrades[(upgrade)/2].level++) #define hasAnyUpgrade(player, upgrade) \ ((player)->upgrades[(upgrade)/2].allowed > 0 && \ (player)->upgrades[(upgrade)/2].level > 0) #define hasRemainingUpgrade(player, upgrade) \ ((player)->upgrades[(upgrade)/2].level < (player)->upgrades[(upgrade)/2].allowed) #define getUpgradeLevel(player, upgrade) \ ((player)->upgrades[(upgrade)/2].level) #define checkUpgradeLevel(player, upgrade) \ ((player)->upgrades[(upgrade)/2].level <= (player)->upgrades[(upgrade)/2].allowed) #define setUpgradeAllowed(player, upgrade, value) \ ((player)->upgrades[(upgrade)/2].allowed = (value)) #define imageResourceRefFromPlayer(player, hIdx, oIdx) imageResourceRef((player)->race == WAR_RACE_HUMANS ? (hIdx) : (oIdx)) #define spriteResourceRefFromPlayer(player, hIdx, oIdx, spriteIndex) wspr_createSpriteResourceRef((player)->race == WAR_RACE_HUMANS ? (hIdx) : (oIdx), 1, arrayArg(s32, (spriteIndex))) struct _WarMapSettings { WarMapSpeed gameSpeed; s32 musicVol; s32 sfxVol; WarMapSpeed mouseScrollSpeed; WarMapSpeed keyScrollSpeed; }; struct _WarMap { bool playing; bool custom; WarLevelResult result; WarMenuState menuState; s32 levelInfoIndex; f32 objectivesTime; // scroll bool isScrolling; bool wasScrolling; WarMapSettings settings; WarMapSettings settings2; // viewport in map coordinates, // this is the portion of the map that the player see rect viewport; // panels of the ui, in screen coordinates rect leftTopPanel; rect leftBottomPanel; rect topPanel; rect bottomPanel; rect rightPanel; rect mapPanel; rect minimapPanel; rect menuPanel; rect messagePanel; rect saveLoadPanel; WarSprite sprite; WarSprite minimapSprite; WarSprite blackSprite; WarMapTilesetType tilesetType; WarMapTile tiles[MAP_TILES_WIDTH * MAP_TILES_HEIGHT]; WarEntityManager entityManager; WarEntityIdList selectedEntities; WarEntity* forest; WarEntity* wall; WarEntity* road; WarEntity* ruin; bool editingTrees; bool editingWalls; bool editingRoads; bool editingRuins; bool editingRainOfFire; bool addingUnit; WarUnitType addingUnitType; bool hurryUp; bool fowEnabled; WarPathFinder finder; WarUnitCommand command; WarFlashStatus flashStatus; WarCheatStatus cheatStatus; WarPlayerInfo players[MAX_PLAYERS_COUNT]; char hudStatusText[256]; s32 hudStatusHighlightIndex; s32 hudStatusHighlightCount; s32 hudStatusGold; s32 hudStatusWood; WarUnitCommandData commandSlots[6]; bool commandSlotActive[6]; char commandTexts[4][32]; s32 commandTextHighlightIndex[4]; s32 commandTextHighlightCount[4]; bool commandTextVisible[4]; }; WarMap* wmap_createMap(WarContext *context, s32 levelInfoIndex); void wmap_freeMap(WarContext* context, WarMap* map); void wmap_enterMap(WarContext* context); void wmap_updateMap(WarContext* context); void wmap_leaveMap(WarContext* context); void wmap_renderMap(WarContext* context); void wmap_addEntityToSelection(WarContext* context, WarEntityId id); void wmap_removeEntityFromSelection(WarContext* context, WarEntityId id); void wmap_clearSelection(WarContext* context); vec2 wmap_getDirFromArrowKeys(WarContext* context); vec2 wmap_getDirFromMousePos(WarContext* context); vec2 wmap_screenToMapCoordinatesV(WarContext* context, vec2 v); vec2 wmap_screenToMinimapCoordinatesV(WarContext* context, vec2 v); rect wmap_screenToMapCoordinatesR(WarContext* context, rect r); vec2 wmap_mapToScreenCoordinatesV(WarContext* context, vec2 v); rect wmap_mapToScreenCoordinatesR(WarContext* context, rect r); vec2 wmap_mapToTileCoordinatesV(vec2 v); vec2 wmap_tileToMapCoordinatesV(vec2 v, bool centeredInTile); vec2 wmap_minimapToViewportCoordinatesV(WarContext* context, vec2 v); WarColor wmap_getMapTileAverage(WarResource* levelVisual, WarResource* tileset, s32 x, s32 y); void wmap_updateMinimapTile(WarContext* context, WarResource* levelVisual, WarResource* tileset, s32 x, s32 y); s32 wmap_getMapTileIndex(WarContext* context, s32 x, s32 y); void wmap_setMapTileIndex(WarContext* context, s32 x, s32 y, s32 tile); WarMapTile* wmap_getMapTileState(WarMap* map, s32 x, s32 y); void wmap_setMapTileState(WarMap* map, s32 startX, s32 startY, s32 width, s32 height, WarMapTileState tileState); void wmap_setUnitMapTileState(WarContext* context, WarMap* map, WarEntity* entity, WarMapTileState tileState); bool wmap_isTileInState(WarMap* map, s32 x, s32 y, WarMapTileState state); bool wmap_isAnyTileInStates(WarMap* map, s32 startX, s32 startY, s32 width, s32 height, WarMapTileState state); bool wmap_isAnyUnitTileInStates(WarContext* context, WarMap* map, WarEntity* entity, WarMapTileState state); bool wmap_areAllTilesInState(WarMap* map, s32 startX, s32 startY, s32 width, s32 height, WarMapTileState state); bool wmap_areAllUnitTilesInState(WarContext* context, WarMap* map, WarEntity* entity, WarMapTileState state); bool wmap_isUnitPartiallyVisible(WarContext* context, WarMap* map, WarEntity* entity); bool wmap_isUnitVisible(WarContext* context, WarMap* map, WarEntity* entity); bool wmap_isUnitPartiallyFog(WarContext* context, WarMap* map, WarEntity* entity); bool wmap_isUnitFog(WarContext* context, WarMap* map, WarEntity* entity); bool wmap_isUnitPartiallyUnkown(WarContext* context, WarMap* map, WarEntity* entity); bool wmap_isUnitUnknown(WarContext* context, WarMap* map, WarEntity* entity); bool wmap_isTileUnkown(WarMap* map, s32 x, s32 y); bool wmap_isTileFog(WarMap* map, s32 x, s32 y); bool wmap_isTileVisible(WarMap* map, s32 x, s32 y); void wui_changeCursorType(WarContext* context, WarCursorType type); WarCampaignMapType wmap_getCampaignMapTypeByLevelInfoIndex(s32 levelInfoIndex); f32 wmap_getMapScaledSpeed(WarContext* context, f32 t); f32 wmap_getMapScaledTime(WarContext* context, f32 t); #define getMapScrollSpeed(speedValue) ((f32)(100 + (speedValue) * 50)) ================================================ FILE: src/war_map_menu.c ================================================ #include "war_map_menu.h" #include "SDL3/SDL.h" #include "shl/wstr.h" #include "war_campaigns.h" #include "war_game.h" #include "war_map.h" #include "war_resources.h" #include "war_ui.h" void wmm_showOrHideGameOverMenu(WarContext* context, bool status) { WarMap* map = context->map; map->menuState = status ? WAR_MENU_STATE_GAME_OVER : WAR_MENU_STATE_NONE; map->playing = !status; } void wmm_showDemoEndMenu(WarContext* context, bool status) { WarMap* map = context->map; map->menuState = status ? WAR_MENU_STATE_DEMO_END : WAR_MENU_STATE_NONE; map->playing = !status; } // menu button handlers void wmm_handleMenu(WarContext* context, WarEntity* entity) { NOT_USED(entity); WarMap* map = context->map; map->menuState = WAR_MENU_STATE_MAIN; map->playing = false; } void wmm_handleOptions(WarContext* context, WarEntity* entity) { NOT_USED(entity); WarMap* map = context->map; // copy live volume values into settings, then snapshot into settings2 map->settings.musicVol = (s32)(context->musicVolume * 100); map->settings.sfxVol = (s32)(context->soundVolume * 100); memcpy(&map->settings2, &map->settings, sizeof(WarMapSettings)); map->menuState = WAR_MENU_STATE_OPTIONS; map->playing = false; } void wmm_handleObjectives(WarContext* context, WarEntity* entity) { NOT_USED(entity); WarMap* map = context->map; map->menuState = WAR_MENU_STATE_OBJECTIVES; map->playing = false; } void wmm_handleRestart(WarContext* context, WarEntity* entity) { NOT_USED(entity); WarMap* map = context->map; map->menuState = WAR_MENU_STATE_RESTART; map->playing = false; } void wmm_handleContinue(WarContext* context, WarEntity* entity) { NOT_USED(entity); WarMap* map = context->map; map->menuState = WAR_MENU_STATE_NONE; map->playing = true; } void wmm_handleQuit(WarContext* context, WarEntity* entity) { NOT_USED(entity); WarMap* map = context->map; map->menuState = WAR_MENU_STATE_QUIT; map->playing = false; } void wmm_handleGameSpeedDec(WarContext* context, WarEntity* entity) { NOT_USED(entity); WarMap* map = context->map; if (map->settings2.gameSpeed > WAR_SPEED_SLOWEST) map->settings2.gameSpeed--; } void wmm_handleGameSpeedInc(WarContext* context, WarEntity* entity) { NOT_USED(entity); WarMap* map = context->map; if (map->settings2.gameSpeed < WAR_SPEED_FASTEST) map->settings2.gameSpeed++; } void wmm_handleMusicVolDec(WarContext* context, WarEntity* entity) { NOT_USED(entity); WarMap* map = context->map; map->settings2.musicVol = CLAMP(map->settings2.musicVol - 5, 0, 100); } void wmm_handleMusicVolInc(WarContext* context, WarEntity* entity) { NOT_USED(entity); WarMap* map = context->map; map->settings2.musicVol = CLAMP(map->settings2.musicVol + 5, 0, 100); } void wmm_handleSfxVolDec(WarContext* context, WarEntity* entity) { NOT_USED(entity); WarMap* map = context->map; map->settings2.sfxVol = CLAMP(map->settings2.sfxVol - 5, 0, 100); } void wmm_handleSfxVolInc(WarContext* context, WarEntity* entity) { NOT_USED(entity); WarMap* map = context->map; map->settings2.sfxVol = CLAMP(map->settings2.sfxVol + 5, 0, 100); } void wmm_handleMouseScrollSpeedDec(WarContext* context, WarEntity* entity) { NOT_USED(entity); WarMap* map = context->map; if (map->settings2.mouseScrollSpeed > WAR_SPEED_SLOWEST) map->settings2.mouseScrollSpeed--; } void wmm_handleMouseScrollSpeedInc(WarContext* context, WarEntity* entity) { NOT_USED(entity); WarMap* map = context->map; if (map->settings2.mouseScrollSpeed < WAR_SPEED_FASTEST) map->settings2.mouseScrollSpeed++; } void wmm_handleKeyScrollSpeedDec(WarContext* context, WarEntity* entity) { NOT_USED(entity); WarMap* map = context->map; if (map->settings2.keyScrollSpeed > WAR_SPEED_SLOWEST) map->settings2.keyScrollSpeed--; } void wmm_handleKeyScrollSpeedInc(WarContext* context, WarEntity* entity) { NOT_USED(entity); WarMap* map = context->map; if (map->settings2.keyScrollSpeed < WAR_SPEED_FASTEST) map->settings2.keyScrollSpeed++; } void wmm_handleOptionsOk(WarContext* context, WarEntity* entity) { NOT_USED(entity); WarMap* map = context->map; // persist the changes memcpy(&map->settings, &map->settings2, sizeof(WarMapSettings)); context->musicVolume = (f32)map->settings.musicVol / 100; context->soundVolume = (f32)map->settings.sfxVol / 100; map->menuState = WAR_MENU_STATE_MAIN; map->playing = false; } void wmm_handleOptionsCancel(WarContext* context, WarEntity* entity) { NOT_USED(entity); WarMap* map = context->map; map->menuState = WAR_MENU_STATE_MAIN; map->playing = false; } void wmm_handleObjectivesMenu(WarContext* context, WarEntity* entity) { NOT_USED(entity); WarMap* map = context->map; map->menuState = WAR_MENU_STATE_MAIN; map->playing = false; } void wmm_handleRestartRestart(WarContext* context, WarEntity* entity) { NOT_USED(entity); s32 levelInfoIndex = context->map->levelInfoIndex; WarMap* map = wmap_createMap(context, levelInfoIndex); wg_setNextMap(context, map, 1.0f); } void wmm_handleRestartCancel(WarContext* context, WarEntity* entity) { NOT_USED(entity); WarMap* map = context->map; map->menuState = WAR_MENU_STATE_MAIN; map->playing = false; } void wmm_handleGameOverSave(WarContext* context, WarEntity* entity) { NOT_USED(context); NOT_USED(entity); NOT_IMPLEMENTED(); } void wmm_handleGameOverContinue(WarContext* context, WarEntity* entity) { NOT_USED(entity); WarMap* map = context->map; s32 levelInfoIndex = map->levelInfoIndex; if (map->result == WAR_LEVEL_RESULT_WIN) { WarScene* scene = wsc_createScene(context, WAR_SCENE_BRIEFING); scene->briefing.race = map->players[0].race; scene->briefing.mapType = levelInfoIndex + 2; wg_setNextScene(context, scene, 1.0f); } else if (map->result == WAR_LEVEL_RESULT_LOSE) { WarScene* scene = wsc_createScene(context, WAR_SCENE_BRIEFING); scene->briefing.race = map->players[0].race; scene->briefing.mapType = levelInfoIndex; wg_setNextScene(context, scene, 1.0f); } else { logError("It shouldn't reach here! Map result: %d", map->result); assert(false); } } void wmm_handleQuitQuit(WarContext* context, WarEntity* entity) { NOT_USED(context); NOT_USED(entity); SDL_PushEvent(&(SDL_Event){ .type = SDL_EVENT_QUIT }); } void wmm_handleQuitMenu(WarContext* context, WarEntity* entity) { NOT_USED(entity); WarScene* scene = wsc_createScene(context, WAR_SCENE_MAIN_MENU); wg_setNextScene(context, scene, 1.0f); } void wmm_handleQuitCancel(WarContext* context, WarEntity* entity) { NOT_USED(entity); WarMap* map = context->map; map->menuState = WAR_MENU_STATE_MAIN; map->playing = false; } void wmm_handleDemoEndMenu(WarContext* context, WarEntity* entity) { NOT_USED(entity); WarScene* scene = wsc_createScene(context, WAR_SCENE_MAIN_MENU); wg_setNextScene(context, scene, 1.0f); } ================================================ FILE: src/war_map_menu.h ================================================ #pragma once #include "war.h" void wmm_showOrHideGameOverMenu(WarContext* context, bool status); void wmm_showDemoEndMenu(WarContext* context, bool status); // menu button handlers void wmm_handleMenu(WarContext* context, WarEntity* entity); void wmm_handleOptions(WarContext* context, WarEntity* entity); void wmm_handleObjectives(WarContext* context, WarEntity* entity); void wmm_handleRestart(WarContext* context, WarEntity* entity); void wmm_handleContinue(WarContext* context, WarEntity* entity); void wmm_handleQuit(WarContext* context, WarEntity* entity); void wmm_handleGameSpeedDec(WarContext* context, WarEntity* entity); void wmm_handleGameSpeedInc(WarContext* context, WarEntity* entity); void wmm_handleMusicVolDec(WarContext* context, WarEntity* entity); void wmm_handleMusicVolInc(WarContext* context, WarEntity* entity); void wmm_handleSfxVolDec(WarContext* context, WarEntity* entity); void wmm_handleSfxVolInc(WarContext* context, WarEntity* entity); void wmm_handleMouseScrollSpeedDec(WarContext* context, WarEntity* entity); void wmm_handleMouseScrollSpeedInc(WarContext* context, WarEntity* entity); void wmm_handleKeyScrollSpeedDec(WarContext* context, WarEntity* entity); void wmm_handleKeyScrollSpeedInc(WarContext* context, WarEntity* entity); void wmm_handleOptionsOk(WarContext* context, WarEntity* entity); void wmm_handleOptionsCancel(WarContext* context, WarEntity* entity); void wmm_handleObjectivesMenu(WarContext* context, WarEntity* entity); void wmm_handleRestartRestart(WarContext* context, WarEntity* entity); void wmm_handleRestartCancel(WarContext* context, WarEntity* entity); void wmm_handleGameOverSave(WarContext* context, WarEntity* entity); void wmm_handleGameOverContinue(WarContext* context, WarEntity* entity); void wmm_handleQuitQuit(WarContext* context, WarEntity* entity); void wmm_handleQuitMenu(WarContext* context, WarEntity* entity); void wmm_handleQuitCancel(WarContext* context, WarEntity* entity); void wmm_handleDemoEndMenu(WarContext* context, WarEntity* entity); ================================================ FILE: src/war_map_ui.c ================================================ #include "war_map_ui.h" #include #include #include #include "shl/wstr.h" #include "war_campaigns.h" #include "war_entities.h" #include "war_imui.h" #include "war_map.h" #include "war_map_menu.h" #include "war_ui.h" #include "war_units.h" void wmui_createMapUI(WarContext* context) { WarMap* map = context->map; vec2 minimapPanel = RECT_TOP_LEFT(map->minimapPanel); WarCheatStatus* cheatStatus = &map->cheatStatus; cheatStatus->enabled = true; cheatStatus->visible = false; cheatStatus->position = 0; wstr_clear(&cheatStatus->text); wmui_createUIMinimap(context, wstr_fromCString("minimap"), minimapPanel); } WarEntity* wmui_createUIMinimap(WarContext* context, String name, vec2 position) { WarEntity* entity = we_createEntity(context, WAR_ENTITY_TYPE_MINIMAP, true); we_addTransformComponent(context, entity, WAR_TRANSFORM_COMPONENT_INIT( .position = position, )); we_addUIComponent(context, entity, name); return entity; } void wmui_setFlashStatus(WarContext* context, f32 duration, String text) { WarMap* map = context->map; WarFlashStatus* flashStatus = &map->flashStatus; assert(duration >= 0); assert(text.data); flashStatus->enabled = true; flashStatus->startTime = context->time; flashStatus->duration = duration; wstr_free(flashStatus->text); flashStatus->text = text; } static const char* getSpeedStr(WarMapSpeed value) { switch (value) { case WAR_SPEED_SLOWEST: return "Slowest"; case WAR_SPEED_SLOW: return "Slow"; case WAR_SPEED_NORMAL: return "Normal"; case WAR_SPEED_FASTER: return "Faster"; case WAR_SPEED_FASTEST: return "Fastest"; default: return ""; } } static void renderMenus(WarContext* context) { TracyCZoneN(ctx, "RenderMenus", 1); WarMap* map = context->map; if (map->menuState == WAR_MENU_STATE_NONE) { TracyCZoneEnd(ctx); return; } WarPlayerInfo* player = &map->players[0]; WarSpriteResourceRef mediumNormalRef = imageResourceRef(239); WarSpriteResourceRef mediumPressedRef = imageResourceRef(240); WarSpriteResourceRef smallNormalRef = imageResourceRef(241); WarSpriteResourceRef smallPressedRef = imageResourceRef(242); WarSpriteResourceRef leftArrowNormal = imageResourceRef(244); WarSpriteResourceRef leftArrowPressed = imageResourceRef(245); WarSpriteResourceRef rightArrowNormal = imageResourceRef(246); WarSpriteResourceRef rightArrowPressed = imageResourceRef(247); vec2 mp = RECT_TOP_LEFT(map->menuPanel); vec2 msgp = RECT_TOP_LEFT(map->messagePanel); char buf[256]; // Semi-transparent backdrop over the whole window imui_rect(context, "menuBackdrop", CREATE_UI_RECT_ARGS_INIT( .position = VEC2_ZERO, .size = vec2i(context->windowWidth, context->windowHeight), .color = WAR_COLOR_RGBA(0, 0, 0, 150), )); switch (map->menuState) { case WAR_MENU_STATE_MAIN: { imui_image(context, "imgMenuBackground", CREATE_UI_IMAGE_ARGS_INIT( .spriteRef = imageResourceRefFromPlayer(player, 233, 234), .position = mp, )); imui_text(context, "txtMenuHeader", CREATE_UI_TEXT_ARGS_INIT( .position = vec2_addv(mp, vec2i(0, 10)), .fontIndex = 1, .boundings = vec2f(map->menuPanel.width, 12), .horizontalAlign = WAR_TEXT_ALIGN_CENTER, .verticalAlign = WAR_TEXT_ALIGN_MIDDLE, .text = wsv_fromCString("Warcraft") )); // Save / Load not yet implemented — no handler imui_text_button(context, "btnMenuSave", CREATE_UI_TEXT_BUTTON_ARGS_INIT( .fontIndex = 1, .text = wsv_fromCString("Save"), .backgroundNormalRef = smallNormalRef, .backgroundPressedRef = smallPressedRef, .position = vec2_addv(mp, vec2i(20, 25)), .hotKey = WAR_KEY_S, .highlightIndex = 0, .highlightCount = 1, )); imui_text_button(context, "btnMenuLoad", CREATE_UI_TEXT_BUTTON_ARGS_INIT( .fontIndex = 1, .text = wsv_fromCString("Load"), .backgroundNormalRef = smallNormalRef, .backgroundPressedRef = smallPressedRef, .position = vec2_addv(mp, vec2i(78, 25)), .hotKey = WAR_KEY_L, .highlightIndex = 0, .highlightCount = 1, )); if (imui_text_button(context, "btnMenuOptions", CREATE_UI_TEXT_BUTTON_ARGS_INIT( .fontIndex = 1, .text = wsv_fromCString("Options"), .backgroundNormalRef = mediumNormalRef, .backgroundPressedRef = mediumPressedRef, .position = vec2_addv(mp, vec2i(20, 45)), .hotKey = WAR_KEY_O, .highlightIndex = 0, .highlightCount = 1, ))) wmm_handleOptions(context, NULL); if (imui_text_button(context, "btnMenuObjectives", CREATE_UI_TEXT_BUTTON_ARGS_INIT( .fontIndex = 1, .text = wsv_fromCString("Objectives"), .backgroundNormalRef = mediumNormalRef, .backgroundPressedRef = mediumPressedRef, .position = vec2_addv(mp, vec2i(20, 65)), .hotKey = WAR_KEY_J, .highlightIndex = 0, .highlightCount = 1, ))) wmm_handleObjectives(context, NULL); if (imui_text_button(context, "btnMenuRestart", CREATE_UI_TEXT_BUTTON_ARGS_INIT( .fontIndex = 1, .text = wsv_fromCString("Restart scenario"), .backgroundNormalRef = mediumNormalRef, .backgroundPressedRef = mediumPressedRef, .position = vec2_addv(mp, vec2i(20, 85)), .hotKey = WAR_KEY_R, .highlightIndex = 0, .highlightCount = 1, ))) wmm_handleRestart(context, NULL); if (imui_text_button(context, "btnMenuContinue", CREATE_UI_TEXT_BUTTON_ARGS_INIT( .fontIndex = 1, .text = wsv_fromCString("Continue"), .backgroundNormalRef = smallNormalRef, .backgroundPressedRef = smallPressedRef, .position = vec2_addv(mp, vec2i(20, 105)), .hotKey = WAR_KEY_C, .highlightIndex = 0, .highlightCount = 1, ))) wmm_handleContinue(context, NULL); if (imui_text_button(context, "btnMenuQuit", CREATE_UI_TEXT_BUTTON_ARGS_INIT( .fontIndex = 1, .text = wsv_fromCString("Quit"), .backgroundNormalRef = smallNormalRef, .backgroundPressedRef = smallPressedRef, .position = vec2_addv(mp, vec2i(78, 105)), .hotKey = WAR_KEY_Q, .highlightIndex = 0, .highlightCount = 1, ))) wmm_handleQuit(context, NULL); break; } case WAR_MENU_STATE_OPTIONS: { imui_image(context, "imgMenuBackground", CREATE_UI_IMAGE_ARGS_INIT( .spriteRef = imageResourceRefFromPlayer(player, 233, 234), .position = mp, )); imui_text(context, "txtOptionsHeader", CREATE_UI_TEXT_ARGS_INIT( .position = vec2_addv(mp, vec2i(0, 10)), .fontIndex = 1, .boundings = vec2f(map->menuPanel.width, 12), .horizontalAlign = WAR_TEXT_ALIGN_CENTER, .verticalAlign = WAR_TEXT_ALIGN_MIDDLE, .text = wsv_fromCString("Options") )); // Labels (right-aligned in 75px) static const char* labelNames[5] = { "Game Speed", "Music Vol", "SFX Vol", "Mouse Scroll", "Key Scroll" }; static const s32 labelOffY[5] = { 25, 42, 59, 76, 93 }; for (s32 i = 0; i < 5; i++) { snprintf(buf, sizeof(buf), "txtOptionsLabel%d", i); imui_text(context, buf, CREATE_UI_TEXT_ARGS_INIT( .position = vec2_addv(mp, vec2i(0, labelOffY[i])), .fontIndex = 1, .boundings = vec2f(75, 12), .horizontalAlign = WAR_TEXT_ALIGN_RIGHT, .verticalAlign = WAR_TEXT_ALIGN_MIDDLE, .text = wsv_fromCString(labelNames[i]) )); } // Value texts (centred in 42px) snprintf(buf, sizeof(buf), "%s", getSpeedStr(map->settings2.gameSpeed)); imui_text(context, "txtOptionsGameSpeedValue", CREATE_UI_TEXT_ARGS_INIT( .position = vec2_addv(mp, vec2i(92, 25)), .fontIndex = 1, .boundings = vec2f(42, 12), .horizontalAlign = WAR_TEXT_ALIGN_CENTER, .verticalAlign = WAR_TEXT_ALIGN_MIDDLE, .text = wsv_fromCString(buf) )); snprintf(buf, sizeof(buf), "%d", map->settings2.musicVol); imui_text(context, "txtOptionsMusicVolValue", CREATE_UI_TEXT_ARGS_INIT( .position = vec2_addv(mp, vec2i(92, 42)), .fontIndex = 1, .boundings = vec2f(42, 12), .horizontalAlign = WAR_TEXT_ALIGN_CENTER, .verticalAlign = WAR_TEXT_ALIGN_MIDDLE, .text = wsv_fromCString(buf) )); snprintf(buf, sizeof(buf), "%d", map->settings2.sfxVol); imui_text(context, "txtOptionsSFXVolValue", CREATE_UI_TEXT_ARGS_INIT( .position = vec2_addv(mp, vec2i(92, 59)), .fontIndex = 1, .boundings = vec2f(42, 12), .horizontalAlign = WAR_TEXT_ALIGN_CENTER, .verticalAlign = WAR_TEXT_ALIGN_MIDDLE, .text = wsv_fromCString(buf) )); snprintf(buf, sizeof(buf), "%s", getSpeedStr(map->settings2.mouseScrollSpeed)); imui_text(context, "txtOptionsMouseScrollValue", CREATE_UI_TEXT_ARGS_INIT( .position = vec2_addv(mp, vec2i(92, 76)), .fontIndex = 1, .boundings = vec2f(42, 12), .horizontalAlign = WAR_TEXT_ALIGN_CENTER, .verticalAlign = WAR_TEXT_ALIGN_MIDDLE, .text = wsv_fromCString(buf) )); snprintf(buf, sizeof(buf), "%s", getSpeedStr(map->settings2.keyScrollSpeed)); imui_text(context, "txtOptionsKeyScrollValue", CREATE_UI_TEXT_ARGS_INIT( .position = vec2_addv(mp, vec2i(92, 93)), .fontIndex = 1, .boundings = vec2f(42, 12), .horizontalAlign = WAR_TEXT_ALIGN_CENTER, .verticalAlign = WAR_TEXT_ALIGN_MIDDLE, .text = wsv_fromCString(buf) )); // Arrow buttons — (dec at x+76, inc at x+133), y offsets: 22,39,56,73,90 if (imui_image_button(context, "btnOptionsGameSpeedDec", CREATE_UI_IMAGE_BUTTON_ARGS_INIT( .backgroundNormalRef = leftArrowNormal, .backgroundPressedRef = leftArrowPressed, .position = vec2_addv(mp, vec2i(76, 22)), ))) wmm_handleGameSpeedDec(context, NULL); if (imui_image_button(context, "btnOptionsGameSpeedInc", CREATE_UI_IMAGE_BUTTON_ARGS_INIT( .backgroundNormalRef = rightArrowNormal, .backgroundPressedRef = rightArrowPressed, .position = vec2_addv(mp, vec2i(133, 22)), ))) wmm_handleGameSpeedInc(context, NULL); if (imui_image_button(context, "btnOptionsMusicVolDec", CREATE_UI_IMAGE_BUTTON_ARGS_INIT( .backgroundNormalRef = leftArrowNormal, .backgroundPressedRef = leftArrowPressed, .position = vec2_addv(mp, vec2i(76, 39)), ))) wmm_handleMusicVolDec(context, NULL); if (imui_image_button(context, "btnOptionsMusicVolInc", CREATE_UI_IMAGE_BUTTON_ARGS_INIT( .backgroundNormalRef = rightArrowNormal, .backgroundPressedRef = rightArrowPressed, .position = vec2_addv(mp, vec2i(133, 39)), ))) wmm_handleMusicVolInc(context, NULL); if (imui_image_button(context, "btnOptionsSFXVolDec", CREATE_UI_IMAGE_BUTTON_ARGS_INIT( .backgroundNormalRef = leftArrowNormal, .backgroundPressedRef = leftArrowPressed, .position = vec2_addv(mp, vec2i(76, 56)), ))) wmm_handleSfxVolDec(context, NULL); if (imui_image_button(context, "btnOptionsSFXVolInc", CREATE_UI_IMAGE_BUTTON_ARGS_INIT( .backgroundNormalRef = rightArrowNormal, .backgroundPressedRef = rightArrowPressed, .position = vec2_addv(mp, vec2i(133, 56)), ))) wmm_handleSfxVolInc(context, NULL); if (imui_image_button(context, "btnOptionsMouseScrollDec", CREATE_UI_IMAGE_BUTTON_ARGS_INIT( .backgroundNormalRef = leftArrowNormal, .backgroundPressedRef = leftArrowPressed, .position = vec2_addv(mp, vec2i(76, 73)), ))) wmm_handleMouseScrollSpeedDec(context, NULL); if (imui_image_button(context, "btnOptionsMouseScrollInc", CREATE_UI_IMAGE_BUTTON_ARGS_INIT( .backgroundNormalRef = rightArrowNormal, .backgroundPressedRef = rightArrowPressed, .position = vec2_addv(mp, vec2i(133, 73)), ))) wmm_handleMouseScrollSpeedInc(context, NULL); if (imui_image_button(context, "btnOptionsKeyScrollDec", CREATE_UI_IMAGE_BUTTON_ARGS_INIT( .backgroundNormalRef = leftArrowNormal, .backgroundPressedRef = leftArrowPressed, .position = vec2_addv(mp, vec2i(76, 90)), ))) wmm_handleKeyScrollSpeedDec(context, NULL); if (imui_image_button(context, "btnOptionsKeyScrollInc", CREATE_UI_IMAGE_BUTTON_ARGS_INIT( .backgroundNormalRef = rightArrowNormal, .backgroundPressedRef = rightArrowPressed, .position = vec2_addv(mp, vec2i(133, 90)), ))) wmm_handleKeyScrollSpeedInc(context, NULL); if (imui_text_button(context, "btnOptionsOk", CREATE_UI_TEXT_BUTTON_ARGS_INIT( .fontIndex = 1, .text = wsv_fromCString("Ok"), .backgroundNormalRef = smallNormalRef, .backgroundPressedRef = smallPressedRef, .position = vec2_addv(mp, vec2i(20, 115)), .hotKey = WAR_KEY_O, .highlightIndex = 0, .highlightCount = 1, ))) wmm_handleOptionsOk(context, NULL); if (imui_text_button(context, "btnOptionsCancel", CREATE_UI_TEXT_BUTTON_ARGS_INIT( .fontIndex = 1, .text = wsv_fromCString("Cancel"), .backgroundNormalRef = smallNormalRef, .backgroundPressedRef = smallPressedRef, .position = vec2_addv(mp, vec2i(78, 115)), .hotKey = WAR_KEY_C, .highlightIndex = 0, .highlightCount = 1, ))) wmm_handleOptionsCancel(context, NULL); break; } case WAR_MENU_STATE_OBJECTIVES: { WarCampaignMapData campaignData = wcamp_getCampaignData( wmap_getCampaignMapTypeByLevelInfoIndex(map->levelInfoIndex) ); imui_image(context, "imgMenuBackground", CREATE_UI_IMAGE_ARGS_INIT( .spriteRef = imageResourceRefFromPlayer(player, 233, 234), .position = mp, )); imui_text(context, "txtObjectivesHeader", CREATE_UI_TEXT_ARGS_INIT( .position = vec2_addv(mp, vec2i(0, 10)), .fontIndex = 1, .boundings = vec2f(map->menuPanel.width, 12), .horizontalAlign = WAR_TEXT_ALIGN_CENTER, .verticalAlign = WAR_TEXT_ALIGN_MIDDLE, .text = wsv_fromCString("Objectives") )); imui_text(context, "txtObjectivesText", CREATE_UI_TEXT_ARGS_INIT( .position = vec2_addv(mp, vec2i(10, 26)), .fontIndex = 1, .multiline = true, .boundings = vec2f(map->menuPanel.width - 20, 75), .wrapping = WAR_TEXT_WRAP_CHAR, .trimming = WAR_TEXT_TRIM_SPACES, .text = campaignData.objectives )); if (imui_text_button(context, "btnObjectivesMenu", CREATE_UI_TEXT_BUTTON_ARGS_INIT( .fontIndex = 1, .text = wsv_fromCString("Menu"), .backgroundNormalRef = mediumNormalRef, .backgroundPressedRef = mediumPressedRef, .position = vec2_addv(mp, vec2i(20, 105)), .hotKey = WAR_KEY_M, .highlightIndex = 0, .highlightCount = 1, ))) wmm_handleObjectivesMenu(context, NULL); break; } case WAR_MENU_STATE_RESTART: { imui_image(context, "imgMessageMenuBackground", CREATE_UI_IMAGE_ARGS_INIT( .spriteRef = imageResourceRefFromPlayer(player, 235, 236), .position = msgp, )); imui_text(context, "txtRestartText", CREATE_UI_TEXT_ARGS_INIT( .position = vec2_addv(msgp, vec2i(0, 10)), .fontIndex = 1, .boundings = vec2f(map->messagePanel.width, 12), .horizontalAlign = WAR_TEXT_ALIGN_CENTER, .verticalAlign = WAR_TEXT_ALIGN_MIDDLE, .text = wsv_fromCString("Are you sure you want to restart?") )); if (imui_text_button(context, "btnRestartRestart", CREATE_UI_TEXT_BUTTON_ARGS_INIT( .fontIndex = 1, .text = wsv_fromCString("Restart"), .backgroundNormalRef = smallNormalRef, .backgroundPressedRef = smallPressedRef, .position = vec2_addv(msgp, vec2i(20, 25)), .hotKey = WAR_KEY_R, .highlightIndex = 0, .highlightCount = 1, ))) wmm_handleRestartRestart(context, NULL); if (imui_text_button(context, "btnRestartCancel", CREATE_UI_TEXT_BUTTON_ARGS_INIT( .fontIndex = 1, .text = wsv_fromCString("Cancel"), .backgroundNormalRef = smallNormalRef, .backgroundPressedRef = smallPressedRef, .position = vec2_addv(msgp, vec2i(210, 25)), .hotKey = WAR_KEY_C, .highlightIndex = 0, .highlightCount = 1, ))) wmm_handleRestartCancel(context, NULL); break; } case WAR_MENU_STATE_GAME_OVER: { imui_image(context, "imgMessageMenuBackground", CREATE_UI_IMAGE_ARGS_INIT( .spriteRef = imageResourceRefFromPlayer(player, 235, 236), .position = msgp, )); const char* gameOverText = (map->result == WAR_LEVEL_RESULT_WIN) ? "You are victorious!" : "You failed to archieve victory..."; imui_text(context, "txtGameOverText", CREATE_UI_TEXT_ARGS_INIT( .position = vec2_addv(msgp, vec2i(0, 10)), .fontIndex = 1, .boundings = vec2f(map->messagePanel.width, 12), .horizontalAlign = WAR_TEXT_ALIGN_CENTER, .verticalAlign = WAR_TEXT_ALIGN_MIDDLE, .text = wsv_fromCString(gameOverText) )); if (map->result == WAR_LEVEL_RESULT_WIN) { if (imui_text_button(context, "btnGameOverSave", CREATE_UI_TEXT_BUTTON_ARGS_INIT( .fontIndex = 1, .text = wsv_fromCString("Save"), .backgroundNormalRef = smallNormalRef, .backgroundPressedRef = smallPressedRef, .position = vec2_addv(msgp, vec2i(20, 25)), .hotKey = WAR_KEY_S, .highlightIndex = 0, .highlightCount = 1, ))) wmm_handleGameOverSave(context, NULL); if (imui_text_button(context, "btnGameOverContinue", CREATE_UI_TEXT_BUTTON_ARGS_INIT( .fontIndex = 1, .text = wsv_fromCString("Continue"), .backgroundNormalRef = smallNormalRef, .backgroundPressedRef = smallPressedRef, .position = vec2_addv(msgp, vec2i(210, 25)), .hotKey = WAR_KEY_C, .highlightIndex = 0, .highlightCount = 1, ))) wmm_handleGameOverContinue(context, NULL); } else { if (imui_text_button(context, "btnGameOverOk", CREATE_UI_TEXT_BUTTON_ARGS_INIT( .fontIndex = 1, .text = wsv_fromCString("Ok"), .backgroundNormalRef = smallNormalRef, .backgroundPressedRef = smallPressedRef, .position = vec2_addv(msgp, vec2i(116, 25)), .hotKey = WAR_KEY_O, .highlightIndex = 0, .highlightCount = 1, ))) wmm_handleGameOverContinue(context, NULL); } break; } case WAR_MENU_STATE_QUIT: { imui_image(context, "imgMessageMenuBackground", CREATE_UI_IMAGE_ARGS_INIT( .spriteRef = imageResourceRefFromPlayer(player, 235, 236), .position = msgp, )); imui_text(context, "txtQuitText", CREATE_UI_TEXT_ARGS_INIT( .position = vec2_addv(msgp, vec2i(0, 10)), .fontIndex = 1, .boundings = vec2f(map->messagePanel.width, 12), .horizontalAlign = WAR_TEXT_ALIGN_CENTER, .verticalAlign = WAR_TEXT_ALIGN_MIDDLE, .text = wsv_fromCString("Are you sure you want to quit?") )); if (imui_text_button(context, "btnQuitQuit", CREATE_UI_TEXT_BUTTON_ARGS_INIT( .fontIndex = 1, .text = wsv_fromCString("Quit"), .backgroundNormalRef = smallNormalRef, .backgroundPressedRef = smallPressedRef, .position = vec2_addv(msgp, vec2i(20, 25)), .hotKey = WAR_KEY_Q, .highlightIndex = 0, .highlightCount = 1, ))) wmm_handleQuitQuit(context, NULL); if (imui_text_button(context, "btnQuitMenu", CREATE_UI_TEXT_BUTTON_ARGS_INIT( .fontIndex = 1, .text = wsv_fromCString("Menu"), .backgroundNormalRef = smallNormalRef, .backgroundPressedRef = smallPressedRef, .position = vec2_addv(msgp, vec2i(115, 25)), .hotKey = WAR_KEY_M, .highlightIndex = 0, .highlightCount = 1, ))) wmm_handleQuitMenu(context, NULL); if (imui_text_button(context, "btnQuitCancel", CREATE_UI_TEXT_BUTTON_ARGS_INIT( .fontIndex = 1, .text = wsv_fromCString("Cancel"), .backgroundNormalRef = smallNormalRef, .backgroundPressedRef = smallPressedRef, .position = vec2_addv(msgp, vec2i(210, 25)), .hotKey = WAR_KEY_C, .highlightIndex = 0, .highlightCount = 1, ))) wmm_handleQuitCancel(context, NULL); break; } case WAR_MENU_STATE_DEMO_END: { imui_image(context, "imgMenuBackground", CREATE_UI_IMAGE_ARGS_INIT( .spriteRef = imageResourceRefFromPlayer(player, 233, 234), .position = mp, )); imui_text(context, "txtDemoEndHeader", CREATE_UI_TEXT_ARGS_INIT( .position = vec2_addv(mp, vec2i(0, 10)), .fontIndex = 1, .boundings = vec2f(map->menuPanel.width, 12), .horizontalAlign = WAR_TEXT_ALIGN_CENTER, .verticalAlign = WAR_TEXT_ALIGN_MIDDLE, .text = wsv_fromCString("Thanks for playing!") )); imui_text(context, "txtDemoEndText", CREATE_UI_TEXT_ARGS_INIT( .position = vec2_addv(mp, vec2i(8, 26)), .fontIndex = 1, .fontSize = 7, .multiline = true, .boundings = vec2f(map->menuPanel.width - 16, 75), .wrapping = WAR_TEXT_WRAP_CHAR, .text = wsv_fromCString( "This is a non-profit project with\n" "the personal goal of learning to\n" "do RTS engines\n" "\n" "This is not an official Blizzard\n" "product. Warcraft and all assets\n" "you see are registered trademarks\n" "of Blizzard Entertainment.\n" "\n" "Made by @acoro87") )); if (imui_text_button(context, "btnDemoEndMenu", CREATE_UI_TEXT_BUTTON_ARGS_INIT( .fontIndex = 1, .text = wsv_fromCString("Menu"), .backgroundNormalRef = mediumNormalRef, .backgroundPressedRef = mediumPressedRef, .position = vec2_addv(mp, vec2i(20, 105)), .hotKey = WAR_KEY_M, .highlightIndex = 0, .highlightCount = 1, ))) wmm_handleDemoEndMenu(context, NULL); break; } default: break; } TracyCZoneEnd(ctx); } static void renderHUD(WarContext* context) { TracyCZoneN(ctx, "RenderHUD", 1); WarMap* map = context->map; WarImuiState* imui = &context->imui; WarPlayerInfo* player = &map->players[0]; WarCheatStatus* cheatStatus = &map->cheatStatus; // Suppress imui button hotkeys while the cheat panel is open so that // key presses intended as cheat input don't trigger command shortcuts. if (cheatStatus->enabled && cheatStatus->visible) { context->imui.hotkeys_enabled = false; } vec2 topPanel = RECT_TOP_LEFT(map->topPanel); vec2 bottomPanel = RECT_TOP_LEFT(map->bottomPanel); vec2 leftBottomPanel = RECT_TOP_LEFT(map->leftBottomPanel); char buf[32]; // --- Gold counter (top panel) --- snprintf(buf, sizeof(buf), "GOLD:%6d", player->gold); imui_text(context, "txtGold", CREATE_UI_TEXT_ARGS_INIT( .position = vec2_addv(topPanel, vec2i(135, 2)), .fontSize = 6, .text = wsv_fromCString(buf) )); // --- Wood counter (top panel) --- snprintf(buf, sizeof(buf), "LUMBER:%6d", player->wood); imui_text(context, "txtWood", CREATE_UI_TEXT_ARGS_INIT( .position = vec2_addv(topPanel, vec2i(24, 2)), .fontSize = 6, .text = wsv_fromCString(buf) )); // --- Selection info panel (left bottom panel) --- // // Life bar thresholds and widths match the original retained-mode values. // Frame indices for resource 360/359: // 0 = single unit non-magic dude / complete building // 1 = single unit magic dude (shows mana bar) // 2 = single unit building under construction (shows build-percent bar) // 3-5 = multi-select background (selectedEntitiesCount+1, for selectedEntitiesCount 2-4) // 6-8 = multi-select life-bar section (selectedEntitiesCount+4, for selectedEntitiesCount 2-4) { const f32 hpRedThresh = 0.35f; const f32 hpYellowThresh = 0.70f; const s32 hpBarWidthPx = 27; const s32 mpBarWidthPx = 27; const s32 pctBarWidthPx = 64; s32 selectedEntitiesCount = MIN(map->selectedEntities.count, 4); if (selectedEntitiesCount == 1) { WarEntityId selectedEntityId = map->selectedEntities.items[0]; WarEntity* selectedEntity = we_findEntity(context, selectedEntityId); if (selectedEntity && wu_isUnit(selectedEntity)) { WarUnitComponent* unit = we_getUnitComponent(context, selectedEntity); assert(unit); // Background panel frame s32 infoFrame = 0; if (wu_isDudeUnit(context, selectedEntity) && wu_isMagicUnit(context, selectedEntity)) { infoFrame = 1; } else if (wu_isBuildingUnit(context, selectedEntity) && unit->building) { infoFrame = 2; } imui_image_frame(context, "imgUnitInfo", CREATE_UI_IMAGE_ARGS_INIT( .spriteRef = imageResourceRefFromPlayer(player, 360, 359), .position = vec2_addv(leftBottomPanel, vec2i(2, 0)), ), infoFrame); // Portrait const WarUnitData* unitData = wu_getUnitData(unit->type); imui_image_frame(context, "imgUnitPortrait0", CREATE_UI_IMAGE_ARGS_INIT( .spriteRef = imageResourceRef(361), .position = vec2_addv(leftBottomPanel, vec2i(6, 4)), ), unitData->portraitFrameIndex); // Unit name imui_text(context, "txtUnitName", CREATE_UI_TEXT_ARGS_INIT( .position = vec2_addv(leftBottomPanel, vec2i(6, 26)), .fontSize = 6, .highlightIndex = NO_HIGHLIGHT, .text = unitData->name )); // Life bar { f32 hpPct = PERCENTF01(unit->hp, unit->maxhp); WarColor barColor = WAR_COLOR_GREEN; if (hpPct <= hpRedThresh) barColor = WAR_COLOR_RED; else if (hpPct <= hpYellowThresh) barColor = WAR_COLOR_YELLOW; imui_rect(context, "rectLifeBar0", CREATE_UI_RECT_ARGS_INIT( .position = vec2_addv(leftBottomPanel, vec2i(37, 20)), .size = vec2i((s32)(hpPct * hpBarWidthPx), 3), .color = barColor, )); } // Mana bar (magic dudes only) if (wu_isDudeUnit(context, selectedEntity) && wu_isMagicUnit(context, selectedEntity)) { f32 mpPct = PERCENTF01(unit->mana, unit->maxMana); imui_rect(context, "rectMagicBar", CREATE_UI_RECT_ARGS_INIT( .position = vec2_addv(leftBottomPanel, vec2i(37, 9)), .size = vec2i((s32)(mpPct * mpBarWidthPx), 3), .color = WAR_COLOR_GREEN, )); } // Build-percent bar (buildings under construction only) if (wu_isBuildingUnit(context, selectedEntity) && unit->building) { f32 pct = unit->buildPercent; imui_rect(context, "rectPercentBar", CREATE_UI_RECT_ARGS_INIT( .position = vec2_addv(leftBottomPanel, vec2i(4, 37)), .size = vec2i((s32)(pct * pctBarWidthPx), 5), .color = WAR_COLOR_GREEN, )); imui_image_frame(context, "rectPercentText", CREATE_UI_IMAGE_ARGS_INIT( .spriteRef = imageResourceRef(410), .position = vec2_addv(leftBottomPanel, vec2i(15, 37)), ), 0); } } } else if (selectedEntitiesCount > 1) { // Portrait and life-bar slot positions for multi-select (indices 1-4) const s32 portraitOffX[5] = { 0, 4, 38, 4, 38 }; const s32 portraitOffY[5] = { 0, 1, 1, 23, 23 }; const s32 lifeBarOffX[5] = { 0, 4, 38, 4, 38 }; const s32 lifeBarOffY[5] = { 0, 17, 17, 39, 39 }; // Background panels (frame 3/4/5 for 2/3/4 units) imui_image_frame(context, "imgUnitInfo", CREATE_UI_IMAGE_ARGS_INIT( .spriteRef = imageResourceRefFromPlayer(player, 360, 359), .position = vec2_addv(leftBottomPanel, vec2i(2, 0)), ), selectedEntitiesCount + 1); imui_image_frame(context, "imgUnitInfoLife", CREATE_UI_IMAGE_ARGS_INIT( .spriteRef = imageResourceRefFromPlayer(player, 360, 359), .position = vec2_addv(leftBottomPanel, vec2i(3, 16)), ), selectedEntitiesCount + 4); for (s32 i = 1; i <= selectedEntitiesCount; i++) { WarEntityId selectedEntityId = map->selectedEntities.items[i - 1]; WarEntity* selectedEntity = we_findEntity(context, selectedEntityId); if (selectedEntity && wu_isUnit(selectedEntity)) { WarUnitComponent* unit = we_getUnitComponent(context, selectedEntity); assert(unit); const WarUnitData* unitData = wu_getUnitData(unit->type); // Portrait char portraitId[32]; snprintf(portraitId, sizeof(portraitId), "imgUnitPortrait%d", i); imui_image_frame(context, portraitId, CREATE_UI_IMAGE_ARGS_INIT( .spriteRef = imageResourceRef(361), .position = vec2_addv(leftBottomPanel, vec2i(portraitOffX[i], portraitOffY[i])), ), unitData->portraitFrameIndex); // Life bar f32 hpPct = PERCENTF01(unit->hp, unit->maxhp); WarColor barColor = WAR_COLOR_GREEN; if (hpPct <= hpRedThresh) barColor = WAR_COLOR_RED; else if (hpPct <= hpYellowThresh) barColor = WAR_COLOR_YELLOW; char lifeBarId[32]; snprintf(lifeBarId, sizeof(lifeBarId), "rectLifeBar%d", i); imui_rect(context, lifeBarId, CREATE_UI_RECT_ARGS_INIT( .position = vec2_addv(leftBottomPanel, vec2i(lifeBarOffX[i], lifeBarOffY[i])), .size = vec2i((s32)(hpPct * hpBarWidthPx), 3), .color = barColor, )); } } } } // --- Command panel (only when no menu is open) --- if (map->menuState == WAR_MENU_STATE_NONE) { WarSpriteResourceRef normalRef = imageResourceRef(364); WarSpriteResourceRef pressedRef = imageResourceRef(365); WarSpriteResourceRef portraitsRef = imageResourceRef(361); static const s32 cmdOffX[6] = { 2, 36, 2, 36, 2, 36 }; static const s32 cmdOffY[6] = { 44, 44, 67, 67, 90, 90 }; for (s32 i = 0; i < 6; i++) { if (!map->commandSlotActive[i]) continue; char btnId[16]; snprintf(btnId, sizeof(btnId), "btnCommand%d", i); if (imui_image_button(context, btnId, CREATE_UI_IMAGE_BUTTON_ARGS_INIT( .backgroundNormalRef = normalRef, .backgroundPressedRef = pressedRef, .foregroundRef = portraitsRef, .foregroundFrameIndex = map->commandSlots[i].frameIndex, .position = vec2_addv(leftBottomPanel, vec2i(cmdOffX[i], cmdOffY[i])), .hotKey = map->commandSlots[i].hotKey, .tooltip = map->commandSlots[i].tooltip, .tooltipHighlightIndex = map->commandSlots[i].highlightIndex, .tooltipHighlightCount = map->commandSlots[i].highlightCount, .gold = map->commandSlots[i].gold, .wood = map->commandSlots[i].wood, ))) { if (map->commandSlots[i].clickHandler) map->commandSlots[i].clickHandler(context, NULL); } } // Command info text rows (farm / goldmine info) static const s32 txtOffX[4] = { 3, 3, 7, 11 }; static const s32 txtOffY[4] = { 46, 56, 64, 54 }; for (s32 i = 0; i < 4; i++) { if (!map->commandTextVisible[i]) continue; char txtId[16]; snprintf(txtId, sizeof(txtId), "txtCommand%d", i); imui_text(context, txtId, CREATE_UI_TEXT_ARGS_INIT( .position = vec2_addv(leftBottomPanel, vec2i(txtOffX[i], txtOffY[i])), .fontSize = 6, .highlightIndex = map->commandTextHighlightIndex[i], .highlightCount = map->commandTextHighlightCount[i], .text = wsv_fromCString(map->commandTexts[i]) )); } // Menu button if (imui_image_button(context, "btnMenu", CREATE_UI_IMAGE_BUTTON_ARGS_INIT( .backgroundNormalRef = imageResourceRef(362), .backgroundPressedRef = imageResourceRef(363), .position = vec2_addv(leftBottomPanel, vec2i(3, 116)), .hotKey = WAR_KEY_F10, .tooltip = wsv_fromCString("MENU (F10)"), .tooltipHighlightIndex = 6, .tooltipHighlightCount = 3, ))) { wmm_handleMenu(context, NULL); } } if (!imui->show_tooltip && map->hudStatusText[0] != '\0') { imui_deferTooltip(context, wsv_fromCString(map->hudStatusText), map->hudStatusHighlightIndex, map->hudStatusHighlightCount, map->hudStatusGold, map->hudStatusWood ); } // --- Cheat input cursor (visible while cheat panel is open) --- // Drawn as a 1×7 white rect at the current text insertion position. if (cheatStatus->enabled && cheatStatus->visible && cheatStatus->cursorX >= 0.0f) { imui_rect(context, "rectStatusCursor", CREATE_UI_RECT_ARGS_INIT( .position = vec2f(bottomPanel.x + cheatStatus->cursorX, bottomPanel.y + 4.0f), .size = vec2i(1, 7), .color = WAR_COLOR_WHITE, )); } // --- Cheat feedback text (shown for a few seconds after applying a cheat) --- if (cheatStatus->enabled && cheatStatus->feedback && cheatStatus->feedbackText.data) { imui_text(context, "txtCheatFeedback", CREATE_UI_TEXT_ARGS_INIT( .position = vec2_addv(bottomPanel, vec2i(15, -20)), .fontIndex = 1, .fontSize = 8, .fontColor = WAR_COLOR_YELLOW, .text = wstr_view(&cheatStatus->feedbackText) )); } TracyCZoneEnd(ctx); } static void renderStaticPanels(WarContext* context) { WarMap* map = context->map; WarPlayerInfo* player = &map->players[0]; vec2 leftTopPanel = RECT_TOP_LEFT(map->leftTopPanel); vec2 leftBottomPanel = RECT_TOP_LEFT(map->leftBottomPanel); vec2 topPanel = RECT_TOP_LEFT(map->topPanel); vec2 rightPanel = RECT_TOP_LEFT(map->rightPanel); vec2 bottomPanel = RECT_TOP_LEFT(map->bottomPanel); imui_image(context, "panelLeftTop", CREATE_UI_IMAGE_ARGS_INIT( .spriteRef = imageResourceRefFromPlayer(player, 224, 225), .position = leftTopPanel, )); imui_image(context, "panelLeftBottom", CREATE_UI_IMAGE_ARGS_INIT( .spriteRef = imageResourceRefFromPlayer(player, 226, 227), .position = leftBottomPanel, )); imui_image(context, "panelTop", CREATE_UI_IMAGE_ARGS_INIT( .spriteRef = imageResourceRefFromPlayer(player, 218, 219), .position = topPanel, )); imui_image(context, "panelRight", CREATE_UI_IMAGE_ARGS_INIT( .spriteRef = imageResourceRefFromPlayer(player, 220, 221), .position = rightPanel, )); imui_image(context, "panelBottom", CREATE_UI_IMAGE_ARGS_INIT( .spriteRef = imageResourceRefFromPlayer(player, 222, 223), .position = bottomPanel, )); imui_image(context, "imgGold", CREATE_UI_IMAGE_ARGS_INIT( .spriteRef = imageResourceRef(406), .position = vec2_addv(topPanel, vec2i(201, 1)), )); imui_image(context, "imgLumber", CREATE_UI_IMAGE_ARGS_INIT( .spriteRef = imageResourceRef(407), .position = vec2_addv(topPanel, vec2i(102, 0)), )); } static void renderSelectionRect(WarContext* context) { TracyCZoneN(ctx, "RenderSelectionRect", 1); wr_save(context); WarInput* input = &context->input; if (isMapDragging(input)) { rect pointerRect = rectpf(input->mapDragStartPos.x, input->mapDragStartPos.y, input->pos.x, input->pos.y); wr_strokeRect(context, pointerRect, WAR_COLOR_GREEN_SELECTION, 1.0f); } wr_restore(context); TracyCZoneEnd(ctx); } static void renderCommand(WarContext* context) { TracyCZoneN(ctx, "RenderCommand", 1); WarMap* map = context->map; WarUnitCommand* command = &map->command; WarInput* input = &context->input; wr_save(context); switch (command->type) { case WAR_COMMAND_BUILD_FARM_HUMANS: case WAR_COMMAND_BUILD_FARM_ORCS: case WAR_COMMAND_BUILD_BARRACKS_HUMANS: case WAR_COMMAND_BUILD_BARRACKS_ORCS: case WAR_COMMAND_BUILD_CHURCH: case WAR_COMMAND_BUILD_TEMPLE: case WAR_COMMAND_BUILD_TOWER_HUMANS: case WAR_COMMAND_BUILD_TOWER_ORCS: case WAR_COMMAND_BUILD_TOWNHALL_HUMANS: case WAR_COMMAND_BUILD_TOWNHALL_ORCS: case WAR_COMMAND_BUILD_LUMBERMILL_HUMANS: case WAR_COMMAND_BUILD_LUMBERMILL_ORCS: case WAR_COMMAND_BUILD_STABLE: case WAR_COMMAND_BUILD_KENNEL: case WAR_COMMAND_BUILD_BLACKSMITH_HUMANS: case WAR_COMMAND_BUILD_BLACKSMITH_ORCS: { vec2 position = wmap_screenToMapCoordinatesV(context, input->pos); position = wmap_mapToTileCoordinatesV(position); WarUnitType buildingToBuild = command->build.buildingToBuild; const WarUnitData* unitData = wu_getUnitData(buildingToBuild); WarColor fillColor = we_checkRectToBuild(context, (s32)position.x, (s32)position.y, unitData->sizex, unitData->sizey) ? WAR_COLOR_GRAY_TRANSPARENT : WAR_COLOR_RED_TRANSPARENT; position = wmap_tileToMapCoordinatesV(position, false); position = wmap_mapToScreenCoordinatesV(context, position); vec2 size = vec2i(unitData->sizex * MEGA_TILE_WIDTH, unitData->sizey * MEGA_TILE_HEIGHT); rect buildingRect = rectv(position, size); wr_fillRect(context, buildingRect, fillColor); break; } case WAR_COMMAND_BUILD_WALL: case WAR_COMMAND_BUILD_ROAD: { vec2 position = wmap_screenToMapCoordinatesV(context, input->pos); position = wmap_mapToTileCoordinatesV(position); WarColor fillColor = we_checkRectToBuild(context, (s32)position.x, (s32)position.y, 1, 1) ? WAR_COLOR_GRAY_TRANSPARENT : WAR_COLOR_RED_TRANSPARENT; position = wmap_tileToMapCoordinatesV(position, false); position = wmap_mapToScreenCoordinatesV(context, position); vec2 size = vec2i(MEGA_TILE_WIDTH, MEGA_TILE_HEIGHT); rect buildingRect = rectv(position, size); wr_fillRect(context, buildingRect, fillColor); break; } default: { // don't render the rest of the commands break; } } wr_restore(context); TracyCZoneEnd(ctx); } void wmui_renderMapUI(WarContext* context) { TracyCZoneN(ctx, "RenderMapUI", 1); wr_save(context); renderStaticPanels(context); renderSelectionRect(context); renderCommand(context); wui_renderUIEntities(context); renderHUD(context); renderMenus(context); wr_restore(context); TracyCZoneEnd(ctx); } ================================================ FILE: src/war_map_ui.h ================================================ #pragma once #include "war.h" void wmui_createMapUI(WarContext* context); WarEntity* wmui_createUIMinimap(WarContext* context, String name, vec2 position); void wmui_setFlashStatus(WarContext* context, f32 duration, String text); void wmui_renderMapUI(WarContext* context); ================================================ FILE: src/war_math.c ================================================ #pragma once #include "war_math.h" vec2 vec2f(f32 x, f32 y) { return (vec2){x, y}; } vec2 vec2i(s32 x, s32 y) { return (vec2){(f32)x, (f32)y}; } vec2 vec2_addv(vec2 a, vec2 b) { return (vec2){a.x + b.x, a.y + b.y}; } vec2 vec2_addi(vec2 v, s32 x) { return (vec2){v.x + x, v.y + x}; } vec2 vec2_addf(vec2 v, f32 x) { return (vec2){v.x + x, v.y + x}; } vec2 vec2_subv(vec2 a, vec2 b) { return (vec2){a.x - b.x, a.y - b.y}; } vec2 vec2_subi(vec2 v, s32 x) { return (vec2){v.x - x, v.y - x}; } vec2 vec2_subf(vec2 v, f32 x) { return (vec2){v.x - x, v.y - x}; } vec2 vec2_mulf(vec2 v, f32 a) { return (vec2){v.x * a, v.y * a}; } vec2 vec2_muli(vec2 v, s32 a) { return (vec2){v.x * (f32)a, v.y * (f32)a}; } vec2 vec2_mulv(vec2 a, vec2 b) { return (vec2){a.x * b.x, a.y * b.y}; } vec2 vec2_half(vec2 a) { return (vec2){a.x * 0.5f, a.y * 0.5f}; } vec2 vec2_translatef(vec2 v, f32 x, f32 y) { return (vec2){v.x + x, v.y + y}; } vec2 vec2_translatei(vec2 v, s32 x, s32 y) { return (vec2){v.x + (f32)x, v.y + (f32)y}; } vec2 vec2_scalef(vec2 v, f32 scale) { return (vec2){v.x * scale, v.y * scale}; } vec2 vec2_scalei(vec2 v, s32 scale) { return (vec2){v.x * (f32)scale, v.y * (f32)scale}; } vec2 vec2_scalev(vec2 v, vec2 scale) { return (vec2){v.x * scale.x, v.y * scale.y}; } vec2 vec2_inverse(vec2 v) { return (vec2){-v.x, -v.y}; } f32 vec2_lengthSqr(vec2 v) { return v.x * v.x + v.y * v.y; } f32 vec2_length(vec2 v) { return sqrtf(vec2_lengthSqr(v)); } f32 vec2_distanceSqr(vec2 v1, vec2 v2) { f32 xx = (v1.x - v2.x); f32 yy = (v1.y - v2.y); return xx * xx + yy * yy; } f32 vec2_distance(vec2 v1, vec2 v2) { return sqrtf(vec2_distanceSqr(v1, v2)); } f32 vec2_distanceInTiles(vec2 v1, vec2 v2) { vec2 diff = vec2_subv(v1, v2); return MAX(ABS(diff.x), ABS(diff.y)); } vec2 vec2_normalize(vec2 v) { f32 len = vec2_length(v); return len != 0 ? vec2_scalef(v, 1 / len) : VEC2_ZERO; } f32 vec2_dot(vec2 v1, vec2 v2) { return v1.x * v2.x + v1.y * v2.y; } f32 vec2_determinant(vec2 v1, vec2 v2) { return v1.x * v2.x - v1.y * v2.y; } s32 vec2_orientation(vec2 v1, vec2 v2) { return v1.x * v2.y - v1.y * v2.x >= 0 ? 1 : -1; } f32 vec2_angle(vec2 v1, vec2 v2) { f32 v1Length = vec2_length(v1); f32 v2Length = vec2_length(v2); if (v1Length == 0 || v2Length == 0) return 0; f32 dot = vec2_dot(v1, v2); f32 angleRad = acosf(dot / (v1Length * v2Length)); return RAD2DEG(angleRad); } f32 vec2_angleClockwise(vec2 v1, vec2 v2) { f32 v1Length = vec2_length(v1); f32 v2Length = vec2_length(v2); if (v1Length == 0 || v2Length == 0) return 0; s32 orientation = vec2_orientation(v1, v2); f32 dot = vec2_dot(v1, v2); f32 angleRad = acosf(dot / (v1Length * v2Length)); // if the two vectors are in counter-clockwise orientation // take the larger angle between the two vectors if (orientation < 0) angleRad = 2 * PI - angleRad; return RAD2DEG(angleRad); } vec2 vec2_clampf(vec2 v, f32 a, f32 b) { return (vec2){CLAMP(v.x, a, b), CLAMP(v.y, a, b)}; } vec2 vec2_clampi(vec2 v, s32 a, s32 b) { return (vec2){CLAMP(v.x, (f32)a, (f32)b), CLAMP(v.y, (f32)a, (f32)b)}; } vec2 vec2_clampv(vec2 v, vec2 a, vec2 b) { return (vec2){CLAMP(v.x, a.x, b.x), CLAMP(v.y, a.y, b.y)}; } vec2 vec2_floor(vec2 v) { return (vec2){floorf(v.x), floorf(v.y)}; } vec2 vec2_ceil(vec2 v) { return (vec2){ceilf(v.x), ceilf(v.y)}; } vec2 vec2_round(vec2 v) { return (vec2){roundf(v.x), roundf(v.y)}; } void vec2_print(vec2 v) { logDebug("(%f, %f)", v.x, v.y); } rect rectf(f32 x, f32 y, f32 width, f32 height) { return (rect){x, y, width, height}; } rect recti(s32 x, s32 y, s32 width, s32 height) { return (rect){(f32)x, (f32)y, (f32)width, (f32)height}; } rect rectpf(f32 x1, f32 y1, f32 x2, f32 y2) { return rectf(MIN(x1, x2), MIN(y1, y2), ABS(x1 - x2), ABS(y1 - y2)); } rect rectv(vec2 pos, vec2 size) { return (rect){pos.x, pos.y, size.x, size.y}; } rect rects(vec2 size) { return (rect){0.0f, 0.0f, size.x, size.y}; } bool rect_containsf(rect r, f32 x, f32 y) { return x >= r.x && x <= r.x + r.width && y >= r.y && y <= r.y + r.height; } bool rect_intersects(rect r1, rect r2) { return !(r1.x + r1.width < r2.x || r1.x > r2.x + r2.width || r1.y + r1.height < r2.y || r1.y > r2.y + r2.height); } rect rect_scalef(rect r, f32 scale) { r.x *= scale; r.y *= scale; r.width *= scale; r.height *= scale; return r; } rect rect_translatef(rect r, f32 x, f32 y) { r.x += x; r.y += y; return r; } vec2 rect_center(rect r) { return vec2f(r.x + 0.5f * r.width, r.y + 0.5f * r.height); } rect rect_expand(rect r, f32 dx, f32 dy) { r.x -= dx; r.y -= dy; r.width += dx * 2; r.height += dy * 2; return r; } vec2 get_closestPointOnRect(vec2 p, rect r) { f32 left = r.x; f32 top = r.y; f32 right = r.x + r.width - 1; f32 bottom = r.y + r.height - 1; // top-left if (p.x < left && p.y < top) return vec2f(left, top); // top-center if (p.x >= left && p.x <= right && p.y < top) return vec2f(p.x, top); // top-right if (p.x > right && p.y < top) return vec2f(right, top); // middle-right if (p.x > right && p.y >= top && p.y <= bottom) return vec2f(right, p.y); // bottom-right if (p.x > right && p.y > bottom) return vec2f(right, bottom); // bottom-center if (p.x >= left && p.x <= right && p.y > bottom) return vec2f(p.x, bottom); // bottom-left if (p.x < left && p.y > bottom) return vec2f(left, bottom); // middle-left if (p.x < left && p.y >= top && p.y <= bottom) return vec2f(left, p.y); // the point is inside the rect return p; } void rect_print(rect r) { logDebug("(%f, %f, %f, %f)", r.x, r.y, r.width, r.height); } bool equalsS32(const s32 a, const s32 b) { return a == b; } bool compareS32(const s32 a, const s32 b) { return a - b; } shlDefineList(s32List, s32) bool equalsVec2(const vec2 v1, const vec2 v2) { return v1.x == v2.x && v1.y == v2.y; } shlDefineList(vec2List, vec2) bool equalsRect(const rect r1, const rect r2) { return r1.x == r2.x && r1.y == r2.y && r1.width == r2.width && r1.height == r2.height; } shlDefineList(rectList, rect) shlDefineMap(StringViewMap, StringView, String) ================================================ FILE: src/war_math.h ================================================ #pragma once #include #include "shl/list.h" #include "shl/map.h" #include "common.h" #define SIGN(x) ((x) < 0 ? -1 : 1) #define MIN(a, b) ((a) < (b) ? (a) : (b)) #define MAX(a, b) ((a) > (b) ? (a) : (b)) #define CLAMP(x, a, b) (MAX(MIN(x, b), a)) #define ABS(x) ((x) < 0 ? -(x) : (x)) #define PERCENTF(x) ((x) * 100) #define PERCENTI(x) ((s32)PERCENTF(x)) #define PERCENTF01(a, b) ((f32)(a)/(b)) #define PERCENTABF(a, b) PERCENTF(PERCENTF01(a, b)) #define PERCENTABI(a, b) PERCENTI(PERCENTF01(a, b)) #define PI 3.14159265358979323846264338327f #define RAD2DEG(x) ((x) * 180 / PI) #define DEG2RAD(x) ((x) * PI / 180) /* * vec2 types and functions */ typedef struct { f32 x, y; } vec2; #define VEC2_ZERO ((vec2){0.0f, 0.0f}) #define VEC2_ONE ((vec2){1.0f, 1.0f}) #define VEC2_LEFT ((vec2){-1.0f, 0.0 }) #define VEC2_UP ((vec2){0.0f, -1.0 }) #define VEC2_RIGHT ((vec2){1.0f, 0.0f}) #define VEC2_DOWN ((vec2){0.0f, 1.0f}) #define VEC2_IS_ZERO(v) ((v).x == 0.0f && (v).y == 0.0f) #define VEC2_IS_ONE(v) ((v).x == 1.0f && (v).y == 1.0f) vec2 vec2f(f32 x, f32 y); vec2 vec2i(s32 x, s32 y); vec2 vec2_addv(vec2 a, vec2 b); vec2 vec2_addi(vec2 v, s32 x); vec2 vec2_addf(vec2 v, f32 x); vec2 vec2_subv(vec2 a, vec2 b); vec2 vec2_subi(vec2 v, s32 x); vec2 vec2_subf(vec2 v, f32 x); vec2 vec2_mulf(vec2 v, f32 a); vec2 vec2_muli(vec2 v, s32 a); vec2 vec2_mulv(vec2 a, vec2 b); vec2 vec2_half(vec2 a); vec2 vec2_translatef(vec2 v, f32 x, f32 y); vec2 vec2_translatei(vec2 v, s32 x, s32 y); vec2 vec2_scalef(vec2 v, f32 scale); vec2 vec2_scalei(vec2 v, s32 scale); vec2 vec2_scalev(vec2 v, vec2 scale); vec2 vec2_inverse(vec2 v); f32 vec2_lengthSqr(vec2 v); f32 vec2_length(vec2 v); f32 vec2_distanceSqr(vec2 v1, vec2 v2); f32 vec2_distance(vec2 v1, vec2 v2); f32 vec2_distanceInTiles(vec2 v1, vec2 v2); vec2 vec2_normalize(vec2 v); f32 vec2_dot(vec2 v1, vec2 v2); f32 vec2_determinant(vec2 v1, vec2 v2); s32 vec2_orientation(vec2 v1, vec2 v2); f32 vec2_angle(vec2 v1, vec2 v2); f32 vec2_angleClockwise(vec2 v1, vec2 v2); vec2 vec2_clampf(vec2 v, f32 a, f32 b); vec2 vec2_clampi(vec2 v, s32 a, s32 b); vec2 vec2_clampv(vec2 v, vec2 a, vec2 b); vec2 vec2_floor(vec2 v); vec2 vec2_ceil(vec2 v); vec2 vec2_round(vec2 v); void vec2_print(vec2 v); /* * rect types and functions */ typedef struct { f32 x, y; f32 width, height; } rect; #define RECT_EMPTY ((rect){0.0f, 0.0f, 0.0f, 0.0f}) #define RECT_TOP_LEFT(r) vec2f(r.x, r.y) #define RECT_TOP_RIGHT(r) vec2f(r.x + r.width, r.y) #define RECT_BOTTOM_LEFT(r) vec2f(r.x, r.y + r.height) #define RECT_BOTTOM_RIGHT(r) vec2f(r.x + r.width, r.y + r.height) #define RECT_SIZE(r) vec2f(r.width, r.height) rect rectf(f32 x, f32 y, f32 width, f32 height); rect recti(s32 x, s32 y, s32 width, s32 height); rect rectpf(f32 x1, f32 y1, f32 x2, f32 y2); rect rectv(vec2 pos, vec2 size); rect rects(vec2 size); bool rect_containsf(rect r, f32 x, f32 y); bool rect_intersects(rect r1, rect r2); rect rect_scalef(rect r, f32 scale); rect rect_translatef(rect r, f32 x, f32 y); vec2 rect_center(rect r); rect rect_expand(rect r, f32 dx, f32 dy); vec2 get_closestPointOnRect(vec2 p, rect r); void rect_print(rect r); /* * shl list/map types */ #include "shl/list.h" #include "shl/map.h" #include "shl/wstr.h" bool equalsS32(const s32 a, const s32 b); bool compareS32(const s32 a, const s32 b); bool equalsVec2(const vec2 v1, const vec2 v2); bool equalsRect(const rect r1, const rect r2); shlDeclareList(s32List, s32) shlDeclareList(vec2List, vec2) shlDeclareList(rectList, rect) shlDeclareMap(StringViewMap, StringView, String) #define s32ListDefaultOptions (s32ListOptions){0, equalsS32, NULL} #define vec2ListDefaultOptions (vec2ListOptions){VEC2_ZERO, equalsVec2, NULL} #define rectListDefaultOptions (rectListOptions){RECT_EMPTY, equalsRect, NULL} #define StringViewMapDefaultOptions (StringViewMapOptions){(String){0}, wsv_hashFNV32, wsv_equals, wstr_free} ================================================ FILE: src/war_net.c ================================================ #include "war_net.h" #include #include #include "shl/wstr.h" #include "war_log.h" #define WAR_REQUEST_MESSAGE_MAX_SIZE 2048 #define WAR_URL_BUFFER_MAX_SIZE 1024 #if _WIN32 #define closeSocket closesocket #else #define closeSocket close #endif bool wnet_initNetwork(void) { #if _WIN32 WSADATA wsaData; s32 status = WSAStartup(MAKEWORD(2, 2), &wsaData); if (status != 0) { logError("Couldn't initialize Websock. Errno: %d", status); return false; } #endif return true; } bool wnet_cleanNetwork(void) { #if _WIN32 s32 status = WSACleanup(); if (status == SOCKET_ERROR) { logError("Couldn't cleanup Websock. Errno: %d", WSAGetLastError()); return false; } #endif return true; } WarSocket wnet_connectToHost(StringView host) { const char* hostStr = wsv_data(host); struct hostent* hostEntry = gethostbyname(hostStr); if(!hostEntry) { #if _WIN32 logError("Couldn't create socket to host %s. Errno: %d", hostStr, WSAGetLastError()); #else logError("Couldn't create socket to host %s. Errno: %d", hostStr, h_errno); #endif return 0; } WarSocket sck = socket(AF_INET, SOCK_STREAM, 0); if(sck == INVALID_SOCKET) { #if _WIN32 logError("Couldn't create socket to host %s. Last error: %d", hostStr, WSAGetLastError()); #else logError("Couldn't create socket to host %s. Last error: %d", hostStr, errno); #endif return 0; } struct sockaddr_in hostInfo; hostInfo.sin_family = AF_INET; hostInfo.sin_addr = *((struct in_addr*)*hostEntry->h_addr_list); hostInfo.sin_port = htons(80); s32 status = connect(sck, (struct sockaddr*)&hostInfo, sizeof(struct sockaddr)); if(status == SOCKET_ERROR) { #if _WIN32 logError("Couldn't connect socket to host %s. Last error: %d", hostStr, WSAGetLastError()); #else logError("Couldn't connect socket to host %s. Last error: %d", hostStr, errno); #endif closeSocket(sck); return 0; } return sck; } bool wnet_requestResource(WarSocket sck, StringView resource, StringView host) { const char* resourceStr = wsv_data(resource); const char* hostStr = wsv_data(host); size32 resourcelen = strlen(resourceStr); size32 hostlen = strlen(hostStr); size32 requestLength; size32 hostRequestLength; if (resourcelen > 0 && resourceStr[0] == '/') { resourceStr++; resourcelen--; } requestLength = (sizeof("GET / HTTP/1.1\r\n") - 1) + resourcelen + 1; hostRequestLength = (sizeof("Host: \r\n\r\n") - 1) + hostlen + 1; if (requestLength > WAR_REQUEST_MESSAGE_MAX_SIZE || hostRequestLength > WAR_REQUEST_MESSAGE_MAX_SIZE) { logError("The host or resource are too long to build the HTTP request: host=%s, resource=%s.", hostStr, resourceStr); return false; } char message[WAR_REQUEST_MESSAGE_MAX_SIZE]; snprintf(message, sizeof(message), "GET /%s HTTP/1.1\r\n", resourceStr); s32 status = send(sck, message, (s32)strlen(message), 0); if (status == SOCKET_ERROR) { #if _WIN32 logError("Couldn't send request with message: %s. Errno: %d", message, WSAGetLastError()); #else logError("Couldn't send request with message: %s. Errno: %d", message, errno); #endif return false; } memset(message, 0, sizeof(message)); snprintf(message, sizeof(message), "Host: %s\r\n\r\n", hostStr); status = send(sck, message, (s32)strlen(message), 0); if (status == SOCKET_ERROR) { #if _WIN32 logError("Couldn't send request with message: %s. Errno: %d", message, WSAGetLastError()); #else logError("Couldn't send request with message: %s. Errno: %d", message, errno); #endif return false; } return true; } s32 wnet_parseHeadersFromResponse(StringView response, s32 responseLength, StringViewMap* headers) { NOT_USED(responseLength); StringView view = response; size_t headersEnd = wsv_find(view, wsv_fromCString("\r\n\r\n")); if (headersEnd == WSV_NPOS) { return 0; } StringView headersText = wsv_slice(view, 0, headersEnd); // parse status line StringView line = wsv_chopByDelimiter(&headersText, '\n'); line = wsv_trimRight(line); // Remove '\r' StringView httpVersion; if (wsv_splitOnce(line, wsv_fromCString(" "), &httpVersion, &line)) { StringViewMapSet(headers, wsv_fromCString("HttpVersion"), wsv_toString(httpVersion)); line = wsv_trimLeft(line); StringViewMapSet(headers, wsv_fromCString("ResponseStatus"), wsv_toString(line)); } // parse headers while (headersText.length > 0) { line = wsv_chopByDelimiter(&headersText, '\n'); line = wsv_trimRight(line); // Remove '\r' if (wsv_isEmpty(line)) { continue; } StringView headerName, headerValue; if (wsv_splitOnce(line, wsv_fromCString(":"), &headerName, &headerValue)) { headerValue = wsv_trimLeft(headerValue); StringViewMapSet(headers, headerName, wsv_toString(headerValue)); } } // Return the number of bytes consumed including the \r\n\r\n return (s32)(headersEnd + 4); } s32 wnet_readResponse(WarSocket sck, char responseBuffer[], s32 responseBufferLength) { char* responsePtr = responseBuffer; s32 responseLength = 0; s32 readFromSocket; do { size32 sizeToRead = MIN(RESPONSE_READ_SIZE, responseBufferLength - responseLength); if (sizeToRead <= 0) break; readFromSocket = recv(sck, responsePtr, (s32)sizeToRead, 0); if (readFromSocket == SOCKET_ERROR) { #if _WIN32 logError("Couldn't receive the response from socket %d. Errno: %d", (int)sck, WSAGetLastError()); #else logError("Couldn't receive the response from socket %d. Errno: %d", sck, errno); #endif responseLength = -1; break; } responsePtr += readFromSocket; responseLength += readFromSocket; } while (readFromSocket > 0); return responseLength; } bool wnet_downloadFileFromUrl(WarContext* context, StringView url, StringView filePath) { NOT_USED(context); const char* urlStr = wsv_data(url); const char* filePathStr = wsv_data(filePath); if(!urlStr || !filePathStr) { return false; } u16 shift = 0; if(strncasecmp(urlStr, "http://", strlen("http://")) == 0) { shift = (u16)strlen("http://"); } if (strncasecmp(urlStr + shift, "www.", strlen("www.")) == 0) { shift += (u16)strlen("www."); } size32 urlLength = strlen(urlStr); if (shift > urlLength) { logError("The url has an invalid prefix offset: %s", urlStr); return false; } size32 cutLength = urlLength - shift + 1; if (cutLength > WAR_URL_BUFFER_MAX_SIZE) { logError("The url is too long to parse: %s", urlStr); return false; } char cut[WAR_URL_BUFFER_MAX_SIZE]; strcpy(cut, urlStr + shift); const char* host = strtok(cut, "/"); const char* resource = urlStr + shift + strlen(host); if (!wnet_initNetwork()) { logError("Couldn't initialize the network."); return false; } WarSocket sck = wnet_connectToHost(wsv_fromCString(host)); if (!sck) { logError("Couldn't connect to host: %s", host); wnet_cleanNetwork(); return false; } if (!wnet_requestResource(sck, wsv_fromCString(resource), wsv_fromCString(host))) { logError("Couldn't download file from url %s", urlStr); closeSocket(sck); wnet_cleanNetwork(); return false; } char* response = (char*)wm_alloc(RESPONSE_MAX_SIZE * sizeof(char)); char* responsePtr = response; s32 responseLength = wnet_readResponse(sck, response, RESPONSE_MAX_SIZE); if (responseLength < 0) { logError("Couldn't receive response from url %s", urlStr); closeSocket(sck); wnet_cleanNetwork(); wm_free(response); return false; } SDL_IOStream *stream = SDL_IOFromFile(filePathStr, "wb"); if (!stream) { logError("Couldn't create a new file at: %s", filePathStr); closeSocket(sck); wnet_cleanNetwork(); wm_free(response); return false; } if (responseLength == 0) { logError("The response was empty from %s", urlStr); closeSocket(sck); wnet_cleanNetwork(); wm_free(response); SDL_CloseIO(stream); return true; } StringViewMapOptions options = StringViewMapDefaultOptions; StringViewMap headers; StringViewMapInit(&headers, options); s32 readFromResponse = wnet_parseHeadersFromResponse(wsv_fromParts(response, responseLength), responseLength, &headers); responsePtr += readFromResponse; responseLength -= readFromResponse; String responseStatus = StringViewMapGet(&headers, wsv_fromCString("ResponseStatus")); if (!responseStatus.data || !wsv_equals(wstr_view(&responseStatus), wsv_fromCString("200 OK"))) { logError("The response status is not successful, received %s", responseStatus.data ? wstr_cstr(&responseStatus) : "NULL"); StringViewMapFree(&headers); closeSocket(sck); wnet_cleanNetwork(); wm_free(response); SDL_CloseIO(stream); return false; } String contentType = StringViewMapGet(&headers, wsv_fromCString("Content-Type")); if (!contentType.data || !wsv_equals(wstr_view(&contentType), wsv_fromCString("application/octet-stream"))) { logError("The content type of the response should be binary, received: %s", contentType.data ? wstr_cstr(&contentType) : "NULL"); StringViewMapFree(&headers); closeSocket(sck); wnet_cleanNetwork(); wm_free(response); SDL_CloseIO(stream); return false; } String contentDisposition = StringViewMapGet(&headers, wsv_fromCString("Content-Disposition")); if (!contentDisposition.data || wsv_find(wstr_view(&contentDisposition), wsv_fromCString("attachment")) == WSV_NPOS) { logError("The content disposition of the response should be 'attachment', received: %s", contentDisposition.data ? wstr_cstr(&contentDisposition) : "NULL"); StringViewMapFree(&headers); closeSocket(sck); wnet_cleanNetwork(); wm_free(response); SDL_CloseIO(stream); return false; } String transferEncoding = StringViewMapGet(&headers, wsv_fromCString("Transfer-Encoding")); if (transferEncoding.data && wsv_equals(wstr_view(&transferEncoding), wsv_fromCString("chunked"))) { while (responseLength > 0) { s32 chunkSize = strtol(responsePtr, NULL, 16); // advance the characters of the chunk size and the \r\n s32 lengthToSkip = (s32)strcspn(responsePtr, "\r"); responsePtr += lengthToSkip + 2; responseLength -= lengthToSkip + 2; if (chunkSize == 0) { break; } s32 sizeToWrite = MIN(chunkSize, responseLength); SDL_WriteIO(stream, responsePtr, sizeToWrite); responsePtr += sizeToWrite + 2; responseLength -= sizeToWrite + 2; } } else { // assume Transfer-Encoding: identity SDL_WriteIO(stream, responsePtr, responseLength); } StringViewMapFree(&headers); closeSocket(sck); wnet_cleanNetwork(); free(response); SDL_CloseIO(stream); return true; } ================================================ FILE: src/war_net.h ================================================ #pragma once #include #if _WIN32 #include #include typedef SOCKET WarSocket; #else #include #include #include #define INVALID_SOCKET (-1) #define SOCKET_ERROR (-1) typedef int WarSocket; #endif #define RESPONSE_READ_SIZE 2048 #define RESPONSE_MAX_SIZE (5 * 1024 * 1024) // 5MB #include "war.h" bool wnet_initNetwork(void); bool wnet_cleanNetwork(void); WarSocket wnet_connectToHost(StringView host); bool wnet_requestResource(WarSocket sck, StringView resource, StringView host); s32 wnet_readResponse(WarSocket sck, char responseBuffer[], s32 responseBufferLength); s32 wnet_parseHeadersFromResponse(StringView response, s32 responseLength, StringViewMap* headers); bool wnet_downloadFileFromUrl(WarContext* context, StringView url, StringView filePath); ================================================ FILE: src/war_pathfinder.c ================================================ #include #include "war_pathfinder.h" static s32 manhattanDistance(const WarMapNode node1, const WarMapNode node2) { return ABS(node1.x - node2.x) + ABS(node1.y - node2.y); } static s32 nodeDistanceSqr(const WarMapNode node1, const WarMapNode node2) { s32 xx = node1.x - node2.x; s32 yy = node1.y - node2.y; return xx * xx + yy * yy; } bool equalsMapNode(const WarMapNode node1, const WarMapNode node2) { return node1.x == node2.x && node1.y == node2.y; } s32 compareFScore(const WarMapNode node1, const WarMapNode node2) { return node1.fScore - node2.fScore; } u32 hashMapNode(const s32 key) { return (u32)key; } bool equalsMapNodeId(const s32 key1, const s32 key2) { return key1 == key2; } shlDefineList(WarMapNodeList, WarMapNode) shlDefineBinaryHeap(WarMapNodeHeap, WarMapNode) shlDefineMap(WarMapNodeMap, s32, WarMapNode) static WarMapNode createNode(WarPathFinder finder, s32 x, s32 y) { return (WarMapNode){y * finder.width + x, x, y, 0, -1, INT32_MAX, INT32_MAX}; } u16 wpath_getTileValue(WarPathFinder finder, s32 x, s32 y) { assert(inRange(x, 0, finder.width)); assert(inRange(y, 0, finder.height)); return finder.data[y * finder.width + x]; } void wpath_setTilesValue(WarPathFinder finder, s32 startX, s32 startY, s32 width, s32 height, u16 value) { if (!inRange(startX, 0, finder.width) || !inRange(startY, 0, finder.height)) return; if (startX + width >= finder.width) width = finder.width - startX; if (startY + height >= finder.height) height = finder.height - startY; s32 endX = startX + width; s32 endY = startY + height; for(s32 y = startY; y < endY; y++) { for(s32 x = startX; x < endX; x++) { finder.data[y * finder.width + x] = value; } } } static WarMapPath bfs(WarPathFinder finder, s32 startX, s32 startY, s32 endX, s32 endY) { WarMapNodeList nodes; WarMapNodeListInit(&nodes, WarMapNodeListDefaultOptions); WarMapNode startNode = createNode(finder, startX, startY); WarMapNode endNode = createNode(finder, endX, endY); WarMapNodeListAdd(&nodes, startNode); const s32 dirC = 8; const s32 dirX[] = { 0, 1, 1, 1, 0, -1, -1, -1 }; const s32 dirY[] = { -1, -1, 0, 1, 1, 1, 0, -1 }; s32 i; for(i = 0; i < nodes.count; i++) { WarMapNode node = nodes.items[i]; if (equalsMapNode(node, endNode)) break; for(s32 d = 0; d < dirC; d++) { s32 xx = node.x + dirX[d]; s32 yy = node.y + dirY[d]; if (wpath_isInside(finder, xx, yy)) { WarMapNode newNode = createNode(finder, xx, yy); if (isEmpty(finder, xx, yy) || equalsMapNode(newNode, endNode)) { if (!WarMapNodeListContains(&nodes, newNode)) { newNode.parent = i; newNode.level = node.level + 1; WarMapNodeListAdd(&nodes, newNode); } } } } } WarMapPath path = (WarMapPath){0}; vec2ListInit(&path.nodes, vec2ListDefaultOptions); if (i < nodes.count) { WarMapNode node = nodes.items[i]; vec2ListAdd(&path.nodes, vec2i(node.x, node.y)); while (node.parent >= 0) { node = nodes.items[node.parent]; vec2ListAdd(&path.nodes, vec2i(node.x, node.y)); } vec2ListReverse(&path.nodes); } WarMapNodeListFree(&nodes); return path; } static WarMapPath astar(WarPathFinder finder, s32 startX, s32 startY, s32 endX, s32 endY) { TracyCZoneN(ctx, "Astar", 1); // The set of currently discovered nodes that are not evaluated yet. WarMapNodeHeap openSet; WarMapNodeHeapInit(&openSet, WarMapNodeHeapDefaultOptions); // The set of nodes already evaluated (this could be a simple boolean array to mark the visited nodes) WarMapNodeMap closedSet; WarMapNodeMapInit(&closedSet, WarMapNodeMapDefaultOptions); WarMapNode startNode = createNode(finder, startX, startY); WarMapNode endNode = createNode(finder, endX, endY); const s32 dirC = 8; const s32 dirX[] = { 0, 1, 1, 1, 0, -1, -1, -1 }; const s32 dirY[] = { -1, -1, 0, 1, 1, 1, 0, -1 }; // The cost of going from start to start is zero. startNode.gScore = 0; // The cost of going from start to end is infinity. endNode.gScore = INT32_MAX; // For the first node, the fScore that value is completely heuristic. startNode.fScore = manhattanDistance(startNode, endNode); // For the last node, the fScore is 0 endNode.fScore = 0; // Initially, only the start node is known. WarMapNodeHeapPush(&openSet, startNode); while (openSet.count > 0) { // the node in openSet having the lowest fScore value WarMapNode current = WarMapNodeHeapPop(&openSet); WarMapNodeMapSet(&closedSet, current.id, current); if (equalsMapNode(current, endNode)) break; for(s32 d = 0; d < dirC; d++) { s32 xx = current.x + dirX[d]; s32 yy = current.y + dirY[d]; if (wpath_isInside(finder, xx, yy)) { // if the neighbor position is occupied by a static entity, // don't consider it so that the unit is able to surround it if (isStatic(finder, xx, yy)) continue; WarMapNode neighbor = createNode(finder, xx, yy); // if the neighbor position is a occupied by a dynamic entity (another unit moving), // there is a chance that when the unit gets there the position is empty // but only consider it in the path when that position is far away from the start, // because when that position is close enough, the risk of overlaping units is greater if (isDynamic(finder, xx, yy)) { s32 distance = nodeDistanceSqr(startNode, neighbor); if (distance < DISTANCE_SQR_AVOID_DYNAMIC_POSITIONS) continue; } // Ignore the neighbor which is already evaluated. if (WarMapNodeMapContains(&closedSet, neighbor.id)) continue; // The distance from start -> current node -> neighbor s32 gScore = current.gScore + 1 /* cost from current to neighbor, can be a little higher for diagonals */; // < 0 indicates that this node need to be inserted into the heap s32 index = WarMapNodeHeapIndexOf(&openSet, neighbor); // if the node is already in the heap, check to update its gScore if necessary if (index >= 0) { neighbor = openSet.items[index]; // going from the current node through this neighbor is not the best way, skip it if (gScore >= neighbor.gScore) continue; } // This path is the best until now. Record it! neighbor.parent = current.id; neighbor.gScore = gScore; neighbor.fScore = neighbor.gScore + manhattanDistance(neighbor, endNode); if (index >= 0) WarMapNodeHeapUpdate(&openSet, index, neighbor); else WarMapNodeHeapPush(&openSet, neighbor); } } } WarMapPath path = (WarMapPath){0}; vec2ListInit(&path.nodes, vec2ListDefaultOptions); // only process the path if has at least two points if (closedSet.count > 1) { WarMapNode node = {0}; // if the last node is not in the collection of processed nodes, // then the node is unreachable, look for the closest one and go there if (!WarMapNodeMapContains(&closedSet, endNode.id)) { s32 minDistanceToEnd = INT32_MAX; s32 minDistanceFromStart = INT32_MAX; for(s32 k = 0; k < closedSet.capacity; k++) { if (closedSet.entries[k].active) { s32 distanceToEnd = nodeDistanceSqr(endNode, closedSet.entries[k].value); if (distanceToEnd < minDistanceToEnd) { node = closedSet.entries[k].value; minDistanceToEnd = distanceToEnd; minDistanceFromStart = nodeDistanceSqr(startNode, closedSet.entries[k].value); } else if(distanceToEnd == minDistanceToEnd) { s32 distanceFromStart = nodeDistanceSqr(startNode, closedSet.entries[k].value); if (distanceFromStart < minDistanceFromStart) { node = closedSet.entries[k].value; minDistanceToEnd = distanceToEnd; minDistanceFromStart = distanceFromStart; } } } } } else { node = WarMapNodeMapGet(&closedSet, endNode.id); } while (node.parent >= 0) { vec2ListAdd(&path.nodes, vec2i(node.x, node.y)); node = WarMapNodeMapGet(&closedSet, node.parent); } vec2ListAdd(&path.nodes, vec2i(node.x, node.y)); vec2ListReverse(&path.nodes); } WarMapNodeHeapFree(&openSet); WarMapNodeMapFree(&closedSet); TracyCZoneEnd(ctx); return path; } WarPathFinder wpath_initPathFinder(WarContext* context, PathFindingType type, s32 width, s32 height, u16 data[]) { NOT_USED(context); WarPathFinder finder = (WarPathFinder){0}; finder.type = type; finder.width = width; finder.height = height; finder.data = (u16*)wm_alloc(width * height * sizeof(u16)); // 128 -> wood, 64 -> water, 16 -> bridge, 0 -> empty for(s32 i = 0; i < width * height; i++) { switch (data[i]) { case 128: case 64: finder.data[i] = PATH_FINDER_DATA_STATIC; break; default: finder.data[i] = PATH_FINDER_DATA_EMPTY; break; } } return finder; } bool wpath_isInside(WarPathFinder finder, s32 x, s32 y) { return inRange(x, 0, finder.width) && inRange(y, 0, finder.height); } WarMapPath wpath_findPath(WarPathFinder finder, s32 startX, s32 startY, s32 endX, s32 endY) { TracyCZoneN(ctx, "FindPath", 1); WarMapPath path; switch (finder.type) { case PATH_FINDING_BFS: path = bfs(finder, startX, startY, endX, endY); break; case PATH_FINDING_ASTAR: path = astar(finder, startX, startY, endX, endY); break; default: { logWarning("Unkown path finding type %d, defaulting to %d", finder.type, PATH_FINDING_ASTAR); path = astar(finder, startX, startY, endX, endY); break; } } TracyCZoneEnd(ctx); return path; } bool wpath_reRoutePath(WarPathFinder finder, WarMapPath* path, s32 fromIndex, s32 toIndex) { assert(inRange(fromIndex, 0, path->nodes.count)); assert(inRange(toIndex, 0, path->nodes.count)); assert(fromIndex != toIndex); bool result = false; vec2 fromNode = path->nodes.items[fromIndex]; vec2 toNode = path->nodes.items[toIndex]; // find a new path from the current position to the destination WarMapPath newPath = wpath_findPath(finder, (s32)fromNode.x, (s32)fromNode.y, (s32)toNode.x, (s32)toNode.y); if (newPath.nodes.count > 1) { s32 minIndex = MIN(fromIndex, toIndex); s32 maxIndex = MAX(fromIndex, toIndex); // remove the nodes in the range [fromIndex, toIndex] or [toIndex, fromIndex] from current to last remaining nodes of the current path vec2ListRemoveAtRange(&path->nodes, minIndex, maxIndex - minIndex + 1); // if a path was found subsitute the portion of the path with the new one vec2ListInsertRange(&path->nodes, minIndex, newPath.nodes.count, newPath.nodes.items); result = true; } wpath_freePath(newPath); return result; } bool wpath_pathExists(WarPathFinder finder, s32 startX, s32 startY, s32 endX, s32 endY) { WarMapPath path = wpath_findPath(finder, startX, startY, endX, endY); bool result = path.nodes.count >= 2; wpath_freePath(path); return result; } void wpath_freePath(WarMapPath path) { vec2ListFree(&path.nodes); } vec2 wpath_findEmptyPosition(WarPathFinder finder, vec2 position) { const s32 dirC = 8; const s32 dirX[] = { 0, 1, 1, 1, 0, -1, -1, -1 }; const s32 dirY[] = { -1, -1, 0, 1, 1, 1, 0, -1 }; if (isEmpty(finder, (s32)position.x, (s32)position.y)) return position; vec2List positions; vec2ListInit(&positions, vec2ListDefaultOptions); vec2ListAdd(&positions, position); for(s32 i = 0; i < positions.count; i++) { vec2 currentPosition = positions.items[i]; if (isEmpty(finder, (s32)currentPosition.x, (s32)currentPosition.y)) { position = currentPosition; break; } for(s32 d = 0; d < dirC; d++) { s32 xx = (s32)currentPosition.x + dirX[d]; s32 yy = (s32)currentPosition.y + dirY[d]; if (inRange(xx, 0, finder.width) && inRange(yy, 0, finder.height)) { vec2 newPosition = vec2i(xx, yy); if (!vec2ListContains(&positions, newPosition)) vec2ListAdd(&positions, newPosition); } } } vec2ListFree(&positions); return position; } bool wpath_isPositionAccesible(WarPathFinder finder, vec2 position) { const s32 dirC = 8; const s32 dirX[] = { 0, 1, 1, 1, 0, -1, -1, -1 }; const s32 dirY[] = { -1, -1, 0, 1, 1, 1, 0, -1 }; for(s32 d = 0; d < dirC; d++) { s32 xx = (s32)position.x + dirX[d]; s32 yy = (s32)position.y + dirY[d]; if (inRange(xx, 0, finder.width) && inRange(yy, 0, finder.height)) { if (isEmpty(finder, xx, yy)) return true; } } return false; } ================================================ FILE: src/war_pathfinder.h ================================================ #pragma once #include "shl/binary_heap.h" #include "shl/list.h" #include "shl/map.h" #include "common.h" #include "war_fwd.h" #include "war_math.h" struct _WarMapNode { s32 id; // id of the node s32 x, y; // the coordinates of the node s32 level; // the length of the path from the start to this node s32 parent; // the previous node in the path from start to end passing through this node s32 gScore; // the cost from the start to this node s32 fScore; // the cost from start to end passing through this node }; struct _WarMapPath { vec2List nodes; }; struct _WarPathFinder { PathFindingType type; s32 width, height; u16* data; }; // NOTE: this value is the distance squared to avoid dynamic units // so if the dynamic entity at a distance squared less than this value, // treat it like a static one, so the unit can get around it and the risk of // overlapping units is less #define DISTANCE_SQR_AVOID_DYNAMIC_POSITIONS 2.0f #define WarMapNodeEmpty (WarMapNode){0} bool equalsMapNode(const WarMapNode node1, const WarMapNode node2); s32 compareFScore(const WarMapNode node1, const WarMapNode node2); u32 hashMapNode(const s32 key); bool equalsMapNodeId(const s32 key1, const s32 key2); shlDeclareList(WarMapNodeList, WarMapNode) shlDeclareBinaryHeap(WarMapNodeHeap, WarMapNode) shlDeclareMap(WarMapNodeMap, s32, WarMapNode) #define WarMapNodeListDefaultOptions (WarMapNodeListOptions){WarMapNodeEmpty, equalsMapNode} #define WarMapNodeHeapDefaultOptions (WarMapNodeHeapOptions){WarMapNodeEmpty, equalsMapNode, compareFScore} #define WarMapNodeMapDefaultOptions (WarMapNodeMapOptions){WarMapNodeEmpty, hashMapNode, equalsMapNodeId} u16 wpath_getTileValue(WarPathFinder finder, s32 x, s32 y); void wpath_setTilesValue(WarPathFinder finder, s32 startX, s32 startY, s32 width, s32 height, u16 value); #define setFreeTiles(finder, startX, startY, width, height) wpath_setTilesValue(finder, startX, startY, width, height, PATH_FINDER_DATA_EMPTY) #define setDynamicEntity(finder, startX, startY, width, height, id) wpath_setTilesValue(finder, startX, startY, width, height, (id << 4) | PATH_FINDER_DATA_DYNAMIC) #define setStaticEntity(finder, startX, startY, width, height, id) wpath_setTilesValue(finder, startX, startY, width, height, (id << 4) | PATH_FINDER_DATA_STATIC) #define getTileValueType(finder, x, y) (wpath_getTileValue(finder, x, y) & 0x000F) #define getTileEntityId(finder, x, y) ((wpath_getTileValue(finder, x, y) & 0xFFF0) >> 4) #define isEmpty(finder, x, y) (getTileValueType(finder, x, y) == PATH_FINDER_DATA_EMPTY) #define isStatic(finder, x, y) (getTileValueType(finder, x, y) == PATH_FINDER_DATA_STATIC) #define isDynamic(finder, x, y) (getTileValueType(finder, x, y) == PATH_FINDER_DATA_DYNAMIC) #define isDynamicOfEntity(finder, x, y, id) (getTileEntityId(finder, x, y) == id) WarPathFinder wpath_initPathFinder(WarContext* context, PathFindingType type, s32 width, s32 height, u16 data[]); bool wpath_isInside(WarPathFinder finder, s32 x, s32 y); WarMapPath wpath_findPath(WarPathFinder finder, s32 startX, s32 startY, s32 endX, s32 endY); bool wpath_reRoutePath(WarPathFinder finder, WarMapPath* path, s32 fromIndex, s32 toIndex); bool wpath_pathExists(WarPathFinder finder, s32 startX, s32 startY, s32 endX, s32 endY); void wpath_freePath(WarMapPath path); vec2 wpath_findEmptyPosition(WarPathFinder finder, vec2 position); bool wpath_isPositionAccesible(WarPathFinder finder, vec2 position); ================================================ FILE: src/war_projectiles.c ================================================ #include "war_projectiles.h" #include #include "war_animations.h" #include "war_audio.h" #include "war_entities.h" #include "war_map.h" #include "war_units.h" typedef struct { WarProjectileType type; s32 resourceIndex; s32 speed; // in pixels/seconds s32 frameCount; // number of frames that conform a single animation s32 frameStride; // number of frames until next sprite from current animation // this is due to some projectiles sprite having directional sprites // so like sprites of units, they have 5 directions and 3 that are // mirrored from others } WarProjectileData; WarProjectileData projectilesData[] = { // type resourceIndex speed frames stride { WAR_PROJECTILE_ARROW, 349, 8 * MEGA_TILE_WIDTH, 1, 0 }, { WAR_PROJECTILE_CATAPULT, 348, 4 * MEGA_TILE_WIDTH, 3, 5 }, { WAR_PROJECTILE_FIREBALL, 347, 8 * MEGA_TILE_WIDTH, 5, 5 }, { WAR_PROJECTILE_FIREBALL_2, 358, 8 * MEGA_TILE_WIDTH, 2, 5 }, { WAR_PROJECTILE_WATER_ELEMENTAL, 357, 8 * MEGA_TILE_WIDTH, 2, 5 }, { WAR_PROJECTILE_RAIN_OF_FIRE, 351, 6 * MEGA_TILE_WIDTH, 3, 1 }, }; WarProjectileData wproj_getProjectileData(WarProjectileType type) { s32 index = 0; s32 length = arrayLength(projectilesData); while (index < length && projectilesData[index].type != type) index++; assert(index < length); return projectilesData[index]; } void wproj_doProjectileTargetDamage(WarContext* context, WarEntity* entity) { WarProjectileComponent* projectile = we_getProjectileComponent(context, entity); assert(projectile); vec2 position = wmap_mapToTileCoordinatesV(projectile->target); WarEntity* sourceEntity = we_findEntity(context, projectile->sourceEntityId); WarEntity* targetEntity = we_findEntity(context, projectile->targetEntityId); // check if the attacker and the victim exists because it could be eliminated by other unit if (sourceEntity && targetEntity) { if (wu_isWall(targetEntity)) { WarWallPiece* piece = we_getWallPieceAtPosition(context, targetEntity, (s32)position.x, (s32)position.y); if (piece) { we_meleeWallAttack(context, sourceEntity, targetEntity, piece); } } else { we_meleeAttack(context, sourceEntity, targetEntity); } } } void wproj_doProjectileSplashDamage(WarContext* context, WarEntity* entity, s32 splashRadius) { WarProjectileComponent* projectile = we_getProjectileComponent(context, entity); assert(projectile); vec2 targetTile = wmap_mapToTileCoordinatesV(projectile->target); WarEntity* sourceEntity = we_findEntity(context, projectile->sourceEntityId); if (sourceEntity) { WarEntityList* nearUnits = we_getNearUnits(context, targetTile, splashRadius); for (s32 i = 0; i < nearUnits->count; i++) { WarEntity* targetEntity = nearUnits->items[i]; if (targetEntity && wu_canAttack(context, sourceEntity, targetEntity)) { we_meleeAttack(context, sourceEntity, targetEntity); } } WarEntityListFree(nearUnits); WarEntityList* walls = we_getEntitiesOfType(context, WAR_ENTITY_TYPE_WALL); for (s32 i = 0; i < walls->count; i++) { WarEntity* targetEntity = walls->items[i]; WarWallComponent* wall = we_getWallComponent(context, targetEntity); assert(wall); WarWallPieceList* pieces = &wall->pieces; for (s32 k = 0; k < pieces->count; k++) { WarWallPiece* piece = &pieces->items[k]; vec2 piecePosition = vec2i(piece->tilex, piece->tiley); if (vec2_distanceInTiles(targetTile, piecePosition) <= splashRadius) { we_meleeWallAttack(context, sourceEntity, targetEntity, piece); } } } } } void wproj_doRainOfFireProjectileSplashDamage(WarContext* context, WarEntity* entity, s32 splashRadius) { WarProjectileComponent* projectile = we_getProjectileComponent(context, entity); assert(projectile); vec2 targetTile = wmap_mapToTileCoordinatesV(projectile->target); WarEntityList* nearUnits = we_getNearUnits(context, targetTile, splashRadius); for (s32 i = 0; i < nearUnits->count; i++) { WarEntity* targetEntity = nearUnits->items[i]; if (targetEntity && !wst_isDead(context, targetEntity) && !wst_isGoingToDie(context, targetEntity) && !wst_isCollapsing(context, targetEntity) && !wst_isGoingToCollapse(context, targetEntity)) { we_takeDamage(context, targetEntity, 0, RAIN_OF_FIRE_PROJECTILE_DAMAGE); } } WarEntityListFree(nearUnits); WarEntityList* walls = we_getEntitiesOfType(context, WAR_ENTITY_TYPE_WALL); for (s32 i = 0; i < walls->count; i++) { WarEntity* targetEntity = walls->items[i]; WarWallComponent* wall = we_getWallComponent(context, targetEntity); assert(wall); WarWallPieceList* pieces = &wall->pieces; for (s32 k = 0; k < pieces->count; k++) { WarWallPiece* piece = &pieces->items[k]; vec2 piecePosition = vec2i(piece->tilex, piece->tiley); if (vec2_distanceInTiles(targetTile, piecePosition) <= splashRadius) { we_takeWallDamage(context, targetEntity, piece, 0, RAIN_OF_FIRE_PROJECTILE_DAMAGE); } } } } bool wproj_updateProjectilePosition(WarContext* context, WarEntity* entity) { WarTransformComponent* transform = we_getTransformComponent(context, entity); assert(transform); WarProjectileComponent* projectile = we_getProjectileComponent(context, entity); assert(projectile); vec2 position = transform->position; vec2 target = projectile->target; f32 speed = (f32)projectile->speed; speed = wmap_getMapScaledSpeed(context, speed); vec2 direction = vec2_subv(target, position); f32 directionLength = vec2_length(direction); vec2 step = vec2_mulf(vec2_normalize(direction), speed * context->deltaTime); f32 stepLength = vec2_length(step); if (directionLength < stepLength) { step = direction; } vec2 newPosition = vec2_addv(position, step); f32 distance = vec2_distance(newPosition, target); transform->position = newPosition; return distance < MOVE_EPSILON; } void wproj_updateProjectileSprite(WarContext* context, WarEntity* entity) { NOT_USED(context); WarTransformComponent* transform = we_getTransformComponent(context, entity); assert(transform); WarSpriteComponent* sprite = we_getSpriteComponent(context, entity); assert(sprite); WarProjectileComponent* projectile = we_getProjectileComponent(context, entity); assert(projectile); WarProjectileData data = wproj_getProjectileData(projectile->type); vec2 position = transform->position; vec2 origin = projectile->origin; vec2 target = projectile->target; f32 totalDistance = vec2_distance(origin, target); vec2 direction = vec2_subv(target, position); f32 directionLength = vec2_length(direction); f32 travelDistance = totalDistance - directionLength; f32 travelPercent = PERCENTABF(travelDistance, totalDistance); f32 angle = vec2_angleClockwise(VEC2_RIGHT, direction); // these are the angles at wich the frame index of the arrow // sprite needs to change and also where the x-scale needs to // be reversed f32 controlAngles[] = { 0, 45, 90, 135, 180, 225, 270, 315, 360 }; s32 frameIndices[] = { 2, 3, 4, 3, 2, 1, 0, 1, 2 }; s32 frameScales[] = { 1, 1, 1, -1, -1, -1, 1, 1, 1 }; s32 newFrameIndex = 0; vec2 newScale = VEC2_ONE; // find the current frame index and scale for (s32 i = 0; i < arrayLength(controlAngles); i++) { if (angle >= controlAngles[i] - 0.5f * 45 && angle < controlAngles[i] + 0.5f * 45) { newFrameIndex = frameIndices[i]; newScale.x *= frameScales[i]; break; } } // the new frame index have to be changed for some projectiles // based on the travel percent of the projectile // s32 frameCount = data.frameCount; bool reverseFromHalf = false; // some projectiles have sequences like: 0 1 0 or 0 1 2 1 0 // but the FIREBALL and RAIN_OF_FIRE projectiles have linear frame sequences if (projectile->type != WAR_PROJECTILE_FIREBALL && projectile->type != WAR_PROJECTILE_RAIN_OF_FIRE) { frameCount = frameCount * 2 - 1; reverseFromHalf = true; } s32 q = (100 / frameCount); for (s32 k = 1; k < frameCount; k++) { if (q * k >= travelPercent) break; if (reverseFromHalf && k > frameCount / 2) newFrameIndex -= data.frameStride; else newFrameIndex += data.frameStride; } transform->scale = newScale; sprite->frameIndex = newFrameIndex; } void wproj_updateRainOfFireProjectileSprite(WarContext* context, WarEntity* entity) { NOT_USED(context); WarTransformComponent* transform = we_getTransformComponent(context, entity); assert(transform); WarSpriteComponent* sprite = we_getSpriteComponent(context, entity); assert(sprite); WarProjectileComponent* projectile = we_getProjectileComponent(context, entity); assert(projectile); WarProjectileData data = wproj_getProjectileData(projectile->type); vec2 position = transform->position; vec2 origin = projectile->origin; vec2 target = projectile->target; s32 frameCount = data.frameCount; f32 totalDistance = vec2_distance(origin, target); vec2 direction = vec2_subv(target, position); f32 directionLength = vec2_length(direction); f32 travelDistance = totalDistance - directionLength; f32 travelPercent = PERCENTABF(travelDistance, totalDistance); // the new frame index have to be changed for some projectiles // based on the travel percent of the projectile // s32 newFrameIndex = 0; s32 q = (100 / frameCount); for (s32 k = 1; k < frameCount; k++) { if (q * k >= travelPercent) break; newFrameIndex += data.frameStride; } sprite->frameIndex = newFrameIndex; } void wproj_updateProjectile(WarContext* context, WarEntity* entity) { if (we_isComponentEnabled(context, entity, COMP_SPRITE) && we_isComponentEnabled(context, entity, COMP_PROJECTILE)) { WarProjectileComponent* projectile = we_getProjectileComponent(context, entity); assert(projectile); if (projectile->type == WAR_PROJECTILE_RAIN_OF_FIRE) { if (!wproj_updateProjectilePosition(context, entity)) { wproj_updateRainOfFireProjectileSprite(context, entity); } else { wproj_doRainOfFireProjectileSplashDamage(context, entity, NEAR_RAIN_OF_FIRE_RADIUS); WarEntity* animEntity = we_createEntity(context, WAR_ENTITY_TYPE_ANIMATION, true); we_addAnimationsComponent(context, animEntity); wanim_createRainOfFireExplosionAnimation(context, animEntity, projectile->target); wa_createAudioWithPosition(context, CREATE_AUDIO_ARGS_INIT(.audioId=WAR_CATAPULT_FIRE_EXPLOSION, .position=projectile->target, .hasPosition=true, .loop=false)); we_removeEntityById(context, entity->id); } } else { if (!wproj_updateProjectilePosition(context, entity)) { wproj_updateProjectileSprite(context, entity); } else { if (projectile->type == WAR_PROJECTILE_CATAPULT) { wproj_doProjectileSplashDamage(context, entity, NEAR_CATAPULT_RADIUS); WarEntity* animEntity = we_createEntity(context, WAR_ENTITY_TYPE_ANIMATION, true); we_addAnimationsComponent(context, animEntity); wanim_createExplosionAnimation(context, animEntity, projectile->target); wa_createAudioWithPosition(context, CREATE_AUDIO_ARGS_INIT(.audioId=WAR_CATAPULT_FIRE_EXPLOSION, .position=projectile->target, .hasPosition=true, .loop=false)); } else { wproj_doProjectileTargetDamage(context, entity); if (projectile->type == WAR_PROJECTILE_ARROW) wa_createAudioWithPosition(context, CREATE_AUDIO_ARGS_INIT(.audioId=WAR_ARROW_SPEAR_HIT, .position=projectile->target, .hasPosition=true, .loop=false)); } we_removeEntityById(context, entity->id); } } } } WarEntity* wproj_createProjectile(WarContext* context, WarProjectileType type, WarEntityId sourceEntityId, WarEntityId targetEntityId, vec2 origin, vec2 target) { WarProjectileData data = wproj_getProjectileData(type); WarEntity* projectile = we_createEntity(context, WAR_ENTITY_TYPE_PROJECTILE, true); we_addTransformComponent(context, projectile, WAR_TRANSFORM_COMPONENT_INIT( .position = origin, )); we_addSpriteComponentFromResource(context, projectile, imageResourceRef(data.resourceIndex)); we_addProjectileComponent(context, projectile, WAR_PROJECTILE_COMPONENT_INIT( .type = type, .sourceEntityId = sourceEntityId, .targetEntityId = targetEntityId, .origin = origin, .target = target, .speed = data.speed, )); return projectile; } ================================================ FILE: src/war_projectiles.h ================================================ #pragma once #include "common.h" #include "war.h" #include "war_math.h" #include "war_units.h" WarEntity* wproj_createProjectile( WarContext* context, WarProjectileType type, WarEntityId sourceEntityId, WarEntityId targetEntityId, vec2 origin, vec2 target); ================================================ FILE: src/war_render.c ================================================ #include "war_render.h" #include // --------------------------------------------------------------------------- // Render state stack (replaces nvgSave/nvgRestore/nvgTranslate/nvgScale/nvgGlobalAlpha) // --------------------------------------------------------------------------- void wr_init(WarContext* context) { context->renderStateTop = 0; context->renderState[0].offsetX = 0; context->renderState[0].offsetY = 0; context->renderState[0].scaleX = 1; context->renderState[0].scaleY = 1; context->renderState[0].alpha = 1; } static WarRenderState* wr_renderGetState(WarContext* context) { return &context->renderState[context->renderStateTop]; } void wr_save(WarContext* context) { assert(context->renderStateTop + 1 < MAX_RENDER_STATE_STACK); context->renderState[context->renderStateTop + 1] = context->renderState[context->renderStateTop]; context->renderStateTop++; } void wr_restore(WarContext* context) { assert(context->renderStateTop > 0); context->renderStateTop--; } void wr_translate(WarContext* context, f32 tx, f32 ty) { WarRenderState* s = wr_renderGetState(context); s->offsetX += tx * s->scaleX; s->offsetY += ty * s->scaleY; } void wr_scale(WarContext* context, f32 sx, f32 sy) { WarRenderState* s = wr_renderGetState(context); s->scaleX *= sx; s->scaleY *= sy; } void wr_globalAlpha(WarContext* context, f32 a) { WarRenderState* s = wr_renderGetState(context); s->alpha *= a; } // --------------------------------------------------------------------------- // Transform helpers — map local coordinates to screen coordinates // --------------------------------------------------------------------------- static SDL_FRect renderTransformRect(WarContext* context, rect r) { WarRenderState* s = wr_renderGetState(context); f32 sx = s->scaleX; f32 sy = s->scaleY; f32 x = s->offsetX + r.x * sx; f32 y = s->offsetY + r.y * sy; f32 w = r.width * sx; f32 h = r.height * sy; // if scale is negative, flip the origin if (w < 0) { x += w; w = -w; } if (h < 0) { y += h; h = -h; } return (SDL_FRect){ x, y, w, h }; } static void wr_renderTransformPoint(WarContext* context, f32 lx, f32 ly, f32* ox, f32* oy) { WarRenderState* s = wr_renderGetState(context); *ox = s->offsetX + lx * s->scaleX; *oy = s->offsetY + ly * s->scaleY; } // --------------------------------------------------------------------------- // Primitive rendering (replaces nvgFillRect, nvgStrokeRect, nvgStrokeLine, etc.) // --------------------------------------------------------------------------- static void wr_renderSetDrawColor(WarContext* context, WarColor color) { WarRenderState* s = wr_renderGetState(context); u8 a = (u8)(color.a * s->alpha); SDL_SetRenderDrawColor(context->renderer, color.r, color.g, color.b, a); } void wr_fillRect(WarContext* context, rect r, WarColor color) { SDL_FRect dr = renderTransformRect(context, r); wr_renderSetDrawColor(context, color); SDL_SetRenderDrawBlendMode(context->renderer, SDL_BLENDMODE_BLEND); SDL_RenderFillRect(context->renderer, &dr); } void wr_fillRects(WarContext* context, s32 count, rect r[], WarColor color) { for (s32 i = 0; i < count; i++) wr_fillRect(context, r[i], color); } void wr_strokeRect(WarContext* context, rect r, WarColor color, f32 width) { NOT_USED(width); // SDL_RenderRect always draws 1px lines; good enough at 320x200 SDL_FRect dr = renderTransformRect(context, r); wr_renderSetDrawColor(context, color); SDL_SetRenderDrawBlendMode(context->renderer, SDL_BLENDMODE_BLEND); SDL_RenderRect(context->renderer, &dr); } void wr_strokeLine(WarContext* context, vec2 p1, vec2 p2, WarColor color, f32 width) { NOT_USED(width); f32 x1, y1, x2, y2; wr_renderTransformPoint(context, p1.x, p1.y, &x1, &y1); wr_renderTransformPoint(context, p2.x, p2.y, &x2, &y2); wr_renderSetDrawColor(context, color); SDL_SetRenderDrawBlendMode(context->renderer, SDL_BLENDMODE_BLEND); SDL_RenderLine(context->renderer, x1, y1, x2, y2); } // --------------------------------------------------------------------------- // Image / sub-image rendering (replaces nvgRenderSubImage and batch system) // --------------------------------------------------------------------------- void wr_subImage(WarContext* context, SDL_Texture* texture, rect rs, rect rd, vec2 scale) { if (!texture) return; WarRenderState* s = wr_renderGetState(context); // Combine the per-call scale with the render-state scale f32 combinedSX = s->scaleX * scale.x; f32 combinedSY = s->scaleY * scale.y; // Determine flip flags from sign of combined scale SDL_FlipMode flip = SDL_FLIP_NONE; if (combinedSX < 0 && combinedSY < 0) flip = (SDL_FlipMode)(SDL_FLIP_HORIZONTAL | SDL_FLIP_VERTICAL); else if (combinedSX < 0) flip = SDL_FLIP_HORIZONTAL; else if (combinedSY < 0) flip = SDL_FLIP_VERTICAL; f32 absSX = combinedSX < 0 ? -combinedSX : combinedSX; f32 absSY = combinedSY < 0 ? -combinedSY : combinedSY; f32 dx = s->offsetX + rd.x * s->scaleX; f32 dy = s->offsetY + rd.y * s->scaleY; f32 dw = rd.width * absSX; f32 dh = rd.height * absSY; // if state scale is negative, adjust origin if (s->scaleX < 0) dx -= dw; if (s->scaleY < 0) dy -= dh; SDL_FRect srcRect = { rs.x, rs.y, rs.width, rs.height }; SDL_FRect dstRect = { dx, dy, dw, dh }; // Apply alpha from render state u8 alpha = (u8)(s->alpha * 255); SDL_SetTextureAlphaMod(texture, alpha); SDL_SetTextureBlendMode(texture, SDL_BLENDMODE_BLEND); if (flip != SDL_FLIP_NONE) SDL_RenderTextureRotated(context->renderer, texture, &srcRect, &dstRect, 0.0, NULL, flip); else SDL_RenderTexture(context->renderer, texture, &srcRect, &dstRect); } // --------------------------------------------------------------------------- // Color helper (replaces wr_getColorFromList which returned NVGcolor) // --------------------------------------------------------------------------- WarColor wr_getColorFromList(s32 index) { const u32 colors[] = { 0xE52B50, // Amaranth 0xFFBF00, // Amber 0x9966CC, // Amethyst 0xFBCEB1, // Apricot 0x7FFFD4, // Aquamarine 0x007FFF, // Azure 0x89CFF0, // Baby blue 0xF5F5DC, // Beige 0x000000, // Black 0x0000FF, // Blue 0x0095B6, // Blue-green 0x8A2BE2, // Blue-violet 0xDE5D83, // Blush 0xCD7F32, // Bronze 0x964B00, // Brown 0x800020, // Burgundy 0x702963, // Byzantium 0x960018, // Carmine 0xDE3163, // Cerise 0x007BA7, // Cerulean 0xF7E7CE, // Champagne 0x7FFF00, // Chartreuse green 0x7B3F00, // Chocolate 0x0047AB, // Cobalt blue 0x6F4E37, // Coffee 0xB87333, // Copper 0xF88379, // Coral 0xDC143C, // Crimson 0x00FFFF, // Cyan 0xEDC9AF, // Desert sand 0x7DF9FF, // Electric blue 0x50C878, // Emerald 0x00FF3F, // Erin 0xFFD700, // Gold 0x808080, // Gray 0x00FF00, // Green 0x3FFF00, // Harlequin 0x4B0082, // Indigo 0xFFFFF0, // Ivory 0x00A86B, // Jade 0x29AB87, // Jungle green 0xB57EDC, // Lavender 0xFFF700, // Lemon 0xC8A2C8, // Lilac 0xBFFF00, // Lime 0xFF00FF, // Magenta 0xFF00AF, // Magenta rose 0x800000, // Maroon 0xE0B0FF, // Mauve 0x000080, // Navy blue 0xCC7722, // Ocher 0x808000, // Olive 0xFFA500, // Orange 0xFF4500, // Orange-red 0xDA70D6, // Orchid 0xFFE5B4, // Peach 0xD1E231, // Pear 0xCCCCFF, // Periwinkle 0x1C39BB, // Persian blue 0xFFC0CB, // Pink 0x8E4585, // Plum 0x003153, // Prussian blue 0xCC8899, // Puce 0x800080, // Purple 0xE30B5C, // Raspberry 0xFF0000, // Red 0xC71585, // Red-violet 0xFF007F, // Rose 0xE0115F, // Ruby 0xFA8072, // Salmon 0x92000A, // Sangria 0x0F52BA, // Sapphire 0xFF2400, // Scarlet 0xC0C0C0, // Silver 0x708090, // Slate gray 0xA7FC00, // Spring bud 0x00FF7F, // Spring green 0xD2B48C, // Tan 0x483C32, // Taupe 0x008080, // Teal 0x40E0D0, // Turquoise 0xEE82EE, // Violet 0x40826D, // Viridian 0xFFFFFF, // White 0xFFFF00, // Yellow }; u32 rgb = colors[index % arrayLength(colors)]; WarColor color; color.r = (rgb >> 16) & 0xFF; color.g = (rgb >> 8) & 0xFF; color.b = (rgb >> 0) & 0xFF; color.a = 255; return color; } ================================================ FILE: src/war_render.h ================================================ #pragma once #include "SDL3/SDL.h" #include "war.h" #include "war_color.h" #include "war_math.h" void wr_init(WarContext* context); void wr_save(WarContext* context); void wr_restore(WarContext* context); void wr_translate(WarContext* context, f32 tx, f32 ty); void wr_scale(WarContext* context, f32 sx, f32 sy); void wr_globalAlpha(WarContext* context, f32 a); void wr_fillRect(WarContext* context, rect r, WarColor color); void wr_fillRects(WarContext* context, s32 count, rect r[], WarColor color); void wr_strokeRect(WarContext* context, rect r, WarColor color, f32 width); void wr_strokeLine(WarContext* context, vec2 p1, vec2 p2, WarColor color, f32 width); void wr_subImage(WarContext* context, SDL_Texture* texture, rect rs, rect rd, vec2 scale); WarColor wr_getColorFromList(s32 index); ================================================ FILE: src/war_resources.c ================================================ #include "war_resources.h" #include #ifdef SHL_MZ_DEBUG #include "shl/memzone_audit.h" #else #include "shl/memzone.h" #endif #include "shl/memory_buffer.h" #include "shl/wstr.h" #include "war_log.h" #include "war_audio.h" #define readu8(arr, index) (arr[index]) #define reads16(arr, index) (*(s16*)((arr) + (index))) #define readu16(arr, index) (*(u16*)((arr) + (index))) #define reads32(arr, index) (*(s32*)((arr) + (index))) #define readu32(arr, index) (*(u32*)((arr) + (index))) WarResource* wres_getOrCreateResource(WarContext* context, s32 index) { assert(index >= 0 && index < MAX_RESOURCES_COUNT); if (!context->resources[index]) { logInfo("Creating resource: %d", index); context->resources[index] = (WarResource*)wm_alloc(sizeof(WarResource)); } return context->resources[index]; } void wres_getPalette(WarContext* context, s32 palette1Index, s32 palette2Index, u8 *paletteData) { memset(paletteData, 0, PALETTE_LENGTH); if (palette1Index) { WarResource* palette1 = wres_getOrCreateResource(context, palette1Index); u8 *palette1Data = palette1->paletteData.colors; memcpy(paletteData, palette1Data, PALETTE_LENGTH); } // probably only the palettes 191, 194, 197 need this to use a second palette for the background // for now leave it whenever there is specified a second palette on the entry if (palette2Index) { WarResource* palette2 = wres_getOrCreateResource(context, palette2Index); u8 *palette2Data = palette2->paletteData.colors; for (s32 i = 0; i < 128; ++i) { if (paletteData[i * 3 + 0] == 252 && paletteData[i * 3 + 1] == 0 && paletteData[i * 3 + 2] == 252) { paletteData[i * 3 + 0] = palette2Data[i * 3 + 0]; paletteData[i * 3 + 1] = palette2Data[i * 3 + 1]; paletteData[i * 3 + 2] = palette2Data[i * 3 + 2]; } } for (s32 i = 128; i < 256; ++i) { if (!(palette2Data[i * 3 + 0] == 252 && palette2Data[i * 3 + 1] == 0 && palette2Data[i * 3 + 2] == 252)) { paletteData[i * 3 + 0] = palette2Data[i * 3 + 0]; paletteData[i * 3 + 1] = palette2Data[i * 3 + 1]; paletteData[i * 3 + 2] = palette2Data[i * 3 + 2]; } } } } void wres_loadPaletteResource(WarContext *context, DatabaseEntry *entry) { s32 index = entry->index; WarRawResource rawResource = context->warFile->resources[index]; if (rawResource.placeholder) { logInfo("Placeholder resource found at: %d", index); return; } if (rawResource.length < PALETTE_LENGTH) { rawResource.data = (u8*)wm_realloc(rawResource.data, PALETTE_LENGTH); memset(rawResource.data + rawResource.length, 0, PALETTE_LENGTH - rawResource.length); } WarResource *resource = wres_getOrCreateResource(context, index); resource->type = WAR_RESOURCE_TYPE_PALETTE; for (s32 i = 0; i < PALETTE_LENGTH; ++i) { resource->paletteData.colors[i] = rawResource.data[i] * 4; } // this is a hack in palette #255 because the UI graphics of the unit info // is wrong when using the palette as it came from the file, // or at least I didn't knew how to decode it. if (index == 255) { resource->paletteData.colors[0] = 0; resource->paletteData.colors[1] = 0; resource->paletteData.colors[2] = 0; resource->paletteData.colors[190 * 3 + 0] = 176; resource->paletteData.colors[190 * 3 + 1] = 184; resource->paletteData.colors[190 * 3 + 2] = 208; resource->paletteData.colors[191 * 3 + 0] = 208; resource->paletteData.colors[191 * 3 + 1] = 208; resource->paletteData.colors[191 * 3 + 2] = 236; resource->paletteData.colors[214 * 3 + 0] = 204; resource->paletteData.colors[214 * 3 + 1] = 212; resource->paletteData.colors[214 * 3 + 2] = 180; resource->paletteData.colors[208 * 3 + 0] = 32; resource->paletteData.colors[208 * 3 + 1] = 32; resource->paletteData.colors[208 * 3 + 2] = 44; resource->paletteData.colors[211 * 3 + 0] = 80; resource->paletteData.colors[211 * 3 + 1] = 104; resource->paletteData.colors[211 * 3 + 2] = 104; resource->paletteData.colors[184 * 3 + 0] = 12; resource->paletteData.colors[184 * 3 + 1] = 20; resource->paletteData.colors[184 * 3 + 2] = 12; resource->paletteData.colors[185 * 3 + 0] = 28; resource->paletteData.colors[185 * 3 + 1] = 32; resource->paletteData.colors[185 * 3 + 2] = 32; resource->paletteData.colors[186 * 3 + 0] = 56; resource->paletteData.colors[186 * 3 + 1] = 64; resource->paletteData.colors[186 * 3 + 2] = 68; resource->paletteData.colors[189 * 3 + 0] = 144; resource->paletteData.colors[189 * 3 + 1] = 156; resource->paletteData.colors[189 * 3 + 2] = 176; } // this palette has an ugly pink color (color #150) // that is showing in the unit portraits, so change it to dark gray else if (index == 217) { resource->paletteData.colors[96 * 3 + 0] = 108; resource->paletteData.colors[96 * 3 + 1] = 72; resource->paletteData.colors[96 * 3 + 2] = 40; resource->paletteData.colors[150 * 3 + 0] = 46; resource->paletteData.colors[150 * 3 + 1] = 54; resource->paletteData.colors[150 * 3 + 2] = 54; resource->paletteData.colors[158 * 3 + 0] = 40; resource->paletteData.colors[158 * 3 + 1] = 64; resource->paletteData.colors[158 * 3 + 2] = 112; resource->paletteData.colors[215 * 3 + 0] = 32; resource->paletteData.colors[215 * 3 + 1] = 20; resource->paletteData.colors[215 * 3 + 2] = 24; } } void wres_loadImageResource(WarContext *context, DatabaseEntry *entry) { u8 paletteData[PALETTE_LENGTH]; wres_getPalette(context, entry->param1, entry->param2, paletteData); s32 index = entry->index; WarRawResource rawResource = context->warFile->resources[index]; if (rawResource.placeholder) { logInfo("Placeholder resource found at: %d", index); return; } u16 width = readu16(rawResource.data, 0); u16 height = readu16(rawResource.data, 2); u8 *pixels = (u8*)wm_alloc(width * height * 4 * sizeof(u8)); for (s32 i = 0; i < width * height; ++i) { u32 colorIndex = readu8(rawResource.data, 4 + i); pixels[i * 4 + 0] = readu8(paletteData, colorIndex * 3 + 0); pixels[i * 4 + 1] = readu8(paletteData, colorIndex * 3 + 1); pixels[i * 4 + 2] = readu8(paletteData, colorIndex * 3 + 2); // assuming that colorIndex == 0 is the transparent color if (pixels[i * 4 + 0] > 0 || pixels[i * 4 + 1] > 0 || pixels[i * 4 + 2] > 0 || colorIndex != 0) { pixels[i * 4 + 3] = 255; } } WarResource *resource = wres_getOrCreateResource(context, index); resource->type = WAR_RESOURCE_TYPE_IMAGE; resource->imageData.width = width; resource->imageData.height = height; resource->imageData.pixels = pixels; } void wres_loadSpriteResource(WarContext *context, DatabaseEntry *entry) { u8 paletteData[PALETTE_LENGTH]; wres_getPalette(context, entry->param1, entry->param2, paletteData); s32 index = entry->index; WarRawResource rawResource = context->warFile->resources[index]; if (rawResource.placeholder) { logInfo("Placeholder resource found at: %d", index); return; } u16 framesCount = readu16(rawResource.data, 0); u8 frameWidth = readu8(rawResource.data, 2); u8 frameHeight = readu8(rawResource.data, 3); WarResource *resource = wres_getOrCreateResource(context, index); for (s32 i = 0; i < framesCount; ++i) { WarSpriteFrame *frame = &resource->spriteData.frames[i]; frame->dx = readu8(rawResource.data, 4 + i * 8 + 0); frame->dy = readu8(rawResource.data, 4 + i * 8 + 1); frame->w = readu8(rawResource.data, 4 + i * 8 + 2); frame->h = readu8(rawResource.data, 4 + i * 8 + 3); frame->off = readu32(rawResource.data, 4 + i * 8 + 4); frame->data = (u8*)wm_alloc(frameWidth * frameHeight * 4 * sizeof(u8)); // found in war1tool.c, don't know if is needed // if (off < 0) { // High bit of width // off &= 0x7FFFFFFF; // w += 256; // } } for (s32 i = 0; i < framesCount; ++i) { WarSpriteFrame* frame = &resource->spriteData.frames[i]; u32 off = frame->off; for (s32 y = frame->dy; y < (frame->dy + frame->h); ++y) { for (s32 x = frame->dx; x < (frame->dx + frame->w); ++x) { u32 pixel = (x + y * frameWidth) * 4; u32 colorIndex = rawResource.data[off++]; frame->data[pixel + 0] = readu8(paletteData, colorIndex * 3 + 0); frame->data[pixel + 1] = readu8(paletteData, colorIndex * 3 + 1); frame->data[pixel + 2] = readu8(paletteData, colorIndex * 3 + 2); // assuming that colorIndex == 0 is the transparent color if (frame->data[pixel + 0] > 0 || frame->data[pixel + 1] > 0 || frame->data[pixel + 2] > 0 || colorIndex != 0) { // Make shadow not so dark // // Altough it seem that the original game has (0, 0, 0) as // the color for shadows // // if (colorIndex == 96) // frame->data[pixel + 3] = 150; frame->data[pixel + 3] = 255; } } } } resource->type = WAR_RESOURCE_TYPE_SPRITE; resource->spriteData.framesCount = framesCount; resource->spriteData.frameWidth = frameWidth; resource->spriteData.frameHeight = frameHeight; } s32 wres_loadStartEntities(WarResource* resource, WarRawResource* rawResource, s32 offset) { resource->levelInfo.startEntitiesCount = 0; while (offset < (s32)rawResource->length) { u16 val = readu16(rawResource->data, offset); if (val == 0xFFFF) { break; } WarLevelUnit* startEntity = &resource->levelInfo.startEntities[resource->levelInfo.startEntitiesCount]; startEntity->x = readu8(rawResource->data, offset + 0) / 2; startEntity->y = readu8(rawResource->data, offset + 1) / 2; startEntity->type = readu8(rawResource->data, offset + 2); startEntity->player = readu8(rawResource->data, offset + 3); offset += 4; if (startEntity->type == WAR_UNIT_GOLDMINE) { startEntity->resourceKind = WAR_RESOURCE_GOLD; startEntity->amount = readu16(rawResource->data, offset); offset += 2; } resource->levelInfo.startEntitiesCount++; } return offset; } s32 wres_loadStartRoads(WarResource* resource, WarRawResource* rawResource, s32 offset) { resource->levelInfo.startRoadsCount = 0; while (offset < (s32)rawResource->length) { u16 val = readu16(rawResource->data, offset); if (val == 0xFFFF) { break; } WarLevelConstruct* construct = &resource->levelInfo.startRoads[resource->levelInfo.startRoadsCount]; construct->type = WAR_CONSTRUCT_ROAD; construct->x1 = readu8(rawResource->data, offset + 0) / 2; construct->y1 = readu8(rawResource->data, offset + 1) / 2; construct->x2 = readu8(rawResource->data, offset + 2) / 2; construct->y2 = readu8(rawResource->data, offset + 3) / 2; construct->player = readu8(rawResource->data, offset + 4); offset += 5; resource->levelInfo.startRoadsCount++; } return offset; } s32 wres_loadStartWalls(WarResource* resource, WarRawResource* rawResource, s32 offset) { resource->levelInfo.startWallsCount = 0; while (offset < (s32)rawResource->length) { u16 val = readu16(rawResource->data, offset); if (val == 0xFFFF) { break; } WarLevelConstruct* construct = &resource->levelInfo.startWalls[resource->levelInfo.startWallsCount]; construct->type = WAR_CONSTRUCT_WALL; construct->x1 = readu8(rawResource->data, offset + 0) / 2; construct->y1 = readu8(rawResource->data, offset + 1) / 2; construct->x2 = readu8(rawResource->data, offset + 2) / 2; construct->y2 = readu8(rawResource->data, offset + 3) / 2; construct->player = readu8(rawResource->data, offset + 4); offset += 5; resource->levelInfo.startWallsCount++; } return offset; } s32 wres_loadCustomStartGoldmines(WarResource* resource, WarRawResource* rawResource, s32 offset) { resource->levelInfo.startGoldminesCount = 0; while (offset < (s32)rawResource->length) { u16 val = readu16(rawResource->data, offset); if (val == 0xFFFF) { break; } WarLevelUnit* startGoldmine = &resource->levelInfo.startGoldmines[resource->levelInfo.startGoldminesCount]; startGoldmine->x = readu8(rawResource->data, offset + 0) / 2; startGoldmine->y = readu8(rawResource->data, offset + 1) / 2; startGoldmine->type = WAR_UNIT_GOLDMINE;; startGoldmine->player = 4; offset += 4; resource->levelInfo.startGoldminesCount++; } return offset; } s32 wres_loadCustomStartEntities(WarResource* resource, WarRawResource* rawResource, s32 offset, WarCustomMapConfiguration* configuration, u8 player) { NOT_USED(resource); while (offset < (s32)rawResource->length) { u16 val = readu16(rawResource->data, offset); if (val == 0xFFFF) { break; } WarLevelUnit* startEntity = &configuration->startEntities[configuration->startEntitiesCount]; startEntity->x = readu8(rawResource->data, offset + 0) / 2; startEntity->y = readu8(rawResource->data, offset + 1) / 2; startEntity->type = readu8(rawResource->data, offset + 2); startEntity->player = player; offset += 4; configuration->startEntitiesCount++; } return offset; } void wres_loadLevelInfo(WarContext *context, DatabaseEntry *entry) { s32 index = entry->index; WarMapTilesetType tilesetType = (WarMapTilesetType)entry->param1; bool isCustomMap = entry->param2; WarRawResource rawResource = context->warFile->resources[index]; if (rawResource.placeholder) { logInfo("Placeholder resource found at: %d", index); return; } u32 allowId = readu32(rawResource.data, 0); WarResource *resource = wres_getOrCreateResource(context, index); resource->type = WAR_RESOURCE_TYPE_LEVEL_INFO; resource->levelInfo.allowId = allowId; resource->levelInfo.allowedHumanUnits = 1; resource->levelInfo.allowedOrcsUnits = 1; resource->levelInfo.tilesetType = tilesetType; resource->levelInfo.customMap = isCustomMap; memset(resource->levelInfo.allowedFeatures, 0, MAX_FEATURES_COUNT); for(s32 f = 0; f < MAX_FEATURES_COUNT; f++) { // the feature is allowed if the corresponding bit is set if (allowId & (1 << f)) { resource->levelInfo.allowedFeatures[f] = 1; } } // 0x0004 - 0x0008: 5xByte: Upgrade: Ranged Weapons, arrows / spears. // 0x0009 - 0x000D: 5xByte: Upgrade: Melee Weapons, swords / axes. // 0x000E - 0x0012: 5xByte: Upgrade: Rider speed, horses / wolves. // 0x0013 - 0x0017: 5xByte: Spell: summon scorpions / summon spiders. // 0x0018 - 0x001C: 5xByte: Spell: rain of fire / cloud of poison. // 0x001D - 0x0021: 5xByte: Spell: summon water elemental / summon daemon. // 0x0022 - 0x0026: 5xByte: Spell: healing / raise dead. // 0x0027 - 0x002B: 5xByte: Spell: far seeing / dark vision. // 0x002C - 0x0030: 5xByte: Spell: invisibility / unholy armor. // 0x0031 - 0x0035: 5xByte: Upgrade: Shields. for(s32 upgrade = 0; upgrade < MAX_UPGRADES_COUNT; upgrade++) { bool allowedUpgrade = true; if (upgrade >= 3 && upgrade <= 8) { // if it's a spell upgrade check the allowed features, because spells may not be allowed. // offset of spells in allowed features is 15 // usefully, they are not in the same order in the allowid as they // are in the list of researched stuff, that's the (upgrade + 3) % 6 are for. u8 allowed = resource->levelInfo.allowedFeatures[15 + (upgrade + 3) % 6]; allowedUpgrade = (allowed > 0); } if (allowedUpgrade) { for(s32 player = 0; player < 5; player++) { u8 value = readu8(rawResource.data, 4 + upgrade * 5 + player); resource->levelInfo.allowedUpgrades[upgrade][player] = value; } } } // 0x005C - 0x0069: 5xDWord: Lumber for each player. for(s32 i = 0; i < 5; i++) { resource->levelInfo.lumber[i] = readu32(rawResource.data, 0x5C + i * 4); } // 0x0070 - 0x0083: 5xDWord: Gold for each player. for(s32 i = 0; i < 5; i++) { resource->levelInfo.gold[i] = readu32(rawResource.data, 0x70 + i * 4); } // 0xCC, 0xCE => Starting position of unit (divide by 2) (ushort) resource->levelInfo.startX = readu16(rawResource.data, 0xCC) / 2; resource->levelInfo.startY = readu16(rawResource.data, 0xCE) / 2; // 0x84 - 0x88: players info u32 race = readu32(rawResource.data, 0x84); resource->levelInfo.races[0] = (race >= (1 << 16)) ? WAR_RACE_HUMANS : WAR_RACE_ORCS; for(s32 i = 1; i < 4; i++) { resource->levelInfo.races[i] = (resource->levelInfo.races[0] == WAR_RACE_HUMANS) ? WAR_RACE_ORCS : WAR_RACE_HUMANS; } // 0x94: objectives u32 objectivesOffset = readu16(rawResource.data, 0x94); if (objectivesOffset) { strcpy(resource->levelInfo.objectives, (char*)(rawResource.data + objectivesOffset)); } // next level resource index: *0xCA - 2 u16 nextLevelIndex = readu16(rawResource.data, 0xCA); if (nextLevelIndex != 0 && nextLevelIndex != 0xFFFF) { resource->levelInfo.nextLevelIndex = nextLevelIndex - 2; } // visual resource index: *0xD0 - 2 u16 visualIndex = readu16(rawResource.data, 0xD0); if (visualIndex != 0 && visualIndex != 0xFFFF) { resource->levelInfo.visualIndex = visualIndex - 2; } // passable resource index: *0xD2 - 2 u16 passableIndex = readu16(rawResource.data, 0xD2); if (passableIndex != 0 && passableIndex != 0xFFFF) { resource->levelInfo.passableIndex = passableIndex - 2; } // tileset resource index: *0xD4 - 2 u16 tilesetIndex = readu16(rawResource.data, 0xD4); if (tilesetIndex != 0 && tilesetIndex != 0xFFFF) { resource->levelInfo.tilesetIndex = tilesetIndex - 2; } // tiles resource index: *0xD6 - 2 u16 tilesIndex = readu16(rawResource.data, 0xD6); if (tilesIndex != 0 && tilesIndex != 0xFFFF) { resource->levelInfo.tilesIndex = tilesIndex - 2; } // palette resource index: *0xD8 - 2 u16 paletteIndex = readu16(rawResource.data, 0xD8); if (paletteIndex != 0 && paletteIndex != 0xFFFF) { resource->levelInfo.paletteIndex = paletteIndex - 2; } // dynamic data: 0xE3 s32 offset = 0xE3; while (readu32(rawResource.data, offset) != 0xFFFFFFFF) { offset++; } // skip marker 0xFFFF offset += 4; // offset of the units and construction information offset = readu16(rawResource.data, offset); if (isCustomMap) { // It seems that the structure of custom map is different of the structure for the levels. // It has the the placeholders for the possible configurations of starting positions. // Warcraft 1 only supports one vs one custom maps, and every custom map I got has four // starting positions, so there are 6 possible configurations. // // offset of gold mines // FF FF // offset of player 1 in first configuration // offset of player 2 in first configuration // FF FF // offset of player 1 in second configuration // offset of player 2 in second configuration // FF FF // ... the above repeats 4 more times for a total of 6 configurations // // the goldmines data is in the form of a collection of entities without // the gold amount data that ends with a 0xFFFF marker. // the players configuration data is just the collection of starting entities // followed by a marker 0xFFFF and then the collection of roads for that player. // The starting entities are usually (at least in the DATA file I have) just // a placeholder town hall and a placeholder farm that, I'm guessing at the // start of the map it gets replaced by the actual race townhall and farm // s32 goldminesOffset = readu16(rawResource.data, offset); wres_loadCustomStartGoldmines(resource, &rawResource, goldminesOffset); offset += 2; // skip marker 0xFFFF offset += 2; while (offset < goldminesOffset) { WarCustomMapConfiguration* configuration = &resource->levelInfo.startConfigurations[resource->levelInfo.startConfigurationsCount]; configuration->startEntitiesCount = 0; s32 offset0 = readu16(rawResource.data, offset); offset0 = wres_loadCustomStartEntities(resource, &rawResource, offset0, configuration, 0); offset0 = wres_loadStartRoads(resource, &rawResource, offset0 + 2); offset += 2; s32 offset1 = readu16(rawResource.data, offset); offset1 = wres_loadCustomStartEntities(resource, &rawResource, offset1, configuration, 1); offset1 = wres_loadStartRoads(resource, &rawResource, offset1 + 2); offset += 2; // skip marker 0xFFFF offset += 2; resource->levelInfo.startConfigurationsCount++; } } else { // starting units offset = wres_loadStartEntities(resource, &rawResource, offset); // skip marker 0xFFFF offset += 2; // roads offset = wres_loadStartRoads(resource, &rawResource, offset); // skip marker 0xFFFF offset += 2; // walls offset = wres_loadStartWalls(resource, &rawResource, offset); // skip marker 0xFFFF offset += 2; } } void wres_loadLevelVisual(WarContext *context, DatabaseEntry *entry) { s32 index = entry->index; WarRawResource rawResource = context->warFile->resources[index]; if (rawResource.placeholder) { logInfo("Placeholder resource found at: %d", index); return; } WarResource *resource = wres_getOrCreateResource(context, index); resource->type = WAR_RESOURCE_TYPE_LEVEL_VISUAL; for(s32 i = 0; i < MAP_TILES_WIDTH * MAP_TILES_HEIGHT; i++) { resource->levelVisual.data[i] = readu16(rawResource.data, i * 2); } } void wres_loadLevelPassable(WarContext *context, DatabaseEntry *entry) { s32 index = entry->index; WarRawResource rawResource = context->warFile->resources[index]; if (rawResource.placeholder) { logInfo("Placeholder resource found at: %d", index); return; } WarResource *resource = wres_getOrCreateResource(context, index); resource->type = WAR_RESOURCE_TYPE_LEVEL_PASSABLE; for(s32 i = 0; i < MAP_TILES_WIDTH * MAP_TILES_HEIGHT; i++) { // 128 -> wood, 64 -> water, 16 -> bridge, 0 -> empty resource->levelPassable.data[i] = readu16(rawResource.data, i * 2); } } void wres_loadTileset(WarContext *context, DatabaseEntry *entry) { s32 index = entry->index; WarRawResource rawResource = context->warFile->resources[index]; if (rawResource.placeholder) { logInfo("Placeholder resource found at: %d", index); return; } WarResource *tiles = wres_getOrCreateResource(context, entry->param1); // Local scratch zone for the temporary indexed-colour tile buffer. memzone_t* scratch = mz_init(TILESET_WIDTH * TILESET_HEIGHT + 1024); u8 *data = (u8*)mz_alloc(scratch, TILESET_WIDTH * TILESET_HEIGHT); u32 tilesCount = rawResource.length / 8; for(u32 i = 0; i < tilesCount; i++) { for(s32 my = 0; my < 2; my++) { for(s32 mx = 0; mx < 2; mx++) { u16 offset = readu16(rawResource.data, i * 8 + (my * 2 + mx) * 2); bool flipX = (offset & 0x02); bool flipY = (offset & 0x01); offset = (u16)((offset & 0xFFFC) << 1); static const s32 flip[] = { 7, 6, 5, 4, 3, 2, 1, 0, 8 }; s32 ix = mx + (i % TILESET_TILES_PER_ROW) * 2; s32 iy = my + (i / TILESET_TILES_PER_ROW) * 2; for (s32 y = 0; y < 8; ++y) { for (s32 x = 0; x < 8; ++x) { s32 fy = (flipY ? flip[y] : y); s32 fx = (flipX ? flip[x] : x); s32 srcValueIndex = offset + fy * 8 + fx; s32 destValueIndex = (y + iy * 8) * TILESET_WIDTH + ix * 8 + x; data[destValueIndex] = tiles->tilesData.data[srcValueIndex]; } } } } } u8 paletteData[PALETTE_LENGTH]; wres_getPalette(context, tiles->tilesData.palette1, tiles->tilesData.palette2, paletteData); WarResource *resource = wres_getOrCreateResource(context, index); resource->type = WAR_RESOURCE_TYPE_TILESET; resource->tilesetData.tilesCount = rawResource.length / 8; for(s32 i = 0; i < TILESET_WIDTH * TILESET_HEIGHT; i++) { resource->tilesetData.data[i * 4 + 0] = paletteData[data[i] * 3 + 0]; resource->tilesetData.data[i * 4 + 1] = paletteData[data[i] * 3 + 1]; resource->tilesetData.data[i * 4 + 2] = paletteData[data[i] * 3 + 2]; resource->tilesetData.data[i * 4 + 3] = data[i] > 0 ? 255 : 0; } // #if __DEBUG__ // { // char path[32]; // StringView fp = wsv_fromCStringFormat(path, sizeof(path), "tileset_%d.png", index); // stbi_write_png(wsv_data(fp), TILESET_WIDTH, TILESET_HEIGHT, 4, resource->tilesetData.data, TILESET_WIDTH * 4); // } // #endif mz_destroy(scratch); } void wres_loadTiles(WarContext *context, DatabaseEntry *entry) { u8 paletteData[PALETTE_LENGTH]; wres_getPalette(context, entry->param1, entry->param2, paletteData); s32 index = entry->index; WarRawResource rawResource = context->warFile->resources[index]; if (rawResource.placeholder) { logInfo("Placeholder resource found at: %d", index); return; } WarResource *resource = wres_getOrCreateResource(context, index); resource->type = WAR_RESOURCE_TYPE_TILES; resource->tilesData.palette1 = entry->param1; resource->tilesData.palette2 = entry->param2; resource->tilesData.data = (u8*)wm_alloc(rawResource.length * sizeof(u8)); memcpy(resource->tilesData.data, rawResource.data, rawResource.length); } void wres_loadText(WarContext *context, DatabaseEntry *entry) { s32 index = entry->index; WarRawResource rawResource = context->warFile->resources[index]; if (rawResource.placeholder) { logInfo("Placeholder resource found at: %d", index); return; } WarResource *resource = wres_getOrCreateResource(context, index); resource->type = WAR_RESOURCE_TYPE_TEXT; resource->textData.length = rawResource.length; resource->textData.text = (char *)wm_alloc(resource->textData.length * sizeof(char)); memcpy(resource->textData.text, rawResource.data, resource->textData.length); } void wres_loadXmi(WarContext *context, DatabaseEntry *entry) { s32 index = entry->index; WarRawResource rawResource = context->warFile->resources[index]; if (rawResource.placeholder) { logInfo("Placeholder resource found at: %d", index); return; } u8* xmiData = rawResource.data; size32 xmiLength = rawResource.length; size32 midLength; uint8_t* midData = wa_transcodeXmiToMid(context, xmiData, xmiLength, &midLength); if (!midData) { logError("Can't convert XMI file of resource %d", index); return; } WarResource* resource = wres_getOrCreateResource(context, index); resource->type = WAR_RESOURCE_TYPE_XMID; resource->audio.data = midData; assert(midLength <= INT32_MAX); resource->audio.length = (s32)midLength; } void wres_loadWave(WarContext *context, DatabaseEntry *entry) { s32 index = entry->index; WarRawResource rawResource = context->warFile->resources[index]; if (rawResource.placeholder) { logInfo("Placeholder resource found at: %d", index); return; } memory_buffer_t bufInput = {0}; mb_initFromMemory(&bufInput, rawResource.data, rawResource.length); // skip "RIFF" assert(mb_skip(&bufInput, 4)); // skip file length, always 36 + dataLength assert(mb_skip(&bufInput, sizeof(s32))); // skip "WAVE" assert(mb_skip(&bufInput, 4)); // skip "fmt " assert(mb_skip(&bufInput, 4)); // skip fmt length, always 10 assert(mb_skip(&bufInput, sizeof(s32))); // skip uncompressed, always 1 assert(mb_skip(&bufInput, sizeof(s16))); // skip channel count, always 1 assert(mb_skip(&bufInput, sizeof(s16))); // skip sample rate, always 11025 assert(mb_skip(&bufInput, sizeof(s32))); // skip byte rate, always 11025 assert(mb_skip(&bufInput, sizeof(s32))); // skip block align, always 1 assert(mb_skip(&bufInput, sizeof(s16))); // skip bits per sample, always 8 assert(mb_skip(&bufInput, sizeof(s16))); // skip "data" assert(mb_skip(&bufInput, 4)); s32 dataLength; assert(mb_readInt32LE(&bufInput, &dataLength)); assert(dataLength > 0); // Local scratch zone for the intermediate 11025 Hz PCM buffer. memzone_t* scratch = mz_init((size_t)dataLength + 1024); u8* data = (u8*)mz_alloc(scratch, (size_t)dataLength); assert(mb_readBytes(&bufInput, data, dataLength)); // this data is at 11025khz, and for playing it back I needed at 44100khz // so I need to upsampling it here by a factor of 4 u8* newData = wa_changeSampleRate(context, data, dataLength, 4); s32 newDataLength = dataLength * 4; WarResource* resource = wres_getOrCreateResource(context, index); resource->type = WAR_RESOURCE_TYPE_WAVE; resource->audio.data = newData; resource->audio.length = newDataLength; mz_destroy(scratch); } void wres_loadVoc(WarContext *context, DatabaseEntry *entry) { s32 index = entry->index; WarRawResource rawResource = context->warFile->resources[index]; if (rawResource.placeholder) { logInfo("Placeholder resource found at: %d", index); return; } memory_buffer_t bufInput = {0}; mb_initFromMemory(&bufInput, rawResource.data, rawResource.length); char vocHeader[19]; assert(mb_readString(&bufInput, vocHeader, sizeof(vocHeader))); assert(strncmp(vocHeader, "Creative Voice File", sizeof(vocHeader)) == 0); // skip 0x1A assert(mb_skip(&bufInput, 1)); // skip offset to data, always 26 assert(mb_skip(&bufInput, 2)); // skip version, always 266 assert(mb_skip(&bufInput, 2)); // skip 2's comp of version, always 4393 assert(mb_skip(&bufInput, 2)); u8 type; assert(mb_read(&bufInput, &type)); assert(type == 1); s32 dataLength; assert(mb_readInt24LE(&bufInput, &dataLength)); assert(dataLength > 0); // the length of the data is this value - 2 // for the next two skipped bytes dataLength -= 2; // skip sample rate and compression type assert(mb_skip(&bufInput, 2)); // Local scratch zone for the intermediate 11025 Hz PCM buffer. memzone_t* scratch = mz_init((size_t)dataLength + 1024); u8* data = (u8*)mz_alloc(scratch, (size_t)dataLength); assert(mb_readBytes(&bufInput, data, dataLength)); // this data is at 11025khz, and for playing it back I needed at 44100khz // so I need to upsampling it here by a factor of 4 u8* newData = wa_changeSampleRate(context, data, dataLength, 4); s32 newDataLength = dataLength * 4; WarResource* resource = wres_getOrCreateResource(context, index); resource->type = WAR_RESOURCE_TYPE_VOC; resource->audio.data = newData; resource->audio.length = newDataLength; mz_destroy(scratch); } void wres_loadCursor(WarContext* context, DatabaseEntry* entry) { u8 paletteData[PALETTE_LENGTH]; wres_getPalette(context, entry->param1, entry->param2, paletteData); s32 index = entry->index; WarRawResource rawResource = context->warFile->resources[index]; if (rawResource.placeholder) { logInfo("Placeholder resource found at: %d", index); return; } u16 hotx = readu16(rawResource.data, 0); u16 hoty = readu16(rawResource.data, 2); u16 width = readu16(rawResource.data, 4); u16 height = readu16(rawResource.data, 6); u8 *pixels = (u8*)wm_alloc(width * height * 4 * sizeof(u8)); for (s32 i = 0; i < width * height; ++i) { u32 colorIndex = readu8(rawResource.data, 8 + i); pixels[i * 4 + 0] = readu8(paletteData, colorIndex * 3 + 0); pixels[i * 4 + 1] = readu8(paletteData, colorIndex * 3 + 1); pixels[i * 4 + 2] = readu8(paletteData, colorIndex * 3 + 2); // assuming that colorIndex == 0 is the transparent color if (pixels[i * 4 + 0] > 0 || pixels[i * 4 + 1] > 0 || pixels[i * 4 + 2] > 0 || colorIndex != 0) { pixels[i * 4 + 3] = 255; } } WarResource *resource = wres_getOrCreateResource(context, index); resource->type = WAR_RESOURCE_TYPE_CURSOR; resource->cursor.hotx = hotx; resource->cursor.hoty = hoty; resource->cursor.width = width; resource->cursor.height = height; resource->cursor.pixels = pixels; } void wres_loadResource(WarContext *context, DatabaseEntry *entry) { switch (entry->type) { case DB_ENTRY_TYPE_PALETTE: { wres_loadPaletteResource(context, entry); break; } case DB_ENTRY_TYPE_IMAGE: { wres_loadImageResource(context, entry); break; } case DB_ENTRY_TYPE_SPRITE: { wres_loadSpriteResource(context, entry); break; } case DB_ENTRY_TYPE_LEVEL_INFO: { wres_loadLevelInfo(context, entry); break; } case DB_ENTRY_TYPE_LEVEL_VISUAL: { wres_loadLevelVisual(context, entry); break; } case DB_ENTRY_TYPE_LEVEL_PASSABLE: { wres_loadLevelPassable(context, entry); break; } case DB_ENTRY_TYPE_TILESET: { wres_loadTileset(context, entry); break; } case DB_ENTRY_TYPE_TILES: { wres_loadTiles(context, entry); break; } case DB_ENTRY_TYPE_TEXT: { wres_loadText(context, entry); break; } case DB_ENTRY_TYPE_XMID: { wres_loadXmi(context, entry); break; } case DB_ENTRY_TYPE_WAVE: { wres_loadWave(context, entry); break; } case DB_ENTRY_TYPE_VOC: { wres_loadVoc(context, entry); break; } case DB_ENTRY_TYPE_CURSOR: { wres_loadCursor(context, entry); break; } default: { logInfo("DB entries of type %d aren't handled yet.", entry->type); break; } } } ================================================ FILE: src/war_resources.h ================================================ #pragma once #include "war_sprites.h" #include "war_units.h" #include "war_database.h" #define WAR_BUILDING_DAMAGE_1_RESOURCE 352 #define WAR_BUILDING_DAMAGE_2_RESOURCE 353 #define WAR_BUILDING_COLLAPSE_RESOURCE 356 #define WAR_EXPLOSION_RESOURCE 354 #define WAR_RAIN_OF_FIRE_EXPLOSION_RESOURCE 351 #define WAR_SPELL_RESOURCE 355 #define WAR_POISON_CLOUD_RESOURCE 350 struct _WarRawResource { bool placeholder; bool compressed; u32 offset; u32 compressedLength; u32 length; u32 index; u8 *data; }; struct _WarFile { // File Header // Version Archive ID Number of Entries // PreRelease EF 01 00 00 (495) little-endian // DOS Retail 18 00 00 00 (24) 47 02 00 00 (583) little-endian // DOS Shareware 19 00 00 00 (25) 47 02 00 00 (583) little-endian // Mac Retail 00 00 00 1A (26) 00 00 02 47 (583) big-endian // Mac Shareware 00 00 00 19 (25) 00 00 02 47 (583) big-endian u32 archiveID; u32 numberOfEntries; // File Table u32 offsets[MAX_RESOURCES_COUNT]; WarFileType type; WarRawResource resources[MAX_RESOURCES_COUNT]; }; struct _WarLevelUnit { u8 x, y; WarUnitType type; u8 player; WarResourceKind resourceKind; u16 amount; }; struct _WarLevelConstruct { WarConstructType type; u8 x1, y1; u8 x2, y2; u8 player; }; struct _WarTilesetTile { struct { u16 index; bool flipX; bool flipY; } tiles[4]; }; struct _WarCustomMapConfiguration { u32 startEntitiesCount; WarLevelUnit startEntities[MAX_CUSTOM_MAP_ENTITIES_COUNT]; }; struct _WarResource { WarResourceType type; union { struct { u8 colors[PALETTE_LENGTH]; } paletteData; struct { u16 width; u16 height; u8* pixels; } imageData; struct { u16 framesCount; u8 frameWidth; u8 frameHeight; WarSpriteFrame frames[MAX_SPRITE_FRAME_COUNT]; } spriteData; struct { u32 allowId; bool allowedHumanUnits; bool allowedOrcsUnits; bool customMap; u8 allowedFeatures[MAX_FEATURES_COUNT]; u8 allowedUpgrades[MAX_UPGRADES_COUNT][MAX_PLAYERS_COUNT]; u16 startX; u16 startY; u16 nextLevelIndex; u16 visualIndex; u16 passableIndex; u16 paletteIndex; u16 tilesIndex; u16 tilesetIndex; u16 tilesetType; u32 lumber[MAX_PLAYERS_COUNT]; u32 gold[MAX_PLAYERS_COUNT]; WarRace races[MAX_PLAYERS_COUNT]; char objectives[MAX_OBJECTIVES_LENGTH]; u32 startEntitiesCount; WarLevelUnit startEntities[MAX_ENTITIES_COUNT]; u32 startRoadsCount; WarLevelConstruct startRoads[MAX_CONSTRUCTS_COUNT]; u32 startWallsCount; WarLevelConstruct startWalls[MAX_CONSTRUCTS_COUNT]; u32 startGoldminesCount; WarLevelUnit startGoldmines[MAX_CUSTOM_MAP_GOLDMINES_COUNT]; u32 startConfigurationsCount; WarCustomMapConfiguration startConfigurations[MAX_CUSTOM_MAP_CONFIGURATIONS_COUNT]; } levelInfo; struct { u16 data[MAP_TILES_WIDTH * MAP_TILES_HEIGHT]; } levelVisual; struct { u16 data[MAP_TILES_WIDTH * MAP_TILES_HEIGHT]; } levelPassable; struct { u32 tilesCount; u8 data[TILESET_WIDTH * TILESET_HEIGHT * 4]; } tilesetData; struct { u16 palette1, palette2; u8* data; } tilesData; struct { u32 length; char* text; } textData; struct { u8* data; s32 length; } audio; struct { u16 hotx; u16 hoty; u16 width; u16 height; u8* pixels; } cursor; }; }; WarResource* wres_getOrCreateResource(WarContext* context, s32 index); void wres_loadResource(WarContext* context, DatabaseEntry* entry); ================================================ FILE: src/war_roads.c ================================================ #include "war_entities.h" #include bool we_hasRoadPieceAtPosition(WarContext* context, WarEntity* entity, s32 x, s32 y) { WarRoadComponent* road = we_getRoadComponent(context, entity); assert(road); WarRoadPieceList* pieces = &road->pieces; for (s32 i = 0; i < pieces->count; i++) { WarRoadPiece* piece = &pieces->items[i]; if (piece->tilex == x && piece->tiley == y) return true; } return false; } WarRoadPiece* we_getRoadPieceAtPosition(WarContext* context, WarEntity* entity, s32 x, s32 y) { WarRoadComponent* road = we_getRoadComponent(context, entity); assert(road); WarRoadPieceList* pieces = &road->pieces; for (s32 i = 0; i < pieces->count; i++) { WarRoadPiece* piece = &pieces->items[i]; if (piece->tilex == x && piece->tiley == y) return piece; } return NULL; } void we_determineRoadTypes(WarContext* context, WarEntity* entity) { assert(entity->type == WAR_ENTITY_TYPE_ROAD); WarMap* map = context->map; WarRoadComponent* roadComponent = we_getRoadComponent(context, entity); assert(roadComponent); const s32 dirC = 4; const s32 dirX[] = { 0, 1, 0, -1 }; const s32 dirY[] = { -1, 0, 1, 0 }; WarRoadPieceList* pieces = &roadComponent->pieces; for(s32 i = 0; i < pieces->count; i++) { WarRoadPiece* pi = &pieces->items[i]; s32 index = 0; for (s32 d = 0; d < dirC; d++) { s32 xx = pi->tilex + dirX[d]; s32 yy = pi->tiley + dirY[d]; if (!wpath_isInside(map->finder, xx, yy) || we_hasRoadPieceAtPosition(context, entity, xx, yy)) { index = index | (1 << d); } } pi->type = roadTileTypeMap[index]; } } void we_addRoadPiece(WarContext* context, WarEntity* entity, s32 x, s32 y, s32 player) { WarRoadComponent* road = we_getRoadComponent(context, entity); assert(road); WarRoadPieceList* pieces = &road->pieces; WarRoadPieceListAdd(pieces, createRoadPiece(x, y, player)); } void we_addRoadPiecesFromConstruct(WarContext* context, WarEntity* entity, WarLevelConstruct *construct) { assert(entity->type == WAR_ENTITY_TYPE_ROAD); WarRoadComponent* road = we_getRoadComponent(context, entity); assert(road); WarRoadPieceList* pieces = &road->pieces; s32 x1 = construct->x1; s32 y1 = construct->y1; s32 x2 = construct->x2; s32 y2 = construct->y2; u8 player = construct->player; s32 dx = x2 - x1; dx = SIGN(dx); s32 dy = y2 - y1; dy = SIGN(dy); s32 x = x1; s32 y = y1; while (x != x2) { WarRoadPieceListAdd(pieces, createRoadPiece(x, y, player)); x += dx; } WarRoadPieceListAdd(pieces, createRoadPiece(x, y, player)); while (y != y2) { WarRoadPieceListAdd(pieces, createRoadPiece(x, y, player)); y += dy; } WarRoadPieceListAdd(pieces, createRoadPiece(x, y, player)); } void we_removeRoadPiece(WarContext* context, WarEntity* entity, WarRoadPiece* piece) { WarRoadComponent* road = we_getRoadComponent(context, entity); assert(road); WarRoadPieceList* pieces = &road->pieces; WarRoadPieceListRemove(pieces, *piece); } WarEntity* we_createRoad(WarContext* context) { WarMap* map = context->map; WarRoadPieceList pieces; WarRoadPieceListInit(&pieces, WarRoadPieceListDefaultOptions); WarEntity *entity = we_createEntity(context, WAR_ENTITY_TYPE_ROAD, true); we_addRoadComponent(context, entity, pieces); we_addSpriteComponent(context, entity, WAR_SPRITE_COMPONENT_INIT( .sprite = map->sprite )); return entity; } ================================================ FILE: src/war_ruins.c ================================================ #include "war_entities.h" #include bool we_hasRuinPieceAtPosition(WarContext* context, WarEntity* ruins, s32 x, s32 y) { WarRuinComponent* ruin = we_getRuinComponent(context, ruins); assert(ruin); WarRuinPieceList* pieces = &ruin->pieces; for (s32 i = 0; i < pieces->count; i++) { WarRuinPiece* piece = &pieces->items[i]; if (piece->tilex == x && piece->tiley == y) return true; } return false; } WarRuinPiece* we_getRuinPieceAtPosition(WarContext* context, WarEntity* ruins, s32 x, s32 y) { WarRuinComponent* ruin = we_getRuinComponent(context, ruins); assert(ruin); WarRuinPieceList* pieces = &ruin->pieces; for (s32 i = 0; i < pieces->count; i++) { WarRuinPiece* piece = &pieces->items[i]; if (piece->tilex == x && piece->tiley == y) return piece; } return NULL; } void we_determineRuinTypes(WarContext* context, WarEntity* entity) { assert(entity); assert(entity->type == WAR_ENTITY_TYPE_RUIN); WarMap* map = context->map; WarRuinComponent* ruinComp = we_getRuinComponent(context, entity); assert(ruinComp); WarRuinPieceList* pieces = &ruinComp->pieces; const s32 dirC = 8; const s32 dirX[] = { -1, 0, 1, 1, 1, 0, -1, -1 }; const s32 dirY[] = { -1, -1, -1, 0, 1, 1, 1, 0 }; s32List invalidPieces; s32ListInit(&invalidPieces, s32ListDefaultOptions); for(s32 i = 0; i < pieces->count; i++) { WarRuinPiece* pi = &pieces->items[i]; s32 index = 0; for (s32 d = 0; d < dirC; d++) { s32 xx = pi->tilex + dirX[d]; s32 yy = pi->tiley + dirY[d]; if (!wpath_isInside(map->finder, xx, yy) || we_hasRuinPieceAtPosition(context, entity, xx, yy)) { index = index | (1 << d); } } pi->type = ruinTileTypeMap[index]; if (pi->type == WAR_RUIN_PIECE_NONE) s32ListAdd(&invalidPieces, i); } for (s32 i = invalidPieces.count - 1; i >= 0; i--) WarRuinPieceListRemoveAt(pieces, invalidPieces.items[i]); s32ListFree(&invalidPieces); } WarEntity* we_createRuins(WarContext* context) { WarMap* map = context->map; WarRuinPieceList pieces; WarRuinPieceListInit(&pieces, WarRuinPieceListDefaultOptions); WarEntity *entity = we_createEntity(context, WAR_ENTITY_TYPE_RUIN, true); we_addRuinComponent(context, entity, pieces); we_addSpriteComponent(context, entity, WAR_SPRITE_COMPONENT_INIT( .sprite = map->sprite )); return entity; } void we_addRuinsPieces(WarContext* context, WarEntity* entity, s32 x, s32 y, s32 dim) { assert(entity); assert(entity->type == WAR_ENTITY_TYPE_RUIN); WarRuinComponent* ruinComp = we_getRuinComponent(context, entity); assert(ruinComp); WarRuinPieceList* pieces = &ruinComp->pieces; for(s32 yy = 0; yy < dim; yy++) { for(s32 xx = 0; xx < dim; xx++) { if (!we_hasRuinPieceAtPosition(context, entity, x + xx, y + yy)) WarRuinPieceListAdd(pieces, createRuinPiece(x + xx, y + yy)); } } } void we_removeRuinPiece(WarContext* context, WarEntity* entity, WarRuinPiece* piece) { WarRuinComponent* ruinComp = we_getRuinComponent(context, entity); assert(ruinComp); WarRuinPieceList* pieces = &ruinComp->pieces; WarRuinPieceListRemove(pieces, *piece); } ================================================ FILE: src/war_scene_blizzard.c ================================================ #include "war_scene_blizzard.h" #include "war_audio.h" #include "war_imui.h" #include "war_scenes.h" void wsc_enterSceneBlizzard(WarContext* context) { WarScene* scene = context->scene; scene->blizzard.time = 3.0f; wa_createAudio(context, CREATE_AUDIO_ARGS_INIT(.audioId=WAR_LOGO, .loop=true)); } void wsc_updateSceneBlizzard(WarContext* context) { WarScene* scene = context->scene; scene->blizzard.time -= context->deltaTime; if (scene->blizzard.time <= 0) { WarScene* nextScene = wsc_createScene(context, WAR_SCENE_MAIN_MENU); wg_setNextScene(context, nextScene, 0.3f); } } void wsc_renderSceneBlizzard(WarContext* context) { imui_image(context, "imgBackground", CREATE_UI_IMAGE_ARGS_INIT( .spriteRef = imageResourceRef(216), .position = VEC2_ZERO, )); } ================================================ FILE: src/war_scene_blizzard.h ================================================ #pragma once #include "war.h" void wsc_enterSceneBlizzard(WarContext* context); void wsc_updateSceneBlizzard(WarContext* context); void wsc_renderSceneBlizzard(WarContext* context); ================================================ FILE: src/war_scene_briefing.c ================================================ #include "war_scene_briefing.h" #include #include "shl/wstr.h" #include "war_animations.h" #include "war_audio.h" #include "war_campaigns.h" #include "war_entities.h" #include "war_imui.h" void wsbr_enterSceneBriefingHumans(WarContext* context) { WarScene* scene = context->scene; WarCampaignMapData data = wcamp_getCampaignData(scene->briefing.mapType); scene->briefing.time = data.briefingDuration; scene->briefing.scrollY = 160.0f; scene->briefing.briefingText = data.briefingText; // transfer ownership WarEntity* animEntity = we_createEntity(context, WAR_ENTITY_TYPE_ANIMATION, true); we_addAnimationsComponent(context, animEntity); WarSpriteAnimation* anim1 = wanim_createAnimationFromResourceIndex(context, wstr_fromCString("anim1"), imageResourceRef(428), 0.2f, true); anim1->offset = vec2i(83, 37); anim1->loopDelay = 2.0f; wanim_addAnimationFramesRange(anim1, 0, 4); wanim_addAnimationFramesRange(anim1, 4, 0); wanim_addAnimation(context, animEntity, anim1); WarSpriteAnimation* anim2 = wanim_createAnimationFromResourceIndex(context, wstr_fromCString("anim2"), imageResourceRef(429), 0.2f, true); anim2->offset = vec2i(207, 29); anim1->loopDelay = 2.0f; wanim_addAnimationFramesRange(anim2, 0, 20); wanim_addAnimation(context, animEntity, anim2); WarSpriteAnimation* anim3 = wanim_createAnimationFromResourceIndex(context, wstr_fromCString("anim3"), imageResourceRef(430), 0.1f, true); anim3->offset = vec2i(21, 17); wanim_addAnimationFramesRange(anim3, 0, 20); wanim_addAnimation(context, animEntity, anim3); WarSpriteAnimation* anim4 = wanim_createAnimationFromResourceIndex(context, wstr_fromCString("anim4"), imageResourceRef(431), 0.1f, true); anim4->offset = vec2i(275, 21); wanim_addAnimationFramesRange(anim4, 0, 20); wanim_addAnimation(context, animEntity, anim4); if (!isDemo(context)) wa_createAudio(context, CREATE_AUDIO_ARGS_INIT(.audioId=data.briefingAudioId, .loop=false)); } void wsbr_enterSceneBriefingOrcs(WarContext* context) { WarScene* scene = context->scene; WarCampaignMapData data = wcamp_getCampaignData(scene->briefing.mapType); scene->briefing.time = data.briefingDuration; scene->briefing.scrollY = 160.0f; scene->briefing.briefingText = data.briefingText; // transfer ownership WarEntity* animEntity = we_createEntity(context, WAR_ENTITY_TYPE_ANIMATION, true); we_addAnimationsComponent(context, animEntity); WarSpriteAnimation* anim1 = wanim_createAnimationFromResourceIndex(context, wstr_fromCString("anim1"), imageResourceRef(426), 0.2f, true); anim1->offset = vec2i(18, 67); anim1->loopDelay = 2.0f; wanim_addAnimationFramesRange(anim1, 0, 4); wanim_addAnimationFramesRange(anim1, 4, 0); wanim_addAnimation(context, animEntity, anim1); WarSpriteAnimation* anim2 = wanim_createAnimationFromResourceIndex(context, wstr_fromCString("anim2"), imageResourceRef(427), 0.2f, true); anim2->offset = vec2i(202, 52); anim1->loopDelay = 2.0f; wanim_addAnimationFramesRange(anim2, 0, 4); wanim_addAnimationFramesRange(anim2, 4, 0); wanim_addAnimation(context, animEntity, anim2); if (!isDemo(context)) { WarSpriteAnimation* anim3 = wanim_createAnimationFromResourceIndex(context, wstr_fromCString("anim3"), imageResourceRef(425), 0.1f, true); anim3->offset = vec2i(140, 66); wanim_addAnimationFramesRange(anim3, 0, 30); wanim_addAnimation(context, animEntity, anim3); } if (!isDemo(context)) wa_createAudio(context, CREATE_AUDIO_ARGS_INIT(.audioId=data.briefingAudioId, .loop=false)); } void wsc_enterSceneBriefing(WarContext* context) { WarScene* scene = context->scene; switch (scene->briefing.race) { case WAR_RACE_HUMANS: { wsbr_enterSceneBriefingHumans(context); break; } case WAR_RACE_ORCS: { wsbr_enterSceneBriefingOrcs(context); break; } default: { logError("Not allowed briefing scenes for race: %d", scene->briefing.race); break; } } } void wsc_updateSceneBriefing(WarContext* context) { WarInput* input = &context->input; WarScene* scene = context->scene; scene->briefing.time -= context->deltaTime; scene->briefing.scrollY -= 10.0f * context->deltaTime; wanim_updateAnimations(context); if (scene->briefing.time <= 0 || isButtonJustPressed(input, WAR_MOUSE_LEFT) || isKeyJustPressed(input, WAR_KEY_ENTER) || isKeyJustPressed(input, WAR_KEY_SPACE)) { WarMap* map = wmap_createMap(context, scene->briefing.mapType); wg_setNextMap(context, map, 1.0f); } } void wsc_renderSceneBriefing(WarContext* context) { WarScene* scene = context->scene; // Background image — must render before animations so it sits behind them. s32 bgSpriteIndex = (scene->briefing.race == WAR_RACE_HUMANS) ? 421 : 422; imui_image(context, "imgBackground", CREATE_UI_IMAGE_ARGS_INIT( .spriteRef = imageResourceRef(bgSpriteIndex), .position = VEC2_ZERO, )); } void wsc_renderOverlayBriefing(WarContext* context) { WarScene* scene = context->scene; imui_text(context, "txtBriefing", CREATE_UI_TEXT_ARGS_INIT( .position = vec2f(20.0f, scene->briefing.scrollY), .fontIndex = 1, .fontColor = WAR_COLOR_RGB(255, 215, 138), .multiline = true, .boundings = vec2f((f32)(context->originalWindowWidth - 40), 200.0f), .wrapping = WAR_TEXT_WRAP_CHAR, .lineHeight = 150, .text = scene->briefing.briefingText )); } ================================================ FILE: src/war_scene_briefing.h ================================================ #pragma once #include "war.h" void wsc_enterSceneBriefing(WarContext* context); void wsc_updateSceneBriefing(WarContext* context); void wsc_renderSceneBriefing(WarContext* context); void wsc_renderOverlayBriefing(WarContext* context); ================================================ FILE: src/war_scene_download.c ================================================ #include "war_scene_download.h" #include "SDL3/SDL.h" #include "shl/wstr.h" #include "war.h" #include "war_game.h" #include "war_imui.h" #include "war_net.h" static const char downloadWelcomeText[] = "Hi there! Thanks for downloading the game! :)\n" "\n" "War 1 needs the file with all the assets of the game.\n" "That file is the DATA.WAR that comes with original\n" "game, you can copy and paste that file (if you have it)\n" "into the War 1 folder or you can press Enter to\n" "download the DEMO DATA.WAR file from the internet.\n" "\n" "Enjoy the game!"; static const char downloadConfirmText[] = "The DEMO DATA.WAR doesn't have all assets.\n" "\n" "You may not get all the features, but it will allow you to start and play the game.\n" "\n" "To get the full experience, you need to get an original\n" "copy of the game and copy the file from there.\n" "\n" "Press Enter to confirm you want to download the\n" "DEMO DATA.WAR file"; void wsc_enterSceneDownload(WarContext* context) { WarScene* scene = context->scene; scene->download.status = WAR_SCENE_DOWNLOAD_DOWNLOAD; } void wsc_updateSceneDownload(WarContext* context) { WarInput* input = &context->input; WarScene* scene = context->scene; switch (scene->download.status) { case WAR_SCENE_DOWNLOAD_DOWNLOAD: { if (isKeyJustReleased(input, WAR_KEY_ENTER)) { scene->download.status = WAR_SCENE_DOWNLOAD_CONFIRM; } break; } case WAR_SCENE_DOWNLOAD_CONFIRM: { if (isKeyJustReleased(input, WAR_KEY_ENTER)) { scene->download.status = WAR_SCENE_DOWNLOAD_DOWNLOADING; } break; } case WAR_SCENE_DOWNLOAD_DOWNLOADING: { bool success = wnet_downloadFileFromUrl(context, wsv_fromCString(ONLINE_DEMO_DATAWAR_FILE_URL), wsv_fromCString(DATAWAR_FILE_PATH)); if (success) { scene->download.status = WAR_SCENE_DOWNLOAD_DOWNLOADED; } else { scene->download.status = WAR_SCENE_DOWNLOAD_FAILED; } break; } case WAR_SCENE_DOWNLOAD_DOWNLOADED: { if (isKeyJustReleased(input, WAR_KEY_ENTER)) { if (wg_loadDataFile(context)) { scene->download.status = WAR_SCENE_DOWNLOAD_FILE_LOADED; } else { logError("Could not load file: %s", DATAWAR_FILE_PATH); } } break; } case WAR_SCENE_DOWNLOAD_FILE_LOADED: { WarScene* nextScene = wsc_createScene(context, WAR_SCENE_BLIZZARD); wg_setNextScene(context, nextScene, 0.0f); break; } case WAR_SCENE_DOWNLOAD_FAILED: { if (isKeyJustReleased(input, WAR_KEY_ENTER)) { SDL_PushEvent(&(SDL_Event){ .type = SDL_EVENT_QUIT }); } break; } } } void wsc_renderSceneDownload(WarContext* context) { WarScene* scene = context->scene; f32 w = (f32)(context->originalWindowWidth - 20); f32 h = (f32)(context->originalWindowHeight - 20); // Main body text — shown in DOWNLOAD and CONFIRM states. switch (scene->download.status) { case WAR_SCENE_DOWNLOAD_DOWNLOAD: { imui_text(context, "txtDownload", CREATE_UI_TEXT_ARGS_INIT( .position = vec2i(10, 10), .fontIndex = 1, .fontColor = WAR_COLOR_RGB(255, 215, 138), .multiline = true, .boundings = vec2f(w, h), .wrapping = WAR_TEXT_WRAP_CHAR, .lineHeight = 120, .text = wsv_fromCString(downloadWelcomeText) )); break; } case WAR_SCENE_DOWNLOAD_CONFIRM: { imui_text(context, "txtDownload", CREATE_UI_TEXT_ARGS_INIT( .position = vec2i(10, 10), .fontIndex = 1, .fontColor = WAR_COLOR_RGB(255, 215, 138), .multiline = true, .boundings = vec2f(w, h), .wrapping = WAR_TEXT_WRAP_CHAR, .lineHeight = 120, .text = wsv_fromCString(downloadConfirmText) )); break; } case WAR_SCENE_DOWNLOAD_DOWNLOADING: { imui_text(context, "txtDownloading", CREATE_UI_TEXT_ARGS_INIT( .position = vec2i(10, 10), .fontIndex = 1, .fontColor = WAR_COLOR_RGB(255, 215, 138), .boundings = vec2f(w, h), .verticalAlign = WAR_TEXT_ALIGN_BOTTOM, .text = wsv_fromCString("Downloading...") )); break; } case WAR_SCENE_DOWNLOAD_DOWNLOADED: case WAR_SCENE_DOWNLOAD_FILE_LOADED: { imui_text(context, "txtDownloading", CREATE_UI_TEXT_ARGS_INIT( .position = vec2i(10, 10), .fontIndex = 1, .fontColor = WAR_COLOR_RGB(255, 215, 138), .boundings = vec2f(w, h), .verticalAlign = WAR_TEXT_ALIGN_BOTTOM, .text = wsv_fromCString("Downloading... Done. Press Enter to start the game.") )); break; } case WAR_SCENE_DOWNLOAD_FAILED: { imui_text(context, "txtDownloading", CREATE_UI_TEXT_ARGS_INIT( .position = vec2i(10, 10), .fontIndex = 1, .fontColor = WAR_COLOR_RGB(255, 215, 138), .boundings = vec2f(w, h), .verticalAlign = WAR_TEXT_ALIGN_BOTTOM, .text = wsv_fromCString("Downloading... Failed. Press Enter to quit the game.") )); break; } } } ================================================ FILE: src/war_scene_download.h ================================================ #pragma once #include "war.h" void wsc_enterSceneDownload(WarContext* context); void wsc_updateSceneDownload(WarContext* context); void wsc_renderSceneDownload(WarContext* context); ================================================ FILE: src/war_scene_menu.c ================================================ #include "war_scene_menu.h" #include "SDL3/SDL.h" #include "shl/wstr.h" #include "war_audio.h" #include "war_game.h" #include "war_imui.h" #include "war_map.h" #include "war_ui.h" static const char* getCustomGameRaceStr(WarRace value) { switch (value) { case WAR_RACE_NEUTRAL: return "Random"; case WAR_RACE_HUMANS: return "Human"; case WAR_RACE_ORCS: return "Orc"; default: return ""; } } static const char* getCustomMapStr(s32 value) { switch (value) { case 147: return "Forest 1"; case 148: return "Forest 2"; case 149: return "Forest 3"; case 150: return "Forest 4"; case 151: return "Forest 5"; case 152: return "Forest 6"; case 153: return "Forest 7"; case 154: return "Swamp 6"; case 155: return "Swamp 7"; case 156: return "Swamp 1"; case 157: return "Swamp 2"; case 158: return "Swamp 3"; case 159: return "Swamp 4"; case 160: return "Swamp 5"; case 161: return "Dungeon 1"; case 162: return "Dungeon 2"; case 163: return "Dungeon 3"; case 164: return "Dungeon 4"; case 165: return "Dungeon 5"; case 166: return "Dungeon 6"; case 167: return "Dungeon 7"; case 168: return "Forest 1.1"; case 169: return "Forest 2.1"; case 170: return "Forest 3.1"; case 171: return "Forest 4.1"; case 172: return "Forest 5.1"; case 173: return "Forest 6.1"; case 174: return "Forest 7.1"; case 175: return "Swamp 6.1"; case 176: return "Swamp 7.1"; case 177: return "Swamp 1.1"; case 178: return "Swamp 2.1"; case 179: return "Swamp 3.1"; case 180: return "Swamp 4.1"; case 181: return "Swamp 5.1"; case 182: return "Dungeon 1.1"; case 183: return "Dungeon 2.1"; case 184: return "Dungeon 3.1"; case 185: return "Dungeon 4.1"; case 186: return "Dungeon 5.1"; case 187: return "Dungeon 6.1"; case 188: return "Dungeon 7.1"; default: return ""; } } void wsc_enterSceneMainMenu(WarContext* context) { WarScene* scene = context->scene; scene->menu.menuPanel = WAR_MAIN_MENU_PANEL_MAIN; wcheatp_createCheatsPanel(context); if (!isDemo(context)) wa_createAudio(context, CREATE_AUDIO_ARGS_INIT(.audioId=WAR_MUSIC_00, .loop=true)); } void wsc_renderSceneMainMenu(WarContext* context) { WarScene* scene = context->scene; WarSpriteResourceRef mediumNormalRef = imageResourceRef(239); WarSpriteResourceRef mediumPressedRef = imageResourceRef(240); WarSpriteResourceRef smallNormalRef = imageResourceRef(241); WarSpriteResourceRef smallPressedRef = imageResourceRef(242); // Background is always visible imui_image(context, "imgMenuBackground", CREATE_UI_IMAGE_ARGS_INIT( .spriteRef = imageResourceRef(261), .position = VEC2_ZERO, )); switch (scene->menu.menuPanel) { case WAR_MAIN_MENU_PANEL_MAIN: { if (imui_text_button(context, "btnMenuSinglePlayer", CREATE_UI_TEXT_BUTTON_ARGS_INIT( .fontIndex = 1, .text = wsv_fromCString("Start a new game"), .backgroundNormalRef = mediumNormalRef, .backgroundPressedRef = mediumPressedRef, .position = vec2i(104, 85), .hotKey = WAR_KEY_S, .highlightIndex = 0, .highlightCount = 1, ))) { wsc_handleMenuSinglePlayer(context, NULL); } // Load existing game — not yet implemented; button is inert imui_text_button(context, "btnMenuLoad", CREATE_UI_TEXT_BUTTON_ARGS_INIT( .fontIndex = 1, .text = wsv_fromCString("Load existing game"), .backgroundNormalRef = mediumNormalRef, .backgroundPressedRef = mediumPressedRef, .position = vec2i(104, 105), .hotKey = WAR_KEY_L, .highlightIndex = 0, .highlightCount = 1, )); // Replay introduction — not yet implemented; button is inert imui_text_button(context, "btnMenuReplayIntro", CREATE_UI_TEXT_BUTTON_ARGS_INIT( .fontIndex = 1, .text = wsv_fromCString("Replay introduction"), .backgroundNormalRef = mediumNormalRef, .backgroundPressedRef = mediumPressedRef, .position = vec2i(104, 125), .hotKey = WAR_KEY_R, .highlightIndex = 0, .highlightCount = 1, )); if (imui_text_button(context, "btnMenuQuit", CREATE_UI_TEXT_BUTTON_ARGS_INIT( .fontIndex = 1, .text = wsv_fromCString("Quit"), .backgroundNormalRef = mediumNormalRef, .backgroundPressedRef = mediumPressedRef, .position = vec2i(104, 165), .hotKey = WAR_KEY_Q, .highlightIndex = 0, .highlightCount = 1, ))) { wsc_handleMenuQuit(context, NULL); } break; } case WAR_MAIN_MENU_PANEL_SINGLE_PLAYER: { if (imui_text_button(context, "btnSinglePlayerOrc", CREATE_UI_TEXT_BUTTON_ARGS_INIT( .fontIndex = 1, .text = wsv_fromCString("Orc campaign"), .backgroundNormalRef = mediumNormalRef, .backgroundPressedRef = mediumPressedRef, .position = vec2i(104, 85), .hotKey = WAR_KEY_O, .highlightIndex = 0, .highlightCount = 1, ))) { wsc_handleSinglePlayerOrc(context, NULL); } if (imui_text_button(context, "btnSinglePlayerHuman", CREATE_UI_TEXT_BUTTON_ARGS_INIT( .fontIndex = 1, .text = wsv_fromCString("Human campaign"), .backgroundNormalRef = mediumNormalRef, .backgroundPressedRef = mediumPressedRef, .position = vec2i(104, 105), .hotKey = WAR_KEY_H, .highlightIndex = 0, .highlightCount = 1, ))) { wsc_handleSinglePlayerHuman(context, NULL); } if (imui_text_button(context, "btnCustomGame", CREATE_UI_TEXT_BUTTON_ARGS_INIT( .fontIndex = 1, .text = wsv_fromCString("Custom game"), .backgroundNormalRef = mediumNormalRef, .backgroundPressedRef = mediumPressedRef, .position = vec2i(104, 125), .hotKey = WAR_KEY_U, .highlightIndex = 0, .highlightCount = 1, ))) { wsc_handleCustomGame(context, NULL); } if (imui_text_button(context, "btnSinglePlayerCancel", CREATE_UI_TEXT_BUTTON_ARGS_INIT( .fontIndex = 1, .text = wsv_fromCString("Cancel"), .backgroundNormalRef = smallNormalRef, .backgroundPressedRef = smallPressedRef, .position = vec2i(133, 165), .hotKey = WAR_KEY_C, .highlightIndex = 0, .highlightCount = 1, ))) { wsc_handleSinglePlayerCancel(context, NULL); } break; } case WAR_MAIN_MENU_PANEL_CUSTOM_GAME: { WarSpriteResourceRef leftArrowNormalRef = imageResourceRef(244); WarSpriteResourceRef leftArrowPressedRef = imageResourceRef(245); WarSpriteResourceRef rightArrowNormalRef = imageResourceRef(246); WarSpriteResourceRef rightArrowPressedRef = imageResourceRef(247); // Static labels imui_text(context, "txtYourRaceLabel", CREATE_UI_TEXT_ARGS_INIT( .position = vec2i(40, 105), .fontIndex = 1, .boundings = vec2f(100, 12), .horizontalAlign = WAR_TEXT_ALIGN_RIGHT, .verticalAlign = WAR_TEXT_ALIGN_MIDDLE, .text = wsv_fromCString("Your race:"), )); imui_text(context, "txtEnemyRaceLabel", CREATE_UI_TEXT_ARGS_INIT( .position = vec2i(40, 125), .fontIndex = 1, .boundings = vec2f(100, 12), .horizontalAlign = WAR_TEXT_ALIGN_RIGHT, .verticalAlign = WAR_TEXT_ALIGN_MIDDLE, .text = wsv_fromCString("Enemy race:"), )); imui_text(context, "txtMapLabel", CREATE_UI_TEXT_ARGS_INIT( .position = vec2i(40, 145), .fontIndex = 1, .boundings = vec2f(100, 12), .horizontalAlign = WAR_TEXT_ALIGN_RIGHT, .verticalAlign = WAR_TEXT_ALIGN_MIDDLE, .text = wsv_fromCString("Map:"), )); // Dynamic values imui_text(context, "txtYourRace", CREATE_UI_TEXT_ARGS_INIT( .position = vec2i(180, 105), .fontIndex = 1, .boundings = vec2f(50, 12), .horizontalAlign = WAR_TEXT_ALIGN_CENTER, .verticalAlign = WAR_TEXT_ALIGN_MIDDLE, .text = wsv_fromCString(getCustomGameRaceStr(scene->menu.yourRace)), )); imui_text(context, "txtEnemyRace", CREATE_UI_TEXT_ARGS_INIT( .position = vec2i(180, 125), .fontIndex = 1, .boundings = vec2f(50, 12), .horizontalAlign = WAR_TEXT_ALIGN_CENTER, .verticalAlign = WAR_TEXT_ALIGN_MIDDLE, .text = wsv_fromCString(getCustomGameRaceStr(scene->menu.enemyRace)), )); imui_text(context, "txtMap", CREATE_UI_TEXT_ARGS_INIT( .position = vec2i(180, 145), .fontIndex = 1, .boundings = vec2f(50, 12), .horizontalAlign = WAR_TEXT_ALIGN_CENTER, .verticalAlign = WAR_TEXT_ALIGN_MIDDLE, .text = wsv_fromCString(getCustomMapStr(scene->menu.customMap)), )); // Your race arrows if (imui_image_button(context, "btnYourRaceLeft", CREATE_UI_IMAGE_BUTTON_ARGS_INIT( .backgroundNormalRef = leftArrowNormalRef, .backgroundPressedRef = leftArrowPressedRef, .position = vec2i(160, 103), ))) { wsc_handleYourRaceLeft(context, NULL); } if (imui_image_button(context, "btnYourRaceRight", CREATE_UI_IMAGE_BUTTON_ARGS_INIT( .backgroundNormalRef = rightArrowNormalRef, .backgroundPressedRef = rightArrowPressedRef, .position = vec2i(235, 103), ))) { wsc_handleYourRaceRight(context, NULL); } // Enemy race arrows if (imui_image_button(context, "btnEnemyRaceLeft", CREATE_UI_IMAGE_BUTTON_ARGS_INIT( .backgroundNormalRef = leftArrowNormalRef, .backgroundPressedRef = leftArrowPressedRef, .position = vec2i(160, 123), ))) { wsc_handleEnemyRaceLeft(context, NULL); } if (imui_image_button(context, "btnEnemyRaceRight", CREATE_UI_IMAGE_BUTTON_ARGS_INIT( .backgroundNormalRef = rightArrowNormalRef, .backgroundPressedRef = rightArrowPressedRef, .position = vec2i(235, 123), ))) { wsc_handleEnemyRaceRight(context, NULL); } // Map arrows if (imui_image_button(context, "btnMapLeft", CREATE_UI_IMAGE_BUTTON_ARGS_INIT( .backgroundNormalRef = leftArrowNormalRef, .backgroundPressedRef = leftArrowPressedRef, .position = vec2i(160, 143), ))) { wsc_handleMapLeft(context, NULL); } if (imui_image_button(context, "btnMapRight", CREATE_UI_IMAGE_BUTTON_ARGS_INIT( .backgroundNormalRef = rightArrowNormalRef, .backgroundPressedRef = rightArrowPressedRef, .position = vec2i(235, 143), ))) { wsc_handleMapRight(context, NULL); } // Ok / Cancel if (imui_text_button(context, "btnCustomGameOk", CREATE_UI_TEXT_BUTTON_ARGS_INIT( .fontIndex = 1, .text = wsv_fromCString("Ok"), .backgroundNormalRef = smallNormalRef, .backgroundPressedRef = smallPressedRef, .position = vec2i(100, 165), .hotKey = WAR_KEY_O, .highlightIndex = 0, .highlightCount = 1, ))) { wsc_handleCustomGameOk(context, NULL); } if (imui_text_button(context, "btnCustomGameCancel", CREATE_UI_TEXT_BUTTON_ARGS_INIT( .fontIndex = 1, .text = wsv_fromCString("Cancel"), .backgroundNormalRef = smallNormalRef, .backgroundPressedRef = smallPressedRef, .position = vec2i(180, 165), .hotKey = WAR_KEY_C, .highlightIndex = 0, .highlightCount = 1, ))) { // Cancel from custom game goes back to single player panel wsc_handleMenuSinglePlayer(context, NULL); } break; } default: break; } } // menu button handlers void wsc_handleMenuSinglePlayer(WarContext* context, WarEntity* entity) { NOT_USED(entity); context->scene->menu.menuPanel = WAR_MAIN_MENU_PANEL_SINGLE_PLAYER; } void wsc_handleMenuQuit(WarContext* context, WarEntity* entity) { NOT_USED(context); NOT_USED(entity); SDL_PushEvent(&(SDL_Event){ .type = SDL_EVENT_QUIT }); } void wsc_handleSinglePlayerOrc(WarContext* context, WarEntity* entity) { NOT_USED(entity); WarScene* scene = wsc_createScene(context, WAR_SCENE_BRIEFING); scene->briefing.race = WAR_RACE_ORCS; scene->briefing.mapType = WAR_CAMPAIGN_ORCS_01; wg_setNextScene(context, scene, 1.0f); } void wsc_handleSinglePlayerHuman(WarContext* context, WarEntity* entity) { NOT_USED(entity); WarScene* scene = wsc_createScene(context, WAR_SCENE_BRIEFING); scene->briefing.race = WAR_RACE_HUMANS; scene->briefing.mapType = WAR_CAMPAIGN_HUMANS_01; wg_setNextScene(context, scene, 1.0f); } void wsc_handleCustomGame(WarContext* context, WarEntity* entity) { NOT_USED(entity); WarScene* scene = context->scene; scene->menu.menuPanel = WAR_MAIN_MENU_PANEL_CUSTOM_GAME; scene->menu.yourRace = WAR_RACE_HUMANS; scene->menu.enemyRace = WAR_RACE_ORCS; scene->menu.customMap = 147; } void wsc_handleSinglePlayerCancel(WarContext* context, WarEntity* entity) { NOT_USED(entity); context->scene->menu.menuPanel = WAR_MAIN_MENU_PANEL_MAIN; } void wsc_handleYourRaceLeft(WarContext* context, WarEntity* entity) { NOT_USED(entity); WarScene* scene = context->scene; if (scene->menu.yourRace > WAR_RACE_NEUTRAL) scene->menu.yourRace--; } void wsc_handleYourRaceRight(WarContext* context, WarEntity* entity) { NOT_USED(entity); WarScene* scene = context->scene; if (scene->menu.yourRace < WAR_RACE_ORCS) scene->menu.yourRace++; } void wsc_handleEnemyRaceLeft(WarContext* context, WarEntity* entity) { NOT_USED(entity); WarScene* scene = context->scene; if (scene->menu.enemyRace > WAR_RACE_NEUTRAL) scene->menu.enemyRace--; } void wsc_handleEnemyRaceRight(WarContext* context, WarEntity* entity) { NOT_USED(entity); WarScene* scene = context->scene; if (scene->menu.enemyRace < WAR_RACE_ORCS) scene->menu.enemyRace++; } void wsc_handleMapLeft(WarContext* context, WarEntity* entity) { NOT_USED(entity); WarScene* scene = context->scene; if (scene->menu.customMap > 147) scene->menu.customMap--; } void wsc_handleMapRight(WarContext* context, WarEntity* entity) { NOT_USED(entity); WarScene* scene = context->scene; if (scene->menu.customMap < 188) scene->menu.customMap++; } void wsc_handleCustomGameOk(WarContext* context, WarEntity* entity) { NOT_USED(entity); WarScene* scene = context->scene; WarMap* map = createCustomMap(context, scene->menu.customMap, scene->menu.yourRace, scene->menu.enemyRace); wg_setNextMap(context, map, 1.0f); } ================================================ FILE: src/war_scene_menu.h ================================================ #pragma once #include "war.h" void wsc_enterSceneMainMenu(WarContext* context); void wsc_renderSceneMainMenu(WarContext* context); // menu button handlers void wsc_handleMenuSinglePlayer(WarContext* context, WarEntity* entity); void wsc_handleMenuQuit(WarContext* context, WarEntity* entity); void wsc_handleSinglePlayerOrc(WarContext* context, WarEntity* entity); void wsc_handleSinglePlayerHuman(WarContext* context, WarEntity* entity); void wsc_handleCustomGame(WarContext* context, WarEntity* entity); void wsc_handleSinglePlayerCancel(WarContext* context, WarEntity* entity); void wsc_handleYourRaceLeft(WarContext* context, WarEntity* entity); void wsc_handleYourRaceRight(WarContext* context, WarEntity* entity); void wsc_handleEnemyRaceLeft(WarContext* context, WarEntity* entity); void wsc_handleEnemyRaceRight(WarContext* context, WarEntity* entity); void wsc_handleMapLeft(WarContext* context, WarEntity* entity); void wsc_handleMapRight(WarContext* context, WarEntity* entity); void wsc_handleCustomGameOk(WarContext* context, WarEntity* entity); ================================================ FILE: src/war_scenes.c ================================================ #include "war_scenes.h" #include "war_animations.h" #include "war_cheats.h" #include "war_scene_blizzard.h" #include "war_scene_briefing.h" #include "war_scene_download.h" #include "war_scene_menu.h" WarSceneDescriptor sceneDescriptors[WAR_SCENE_COUNT] = { { WAR_SCENE_DOWNLOAD, wsc_enterSceneDownload, NULL, wsc_updateSceneDownload, wsc_renderSceneDownload, NULL }, { WAR_SCENE_BLIZZARD, wsc_enterSceneBlizzard, NULL, wsc_updateSceneBlizzard, wsc_renderSceneBlizzard, NULL }, { WAR_SCENE_MAIN_MENU, wsc_enterSceneMainMenu, NULL, NULL, wsc_renderSceneMainMenu, NULL }, { WAR_SCENE_BRIEFING, wsc_enterSceneBriefing, NULL, wsc_updateSceneBriefing, wsc_renderSceneBriefing, wsc_renderOverlayBriefing } }; WarScene* wsc_createScene(WarContext* context, WarSceneType type) { WarScene* scene = (WarScene*)wm_alloc(sizeof(WarScene)); scene->type = type; we_initEntityManager(context, &scene->entityManager); return scene; } void wsc_freeScene(WarScene* scene) { WarEntityManager* manager = &scene->entityManager; WarEntityMapFree(&manager->entitiesByType); WarUnitMapFree(&manager->unitsByType); WarEntityIdMapFree(&manager->entitiesById); WarEntityListFree(&manager->uiEntities); } void wsc_enterScene(WarContext* context) { WarScene* scene = context->scene; if (!inRange(scene->type, WAR_SCENE_DOWNLOAD, WAR_SCENE_COUNT)) { logError("Unkown scene type: %d", scene->type); return; } WarSceneFunc enterSceneFunc = sceneDescriptors[scene->type].enterSceneFunc; if (enterSceneFunc) { enterSceneFunc(context); } } void wsc_updateScene(WarContext* context) { TracyCZoneN(ctx, "UpdateScene", 1); WarScene* scene = context->scene; if (!inRange(scene->type, WAR_SCENE_DOWNLOAD, WAR_SCENE_COUNT)) { logError("Unkown scene type: %d", scene->type); TracyCZoneEnd(ctx); return; } WarSceneFunc updateSceneFunc = sceneDescriptors[scene->type].updateSceneFunc; if (updateSceneFunc) { updateSceneFunc(context); } else { wcheatp_updateCheatsPanel(context); wanim_updateAnimations(context); } TracyCZoneEnd(ctx); } void wsc_leaveScene(WarContext* context) { WarScene* scene = context->scene; if (!scene) return; if (!inRange(scene->type, WAR_SCENE_DOWNLOAD, WAR_SCENE_COUNT)) { logError("Unkown scene type: %d", scene->type); return; } WarSceneFunc leaveSceneFunc = sceneDescriptors[scene->type].leaveSceneFunc; if (leaveSceneFunc) { leaveSceneFunc(context); } else { wsc_freeScene(context->scene); context->scene = NULL; } } void wsc_renderScene(WarContext* context) { TracyCZoneN(ctx, "RenderScene", 1); WarScene* scene = context->scene; WarSceneFunc renderSceneFunc = sceneDescriptors[scene->type].renderSceneFunc; if (renderSceneFunc) { renderSceneFunc(context); } WarEntityList* uiEntities = we_getUIEntities(context); assert(uiEntities); for (s32 i = 0; i < uiEntities->count; i++) { WarEntity* entity = uiEntities->items[i]; if (entity && entity->id != 0) { we_renderEntity(context, entity); } } WarEntityList* animations = we_getEntitiesOfType(context, WAR_ENTITY_TYPE_ANIMATION); assert(animations); for(s32 i = 0; i < animations->count; i++) { WarEntity* entity = animations->items[i]; if (entity && entity->id != 0) { we_renderEntity(context, entity); } } // Overlay: rendered on top of both retained UI entities and animations. WarSceneFunc renderOverlayFunc = sceneDescriptors[scene->type].renderOverlayFunc; if (renderOverlayFunc) { renderOverlayFunc(context); } // Cheat panel (imui) — only renders if cheatStatus.enabled is true for this scene. wcheatp_renderCheatsPanel(context); TracyCZoneEnd(ctx); } ================================================ FILE: src/war_scenes.h ================================================ #pragma once #include "war_campaigns.h" #include "war_cheats.h" #include "war_entities.h" struct _WarScene { WarSceneType type; WarEntityManager entityManager; WarCheatStatus cheatStatus; union { struct { WarSceneDownloadState status; } download; struct { f32 time; } blizzard; struct { WarRace yourRace; WarRace enemyRace; s32 customMap; WarMainMenuPanel menuPanel; } menu; struct { f32 time; f32 scrollY; WarRace race; WarCampaignMapType mapType; StringView briefingText; } briefing; }; }; struct _WarSceneDescriptor { WarSceneType type; WarSceneFunc enterSceneFunc; WarSceneFunc leaveSceneFunc; WarSceneFunc updateSceneFunc; WarSceneFunc renderSceneFunc; // Optional: called in wsc_renderScene after the animation loop, so it // draws on top of both retained UI entities and sprite animations. WarSceneFunc renderOverlayFunc; }; WarScene* wsc_createScene(WarContext* context, WarSceneType type); void wsc_freeScene(WarScene* scene); void wsc_enterScene(WarContext* context); void wsc_updateScene(WarContext* context); void wsc_renderScene(WarContext* context); void wsc_leaveScene(WarContext* context); ================================================ FILE: src/war_sprites.c ================================================ #include "war_sprites.h" #include #include "SDL3/SDL.h" #include "war_render.h" #include "war_resources.h" WarSprite wspr_createSprite(WarContext *context, u32 width, u32 height, u8 data[]) { WarSprite sprite = (WarSprite){0}; assert(width <= UINT16_MAX); assert(height <= UINT16_MAX); sprite.frameWidth = width; sprite.frameHeight = height; sprite.framesCount = 1; sprite.texture = SDL_CreateTexture(context->renderer, SDL_PIXELFORMAT_RGBA32, SDL_TEXTUREACCESS_STREAMING, width, height); if (sprite.texture) { SDL_SetTextureScaleMode(sprite.texture, SDL_SCALEMODE_NEAREST); if (data) { SDL_UpdateTexture(sprite.texture, NULL, data, width * 4); } } sprite.frames[0].dx = 0; sprite.frames[0].dy = 0; sprite.frames[0].w = (u16)width; sprite.frames[0].h = (u16)height; sprite.frames[0].off = 0; sprite.frames[0].data = (u8*)wm_alloc(width * height * 4); if (data) memcpy(sprite.frames[0].data, data, width * height * 4); return sprite; } WarSprite wspr_createSpriteFromFrames(WarContext *context, u32 frameWidth, u32 frameHeight, u32 frameCount, WarSpriteFrame frames[]) { WarSprite sprite = (WarSprite){0}; sprite.frameWidth = frameWidth; sprite.frameHeight = frameHeight; sprite.framesCount = frameCount; sprite.texture = SDL_CreateTexture(context->renderer, SDL_PIXELFORMAT_RGBA32, SDL_TEXTUREACCESS_STREAMING, frameWidth, frameHeight); if (sprite.texture) { SDL_SetTextureScaleMode(sprite.texture, SDL_SCALEMODE_NEAREST); } for(u32 i = 0; i < frameCount; i++) { sprite.frames[i].dx = frames[i].dx; sprite.frames[i].dy = frames[i].dy; sprite.frames[i].w = frames[i].w; sprite.frames[i].h = frames[i].h; sprite.frames[i].off = 0; sprite.frames[i].data = (u8*)wm_alloc(frameWidth * frameHeight * 4); if (frames[i].data) memcpy(sprite.frames[i].data, frames[i].data, frameWidth * frameHeight * 4); } return sprite; } WarSprite wspr_createSpriteFromResource(WarContext* context, WarResource* resource, s32 frameIndicesCount, s32 frameIndices[]) { assert(resource); WarSprite sprite = (WarSprite){0}; switch(resource->type) { case WAR_RESOURCE_TYPE_IMAGE: { u32 width = resource->imageData.width; u32 height = resource->imageData.height; u8* data = resource->imageData.pixels; sprite = wspr_createSprite(context, width, height, data); break; } case WAR_RESOURCE_TYPE_SPRITE: { u32 frameWidth = resource->spriteData.frameWidth; u32 frameHeight = resource->spriteData.frameHeight; u32 framesCount = resource->spriteData.framesCount; WarSpriteFrame* frames = resource->spriteData.frames; if (frameIndicesCount > 0) { WarSpriteFrame* allFrames = frames; frames = (WarSpriteFrame*)wm_allocFrame(frameIndicesCount * sizeof(WarSpriteFrame)); for (s32 i = 0; i < frameIndicesCount; i++) { s32 frameIndex = frameIndices[i]; assert(frameIndex >= 0 && frameIndex < (s32)framesCount); frames[i] = allFrames[frameIndex]; } framesCount = frameIndicesCount; } sprite = wspr_createSpriteFromFrames(context, frameWidth, frameHeight, framesCount, frames); if (frameIndicesCount > 0) { // frames lives in frameZone — no explicit free needed } break; } case WAR_RESOURCE_TYPE_CURSOR: { u32 width = resource->cursor.width; u32 height = resource->cursor.height; u8* data = resource->cursor.pixels; sprite = wspr_createSprite(context, width, height, data); break; } default: { logWarning("Trying to load the resource of type %d as a sprite.", resource->type); assert(false); break; } } return sprite; } WarSprite wspr_createSpriteFromResourceIndex(WarContext* context, WarSpriteResourceRef spriteResourceRef) { WarResource* resource = wres_getOrCreateResource(context, spriteResourceRef.resourceIndex); return wspr_createSpriteFromResource(context, resource, spriteResourceRef.frameIndicesCount, spriteResourceRef.frameIndices); } void wspr_updateSpriteImage(WarContext *context, WarSprite sprite, u8 data[]) { NOT_USED(context); if (!sprite.texture) { logWarning("Trying to update a sprite with no texture"); return; } SDL_UpdateTexture(sprite.texture, NULL, data, sprite.frameWidth * 4); } void wspr_renderSubSprite(WarContext *context, WarSprite sprite, rect rs, rect rd, vec2 scale) { if (!sprite.texture) { logWarning("Trying to render a sprite with no texture"); return; } wr_subImage(context, sprite.texture, rs, rd, scale); } void wspr_renderSprite(WarContext *context, WarSprite sprite, vec2 pos, vec2 scale) { if (!sprite.texture) { logWarning("Trying to render a sprite with no texture"); return; } vec2 frameSize = vec2i(sprite.frameWidth, sprite.frameHeight); rect rs = rectv(VEC2_ZERO, frameSize); rect rd = rectv(pos, frameSize); wr_subImage(context, sprite.texture, rs, rd, scale); } WarSpriteFrame wspr_getSpriteFrame(WarContext* context, WarSprite sprite, s32 frameIndex) { NOT_USED(context); assert(sprite.texture); assert(frameIndex >= 0 && frameIndex < (s32)sprite.framesCount); return sprite.frames[frameIndex]; } void wspr_freeSprite(WarContext* context, WarSprite sprite) { NOT_USED(context); if (!sprite.texture) { logWarning("Trying to free a sprite with no texture"); return; } for (s32 i = 0; i < sprite.framesCount; i++) { if (sprite.frames[i].data) wm_free(sprite.frames[i].data); } SDL_DestroyTexture(sprite.texture); } ================================================ FILE: src/war_sprites.h ================================================ #pragma once #include "SDL3/SDL.h" #include "common.h" #include "war.h" #include "war_math.h" struct _WarSpriteFrame { u16 dx, dy; u16 w, h; u32 off; u8* data; }; struct _WarSprite { SDL_Texture* texture; s32 frameWidth; s32 frameHeight; s32 framesCount; WarSpriteFrame frames[MAX_SPRITE_FRAME_COUNT]; }; struct _WarSpriteResourceRef { s32 resourceIndex; s32 frameIndicesCount; s32 frameIndices[MAX_SPRITE_FRAME_COUNT]; }; WarSpriteResourceRef wspr_createSpriteResourceRef(s32 resourceIndex, s32 frameIndicesCount, s32 frameIndices[]) { WarSpriteResourceRef spriteResourceRef = (WarSpriteResourceRef){0}; spriteResourceRef.resourceIndex = resourceIndex; spriteResourceRef.frameIndicesCount = frameIndicesCount; if (frameIndices) { memcpy(spriteResourceRef.frameIndices, frameIndices, frameIndicesCount * sizeof(s32)); } return spriteResourceRef; } #define invalidResourceRef() wspr_createSpriteResourceRef(-1, 0, NULL) #define imageResourceRef(resourceIndex) wspr_createSpriteResourceRef((resourceIndex), 0, NULL) #define spriteResourceRef(resourceIndex, spriteIndex) wspr_createSpriteResourceRef((resourceIndex), 1, arrayArg(s32, (spriteIndex))) WarSprite wspr_createSprite(WarContext* context, u32 width, u32 height, u8 data[]); WarSprite wspr_createSpriteFromFrames(WarContext* context, u32 frameWidth, u32 frameHeight, u32 frameCount, WarSpriteFrame frames[]); WarSprite wspr_createSpriteFromResource(WarContext* context, WarResource* resource, s32 frameIndicesCount, s32 frameIndices[]); WarSprite wspr_createSpriteFromResourceIndex(WarContext* context, WarSpriteResourceRef spriteResourceRef); void wspr_updateSpriteImage(WarContext* context, WarSprite sprite, u8 data[]); void wspr_renderSubSprite(WarContext* context, WarSprite sprite, rect rs, rect rd, vec2 scale); void wspr_renderSprite(WarContext* context, WarSprite sprite, vec2 pos, vec2 scale); WarSpriteFrame wspr_getSpriteFrame(WarContext* context, WarSprite sprite, s32 frameIndex); void wspr_freeSprite(WarContext* context, WarSprite sprite); ================================================ FILE: src/war_state_machine.c ================================================ #include "war_state_machine.h" WarStateDescriptor stateDescriptors[WAR_STATE_COUNT] = { { WAR_STATE_IDLE, wst_enterIdleState, wst_leaveIdleState, wst_updateIdleState, wst_freeIdleState }, { WAR_STATE_MOVE, wst_enterMoveState, wst_leaveMoveState, wst_updateMoveState, wst_freeMoveState }, { WAR_STATE_PATROL, wst_enterPatrolState, wst_leavePatrolState, wst_updatePatrolState, wst_freePatrolState }, { WAR_STATE_FOLLOW, wst_enterFollowState, wst_leaveFollowState, wst_updateFollowState, wst_freeFollowState }, { WAR_STATE_ATTACK, wst_enterAttackState, wst_leaveAttackState, wst_updateAttackState, wst_freeAttackState }, { WAR_STATE_GOLD, wst_enterGatherGoldState, wst_leaveGatherGoldState, wst_updateGatherGoldState, wst_freeGatherGoldState }, { WAR_STATE_MINING, wst_enterMiningState, wst_leaveMiningState, wst_updateMiningState, wst_freeMiningState }, { WAR_STATE_WOOD, wst_enterGatherWoodState, wst_leaveGatherWoodState, wst_updateGatherWoodState, wst_freeGatherWoodState }, { WAR_STATE_CHOPPING, wst_enterChoppingState, wst_leaveChoppingState, wst_updateChoppingState, wst_freeChoppingState }, { WAR_STATE_DELIVER, wst_enterDeliverState, wst_leaveDeliverState, wst_updateDeliverState, wst_freeDeliverState }, { WAR_STATE_DEATH, wst_enterDeathState, wst_leaveDeathState, wst_updateDeathState, wst_freeDeathState }, { WAR_STATE_COLLAPSE, wst_enterCollapseState, wst_leaveCollapseState, wst_updateCollapseState, wst_freeCollapseState }, { WAR_STATE_TRAIN, wst_enterTrainState, wst_leaveTrainState, wst_updateTrainState, wst_freeTrainState }, { WAR_STATE_UPGRADE, wst_enterUpgradeState, wst_leaveUpgradeState, wst_updateUpgradeState, wst_freeUpgradeState }, { WAR_STATE_BUILD, wst_enterBuildState, wst_leaveBuildState, wst_updateBuildState, wst_freeBuildState }, { WAR_STATE_REPAIR, wst_enterRepairState, wst_leaveRepairState, wst_updateRepairState, wst_freeRepairState }, { WAR_STATE_REPAIRING, wst_enterRepairingState, wst_leaveRepairingState, wst_updateRepairingState, wst_freeRepairingState }, { WAR_STATE_CAST, wst_enterCastState, wst_leaveCastState, wst_updateCastState, wst_freeCastState }, { WAR_STATE_WAIT, wst_enterWaitState, wst_leaveWaitState, wst_updateWaitState, wst_freeWaitState }, }; bool wst_isInsideBuilding(WarContext* context, WarEntity* entity) { if (wst_isMining(context, entity)) { return true; } if(wst_isDelivering(context, entity)) { WarState* deliver = wst_getDeliverState(context, entity); return deliver->deliver.insideBuilding; } if (wst_isRepairing2(context, entity)) { WarState* repairing = wst_getRepairingState(context, entity); return repairing->repairing.insideBuilding; } return false; } WarState* wst_createState(WarContext* context, WarEntity* entity, WarStateType type) { NOT_USED(context); WarState* state = (WarState*)wm_alloc(sizeof(WarState)); state->type = type; state->entityId = entity->id; state->nextUpdateTime = 0; state->delay = 0; return state; } void wst_changeNextState(WarContext* context, WarEntity* entity, WarState* state, bool wst_leaveState, bool wst_enterState) { WarStateMachineComponent* stateMachine = we_getStateMachineComponent(context, entity); assert(stateMachine); stateMachine->nextState = state; stateMachine->leaveState = wst_leaveState; stateMachine->enterState = wst_enterState; } bool wst_changeStateNextState(WarContext* context, WarEntity* entity, WarState* state) { if(state->nextState) { wst_changeNextState(context, entity, state->nextState, true, false); state->nextState = NULL; return true; } return false; } WarState* wst_getState(WarContext* context, WarEntity* entity, WarStateType type) { WarStateMachineComponent* stateMachine = we_getStateMachineComponent(context, entity); assert(stateMachine); WarState* state = stateMachine->currentState; while (state && state->type != type) state = state->nextState; return state; } WarState* wst_getDirectState(WarContext* context, WarEntity* entity, WarStateType type) { WarStateMachineComponent* stateMachine = we_getStateMachineComponent(context, entity); assert(stateMachine); WarState* state = stateMachine->currentState; return state && state->type == type ? state : NULL; } WarState* wst_getNextState(WarContext* context, WarEntity* entity, WarStateType type) { WarStateMachineComponent* stateMachine = we_getStateMachineComponent(context, entity); assert(stateMachine); WarState* state = stateMachine->nextState; return state && state->type == type ? state : NULL; } WarState* wst_getIdleState(WarContext* context, WarEntity* entity) { return wst_getDirectState(context, entity, WAR_STATE_IDLE); } WarState* wst_getMoveState(WarContext* context, WarEntity* entity) { return wst_getState(context, entity, WAR_STATE_MOVE); } WarState* wst_getPatrolState(WarContext* context, WarEntity* entity) { return wst_getState(context, entity, WAR_STATE_PATROL); } WarState* wst_getFollowState(WarContext* context, WarEntity* entity) { return wst_getState(context, entity, WAR_STATE_FOLLOW); } WarState* wst_getAttackState(WarContext* context, WarEntity* entity) { return wst_getState(context, entity, WAR_STATE_ATTACK); } WarState* wst_getDeathState(WarContext* context, WarEntity* entity) { return wst_getState(context, entity, WAR_STATE_DEATH); } WarState* wst_getCollapseState(WarContext* context, WarEntity* entity) { return wst_getState(context, entity, WAR_STATE_COLLAPSE); } WarState* wst_getGatherGoldState(WarContext* context, WarEntity* entity) { return wst_getState(context, entity, WAR_STATE_GOLD); } WarState* wst_getMiningState(WarContext* context, WarEntity* entity) { return wst_getState(context, entity, WAR_STATE_MINING); } WarState* wst_getGatherWoodState(WarContext* context, WarEntity* entity) { return wst_getState(context, entity, WAR_STATE_WOOD); } WarState* wst_getChoppingState(WarContext* context, WarEntity* entity) { return wst_getState(context, entity, WAR_STATE_CHOPPING); } WarState* wst_getDeliverState(WarContext* context, WarEntity* entity) { return wst_getState(context, entity, WAR_STATE_DELIVER); } WarState* wst_getTrainState(WarContext* context, WarEntity* entity) { return wst_getState(context, entity, WAR_STATE_TRAIN); } WarState* wst_getUpgradeState(WarContext* context, WarEntity* entity) { return wst_getState(context, entity, WAR_STATE_UPGRADE); } WarState* wst_getBuildState(WarContext* context, WarEntity* entity) { return wst_getState(context, entity, WAR_STATE_BUILD); } WarState* wst_getRepairState(WarContext* context, WarEntity* entity) { return wst_getState(context, entity, WAR_STATE_REPAIR); } WarState* wst_getRepairingState(WarContext* context, WarEntity* entity) { return wst_getState(context, entity, WAR_STATE_REPAIRING); } WarState* wst_getCastState(WarContext* context, WarEntity* entity) { return wst_getState(context, entity, WAR_STATE_CAST); } bool wst_hasState(WarContext* context, WarEntity* entity, WarStateType type) { return wst_getState(context, entity, type) != NULL; } bool wst_hasDirectState(WarContext* context, WarEntity* entity, WarStateType type) { return wst_getDirectState(context, entity, type) != NULL; } bool wst_hasNextState(WarContext* context, WarEntity* entity, WarStateType type) { return wst_getNextState(context, entity, type) != NULL; } bool wst_isIdle(WarContext* context, WarEntity* entity) { return wst_hasDirectState(context, entity, WAR_STATE_IDLE); } bool wst_isMoving(WarContext* context, WarEntity* entity) { return wst_hasState(context, entity, WAR_STATE_MOVE); } bool wst_isPatrolling(WarContext* context, WarEntity* entity) { return wst_hasState(context, entity, WAR_STATE_PATROL); } bool wst_isFollowing(WarContext* context, WarEntity* entity) { return wst_hasState(context, entity, WAR_STATE_FOLLOW); } bool wst_isAttacking(WarContext* context, WarEntity* entity) { return wst_hasState(context, entity, WAR_STATE_ATTACK); } bool wst_isDead(WarContext* context, WarEntity* entity) { return wst_hasState(context, entity, WAR_STATE_DEATH); } bool wst_isCollapsing(WarContext* context, WarEntity* entity) { return wst_hasState(context, entity, WAR_STATE_COLLAPSE); } bool wst_isGatheringGold(WarContext* context, WarEntity* entity) { return wst_hasState(context, entity, WAR_STATE_GOLD); } bool wst_isMining(WarContext* context, WarEntity* entity) { return wst_hasState(context, entity, WAR_STATE_MINING); } bool wst_isGatheringWood(WarContext* context, WarEntity* entity) { return wst_hasState(context, entity, WAR_STATE_WOOD); } bool wst_isChopping(WarContext* context, WarEntity* entity) { return wst_hasState(context, entity, WAR_STATE_CHOPPING); } bool wst_isDelivering(WarContext* context, WarEntity* entity) { return wst_hasState(context, entity, WAR_STATE_DELIVER); } bool wst_isTraining(WarContext* context, WarEntity* entity) { return wst_hasState(context, entity, WAR_STATE_TRAIN); } bool wst_isUpgrading(WarContext* context, WarEntity* entity) { return wst_hasState(context, entity, WAR_STATE_UPGRADE); } bool wst_isBuilding(WarContext* context, WarEntity* entity) { return wst_hasState(context, entity, WAR_STATE_BUILD); } bool wst_isRepairing(WarContext* context, WarEntity* entity) { return wst_hasState(context, entity, WAR_STATE_REPAIR); } bool wst_isRepairing2(WarContext* context, WarEntity* entity) { return wst_hasState(context, entity, WAR_STATE_REPAIRING); } bool wst_isCasting(WarContext* context, WarEntity* entity) { return wst_hasState(context, entity, WAR_STATE_CAST); } bool wst_isGoingToIdle(WarContext* context, WarEntity* entity) { return wst_hasNextState(context, entity, WAR_STATE_IDLE); } bool wst_isGoingToMove(WarContext* context, WarEntity* entity) { return wst_hasNextState(context, entity, WAR_STATE_MOVE); } bool wst_isGoingToPatrol(WarContext* context, WarEntity* entity) { return wst_hasNextState(context, entity, WAR_STATE_PATROL); } bool wst_isGoingToFollow(WarContext* context, WarEntity* entity) { return wst_hasNextState(context, entity, WAR_STATE_FOLLOW); } bool wst_isGoingToAttack(WarContext* context, WarEntity* entity) { return wst_hasNextState(context, entity, WAR_STATE_ATTACK); } bool wst_isGoingToDie(WarContext* context, WarEntity* entity) { return wst_hasNextState(context, entity, WAR_STATE_DEATH); } bool wst_isGoingToCollapse(WarContext* context, WarEntity* entity) { return wst_hasNextState(context, entity, WAR_STATE_COLLAPSE); } bool wst_isGoingToGatherGold(WarContext* context, WarEntity* entity) { return wst_hasNextState(context, entity, WAR_STATE_GOLD); } bool wst_isGoingToMine(WarContext* context, WarEntity* entity) { return wst_hasNextState(context, entity, WAR_STATE_MINING); } bool wst_isGoingToGatherWood(WarContext* context, WarEntity* entity) { return wst_hasNextState(context, entity, WAR_STATE_WOOD); } bool wst_isGoingToChop(WarContext* context, WarEntity* entity) { return wst_hasNextState(context, entity, WAR_STATE_CHOPPING); } bool wst_isGoingToDeliver(WarContext* context, WarEntity* entity) { return wst_hasNextState(context, entity, WAR_STATE_DELIVER); } bool wst_isGoingToTrain(WarContext* context, WarEntity* entity) { return wst_hasNextState(context, entity, WAR_STATE_TRAIN); } bool wst_isGoingToUpgrade(WarContext* context, WarEntity* entity) { return wst_hasNextState(context, entity, WAR_STATE_UPGRADE); } bool wst_isGoingToBuild(WarContext* context, WarEntity* entity) { return wst_hasNextState(context, entity, WAR_STATE_BUILD); } bool wst_isGoingToRepair(WarContext* context, WarEntity* entity) { return wst_hasNextState(context, entity, WAR_STATE_REPAIR); } bool wst_isGoingToRepair2(WarContext* context, WarEntity* entity) { return wst_hasNextState(context, entity, WAR_STATE_REPAIRING); } bool wst_isGoingToCast(WarContext* context, WarEntity* entity) { return wst_hasNextState(context, entity, WAR_STATE_CAST); } void wst_enterState(WarContext* context, WarEntity* entity, WarState* state) { if (!inRange(state->type, WAR_STATE_IDLE, WAR_STATE_COUNT)) { logError("Unkown state %d for entity %d", state->type, entity->id); return; } stateDescriptors[state->type].enterStateFunc(context, entity, state); } void wst_leaveState(WarContext* context, WarEntity* entity, WarState* state) { if (!state) { return; } if (!inRange(state->type, WAR_STATE_IDLE, WAR_STATE_COUNT)) { logError("Unkown state %d for entity %d", state->type, entity->id); return; } stateDescriptors[state->type].leaveStateFunc(context, entity, state); wst_freeState(context, state); } void wst_updateStateMachine(WarContext* context, WarEntity* entity) { if (we_isComponentEnabled(context, entity, COMP_STATE_MACHINE)) { WarStateMachineComponent* stateMachine = we_getStateMachineComponent(context, entity); assert(stateMachine); // the wst_enterState could potentially change state if it determine that is not ready to start the current state while (stateMachine->nextState) { if (stateMachine->leaveState) wst_leaveState(context, entity, stateMachine->currentState); stateMachine->currentState = stateMachine->nextState; stateMachine->nextState = NULL; if (stateMachine->enterState) wst_enterState(context, entity, stateMachine->currentState); } WarState* currentState = stateMachine->currentState; if (currentState->delay > 0) { currentState->nextUpdateTime = context->time + currentState->delay; currentState->delay = 0; } if (context->time >= currentState->nextUpdateTime) { if (!inRange(currentState->type, WAR_STATE_IDLE, WAR_STATE_COUNT)) { logError("Unkown state %d for entity %d", currentState->type, entity->id); return; } stateDescriptors[currentState->type].updateStateFunc(context, entity, currentState); } } } void wst_freeState(WarContext* context, WarState* state) { if (!inRange(state->type, WAR_STATE_IDLE, WAR_STATE_COUNT)) { logError("Unkown state %d", state->type); return; } stateDescriptors[state->type].freeStateFunc(context, state); if (state->nextState) wst_freeState(context, state->nextState); wm_free(state); } ================================================ FILE: src/war_state_machine.h ================================================ #pragma once #include "war_math.h" #include "war_units.h" #include "war_pathfinder.h" struct _WarState { WarStateType type; s32 entityId; f32 nextUpdateTime; f32 delay; struct _WarState* nextState; union { struct { bool lookAround; } idle; struct { s32 positionIndex; vec2List positions; s32 pathNodeIndex; WarMapPath path; s32 waitCount; bool checkForAttacks; } move; struct { s32 positionIndex; vec2List positions; s32 dir; } patrol; struct { // the follow state can follow an entity or a point s32 targetEntityId; vec2 targetTile; // the range distance (in tiles) in which the follower stops s32 distance; } follow; struct { f32 waitTime; } wait; struct { s32 targetEntityId; vec2 targetTile; } attack; struct { s32 goldmineId; } gold; struct { s32 goldmineId; f32 miningTime; } mine; struct { s32 forestId; vec2 position; } wood; struct { s32 forestId; vec2 position; } chop; struct { s32 townHallId; bool insideBuilding; } deliver; struct { WarUnitType unitToBuild; f32 buildTime; f32 totalBuildTime; bool cancelled; } train; struct { WarUpgradeType upgradeToBuild; f32 buildTime; f32 totalBuildTime; bool cancelled; } upgrade; struct { WarEntityId workerId; f32 buildTime; f32 totalBuildTime; bool cancelled; } build; struct { WarEntityId buildingId; } repair; struct { WarEntityId buildingId; bool insideBuilding; } repairing; struct { WarSpellType spellType; WarEntityId targetEntityId; vec2 targetTile; } cast; }; }; typedef struct { WarStateType type; void (*enterStateFunc)(WarContext* context, WarEntity* entity, WarState* state); void (*leaveStateFunc)(WarContext* context, WarEntity* entity, WarState* state); void (*updateStateFunc)(WarContext* context, WarEntity* entity, WarState* state); void (*freeStateFunc)(WarContext* context, WarState* state); } WarStateDescriptor; WarState* wst_createState(WarContext* context, WarEntity* entity, WarStateType type); WarState* wst_createIdleState(WarContext* context, WarEntity* entity, bool lookAround); WarState* wst_createMoveState(WarContext* context, WarEntity* entity, s32 positionCount, vec2 positions[]); WarState* wst_createPatrolState(WarContext* context, WarEntity* entity, s32 positionCount, vec2 positions[]); WarState* wst_createFollowState(WarContext* context, WarEntity* entity, WarEntityId targetEntityId, vec2 targetTile, s32 distance); WarState* wst_createAttackState(WarContext* context, WarEntity* entity, WarEntityId targetEntityId, vec2 targetTile); WarState* wst_createDeathState(WarContext* context, WarEntity* entity); WarState* wst_createCollapseState(WarContext* context, WarEntity* entity); WarState* wst_createWaitState(WarContext* context, WarEntity* entity, f32 waitTime); WarState* wst_createGatherGoldState(WarContext* context, WarEntity* entity, WarEntityId goldmineId); WarState* wst_createMiningState(WarContext* context, WarEntity* entity, WarEntityId goldmineId); WarState* wst_createGatherWoodState(WarContext* context, WarEntity* entity, WarEntityId targetEntityId, vec2 position); WarState* wst_createChoppingState(WarContext* context, WarEntity* entity, WarEntityId forestId, vec2 position); WarState* wst_createDeliverState(WarContext* context, WarEntity* entity, WarEntityId townHallId); WarState* wst_createTrainState(WarContext* context, WarEntity* entity, WarUnitType unitToBuild, f32 buildTime); WarState* wst_createUpgradeState(WarContext* context, WarEntity* entity, WarUpgradeType upgradeToBuild, f32 buildTime); WarState* wst_createBuildState(WarContext* context, WarEntity* entity, f32 buildTime); WarState* wst_createRepairState(WarContext* context, WarEntity* entity, WarEntityId buildingId); WarState* wst_createRepairingState(WarContext* context, WarEntity* entity, WarEntityId buildingId); WarState* wst_createCastState(WarContext* context, WarEntity* entity, WarSpellType spellType, WarEntityId targetEntityId, vec2 targetTile); void wst_changeNextState(WarContext* context, WarEntity* entity, WarState* state, bool wst_leaveState, bool wst_enterState); bool wst_changeStateNextState(WarContext* context, WarEntity* entity, WarState* state); WarState* wst_getState(WarContext* context, WarEntity* entity, WarStateType type); WarState* wst_getDirectState(WarContext* context, WarEntity* entity, WarStateType type); WarState* wst_getNextState(WarContext* context, WarEntity* entity, WarStateType type); WarState* wst_getIdleState(WarContext* context, WarEntity* entity); WarState* wst_getMoveState(WarContext* context, WarEntity* entity); WarState* wst_getPatrolState(WarContext* context, WarEntity* entity); WarState* wst_getFollowState(WarContext* context, WarEntity* entity); WarState* wst_getAttackState(WarContext* context, WarEntity* entity); WarState* wst_getDeathState(WarContext* context, WarEntity* entity); WarState* wst_getCollapseState(WarContext* context, WarEntity* entity); WarState* wst_getGatherGoldState(WarContext* context, WarEntity* entity); WarState* wst_getMiningState(WarContext* context, WarEntity* entity); WarState* wst_getGatherWoodState(WarContext* context, WarEntity* entity); WarState* wst_getChoppingState(WarContext* context, WarEntity* entity); WarState* wst_getDeliverState(WarContext* context, WarEntity* entity); WarState* wst_getTrainState(WarContext* context, WarEntity* entity); WarState* wst_getUpgradeState(WarContext* context, WarEntity* entity); WarState* wst_getBuildState(WarContext* context, WarEntity* entity); WarState* wst_getRepairState(WarContext* context, WarEntity* entity); WarState* wst_getRepairingState(WarContext* context, WarEntity* entity); WarState* wst_getCastState(WarContext* context, WarEntity* entity); bool wst_hasState(WarContext* context, WarEntity* entity, WarStateType type); bool wst_hasDirectState(WarContext* context, WarEntity* entity, WarStateType type); bool wst_hasNextState(WarContext* context, WarEntity* entity, WarStateType type); bool wst_isIdle(WarContext* context, WarEntity* entity); bool wst_isMoving(WarContext* context, WarEntity* entity); bool wst_isPatrolling(WarContext* context, WarEntity* entity); bool wst_isFollowing(WarContext* context, WarEntity* entity); bool wst_isAttacking(WarContext* context, WarEntity* entity); bool wst_isDead(WarContext* context, WarEntity* entity); bool wst_isCollapsing(WarContext* context, WarEntity* entity); bool wst_isGatheringGold(WarContext* context, WarEntity* entity); bool wst_isMining(WarContext* context, WarEntity* entity); bool wst_isGatheringWood(WarContext* context, WarEntity* entity); bool wst_isChopping(WarContext* context, WarEntity* entity); bool wst_isDelivering(WarContext* context, WarEntity* entity); bool wst_isTraining(WarContext* context, WarEntity* entity); bool wst_isUpgrading(WarContext* context, WarEntity* entity); bool wst_isBuilding(WarContext* context, WarEntity* entity); bool wst_isRepairing(WarContext* context, WarEntity* entity); bool wst_isRepairing2(WarContext* context, WarEntity* entity); bool wst_isCasting(WarContext* context, WarEntity* entity); bool wst_isGoingToIdle(WarContext* context, WarEntity* entity); bool wst_isGoingToMove(WarContext* context, WarEntity* entity); bool wst_isGoingToPatrol(WarContext* context, WarEntity* entity); bool wst_isGoingToFollow(WarContext* context, WarEntity* entity); bool wst_isGoingToAttack(WarContext* context, WarEntity* entity); bool wst_isGoingToDie(WarContext* context, WarEntity* entity); bool wst_isGoingToCollapse(WarContext* context, WarEntity* entity); bool wst_isGoingToGatherGold(WarContext* context, WarEntity* entity); bool wst_isGoingToMine(WarContext* context, WarEntity* entity); bool wst_isGoingToGatherWood(WarContext* context, WarEntity* entity); bool wst_isGoingToChop(WarContext* context, WarEntity* entity); bool wst_isGoingToDeliver(WarContext* context, WarEntity* entity); bool wst_isGoingToTrain(WarContext* context, WarEntity* entity); bool wst_isGoingToUpgrade(WarContext* context, WarEntity* entity); bool wst_isGoingToBuild(WarContext* context, WarEntity* entity); bool wst_isGoingToRepair(WarContext* context, WarEntity* entity); bool wst_isGoingToRepair2(WarContext* context, WarEntity* entity); bool wst_isGoingToCast(WarContext* context, WarEntity* entity); bool wst_isInsideBuilding(WarContext* context, WarEntity* entity); void wst_enterIdleState(WarContext* context, WarEntity* entity, WarState* state); void wst_enterMoveState(WarContext* context, WarEntity* entity, WarState* state); void wst_enterPatrolState(WarContext* context, WarEntity* entity, WarState* state); void wst_enterFollowState(WarContext* context, WarEntity* entity, WarState* state); void wst_enterAttackState(WarContext* context, WarEntity* entity, WarState* state); void wst_enterGatherGoldState(WarContext* context, WarEntity* entity, WarState* state); void wst_enterMiningState(WarContext* context, WarEntity* entity, WarState* state); void wst_enterGatherWoodState(WarContext* context, WarEntity* entity, WarState* state); void wst_enterChoppingState(WarContext* context, WarEntity* entity, WarState* state); void wst_enterDeliverState(WarContext* context, WarEntity* entity, WarState* state); void wst_enterDeathState(WarContext* context, WarEntity* entity, WarState* state); void wst_enterCollapseState(WarContext* context, WarEntity* entity, WarState* state); void wst_enterTrainState(WarContext* context, WarEntity* entity, WarState* state); void wst_enterUpgradeState(WarContext* context, WarEntity* entity, WarState* state); void wst_enterBuildState(WarContext* context, WarEntity* entity, WarState* state); void wst_enterRepairState(WarContext* context, WarEntity* entity, WarState* state); void wst_enterRepairingState(WarContext* context, WarEntity* entity, WarState* state); void wst_enterCastState(WarContext* context, WarEntity* entity, WarState* state); void wst_enterWaitState(WarContext* context, WarEntity* entity, WarState* state); void wst_leaveIdleState(WarContext* context, WarEntity* entity, WarState* state); void wst_leaveMoveState(WarContext* context, WarEntity* entity, WarState* state); void wst_leavePatrolState(WarContext* context, WarEntity* entity, WarState* state); void wst_leaveFollowState(WarContext* context, WarEntity* entity, WarState* state); void wst_leaveAttackState(WarContext* context, WarEntity* entity, WarState* state); void wst_leaveGatherGoldState(WarContext* context, WarEntity* entity, WarState* state); void wst_leaveMiningState(WarContext* context, WarEntity* entity, WarState* state); void wst_leaveGatherWoodState(WarContext* context, WarEntity* entity, WarState* state); void wst_leaveChoppingState(WarContext* context, WarEntity* entity, WarState* state); void wst_leaveDeliverState(WarContext* context, WarEntity* entity, WarState* state); void wst_leaveDeathState(WarContext* context, WarEntity* entity, WarState* state); void wst_leaveCollapseState(WarContext* context, WarEntity* entity, WarState* state); void wst_leaveTrainState(WarContext* context, WarEntity* entity, WarState* state); void wst_leaveUpgradeState(WarContext* context, WarEntity* entity, WarState* state); void wst_leaveBuildState(WarContext* context, WarEntity* entity, WarState* state); void wst_leaveRepairState(WarContext* context, WarEntity* entity, WarState* state); void wst_leaveRepairingState(WarContext* context, WarEntity* entity, WarState* state); void wst_leaveCastState(WarContext* context, WarEntity* entity, WarState* state); void wst_leaveWaitState(WarContext* context, WarEntity* entity, WarState* state); void wst_updateIdleState(WarContext* context, WarEntity* entity, WarState* state); void wst_updateMoveState(WarContext* context, WarEntity* entity, WarState* state); void wst_updatePatrolState(WarContext* context, WarEntity* entity, WarState* state); void wst_updateFollowState(WarContext* context, WarEntity* entity, WarState* state); void wst_updateAttackState(WarContext* context, WarEntity* entity, WarState* state); void wst_updateGatherGoldState(WarContext* context, WarEntity* entity, WarState* state); void wst_updateMiningState(WarContext* context, WarEntity* entity, WarState* state); void wst_updateGatherWoodState(WarContext* context, WarEntity* entity, WarState* state); void wst_updateChoppingState(WarContext* context, WarEntity* entity, WarState* state); void wst_updateDeliverState(WarContext* context, WarEntity* entity, WarState* state); void wst_updateDeathState(WarContext* context, WarEntity* entity, WarState* state); void wst_updateCollapseState(WarContext* context, WarEntity* entity, WarState* state); void wst_updateTrainState(WarContext* context, WarEntity* entity, WarState* state); void wst_updateUpgradeState(WarContext* context, WarEntity* entity, WarState* state); void wst_updateBuildState(WarContext* context, WarEntity* entity, WarState* state); void wst_updateRepairState(WarContext* context, WarEntity* entity, WarState* state); void wst_updateRepairingState(WarContext* context, WarEntity* entity, WarState* state); void wst_updateCastState(WarContext* context, WarEntity* entity, WarState* state); void wst_updateWaitState(WarContext* context, WarEntity* entity, WarState* state); void wst_freeIdleState(WarContext* context, WarState* state); void wst_freeMoveState(WarContext* context, WarState* state); void wst_freePatrolState(WarContext* context, WarState* state); void wst_freeFollowState(WarContext* context, WarState* state); void wst_freeAttackState(WarContext* context, WarState* state); void wst_freeGatherGoldState(WarContext* context, WarState* state); void wst_freeMiningState(WarContext* context, WarState* state); void wst_freeGatherWoodState(WarContext* context, WarState* state); void wst_freeChoppingState(WarContext* context, WarState* state); void wst_freeDeliverState(WarContext* context, WarState* state); void wst_freeDeathState(WarContext* context, WarState* state); void wst_freeCollapseState(WarContext* context, WarState* state); void wst_freeTrainState(WarContext* context, WarState* state); void wst_freeUpgradeState(WarContext* context, WarState* state); void wst_freeBuildState(WarContext* context, WarState* state); void wst_freeRepairState(WarContext* context, WarState* state); void wst_freeRepairingState(WarContext* context, WarState* state); void wst_freeCastState(WarContext* context, WarState* state); void wst_freeWaitState(WarContext* context, WarState* state); void wst_enterState(WarContext* context, WarEntity* entity, WarState* state); void wst_leaveState(WarContext* context, WarEntity* entity, WarState* state); void wst_updateStateMachine(WarContext* context, WarEntity* entity); void wst_freeState(WarContext* context, WarState* state); ================================================ FILE: src/war_state_machine_attack.c ================================================ #include "war_state_machine.h" #include "war_map.h" #include "war_actions.h" #include "war_audio.h" #include "war_units.h" WarState* wst_createAttackState(WarContext* context, WarEntity* entity, WarEntityId targetEntityId, vec2 targetTile) { WarState* state = wst_createState(context, entity, WAR_STATE_ATTACK); state->attack.targetEntityId = targetEntityId; state->attack.targetTile = targetTile; return state; } void wst_enterAttackState(WarContext* context, WarEntity* entity, WarState* state) { NOT_USED(context); NOT_USED(entity); NOT_USED(state); } void wst_leaveAttackState(WarContext* context, WarEntity* entity, WarState* state) { NOT_USED(context); NOT_USED(entity); NOT_USED(state); } void wst_updateAttackState(WarContext* context, WarEntity* entity, WarState* state) { WarMap* map = context->map; WarUnitComponent* unit = we_getUnitComponent(context, entity); assert(unit); vec2 unitSize = wu_getUnitSize(context, entity); WarTransformComponent* transform = we_getTransformComponent(context, entity); assert(transform); vec2 position = wmap_mapToTileCoordinatesV(transform->position); const WarUnitStats* stats = wu_getUnitStats(unit->type); WarEntityId targetEntityId = (WarEntityId)state->attack.targetEntityId; WarEntity* targetEntity = we_findEntity(context, targetEntityId); vec2 targetTile = state->attack.targetTile; // if the entity to attack doesn't exists, go to the attacking point or go idle if (!targetEntity) { // when going to an attacking point (where there is no target unit) // check if the attacking unit is in range 1, no matter if the range // of the attacking unit is greater if(!wu_tileInRange(context, entity, targetTile, 1)) { WarState* moveState = wst_createMoveState(context, entity, 2, arrayArg(vec2, position, targetTile)); moveState->nextState = state; moveState->move.checkForAttacks = true; wst_changeNextState(context, entity, moveState, false, true); return; } WarState* idleState = wst_createIdleState(context, entity, true); wst_changeNextState(context, entity, idleState, true, true); return; } if (wu_isUnit(targetEntity)) { // if the target entity is an unit the instead of using the tile where // the player click, use a point on the target unit that is closer to // the attacking unit targetTile = wu_unitPointOnTarget(context, entity, targetEntity); } // if the unit is not in range to attack, chase it if (wu_isUnit(targetEntity) && !wu_unitInRange(context, entity, targetEntity, stats->range)) { WarState* followState = wst_createFollowState(context, entity, targetEntityId, targetTile, stats->range); followState->nextState = state; wst_changeNextState(context, entity, followState, false, true); return; } if(wu_isWall(targetEntity) && !wu_tileInRange(context, entity, targetTile, stats->range)) { WarState* followState = wst_createFollowState(context, entity, 0, targetTile, stats->range); followState->nextState = state; wst_changeNextState(context, entity, followState, false, true); return; } // if the unit is attacking a worker that is currently gathering and inside of the goldmine or the townhall, // wcmd_stop the attacking for a moment until the unit come out again if (wst_isInsideBuilding(context, targetEntity)) { WarState* waitState = wst_createWaitState(context, entity, 1.0f); waitState->nextState = state; wst_changeNextState(context, entity, waitState, false, true); return; } setStaticEntity(map->finder, (s32)position.x, (s32)position.y, (s32)unitSize.x, (s32)unitSize.y, entity->id); wu_setUnitDirectionFromDiff(context, entity, targetTile.x - position.x, targetTile.y - position.y); wact_setAction(context, entity, WAR_ACTION_TYPE_ATTACK, false, 1.0f); WarUnitAction* action = &unit->actions[unit->actionType]; if (action->lastActionStep == WAR_ACTION_STEP_ATTACK) { // when the unit begin an attack, it is not invisible anymore unit->invisible = false; unit->invisibilityTime = 0; // do damage if (wu_isUnit(targetEntity)) { // if the target entity is dead or is collapsing (in case of buildings), go to idle // do this check before apply damage in case of multiple units attacking. // one of them could cause the unit to die, so the other should wcmd_stop doing further damage. if (wst_isDead(context, targetEntity) || wst_isGoingToDie(context, targetEntity) || wst_isCollapsing(context, targetEntity) || wst_isGoingToCollapse(context, targetEntity)) { WarState* idleState = wst_createIdleState(context, entity, true); wst_changeNextState(context, entity, idleState, true, true); } else { if (wu_isRangeUnit(context, entity)) { we_rangeAttack(context, entity, targetEntity); } else { we_meleeAttack(context, entity, targetEntity); } vec2 targetPosition = wu_getUnitCenterPosition(context, targetEntity, false); wa_playAttackSound(context, targetPosition, action->lastSoundStep); } } else if(wu_isWall(targetEntity)) { WarWallPiece* piece = we_getWallPieceAtPosition(context, targetEntity, (s32)targetTile.x, (s32)targetTile.y); if (piece) { // if the piece of the wall the unit is attacking has no more hit points, go to idle. // do this check before apply damage in case of multiple units attacking. // one of them could destroy the piece, so the other should wcmd_stop doing further damage. if (piece->hp == 0) { WarState* idleState = wst_createIdleState(context, entity, true); wst_changeNextState(context, entity, idleState, true, true); } else { if (wu_isRangeUnit(context, entity)) { we_rangeWallAttack(context, entity, targetEntity, piece); } else { we_meleeWallAttack(context, entity, targetEntity, piece); } vec2 targetPosition = wmap_tileToMapCoordinatesV(targetTile, true); wa_playAttackSound(context, targetPosition, action->lastSoundStep); } } } // this is not the more elegant solution, but the actions and the state machine have to comunicate somehow action->lastActionStep = WAR_ACTION_STEP_NONE; action->lastSoundStep = WAR_ACTION_STEP_NONE; } } void wst_freeAttackState(WarContext* context, WarState* state) { NOT_USED(context); NOT_USED(state); } ================================================ FILE: src/war_state_machine_build.c ================================================ #include "war_state_machine.h" #include "war_map.h" #include "war_actions.h" #include "war_audio.h" #include "war_units.h" #include "war_cheats.h" #include "war_pathfinder.h" WarState* wst_createBuildState(WarContext* context, WarEntity* entity, f32 buildTime) { WarState* state = wst_createState(context, entity, WAR_STATE_BUILD); state->build.workerId = 0; state->build.buildTime = 0; state->build.totalBuildTime = buildTime; state->build.cancelled = false; return state; } void wst_enterBuildState(WarContext* context, WarEntity* entity, WarState* state) { NOT_USED(state); WarMap* map = context->map; WarUnitComponent* unit = we_getUnitComponent(context, entity); assert(unit); WarTransformComponent* transform = we_getTransformComponent(context, entity); assert(transform); vec2 unitSize = wu_getUnitSize(context, entity); vec2 position = wmap_mapToTileCoordinatesV(transform->position); setStaticEntity(map->finder, (s32)position.x, (s32)position.y, (s32)unitSize.x, (s32)unitSize.y, entity->id); // remove the current sprite... we_removeSpriteComponent(context, entity); // ...and add the sprite for the construction of the building const WarBuildingData* buildingData = wu_getBuildingData(unit->type); we_addSpriteComponentFromResource(context, entity, imageResourceRef(buildingData->buildingResource)); // set the action to NONE because the sprite changes will be handled by this state wact_setAction(context, entity, WAR_ACTION_TYPE_NONE, true, 1.0f); unit->building = true; unit->buildPercent = 0; } void wst_leaveBuildState(WarContext* context, WarEntity* entity, WarState* state) { NOT_USED(state); WarMap* map = context->map; WarUnitComponent* unit = we_getUnitComponent(context, entity); assert(unit); WarTransformComponent* transform = we_getTransformComponent(context, entity); assert(transform); vec2 unitSize = wu_getUnitSize(context, entity); vec2 position = wmap_mapToTileCoordinatesV(transform->position); setFreeTiles(map->finder, (s32)position.x, (s32)position.y, (s32)unitSize.x, (s32)unitSize.y); unit->building = false; } void wst_updateBuildState(WarContext* context, WarEntity* entity, WarState* state) { WarMap* map = context->map; WarPlayerInfo* player = &map->players[0]; WarUnitComponent* unit = we_getUnitComponent(context, entity); assert(unit); if (state->build.cancelled) { if (!wst_changeStateNextState(context, entity, state)) { WarState* collapseState = wst_createCollapseState(context, entity); wst_changeNextState(context, entity, collapseState, true, true); } return; } // if there is no worker building the building, don't advance build time if (state->build.workerId <= 0) { return; } f32 buildSpeed = wmap_getMapScaledSpeed(context, context->deltaTime); // if hurry up cheat is enabled, speed up the build time by 5000% if (map->hurryUp) { buildSpeed *= CHEAT_SPEED_UP_FACTOR; } state->build.buildTime += buildSpeed; // if the building is finished... if (state->build.buildTime >= state->build.totalBuildTime) { unit->buildPercent = 1; // find the worker that is building the building WarEntity* worker = we_findEntity(context, state->build.workerId); assert(worker); // ...find an empty position to put it vec2 position = wu_getUnitCenterPosition(context, entity, true); vec2 spawnPosition = wpath_findEmptyPosition(map->finder, position); wu_setUnitCenterPosition(context, worker, spawnPosition, true); // remove the building sprite... we_removeSpriteComponent(context, entity); // ...and add the normal sprite of the building const WarUnitData* buildingData = wu_getUnitData(unit->type); we_addSpriteComponentFromResource(context, entity, imageResourceRef(buildingData->resourceIndex)); if (!wst_changeStateNextState(context, entity, state)) { WarState* idleState = wst_createIdleState(context, entity, false); wst_changeNextState(context, entity, idleState, true, true); } WarAudioId audioId = isHumanPlayer(player) ? WAR_HUMAN_WORK_COMPLETE : WAR_ORC_WORK_COMPLETE; wa_createAudio(context, CREATE_AUDIO_ARGS_INIT(.audioId=audioId, .loop=false)); return; } unit->buildPercent = PERCENTF01(state->build.buildTime, state->build.totalBuildTime); // update the sprite of the building to show the construction steps // // NOTE: maybe this could be handled by the BUILD action if I add a `pauseAction` // and `resumeAction` functions to be able to pause it or resume it according // to the presence of the worker at the construction site // WarSpriteComponent* sprite = we_getSpriteComponent(context, entity); assert(sprite); s32 framesCount = sprite->sprite.framesCount; s32 frameIndex = sprite->frameIndex; f32 frameIndexStep = 1.0f / framesCount; if (unit->buildPercent >= (frameIndex + 1) * frameIndexStep) { if (frameIndex + 1 < framesCount) { frameIndex += 1; } } sprite->frameIndex = frameIndex; } void wst_freeBuildState(WarContext* context, WarState* state) { NOT_USED(context); NOT_USED(state); } ================================================ FILE: src/war_state_machine_cast.c ================================================ #include "war_state_machine.h" #include "war_actions.h" #include "war_animations.h" #include "war_audio.h" #include "war_projectiles.h" #include "war_units.h" #include "war_map.h" WarState* wst_createCastState(WarContext* context, WarEntity* entity, WarSpellType spellType, WarEntityId targetEntityId, vec2 targetTile) { WarState* state = wst_createState(context, entity, WAR_STATE_CAST); state->cast.spellType = spellType; state->cast.targetEntityId = targetEntityId; state->cast.targetTile = targetTile; return state; } void wst_enterCastState(WarContext* context, WarEntity* entity, WarState* state) { NOT_USED(context); NOT_USED(entity); NOT_USED(state); } void wst_leaveCastState(WarContext* context, WarEntity* entity, WarState* state) { NOT_USED(context); NOT_USED(entity); NOT_USED(state); } void wst_updateCastState(WarContext* context, WarEntity* entity, WarState* state) { WarMap* map = context->map; WarUnitComponent* unit = we_getUnitComponent(context, entity); assert(unit); vec2 unitSize = wu_getUnitSize(context, entity); WarTransformComponent* transform = we_getTransformComponent(context, entity); assert(transform); vec2 position = wmap_mapToTileCoordinatesV(transform->position); WarSpellType spellType = state->cast.spellType; WarEntityId targetEntityId = state->cast.targetEntityId; vec2 targetTile = state->cast.targetTile; const WarSpellStats* stats = wu_getSpellStats(spellType); if (stats->range) { if(!wu_tileInRange(context, entity, targetTile, stats->range)) { WarState* followState = wst_createFollowState(context, entity, targetEntityId, targetTile, stats->range); followState->nextState = state; wst_changeNextState(context, entity, followState, false, true); return; } } setStaticEntity(map->finder, (s32)position.x, (s32)position.y, (s32)unitSize.x, (s32)unitSize.y, entity->id); wu_setUnitDirectionFromDiff(context, entity, targetTile.x - position.x, targetTile.y - position.y); wact_setAction(context, entity, WAR_ACTION_TYPE_ATTACK, false, 1.0f); WarUnitAction* action = &unit->actions[unit->actionType]; if (action->lastActionStep == WAR_ACTION_STEP_ATTACK) { // when the unit cast a spell, it is not invisible anymore unit->invisible = false; unit->invisibilityTime = 0; switch (spellType) { case WAR_SPELL_HEALING: { WarEntity* targetEntity = we_findEntity(context, targetEntityId); if (targetEntity && wu_isDudeUnit(context, targetEntity)) { WarUnitComponent* targetUnit = we_getUnitComponent(context, targetEntity); assert(targetUnit); // the healing spell's strength is determined by units of mana. // for every 6 units of mana, the damaged unit gets back 1 hit point. // // take all the hp the cleric can restore according to its mana s32 hpToRestore = unit->mana / stats->manaCost; // take in reality how much hp needs to be restored hpToRestore = MIN(hpToRestore, targetUnit->maxhp - targetUnit->hp); // recalculate how much mana the cleric need to spend s32 manaToSpend = hpToRestore * stats->manaCost; we_increaseUnitHp(context, targetEntity, hpToRestore); we_decreaseUnitMana(context, entity, manaToSpend); vec2 targetPosition = wu_getUnitCenterPosition(context, targetEntity, false); WarEntity* animEntity = we_createEntity(context, WAR_ENTITY_TYPE_ANIMATION, true); we_addAnimationsComponent(context, animEntity); wanim_createSpellAnimation(context, animEntity, targetPosition); wa_createAudioWithPosition(context, CREATE_AUDIO_ARGS_INIT(.audioId=WAR_NORMAL_SPELL, .position=targetPosition, .hasPosition=true, .loop=false)); } WarState* idleState = wst_createIdleState(context, entity, true); wst_changeNextState(context, entity, idleState, true, true); break; } case WAR_SPELL_FAR_SIGHT: case WAR_SPELL_DARK_VISION: { if (we_decreaseUnitMana(context, entity, stats->manaCost)) { vec2 targetPosition = wmap_tileToMapCoordinatesV(targetTile, true); WarEntity* sight = we_createEntity(context, WAR_ENTITY_TYPE_SIGHT, true); we_addSightComponent(context, sight, WAR_SIGHT_COMPONENT_INIT( .position = targetTile, .time = stats->time, )); we_addAnimationsComponent(context, sight); wanim_createSpellAnimation(context, sight, targetPosition); wa_createAudioWithPosition(context, CREATE_AUDIO_ARGS_INIT(.audioId=WAR_NORMAL_SPELL, .position=targetPosition, .hasPosition=true, .loop=false)); } WarState* idleState = wst_createIdleState(context, entity, true); wst_changeNextState(context, entity, idleState, true, true); break; } case WAR_SPELL_INVISIBILITY: { WarEntity* targetEntity = we_findEntity(context, targetEntityId); if (targetEntity && wu_isDudeUnit(context, targetEntity)) { WarUnitComponent* targetUnit = we_getUnitComponent(context, targetEntity); assert(targetUnit); if (we_decreaseUnitMana(context, entity, stats->manaCost)) { targetUnit->invisible = true; targetUnit->invisibilityTime = stats->time; vec2 targetPosition = wu_getUnitCenterPosition(context, targetEntity, false); WarEntity* animEntity = we_createEntity(context, WAR_ENTITY_TYPE_ANIMATION, true); we_addAnimationsComponent(context, animEntity); wanim_createSpellAnimation(context, animEntity, targetPosition); wa_createAudioWithPosition(context, CREATE_AUDIO_ARGS_INIT(.audioId=WAR_NORMAL_SPELL, .position=targetPosition, .hasPosition=true, .loop=false)); } } WarState* idleState = wst_createIdleState(context, entity, true); wst_changeNextState(context, entity, idleState, true, true); break; } case WAR_SPELL_RAIN_OF_FIRE: { if (we_decreaseUnitMana(context, entity, stats->manaCost)) { vec2 targetTilePosition = wmap_tileToMapCoordinatesV(targetTile, true); s32 radius = 2 * MEGA_TILE_WIDTH; s32 projectilesCount = 5; while (projectilesCount--) { f32 offsetx = randomf(-radius, radius); f32 offsety = randomf(-radius, radius); vec2 target = vec2_addv(targetTilePosition, vec2f(offsetx, offsety)); offsety = randomf(MEGA_TILE_WIDTH, MEGA_TILE_WIDTH * 4); vec2 origin = vec2f(target.x, map->viewport.y - offsety); wproj_createProjectile(context, WAR_PROJECTILE_RAIN_OF_FIRE, 0, 0, origin, target); } } else { WarState* idleState = wst_createIdleState(context, entity, true); wst_changeNextState(context, entity, idleState, true, true); } break; } case WAR_SPELL_RAISE_DEAD: { WarEntityList* nearUnits = we_getNearUnits(context, targetTile, 4); for (s32 i = 0; i < nearUnits->count; i++) { WarEntity* targetEntity = nearUnits->items[i]; if (targetEntity && wu_isCorpseUnit(context, targetEntity)) { if (we_decreaseUnitMana(context, entity, stats->manaCost)) { vec2 targetPosition = wu_getUnitCenterPosition(context, targetEntity, true); we_createUnit(context, CREATE_UNIT_ARGS_INIT(.type=WAR_UNIT_SKELETON, .x=(s32)targetPosition.x, .y=(s32)targetPosition.y, .player=unit->player, .resourceKind=WAR_RESOURCE_NONE, .amount=0, .addToMap=true)); targetPosition = wu_getUnitCenterPosition(context, targetEntity, false); WarEntity* animEntity = we_createEntity(context, WAR_ENTITY_TYPE_ANIMATION, true); we_addAnimationsComponent(context, animEntity); wanim_createSpellAnimation(context, animEntity, targetPosition); wa_createAudioWithPosition(context, CREATE_AUDIO_ARGS_INIT(.audioId=WAR_NORMAL_SPELL, .position=targetPosition, .hasPosition=true, .loop=false)); we_removeEntityById(context, targetEntity->id); } } } WarEntityListFree(nearUnits); WarState* idleState = wst_createIdleState(context, entity, true); wst_changeNextState(context, entity, idleState, true, true); break; } case WAR_SPELL_UNHOLY_ARMOR: { WarEntity* targetEntity = we_findEntity(context, targetEntityId); if (targetEntity && wu_isDudeUnit(context, targetEntity)) { WarUnitComponent* targetUnit = we_getUnitComponent(context, targetEntity); assert(targetUnit); if (we_decreaseUnitMana(context, entity, stats->manaCost)) { we_decreaseUnitHp(context, targetEntity, targetUnit->hp/2); targetUnit->invulnerable = true; targetUnit->invulnerabilityTime = stats->time; vec2 targetPosition = wu_getUnitCenterPosition(context, targetEntity, false); WarEntity* animEntity = we_createEntity(context, WAR_ENTITY_TYPE_ANIMATION, true); we_addAnimationsComponent(context, animEntity); wanim_createSpellAnimation(context, animEntity, targetPosition); wa_createAudioWithPosition(context, CREATE_AUDIO_ARGS_INIT(.audioId=WAR_NORMAL_SPELL, .position=targetPosition, .hasPosition=true, .loop=false)); } } WarState* idleState = wst_createIdleState(context, entity, true); wst_changeNextState(context, entity, idleState, true, true); break; } case WAR_SPELL_POISON_CLOUD: { if (we_decreaseUnitMana(context, entity, stats->manaCost)) { vec2 targetPosition = wmap_tileToMapCoordinatesV(targetTile, true); WarEntity* poisonCloud = we_createEntity(context, WAR_ENTITY_TYPE_POISON_CLOUD, true); we_addPoisonCloudComponent(context, poisonCloud, WAR_POISON_CLOUD_COMPONENT_INIT( .position = targetTile, .time = stats->time, )); we_addAnimationsComponent(context, poisonCloud); wanim_createPoisonCloudAnimation(context, poisonCloud, targetPosition); wa_createAudioWithPosition(context, CREATE_AUDIO_ARGS_INIT(.audioId=WAR_NORMAL_SPELL, .position=targetPosition, .hasPosition=true, .loop=false)); } WarState* idleState = wst_createIdleState(context, entity, true); wst_changeNextState(context, entity, idleState, true, true); break; } default: { logWarning("Trying to cast wrong spell: %d", spellType); break; } } // this is not the more elegant solution, but the actions and the state machine have to comunicate somehow action->lastActionStep = WAR_ACTION_STEP_NONE; action->lastSoundStep = WAR_ACTION_STEP_NONE; } } void wst_freeCastState(WarContext* context, WarState* state) { NOT_USED(context); NOT_USED(state); } ================================================ FILE: src/war_state_machine_chopping.c ================================================ #include "war_state_machine.h" #include "war_actions.h" #include "war_audio.h" #include "war_units.h" #include "war_map.h" WarState* wst_createChoppingState(WarContext* context, WarEntity* entity, WarEntityId forestId, vec2 position) { WarState* state = wst_createState(context, entity, WAR_STATE_CHOPPING); state->chop.forestId = forestId; state->chop.position = position; return state; } void wst_enterChoppingState(WarContext* context, WarEntity* entity, WarState* state) { WarMap* map = context->map; vec2 unitSize = wu_getUnitSize(context, entity); vec2 position = wu_getUnitCenterPosition(context, entity, true); vec2 treePosition = state->chop.position; setStaticEntity(map->finder, (s32)position.x, (s32)position.y, (s32)unitSize.x, (s32)unitSize.y, entity->id); wu_setUnitDirectionFromDiff(context, entity, treePosition.x - position.x, treePosition.y - position.y); wact_setAction(context, entity, WAR_ACTION_TYPE_HARVEST, true, 1.0f); } void wst_leaveChoppingState(WarContext* context, WarEntity* entity, WarState* state) { NOT_USED(context); NOT_USED(entity); NOT_USED(state); } void wst_updateChoppingState(WarContext* context, WarEntity* entity, WarState* state) { WarUnitComponent* unit = we_getUnitComponent(context, entity); assert(unit); WarEntity* forest = we_findEntity(context, (WarEntityId)state->chop.forestId); // if the forest doesn't exists, go idle if (!forest) { WarState* idleState = wst_createIdleState(context, entity, true); wst_changeNextState(context, entity, idleState, true, true); return; } vec2 treePosition = state->chop.position; WarTree* tree = we_getTreeAtPosition(context, forest, (s32)treePosition.x, (s32)treePosition.y); if (!tree || tree->amount == 0) { WarState* gatherWoodState = wst_createGatherWoodState(context, entity, forest->id, treePosition); wst_changeNextState(context, entity, gatherWoodState, true, true); return; } WarUnitAction* action = &unit->actions[unit->actionType]; if (action->lastActionStep == WAR_ACTION_STEP_ATTACK) { unit->amount += we_chopTree(context, forest, tree, 2); if (unit->amount > 0) { unit->resourceKind = WAR_RESOURCE_WOOD; } if (action->lastSoundStep == WAR_ACTION_STEP_SOUND_CHOPPING) { vec2 targetPosition = wmap_tileToMapCoordinatesV(treePosition, true); wa_createAudioRandomWithPosition(context, CREATE_AUDIO_ARGS_INIT( .randomFromId=WAR_TREE_CHOPPING_1, .randomToId=WAR_TREE_CHOPPING_4, .position=targetPosition, .hasPosition=true, .loop=false )); } if (unit->amount == UNIT_MAX_CARRY_WOOD) { // set the carrying gold sprites const WarWorkerData* workerData = wu_getWorkerData(unit->type); we_removeSpriteComponent(context, entity); we_addSpriteComponentFromResource(context, entity, imageResourceRef(workerData->carryingWoodResource)); // find the closest town hall to deliver the gold WarRace race = wu_getUnitRace(context, entity); WarUnitType townHallType = wu_getTownHallOfRace(race); WarEntity* townHall = we_findClosestUnitOfType(context, entity, townHallType); // if the town hall doesn't exists (it could be under attack and get destroyed), go idle if (!townHall) { WarState* idleState = wst_createIdleState(context, entity, true); wst_changeNextState(context, entity, idleState, true, true); return; } WarState* deliverState = wst_createDeliverState(context, entity, townHall->id); deliverState->nextState = wst_createGatherWoodState(context, entity, forest->id, treePosition); wst_changeNextState(context, entity, deliverState, true, true); } // this is not the more elegant solution, but the actions and the state machine have to comunicate somehow action->lastActionStep = WAR_ACTION_STEP_NONE; action->lastSoundStep = WAR_ACTION_STEP_NONE; } } void wst_freeChoppingState(WarContext* context, WarState* state) { NOT_USED(context); NOT_USED(state); } ================================================ FILE: src/war_state_machine_collapse.c ================================================ #include "war_state_machine.h" #include "shl/wstr.h" #include "war_animations.h" WarState* wst_createCollapseState(WarContext* context, WarEntity* entity) { WarState* state = wst_createState(context, entity, WAR_STATE_COLLAPSE); return state; } void wst_enterCollapseState(WarContext* context, WarEntity* entity, WarState* state) { WarMap* map = context->map; vec2 unitSize = wu_getUnitSize(context, entity); WarTransformComponent* transform = we_getTransformComponent(context, entity); assert(transform); vec2 position = wmap_mapToTileCoordinatesV(transform->position); wanim_removeAnimation(context, entity, wsv_fromCString("littleDamage")); wanim_removeAnimation(context, entity, wsv_fromCString("hugeDamage")); we_disableComponent(context, entity, COMP_SPRITE); WarSpriteAnimation* collapseAnim = wanim_createCollapseAnimation(context, entity, wstr_fromCString("collapse")); state->delay = wmap_getMapScaledTime(context, wanim_getAnimationDuration(collapseAnim)); WarEntity* ruins = map->ruin; we_addRuinsPieces(context, ruins, (s32)position.x, (s32)position.y, (s32)unitSize.x); we_determineRuinTypes(context, ruins); setFreeTiles(map->finder, (s32)position.x, (s32)position.y, (s32)unitSize.x, (s32)unitSize.y); wmap_removeEntityFromSelection(context, entity->id); } void wst_leaveCollapseState(WarContext* context, WarEntity* entity, WarState* state) { NOT_USED(context); NOT_USED(entity); NOT_USED(state); } void wst_updateCollapseState(WarContext* context, WarEntity* entity, WarState* state) { NOT_USED(context); NOT_USED(state); we_removeEntityById(context, entity->id); } void wst_freeCollapseState(WarContext* context, WarState* state) { NOT_USED(context); NOT_USED(state); } ================================================ FILE: src/war_state_machine_death.c ================================================ #include "war_state_machine.h" #include "war_actions.h" WarState* wst_createDeathState(WarContext* context, WarEntity* entity) { WarState* state = wst_createState(context, entity, WAR_STATE_DEATH); return state; } void wst_enterDeathState(WarContext* context, WarEntity* entity, WarState* state) { WarMap* map = context->map; WarTransformComponent* transform = we_getTransformComponent(context, entity); assert(transform); vec2 unitSize = wu_getUnitSize(context, entity); vec2 position = wmap_mapToTileCoordinatesV(transform->position); setFreeTiles(map->finder, (s32)position.x, (s32)position.y, (s32)unitSize.x, (s32)unitSize.y); wact_setAction(context, entity, WAR_ACTION_TYPE_DEATH, true, 1.0f); wmap_removeEntityFromSelection(context, entity->id); s32 deathDuration = wact_getActionDuration(context, entity, WAR_ACTION_TYPE_DEATH); state->delay = wmap_getMapScaledTime(context, __frameCountToSeconds(deathDuration)); } void wst_leaveDeathState(WarContext* context, WarEntity* entity, WarState* state) { NOT_USED(context); NOT_USED(entity); NOT_USED(state); } void wst_updateDeathState(WarContext* context, WarEntity* entity, WarState* state) { NOT_USED(state); // when this state updates there will have pass the time of the death animation, // using the delay field of the states if (!wu_isCorpseUnit(context, entity) && !wu_isCatapultUnit(context, entity) && !wu_isSummonUnit(context, entity) && !wu_isSkeletonUnit(context, entity)) { vec2 position = wu_getUnitCenterPosition(context, entity, true); WarUnitType corpseType = wu_getUnitRace(context, entity) == WAR_RACE_ORCS ? WAR_UNIT_ORC_CORPSE : WAR_UNIT_HUMAN_CORPSE; WarEntity* corpse = we_createUnit(context, CREATE_UNIT_ARGS_INIT( .type=corpseType, .x=(s32)position.x, .y=(s32)position.y, .player=4, .resourceKind=WAR_RESOURCE_NONE, .amount=0, .addToMap=true )); wu_setUnitDirection(context, corpse, wu_getUnitDirection(context, entity)); WarState* deathState = wst_createDeathState(context, corpse); wst_changeNextState(context, corpse, deathState, true, true); } we_removeEntityById(context, entity->id); } void wst_freeDeathState(WarContext* context, WarState* state) { NOT_USED(context); NOT_USED(state); } ================================================ FILE: src/war_state_machine_deliver.c ================================================ #include "war_state_machine.h" WarState* wst_createDeliverState(WarContext* context, WarEntity* entity, WarEntityId townHallId) { WarState* state = wst_createState(context, entity, WAR_STATE_DELIVER); state->deliver.townHallId = townHallId; return state; } void wst_enterDeliverState(WarContext* context, WarEntity* entity, WarState* state) { NOT_USED(context); NOT_USED(entity); NOT_USED(state); } void wst_leaveDeliverState(WarContext* context, WarEntity* entity, WarState* state) { NOT_USED(context); NOT_USED(entity); NOT_USED(state); } void wst_updateDeliverState(WarContext* context, WarEntity* entity, WarState* state) { WarMap* map = context->map; WarUnitComponent* unit = we_getUnitComponent(context, entity); assert(unit); const WarUnitStats* stats = wu_getUnitStats(unit->type); WarEntity* townHall = we_findEntity(context, (WarEntityId)state->deliver.townHallId); // if the town hall doesn't exists (or other units attacking it), go idle if (!townHall) { WarState* idleState = wst_createIdleState(context, entity, true); wst_changeNextState(context, entity, idleState, true, true); return; } if (!wu_unitInRange(context, entity, townHall, stats->range)) { vec2 targetTile = wu_unitPointOnTarget(context, entity, townHall); WarState* followState = wst_createFollowState(context, entity, townHall->id, targetTile, stats->range); followState->nextState = state; wst_changeNextState(context, entity, followState, false, true); return; } if (state->deliver.insideBuilding) { // find a valid spawn position for the unit vec2 position = wu_getUnitCenterPosition(context, townHall, true); vec2 spawnPosition = wpath_findEmptyPosition(map->finder, position); wu_setUnitCenterPosition(context, entity, spawnPosition, true); const WarUnitData* unitData = wu_getUnitData(unit->type); we_removeSpriteComponent(context, entity); we_addSpriteComponentFromResource(context, entity, imageResourceRef(unitData->resourceIndex)); if (!wst_changeStateNextState(context, entity, state)) { WarState* idleState = wst_createIdleState(context, entity, true); wst_changeNextState(context, entity, idleState, true, true); } return; } if (unit->resourceKind == WAR_RESOURCE_GOLD) { we_increasePlayerResources(context, &map->players[0], unit->amount, 0); } else if (unit->resourceKind == WAR_RESOURCE_WOOD) { we_increasePlayerResources(context, &map->players[0], 0, unit->amount); } unit->resourceKind = WAR_RESOURCE_NONE; unit->amount = 0; // the unit arrive to the townhall, so now the unit go inside the building for some time to simulate the depositing // then need go back to the goldmine/trees. state->deliver.insideBuilding = true; we_disableComponent(context, entity, COMP_SPRITE); // remove the unit from selection to avoid the player giving it orders // while inside the townhall wmap_removeEntityFromSelection(context, entity->id); // simulate the time inside the townhall state->delay = wmap_getMapScaledTime(context, 1.0f); } void wst_freeDeliverState(WarContext* context, WarState* state) { NOT_USED(context); NOT_USED(state); } ================================================ FILE: src/war_state_machine_follow.c ================================================ #include "war_state_machine.h" #include "war_units.h" WarState* wst_createFollowState(WarContext* context, WarEntity* entity, WarEntityId targetEntityId, vec2 targetTile, s32 distance) { WarState* state = wst_createState(context, entity, WAR_STATE_FOLLOW); state->follow.targetEntityId = targetEntityId; state->follow.targetTile = targetTile; state->follow.distance = distance; return state; } void wst_enterFollowState(WarContext* context, WarEntity* entity, WarState* state) { NOT_USED(context); NOT_USED(entity); NOT_USED(state); } void wst_leaveFollowState(WarContext* context, WarEntity* entity, WarState* state) { NOT_USED(context); NOT_USED(entity); NOT_USED(state); } void wst_updateFollowState(WarContext* context, WarEntity* entity, WarState* state) { WarMap* map = context->map; vec2 start = wu_getUnitCenterPosition(context, entity, true); vec2 end = state->follow.targetTile; if (state->follow.targetEntityId) { WarEntity* targetEntity = we_findEntity(context, (WarEntityId)state->follow.targetEntityId); if (wu_isUnit(targetEntity)) { // if the target entity is an unit the instead of using the tile where // the player click, use a point on the target unit that is closer to // the following unit end = wu_unitPointOnTarget(context, entity, targetEntity); } else { end = wu_getUnitCenterPosition(context, targetEntity, true); } } f32 distance = vec2_distanceInTiles(start, end); // if the unit is already in distance, go to idle if (distance <= state->follow.distance) { if (!wst_changeStateNextState(context, entity, state)) { WarState* waitState = wst_createWaitState(context, entity, wmap_getMapScaledTime(context, MOVE_WAIT_TIME)); waitState->nextState = state; wst_changeNextState(context, entity, waitState, false, true); } return; } WarMapPath path = wpath_findPath(map->finder, (s32)start.x, (s32)start.y, (s32)end.x, (s32)end.y); // if there is no path to the target, go to idle if (path.nodes.count <= 1) { if (!wst_changeStateNextState(context, entity, state)) { WarState* idleState = wst_createIdleState(context, entity, true); wst_changeNextState(context, entity, idleState, true, true); } wpath_freePath(path); return; } WarState* moveState = wst_createMoveState(context, entity, 2, arrayArg(vec2, path.nodes.items[0], path.nodes.items[1])); moveState->nextState = state; wst_changeNextState(context, entity, moveState, false, true); wpath_freePath(path); } void wst_freeFollowState(WarContext* context, WarState* state) { NOT_USED(context); NOT_USED(state); } ================================================ FILE: src/war_state_machine_gather_gold.c ================================================ #include "war_state_machine.h" WarState* wst_createGatherGoldState(WarContext* context, WarEntity* entity, WarEntityId goldmineId) { WarState* state = wst_createState(context, entity, WAR_STATE_GOLD); state->gold.goldmineId = goldmineId; return state; } void wst_enterGatherGoldState(WarContext* context, WarEntity* entity, WarState* state) { NOT_USED(context); NOT_USED(entity); NOT_USED(state); } void wst_leaveGatherGoldState(WarContext* context, WarEntity* entity, WarState* state) { NOT_USED(context); NOT_USED(entity); NOT_USED(state); } void wst_updateGatherGoldState(WarContext* context, WarEntity* entity, WarState* state) { WarUnitComponent* unit = we_getUnitComponent(context, entity); assert(unit); const WarUnitStats* stats = wu_getUnitStats(unit->type); WarEntity* goldmine = we_findEntity(context, (WarEntityId)state->gold.goldmineId); // if the goldmine doesn't exists (it could ran out of gold, or other units attacking it), go idle // if the unit was already mining, and the gold mine ran out of gold, then another unit previouly got all the remaining gold // so, this unit get nothing if (!goldmine || wst_isCollapsing(context, goldmine) || wst_isGoingToCollapse(context, goldmine)) { WarState* idleState = wst_createIdleState(context, entity, true); wst_changeNextState(context, entity, idleState, true, true); return; } // if the goldmine is not in range, go to it if (!wu_unitInRange(context, entity, goldmine, stats->range)) { WarState* followState = wst_createFollowState(context, entity, goldmine->id, VEC2_ZERO, stats->range); followState->nextState = state; wst_changeNextState(context, entity, followState, false, true); return; } // the unit arrive to the goldmine, go mining WarState* miningState = wst_createMiningState(context, entity, goldmine->id); wst_changeNextState(context, entity, miningState, true, true); } void wst_freeGatherGoldState(WarContext* context, WarState* state) { NOT_USED(context); NOT_USED(state); } ================================================ FILE: src/war_state_machine_gather_wood.c ================================================ #include "war_state_machine.h" WarState* wst_createGatherWoodState(WarContext* context, WarEntity* entity, WarEntityId forestId, vec2 position) { WarState* state = wst_createState(context, entity, WAR_STATE_WOOD); state->wood.forestId = forestId; state->wood.position = position; return state; } void wst_enterGatherWoodState(WarContext* context, WarEntity* entity, WarState* state) { NOT_USED(context); NOT_USED(entity); NOT_USED(state); } void wst_leaveGatherWoodState(WarContext* context, WarEntity* entity, WarState* state) { NOT_USED(context); NOT_USED(entity); NOT_USED(state); } void wst_updateGatherWoodState(WarContext* context, WarEntity* entity, WarState* state) { WarMap* map = context->map; WarUnitComponent* unit = we_getUnitComponent(context, entity); assert(unit); const WarUnitStats* stats = wu_getUnitStats(unit->type); vec2 position = wu_getUnitCenterPosition(context, entity, true); WarEntity* forest = we_findEntity(context, (WarEntityId)state->wood.forestId); // if the forest doesn't exists, go idle if (!forest) { WarState* idleState = wst_createIdleState(context, entity, true); wst_changeNextState(context, entity, idleState, true, true); return; } vec2 treePosition = state->wood.position; WarTree* tree = we_getTreeAtPosition(context, forest, (s32)treePosition.x, (s32)treePosition.y); if (!tree || tree->amount == 0 || !wpath_isPositionAccesible(map->finder, treePosition)) { tree = we_findAccesibleTree(context, forest, treePosition); // if there is no more nearby tree, go idle if (!tree) { WarState* idleState = wst_createIdleState(context, entity, true); wst_changeNextState(context, entity, idleState, true, true); return; } treePosition = vec2i(tree->tilex, tree->tiley); state->wood.position = treePosition; } // if the tree is not in range, go to it if (!wu_tileInRange(context, entity, treePosition, stats->range)) { WarState* moveState = wst_createMoveState(context, entity, 2, arrayArg(vec2, position, treePosition)); moveState->nextState = state; wst_changeNextState(context, entity, moveState, false, true); return; } // the unit arrive to the tree, go chopping WarState* choppingState = wst_createChoppingState(context, entity, forest->id, treePosition); wst_changeNextState(context, entity, choppingState, true, true); } void wst_freeGatherWoodState(WarContext* context, WarState* state) { NOT_USED(context); NOT_USED(state); } ================================================ FILE: src/war_state_machine_idle.c ================================================ #include "war_state_machine.h" #include "war_actions.h" #include "war_map.h" #include "war_units.h" WarState* wst_createIdleState(WarContext* context, WarEntity* entity, bool lookAround) { WarState* state = wst_createState(context, entity, WAR_STATE_IDLE); state->idle.lookAround = lookAround; return state; } void wst_enterIdleState(WarContext* context, WarEntity* entity, WarState* state) { NOT_USED(state); if (wu_isUnit(entity)) { WarMap* map = context->map; vec2 unitSize = wu_getUnitSize(context, entity); vec2 position = wu_getUnitPosition(context, entity, true); setStaticEntity(map->finder, (s32)position.x, (s32)position.y, (s32)unitSize.x, (s32)unitSize.y, entity->id); wact_setAction(context, entity, WAR_ACTION_TYPE_IDLE, true, 1.0f); } } void wst_leaveIdleState(WarContext* context, WarEntity* entity, WarState* state) { NOT_USED(state); if (wu_isUnit(entity)) { WarMap* map = context->map; vec2 unitSize = wu_getUnitSize(context, entity); vec2 position = wu_getUnitPosition(context, entity, true); setFreeTiles(map->finder, (s32)position.x, (s32)position.y, (s32)unitSize.x, (s32)unitSize.y); } } void wst_updateIdleState(WarContext* context, WarEntity* entity, WarState* state) { WarMap* map = context->map; if (wu_isUnit(entity)) { if (state->idle.lookAround) { if (chance(20)) { WarUnitComponent* unit = we_getUnitComponent(context, entity); assert(unit); unit->direction += randomi(-1, 2); if (unit->direction < 0) unit->direction = WAR_DIRECTION_NORTH_WEST; else if(unit->direction >= WAR_DIRECTION_COUNT) unit->direction = WAR_DIRECTION_NORTH; } } // look for foe units to attack them if they are in range if (wu_isWarriorUnit(context, entity)) { WarEntity* enemy = we_getNearEnemy(context, entity); if (enemy) { vec2 enemyPosition = wu_getUnitPosition(context, enemy, true); WarState* attackState = wst_createAttackState(context, entity, enemy->id, enemyPosition); wst_changeNextState(context, entity, attackState, true, true); } } // this is a way to tell the state machine engine to not update this state for the specified amount of time state->delay = 1.0f; } else if(wu_isWall(entity)) { WarWallComponent* wall = we_getWallComponent(context, entity); assert(wall); for(s32 i = 0; i < wall->pieces.count; i++) { WarWallPiece* piece = &wall->pieces.items[i]; s32 hpPercent = PERCENTABI(piece->hp, piece->maxhp); if (hpPercent <= 0) setFreeTiles(map->finder, piece->tilex, piece->tiley, 1, 1); else setStaticEntity(map->finder, piece->tilex, piece->tiley, 1, 1, entity->id); } } } void wst_freeIdleState(WarContext* context, WarState* state) { NOT_USED(context); NOT_USED(state); } ================================================ FILE: src/war_state_machine_mining.c ================================================ #include "war_state_machine.h" WarState* wst_createMiningState(WarContext* context, WarEntity* entity, WarEntityId goldmineId) { WarState* state = wst_createState(context, entity, WAR_STATE_MINING); state->mine.goldmineId = goldmineId; state->mine.miningTime = 0; return state; } void wst_enterMiningState(WarContext* context, WarEntity* entity, WarState* state) { // remove the sprite to simulate the mining process we_removeSpriteComponent(context, entity); WarUnitComponent* unit = we_getUnitComponent(context, entity); assert(unit); // reset the current action to stop any movement or attack action wact_resetAction(context, entity, unit->actionType); // set the mining time state->mine.miningTime = 2.0f; // remove the unit from selection to avoid the player giving it orders while inside the mine wmap_removeEntityFromSelection(context, entity->id); } void wst_leaveMiningState(WarContext* context, WarEntity* entity, WarState* state) { NOT_USED(context); NOT_USED(entity); NOT_USED(state); WarEntity* goldmine = we_findEntity(context, (WarEntityId)state->mine.goldmineId); // NOTE: if the goldmine doesn't exists (it could ran out of gold, or other units destroyed it), or it's collapsing or going to collapse, // restore back the sprite component to the worker, so it should be visible again if (!goldmine || wst_isCollapsing(context, goldmine) || wst_isGoingToCollapse(context, goldmine)) { WarUnitComponent* unit = we_getUnitComponent(context, entity); assert(unit); const WarUnitData* unitData = wu_getUnitData(unit->type); s32 spriteIndex = unitData->resourceIndex; if (spriteIndex == 0) { logError("Sprite for unit of type %d is not configure properly. Default to footman sprite.", unit->type); spriteIndex = 279; } we_addSpriteComponentFromResource(context, entity, imageResourceRef(spriteIndex)); } } void wst_updateMiningState(WarContext* context, WarEntity* entity, WarState* state) { WarMap* map = context->map; WarUnitComponent* unit = we_getUnitComponent(context, entity); assert(unit); WarEntity* goldmine = we_findEntity(context, (WarEntityId)state->mine.goldmineId); // if the goldmine doesn't exists (it could ran out of gold, or other units attacking it), or it's collapsing or going to collapse, go idle // if the unit was already mining, and the gold mine ran out of gold, then another unit previouly got all the remaining gold // so, this unit get nothing if (!goldmine) { // find a valid spawn position for the unit vec2 position = wu_getUnitCenterPosition(context, entity, true); vec2 spawnPosition = wpath_findEmptyPosition(map->finder, position); wu_setUnitCenterPosition(context, entity, spawnPosition, true); WarState* idleState = wst_createIdleState(context, entity, true); wst_changeNextState(context, entity, idleState, true, true); return; } if (wst_isCollapsing(context, goldmine) || wst_isGoingToCollapse(context, goldmine)) { // find a valid spawn position for the unit vec2 position = wu_getUnitCenterPosition(context, goldmine, true); vec2 spawnPosition = wpath_findEmptyPosition(map->finder, position); wu_setUnitCenterPosition(context, entity, spawnPosition, true); WarState* idleState = wst_createIdleState(context, entity, true); wst_changeNextState(context, entity, idleState, true, true); return; } state->mine.miningTime -= wmap_getMapScaledSpeed(context, context->deltaTime); if (state->mine.miningTime < 0) { unit->amount += mine(context, goldmine, UNIT_MAX_CARRY_GOLD); if (unit->amount > 0) { unit->resourceKind = WAR_RESOURCE_GOLD; } // find a valid spawn position for the unit vec2 position = wu_getUnitCenterPosition(context, goldmine, true); vec2 spawnPosition = wpath_findEmptyPosition(map->finder, position); wu_setUnitCenterPosition(context, entity, spawnPosition, true); // set the carrying gold sprites const WarWorkerData* workerData = wu_getWorkerData(unit->type); we_addSpriteComponentFromResource(context, entity, imageResourceRef(workerData->carryingGoldResource)); // find the closest town hall to deliver the gold WarRace race = wu_getUnitRace(context, entity); WarUnitType townHallType = wu_getTownHallOfRace(race); WarEntity* townHall = we_findClosestUnitOfType(context, entity, townHallType); // if the town hall doesn't exists (it could be under attack and get destroyed), go idle if (!townHall) { WarState* idleState = wst_createIdleState(context, entity, true); wst_changeNextState(context, entity, idleState, true, true); return; } WarState* deliverState = wst_createDeliverState(context, entity, townHall->id); deliverState->nextState = wst_createGatherGoldState(context, entity, goldmine->id); wst_changeNextState(context, entity, deliverState, true, true); } } void wst_freeMiningState(WarContext* context, WarState* state) { NOT_USED(context); NOT_USED(state); } ================================================ FILE: src/war_state_machine_move.c ================================================ #include "war_state_machine.h" #include "war_actions.h" #include "war_units.h" WarState* wst_createMoveState(WarContext* context, WarEntity* entity, s32 positionCount, vec2 positions[]) { WarState* state = wst_createState(context, entity, WAR_STATE_MOVE); vec2ListInit(&state->move.positions, vec2ListDefaultOptions); vec2ListAddRange(&state->move.positions, positionCount, positions); return state; } void wst_enterMoveState(WarContext* context, WarEntity* entity, WarState* state) { WarMap* map = context->map; vec2 unitSize = wu_getUnitSize(context, entity); if (state->move.positions.count <= 1) { if (!wst_changeStateNextState(context, entity, state)) { WarState* idleState = wst_createIdleState(context, entity, true); wst_changeNextState(context, entity, idleState, true, true); } return; } state->move.positionIndex = 0; state->move.pathNodeIndex = 0; state->move.waitCount = 0; vec2 start = state->move.positions.items[state->move.positionIndex]; vec2 end = state->move.positions.items[state->move.positionIndex + 1]; WarMapPath path = state->move.path = wpath_findPath(map->finder, (s32)start.x, (s32)start.y, (s32)end.x, (s32)end.y); // if the is no path to the next position, go to idle if (path.nodes.count <= 1) { if (!wst_changeStateNextState(context, entity, state)) { WarState* idleState = wst_createIdleState(context, entity, true); wst_changeNextState(context, entity, idleState, true, true); } return; } vec2 currentNode = path.nodes.items[state->move.pathNodeIndex]; setDynamicEntity(map->finder, (s32)currentNode.x, (s32)currentNode.y, (s32)unitSize.x, (s32)unitSize.y, entity->id); vec2 nextNode = path.nodes.items[state->move.pathNodeIndex + 1]; setDynamicEntity(map->finder, (s32)nextNode.x, (s32)nextNode.y, (s32)unitSize.x, (s32)unitSize.y, entity->id); wu_setUnitDirectionFromDiff(context, entity, nextNode.x - currentNode.x, nextNode.y - currentNode.y); wact_setAction(context, entity, WAR_ACTION_TYPE_WALK, false, wu_getUnitActionScale(context, entity)); } void wst_leaveMoveState(WarContext* context, WarEntity* entity, WarState* state) { WarMap* map = context->map; vec2 unitSize = wu_getUnitSize(context, entity); WarMapPath* path = &state->move.path; if (inRange(state->move.pathNodeIndex, 0, path->nodes.count)) { vec2 currentNode = path->nodes.items[state->move.pathNodeIndex]; if (isDynamicOfEntity(map->finder, (s32)currentNode.x, (s32)currentNode.y, entity->id)) setFreeTiles(map->finder, (s32)currentNode.x, (s32)currentNode.y, (s32)unitSize.x, (s32)unitSize.y); } if (inRange(state->move.pathNodeIndex + 1, 0, path->nodes.count)) { vec2 nextNode = path->nodes.items[state->move.pathNodeIndex + 1]; if (isDynamicOfEntity(map->finder, (s32)nextNode.x, (s32)nextNode.y, entity->id)) setFreeTiles(map->finder, (s32)nextNode.x, (s32)nextNode.y, (s32)unitSize.x, (s32)unitSize.y); } } void wst_updateMoveState(WarContext* context, WarEntity* entity, WarState* state) { WarMap* map = context->map; WarMapPath* path = &state->move.path; assert(path->nodes.count > 1); assert(inRange(state->move.pathNodeIndex, 0, path->nodes.count - 1)); WarUnitComponent* unit = we_getUnitComponent(context, entity); assert(unit); const WarUnitStats* stats = wu_getUnitStats(unit->type); vec2 unitSize = wu_getUnitSize(context, entity); vec2 currentNode = path->nodes.items[state->move.pathNodeIndex]; vec2 nextNode = path->nodes.items[state->move.pathNodeIndex + 1]; if (state->move.checkForAttacks) { WarEntity* enemy = we_getAttacker(context, entity); if (enemy && wu_areEnemies(context, entity, enemy) && wu_canAttack(context, entity, enemy)) { vec2 enemyPosition = wu_getUnitPosition(context, enemy, true); WarState* attackState = wst_createAttackState(context, entity, enemy->id, enemyPosition); wst_changeNextState(context, entity, attackState, true, true); return; } } // if this unit is waiting if (state->move.waitCount > 0) { if (!isEmpty(map->finder, (s32)nextNode.x, (s32)nextNode.y)) { // wait for a number of times before re-route if (state->move.waitCount < MOVE_WAIT_INTENTS) { state->move.waitCount++; WarState* waitState = wst_createWaitState(context, entity, wmap_getMapScaledTime(context, MOVE_WAIT_TIME)); waitState->nextState = state; wst_changeNextState(context, entity, waitState, false, true); return; } state->move.waitCount = 0; // if there is no re-routing possible, go to idle if (!wpath_reRoutePath(map->finder, path, state->move.pathNodeIndex, path->nodes.count - 1)) { if (!wst_changeStateNextState(context, entity, state)) { WarState* idleState = wst_createIdleState(context, entity, true); wst_changeNextState(context, entity, idleState, true, true); } return; } nextNode = path->nodes.items[state->move.pathNodeIndex + 1]; } else { state->move.waitCount = 0; } setDynamicEntity(map->finder, (s32)nextNode.x, (s32)nextNode.y, (s32)unitSize.x, (s32)unitSize.y, entity->id); wu_setUnitDirectionFromDiff(context, entity, nextNode.x - currentNode.x, nextNode.y - currentNode.y); wact_setAction(context, entity, WAR_ACTION_TYPE_WALK, false, wu_getUnitActionScale(context, entity)); } vec2 position = wu_getUnitCenterPosition(context, entity, false); vec2 target = wmap_tileToMapCoordinatesV(nextNode, true); vec2 direction = vec2_subv(target, position); f32 directionLength = vec2_length(direction); f32 speed = wmap_getMapScaledSpeed(context, (f32)stats->speeds[unit->speed]); vec2 step = vec2_mulf(vec2_normalize(direction), speed * context->deltaTime); f32 stepLength = vec2_length(step); if (directionLength < stepLength) { step = direction; } vec2 newPosition = vec2_addv(position, step); wu_setUnitCenterPosition(context, entity, newPosition, false); f32 distance = vec2_distance(newPosition, target); if (distance < MOVE_EPSILON) { newPosition = target; wu_setUnitCenterPosition(context, entity, newPosition, false); setFreeTiles(map->finder, (s32)currentNode.x, (s32)currentNode.y, (s32)unitSize.x, (s32)unitSize.y); setFreeTiles(map->finder, (s32)nextNode.x, (s32)nextNode.y, (s32)unitSize.x, (s32)unitSize.y); state->move.pathNodeIndex++; // if there is no more path nodes to check, go to idle if (state->move.pathNodeIndex >= path->nodes.count - 1) { state->move.positionIndex++; // if this is no more segments, go to idle if (state->move.positionIndex >= state->move.positions.count - 1) { if (!wst_changeStateNextState(context, entity, state)) { WarState* idleState = wst_createIdleState(context, entity, true); wst_changeNextState(context, entity, idleState, true, true); } return; } // free the previous path and check if there is a new one wpath_freePath(*path); vec2 start = state->move.positions.items[state->move.positionIndex]; vec2 end = state->move.positions.items[state->move.positionIndex + 1]; *path = wpath_findPath(map->finder, (s32)start.x, (s32)start.y, (s32)end.x, (s32)end.y); // if there is no path for the next segment, go to idle if (path->nodes.count <= 1) { if (!wst_changeStateNextState(context, entity, state)) { WarState* idleState = wst_createIdleState(context, entity, true); wst_changeNextState(context, entity, idleState, true, true); } return; } state->move.pathNodeIndex = 0; } currentNode = path->nodes.items[state->move.pathNodeIndex]; setDynamicEntity(map->finder, (s32)currentNode.x, (s32)currentNode.y, (s32)unitSize.x, (s32)unitSize.y, entity->id); nextNode = path->nodes.items[state->move.pathNodeIndex + 1]; // if the next node is occupied, check if the unit have to wait to re-route if necessary if (!isEmpty(map->finder, (s32)nextNode.x, (s32)nextNode.y)) { // if the next node is occupied but is the last one, don't wait to re-route, go idle if (state->move.pathNodeIndex + 1 == path->nodes.count - 1) { if (!wst_changeStateNextState(context, entity, state)) { WarState* idleState = wst_createIdleState(context, entity, true); wst_changeNextState(context, entity, idleState, true, true); } return; } state->move.waitCount++; WarState* waitState = wst_createWaitState(context, entity, wmap_getMapScaledTime(context, MOVE_WAIT_TIME)); waitState->nextState = state; wst_changeNextState(context, entity, waitState, false, true); return; } setDynamicEntity(map->finder, (s32)nextNode.x, (s32)nextNode.y, (s32)unitSize.x, (s32)unitSize.y, entity->id); wu_setUnitDirectionFromDiff(context, entity, nextNode.x - currentNode.x, nextNode.y - currentNode.y); } } void wst_freeMoveState(WarContext* context, WarState* state) { NOT_USED(context); vec2ListFree(&state->move.positions); wpath_freePath(state->move.path); } ================================================ FILE: src/war_state_machine_patrol.c ================================================ #include "war_state_machine.h" WarState* wst_createPatrolState(WarContext* context, WarEntity* entity, s32 positionCount, vec2 positions[]) { WarState* state = wst_createState(context, entity, WAR_STATE_PATROL); state->patrol.dir = 1; vec2ListInit(&state->patrol.positions, vec2ListDefaultOptions); vec2ListAddRange(&state->patrol.positions, positionCount, positions); return state; } void wst_enterPatrolState(WarContext* context, WarEntity* entity, WarState* state) { if (state->patrol.positions.count <= 1) { if (!wst_changeStateNextState(context, entity, state)) { WarState* idleState = wst_createIdleState(context, entity, true); wst_changeNextState(context, entity, idleState, true, true); } return; } WarState* moveState = wst_createMoveState(context, entity, state->patrol.positions.count, vec2ListToArray(&state->patrol.positions)); moveState->nextState = state; wst_changeNextState(context, entity, moveState, false, true); } void wst_leavePatrolState(WarContext* context, WarEntity* entity, WarState* state) { NOT_USED(context); NOT_USED(entity); NOT_USED(state); } void wst_updatePatrolState(WarContext* context, WarEntity* entity, WarState* state) { vec2List positions = state->patrol.positions; // if the unit isn't where is suppose to be, then there must have been a problem in the move, so abort and go idle WarTransformComponent* transform = we_getTransformComponent(context, entity); assert(transform); vec2 actualPosition = wmap_mapToTileCoordinatesV(transform->position); vec2 shouldBeAt = positions.items[positions.count - 1]; f32 distance = vec2_distance(actualPosition, shouldBeAt); if (distance >= MOVE_EPSILON) { WarState* idleState = wst_createIdleState(context, entity, true); wst_changeNextState(context, entity, idleState, true, true); return; } // otherwise, reverse the positions list and go to the move state again state->patrol.dir *= -1; vec2ListReverse(&state->patrol.positions); vec2* positionsToMove = vec2ListToArray(&state->patrol.positions); WarState* moveState = wst_createMoveState(context, entity, state->patrol.positions.count, positionsToMove); moveState->nextState = state; wst_changeNextState(context, entity, moveState, false, true); wm_free(positionsToMove); } void wst_freePatrolState(WarContext* context, WarState* state) { NOT_USED(context); vec2ListFree(&state->patrol.positions); } ================================================ FILE: src/war_state_machine_repair.c ================================================ #include "war_state_machine.h" WarState* wst_createRepairState(WarContext* context, WarEntity* entity, WarEntityId buildingId) { WarState* state = wst_createState(context, entity, WAR_STATE_REPAIR); state->repair.buildingId = buildingId; return state; } void wst_enterRepairState(WarContext* context, WarEntity* entity, WarState* state) { NOT_USED(context); NOT_USED(entity); NOT_USED(state); } void wst_leaveRepairState(WarContext* context, WarEntity* entity, WarState* state) { NOT_USED(context); NOT_USED(entity); NOT_USED(state); } void wst_updateRepairState(WarContext* context, WarEntity* entity, WarState* state) { WarUnitComponent* unit = we_getUnitComponent(context, entity); assert(unit); const WarUnitStats* stats = wu_getUnitStats(unit->type); WarEntity* building = we_findEntity(context, state->repair.buildingId); // if the building doesn't exists or is collapsing (it could be attacked by other units), go idle if (!building || wst_isCollapsing(context, building) || wst_isGoingToCollapse(context, building)) { WarState* idleState = wst_createIdleState(context, entity, true); wst_changeNextState(context, entity, idleState, true, true); return; } // if the building is not in range, go to it if (!wu_unitInRange(context, entity, building, stats->range)) { vec2 targetTile = wu_unitPointOnTarget(context, entity, building); WarState* followState = wst_createFollowState(context, entity, building->id, targetTile, stats->range); followState->nextState = state; wst_changeNextState(context, entity, followState, false, true); return; } // the unit arrive to the building, go repairing WarState* repairingState = wst_createRepairingState(context, entity, building->id); wst_changeNextState(context, entity, repairingState, true, true); } void wst_freeRepairState(WarContext* context, WarState* state) { NOT_USED(context); NOT_USED(state); } ================================================ FILE: src/war_state_machine_repairing.c ================================================ #include "war_state_machine.h" #include "war_actions.h" #include "war_units.h" #include "war_pathfinder.h" WarState* wst_createRepairingState(WarContext* context, WarEntity* entity, WarEntityId buildingId) { WarState* state = wst_createState(context, entity, WAR_STATE_REPAIRING); state->repairing.buildingId = buildingId; state->repairing.insideBuilding = false; return state; } void wst_enterRepairingState(WarContext* context, WarEntity* entity, WarState* state) { WarMap* map = context->map; WarEntity* building = we_findEntity(context, state->repairing.buildingId); // if the building doesn't exists or is collapsing (it could be attacked by other units), go idle if (!building || wst_isCollapsing(context, building) || wst_isGoingToCollapse(context, building)) { WarState* idleState = wst_createIdleState(context, entity, true); wst_changeNextState(context, entity, idleState, true, true); return; } // if the building needs to be built, enter the building and build it if (wst_isBuilding(context, building) || wst_isGoingToBuild(context, building)) { WarState* buildState = wst_getBuildState(context, building); assert(buildState); // if there is already someone building it, go idle if (buildState->build.workerId) { WarState* idleState = wst_createIdleState(context, entity, true); wst_changeNextState(context, entity, idleState, true, true); return; } we_disableComponent(context, entity, COMP_SPRITE); // set the unit as inside the building state->repairing.insideBuilding = true; // set up that this worker is the one building the building buildState->build.workerId = entity->id; } else { vec2 unitSize = wu_getUnitSize(context, entity); vec2 position = wu_getUnitCenterPosition(context, entity, true); vec2 targetPosition = wu_getUnitCenterPosition(context, building, true); setStaticEntity(map->finder, (s32)position.x, (s32)position.y, (s32)unitSize.x, (s32)unitSize.y, entity->id); wu_setUnitDirectionFromDiff(context, entity, targetPosition.x - position.x, targetPosition.y - position.y); wact_setAction(context, entity, WAR_ACTION_TYPE_REPAIR, true, 1.0f); } } void wst_leaveRepairingState(WarContext* context, WarEntity* entity, WarState* state) { NOT_USED(state); WarMap* map = context->map; vec2 unitSize = wu_getUnitSize(context, entity); vec2 position = wu_getUnitCenterPosition(context, entity, true); setFreeTiles(map->finder, (s32)position.x, (s32)position.y, (s32)unitSize.x, (s32)unitSize.y); } void wst_updateRepairingState(WarContext* context, WarEntity* entity, WarState* state) { WarMap* map = context->map; WarPlayerInfo* player = &map->players[0]; WarUnitComponent* unit = we_getUnitComponent(context, entity); assert(unit); WarEntity* building = we_findEntity(context, state->repairing.buildingId); // if the building doesn't exists or is collapsing (it could be attacked by other units), go idle if (!building || wst_isCollapsing(context, building) || wst_isGoingToCollapse(context, building)) { if (state->repairing.insideBuilding) { we_enableComponent(context, entity, COMP_SPRITE); // find a valid spawn position for the unit vec2 position = wu_getUnitCenterPosition(context, entity, true); vec2 spawnPosition = wpath_findEmptyPosition(map->finder, position); wu_setUnitCenterPosition(context, entity, spawnPosition, true); } WarState* idleState = wst_createIdleState(context, entity, true); wst_changeNextState(context, entity, idleState, true, true); return; } // if the worker is inside the building then he is building it // so don't make any repairing since new buildings always spawn with full hp if (!state->repairing.insideBuilding) { WarUnitAction* action = &unit->actions[unit->actionType]; if (action->lastActionStep == WAR_ACTION_STEP_ATTACK) { if (!we_decreasePlayerResources(context, player, 1, 1)) { WarState* idleState = wst_createIdleState(context, entity, true); wst_changeNextState(context, entity, idleState, true, true); return; } // to calculate the amount of wood and gold needed to repair a // building I'm taking the 12% of the damage of the building, // so for the a FARM if it has a damage of 200, the amount of // wood and gold would be 200 * 0.12 = 24. // // when repairing each second the amount of wood and gold decrease // in 1, so for each we need to increase the hp in the proportional // amount, in this case is 1 * 100 / 12 = 8.33 (rounding to 9 here) WarUnitComponent* buildingUnit = we_getUnitComponent(context, building); assert(buildingUnit); buildingUnit->hp += 9; if (buildingUnit->hp >= buildingUnit->maxhp) { buildingUnit->hp = buildingUnit->maxhp; WarState* idleState = wst_createIdleState(context, entity, true); wst_changeNextState(context, entity, idleState, true, true); } action->lastActionStep = WAR_ACTION_STEP_NONE; } } else if (!wst_isBuilding(context, building) && !wst_isGoingToBuild(context, building)) { we_enableComponent(context, entity, COMP_SPRITE); // find a valid spawn position for the unit vec2 position = wu_getUnitCenterPosition(context, entity, true); vec2 spawnPosition = wpath_findEmptyPosition(map->finder, position); wu_setUnitCenterPosition(context, entity, spawnPosition, true); WarState* idleState = wst_createIdleState(context, entity, true); wst_changeNextState(context, entity, idleState, true, true); } } void wst_freeRepairingState(WarContext* context, WarState* state) { NOT_USED(context); NOT_USED(state); } ================================================ FILE: src/war_state_machine_train.c ================================================ #include #include "war_state_machine.h" #include "war_audio.h" WarState* wst_createTrainState(WarContext* context, WarEntity* entity, WarUnitType unitToBuild, f32 buildTime) { WarState* state = wst_createState(context, entity, WAR_STATE_TRAIN); state->train.unitToBuild = unitToBuild; state->train.buildTime = 0; state->train.totalBuildTime = buildTime; state->train.cancelled = false; return state; } void wst_enterTrainState(WarContext* context, WarEntity* entity, WarState* state) { NOT_USED(state); WarMap* map = context->map; WarUnitComponent* unit = we_getUnitComponent(context, entity); assert(unit); WarTransformComponent* transform = we_getTransformComponent(context, entity); assert(transform); vec2 unitSize = wu_getUnitSize(context, entity); vec2 position = wmap_mapToTileCoordinatesV(transform->position); setStaticEntity(map->finder, (s32)position.x, (s32)position.y, (s32)unitSize.x, (s32)unitSize.y, entity->id); unit->building = true; unit->buildPercent = 0; } void wst_leaveTrainState(WarContext* context, WarEntity* entity, WarState* state) { NOT_USED(state); WarMap* map = context->map; WarUnitComponent* unit = we_getUnitComponent(context, entity); assert(unit); WarTransformComponent* transform = we_getTransformComponent(context, entity); assert(transform); vec2 unitSize = wu_getUnitSize(context, entity); vec2 position = wmap_mapToTileCoordinatesV(transform->position); setFreeTiles(map->finder, (s32)position.x, (s32)position.y, (s32)unitSize.x, (s32)unitSize.y); unit->building = false; } void wst_updateTrainState(WarContext* context, WarEntity* entity, WarState* state) { WarMap* map = context->map; WarUnitComponent* unit = we_getUnitComponent(context, entity); assert(unit); if (state->train.cancelled) { if (!wst_changeStateNextState(context, entity, state)) { WarState* idleState = wst_createIdleState(context, entity, false); wst_changeNextState(context, entity, idleState, true, true); } return; } f32 trainSpeed = wmap_getMapScaledSpeed(context, context->deltaTime); // if hurry up cheat is enabled, speed up the train time by 5000% if (map->hurryUp) { trainSpeed *= CHEAT_SPEED_UP_FACTOR; } state->train.buildTime += trainSpeed; // if the building is finished... if (state->train.buildTime >= state->train.totalBuildTime) { unit->buildPercent = 1; // ...create the unit WarEntity* unitToBuild = we_createDude(context, CREATE_UNIT_ARGS_INIT( .type=state->train.unitToBuild, .x=0, .y=0, .player=unit->player, .isGoingToTrain=false )); // ...find an empty position to put it vec2 position = wu_getUnitCenterPosition(context, entity, true); vec2 spawnPosition = wpath_findEmptyPosition(map->finder, position); wu_setUnitCenterPosition(context, unitToBuild, spawnPosition, true); if (!wst_changeStateNextState(context, entity, state)) { WarState* idleState = wst_createIdleState(context, entity, false); wst_changeNextState(context, entity, idleState, true, true); } WarAudioId audioId = wu_isHumanUnit(context, unitToBuild) ? WAR_HUMAN_READY : WAR_ORC_READY; wa_createAudio(context, CREATE_AUDIO_ARGS_INIT(.audioId=audioId, .loop=false)); return; } unit->buildPercent = PERCENTF01(state->train.buildTime, state->train.totalBuildTime); } void wst_freeTrainState(WarContext* context, WarState* state) { NOT_USED(context); NOT_USED(state); } ================================================ FILE: src/war_state_machine_upgrade.c ================================================ #include "war_state_machine.h" WarState* wst_createUpgradeState(WarContext* context, WarEntity* entity, WarUpgradeType upgradeToBuild, f32 buildTime) { WarState* state = wst_createState(context, entity, WAR_STATE_UPGRADE); state->upgrade.upgradeToBuild = upgradeToBuild; state->upgrade.buildTime = 0; state->upgrade.totalBuildTime = buildTime; state->upgrade.cancelled = false; return state; } void wst_enterUpgradeState(WarContext* context, WarEntity* entity, WarState* state) { NOT_USED(state); WarMap* map = context->map; WarUnitComponent* unit = we_getUnitComponent(context, entity); assert(unit); WarTransformComponent* transform = we_getTransformComponent(context, entity); assert(transform); vec2 unitSize = wu_getUnitSize(context, entity); vec2 position = wmap_mapToTileCoordinatesV(transform->position); setStaticEntity(map->finder, (s32)position.x, (s32)position.y, (s32)unitSize.x, (s32)unitSize.y, entity->id); unit->building = true; unit->buildPercent = 0; } void wst_leaveUpgradeState(WarContext* context, WarEntity* entity, WarState* state) { NOT_USED(state); WarMap* map = context->map; WarUnitComponent* unit = we_getUnitComponent(context, entity); assert(unit); WarTransformComponent* transform = we_getTransformComponent(context, entity); assert(transform); vec2 unitSize = wu_getUnitSize(context, entity); vec2 position = wmap_mapToTileCoordinatesV(transform->position); setFreeTiles(map->finder, (s32)position.x, (s32)position.y, (s32)unitSize.x, (s32)unitSize.y); unit->building = false; } void wst_updateUpgradeState(WarContext* context, WarEntity* entity, WarState* state) { WarMap* map = context->map; WarPlayerInfo* player = &map->players[0]; WarUnitComponent* unit = we_getUnitComponent(context, entity); assert(unit); if (state->upgrade.cancelled) { if (!wst_changeStateNextState(context, entity, state)) { WarState* idleState = wst_createIdleState(context, entity, false); wst_changeNextState(context, entity, idleState, true, true); } return; } f32 buildSpeed = wmap_getMapScaledSpeed(context, context->deltaTime); // if hurry up cheat is enabled, speed up the build time by 5000% if (map->hurryUp) { buildSpeed *= CHEAT_SPEED_UP_FACTOR; } state->upgrade.buildTime += buildSpeed; // if the building is finished... if (state->upgrade.buildTime >= state->upgrade.totalBuildTime) { unit->buildPercent = 1; // increase the level of the upgrade we_increaseUpgradeLevel(context, player, state->upgrade.upgradeToBuild); assert(checkUpgradeLevel(player, state->upgrade.upgradeToBuild)); if (!wst_changeStateNextState(context, entity, state)) { WarState* idleState = wst_createIdleState(context, entity, false); wst_changeNextState(context, entity, idleState, true, true); } return; } unit->buildPercent = PERCENTF01(state->upgrade.buildTime, state->upgrade.totalBuildTime); } void wst_freeUpgradeState(WarContext* context, WarState* state) { NOT_USED(context); NOT_USED(state); } ================================================ FILE: src/war_state_machine_wait.c ================================================ #include "war_state_machine.h" #include "war_actions.h" WarState* wst_createWaitState(WarContext* context, WarEntity* entity, f32 waitTime) { WarState* state = wst_createState(context, entity, WAR_STATE_WAIT); state->wait.waitTime = waitTime; return state; } void wst_enterWaitState(WarContext* context, WarEntity* entity, WarState* state) { NOT_USED(state); WarMap* map = context->map; WarTransformComponent* transform = we_getTransformComponent(context, entity); assert(transform); vec2 unitSize = wu_getUnitSize(context, entity); vec2 position = wmap_mapToTileCoordinatesV(transform->position); setStaticEntity(map->finder, (s32)position.x, (s32)position.y, (s32)unitSize.x, (s32)unitSize.y, entity->id); wact_setAction(context, entity, WAR_ACTION_TYPE_IDLE, true, 1.0f); } void wst_leaveWaitState(WarContext* context, WarEntity* entity, WarState* state) { NOT_USED(state); WarMap* map = context->map; WarTransformComponent* transform = we_getTransformComponent(context, entity); assert(transform); vec2 unitSize = wu_getUnitSize(context, entity); vec2 position = wmap_mapToTileCoordinatesV(transform->position); setFreeTiles(map->finder, (s32)position.x, (s32)position.y, (s32)unitSize.x, (s32)unitSize.y); } void wst_updateWaitState(WarContext* context, WarEntity* entity, WarState* state) { state->wait.waitTime -= wmap_getMapScaledSpeed(context, context->deltaTime); if (state->wait.waitTime < 0) { if (!wst_changeStateNextState(context, entity, state)) { WarState* idleState = wst_createIdleState(context, entity, true); wst_changeNextState(context, entity, idleState, true, true); } } } void wst_freeWaitState(WarContext* context, WarState* state) { NOT_USED(context); NOT_USED(state); } ================================================ FILE: src/war_trees.c ================================================ #include "war_entities.h" #include bool we_hasTreeAtPosition(WarContext* context, WarEntity* forest, s32 x, s32 y) { WarForestComponent* fc = we_getForestComponent(context, forest); assert(fc); WarTreeList* trees = &fc->trees; for (s32 i = 0; i < trees->count; i++) { WarTree* tree = &trees->items[i]; if (tree->tilex == x && tree->tiley == y) return true; } return false; } WarTree* we_getTreeAtPosition(WarContext* context, WarEntity* forest, s32 x, s32 y) { WarForestComponent* fc = we_getForestComponent(context, forest); assert(fc); WarTreeList* trees = &fc->trees; for (s32 i = 0; i < trees->count; i++) { WarTree* tree = &trees->items[i]; if (tree->tilex == x && tree->tiley == y) return tree; } return NULL; } void we_determineTreeTiles(WarContext* context, WarEntity* forest) { assert(forest); assert(forest->type == WAR_ENTITY_TYPE_FOREST); WarMap* map = context->map; WarForestComponent* fc = we_getForestComponent(context, forest); assert(fc); WarTreeList* trees = &fc->trees; const s32 dirC = 8; const s32 dirX[] = { -1, 0, 1, 1, 1, 0, -1, -1 }; const s32 dirY[] = { -1, -1, -1, 0, 1, 1, 1, 0 }; s32List invalidTrees; s32ListInit(&invalidTrees, s32ListDefaultOptions); for (s32 i = 0; i < trees->count; i++) { WarTree* ti = &trees->items[i]; if (ti->type == WAR_TREE_CHOPPED) continue; s32 index = 0; for (s32 d = 0; d < dirC; d++) { s32 xx = ti->tilex + dirX[d]; s32 yy = ti->tiley + dirY[d]; if (wpath_isInside(map->finder, xx, yy)) { WarEntityId entityId = getTileEntityId(map->finder, xx, yy); WarEntity* entity = we_findEntity(context, entityId); if (entity && entity->type == WAR_ENTITY_TYPE_FOREST) { WarTree* tree = we_getTreeAtPosition(context, entity, xx, yy); if (tree && tree->amount > 0) index = index | (1 << d); } } else { index = index | (1 << d); } } ti->type = treeTileTypeMap[index]; if (ti->type == WAR_TREE_NONE) s32ListAdd(&invalidTrees, i); } for (s32 i = invalidTrees.count - 1; i >= 0; i--) WarTreeListRemoveAt(trees, invalidTrees.items[i]); s32ListFree(&invalidTrees); } void we_determineAllTreeTiles(WarContext* context) { WarEntityList* forests = we_getEntitiesOfType(context, WAR_ENTITY_TYPE_FOREST); for (s32 i = 0; i < forests->count; i++) { WarEntity* entity = forests->items[i]; if (entity) { we_determineTreeTiles(context, entity); } } } WarTree* we_findAccesibleTree(WarContext* context, WarEntity* forest, vec2 position) { WarMap* map = context->map; WarTree* result = NULL; vec2List positions; vec2ListInit(&positions, vec2ListDefaultOptions); vec2ListAdd(&positions, position); const s32 dirC = 8; const s32 dirX[] = { 0, 1, 1, 1, 0, -1, -1, -1 }; const s32 dirY[] = { -1, -1, 0, 1, 1, 1, 0, -1 }; for (s32 i = 0; i < positions.count; i++) { position = positions.items[i]; WarTree* tree = we_getTreeAtPosition(context, forest, (s32)position.x, (s32)position.y); if (tree) { bool isTreeAccessible = wpath_isPositionAccesible(map->finder, position); bool isTreeVisibleOrFog = wmap_isTileVisible(map, (s32)position.x, (s32)position.y) || wmap_isTileFog(map, (s32)position.x, (s32)position.y); if (isTreeAccessible && isTreeVisibleOrFog && tree->amount > 0) { result = tree; break; } } for (s32 d = 0; d < dirC; d++) { s32 xx = (s32)position.x + dirX[d]; s32 yy = (s32)position.y + dirY[d]; if (wpath_isInside(map->finder, xx, yy)) { vec2 newPosition = vec2i(xx, yy); if (!vec2ListContains(&positions, newPosition)) vec2ListAdd(&positions, newPosition); } } } vec2ListFree(&positions); return result; } void we_plantTree(WarContext* context, WarEntity* entity, s32 x, s32 y) { assert(entity); assert(entity->type == WAR_ENTITY_TYPE_FOREST); WarMap* map = context->map; // if the position is not empty, there can't be tree there if (!isEmpty(map->finder, x, y)) return; WarForestComponent* forest = we_getForestComponent(context, entity); assert(forest); // only plant a tree in the top border of the map, if there are one below if (!wpath_isInside(map->finder, x, y - 1)) { WarTree* belowTree = we_getTreeAtPosition(context, entity, x, y + 1); if (belowTree) { WarTree tree1 = createTree(x, y, TREE_MAX_WOOD); WarTreeListAdd(&forest->trees, tree1); setStaticEntity(map->finder, x, y, 1, 1, entity->id); } } else { WarTree tree1 = createTree(x, y, TREE_MAX_WOOD); WarTreeListAdd(&forest->trees, tree1); setStaticEntity(map->finder, x, y, 1, 1, entity->id); if (isEmpty(map->finder, x, y - 1)) { WarTree tree2 = createTree(x, y - 1, TREE_MAX_WOOD); WarTreeListAdd(&forest->trees, tree2); setStaticEntity(map->finder, x, y - 1, 1, 1, entity->id); } } } bool we_validTree(WarContext* context, WarEntity* forest, WarTree* tree) { WarForestComponent* fc = we_getForestComponent(context, forest); assert(fc); WarTreeList* trees = &fc->trees; for (s32 i = 0; i < trees->count; i++) { WarTree* tree2 = &trees->items[i]; if (tree2->tilex == tree->tilex) { if (tree2->tiley == tree->tiley - 1 || tree2->tiley == tree->tiley + 1) { return true; } } } return false; } void we_takeTreeDown(WarContext* context, WarEntity* forest, WarTree* tree) { WarMap* map = context->map; assert(map); assert(forest); assert(forest->type == WAR_ENTITY_TYPE_FOREST); assert(tree); const WarTreeData* data = wu_getTreeData(WAR_TREE_CHOPPED); s32 choppedTileIndex = map->tilesetType == MAP_TILESET_FOREST ? data->tileIndexForest : data->tileIndexSwamp; WarTree choppedTree = *tree; setFreeTiles(map->finder, choppedTree.tilex, choppedTree.tiley, 1, 1); wmap_setMapTileIndex(context, choppedTree.tilex, choppedTree.tiley, choppedTileIndex); WarForestComponent* forestComp = we_getForestComponent(context, forest); assert(forestComp); WarTreeListRemove(&forestComp->trees, choppedTree); WarTree* aboveTree = we_getTreeAtPosition(context, forest, choppedTree.tilex, choppedTree.tiley - 1); if (aboveTree && !we_validTree(context, forest, aboveTree)) we_takeTreeDown(context, forest, aboveTree); WarTree* belowTree = we_getTreeAtPosition(context, forest, choppedTree.tilex, choppedTree.tiley + 1); if (belowTree && !we_validTree(context, forest, belowTree)) we_takeTreeDown(context, forest, belowTree); } s32 we_chopTree(WarContext* context, WarEntity* forest, WarTree* tree, s32 amount) { if (tree->amount < amount) amount = tree->amount; tree->amount -= amount; tree->amount = MAX(tree->amount, 0); if (tree->amount == 0) { we_takeTreeDown(context, forest, tree); we_determineTreeTiles(context, forest); } return amount; } WarEntity* we_createForest(WarContext* context) { WarMap* map = context->map; WarTreeList trees; WarTreeListInit(&trees, WarTreeListDefaultOptions); WarEntity *entity = we_createEntity(context, WAR_ENTITY_TYPE_FOREST, true); we_addSpriteComponent(context, entity, WAR_SPRITE_COMPONENT_INIT( .sprite = map->sprite )); we_addForestComponent(context, entity, trees); return entity; } ================================================ FILE: src/war_ui.c ================================================ #include "war_ui.h" #include #include #include "shl/wstr.h" #include "war_audio.h" #include "war_entities.h" #include "war_resources.h" bool wui_isUIEntity(WarEntity* entity) { switch (entity->type) { case WAR_ENTITY_TYPE_IMAGE: case WAR_ENTITY_TYPE_TEXT: case WAR_ENTITY_TYPE_RECT: case WAR_ENTITY_TYPE_BUTTON: case WAR_ENTITY_TYPE_CURSOR: case WAR_ENTITY_TYPE_MINIMAP: return true; default: return false; } } void wui_clearUIText(WarContext* context, WarEntity* uiText) { WarTextComponent* text = we_getTextComponent(context, uiText); assert(text); wstr_free(text->text); text->text = wstr_make(); we_disableComponent(context, uiText, COMP_TEXT); } void wui_setUIText(WarContext* context, WarEntity* uiText, String text) { wui_clearUIText(context, uiText); if (text.data) { WarTextComponent* textComp = we_getTextComponent(context, uiText); assert(textComp); textComp->text = text; we_enableComponent(context, uiText, COMP_TEXT); } } void wui_setUIImage(WarContext* context, WarEntity* uiImage, s32 frameIndex) { WarSpriteComponent* sprite = we_getSpriteComponent(context, uiImage); assert(sprite); sprite->frameIndex = frameIndex; we_setComponentEnabled(context, uiImage, COMP_SPRITE, frameIndex >= 0); } void wui_setUIRectWidth(WarContext* context, WarEntity* uiRect, s32 width) { WarRectComponent* rect = we_getRectComponent(context, uiRect); assert(rect); rect->size.x = (f32)width; we_setComponentEnabled(context, uiRect, COMP_RECT, width > 0); } void wui_clearUITooltip(WarContext* context, WarEntity* uiButton) { WarButtonComponent* button = we_getButtonComponent(context, uiButton); assert(button); wstr_free(button->tooltip); button->tooltip = wstr_make(); } void wui_setUITooltip(WarContext* context, WarEntity* uiButton, s32 highlightIndex, s32 highlightCount, String text) { wui_clearUITooltip(context, uiButton); if (text.data) { WarButtonComponent* button = we_getButtonComponent(context, uiButton); assert(button); button->highlightIndex = highlightIndex; button->highlightCount = highlightCount; button->tooltip = text; } } void wui_setUITextHighlight(WarContext* context, WarEntity* uiButton, s32 highlightIndex, s32 highlightCount) { WarTextComponent* textComp = we_getTextComponent(context, uiButton); assert(textComp); textComp->highlightIndex = highlightIndex; textComp->highlightCount = highlightCount; } void setUIEntityStatus(WarContext* context, WarEntity* uiEntity, bool value) { we_setComponentEnabled(context, uiEntity, COMP_UI, value); } void setUIButtonStatus(WarContext* context, WarEntity* uiEntity, bool value) { we_setComponentEnabled(context, uiEntity, COMP_BUTTON, value); } void setUIButtonInteractive(WarContext* context, WarEntity* uiEntity, bool value) { WarButtonComponent* button = we_getButtonComponent(context, uiEntity); assert(button); button->interactive = value; } void setUIButtonHotKey(WarContext* context, WarEntity* uiEntity, WarKeys key) { WarButtonComponent* button = we_getButtonComponent(context, uiEntity); assert(button); button->hotKey = key; } void setUIButtonClickHandler(WarContext* context, WarEntity* uiEntity, void (*handler)(WarContext*, WarEntity*)) { WarButtonComponent* button = we_getButtonComponent(context, uiEntity); assert(button); button->clickHandler = handler; } void wui_setUIButtonStatusByName(WarContext* context, StringView name, bool enabled) { WarEntity* entity = we_findUIEntity(context, name); if (entity) { setUIButtonStatus(context, entity, enabled); } } void wui_setUIButtonInteractiveByName(WarContext* context, StringView name, bool interactive) { WarEntity* entity = we_findUIEntity(context, name); if (entity) { setUIButtonInteractive(context, entity, interactive); } } void wui_setUIButtonHotKeyByName(WarContext* context, StringView name, WarKeys key) { WarEntity* entity = we_findUIEntity(context, name); if (entity) { setUIButtonHotKey(context, entity, key); } } void wui_setUIEntityStatusByName(WarContext* context, StringView name, bool enabled) { WarEntity* entity = we_findUIEntity(context, name); if (entity) { setUIEntityStatus(context, entity, enabled); } } void wui_changeCursorType(WarContext* context, WarCursorType type) { context->imui.cursor_type = type; } void wui_updateUICursor(WarContext* context) { NOT_USED(context); // Cursor is now fully managed by imui: wui_changeCursorType sets the type // each frame, and imui_end() renders the sprite at the mouse position. } void wui_updateUIButtons(WarContext* context, bool hotKeysEnabled) { TracyCZoneN(ctx, "UpdateUIButtons", 1); WarInput* input = &context->input; WarEntityList* buttons = we_getEntitiesOfType(context, WAR_ENTITY_TYPE_BUTTON); WarEntity* hoveredButton = NULL; WarEntity* capturedButton = NULL; // NOTE: Store the buttons to update in this frame first // because the action of some buttons is to show other buttons // in their same location, and if the newly shown button is // after in the list, then it will update in this same frame // which shouldn't happen WarEntityIdSet buttonsToUpdate; WarEntityIdSetInit(&buttonsToUpdate, WarEntityIdSetDefaultOptions); for(s32 i = 0; i < buttons->count; i++) { WarEntity* entity = buttons->items[i]; if (entity) { WarButtonComponent* button = we_getButtonComponent(context, entity); assert(button); if (we_isComponentEnabled(context, entity, COMP_UI) && we_isComponentEnabled(context, entity, COMP_BUTTON) && button->interactive) { WarEntityIdSetAdd(&buttonsToUpdate, entity->id); WarTransformComponent* transform = we_getTransformComponent(context, entity); assert(transform); vec2 backgroundSize = vec2i(button->normalSprite.frameWidth, button->normalSprite.frameHeight); rect buttonRect = rectv(transform->position, backgroundSize); if (rect_containsf(buttonRect, input->pos.x, input->pos.y)) { hoveredButton = entity; } } else { button->hot = false; button->active = false; if (input->capturedUIButtonId == entity->id) { input->capturedUIButtonId = 0; } } } } if (input->capturedUIButtonId) { capturedButton = we_findEntity(context, input->capturedUIButtonId); if (!capturedButton || !WarEntityIdSetContains(&buttonsToUpdate, capturedButton->id)) { input->capturedUIButtonId = 0; capturedButton = NULL; } } if (isButtonJustPressed(input, WAR_MOUSE_LEFT) && hoveredButton) { input->capturedUIButtonId = hoveredButton->id; capturedButton = hoveredButton; } for(s32 i = 0; i < buttons->count; i++) { WarEntity* entity = buttons->items[i]; if (entity && WarEntityIdSetContains(&buttonsToUpdate, entity->id)) { WarButtonComponent* button = we_getButtonComponent(context, entity); assert(button); bool isHovered = entity == hoveredButton; bool isCaptured = entity == capturedButton; button->hot = isHovered; button->active = isHovered && isCaptured && isButtonHeld(input, WAR_MOUSE_LEFT); if (hotKeysEnabled && isKeyJustReleased(input, button->hotKey)) { if (button->clickHandler) { button->hot = false; button->active = false; button->clickHandler(context, entity); // in this case break to not allow pressing multiple keys // and executing all of the command for those keys break; } } if (isButtonJustReleased(input, WAR_MOUSE_LEFT) && isCaptured) { if (isHovered && button->clickHandler) { button->clickHandler(context, entity); wa_createAudio(context, CREATE_AUDIO_ARGS_INIT(.audioId=WAR_UI_CLICK, .loop=false)); } button->active = false; input->capturedUIButtonId = 0; } } } WarEntityIdSetFree(&buttonsToUpdate); TracyCZoneEnd(ctx); } void wui_renderUIEntities(WarContext* context) { TracyCZoneN(ctx, "RenderUIEntities", 1); WarEntityList* entities = we_getUIEntities(context); for(s32 i = 0; i < entities->count; i++) { WarEntity *entity = entities->items[i]; // Cursor entities are now rendered by imui_end(); skip them here. if (entity && entity->type != WAR_ENTITY_TYPE_CURSOR) { we_renderEntity(context, entity); } } TracyCZoneEnd(ctx); } ================================================ FILE: src/war_ui.h ================================================ #pragma once #include #include "shl/wstr.h" #include "war.h" #include "war_entities.h" bool wui_isUIEntity(WarEntity* entity); void wui_clearUIText(WarContext* context, WarEntity* uiText); void wui_setUIText(WarContext* context, WarEntity* uiText, String text); void wui_setUIImage(WarContext* context, WarEntity* uiImage, s32 frameIndex); void wui_setUIRectWidth(WarContext* context, WarEntity* uiRect, s32 width); void wui_clearUITooltip(WarContext* context, WarEntity* uiButton); void wui_setUITooltip(WarContext* context, WarEntity* uiButton, s32 highlightIndex, s32 highlightCount, String text); void wui_setUITextHighlight(WarContext* context, WarEntity* uiButton, s32 highlightIndex, s32 highlightCount); void setUIEntityStatus(WarContext* ctx, WarEntity* uiEntity, bool value); void setUIButtonStatus(WarContext* ctx, WarEntity* uiEntity, bool value); void setUIButtonInteractive(WarContext* ctx, WarEntity* uiEntity, bool value); void setUIButtonHotKey(WarContext* ctx, WarEntity* uiEntity, WarKeys key); void setUIButtonClickHandler(WarContext* ctx, WarEntity* uiEntity, void (*handler)(WarContext*, WarEntity*)); void wui_setUIButtonStatusByName(WarContext* context, StringView name, bool enabled); void wui_setUIButtonInteractiveByName(WarContext* context, StringView name, bool interactive); void wui_setUIButtonHotKeyByName(WarContext* context, StringView name, WarKeys key); void wui_setUIEntityStatusByName(WarContext* context, StringView name, bool enabled); typedef struct { vec2 position; vec2 rotation; vec2 scale; StringView text; s32 fontIndex; f32 fontSize; f32 lineHeight; WarColor fontColor; WarColor highlightColor; s32 highlightIndex; s32 highlightCount; vec2 boundings; WarTextAlignment horizontalAlign; WarTextAlignment verticalAlign; WarTextAlignment lineAlign; WarTextWrapping wrapping; WarTextTrimming trimming; bool multiline; } CreateUITextArgs; typedef struct { vec2 position; vec2 rotation; vec2 scale; vec2 size; WarColor color; } CreateUIRectArgs; typedef struct { WarSpriteResourceRef spriteRef; vec2 position; vec2 rotation; vec2 scale; } CreateUIImageArgs; typedef struct { WarCursorType type; vec2 position; vec2 rotation; vec2 scale; s32 frameIndex; } CreateUICursorArgs; typedef struct { vec2 position; vec2 rotation; vec2 scale; s32 fontIndex; f32 fontSize; StringView text; f32 lineHeight; WarColor fontColor; WarColor highlightColor; s32 highlightIndex; s32 highlightCount; WarTextAlignment horizontalAlign; WarTextAlignment verticalAlign; WarTextAlignment lineAlign; WarTextWrapping wrapping; WarTextTrimming trimming; WarSpriteResourceRef backgroundNormalRef; WarSpriteResourceRef backgroundPressedRef; WarSpriteResourceRef foregroundRef; bool interactive; WarKeys hotKey; StringView tooltip; s32 tooltipHighlightIndex; s32 tooltipHighlightCount; s32 gold; s32 wood; WarClickHandler clickHandler; } CreateUITextButtonArgs; typedef struct { WarSpriteResourceRef backgroundNormalRef; WarSpriteResourceRef backgroundPressedRef; WarSpriteResourceRef foregroundRef; vec2 position; vec2 rotation; vec2 scale; bool interactive; WarKeys hotKey; StringView tooltip; s32 tooltipHighlightIndex; s32 tooltipHighlightCount; s32 gold; s32 wood; s32 foregroundFrameIndex; WarClickHandler clickHandler; } CreateUIImageButtonArgs; #define CREATE_UI_TEXT_ARGS_INIT_CONST(...) { \ .scale = {1, 1}, \ .fontSize = 10, \ .fontColor = FONT_NORMAL_COLOR_INIT, \ .highlightColor = FONT_HIGHLIGHT_COLOR_INIT, \ .highlightIndex = NO_HIGHLIGHT, \ .verticalAlign = WAR_TEXT_ALIGN_TOP, \ .lineAlign = WAR_TEXT_ALIGN_LEFT, \ .wrapping = WAR_TEXT_WRAP_NONE, \ __VA_ARGS__ \ } #define CREATE_UI_TEXT_ARGS_INIT(...) (&(CreateUITextArgs)CREATE_UI_TEXT_ARGS_INIT_CONST(__VA_ARGS__)) #define CREATE_UI_RECT_ARGS_INIT_CONST(...) { \ .scale = {1, 1}, \ __VA_ARGS__ \ } #define CREATE_UI_RECT_ARGS_INIT(...) (&(CreateUIRectArgs)CREATE_UI_RECT_ARGS_INIT_CONST(__VA_ARGS__)) #define CREATE_UI_IMAGE_ARGS_INIT_CONST(...) { \ .scale = {1, 1}, \ __VA_ARGS__ \ } #define CREATE_UI_IMAGE_ARGS_INIT(...) (&(CreateUIImageArgs)CREATE_UI_IMAGE_ARGS_INIT_CONST(__VA_ARGS__)) #define CREATE_UI_CURSOR_ARGS_INIT_CONST(...) { \ .scale = {1, 1}, \ __VA_ARGS__ \ } #define CREATE_UI_CURSOR_ARGS_INIT(...) (&(CreateUICursorArgs)CREATE_UI_CURSOR_ARGS_INIT_CONST(__VA_ARGS__)) #define CREATE_UI_TEXT_BUTTON_ARGS_INIT_CONST(...) { \ .scale = {1, 1}, \ .fontSize = 10, \ .fontColor = FONT_NORMAL_COLOR_INIT, \ .highlightColor = FONT_HIGHLIGHT_COLOR_INIT, \ .highlightIndex = NO_HIGHLIGHT, \ .foregroundRef = { -1, 0, {0} }, \ .interactive = true, \ .hotKey = WAR_KEY_NONE, \ .tooltipHighlightIndex = NO_HIGHLIGHT, \ .horizontalAlign = WAR_TEXT_ALIGN_CENTER, \ .verticalAlign = WAR_TEXT_ALIGN_MIDDLE, \ __VA_ARGS__ \ } #define CREATE_UI_TEXT_BUTTON_ARGS_INIT(...) (&(CreateUITextButtonArgs)CREATE_UI_TEXT_BUTTON_ARGS_INIT_CONST(__VA_ARGS__)) #define CREATE_UI_IMAGE_BUTTON_ARGS_INIT_CONST(...) { \ .scale = {1, 1}, \ .foregroundRef = { -1, 0, {0} }, \ .interactive = true, \ .hotKey = WAR_KEY_NONE, \ .tooltipHighlightIndex = NO_HIGHLIGHT, \ .foregroundFrameIndex = 0, \ __VA_ARGS__ \ } #define CREATE_UI_IMAGE_BUTTON_ARGS_INIT(...) (&(CreateUIImageButtonArgs)CREATE_UI_IMAGE_BUTTON_ARGS_INIT_CONST(__VA_ARGS__)) void wui_changeCursorType(WarContext* context, WarCursorType type); void wui_updateUICursor(WarContext* context); void wui_updateUIButtons(WarContext* context, bool hotKeysEnabled); void wui_renderUIEntities(WarContext* context); ================================================ FILE: src/war_units.c ================================================ #include "war_units.h" // Brace-only StringView initializer for use in file-scope const arrays. // Unlike WSV_LITERAL, this does not use a compound literal cast so it // satisfies -Wpedantic's "initializer element is not constant" requirement. #define WSV_INIT(s) { s, sizeof(s) - 1 } // Build time in seconds: (t program cycles) * 80 seconds / 1000 cycles #define __bts(t) ((t)*80/1000) const StringView features[MAX_FEATURES_COUNT * 2] = { // Units. 0 - 6 WSV_INIT("unit-footman"), WSV_INIT("unit-grunt"), WSV_INIT("unit-peasant"), WSV_INIT("unit-peon"), WSV_INIT("unit-human-catapult"), WSV_INIT("unit-orc-catapult"), WSV_INIT("unit-knight"), WSV_INIT("unit-raider"), WSV_INIT("unit-archer"), WSV_INIT("unit-spearman"), WSV_INIT("unit-conjurer"), WSV_INIT("unit-warlock"), WSV_INIT("unit-cleric"), WSV_INIT("unit-necrolyte"), // Constructing buildings. 7 - 14 WSV_INIT("unit-human-farm"), WSV_INIT("unit-orc-farm"), WSV_INIT("unit-human-barracks"), WSV_INIT("unit-orc-barracks"), WSV_INIT("unit-human-church"), WSV_INIT("unit-orc-temple"), WSV_INIT("unit-human-tower"), WSV_INIT("unit-orc-tower"), WSV_INIT("unit-human-town-hall"), WSV_INIT("unit-orc-town-hall"), WSV_INIT("unit-human-lumber-mill"), WSV_INIT("unit-orc-lumber-mill"), WSV_INIT("unit-human-stable"), WSV_INIT("unit-orc-kennel"), WSV_INIT("unit-human-blacksmith"), WSV_INIT("unit-orc-blacksmith"), // Cleric/Necrolyte spells. 15 - 17 WSV_INIT("upgrade-healing"), WSV_INIT("upgrade-raise-dead"), WSV_INIT("upgrade-holy-vision"), WSV_INIT("upgrade-dark-vision"), WSV_INIT("upgrade-invisibility"), WSV_INIT("upgrade-unholy-armor"), // Conjurer/Warlock spells. 18 - 20 WSV_INIT("upgrade-scorpion"), WSV_INIT("upgrade-spider"), WSV_INIT("upgrade-rain-of-fire"), WSV_INIT("upgrade-poison-cloud"), WSV_INIT("upgrade-water-elemental"), WSV_INIT("upgrade-daemon"), // Roads and walls. 21 - 22 WSV_INIT("unit-road"), WSV_INIT("unit-wall") }; static_assert(arrayLength(features) == MAX_FEATURES_COUNT * 2, "features array size does not match MAX_FEATURES_COUNT"); const StringView upgradeNames[MAX_UPGRADES_COUNT * 2] = { // Basic upgrades WSV_INIT("upgrade-spear"), WSV_INIT("upgrade-arrow"), WSV_INIT("upgrade-axe"), WSV_INIT("upgrade-sword"), WSV_INIT("upgrade-wolves"), WSV_INIT("upgrade-horse"), // Spells and summons WSV_INIT("upgrade-spider"), WSV_INIT("upgrade-scorpion"), WSV_INIT("upgrade-poison-cloud"), WSV_INIT("upgrade-rain-of-fire"), WSV_INIT("upgrade-daemon"), WSV_INIT("upgrade-water-elemental"), WSV_INIT("upgrade-raise-dead"), WSV_INIT("upgrade-healing"), WSV_INIT("upgrade-dark-vision"), WSV_INIT("upgrade-far-seeing"), WSV_INIT("upgrade-unholy-armor"), WSV_INIT("upgrade-invisibility"), // Shield upgrades WSV_INIT("upgrade-orc-shield"), WSV_INIT("upgrade-human-shield") }; static_assert(arrayLength(upgradeNames) == MAX_UPGRADES_COUNT * 2, "upgradeNames array size does not match MAX_UPGRADES_COUNT"); const WarUnitData unitsData[] = { // units { WAR_UNIT_FOOTMAN, 279, WAR_PORTRAIT_FOOTMAN, 1, 1, WSV_INIT("FOOTMAN") }, { WAR_UNIT_GRUNT, 280, WAR_PORTRAIT_GRUNT, 1, 1, WSV_INIT("GRUNT") }, { WAR_UNIT_PEASANT, 281, WAR_PORTRAIT_PEASANT, 1, 1, WSV_INIT("PEASANT") }, { WAR_UNIT_PEON, 282, WAR_PORTRAIT_PEON, 1, 1, WSV_INIT("PEON") }, { WAR_UNIT_CATAPULT_HUMANS, 283, WAR_PORTRAIT_CATAPULT_HUMANS, 1, 1, WSV_INIT("CATAPULT") }, { WAR_UNIT_CATAPULT_ORCS, 284, WAR_PORTRAIT_CATAPULT_ORCS, 1, 1, WSV_INIT("CATAPULT") }, { WAR_UNIT_KNIGHT, 285, WAR_PORTRAIT_KNIGHT, 1, 1, WSV_INIT("KNIGHT") }, { WAR_UNIT_RAIDER, 286, WAR_PORTRAIT_RAIDER, 1, 1, WSV_INIT("RAIDER") }, { WAR_UNIT_ARCHER, 287, WAR_PORTRAIT_ARCHER, 1, 1, WSV_INIT("ARCHER") }, { WAR_UNIT_SPEARMAN, 288, WAR_PORTRAIT_SPEARMAN, 1, 1, WSV_INIT("SPEARMAN") }, { WAR_UNIT_CONJURER, 289, WAR_PORTRAIT_CONJURER, 1, 1, WSV_INIT("CONJURER") }, { WAR_UNIT_WARLOCK, 290, WAR_PORTRAIT_WARLOCK, 1, 1, WSV_INIT("WARLOCK") }, { WAR_UNIT_CLERIC, 291, WAR_PORTRAIT_CLERIC, 1, 1, WSV_INIT("CLERIC") }, { WAR_UNIT_NECROLYTE, 292, WAR_PORTRAIT_NECROLYTE, 1, 1, WSV_INIT("NECROLYTE") }, { WAR_UNIT_MEDIVH, 293, WAR_PORTRAIT_MEDIVH, 1, 1, WSV_INIT("MEDIVH") }, { WAR_UNIT_LOTHAR, 294, WAR_PORTRAIT_LOTHAR, 1, 1, WSV_INIT("LOTHAR") }, { WAR_UNIT_WOUNDED, 295, WAR_PORTRAIT_WOUNDED, 1, 1, WSV_INIT("WOUNDED") }, { WAR_UNIT_GRIZELDA, 296, WAR_PORTRAIT_GRIZELDA, 1, 1, WSV_INIT("GRIZELDA") }, { WAR_UNIT_GARONA, 296, WAR_PORTRAIT_GARONA, 1, 1, WSV_INIT("GARONA") }, { WAR_UNIT_OGRE, 297, WAR_PORTRAIT_OGRE, 1, 1, WSV_INIT("OGRE") }, { WAR_UNIT_SPIDER, 298, WAR_PORTRAIT_SPIDER, 1, 1, WSV_INIT("SPIDER") }, { WAR_UNIT_SLIME, 299, WAR_PORTRAIT_SLIME, 1, 1, WSV_INIT("SLIME") }, { WAR_UNIT_FIRE_ELEMENTAL, 300, WAR_PORTRAIT_FIRE_ELEMENTAL, 1, 1, WSV_INIT("FIRE ELEM") }, { WAR_UNIT_SCORPION, 301, WAR_PORTRAIT_SCORPION, 1, 1, WSV_INIT("SCORPION") }, { WAR_UNIT_BRIGAND, 302, WAR_PORTRAIT_BRIGAND, 1, 1, WSV_INIT("BRIGAND") }, { WAR_UNIT_THE_DEAD, 303, WAR_PORTRAIT_DEAD, 1, 1, WSV_INIT("THE DEAD") }, { WAR_UNIT_SKELETON, 304, WAR_PORTRAIT_SKELETON, 1, 1, WSV_INIT("SKELETON") }, { WAR_UNIT_DAEMON, 305, WAR_PORTRAIT_DAEMON, 1, 1, WSV_INIT("DAEMON") }, { WAR_UNIT_WATER_ELEMENTAL, 306, WAR_PORTRAIT_WATER_ELEMENTAL, 1, 1, WSV_INIT("WATER ELEM") }, // buildings { WAR_UNIT_FARM_HUMANS, 307, WAR_PORTRAIT_FARM_HUMANS, 2, 2, WSV_INIT("FARM") }, { WAR_UNIT_FARM_ORCS, 308, WAR_PORTRAIT_FARM_ORCS, 2, 2, WSV_INIT("FARM") }, { WAR_UNIT_BARRACKS_HUMANS, 309, WAR_PORTRAIT_BARRACKS_HUMANS, 3, 3, WSV_INIT("BARRACKS") }, { WAR_UNIT_BARRACKS_ORCS, 310, WAR_PORTRAIT_BARRACKS_ORCS, 3, 3, WSV_INIT("BARRACKS") }, { WAR_UNIT_CHURCH, 311, WAR_PORTRAIT_CHURCH, 3, 3, WSV_INIT("CHURCH") }, { WAR_UNIT_TEMPLE, 312, WAR_PORTRAIT_TEMPLE, 3, 3, WSV_INIT("TEMPLE") }, { WAR_UNIT_TOWER_HUMANS, 313, WAR_PORTRAIT_TOWER_HUMANS, 2, 2, WSV_INIT("TOWER") }, { WAR_UNIT_TOWER_ORCS, 314, WAR_PORTRAIT_TOWER_ORCS, 2, 2, WSV_INIT("TOWER") }, { WAR_UNIT_TOWNHALL_HUMANS, 315, WAR_PORTRAIT_TOWNHALL_HUMANS, 3, 3, WSV_INIT("TOWN HALL") }, { WAR_UNIT_TOWNHALL_ORCS, 316, WAR_PORTRAIT_TOWNHALL_ORCS, 3, 3, WSV_INIT("TOWN HALL") }, { WAR_UNIT_LUMBERMILL_HUMANS, 317, WAR_PORTRAIT_LUMBERMILL_HUMANS, 3, 3, WSV_INIT("MILL") }, { WAR_UNIT_LUMBERMILL_ORCS, 318, WAR_PORTRAIT_LUMBERMILL_ORCS, 3, 3, WSV_INIT("MILL") }, { WAR_UNIT_STABLE, 319, WAR_PORTRAIT_STABLE, 3, 3, WSV_INIT("STABLES") }, { WAR_UNIT_KENNEL, 320, WAR_PORTRAIT_KENNEL, 3, 3, WSV_INIT("KENNEL") }, { WAR_UNIT_BLACKSMITH_HUMANS, 321, WAR_PORTRAIT_BLACKSMITH_HUMANS, 2, 2, WSV_INIT("BLACKSMITH") }, { WAR_UNIT_BLACKSMITH_ORCS, 322, WAR_PORTRAIT_BLACKSMITH_ORCS, 2, 2, WSV_INIT("BLACKSMITH") }, { WAR_UNIT_STORMWIND, 323, WAR_PORTRAIT_STORMWIND, 4, 4, WSV_INIT("STORMWIND") }, { WAR_UNIT_BLACKROCK, 324, WAR_PORTRAIT_BLACKROCK, 4, 4, WSV_INIT("BLACKROCK") }, // neutral { WAR_UNIT_GOLDMINE, 325, WAR_PORTRAIT_GOLDMINE, 3, 3, WSV_INIT("GOLD MINE") }, // corpses { WAR_UNIT_HUMAN_CORPSE, 326, 0, 1, 1, WSV_INIT("CORPSE") }, { WAR_UNIT_ORC_CORPSE, 326, 0, 1, 1, WSV_INIT("CORPSE") } }; static_assert(arrayLength(unitsData) == 50, "unitsData array size does not match WAR_UNIT_COUNT"); const WarWorkerData workersData[] = { // units wood gold { WAR_UNIT_PEASANT, 327, 329 }, { WAR_UNIT_PEON, 328, 330 }, }; static_assert(arrayLength(workersData) == 2, "workersData array size does not match number of worker unit types"); const WarBuildingData buildingsData[] = { { WAR_UNIT_FARM_HUMANS, 331 }, { WAR_UNIT_FARM_ORCS, 332 }, { WAR_UNIT_BARRACKS_HUMANS, 333 }, { WAR_UNIT_BARRACKS_ORCS, 334 }, { WAR_UNIT_CHURCH, 335 }, { WAR_UNIT_TEMPLE, 336 }, { WAR_UNIT_TOWER_HUMANS, 337 }, { WAR_UNIT_TOWER_ORCS, 338 }, { WAR_UNIT_TOWNHALL_HUMANS, 339 }, { WAR_UNIT_TOWNHALL_ORCS, 340 }, { WAR_UNIT_LUMBERMILL_HUMANS, 341 }, { WAR_UNIT_LUMBERMILL_ORCS, 342 }, { WAR_UNIT_STABLE, 343 }, { WAR_UNIT_KENNEL, 344 }, { WAR_UNIT_BLACKSMITH_HUMANS, 345 }, { WAR_UNIT_BLACKSMITH_ORCS, 346 }, }; static_assert(arrayLength(buildingsData) == 16, "buildingsData array size does not match number of building unit types"); const WarRoadData roadsData[] = { { WAR_ROAD_PIECE_LEFT, 56, 57 }, { WAR_ROAD_PIECE_TOP, 57, 58 }, { WAR_ROAD_PIECE_RIGHT, 58, 59 }, { WAR_ROAD_PIECE_BOTTOM, 59, 60 }, { WAR_ROAD_PIECE_BOTTOM_LEFT, 60, 61 }, { WAR_ROAD_PIECE_VERTICAL, 61, 62 }, { WAR_ROAD_PIECE_BOTTOM_RIGHT, 62, 63 }, { WAR_ROAD_PIECE_T_LEFT, 63, 64 }, { WAR_ROAD_PIECE_T_BOTTOM, 64, 65 }, { WAR_ROAD_PIECE_T_RIGHT, 65, 66 }, { WAR_ROAD_PIECE_CROSS, 66, 67 }, { WAR_ROAD_PIECE_TOP_LEFT, 67, 68 }, { WAR_ROAD_PIECE_HORIZONTAL, 68, 69 }, { WAR_ROAD_PIECE_T_TOP, 69, 70 }, { WAR_ROAD_PIECE_TOP_RIGHT, 70, 71 }, }; static_assert(arrayLength(roadsData) == 15, "roadsData array size does not match WAR_ROAD_PIECE_COUNT"); const WarWallData wallsData[] = { { WAR_WALL_PIECE_LEFT, 18, 30, 37, 18, 26, 37 }, { WAR_WALL_PIECE_TOP, 21, 23, 34, 21, 23, 34 }, { WAR_WALL_PIECE_RIGHT, 18, 30, 37, 18, 26, 37 }, { WAR_WALL_PIECE_BOTTOM, 11, 40, 34, 11, 40, 34 }, { WAR_WALL_PIECE_BOTTOM_LEFT, 10, 22, 36, 10, 22, 36 }, { WAR_WALL_PIECE_VERTICAL, 21, 23, 34, 21, 23, 34 }, { WAR_WALL_PIECE_BOTTOM_RIGHT, 12, 24, 38, 12, 24, 38 }, { WAR_WALL_PIECE_T_LEFT, 13, 25, 36, 13, 25, 36 }, { WAR_WALL_PIECE_T_BOTTOM, 14, 26, 39, 14, 26, 39 }, { WAR_WALL_PIECE_T_RIGHT, 15, 27, 38, 15, 27, 38 }, { WAR_WALL_PIECE_CROSS, 16, 28, 39, 16, 28, 39 }, { WAR_WALL_PIECE_TOP_LEFT, 17, 29, 33, 17, 29, 33 }, { WAR_WALL_PIECE_HORIZONTAL, 18, 30, 37, 18, 30, 37 }, { WAR_WALL_PIECE_T_TOP, 19, 31, 37, 19, 31, 37 }, { WAR_WALL_PIECE_TOP_RIGHT, 20, 32, 35, 20, 32, 35 }, }; static_assert(arrayLength(wallsData) == 15, "wallsData array size does not match WAR_WALL_PIECE_COUNT"); const WarRuinData ruinsData[] = { { WAR_RUIN_PIECE_TOP_LEFT, 41, 42 }, { WAR_RUIN_PIECE_TOP, 42, 43 }, { WAR_RUIN_PIECE_TOP_RIGHT, 43, 44 }, { WAR_RUIN_PIECE_LEFT, 44, 45 }, { WAR_RUIN_PIECE_CENTER, 45, 46 }, { WAR_RUIN_PIECE_RIGHT, 46, 47 }, { WAR_RUIN_PIECE_BOTTOM_LEFT, 47, 48 }, { WAR_RUIN_PIECE_BOTTOM, 48, 49 }, { WAR_RUIN_PIECE_BOTTOM_RIGHT, 49, 50 }, { WAR_RUIN_PIECE_TOP_LEFT_INSIDE, 50, 51 }, { WAR_RUIN_PIECE_TOP_RIGHT_INSIDE, 51, 52 }, { WAR_RUIN_PIECE_BOTTOM_LEFT_INSIDE, 53, 54 }, { WAR_RUIN_PIECE_BOTTOM_RIGHT_INSIDE, 52, 53 }, { WAR_RUIN_PIECE_DIAG_1, 55, 56 }, { WAR_RUIN_PIECE_DIAG_2, 54, 55 }, }; static_assert(arrayLength(ruinsData) == 15, "ruinsData array size does not match WAR_RUIN_PIECE_COUNT"); const WarTreeData treesData[] = { { WAR_TREE_NONE, 0, 0 }, { WAR_TREE_TOP_LEFT, 73, 74 }, { WAR_TREE_TOP, 75, 76 }, { WAR_TREE_TOP_RIGHT, 76, 77 }, { WAR_TREE_LEFT, 72, 73 }, { WAR_TREE_CENTER, 94, 95 }, { WAR_TREE_RIGHT, 78, 79 }, { WAR_TREE_BOTTOM_LEFT, 71, 72 }, { WAR_TREE_BOTTOM, 93, 94 }, { WAR_TREE_BOTTOM_RIGHT, 79, 80 }, { WAR_TREE_TOP_LEFT_INSIDE, 80, 81 }, { WAR_TREE_TOP_RIGHT_INSIDE, 81, 82 }, { WAR_TREE_BOTTOM_LEFT_INSIDE, 77, 78 }, { WAR_TREE_BOTTOM_RIGHT_INSIDE, 74, 75 }, { WAR_TREE_TOP_END, 90, 91 }, { WAR_TREE_BOTTOM_END, 92, 93 }, { WAR_TREE_VERTICAL, 91, 92 }, { WAR_TREE_DIAG_1, 83, 84 }, { WAR_TREE_DIAG_2, 82, 83 }, { WAR_TREE_CHOPPED, 95, 96 }, }; static_assert(arrayLength(treesData) == 20, "treesData array size does not match WAR_TREE_TILE_TYPE_COUNT"); const WarUnitStats unitStats[] = { // unit type range sight armor hp mana min D. rnd D. build gold lumber decay speed in pixels x seconds { WAR_UNIT_FOOTMAN, 1, 2, 2, 60, -1, 1, 9, __bts(600), 400, 0, -1, { 16.736f, 16.736f, 16.736f } }, { WAR_UNIT_GRUNT, 1, 2, 2, 60, -1, 1, 9, __bts(600), 400, 0, -1, { 16.736f, 16.736f, 16.736f } }, { WAR_UNIT_PEASANT, 1, 2, 0, 40, -1, 0, 0, __bts(750), 400, 0, -1, { 19.584f, 19.584f, 19.584f } }, { WAR_UNIT_PEON, 1, 2, 0, 40, -1, 0, 0, __bts(750), 400, 0, -1, { 19.584f, 19.584f, 19.584f } }, { WAR_UNIT_CATAPULT_HUMANS, 8, 5, 0, 120, -1, 0, 255, __bts(1000), 900, 200, -1, { 8.992f, 8.992f, 8.992f } }, { WAR_UNIT_CATAPULT_ORCS, 8, 5, 0, 120, -1, 0, 255, __bts(1000), 900, 200, -1, { 8.992f, 8.992f, 8.992f } }, { WAR_UNIT_KNIGHT, 1, 4, 5, 90, -1, 1, 13, __bts(800), 850, 0, -1, { 19.584f, 22.064f, 26.064f } }, { WAR_UNIT_RAIDER, 1, 4, 5, 90, -1, 1, 13, __bts(800), 850, 0, -1, { 19.584f, 22.064f, 26.064f } }, { WAR_UNIT_ARCHER, 5, 5, 1, 60, -1, 4, 0, __bts(700), 450, 50, -1, { 19.584f, 19.584f, 19.584f } }, { WAR_UNIT_SPEARMAN, 4, 4, 1, 60, -1, 5, 0, __bts(700), 450, 50, -1, { 19.584f, 19.584f, 19.584f } }, { WAR_UNIT_CONJURER, 3, 4, 0, 40, 255, 6, 0, __bts(900), 900, 0, -1, { 13.984f, 13.984f, 13.984f } }, { WAR_UNIT_WARLOCK, 2, 3, 0, 40, 255, 6, 0, __bts(900), 900, 0, -1, { 13.984f, 13.984f, 13.984f } }, { WAR_UNIT_CLERIC, 1, 3, 0, 40, 255, 6, 0, __bts(800), 700, 0, -1, { 13.984f, 13.984f, 13.984f } }, { WAR_UNIT_NECROLYTE, 2, 3, 0, 40, 255, 6, 0, __bts(800), 700, 0, -1, { 13.984f, 13.984f, 13.984f } }, { WAR_UNIT_MEDIVH, 5, 5, 0, 110, -1, 10, 0, -1, -1, -1, -1, { 19.584f, 19.584f, 19.584f } }, { WAR_UNIT_LOTHAR, 1, 2, 5, 50, -1, 1, 15, -1, -1, -1, -1, { 19.584f, 19.584f, 19.584f } }, { WAR_UNIT_GRIZELDA, 1, 2, 0, 30, -1, -1, -1, -1, -1, -1, -1, { 13.984f, 13.984f, 13.984f } }, { WAR_UNIT_GARONA, 1, 2, 0, 30, -1, -1, -1, -1, -1, -1, -1, { 13.984f, 13.984f, 13.984f } }, { WAR_UNIT_OGRE, 1, 2, 3, 60, -1, 1, 12, -1, -1, -1, -1, { 17.936f, 17.936f, 17.936f } }, { WAR_UNIT_SPIDER, 1, 2, 0, 30, 255, 1, 3, -1, -1, -1, 45, { 26.064f, 26.064f, 26.064f } }, { WAR_UNIT_SLIME, 1, 2, 10, 150, -1, 1, 0, -1, -1, -1, -1, { 26.064f, 26.064f, 26.064f } }, { WAR_UNIT_FIRE_ELEMENTAL, 1, 2, 0, 200, -1, 0, 40, -1, -1, -1, -1, { 17.936f, 17.936f, 17.936f } }, { WAR_UNIT_SCORPION, 1, 2, 0, 30, 255, 3, 0, -1, -1, -1, 45, { 26.064f, 26.064f, 26.064f } }, { WAR_UNIT_BRIGAND, 1, 2, 1, 40, -1, 1, 9, -1, -1, -1, -1, { 16.736f, 16.736f, 16.736f } }, { WAR_UNIT_THE_DEAD, 1, 2, 2, 30, 255, 1, 9, -1, -1, -1, -1, { 13.984f, 13.984f, 13.984f } }, { WAR_UNIT_SKELETON, 1, 2, 1, 40, -1, 1, 4, -1, -1, -1, 45, { 13.984f, 13.984f, 13.984f } }, { WAR_UNIT_DAEMON, 1, 2, 0, 300, 255, 0, 65, -1, -1, -1, 45, { 17.936f, 17.936f, 17.936f } }, { WAR_UNIT_WATER_ELEMENTAL, 3, 4, 0, 250, 255, 40, 0, -1, -1, -1, 45, { 17.936f, 17.936f, 17.936f } }, }; static_assert(arrayLength(unitStats) == 28, "unitStats array size does not match WAR_UNIT_COUNT"); const WarBuildingStats buildingStats[] = { // building type armor sight hp build gold lumber { WAR_UNIT_FARM_HUMANS, 0, 2, 400, __bts(1000), 500, 300 }, { WAR_UNIT_FARM_ORCS, 0, 2, 400, __bts(1000), 500, 300 }, { WAR_UNIT_BARRACKS_HUMANS, 0, 3, 800, __bts(1500), 600, 500 }, { WAR_UNIT_BARRACKS_ORCS, 0, 3, 800, __bts(1500), 600, 500 }, { WAR_UNIT_CHURCH, 0, 3, 700, __bts(2000), 800, 500 }, { WAR_UNIT_TEMPLE, 0, 3, 700, __bts(2000), 800, 500 }, { WAR_UNIT_TOWER_HUMANS, 0, 2, 900, __bts(2000), 1400, 300 }, { WAR_UNIT_TOWER_ORCS, 0, 2, 900, __bts(2000), 1400, 300 }, { WAR_UNIT_TOWNHALL_HUMANS, 0, 3, 2500, __bts(1000), 400, 400 }, { WAR_UNIT_TOWNHALL_ORCS, 0, 3, 2500, __bts(1000), 400, 400 }, { WAR_UNIT_LUMBERMILL_HUMANS, 0, 3, 600, __bts(1500), 600, 500 }, { WAR_UNIT_LUMBERMILL_ORCS, 0, 3, 600, __bts(1500), 600, 500 }, { WAR_UNIT_STABLE, 0, 3, 500, __bts(1500), 1000, 400 }, { WAR_UNIT_KENNEL, 0, 3, 500, __bts(1500), 1000, 400 }, { WAR_UNIT_BLACKSMITH_HUMANS, 0, 2, 800, __bts(1500), 900, 400 }, { WAR_UNIT_BLACKSMITH_ORCS, 0, 2, 800, __bts(1500), 900, 400 }, { WAR_UNIT_STORMWIND, 0, 4, 5000, -1, -1, -1 }, { WAR_UNIT_BLACKROCK, 0, 4, 5000, -1, -1, -1 }, { WAR_UNIT_GOLDMINE, 0, 3, 25500, -1, -1, -1 }, }; static_assert(arrayLength(buildingStats) == 19, "buildingStats array size does not match WAR_UNIT_COUNT"); const WarUpgradeData upgradesData[] = { { WAR_UPGRADE_ARROWS, 2, { WAR_PORTRAIT_ARROW_2, WAR_PORTRAIT_ARROW_3 } }, { WAR_UPGRADE_SPEARS, 2, { WAR_PORTRAIT_SPEAR_2, WAR_PORTRAIT_SPEAR_3 } }, { WAR_UPGRADE_SWORDS, 2, { WAR_PORTRAIT_SWORD_2, WAR_PORTRAIT_SWORD_3 } }, { WAR_UPGRADE_AXES, 2, { WAR_PORTRAIT_AXE_2, WAR_PORTRAIT_AXE_3 } }, { WAR_UPGRADE_HORSES, 2, { WAR_PORTRAIT_HORSE_1, WAR_PORTRAIT_HORSE_2 } }, { WAR_UPGRADE_WOLVES, 2, { WAR_PORTRAIT_WOLVES_1, WAR_PORTRAIT_WOLVES_2 } }, { WAR_UPGRADE_SCORPIONS, 1, { WAR_PORTRAIT_SCORPION, WAR_PORTRAIT_SCORPION } }, { WAR_UPGRADE_SPIDERS, 1, { WAR_PORTRAIT_SPIDER, WAR_PORTRAIT_SPIDER } }, { WAR_UPGRADE_RAIN_OF_FIRE, 1, { WAR_PORTRAIT_RAIN_OF_FIRE, WAR_PORTRAIT_RAIN_OF_FIRE } }, { WAR_UPGRADE_POISON_CLOUD, 1, { WAR_PORTRAIT_POISON_CLOUD, WAR_PORTRAIT_POISON_CLOUD } }, { WAR_UPGRADE_WATER_ELEMENTAL, 1, { WAR_PORTRAIT_WATER_ELEMENTAL, WAR_PORTRAIT_WATER_ELEMENTAL } }, { WAR_UPGRADE_DAEMON, 1, { WAR_PORTRAIT_DAEMON, WAR_PORTRAIT_DAEMON } }, { WAR_UPGRADE_HEALING, 1, { WAR_PORTRAIT_HEALING, WAR_PORTRAIT_HEALING } }, { WAR_UPGRADE_RAISE_DEAD, 1, { WAR_PORTRAIT_RAISE_DEAD, WAR_PORTRAIT_RAISE_DEAD } }, { WAR_UPGRADE_FAR_SIGHT, 1, { WAR_PORTRAIT_FAR_SIGHT, WAR_PORTRAIT_FAR_SIGHT } }, { WAR_UPGRADE_DARK_VISION, 1, { WAR_PORTRAIT_DARK_VISION, WAR_PORTRAIT_DARK_VISION } }, { WAR_UPGRADE_INVISIBILITY, 1, { WAR_PORTRAIT_INVISIBILITY, WAR_PORTRAIT_INVISIBILITY } }, { WAR_UPGRADE_UNHOLY_ARMOR, 1, { WAR_PORTRAIT_UNHOLY_ARMOR, WAR_PORTRAIT_UNHOLY_ARMOR } }, { WAR_UPGRADE_SHIELD, 2, { WAR_PORTRAIT_SHIELD_2_HUMANS, WAR_PORTRAIT_SHIELD_3_HUMANS } }, }; static_assert(arrayLength(upgradesData) == 19, "upgradesData array size does not match WAR_UPGRADE_COUNT"); const WarUpgradeStats upgradeStats[] = { { WAR_UPGRADE_ARROWS, __bts(1600), { 750, 1500 } }, { WAR_UPGRADE_SPEARS, __bts(1600), { 750, 1500 } }, { WAR_UPGRADE_SWORDS, __bts(1750), { 750, 1500 } }, { WAR_UPGRADE_AXES, __bts(1750), { 750, 1500 } }, { WAR_UPGRADE_HORSES, __bts(1750), { 750, 1500 } }, { WAR_UPGRADE_WOLVES, __bts(1750), { 750, 1500 } }, { WAR_UPGRADE_SCORPIONS, __bts(1750), { 750, 0 } }, { WAR_UPGRADE_SPIDERS, __bts(1750), { 750, 0 } }, { WAR_UPGRADE_RAIN_OF_FIRE, __bts(1750), { 1500, 0 } }, { WAR_UPGRADE_POISON_CLOUD, __bts(1750), { 1500, 0 } }, { WAR_UPGRADE_WATER_ELEMENTAL, __bts(1750), { 3000, 0 } }, { WAR_UPGRADE_DAEMON, __bts(1750), { 3000, 0 } }, { WAR_UPGRADE_HEALING, __bts(1600), { 750, 0 } }, { WAR_UPGRADE_RAISE_DEAD, __bts(1600), { 750, 0 } }, { WAR_UPGRADE_FAR_SIGHT, __bts(1600), { 1500, 0 } }, { WAR_UPGRADE_DARK_VISION, __bts(1600), { 1500, 0 } }, { WAR_UPGRADE_INVISIBILITY, __bts(1600), { 3000, 0 } }, { WAR_UPGRADE_UNHOLY_ARMOR, __bts(1600), { 3000, 0 } }, { WAR_UPGRADE_SHIELD, __bts(1600), { 750, 1500 } }, }; static_assert(arrayLength(upgradeStats) == 19, "upgradeStats array size does not match WAR_UPGRADE_COUNT"); const WarSpellData spellData[] = { // summons { WAR_SUMMON_SPIDER, WAR_PORTRAIT_SPIDER }, { WAR_SUMMON_SCORPION, WAR_PORTRAIT_SCORPION }, { WAR_SUMMON_DAEMON, WAR_PORTRAIT_DAEMON }, { WAR_SUMMON_WATER_ELEMENTAL, WAR_PORTRAIT_WATER_ELEMENTAL }, // spells { WAR_SPELL_HEALING, WAR_PORTRAIT_HEALING }, { WAR_SPELL_FAR_SIGHT, WAR_PORTRAIT_FAR_SIGHT }, { WAR_SPELL_INVISIBILITY, WAR_PORTRAIT_INVISIBILITY }, { WAR_SPELL_RAIN_OF_FIRE, WAR_PORTRAIT_RAIN_OF_FIRE }, { WAR_SPELL_RAISE_DEAD, WAR_PORTRAIT_RAISE_DEAD }, { WAR_SPELL_DARK_VISION, WAR_PORTRAIT_DARK_VISION }, { WAR_SPELL_UNHOLY_ARMOR, WAR_PORTRAIT_UNHOLY_ARMOR }, { WAR_SPELL_POISON_CLOUD, WAR_PORTRAIT_POISON_CLOUD }, }; static_assert(arrayLength(spellData) == 12, "spellData array size does not match WAR_SPELL_COUNT"); const WarSpellStats spellStats[] = { // summons { WAR_SUMMON_SPIDER, 51, 0, 0 }, { WAR_SUMMON_SCORPION, 51, 0, 0 }, { WAR_SUMMON_DAEMON, 255, 0, 0 }, { WAR_SUMMON_WATER_ELEMENTAL, 250, 0, 0 }, // spells { WAR_SPELL_HEALING, 6, 0, 6 }, { WAR_SPELL_FAR_SIGHT, 70, 10, 0 }, { WAR_SPELL_INVISIBILITY, 200, 50, 6 }, { WAR_SPELL_RAIN_OF_FIRE, 25, 0, 12 }, { WAR_SPELL_RAISE_DEAD, 50, 0, 6 }, { WAR_SPELL_DARK_VISION, 50, 10, 0 }, { WAR_SPELL_UNHOLY_ARMOR, 100, 13, 6 }, { WAR_SPELL_POISON_CLOUD, 100, 10, 12 }, }; static_assert(arrayLength(spellStats) == 12, "spellStats array size does not match WAR_SPELL_COUNT"); const WarSpellMapping spellMappings[] = { // summon { WAR_SUMMON_SPIDER, WAR_UNIT_SPIDER }, { WAR_SUMMON_SCORPION, WAR_UNIT_SCORPION }, { WAR_SUMMON_DAEMON, WAR_UNIT_DAEMON }, { WAR_SUMMON_WATER_ELEMENTAL, WAR_UNIT_WATER_ELEMENTAL }, }; static_assert(arrayLength(spellMappings) == 4, "spellMappings array size does not match WAR_SUMMON_COUNT"); const WarUnitCommandBaseData commandsBaseData[] = { { WAR_COMMAND_NONE, NULL, WAR_KEY_NONE, -1, 1, WSV_INIT(""), WSV_INIT("") }, // unit commands { WAR_COMMAND_MOVE, move, WAR_KEY_M, 0, 1, WSV_INIT("MOVE"), WSV_INIT("") }, { WAR_COMMAND_STOP, wcmd_stop, WAR_KEY_S, 0, 1, WSV_INIT("STOP"), WSV_INIT("") }, { WAR_COMMAND_HARVEST, wcmd_harvest, WAR_KEY_H, 0, 1, WSV_INIT("HARVEST LUMBER/MINE GOLD"), WSV_INIT("") }, { WAR_COMMAND_DELIVER, deliver, WAR_KEY_T, 16, 1, WSV_INIT("RETURN GOODS TO TOWN HALL"), WSV_INIT("") }, { WAR_COMMAND_REPAIR, repair, WAR_KEY_R, 0, 1, WSV_INIT("REPAIR"), WSV_INIT("") }, { WAR_COMMAND_BUILD_BASIC, wcmd_buildBasic, WAR_KEY_B, 0, 1, WSV_INIT("BUILD BASIC STRUCTURE"), WSV_INIT("") }, { WAR_COMMAND_BUILD_ADVANCED, wcmd_buildAdvanced, WAR_KEY_A, 6, 1, WSV_INIT("BUILD ADVANCED STRUCTURE"), WSV_INIT("") }, { WAR_COMMAND_ATTACK, attack, WAR_KEY_A, 0, 1, WSV_INIT("ATTACK"), WSV_INIT("") }, // train commands { WAR_COMMAND_TRAIN_FOOTMAN, wcmd_trainFootman, WAR_KEY_F, 6, 1, WSV_INIT("TRAIN FOOTMAN"), WSV_INIT("TRAINING A FOOTMAN") }, { WAR_COMMAND_TRAIN_GRUNT, wcmd_trainGrunt, WAR_KEY_U, 8, 1, WSV_INIT("TRAIN GRUNT"), WSV_INIT("TRAINING A GRUNT") }, { WAR_COMMAND_TRAIN_PEASANT, wcmd_trainPeasant, WAR_KEY_P, 6, 1, WSV_INIT("TRAIN PEASANT"), WSV_INIT("TRAINING A PEASANT") }, { WAR_COMMAND_TRAIN_PEON, wcmd_trainPeon, WAR_KEY_P, 6, 1, WSV_INIT("TRAIN PEON"), WSV_INIT("TRAINING A PEON") }, { WAR_COMMAND_TRAIN_CATAPULT_HUMANS, wcmd_trainHumanCatapult, WAR_KEY_T, 8, 1, WSV_INIT("BUILD CATAPULT"), WSV_INIT("TRAINING A CATAPULT CREW") }, { WAR_COMMAND_TRAIN_CATAPULT_ORCS, wcmd_trainOrcCatapult, WAR_KEY_T, 8, 1, WSV_INIT("BUILD CATAPULT"), WSV_INIT("TRAINING A CATAPULT CREW") }, { WAR_COMMAND_TRAIN_KNIGHT, wcmd_trainKnight, WAR_KEY_K, 6, 1, WSV_INIT("TRAIN KNIGHT"), WSV_INIT("TRAINING A KNIGHT") }, { WAR_COMMAND_TRAIN_RAIDER, wcmd_trainRaider, WAR_KEY_R, 6, 1, WSV_INIT("TRAIN RAIDER"), WSV_INIT("TRAINING A RAIDER") }, { WAR_COMMAND_TRAIN_ARCHER, wcmd_trainArcher, WAR_KEY_A, 6, 1, WSV_INIT("TRAIN ARCHER"), WSV_INIT("TRAINING AN ARCHER") }, { WAR_COMMAND_TRAIN_SPEARMAN, wcmd_trainSpearman, WAR_KEY_S, 6, 1, WSV_INIT("TRAIN SPEARMAN"), WSV_INIT("TRAINING A SPEARMAN") }, { WAR_COMMAND_TRAIN_CONJURER, wcmd_trainConjurer, WAR_KEY_T, 0, 1, WSV_INIT("TRAIN CONJURER"), WSV_INIT("TRAINING A CONJURER") }, { WAR_COMMAND_TRAIN_WARLOCK, wcmd_trainWarlock, WAR_KEY_T, 0, 1, WSV_INIT("TRAIN WARLOCK"), WSV_INIT("TRAINING A WARLOCK") }, { WAR_COMMAND_TRAIN_CLERIC, wcmd_trainCleric, WAR_KEY_T, 0, 1, WSV_INIT("TRAIN CLERIC"), WSV_INIT("TRAINING A CLERIC") }, { WAR_COMMAND_TRAIN_NECROLYTE, wcmd_trainNecrolyte, WAR_KEY_T, 0, 1, WSV_INIT("TRAIN NECROLYTE"), WSV_INIT("TRAINING A NECROLYTE") }, // spell commands { WAR_COMMAND_SPELL_HEALING, wcmd_castHeal, WAR_KEY_H, 0, 1, WSV_INIT("HEALING"), WSV_INIT("") }, { WAR_COMMAND_SPELL_POISON_CLOUD, wcmd_castPoisonCloud, WAR_KEY_P, 9, 1, WSV_INIT("CLOUD OF POISON"), WSV_INIT("") }, { WAR_COMMAND_SPELL_FAR_SIGHT, wcmd_castFarSight, WAR_KEY_F, 0, 1, WSV_INIT("FAR SEEING"), WSV_INIT("") }, { WAR_COMMAND_SPELL_DARK_VISION, wcmd_castDarkVision, WAR_KEY_D, 0, 1, WSV_INIT("DARK VISION"), WSV_INIT("") }, { WAR_COMMAND_SPELL_INVISIBILITY, wcmd_castInvisibility, WAR_KEY_I, 0, 1, WSV_INIT("INVISIBILITY"), WSV_INIT("") }, { WAR_COMMAND_SPELL_UNHOLY_ARMOR, wcmd_castUnHolyArmor, WAR_KEY_U, 0, 1, WSV_INIT("UNHOLY ARMOR"), WSV_INIT("") }, { WAR_COMMAND_SPELL_RAIN_OF_FIRE, wcmd_castRainOfFire, WAR_KEY_R, 0, 1, WSV_INIT("RAIN OF FIRE"), WSV_INIT("") }, { WAR_COMMAND_SPELL_RAISE_DEAD, wcmd_castRaiseDead, WAR_KEY_R, 0, 1, WSV_INIT("RAISE DEAD"), WSV_INIT("") }, // summons { WAR_COMMAND_SUMMON_SCORPION, wcmd_summonScorpion, WAR_KEY_O, 9, 1, WSV_INIT("SUMMON SCORPIONS"), WSV_INIT("") }, { WAR_COMMAND_SUMMON_SPIDER, wcmd_summonSpider, WAR_KEY_R, 12, 1, WSV_INIT("SUMMON SPIDERS"), WSV_INIT("") }, { WAR_COMMAND_SUMMON_WATER_ELEMENTAL, wcmd_summonWaterElemental, WAR_KEY_W, 7, 1, WSV_INIT("SUMMON WATER ELEMENTAL"), WSV_INIT("") }, { WAR_COMMAND_SUMMON_DAEMON, wcmd_summonDaemon, WAR_KEY_D, 7, 1, WSV_INIT("SUMMON DAEMON"), WSV_INIT("") }, // build commands { WAR_COMMAND_BUILD_FARM_HUMANS, wcmd_buildFarmHumans, WAR_KEY_F, 6, 1, WSV_INIT("BUILD FARM"), WSV_INIT("") }, { WAR_COMMAND_BUILD_FARM_ORCS, wcmd_buildFarmOrcs, WAR_KEY_F, 6, 1, WSV_INIT("BUILD FARM"), WSV_INIT("") }, { WAR_COMMAND_BUILD_BARRACKS_HUMANS, wcmd_buildBarracksHumans, WAR_KEY_B, 6, 1, WSV_INIT("BUILD BARRACKS"), WSV_INIT("") }, { WAR_COMMAND_BUILD_BARRACKS_ORCS, wcmd_buildBarracksOrcs, WAR_KEY_B, 6, 1, WSV_INIT("BUILD BARRACKS"), WSV_INIT("") }, { WAR_COMMAND_BUILD_CHURCH, wcmd_buildChurch, WAR_KEY_U, 8, 1, WSV_INIT("BUILD CHURCH"), WSV_INIT("") }, { WAR_COMMAND_BUILD_TEMPLE, wcmd_buildTemple, WAR_KEY_E, 7, 1, WSV_INIT("BUILD TEMPLE"), WSV_INIT("") }, { WAR_COMMAND_BUILD_TOWER_HUMANS, wcmd_buildTowerHumans, WAR_KEY_T, 6, 1, WSV_INIT("BUILD TOWER"), WSV_INIT("") }, { WAR_COMMAND_BUILD_TOWER_ORCS, wcmd_buildTowerOrcs, WAR_KEY_T, 6, 1, WSV_INIT("BUILD TOWER"), WSV_INIT("") }, { WAR_COMMAND_BUILD_TOWNHALL_HUMANS, wcmd_buildTownHallHumans, WAR_KEY_H, 11, 1, WSV_INIT("BUILD TOWN HALL"), WSV_INIT("") }, { WAR_COMMAND_BUILD_TOWNHALL_ORCS, wcmd_buildTownHallOrcs, WAR_KEY_H, 11, 1, WSV_INIT("BUILD TOWN HALL"), WSV_INIT("") }, { WAR_COMMAND_BUILD_LUMBERMILL_HUMANS, wcmd_buildLumbermillHumans, WAR_KEY_L, 6, 1, WSV_INIT("BUILD LUMBER MILL"), WSV_INIT("") }, { WAR_COMMAND_BUILD_LUMBERMILL_ORCS, wcmd_buildLumbermillOrcs, WAR_KEY_L, 6, 1, WSV_INIT("BUILD LUMBER MILL"), WSV_INIT("") }, { WAR_COMMAND_BUILD_STABLE, wcmd_buildStable, WAR_KEY_S, 6, 1, WSV_INIT("BUILD STABLES"), WSV_INIT("") }, { WAR_COMMAND_BUILD_KENNEL, wcmd_buildKennel, WAR_KEY_K, 6, 1, WSV_INIT("BUILD KENNEL"), WSV_INIT("") }, { WAR_COMMAND_BUILD_BLACKSMITH_HUMANS, wcmd_buildBlacksmithHumans, WAR_KEY_B, 6, 1, WSV_INIT("BUILD BLACKSMITH"), WSV_INIT("") }, { WAR_COMMAND_BUILD_BLACKSMITH_ORCS, wcmd_buildBlacksmithOrcs, WAR_KEY_B, 6, 1, WSV_INIT("BUILD BLACKSMITH"), WSV_INIT("") }, { WAR_COMMAND_BUILD_ROAD, wcmd_buildRoad, WAR_KEY_R, 6, 1, WSV_INIT("BUILD ROAD"), WSV_INIT("") }, { WAR_COMMAND_BUILD_WALL, wcmd_buildWall, WAR_KEY_W, 6, 1, WSV_INIT("BUILD WALL"), WSV_INIT("") }, // upgrades { WAR_COMMAND_UPGRADE_SWORDS, wcmd_upgradeSwords, WAR_KEY_W, 9, 1, WSV_INIT("UPGRADE SWORD STRENGTH"), WSV_INIT("RESEARCHING WEAPONRY") }, { WAR_COMMAND_UPGRADE_AXES, wcmd_upgradeAxes, WAR_KEY_A, 8, 1, WSV_INIT("UPGRADE AXE STRENGTH"), WSV_INIT("RESEARCHING WEAPONRY") }, { WAR_COMMAND_UPGRADE_SHIELD_HUMANS, wcmd_upgradeHumanShields, WAR_KEY_H, 9, 1, WSV_INIT("UPGRADE SHIELD STRENGTH"), WSV_INIT("RESEARCHING ARMOR") }, { WAR_COMMAND_UPGRADE_SHIELD_ORCS, wcmd_upgradeOrcsShields, WAR_KEY_H, 9, 1, WSV_INIT("UPGRADE SHIELD STRENGTH"), WSV_INIT("RESEARCHING ARMOR") }, { WAR_COMMAND_UPGRADE_ARROWS, wcmd_upgradeArrows, WAR_KEY_U, 0, 1, WSV_INIT("UPGRADE ARROW STRENGTH"), WSV_INIT("RESEARCHING WEAPONRY") }, { WAR_COMMAND_UPGRADE_SPEARS, wcmd_upgradeSpears, WAR_KEY_U, 0, 1, WSV_INIT("UPGRADE SPEAR STRENGTH"), WSV_INIT("RESEARCHING WEAPONRY") }, { WAR_COMMAND_UPGRADE_HORSES, wcmd_upgradeHorses, WAR_KEY_B, 0, 1, WSV_INIT("BREED FASTER HORSES"), WSV_INIT("BREADING BETTER STOCK") }, { WAR_COMMAND_UPGRADE_WOLVES, wcmd_upgradeWolves, WAR_KEY_B, 0, 1, WSV_INIT("BREED FASTER WOLVES"), WSV_INIT("BREADING BETTER STOCK") }, { WAR_COMMAND_UPGRADE_SCORPION, wcmd_upgradeScorpions, WAR_KEY_M, 9, 1, WSV_INIT("RESEARCH MINOR SUMMONING"), WSV_INIT("RESEARCHING NEW SPELL") }, { WAR_COMMAND_UPGRADE_SPIDER, wcmd_upgradeSpiders, WAR_KEY_M, 9, 1, WSV_INIT("RESEARCH MINOR SUMMONING"), WSV_INIT("RESEARCHING NEW SPELL") }, { WAR_COMMAND_UPGRADE_RAIN_OF_FIRE, wcmd_upgradeRainOfFire, WAR_KEY_R, 9, 1, WSV_INIT("RESEARCH RAIN OF FIRE"), WSV_INIT("RESEARCHING NEW SPELL") }, { WAR_COMMAND_UPGRADE_POISON_CLOUD, wcmd_upgradePoisonCloud, WAR_KEY_P, 18, 1, WSV_INIT("RESEARCH CLOUD OF POISON"), WSV_INIT("RESEARCHING NEW SPELL") }, { WAR_COMMAND_UPGRADE_WATER_ELEMENTAL, wcmd_upgradeWaterElemental, WAR_KEY_A, 10, 1, WSV_INIT("RESEARCH MAJOR SUMMONING"), WSV_INIT("RESEARCHING NEW SPELL") }, { WAR_COMMAND_UPGRADE_DAEMON, wcmd_upgradeDaemon, WAR_KEY_A, 10, 1, WSV_INIT("RESEARCH MAJOR SUMMONING"), WSV_INIT("RESEARCHING NEW SPELL") }, { WAR_COMMAND_UPGRADE_HEALING, wcmd_upgradeHealing, WAR_KEY_H, 9, 1, WSV_INIT("RESEARCH HEALING"), WSV_INIT("RESEARCHING NEW SPELL") }, { WAR_COMMAND_UPGRADE_RAISE_DEAD, wcmd_upgradeRaiseDead, WAR_KEY_R, 9, 1, WSV_INIT("RESEARCH RAISING DEAD"), WSV_INIT("RESEARCHING NEW SPELL") }, { WAR_COMMAND_UPGRADE_FAR_SIGHT, wcmd_upgradeFarSight, WAR_KEY_F, 9, 1, WSV_INIT("RESEARCH FAR SEEING"), WSV_INIT("RESEARCHING NEW SPELL") }, { WAR_COMMAND_UPGRADE_DARK_VISION, wcmd_upgradeDarkVision, WAR_KEY_D, 9, 1, WSV_INIT("RESEARCH DARK VISION"), WSV_INIT("RESEARCHING NEW SPELL") }, { WAR_COMMAND_UPGRADE_INVISIBILITY, wcmd_upgradeInvisibility, WAR_KEY_I, 9, 1, WSV_INIT("RESEARCH INVISIBILITY"), WSV_INIT("RESEARCHING NEW SPELL") }, { WAR_COMMAND_UPGRADE_UNHOLY_ARMOR, wcmd_upgradeUnholyArmor, WAR_KEY_U, 9, 1, WSV_INIT("RESEARCH UNHOLY ARMOR"), WSV_INIT("RESEARCHING NEW SPELL") }, // wcmd_cancel { WAR_COMMAND_CANCEL, wcmd_cancel, WAR_KEY_ESC, 0, 3, WSV_INIT("ESC - CANCEL"), WSV_INIT("") } }; static_assert(arrayLength(commandsBaseData) == 74, "commandsBaseData array size does not match WAR_COMMAND_COUNT"); const WarUnitCommandMapping commandMappings[] = { // train commands { WAR_COMMAND_TRAIN_FOOTMAN, WAR_UNIT_FOOTMAN }, { WAR_COMMAND_TRAIN_GRUNT, WAR_UNIT_GRUNT }, { WAR_COMMAND_TRAIN_PEASANT, WAR_UNIT_PEASANT }, { WAR_COMMAND_TRAIN_PEON, WAR_UNIT_PEON }, { WAR_COMMAND_TRAIN_CATAPULT_HUMANS, WAR_UNIT_CATAPULT_HUMANS }, { WAR_COMMAND_TRAIN_CATAPULT_ORCS, WAR_UNIT_CATAPULT_ORCS }, { WAR_COMMAND_TRAIN_KNIGHT, WAR_UNIT_KNIGHT }, { WAR_COMMAND_TRAIN_RAIDER, WAR_UNIT_RAIDER }, { WAR_COMMAND_TRAIN_ARCHER, WAR_UNIT_ARCHER }, { WAR_COMMAND_TRAIN_SPEARMAN, WAR_UNIT_SPEARMAN }, { WAR_COMMAND_TRAIN_CONJURER, WAR_UNIT_CONJURER }, { WAR_COMMAND_TRAIN_WARLOCK, WAR_UNIT_WARLOCK }, { WAR_COMMAND_TRAIN_CLERIC, WAR_UNIT_CLERIC }, { WAR_COMMAND_TRAIN_NECROLYTE, WAR_UNIT_NECROLYTE }, // build commands { WAR_COMMAND_BUILD_FARM_HUMANS, WAR_UNIT_FARM_HUMANS }, { WAR_COMMAND_BUILD_FARM_ORCS, WAR_UNIT_FARM_ORCS }, { WAR_COMMAND_BUILD_BARRACKS_HUMANS, WAR_UNIT_BARRACKS_HUMANS }, { WAR_COMMAND_BUILD_BARRACKS_ORCS, WAR_UNIT_BARRACKS_ORCS }, { WAR_COMMAND_BUILD_CHURCH, WAR_UNIT_CHURCH }, { WAR_COMMAND_BUILD_TEMPLE, WAR_UNIT_TEMPLE }, { WAR_COMMAND_BUILD_TOWER_HUMANS, WAR_UNIT_TOWER_HUMANS }, { WAR_COMMAND_BUILD_TOWER_ORCS, WAR_UNIT_TOWER_ORCS }, { WAR_COMMAND_BUILD_TOWNHALL_HUMANS, WAR_UNIT_TOWNHALL_HUMANS }, { WAR_COMMAND_BUILD_TOWNHALL_ORCS, WAR_UNIT_TOWNHALL_ORCS }, { WAR_COMMAND_BUILD_LUMBERMILL_HUMANS, WAR_UNIT_LUMBERMILL_HUMANS }, { WAR_COMMAND_BUILD_LUMBERMILL_ORCS, WAR_UNIT_LUMBERMILL_ORCS }, { WAR_COMMAND_BUILD_STABLE, WAR_UNIT_STABLE }, { WAR_COMMAND_BUILD_KENNEL, WAR_UNIT_KENNEL }, { WAR_COMMAND_BUILD_BLACKSMITH_HUMANS, WAR_UNIT_BLACKSMITH_HUMANS }, { WAR_COMMAND_BUILD_BLACKSMITH_ORCS, WAR_UNIT_BLACKSMITH_ORCS }, // upgrades { WAR_COMMAND_UPGRADE_SWORDS, WAR_UPGRADE_SWORDS }, { WAR_COMMAND_UPGRADE_AXES, WAR_UPGRADE_AXES }, { WAR_COMMAND_UPGRADE_SHIELD_HUMANS, WAR_UPGRADE_SHIELD }, { WAR_COMMAND_UPGRADE_SHIELD_ORCS, WAR_UPGRADE_SHIELD }, { WAR_COMMAND_UPGRADE_ARROWS, WAR_UPGRADE_ARROWS }, { WAR_COMMAND_UPGRADE_SPEARS, WAR_UPGRADE_SPEARS }, { WAR_COMMAND_UPGRADE_HORSES, WAR_UPGRADE_HORSES }, { WAR_COMMAND_UPGRADE_WOLVES, WAR_UPGRADE_WOLVES }, { WAR_COMMAND_UPGRADE_SCORPION, WAR_UPGRADE_SCORPIONS }, { WAR_COMMAND_UPGRADE_SPIDER, WAR_UPGRADE_SPIDERS }, { WAR_COMMAND_UPGRADE_RAIN_OF_FIRE, WAR_UPGRADE_RAIN_OF_FIRE }, { WAR_COMMAND_UPGRADE_POISON_CLOUD, WAR_UPGRADE_POISON_CLOUD }, { WAR_COMMAND_UPGRADE_WATER_ELEMENTAL, WAR_UPGRADE_WATER_ELEMENTAL }, { WAR_COMMAND_UPGRADE_DAEMON, WAR_UPGRADE_DAEMON }, { WAR_COMMAND_UPGRADE_HEALING, WAR_UPGRADE_HEALING }, { WAR_COMMAND_UPGRADE_RAISE_DEAD, WAR_UPGRADE_RAISE_DEAD }, { WAR_COMMAND_UPGRADE_FAR_SIGHT, WAR_UPGRADE_FAR_SIGHT }, { WAR_COMMAND_UPGRADE_DARK_VISION, WAR_UPGRADE_DARK_VISION }, { WAR_COMMAND_UPGRADE_INVISIBILITY, WAR_UPGRADE_INVISIBILITY }, { WAR_COMMAND_UPGRADE_UNHOLY_ARMOR, WAR_UPGRADE_UNHOLY_ARMOR }, // summon commands { WAR_COMMAND_SUMMON_SPIDER, WAR_SUMMON_SPIDER }, { WAR_COMMAND_SUMMON_SCORPION, WAR_SUMMON_SCORPION }, { WAR_COMMAND_SUMMON_DAEMON, WAR_SUMMON_DAEMON }, { WAR_COMMAND_SUMMON_WATER_ELEMENTAL, WAR_SUMMON_WATER_ELEMENTAL }, // spells { WAR_COMMAND_SPELL_HEALING, WAR_SPELL_HEALING }, { WAR_COMMAND_SPELL_FAR_SIGHT, WAR_SPELL_FAR_SIGHT }, { WAR_COMMAND_SPELL_INVISIBILITY, WAR_SPELL_INVISIBILITY }, { WAR_COMMAND_SPELL_RAIN_OF_FIRE, WAR_SPELL_RAIN_OF_FIRE }, { WAR_COMMAND_SPELL_RAISE_DEAD, WAR_SPELL_RAISE_DEAD }, { WAR_COMMAND_SPELL_DARK_VISION, WAR_SPELL_DARK_VISION }, { WAR_COMMAND_SPELL_UNHOLY_ARMOR, WAR_SPELL_UNHOLY_ARMOR }, { WAR_COMMAND_SPELL_POISON_CLOUD, WAR_SPELL_POISON_CLOUD }, }; static_assert(arrayLength(commandMappings) == 62, "commandMappings array size does not match expected number of commands with mappings"); const WarRoadPieceType roadTileTypeMap[16] = { // 0-15 0, 3, 0, 4, 1, 5, 11, 7, 2, 6, 12, 8, 14, 9, 13, 10, }; static_assert(arrayLength(roadTileTypeMap) == 16, "roadTileTypeMap array size does not match expected size of 16"); const WarWallPieceType wallTileTypeMap[16] = { // 0-15 0, 3, 0, 4, 1, 5, 11, 7, 2, 6, 12, 8, 14, 9, 13, 10, }; static_assert(arrayLength(wallTileTypeMap) == 16, "wallTileTypeMap array size does not match expected size of 16"); const WarRuinPieceType ruinTileTypeMap[256] = { // 0-15 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 7, // 16-31 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 7, // 32-47 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 0, // 48-63 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 4, 4, // 64-79 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 7, // 80-95 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 7, // 96-111 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 7, // 112-127 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 4, 4, // 128-143 0, 0, 0, 9, 0, 0, 0, 9, 0, 0, 0, 9, 0, 0, 7, 8, // 144-159 0, 0, 0, 9, 0, 0, 0, 9, 0, 0, 0, 9, 0, 0, 7, 8, // 160-175 0, 0, 0, 9, 0, 0, 0, 9, 0, 0, 0, 9, 0, 0, 7, 8, // 176-191 0, 0, 0, 9, 0, 0, 0, 9, 1, 1, 1, 14, 1, 1, 4, 11, // 192-207 0, 0, 0, 9, 0, 0, 0, 9, 0, 0, 0, 9, 0, 0, 7, 8, // 208-223 0, 0, 0, 9, 0, 0, 0, 9, 0, 0, 0, 9, 0, 0, 7, 8, // 224-239 3, 3, 3, 6, 3, 3, 3, 6, 3, 3, 3, 6, 3, 3, 15, 10, // 240-255 3, 3, 3, 6, 3, 3, 3, 6, 2, 2, 2, 12, 2, 2, 13, 5, }; static_assert(arrayLength(ruinTileTypeMap) == 256, "ruinTileTypeMap array size does not match expected size of 256"); const WarTreeTileType treeTileTypeMap[256] = { // 0-15 0, 0, 15, 15, 0, 0, 15, 15, 0, 0, 0, 0, 0, 0, 7, 7, // 16-31 0, 0, 15, 15, 0, 0, 15, 15, 0, 0, 15, 15, 0, 0, 7, 7, // 32-47 14, 14, 16, 16, 14, 14, 16, 16, 0, 0, 0, 0, 14, 14, 4, 4, // 48-63 14, 14, 16, 16, 14, 14, 16, 16, 1, 1, 4, 4, 1, 1, 4, 4, // 64-79 0, 0, 15, 15, 0, 0, 15, 15, 0, 0, 0, 0, 0, 0, 7, 7, // 80-95 0, 0, 15, 15, 0, 0, 15, 15, 0, 0, 7, 15, 0, 0, 7, 7, // 96-111 14, 14, 16, 16, 14, 14, 16, 16, 1, 0, 4, 0, 14, 1, 4, 4, // 112-127 14, 14, 16, 16, 14, 14, 16, 16, 1, 1, 4, 4, 1, 1, 4, 4, // 128-143 0, 0, 0, 9, 0, 0, 0, 9, 0, 0, 0, 8, 0, 0, 8, 8, // 144-159 0, 0, 0, 9, 0, 0, 0, 9, 0, 0, 8, 9, 0, 0, 8, 8, // 160-175 0, 14, 0, 6, 0, 3, 6, 6, 2, 0, 0, 0, 0, 14, 0, 5, // 176-191 0, 14, 0, 6, 0, 14, 0, 6, 0, 1, 0, 18, 0, 14, 5, 11, // 192-207 0, 0, 15, 9, 0, 0, 15, 9, 0, 0, 0, 0, 0, 0, 7, 8, // 208-223 0, 0, 9, 9, 0, 0, 15, 9, 0, 0, 15, 9, 0, 0, 7, 8, // 224-239 3, 3, 6, 6, 3, 3, 6, 6, 2, 2, 0, 5, 3, 2, 17, 10, // 240-255 3, 3, 6, 6, 3, 3, 6, 6, 2, 2, 5, 12, 2, 2, 13, 5, }; static_assert(arrayLength(treeTileTypeMap) == 256, "treeTileTypeMap array size does not match expected size of 256"); const WarFogPieceType fogTileTypeMap[256] = { // 0-15 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 7, // 16-31 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 7, // 32-47 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 0, // 48-63 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 4, 4, // 64-79 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 7, // 80-95 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 7, // 96-111 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 7, // 112-127 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 4, 4, // 128-143 0, 0, 0, 9, 0, 0, 0, 9, 0, 0, 0, 9, 0, 0, 7, 8, // 144-159 0, 0, 0, 9, 0, 0, 0, 9, 0, 0, 0, 9, 0, 0, 7, 8, // 160-175 0, 0, 0, 9, 0, 0, 0, 9, 0, 0, 0, 9, 0, 0, 7, 8, // 176-191 0, 0, 0, 9, 0, 0, 0, 9, 1, 1, 1, 0, 1, 1, 4, 0, // 192-207 0, 0, 0, 9, 0, 0, 0, 9, 0, 0, 0, 9, 0, 0, 7, 8, // 208-223 0, 0, 0, 9, 0, 0, 0, 9, 0, 0, 0, 9, 0, 0, 7, 8, // 224-239 3, 3, 3, 6, 3, 3, 3, 6, 3, 3, 3, 6, 3, 3, 0, 0, // 240-255 3, 3, 3, 6, 3, 3, 3, 6, 2, 2, 0, 0, 2, 2, 0, 5, }; static_assert(arrayLength(fogTileTypeMap) == 256, "fogTileTypeMap array size does not match expected size of 256"); u32 wu_hashUnitType(const WarUnitType type) { return type; } bool wu_equalsUnitType(const WarUnitType t1, const WarUnitType t2) { return t1 == t2; } #define FIND_BY_TYPE(array, type) \ s32 index = 0; \ s32 length = arrayLength(array); \ while (index < length && array[index].type != type) \ index++; \ assert(index < length); \ return &array[index]; const WarUnitData* wu_getUnitData(WarUnitType type) { FIND_BY_TYPE(unitsData, type); } const WarWorkerData* wu_getWorkerData(WarUnitType type) { FIND_BY_TYPE(workersData, type); } const WarBuildingData* wu_getBuildingData(WarUnitType type) { FIND_BY_TYPE(buildingsData, type); } const WarRoadData* wu_getRoadData(WarRoadPieceType type) { FIND_BY_TYPE(roadsData, type); } const WarWallData* wu_getWallData(WarWallPieceType type) { FIND_BY_TYPE(wallsData, type); } const WarRuinData* wu_getRuinData(WarRuinPieceType type) { FIND_BY_TYPE(ruinsData, type); } const WarTreeData* wu_getTreeData(WarTreeTileType type) { FIND_BY_TYPE(treesData, type); } const WarUpgradeData* wu_getUpgradeData(WarUpgradeType type) { FIND_BY_TYPE(upgradesData, type); } const WarSpellData* wu_getSpellData(WarSpellType type) { FIND_BY_TYPE(spellData, type); } const WarUnitStats* wu_getUnitStats(WarUnitType type) { FIND_BY_TYPE(unitStats, type); } const WarBuildingStats* wu_getBuildingStats(WarUnitType type) { FIND_BY_TYPE(buildingStats, type); } const WarUpgradeStats* wu_getUpgradeStats(WarUpgradeType type) { FIND_BY_TYPE(upgradeStats, type); } const WarSpellStats* wu_getSpellStats(WarSpellType type) { FIND_BY_TYPE(spellStats, type); } const WarSpellMapping* wu_getSpellMapping(WarSpellType type) { FIND_BY_TYPE(spellMappings, type); } const WarUnitCommandBaseData* wu_getCommandBaseData(WarUnitCommandType type) { FIND_BY_TYPE(commandsBaseData, type); } const WarUnitCommandMapping* wu_getCommandMapping(WarUnitCommandType type) { FIND_BY_TYPE(commandMappings, type); } const WarUnitCommandMapping* wu_getCommandMappingFromUnitType(WarUnitType unitType) { s32 index = 0; s32 length = index + 30; while (index < length && commandMappings[index].mappedType != unitType) index++; assert(index < length); return &commandMappings[index]; } const WarUnitCommandMapping* wu_getCommandMappingFromUpgradeType(WarUpgradeType upgradeType) { s32 index = 30; s32 length = index + 20; while (index < length && commandMappings[index].mappedType != upgradeType) index++; assert(index < length); return &commandMappings[index]; } const WarUnitCommandMapping* wu_getCommandMappingFromSpellType(WarSpellType spellType) { s32 index = 50; s32 length = arrayLength(commandMappings); while (index < length && commandMappings[index].mappedType != spellType) index++; assert(index < length); return &commandMappings[index]; } bool wu_isUnit(const WarEntity* entity) { return entity->type == WAR_ENTITY_TYPE_UNIT; } bool wu_isUnitOfType(WarContext* ctx, const WarEntity* entity, WarUnitType unitType) { if (!wu_isUnit(entity)) return false; WarUnitComponent* unit = we_getUnitComponent(ctx, entity); return unit && unit->type == unitType; } bool wu_isRoad(const WarEntity* entity) { return entity->type == WAR_ENTITY_TYPE_ROAD; } bool wu_isWall(const WarEntity* entity) { return entity->type == WAR_ENTITY_TYPE_WALL; } bool wu_isRuin(const WarEntity* entity) { return entity->type == WAR_ENTITY_TYPE_RUIN; } bool wu_isDudeUnitType(WarUnitType type) { switch (type) { case WAR_UNIT_FOOTMAN: case WAR_UNIT_GRUNT: case WAR_UNIT_PEASANT: case WAR_UNIT_PEON: case WAR_UNIT_CATAPULT_HUMANS: case WAR_UNIT_CATAPULT_ORCS: case WAR_UNIT_KNIGHT: case WAR_UNIT_RAIDER: case WAR_UNIT_ARCHER: case WAR_UNIT_SPEARMAN: case WAR_UNIT_CONJURER: case WAR_UNIT_WARLOCK: case WAR_UNIT_CLERIC: case WAR_UNIT_NECROLYTE: case WAR_UNIT_MEDIVH: case WAR_UNIT_LOTHAR: case WAR_UNIT_WOUNDED: case WAR_UNIT_GRIZELDA: case WAR_UNIT_GARONA: case WAR_UNIT_OGRE: case WAR_UNIT_SPIDER: case WAR_UNIT_SLIME: case WAR_UNIT_FIRE_ELEMENTAL: case WAR_UNIT_SCORPION: case WAR_UNIT_BRIGAND: case WAR_UNIT_THE_DEAD: case WAR_UNIT_SKELETON: case WAR_UNIT_DAEMON: case WAR_UNIT_WATER_ELEMENTAL: return true; default: return false; } } bool wu_isBuildingUnitType(WarUnitType type) { switch (type) { case WAR_UNIT_FARM_HUMANS: case WAR_UNIT_FARM_ORCS: case WAR_UNIT_BARRACKS_HUMANS: case WAR_UNIT_BARRACKS_ORCS: case WAR_UNIT_CHURCH: case WAR_UNIT_TEMPLE: case WAR_UNIT_TOWER_HUMANS: case WAR_UNIT_TOWER_ORCS: case WAR_UNIT_TOWNHALL_HUMANS: case WAR_UNIT_TOWNHALL_ORCS: case WAR_UNIT_LUMBERMILL_HUMANS: case WAR_UNIT_LUMBERMILL_ORCS: case WAR_UNIT_STABLE: case WAR_UNIT_KENNEL: case WAR_UNIT_BLACKSMITH_HUMANS: case WAR_UNIT_BLACKSMITH_ORCS: case WAR_UNIT_STORMWIND: case WAR_UNIT_BLACKROCK: case WAR_UNIT_GOLDMINE: return true; default: return false; } } bool wu_isWorkerUnitType(WarUnitType type) { switch (type) { case WAR_UNIT_PEASANT: case WAR_UNIT_PEON: return true; default: return false; } } bool wu_isWarriorUnitType(WarUnitType type) { switch (type) { case WAR_UNIT_FOOTMAN: case WAR_UNIT_GRUNT: case WAR_UNIT_CATAPULT_HUMANS: case WAR_UNIT_CATAPULT_ORCS: case WAR_UNIT_KNIGHT: case WAR_UNIT_RAIDER: case WAR_UNIT_ARCHER: case WAR_UNIT_SPEARMAN: case WAR_UNIT_CONJURER: case WAR_UNIT_WARLOCK: case WAR_UNIT_CLERIC: case WAR_UNIT_NECROLYTE: case WAR_UNIT_MEDIVH: case WAR_UNIT_LOTHAR: case WAR_UNIT_WOUNDED: case WAR_UNIT_OGRE: case WAR_UNIT_SPIDER: case WAR_UNIT_SLIME: case WAR_UNIT_FIRE_ELEMENTAL: case WAR_UNIT_SCORPION: case WAR_UNIT_BRIGAND: case WAR_UNIT_THE_DEAD: case WAR_UNIT_SKELETON: case WAR_UNIT_DAEMON: case WAR_UNIT_WATER_ELEMENTAL: return true; default: return false; } } bool wu_isRangeUnitType(WarUnitType type) { switch (type) { case WAR_UNIT_CATAPULT_HUMANS: case WAR_UNIT_CATAPULT_ORCS: case WAR_UNIT_ARCHER: case WAR_UNIT_SPEARMAN: case WAR_UNIT_CONJURER: case WAR_UNIT_WARLOCK: case WAR_UNIT_CLERIC: case WAR_UNIT_NECROLYTE: case WAR_UNIT_MEDIVH: case WAR_UNIT_WATER_ELEMENTAL: return true; default: return false; } } bool wu_isMeleeUnitType(WarUnitType type) { switch (type) { case WAR_UNIT_FOOTMAN: case WAR_UNIT_GRUNT: case WAR_UNIT_KNIGHT: case WAR_UNIT_RAIDER: case WAR_UNIT_CLERIC: case WAR_UNIT_LOTHAR: case WAR_UNIT_OGRE: case WAR_UNIT_SPIDER: case WAR_UNIT_SLIME: case WAR_UNIT_FIRE_ELEMENTAL: case WAR_UNIT_SCORPION: case WAR_UNIT_BRIGAND: case WAR_UNIT_SKELETON: case WAR_UNIT_DAEMON: return true; default: return false; } } bool wu_isFistUnitType(WarUnitType type) { switch (type) { case WAR_UNIT_OGRE: case WAR_UNIT_SPIDER: case WAR_UNIT_SLIME: case WAR_UNIT_FIRE_ELEMENTAL: case WAR_UNIT_SCORPION: return true; default: return false; } } bool wu_isSwordUnitType(WarUnitType type) { switch (type) { case WAR_UNIT_FOOTMAN: case WAR_UNIT_GRUNT: case WAR_UNIT_KNIGHT: case WAR_UNIT_RAIDER: case WAR_UNIT_LOTHAR: case WAR_UNIT_BRIGAND: case WAR_UNIT_SKELETON: case WAR_UNIT_DAEMON: return true; default: return false; } } bool wu_isMagicUnitType(WarUnitType type) { switch (type) { case WAR_UNIT_CONJURER: case WAR_UNIT_WARLOCK: case WAR_UNIT_CLERIC: case WAR_UNIT_NECROLYTE: case WAR_UNIT_SCORPION: case WAR_UNIT_SPIDER: case WAR_UNIT_WATER_ELEMENTAL: case WAR_UNIT_DAEMON: case WAR_UNIT_THE_DEAD: return true; default: return false; } } bool wu_isCorpseUnitType(WarUnitType type) { switch (type) { case WAR_UNIT_HUMAN_CORPSE: case WAR_UNIT_ORC_CORPSE: return true; default: return false; } } bool wu_isCatapultUnitType(WarUnitType type) { switch (type) { case WAR_UNIT_CATAPULT_HUMANS: case WAR_UNIT_CATAPULT_ORCS: return true; default: return false; } } bool wu_isConjurerOrWarlockUnitType(WarUnitType type) { switch (type) { case WAR_UNIT_CONJURER: case WAR_UNIT_WARLOCK: return true; default: return false; } } bool wu_isClericOrNecrolyteUnitType(WarUnitType type) { switch (type) { case WAR_UNIT_CLERIC: case WAR_UNIT_NECROLYTE: return true; default: return false; } } bool wu_isSummonUnitType(WarUnitType type) { switch (type) { case WAR_UNIT_SCORPION: case WAR_UNIT_SPIDER: case WAR_UNIT_WATER_ELEMENTAL: case WAR_UNIT_DAEMON: case WAR_UNIT_THE_DEAD: return true; default: return false; } } bool wu_isDudeUnit(WarContext* context, WarEntity* entity) { WarUnitComponent* unit = we_getUnitComponent(context, entity); return unit && wu_isDudeUnitType(unit->type); } bool wu_isBuildingUnit(WarContext* context, WarEntity* entity) { WarUnitComponent* unit = we_getUnitComponent(context, entity); return unit && wu_isBuildingUnitType(unit->type); } bool wu_isWorkerUnit(WarContext* context, WarEntity* entity) { WarUnitComponent* unit = we_getUnitComponent(context, entity); return unit && wu_isWorkerUnitType(unit->type); } bool wu_isWarriorUnit(WarContext* context, WarEntity* entity) { WarUnitComponent* unit = we_getUnitComponent(context, entity); return unit && wu_isWarriorUnitType(unit->type); } bool wu_isRangeUnit(WarContext* context, WarEntity* entity) { WarUnitComponent* unit = we_getUnitComponent(context, entity); return unit && wu_isRangeUnitType(unit->type); } bool wu_isMeleeUnit(WarContext* context, WarEntity* entity) { WarUnitComponent* unit = we_getUnitComponent(context, entity); return unit && wu_isMeleeUnitType(unit->type); } bool wu_isFistUnit(WarContext* context, WarEntity* entity) { WarUnitComponent* unit = we_getUnitComponent(context, entity); return unit && wu_isFistUnitType(unit->type); } bool wu_isSwordUnit(WarContext* context, WarEntity* entity) { WarUnitComponent* unit = we_getUnitComponent(context, entity); return unit && wu_isSwordUnitType(unit->type); } bool wu_isMagicUnit(WarContext* context, WarEntity* entity) { WarUnitComponent* unit = we_getUnitComponent(context, entity); return unit && wu_isMagicUnitType(unit->type); } bool wu_isCorpseUnit(WarContext* context, WarEntity* entity) { WarUnitComponent* unit = we_getUnitComponent(context, entity); return unit && wu_isCorpseUnitType(unit->type); } bool wu_isCatapultUnit(WarContext* context, WarEntity* entity) { WarUnitComponent* unit = we_getUnitComponent(context, entity); return unit && wu_isCatapultUnitType(unit->type); } bool wu_isConjurerOrWarlockUnit(WarContext* context, WarEntity* entity) { WarUnitComponent* unit = we_getUnitComponent(context, entity); return unit && wu_isConjurerOrWarlockUnitType(unit->type); } bool wu_isClericOrNecrolyteUnit(WarContext* context, WarEntity* entity) { WarUnitComponent* unit = we_getUnitComponent(context, entity); return unit && wu_isClericOrNecrolyteUnitType(unit->type); } bool wu_isSummonUnit(WarContext* context, WarEntity* entity) { WarUnitComponent* unit = we_getUnitComponent(context, entity); return unit && wu_isSummonUnitType(unit->type); } bool wu_isSkeletonUnit(WarContext* context, WarEntity* entity) { WarUnitComponent* unit = we_getUnitComponent(context, entity); return unit && unit->type == WAR_UNIT_SKELETON; } WarRace wu_getUnitTypeRace(WarUnitType type) { switch (type) { // units case WAR_UNIT_FOOTMAN: case WAR_UNIT_PEASANT: case WAR_UNIT_CATAPULT_HUMANS: case WAR_UNIT_KNIGHT: case WAR_UNIT_ARCHER: case WAR_UNIT_CONJURER: case WAR_UNIT_CLERIC: case WAR_UNIT_LOTHAR: case WAR_UNIT_SCORPION: case WAR_UNIT_WATER_ELEMENTAL: case WAR_UNIT_HUMAN_CORPSE: // buildings case WAR_UNIT_FARM_HUMANS: case WAR_UNIT_BARRACKS_HUMANS: case WAR_UNIT_CHURCH: case WAR_UNIT_TOWER_HUMANS: case WAR_UNIT_TOWNHALL_HUMANS: case WAR_UNIT_LUMBERMILL_HUMANS: case WAR_UNIT_STABLE: case WAR_UNIT_BLACKSMITH_HUMANS: case WAR_UNIT_STORMWIND: return WAR_RACE_HUMANS; // units case WAR_UNIT_GRUNT: case WAR_UNIT_PEON: case WAR_UNIT_CATAPULT_ORCS: case WAR_UNIT_RAIDER: case WAR_UNIT_SPEARMAN: case WAR_UNIT_WARLOCK: case WAR_UNIT_NECROLYTE: case WAR_UNIT_GRIZELDA: case WAR_UNIT_GARONA: case WAR_UNIT_SPIDER: case WAR_UNIT_DAEMON: case WAR_UNIT_ORC_CORPSE: // buildings case WAR_UNIT_FARM_ORCS: case WAR_UNIT_BARRACKS_ORCS: case WAR_UNIT_TEMPLE: case WAR_UNIT_TOWER_ORCS: case WAR_UNIT_TOWNHALL_ORCS: case WAR_UNIT_LUMBERMILL_ORCS: case WAR_UNIT_KENNEL: case WAR_UNIT_BLACKSMITH_ORCS: case WAR_UNIT_BLACKROCK: return WAR_RACE_ORCS; default: return WAR_RACE_NEUTRAL; } } WarRace wu_getUnitRace(WarContext* context, WarEntity* entity) { WarUnitComponent* unit = we_getUnitComponent(context, entity); return unit ? wu_getUnitTypeRace(unit->type) : WAR_RACE_NEUTRAL; } bool wu_isHumanUnit(WarContext* context, WarEntity* entity) { return wu_getUnitRace(context, entity) == WAR_RACE_HUMANS; } bool wu_isOrcUnit(WarContext* context, WarEntity* entity) { return wu_getUnitRace(context, entity) == WAR_RACE_ORCS; } bool wu_isNeutralUnit(WarContext* context, WarEntity* entity) { return wu_getUnitRace(context, entity) == WAR_RACE_NEUTRAL; } WarProjectileType wu_getProjectileType(WarUnitType type) { assert(wu_isRangeUnitType(type)); switch (type) { case WAR_UNIT_ARCHER: case WAR_UNIT_SPEARMAN: { return WAR_PROJECTILE_ARROW; } case WAR_UNIT_CATAPULT_HUMANS: case WAR_UNIT_CATAPULT_ORCS: { return WAR_PROJECTILE_CATAPULT; } case WAR_UNIT_CONJURER: case WAR_UNIT_WARLOCK: case WAR_UNIT_CLERIC: case WAR_UNIT_NECROLYTE: { return WAR_PROJECTILE_FIREBALL; } case WAR_UNIT_WATER_ELEMENTAL: { return WAR_PROJECTILE_WATER_ELEMENTAL; } default: { // unreachable logWarning("Invalid unit firing a projectile: %d", type); return WAR_PROJECTILE_ARROW; } } } WarUnitType wu_getTownHallOfRace(WarRace race) { switch (race) { case WAR_RACE_HUMANS: return WAR_UNIT_TOWNHALL_HUMANS; case WAR_RACE_ORCS: return WAR_UNIT_TOWNHALL_ORCS; default: return WAR_UNIT_TOWNHALL_HUMANS; } } WarUnitType wu_getProducerUnitOfType(WarUnitType type) { switch (type) { case WAR_UNIT_PEASANT: return WAR_UNIT_TOWNHALL_HUMANS; case WAR_UNIT_PEON: return WAR_UNIT_TOWNHALL_ORCS; case WAR_UNIT_FOOTMAN: case WAR_UNIT_CATAPULT_HUMANS: case WAR_UNIT_KNIGHT: case WAR_UNIT_ARCHER: return WAR_UNIT_BARRACKS_HUMANS; case WAR_UNIT_GRUNT: case WAR_UNIT_CATAPULT_ORCS: case WAR_UNIT_RAIDER: case WAR_UNIT_SPEARMAN: return WAR_UNIT_BARRACKS_ORCS; case WAR_UNIT_CONJURER: return WAR_UNIT_TOWER_HUMANS; case WAR_UNIT_WARLOCK: return WAR_UNIT_TOWER_ORCS; case WAR_UNIT_CLERIC: return WAR_UNIT_CHURCH; case WAR_UNIT_NECROLYTE: return WAR_UNIT_TEMPLE; default: { logWarning("There is not producer unit for unit type %d", type); return -1; } } } vec2 wu_getUnitSize(WarContext* context, WarEntity* entity) { assert(wu_isUnit(entity)); WarUnitComponent* unit = we_getUnitComponent(context, entity); assert(unit); return vec2i(unit->sizex, unit->sizey); } vec2 wu_getUnitFrameSize(WarContext* context, WarEntity* entity) { if (we_isComponentEnabled(context, entity, COMP_SPRITE)) { WarSpriteComponent* sprite = we_getSpriteComponent(context, entity); assert(sprite); return vec2i(sprite->sprite.frameWidth, sprite->sprite.frameHeight); } return VEC2_ZERO; } rect wu_getUnitFrameRect(WarContext* context, WarEntity* entity) { return rectv(VEC2_ZERO, wu_getUnitFrameSize(context, entity)); } vec2 wu_getUnitSpriteSize(WarContext* context, WarEntity* entity) { assert(wu_isUnit(entity)); WarUnitComponent* unit = we_getUnitComponent(context, entity); assert(unit); return vec2i(unit->sizex * MEGA_TILE_WIDTH, unit->sizey * MEGA_TILE_HEIGHT); } rect wu_getUnitSpriteRect(WarContext* context, WarEntity* entity) { vec2 frameSize = wu_getUnitFrameSize(context, entity); vec2 unitSize = wu_getUnitSpriteSize(context, entity); vec2 pos = vec2_half(vec2_subv(frameSize, unitSize)); return rectv(pos, unitSize); } vec2 wu_getUnitSpriteCenter(WarContext* context, WarEntity* entity) { vec2 frameSize = wu_getUnitFrameSize(context, entity); vec2 unitSize = wu_getUnitSpriteSize(context, entity); vec2 pos = vec2_half(vec2_subv(frameSize, unitSize)); return vec2_addv(pos, vec2_half(unitSize)); } rect wu_getUnitRect(WarContext* context, WarEntity* entity) { assert(wu_isUnit(entity)); WarTransformComponent* transform = we_getTransformComponent(context, entity); assert(transform); return rectv(transform->position, wu_getUnitSpriteSize(context, entity)); } vec2 wu_getUnitPosition(WarContext* context, WarEntity* entity, bool inTiles) { WarTransformComponent* transform = we_getTransformComponent(context, entity); assert(transform); vec2 position = transform->position; return inTiles ? wmap_mapToTileCoordinatesV(position) : position; } vec2 wu_getUnitCenterPosition(WarContext* context, WarEntity* entity, bool inTiles) { WarTransformComponent* transform = we_getTransformComponent(context, entity); assert(transform); vec2 spriteSize = wu_getUnitSpriteSize(context, entity); vec2 unitCenter = vec2_half(spriteSize); vec2 position = vec2_addv(transform->position, unitCenter); return inTiles ? wmap_mapToTileCoordinatesV(position) : position; } void wu_setUnitPosition(WarContext* context, WarEntity* entity, vec2 position, bool inTiles) { if (inTiles) { position = wmap_tileToMapCoordinatesV(position, true); } WarTransformComponent* transform = we_getTransformComponent(context, entity); assert(transform); transform->position = position; } void wu_setUnitCenterPosition(WarContext* context, WarEntity* entity, vec2 position, bool inTiles) { if (inTiles) { position = wmap_tileToMapCoordinatesV(position, true); } WarTransformComponent* transform = we_getTransformComponent(context, entity); assert(transform); vec2 spriteSize = wu_getUnitSpriteSize(context, entity); vec2 unitCenter = vec2_half(spriteSize); transform->position = vec2_subv(position, unitCenter); } WarUnitDirection wu_getUnitDirection(WarContext* context, WarEntity* entity) { assert(wu_isUnit(entity)); WarUnitComponent* unit = we_getUnitComponent(context, entity); assert(unit); return unit->direction; } WarUnitDirection wu_getDirectionFromDiff(f32 x, f32 y) { if (x < 0 && y < 0) return WAR_DIRECTION_NORTH_WEST; if (x == 0 && y < 0) return WAR_DIRECTION_NORTH; if (x > 0 && y < 0) return WAR_DIRECTION_NORTH_EAST; if (x < 0 && y == 0) return WAR_DIRECTION_WEST; if (x > 0 && y == 0) return WAR_DIRECTION_EAST; if (x < 0 && y > 0) return WAR_DIRECTION_SOUTH_WEST; if (x == 0 && y > 0) return WAR_DIRECTION_SOUTH; if (x > 0 && y > 0) return WAR_DIRECTION_SOUTH_EAST; return WAR_DIRECTION_NORTH; } void wu_setUnitDirection(WarContext* context, WarEntity* entity, WarUnitDirection direction) { assert(wu_isUnit(entity)); WarUnitComponent* unit = we_getUnitComponent(context, entity); assert(unit); unit->direction = direction; } void wu_setUnitDirectionFromDiff(WarContext* context, WarEntity* entity, f32 dx, f32 dy) { assert(wu_isUnit(entity)); WarUnitDirection direction = wu_getDirectionFromDiff(dx, dy); wu_setUnitDirection(context, entity, direction); } f32 wu_getUnitActionScale(WarContext* context, WarEntity* entity) { assert(wu_isUnit(entity)); WarUnitComponent* unit = we_getUnitComponent(context, entity); assert(unit); return 1 - unit->speed * 0.1f; } vec2 wu_unitPointOnTarget(WarContext* context, WarEntity* entity, WarEntity* targetEntity) { assert(wu_isUnit(entity)); assert(wu_isUnit(targetEntity)); vec2 position = wu_getUnitCenterPosition(context, entity, true); WarTransformComponent* targetTransform = we_getTransformComponent(context, targetEntity); assert(targetTransform); vec2 targetPosition = wmap_mapToTileCoordinatesV(targetTransform->position); vec2 unitSize = wu_getUnitSize(context, targetEntity); rect unitRect = rectv(targetPosition, unitSize); return get_closestPointOnRect(position, unitRect); } s32 wu_entityTileDistance(WarContext* context, WarEntity* entity, vec2 targetPosition) { assert(wu_isUnit(entity)); vec2 position = wu_getUnitCenterPosition(context, entity, true); f32 distance = vec2_distanceInTiles(position, targetPosition); return (s32)distance; } bool wu_tileInRange(WarContext* context, WarEntity* entity, vec2 targetTile, s32 range) { assert(range >= 0); s32 distance = wu_entityTileDistance(context, entity, targetTile); return distance <= range; } s32 wu_unitDistanceInTiles(WarContext* context, WarEntity* entity, WarEntity* targetEntity) { assert(wu_isUnit(entity)); assert(wu_isUnit(targetEntity)); vec2 pointOnTarget = wu_unitPointOnTarget(context, entity, targetEntity); return wu_entityTileDistance(context, entity, pointOnTarget); } bool wu_unitInRange(WarContext* context, WarEntity* entity, WarEntity* targetEntity, s32 range) { assert(wu_isUnit(entity)); assert(wu_isUnit(targetEntity)); assert(range >= 0); s32 distance = wu_unitDistanceInTiles(context, entity, targetEntity); return distance <= range; } bool wu_isCarryingResources(WarContext* context, WarEntity* entity) { assert(entity); assert(wu_isUnit(entity)); WarUnitComponent* unit = we_getUnitComponent(context, entity); assert(unit); switch (unit->resourceKind) { case WAR_RESOURCE_GOLD: return unit->amount == UNIT_MAX_CARRY_GOLD; case WAR_RESOURCE_WOOD: return unit->amount == UNIT_MAX_CARRY_WOOD; default: return false; } } s32 wu_getUnitSightRange(WarContext* context, WarEntity* entity) { assert(wu_isUnit(entity)); WarUnitComponent* unit = we_getUnitComponent(context, entity); assert(unit); s32 sight = 0; if (wu_isBuildingUnit(context, entity)) { const WarBuildingStats* stats = wu_getBuildingStats(unit->type); sight = stats->sight; } else { const WarUnitStats* stats = wu_getUnitStats(unit->type); sight = stats->sight; } return sight; } bool wu_isFriendlyUnit(WarContext* context, WarEntity* entity) { WarMap* map = context->map; WarPlayerInfo* player = &map->players[0]; WarUnitComponent* unit = we_getUnitComponent(context, entity); return unit && unit->player == player->index; } bool wu_isEnemyUnit(WarContext* context, WarEntity* entity) { WarMap* map = context->map; WarPlayerInfo* player = &map->players[0]; WarUnitComponent* unit = we_getUnitComponent(context, entity); if (!unit) return false; if (unit->player == player->index) return false; WarPlayerInfo* otherPlayer = &map->players[unit->player]; return !isNeutralPlayer(otherPlayer); } bool wu_areEnemies(WarContext* context, WarEntity* entity1, WarEntity* entity2) { WarMap* map = context->map; WarUnitComponent* unit1 = we_getUnitComponent(context, entity1); WarUnitComponent* unit2 = we_getUnitComponent(context, entity2); if (!unit1 || !unit2) return false; if (entity1->id == entity2->id) return false; if (unit1->player == unit2->player) return false; WarPlayerInfo* otherPlayer = &map->players[unit2->player]; return !isNeutralPlayer(otherPlayer); } bool wu_canAttack(WarContext* context, WarEntity* entity, WarEntity* targetEntity) { NOT_USED(context); if (wu_isWarriorUnit(context, entity) && !wst_isDead(context, entity) && !wst_isGoingToDie(context, entity)) { if (wu_isUnit(targetEntity)) { if (!wst_isDead(context, targetEntity) && !wst_isGoingToDie(context, targetEntity) && !wu_isCorpseUnit(context, targetEntity) && !wst_isCollapsing(context, entity) && !wst_isGoingToCollapse(context, entity)) { return true; } } else if (wu_isWall(targetEntity)) return true; } return false; } bool wu_displayUnitOnMinimap(WarContext* context, WarEntity* entity) { assert(wu_isUnit(entity)); if (wu_isCorpseUnit(context, entity)) return false; if (wst_isDead(context, entity) || wst_isGoingToDie(context, entity)) return false; if (wst_isCollapsing(context, entity) || wst_isGoingToCollapse(context, entity)) return false; return true; } WarColor wu_getUnitColorOnMinimap(WarContext* context, WarEntity* entity) { assert(wu_isUnit(entity)); WarUnitComponent* unit = we_getUnitComponent(context, entity); assert(unit); u8 r = 211, g = 211, b = 211; if (unit->type == WAR_UNIT_TOWNHALL_HUMANS || unit->type == WAR_UNIT_TOWNHALL_ORCS) { r = 255; g = 255; b = 0; } else if(unit->player == 0) { r = 0; g = 199; b = 0; } else if(unit->player < 4) { r = 199; g = 0; b = 0; } return WAR_COLOR_RGB(r, g, b); } s32 wu_getTotalNumberOfUnits(WarContext* context, u8 player) { s32 count = 0; WarEntityList* units = we_getEntitiesOfType(context, WAR_ENTITY_TYPE_UNIT); for (s32 i = 0; i < units->count; i++) { WarEntity* entity = units->items[i]; if (entity) { WarUnitComponent* unit = we_getUnitComponent(context, entity); if (unit && unit->player == player) { count++; } } } return count; } bool wu_playerHasUnit(WarContext* context, u8 player, WarUnitType unitType) { return wu_getNumberOfUnitsOfType(context, player, unitType) > 0; } bool wu_playerHasBuilding(WarContext* context, u8 player, WarUnitType unitType) { return wu_getNumberOfBuildingsOfType(context, player, unitType, true) > 0; } bool wu_isValidUnitType(WarUnitType type) { return inRange(type, WAR_UNIT_FOOTMAN, WAR_UNIT_COUNT); } s32 wu_getTotalNumberOfDudes(WarContext* context, u8 player) { s32 count = 0; WarEntityList* units = we_getEntitiesOfType(context, WAR_ENTITY_TYPE_UNIT); for (s32 i = 0; i < units->count; i++) { WarEntity* entity = units->items[i]; if (entity && wu_isDudeUnit(context, entity) && !wu_isSummonUnit(context, entity) && !wu_isSkeletonUnit(context, entity)) { WarUnitComponent* unit = we_getUnitComponent(context, entity); if (unit && unit->player == player) { count++; } } } return count; } s32 wu_getTotalNumberOfBuildings(WarContext* context, u8 player, bool alreadyBuilt) { s32 count = 0; WarEntityList* units = we_getEntitiesOfType(context, WAR_ENTITY_TYPE_UNIT); for (s32 i = 0; i < units->count; i++) { WarEntity* entity = units->items[i]; if (entity) { WarUnitComponent* unit = we_getUnitComponent(context, entity); if (unit && unit->player == player && wu_isBuildingUnit(context, entity)) { if (alreadyBuilt && (wst_isBuilding(context, entity) || wst_isGoingToBuild(context, entity))) continue; count++; } } } return count; } s32 wu_getNumberOfBuildingsOfType(WarContext* context, u8 player, WarUnitType unitType, bool alreadyBuilt) { assert(wu_isBuildingUnitType(unitType)); s32 count = 0; WarEntityList* units = we_getEntitiesOfType(context, WAR_ENTITY_TYPE_UNIT); for (s32 i = 0; i < units->count; i++) { WarEntity* entity = units->items[i]; if (entity) { WarUnitComponent* unit = we_getUnitComponent(context, entity); if (unit && unit->player == player && unit->type == unitType) { if (alreadyBuilt && (wst_isBuilding(context, entity) || wst_isGoingToBuild(context, entity))) continue; count++; } } } return count; } s32 wu_getNumberOfUnitsOfType(WarContext* context, u8 player, WarUnitType unitType) { s32 count = 0; WarEntityList* units = we_getEntitiesOfType(context, WAR_ENTITY_TYPE_UNIT); for (s32 i = 0; i < units->count; i++) { WarEntity* entity = units->items[i]; if (entity) { WarUnitComponent* unit = we_getUnitComponent(context, entity); if (unit && unit->player == player && unit->type == unitType) { count++; } } } return count; } WarUnitType wu_getUnitTypeForRace(WarUnitType type, WarRace race) { if (race == WAR_RACE_HUMANS) { switch (type) { case WAR_UNIT_GRUNT: return WAR_UNIT_FOOTMAN; case WAR_UNIT_PEON: return WAR_UNIT_PEASANT; case WAR_UNIT_CATAPULT_ORCS: return WAR_UNIT_CATAPULT_HUMANS; case WAR_UNIT_RAIDER: return WAR_UNIT_KNIGHT; case WAR_UNIT_SPEARMAN: return WAR_UNIT_ARCHER; case WAR_UNIT_WARLOCK: return WAR_UNIT_CONJURER; case WAR_UNIT_NECROLYTE: return WAR_UNIT_CLERIC; case WAR_UNIT_FARM_ORCS: return WAR_UNIT_FARM_HUMANS; case WAR_UNIT_BARRACKS_ORCS: return WAR_UNIT_BARRACKS_HUMANS; case WAR_UNIT_TEMPLE: return WAR_UNIT_CHURCH; case WAR_UNIT_TOWER_ORCS: return WAR_UNIT_TOWER_HUMANS; case WAR_UNIT_TOWNHALL_ORCS: return WAR_UNIT_TOWNHALL_HUMANS; case WAR_UNIT_LUMBERMILL_ORCS: return WAR_UNIT_LUMBERMILL_HUMANS; case WAR_UNIT_KENNEL: return WAR_UNIT_STABLE; case WAR_UNIT_BLACKSMITH_ORCS: return WAR_UNIT_BLACKSMITH_HUMANS; case WAR_UNIT_ORC_CORPSE: return WAR_UNIT_HUMAN_CORPSE; default: { logInfo("Trying to get type %d for race %d, returning %d", type, race, type); return type; } } } if (race == WAR_RACE_ORCS) { switch (type) { case WAR_UNIT_FOOTMAN: return WAR_UNIT_GRUNT; case WAR_UNIT_PEASANT: return WAR_UNIT_PEON; case WAR_UNIT_CATAPULT_HUMANS: return WAR_UNIT_CATAPULT_ORCS; case WAR_UNIT_KNIGHT: return WAR_UNIT_RAIDER; case WAR_UNIT_ARCHER: return WAR_UNIT_SPEARMAN; case WAR_UNIT_CONJURER: return WAR_UNIT_WARLOCK; case WAR_UNIT_CLERIC: return WAR_UNIT_NECROLYTE; case WAR_UNIT_FARM_HUMANS: return WAR_UNIT_FARM_ORCS; case WAR_UNIT_BARRACKS_HUMANS: return WAR_UNIT_BARRACKS_ORCS; case WAR_UNIT_CHURCH: return WAR_UNIT_TEMPLE; case WAR_UNIT_TOWER_HUMANS: return WAR_UNIT_TOWER_ORCS; case WAR_UNIT_TOWNHALL_HUMANS: return WAR_UNIT_TOWNHALL_ORCS; case WAR_UNIT_LUMBERMILL_HUMANS: return WAR_UNIT_LUMBERMILL_ORCS; case WAR_UNIT_STABLE: return WAR_UNIT_KENNEL; case WAR_UNIT_BLACKSMITH_HUMANS: return WAR_UNIT_BLACKSMITH_ORCS; case WAR_UNIT_HUMAN_CORPSE: return WAR_UNIT_ORC_CORPSE; default: { logInfo("Trying to get type %d for race %d, returning %d", type, race, type); return type; } } } logInfo("Trying to get type %d for race %d, returning %d", type, race, type); return type; } void wu_getUnitCommands(WarContext* context, WarEntity* entity, WarUnitCommandType commands[]) { assert(entity); assert(wu_isUnit(entity)); WarMap* map = context->map; WarUnitCommand* command = &map->command; WarPlayerInfo* player = &map->players[0]; WarUnitComponent* unit = we_getUnitComponent(context, entity); assert(unit); if (player->race != wu_getUnitRace(context, entity)) { return; } switch (unit->type) { // units case WAR_UNIT_FOOTMAN: case WAR_UNIT_GRUNT: case WAR_UNIT_CATAPULT_HUMANS: case WAR_UNIT_CATAPULT_ORCS: case WAR_UNIT_KNIGHT: case WAR_UNIT_RAIDER: case WAR_UNIT_ARCHER: case WAR_UNIT_SPEARMAN: case WAR_UNIT_WATER_ELEMENTAL: case WAR_UNIT_DAEMON: case WAR_UNIT_SCORPION: case WAR_UNIT_SPIDER: case WAR_UNIT_SKELETON: { if (command->type != WAR_COMMAND_NONE) { commands[5] = WAR_COMMAND_CANCEL; } else { commands[0] = WAR_COMMAND_MOVE; commands[1] = WAR_COMMAND_STOP; commands[2] = WAR_COMMAND_ATTACK; } break; } case WAR_UNIT_PEASANT: { if (command->type != WAR_COMMAND_NONE) { if (command->type == WAR_COMMAND_BUILD_BASIC) { commands[0] = WAR_COMMAND_BUILD_FARM_HUMANS; if (isFeatureAllowed(player, WAR_FEATURE_UNIT_LUMBER_MILL_HUMANS)) { commands[1] = WAR_COMMAND_BUILD_LUMBERMILL_HUMANS; } commands[2] = WAR_COMMAND_BUILD_BARRACKS_HUMANS; } else if (command->type == WAR_COMMAND_BUILD_ADVANCED) { commands[0] = WAR_COMMAND_BUILD_BLACKSMITH_HUMANS; commands[1] = WAR_COMMAND_BUILD_CHURCH; commands[2] = WAR_COMMAND_BUILD_STABLE; if (wu_playerHasBuilding(context, player->index, WAR_UNIT_BLACKSMITH_HUMANS)) { commands[3] = WAR_COMMAND_BUILD_TOWER_HUMANS; } } commands[5] = WAR_COMMAND_CANCEL; } else { commands[0] = WAR_COMMAND_MOVE; commands[1] = WAR_COMMAND_STOP; commands[2] = WAR_COMMAND_REPAIR; commands[3] = !wu_isCarryingResources(context, entity) ? WAR_COMMAND_HARVEST : WAR_COMMAND_DELIVER; commands[4] = WAR_COMMAND_BUILD_BASIC; if (wu_playerHasBuilding(context, player->index, WAR_UNIT_LUMBERMILL_HUMANS)) { commands[5] = WAR_COMMAND_BUILD_ADVANCED; } } break; } case WAR_UNIT_PEON: { if (command->type != WAR_COMMAND_NONE) { if (command->type == WAR_COMMAND_BUILD_BASIC) { commands[0] = WAR_COMMAND_BUILD_FARM_ORCS; if (isFeatureAllowed(player, WAR_FEATURE_UNIT_LUMBER_MILL_ORCS)) { commands[1] = WAR_COMMAND_BUILD_LUMBERMILL_ORCS; } commands[2] = WAR_COMMAND_BUILD_BARRACKS_ORCS; } else if (command->type == WAR_COMMAND_BUILD_ADVANCED) { commands[0] = WAR_COMMAND_BUILD_BARRACKS_ORCS; commands[1] = WAR_COMMAND_BUILD_TEMPLE; commands[2] = WAR_COMMAND_BUILD_KENNEL; if (wu_playerHasBuilding(context, player->index, WAR_UNIT_BLACKSMITH_ORCS)) { commands[3] = WAR_COMMAND_BUILD_TOWER_ORCS; } } commands[5] = WAR_COMMAND_CANCEL; } else { commands[0] = WAR_COMMAND_MOVE; commands[1] = WAR_COMMAND_STOP; commands[2] = WAR_COMMAND_REPAIR; commands[3] = !wu_isCarryingResources(context, entity) ? WAR_COMMAND_HARVEST : WAR_COMMAND_DELIVER; commands[4] = WAR_COMMAND_BUILD_BASIC; if (wu_playerHasBuilding(context, player->index, WAR_UNIT_LUMBERMILL_ORCS)) { commands[5] = WAR_COMMAND_BUILD_ADVANCED; } } break; } case WAR_UNIT_CONJURER: { if (command->type != WAR_COMMAND_NONE) { commands[5] = WAR_COMMAND_CANCEL; } else { commands[0] = WAR_COMMAND_MOVE; commands[1] = WAR_COMMAND_STOP; commands[2] = WAR_COMMAND_ATTACK; // only if these spells are researshed if (isFeatureAllowed(player, WAR_FEATURE_SPELL_RAIN_OF_FIRE) && hasAnyUpgrade(player, WAR_UPGRADE_RAIN_OF_FIRE)) { commands[3] = WAR_COMMAND_SPELL_RAIN_OF_FIRE; } if (isFeatureAllowed(player, WAR_FEATURE_SPELL_SCORPION) && hasAnyUpgrade(player, WAR_UPGRADE_SCORPIONS)) { commands[4] = WAR_COMMAND_SUMMON_SCORPION; } if (isFeatureAllowed(player, WAR_FEATURE_SPELL_WATER_ELEMENTAL) && hasAnyUpgrade(player, WAR_UPGRADE_WATER_ELEMENTAL)) { commands[5] = WAR_COMMAND_SUMMON_WATER_ELEMENTAL; } } break; } case WAR_UNIT_WARLOCK: { if (command->type != WAR_COMMAND_NONE) { commands[5] = WAR_COMMAND_CANCEL; } else { commands[0] = WAR_COMMAND_MOVE; commands[1] = WAR_COMMAND_STOP; commands[2] = WAR_COMMAND_ATTACK; // only if these spells are researshed if (isFeatureAllowed(player, WAR_FEATURE_SPELL_POISON_CLOUD) && hasAnyUpgrade(player, WAR_UPGRADE_POISON_CLOUD)) { commands[3] = WAR_COMMAND_SPELL_POISON_CLOUD; } if (isFeatureAllowed(player, WAR_FEATURE_SPELL_SPIDER) && hasAnyUpgrade(player, WAR_UPGRADE_SPIDERS)) { commands[4] = WAR_COMMAND_SUMMON_SPIDER; } if (isFeatureAllowed(player, WAR_FEATURE_SPELL_DAEMON) && hasAnyUpgrade(player, WAR_UPGRADE_DAEMON)) { commands[5] = WAR_COMMAND_SUMMON_DAEMON; } } break; } case WAR_UNIT_CLERIC: { if (command->type != WAR_COMMAND_NONE) { commands[5] = WAR_COMMAND_CANCEL; } else { commands[0] = WAR_COMMAND_MOVE; commands[1] = WAR_COMMAND_STOP; commands[2] = WAR_COMMAND_ATTACK; // only if these spells are researshed if (isFeatureAllowed(player, WAR_FEATURE_SPELL_HEALING) && hasAnyUpgrade(player, WAR_UPGRADE_HEALING)) { commands[3] = WAR_COMMAND_SPELL_HEALING; } if (isFeatureAllowed(player, WAR_FEATURE_SPELL_FAR_SIGHT) && hasAnyUpgrade(player, WAR_UPGRADE_FAR_SIGHT)) { commands[4] = WAR_COMMAND_SPELL_FAR_SIGHT; } if (isFeatureAllowed(player, WAR_FEATURE_SPELL_INVISIBILITY) && hasAnyUpgrade(player, WAR_UPGRADE_INVISIBILITY)) { commands[5] = WAR_COMMAND_SPELL_INVISIBILITY; } } break; } case WAR_UNIT_NECROLYTE: { if (command->type != WAR_COMMAND_NONE) { commands[5] = WAR_COMMAND_CANCEL; } else { commands[0] = WAR_COMMAND_MOVE; commands[1] = WAR_COMMAND_STOP; commands[2] = WAR_COMMAND_ATTACK; // only if these spells are researshed if (isFeatureAllowed(player, WAR_FEATURE_SPELL_RAISE_DEAD) && hasAnyUpgrade(player, WAR_UPGRADE_RAISE_DEAD)) { commands[3] = WAR_COMMAND_SPELL_RAISE_DEAD; } if (isFeatureAllowed(player, WAR_FEATURE_SPELL_DARK_VISION) && hasAnyUpgrade(player, WAR_UPGRADE_DARK_VISION)) { commands[4] = WAR_COMMAND_SPELL_DARK_VISION; } if (isFeatureAllowed(player, WAR_FEATURE_SPELL_UNHOLY_ARMOR) && hasAnyUpgrade(player, WAR_UPGRADE_UNHOLY_ARMOR)) { commands[5] = WAR_COMMAND_SPELL_UNHOLY_ARMOR; } } break; } // buildings case WAR_UNIT_FARM_HUMANS: case WAR_UNIT_FARM_ORCS: { if (unit->building) { commands[5] = WAR_COMMAND_CANCEL; } break; } case WAR_UNIT_BARRACKS_HUMANS: { if (unit->building) { commands[5] = WAR_COMMAND_CANCEL; } else { commands[0] = WAR_COMMAND_TRAIN_FOOTMAN; // only if there is a lumber mill if (wu_playerHasBuilding(context, player->index, WAR_UNIT_LUMBERMILL_HUMANS)) { commands[1] = WAR_COMMAND_TRAIN_ARCHER; } // only if there is a blacksmith if (wu_playerHasBuilding(context, player->index, WAR_UNIT_BLACKSMITH_HUMANS)) { commands[2] = WAR_COMMAND_TRAIN_CATAPULT_HUMANS; // only if there is a stable if (wu_playerHasBuilding(context, player->index, WAR_UNIT_STABLE)) { commands[3] = WAR_COMMAND_TRAIN_KNIGHT; } } } break; } case WAR_UNIT_BARRACKS_ORCS: { if (unit->building) { commands[5] = WAR_COMMAND_CANCEL; } else { commands[0] = WAR_COMMAND_TRAIN_GRUNT; // only if there is a lumber mill if (wu_playerHasBuilding(context, player->index, WAR_UNIT_LUMBERMILL_ORCS)) { commands[1] = WAR_COMMAND_TRAIN_SPEARMAN; } // only if there is a blacksmith if (wu_playerHasBuilding(context, player->index, WAR_UNIT_BLACKSMITH_ORCS)) { commands[2] = WAR_COMMAND_TRAIN_CATAPULT_ORCS; // only if there is a kennel if (wu_playerHasBuilding(context, player->index, WAR_UNIT_KENNEL)) { commands[3] = WAR_COMMAND_TRAIN_RAIDER; } } } break; } case WAR_UNIT_CHURCH: { if (unit->building) { commands[5] = WAR_COMMAND_CANCEL; } else { commands[0] = WAR_COMMAND_TRAIN_CLERIC; // only if this upgrade is not been researched yet if (isFeatureAllowed(player, WAR_FEATURE_SPELL_HEALING) && hasRemainingUpgrade(player, WAR_UPGRADE_HEALING)) { commands[1] = WAR_COMMAND_UPGRADE_HEALING; } if (isFeatureAllowed(player, WAR_FEATURE_SPELL_FAR_SIGHT) && hasRemainingUpgrade(player, WAR_UPGRADE_FAR_SIGHT)) { commands[2] = WAR_COMMAND_UPGRADE_FAR_SIGHT; } if (isFeatureAllowed(player, WAR_FEATURE_SPELL_INVISIBILITY) && hasRemainingUpgrade(player, WAR_UPGRADE_INVISIBILITY)) { commands[3] = WAR_COMMAND_UPGRADE_INVISIBILITY; } } break; } case WAR_UNIT_TEMPLE: { if (unit->building) { commands[5] = WAR_COMMAND_CANCEL; } else { commands[0] = WAR_COMMAND_TRAIN_NECROLYTE; // only if this upgrade is not been researched yet if (isFeatureAllowed(player, WAR_FEATURE_SPELL_RAISE_DEAD) && hasRemainingUpgrade(player, WAR_UPGRADE_RAISE_DEAD)) { commands[1] = WAR_COMMAND_UPGRADE_RAISE_DEAD; } if (isFeatureAllowed(player, WAR_FEATURE_SPELL_DARK_VISION) && hasRemainingUpgrade(player, WAR_UPGRADE_DARK_VISION)) { commands[2] = WAR_COMMAND_UPGRADE_DARK_VISION; } if (isFeatureAllowed(player, WAR_FEATURE_SPELL_UNHOLY_ARMOR) && hasRemainingUpgrade(player, WAR_UPGRADE_UNHOLY_ARMOR)) { commands[3] = WAR_COMMAND_UPGRADE_UNHOLY_ARMOR; } } break; } case WAR_UNIT_TOWER_HUMANS: { if (unit->building) { commands[5] = WAR_COMMAND_CANCEL; } else { commands[0] = WAR_COMMAND_TRAIN_CONJURER; // only if this upgrade is not been researched yet if (isFeatureAllowed(player, WAR_FEATURE_SPELL_SCORPION) && hasRemainingUpgrade(player, WAR_UPGRADE_SCORPIONS)) { commands[1] = WAR_COMMAND_UPGRADE_SCORPION; } if (isFeatureAllowed(player, WAR_FEATURE_SPELL_RAIN_OF_FIRE) && hasRemainingUpgrade(player, WAR_UPGRADE_RAIN_OF_FIRE)) { commands[2] = WAR_COMMAND_UPGRADE_RAIN_OF_FIRE; } if (isFeatureAllowed(player, WAR_FEATURE_SPELL_WATER_ELEMENTAL) && hasRemainingUpgrade(player, WAR_UPGRADE_WATER_ELEMENTAL)) { commands[3] = WAR_COMMAND_UPGRADE_WATER_ELEMENTAL; } } break; } case WAR_UNIT_TOWER_ORCS: { if (unit->building) { commands[5] = WAR_COMMAND_CANCEL; } else { commands[0] = WAR_COMMAND_TRAIN_WARLOCK; // only if this upgrade is not been researched yet if (isFeatureAllowed(player, WAR_FEATURE_SPELL_SPIDER) && hasRemainingUpgrade(player, WAR_UPGRADE_SPIDERS)) { commands[1] = WAR_COMMAND_UPGRADE_SPIDER; } if (isFeatureAllowed(player, WAR_FEATURE_SPELL_POISON_CLOUD) && hasRemainingUpgrade(player, WAR_UPGRADE_POISON_CLOUD)) { commands[2] = WAR_COMMAND_UPGRADE_POISON_CLOUD; } if (isFeatureAllowed(player, WAR_FEATURE_SPELL_DAEMON) && hasRemainingUpgrade(player, WAR_UPGRADE_DAEMON)) { commands[3] = WAR_COMMAND_UPGRADE_DAEMON; } } break; } case WAR_UNIT_TOWNHALL_HUMANS: case WAR_UNIT_TOWNHALL_ORCS: { if (command->type == WAR_COMMAND_BUILD_WALL || command->type == WAR_COMMAND_BUILD_ROAD || unit->building) { commands[5] = WAR_COMMAND_CANCEL; } else { commands[0] = unit->type == WAR_UNIT_TOWNHALL_HUMANS ? WAR_COMMAND_TRAIN_PEASANT : WAR_COMMAND_TRAIN_PEON; commands[1] = WAR_COMMAND_BUILD_ROAD; // only if this is allowed if (isFeatureAllowed(player, WAR_FEATURE_UNIT_WALL)) { commands[2] = WAR_COMMAND_BUILD_WALL; } } break; } case WAR_UNIT_LUMBERMILL_HUMANS: { if (unit->building) { commands[5] = WAR_COMMAND_CANCEL; } else { // only if this upgrade is less than level 2 if (hasRemainingUpgrade(player, WAR_UPGRADE_ARROWS)) { commands[0] = WAR_COMMAND_UPGRADE_ARROWS; } } break; } case WAR_UNIT_LUMBERMILL_ORCS: { if (unit->building) { commands[5] = WAR_COMMAND_CANCEL; } else { // only if this upgrade is less than level 2 if (hasRemainingUpgrade(player, WAR_UPGRADE_SPEARS)) { commands[0] = WAR_COMMAND_UPGRADE_SPEARS; } } break; } case WAR_UNIT_STABLE: { if (unit->building) { commands[5] = WAR_COMMAND_CANCEL; } else { // only if this upgrade is less than level 2 if (hasRemainingUpgrade(player, WAR_UPGRADE_HORSES)) { commands[0] = WAR_COMMAND_UPGRADE_HORSES; } } break; } case WAR_UNIT_KENNEL: { if (unit->building) { commands[5] = WAR_COMMAND_CANCEL; } else { // only if this upgrade is less than level 2 if (hasRemainingUpgrade(player, WAR_UPGRADE_WOLVES)) { commands[0] = WAR_COMMAND_UPGRADE_WOLVES; } } break; } case WAR_UNIT_BLACKSMITH_HUMANS: { if (unit->building) { commands[5] = WAR_COMMAND_CANCEL; } else { // only if this upgrade is less than level 2 if (hasRemainingUpgrade(player, WAR_UPGRADE_SWORDS)) { commands[0] = WAR_COMMAND_UPGRADE_SWORDS; } if (hasRemainingUpgrade(player, WAR_UPGRADE_SHIELD)) { commands[1] = WAR_COMMAND_UPGRADE_SHIELD_HUMANS; } } break; } case WAR_UNIT_BLACKSMITH_ORCS: { if (unit->building) { commands[5] = WAR_COMMAND_CANCEL; } else { // only if this upgrade is less than level 2 if (hasRemainingUpgrade(player, WAR_UPGRADE_AXES)) { commands[0] = WAR_COMMAND_UPGRADE_AXES; } if (hasRemainingUpgrade(player, WAR_UPGRADE_SHIELD)) { commands[1] = WAR_COMMAND_UPGRADE_SHIELD_ORCS; } } break; } default: { logWarning("Commands for unit type %d not handled yet.", unit->type); break; } } } WarUnitCommandData wu_getUnitCommandData(WarContext* context, WarEntity* entity, WarUnitCommandType commandType) { WarMap* map = context->map; WarPlayerInfo* player = &map->players[0]; const WarUnitCommandBaseData* commandBaseData = wu_getCommandBaseData(commandType); WarUnitCommandData data = (WarUnitCommandData){0}; data.type = commandType; data.hotKey = commandBaseData->hotKey; data.highlightIndex = commandBaseData->highlightIndex; data.highlightCount = commandBaseData->highlightCount; data.tooltip = commandBaseData->tooltip; data.clickHandler = commandBaseData->clickHandler; switch (commandType) { // unit commands case WAR_COMMAND_MOVE: { data.frameIndex = isHumanPlayer(player) ? WAR_PORTRAIT_MOVE_HUMANS : WAR_PORTRAIT_MOVE_ORCS; break; } case WAR_COMMAND_STOP: { // check here upgrades for the shields if (getUpgradeLevel(player, WAR_UPGRADE_SHIELD) == 2) { data.frameIndex = isHumanPlayer(player) ? WAR_PORTRAIT_SHIELD_3_HUMANS : WAR_PORTRAIT_SHIELD_3_ORCS; } else if (getUpgradeLevel(player, WAR_UPGRADE_SHIELD) == 1) { data.frameIndex = isHumanPlayer(player) ? WAR_PORTRAIT_SHIELD_2_HUMANS : WAR_PORTRAIT_SHIELD_2_ORCS; } else { data.frameIndex = isHumanPlayer(player) ? WAR_PORTRAIT_SHIELD_1_HUMANS : WAR_PORTRAIT_SHIELD_1_ORCS; } break; } case WAR_COMMAND_HARVEST: { data.frameIndex = WAR_PORTRAIT_HARVEST; break; } case WAR_COMMAND_DELIVER: { data.frameIndex = WAR_PORTRAIT_DELIVER; break; } case WAR_COMMAND_REPAIR: { data.frameIndex = WAR_PORTRAIT_REPAIR; break; } case WAR_COMMAND_BUILD_BASIC: { data.frameIndex = WAR_PORTRAIT_BUILD_BASIC; break; } case WAR_COMMAND_BUILD_ADVANCED: { data.frameIndex = WAR_PORTRAIT_BUILD_ADVANCED; break; } case WAR_COMMAND_ATTACK: { if (entity && wu_isUnit(entity)) { WarUnitComponent* unit = we_getUnitComponent(context, entity); assert(unit); switch (unit->type) { // units case WAR_UNIT_FOOTMAN: case WAR_UNIT_GRUNT: case WAR_UNIT_KNIGHT: case WAR_UNIT_RAIDER: case WAR_UNIT_CATAPULT_HUMANS: case WAR_UNIT_CATAPULT_ORCS: case WAR_UNIT_SCORPION: case WAR_UNIT_SPIDER: case WAR_UNIT_DAEMON: { // check here upgrades for the sword WarUpgradeType swordAxeUpgrade = isHumanPlayer(player) ? WAR_UPGRADE_SWORDS : WAR_UPGRADE_AXES; if (getUpgradeLevel(player, swordAxeUpgrade) == 2) { data.frameIndex = isHumanPlayer(player) ? WAR_PORTRAIT_SWORD_3 : WAR_PORTRAIT_AXE_3; } else if (getUpgradeLevel(player, swordAxeUpgrade) == 1) { data.frameIndex = isHumanPlayer(player) ? WAR_PORTRAIT_SWORD_2 : WAR_PORTRAIT_AXE_2; } else { data.frameIndex = isHumanPlayer(player) ? WAR_PORTRAIT_SWORD_1 : WAR_PORTRAIT_AXE_1; } break; } case WAR_UNIT_ARCHER: case WAR_UNIT_SPEARMAN: { // check here upgrades for the arrows WarUpgradeType arrowSpearUpgrade = isHumanPlayer(player) ? WAR_UPGRADE_ARROWS : WAR_UPGRADE_SPEARS; if (getUpgradeLevel(player, arrowSpearUpgrade) == 2) { data.frameIndex = isHumanPlayer(player) ? WAR_PORTRAIT_ARROW_3 : WAR_PORTRAIT_SPEAR_3; } else if (getUpgradeLevel(player, arrowSpearUpgrade) == 1) { data.frameIndex = isHumanPlayer(player) ? WAR_PORTRAIT_ARROW_2 : WAR_PORTRAIT_SPEAR_2; } else { data.frameIndex = isHumanPlayer(player) ? WAR_PORTRAIT_ARROW_1 : WAR_PORTRAIT_SPEAR_1; } break; } case WAR_UNIT_CONJURER: case WAR_UNIT_WATER_ELEMENTAL: { data.frameIndex = WAR_PORTRAIT_ELEMENTAL_BLAST; break; } case WAR_UNIT_CLERIC: { data.frameIndex = WAR_PORTRAIT_HOLY_LANCE; break; } case WAR_UNIT_NECROLYTE: { data.frameIndex = WAR_PORTRAIT_SHADOW_SPEAR; break; } case WAR_UNIT_WARLOCK: { data.frameIndex = WAR_PORTRAIT_FIREBALL; break; } default: { logWarning("Trying to get an attack command for unit of type: %d", unit->type); break; } } } else { // check here upgrades for the sword if (isHumanPlayer(player)) { if (getUpgradeLevel(player, WAR_UPGRADE_SWORDS) == 2) data.frameIndex = WAR_PORTRAIT_SWORD_3; else if (getUpgradeLevel(player, WAR_UPGRADE_SWORDS) == 1) data.frameIndex = WAR_PORTRAIT_SWORD_2; else data.frameIndex = WAR_PORTRAIT_SWORD_1; } else if (isOrcPlayer(player)) { if (getUpgradeLevel(player, WAR_UPGRADE_AXES) == 2) data.frameIndex = WAR_PORTRAIT_AXE_3; else if (getUpgradeLevel(player, WAR_UPGRADE_AXES) == 1) data.frameIndex = WAR_PORTRAIT_AXE_2; else data.frameIndex = WAR_PORTRAIT_AXE_1; } else { logWarning("Trying to get a frame index for player race: %d", player->race); assert(false); } } break; } case WAR_COMMAND_TRAIN_PEASANT: case WAR_COMMAND_TRAIN_PEON: case WAR_COMMAND_TRAIN_FOOTMAN: case WAR_COMMAND_TRAIN_GRUNT: case WAR_COMMAND_TRAIN_CATAPULT_HUMANS: case WAR_COMMAND_TRAIN_CATAPULT_ORCS: case WAR_COMMAND_TRAIN_KNIGHT: case WAR_COMMAND_TRAIN_RAIDER: case WAR_COMMAND_TRAIN_ARCHER: case WAR_COMMAND_TRAIN_SPEARMAN: case WAR_COMMAND_TRAIN_CONJURER: case WAR_COMMAND_TRAIN_WARLOCK: case WAR_COMMAND_TRAIN_CLERIC: case WAR_COMMAND_TRAIN_NECROLYTE: { const WarUnitCommandMapping* commandMapping = wu_getCommandMapping(commandType); const WarUnitData* unitData = wu_getUnitData(commandMapping->mappedType); const WarUnitStats* stats = wu_getUnitStats(commandMapping->mappedType); data.gold = stats->goldCost; data.wood = stats->woodCost; data.frameIndex = unitData->portraitFrameIndex; break; } case WAR_COMMAND_BUILD_FARM_HUMANS: case WAR_COMMAND_BUILD_FARM_ORCS: case WAR_COMMAND_BUILD_BARRACKS_HUMANS: case WAR_COMMAND_BUILD_BARRACKS_ORCS: case WAR_COMMAND_BUILD_CHURCH: case WAR_COMMAND_BUILD_TEMPLE: case WAR_COMMAND_BUILD_TOWER_HUMANS: case WAR_COMMAND_BUILD_TOWER_ORCS: case WAR_COMMAND_BUILD_TOWNHALL_HUMANS: case WAR_COMMAND_BUILD_TOWNHALL_ORCS: case WAR_COMMAND_BUILD_LUMBERMILL_HUMANS: case WAR_COMMAND_BUILD_LUMBERMILL_ORCS: case WAR_COMMAND_BUILD_STABLE: case WAR_COMMAND_BUILD_KENNEL: case WAR_COMMAND_BUILD_BLACKSMITH_HUMANS: case WAR_COMMAND_BUILD_BLACKSMITH_ORCS: { const WarUnitCommandMapping* commandMapping = wu_getCommandMapping(commandType); const WarUnitData* unitData = wu_getUnitData(commandMapping->mappedType); const WarBuildingStats* stats = wu_getBuildingStats(commandMapping->mappedType); data.gold = stats->goldCost; data.wood = stats->woodCost; data.frameIndex = unitData->portraitFrameIndex; break; } case WAR_COMMAND_BUILD_ROAD: { data.gold = 50; data.frameIndex = WAR_PORTRAIT_ROAD; break; } case WAR_COMMAND_BUILD_WALL: { data.gold = WAR_WALL_GOLD_COST; data.frameIndex = WAR_PORTRAIT_WALL; break; } case WAR_COMMAND_UPGRADE_SWORDS: case WAR_COMMAND_UPGRADE_AXES: case WAR_COMMAND_UPGRADE_SHIELD_HUMANS: case WAR_COMMAND_UPGRADE_SHIELD_ORCS: case WAR_COMMAND_UPGRADE_ARROWS: case WAR_COMMAND_UPGRADE_SPEARS: case WAR_COMMAND_UPGRADE_HORSES: case WAR_COMMAND_UPGRADE_WOLVES: case WAR_COMMAND_UPGRADE_SCORPION: case WAR_COMMAND_UPGRADE_SPIDER: case WAR_COMMAND_UPGRADE_RAIN_OF_FIRE: case WAR_COMMAND_UPGRADE_POISON_CLOUD: case WAR_COMMAND_UPGRADE_WATER_ELEMENTAL: case WAR_COMMAND_UPGRADE_DAEMON: case WAR_COMMAND_UPGRADE_HEALING: case WAR_COMMAND_UPGRADE_RAISE_DEAD: case WAR_COMMAND_UPGRADE_FAR_SIGHT: case WAR_COMMAND_UPGRADE_DARK_VISION: case WAR_COMMAND_UPGRADE_INVISIBILITY: case WAR_COMMAND_UPGRADE_UNHOLY_ARMOR: { const WarUnitCommandMapping* commandMapping = wu_getCommandMapping(commandType); assert(hasRemainingUpgrade(player, commandMapping->mappedType)); const WarUpgradeData* upgradeData = wu_getUpgradeData(commandMapping->mappedType); const WarUpgradeStats* stats = wu_getUpgradeStats(commandMapping->mappedType); s32 upgradeLevel = getUpgradeLevel(player, commandMapping->mappedType); data.gold = stats->goldCost[upgradeLevel]; data.frameIndex = upgradeData->frameIndices[upgradeLevel]; break; } case WAR_COMMAND_SUMMON_SPIDER: case WAR_COMMAND_SUMMON_SCORPION: case WAR_COMMAND_SUMMON_DAEMON: case WAR_COMMAND_SUMMON_WATER_ELEMENTAL: case WAR_COMMAND_SPELL_HEALING: case WAR_COMMAND_SPELL_FAR_SIGHT: case WAR_COMMAND_SPELL_INVISIBILITY: case WAR_COMMAND_SPELL_RAIN_OF_FIRE: case WAR_COMMAND_SPELL_RAISE_DEAD: case WAR_COMMAND_SPELL_DARK_VISION: case WAR_COMMAND_SPELL_UNHOLY_ARMOR: case WAR_COMMAND_SPELL_POISON_CLOUD: { const WarUnitCommandMapping* commandMapping = wu_getCommandMapping(commandType); const WarSpellData* spell = wu_getSpellData(commandMapping->mappedType); data.frameIndex = spell->portraitFrameIndex; break; } // wcmd_cancel case WAR_COMMAND_CANCEL: { data.frameIndex = WAR_PORTRAIT_CANCEL; break; } default: { logWarning("Unkown command type: %d", commandType); break; } } return data; } ================================================ FILE: src/war_units.h ================================================ #pragma once #include #include "common.h" #include "war_math.h" #include "war_log.h" #include "war.h" #include "war_color.h" #include "war_commands.h" #define directionByIndex(i) ((WarUnitDirection)(WAR_DIRECTION_NORTH + i)) extern const StringView features[]; extern const StringView upgradeNames[]; struct _WarUnitData { WarUnitType type; s32 resourceIndex; s32 portraitFrameIndex; s32 sizex; s32 sizey; StringView name; }; extern const WarUnitData unitsData[]; struct _WarWorkerData { WarUnitType type; s32 carryingWoodResource; s32 carryingGoldResource; }; extern const WarWorkerData workersData[]; struct _WarBuildingData { WarUnitType type; s32 buildingResource; }; extern const WarBuildingData buildingsData[]; struct _WarRoadData { WarRoadPieceType type; s32 tileIndexForest; s32 tileIndexSwamp; }; extern const WarRoadData roadsData[]; // this is a map of the configurations of the neighbors of a tile to a road tile type. // each index represent one configuration of the 16 possibles and the value at that index // is the tile the tree should get based on that configuration. extern const WarRoadPieceType roadTileTypeMap[16]; struct _WarWallData { WarWallPieceType type; s32 tileForest; s32 tileDamagedForest; s32 tileDestroyedForest; s32 tileSwamp; s32 tileDamagedSwamp; s32 tileDestroyedSwamp; }; extern const WarWallData wallsData[]; // this is a map of the configurations of the neighbors of a tile to a wall tile type. // each index represent one configuration of the 16 possibles and the value at that index // is the tile the tree should get based on that configuration. extern const WarWallPieceType wallTileTypeMap[16]; #define __bts(t) ((t)*80/1000) #define WAR_WALL_GOLD_COST 100 #define WAR_WALL_WOOD_COST 0 #define WAR_WALL_BUILD_TIME __bts(200) #define WAR_WALL_MAX_HP 60 #define WAR_ROAD_GOLD_COST 50 #define WAR_ROAD_WOOD_COST 0 #define GOD_MODE_MIN_DAMAGE 255 struct _WarRuinData { WarRuinPieceType type; s32 tileIndexForest; s32 tileIndexSwamp; }; extern const WarRuinData ruinsData[]; // this is a map of the configurations of the neighbors of a tile to a ruin tile type. // each index represent one configuration of the 256 possibles and the value at that index // is the tile the tree should get based on that configuration. extern const WarRuinPieceType ruinTileTypeMap[256]; struct _WarTreeData { WarTreeTileType type; s32 tileIndexForest; s32 tileIndexSwamp; }; extern const WarTreeData treesData[]; // this is a map of the configurations of the neighbors of a tile to a tree tile type. // each index represent one configuration of the 256 possibles and the value at that index // is the tile the tree should get based on that configuration. extern const WarTreeTileType treeTileTypeMap[256]; // this is a map of the configurations of the neighbors of a tile to a ruin tile type. // each index represent one configuration of the 256 possibles and the value at that index // is the tile the tree should get based on that configuration. extern const WarFogPieceType fogTileTypeMap[256]; struct _WarUnitStats { WarUnitType type; s32 range; s32 sight; s32 armor; s32 hp; s32 mana; s32 minDamage; s32 rndDamage; s32 buildTime; s32 goldCost; s32 woodCost; s32 decay; f32 speeds[3]; }; // Move speeds (equivalent for orcs): // Scorpion, Knight (upgrade 2) = 1.629 bps = 1.629 bps * 16 px = 26.064 pxs = 26 pxs // Knight (upgrade 1) = 1.379 bps = 1.379 bps * 16 px = 22.064 pxs = 22 pxs // Peasant, Archer, Knight, Lothar, Medivh = 1.224 bps = 1.224 bps * 16 px = 19.584 pxs = 19 pxs // Elemental = 1.121 bps = 1.121 bps * 16 px = 17.936 pxs = 18 pxs // Footman = 1.046 bps = 1.046 bps * 16 px = 16.736 pxs = 17 pxs // Cleric, Conjurer, Griselda, Garona = 0.874 bps = 0.874 bps * 16 px = 13.984 pxs = 14 pxs // Catapult = 0.562 bps = 0.562 bps * 16 px = 8.992 pxs = 9 pxs // Build times in the document Warcraft: Orcs & Humans Insider's Guide have some inconsistencies // or at least I couldn't understanding it. So I'm taking the formula from the statement (also in that document) // that the TownHall which have 1000 build units last aprox. 80 seconds // // Unit build times (equivalent for orcs): // FOOTMAN, 600 program cycles = 48s // PEASANT, 750 program cycles = 60s // CATAPULT_HUMANS 1000 program cycles = 80s // KNIGHT, 800 program cycles = 64s // ARCHER, 700 program cycles = 56s // CONJURER, 900 program cycles = 72s // CLERIC, 800 program cycles = 64s // // Building build times (equivalent for orcs): // FARM_HUMANS, 1000 program cycles = 80s // BARRACKS_HUMANS, 1500 program cycles = 120s // CHURCH, 2000 program cycles = 160s // TOWER_HUMANS, 2000 program cycles = 160s // TOWNHALL_HUMANS, 1000 program cycles = 80s // LUMBERMILL_HUMANS, 1500 program cycles = 120s // STABLE, 1500 program cycles = 120s // BLACKSMITH_HUMANS, 1500 program cycles = 120s // // build time in seconds extern const WarUnitStats unitStats[]; struct _WarBuildingStats { WarUnitType type; s32 armor; s32 sight; s32 hp; s32 buildTime; s32 goldCost; s32 woodCost; }; extern const WarBuildingStats buildingStats[]; struct _WarUpgradeData { WarUpgradeType type; s32 maxLevelAllowed; s32 frameIndices[2]; }; extern const WarUpgradeData upgradesData[]; struct _WarUpgradeStats { WarUpgradeType type; s32 buildTime; s32 goldCost[2]; }; extern const WarUpgradeStats upgradeStats[]; struct _WarSpellData { WarSpellType type; s32 portraitFrameIndex; }; extern const WarSpellData spellData[]; struct _WarSpellStats { WarSpellType type; s32 manaCost; f32 time; s32 range; }; extern const WarSpellStats spellStats[]; struct _WarSpellMapping { WarSpellType type; s32 mappedType; }; extern const WarSpellMapping spellMappings[]; struct _WarUnitCommandBaseData { WarUnitCommandType type; WarClickHandler clickHandler; WarKeys hotKey; s32 highlightIndex; s32 highlightCount; StringView tooltip; StringView tooltip2; }; extern const WarUnitCommandBaseData commandsBaseData[]; struct _WarUnitCommandMapping { WarUnitCommandType type; s32 mappedType; }; extern const WarUnitCommandMapping commandMappings[]; struct _WarUnitCommandData { WarUnitCommandType type; s32 gold; s32 wood; s32 frameIndex; // always from resource 361 WarKeys hotKey; s32 highlightIndex; s32 highlightCount; StringView tooltip; WarClickHandler clickHandler; }; u32 wu_hashUnitType(const WarUnitType type); bool wu_equalsUnitType(const WarUnitType t1, const WarUnitType t2); const WarUnitData* wu_getUnitData(WarUnitType type); const WarWorkerData* wu_getWorkerData(WarUnitType type); const WarBuildingData* wu_getBuildingData(WarUnitType type); const WarRoadData* wu_getRoadData(WarRoadPieceType type); const WarWallData* wu_getWallData(WarWallPieceType type); const WarRuinData* wu_getRuinData(WarRuinPieceType type); const WarTreeData* wu_getTreeData(WarTreeTileType type); const WarUpgradeData* wu_getUpgradeData(WarUpgradeType type); const WarSpellData* wu_getSpellData(WarSpellType type); const WarUnitStats* wu_getUnitStats(WarUnitType type); const WarBuildingStats* wu_getBuildingStats(WarUnitType type); const WarUpgradeStats* wu_getUpgradeStats(WarUpgradeType type); const WarSpellStats* wu_getSpellStats(WarSpellType type); const WarSpellMapping* wu_getSpellMapping(WarSpellType type); const WarUnitCommandBaseData* wu_getCommandBaseData(WarUnitCommandType type); const WarUnitCommandMapping* wu_getCommandMapping(WarUnitCommandType type); const WarUnitCommandMapping* wu_getCommandMappingFromUnitType(WarUnitType unitType); const WarUnitCommandMapping* wu_getCommandMappingFromUpgradeType(WarUpgradeType upgradeType); const WarUnitCommandMapping* wu_getCommandMappingFromSpellType(WarSpellType spellType); bool wu_isUnit(const WarEntity* entity); bool wu_isUnitOfType(WarContext* ctx, const WarEntity* entity, WarUnitType unitType); bool wu_isRoad(const WarEntity* entity); bool wu_isWall(const WarEntity* entity); bool wu_isRuin(const WarEntity* entity); bool wu_isDudeUnitType(WarUnitType type); bool wu_isBuildingUnitType(WarUnitType type); bool wu_isWorkerUnitType(WarUnitType type); bool wu_isWarriorUnitType(WarUnitType type); bool wu_isRangeUnitType(WarUnitType type); bool wu_isMeleeUnitType(WarUnitType type); bool wu_isFistUnitType(WarUnitType type); bool wu_isSwordUnitType(WarUnitType type); bool wu_isMagicUnitType(WarUnitType type); bool wu_isCorpseUnitType(WarUnitType type); bool wu_isCatapultUnitType(WarUnitType type); bool wu_isConjurerOrWarlockUnitType(WarUnitType type); bool wu_isClericOrNecrolyteUnitType(WarUnitType type); bool wu_isSummonUnitType(WarUnitType type); // Entity-level unit-type queries (bodies defined in war_entities.h after WarEntity is complete) bool wu_isDudeUnit(WarContext* context, WarEntity* entity); bool wu_isBuildingUnit(WarContext* context, WarEntity* entity); bool wu_isWorkerUnit(WarContext* context, WarEntity* entity); bool wu_isWarriorUnit(WarContext* context, WarEntity* entity); bool wu_isRangeUnit(WarContext* context, WarEntity* entity); bool wu_isMeleeUnit(WarContext* context, WarEntity* entity); bool wu_isFistUnit(WarContext* context, WarEntity* entity); bool wu_isSwordUnit(WarContext* context, WarEntity* entity); bool wu_isMagicUnit(WarContext* context, WarEntity* entity); bool wu_isCorpseUnit(WarContext* context, WarEntity* entity); bool wu_isCatapultUnit(WarContext* context, WarEntity* entity); bool wu_isConjurerOrWarlockUnit(WarContext* context, WarEntity* entity); bool wu_isClericOrNecrolyteUnit(WarContext* context, WarEntity* entity); bool wu_isSummonUnit(WarContext* context, WarEntity* entity); bool wu_isSkeletonUnit(WarContext* context, WarEntity* entity); WarRace wu_getUnitTypeRace(WarUnitType type); WarRace wu_getUnitRace(WarContext* context, WarEntity* entity); bool wu_isHumanUnit(WarContext* context, WarEntity* entity); bool wu_isOrcUnit(WarContext* context, WarEntity* entity); bool wu_isNeutralUnit(WarContext* context, WarEntity* entity); WarUnitType wu_getUnitTypeForRace(WarUnitType type, WarRace race); WarProjectileType wu_getProjectileType(WarUnitType type); bool wu_isFriendlyUnit(WarContext* context, WarEntity* entity); bool wu_isEnemyUnit(WarContext* context, WarEntity* entity); bool wu_areEnemies(WarContext* context, WarEntity* entity, WarEntity* other); bool wu_canAttack(WarContext* context, WarEntity* entity, WarEntity* targetEntity); WarUnitType wu_getTownHallOfRace(WarRace race); WarUnitType wu_getProducerUnitOfType(WarUnitType type); // Entity geometry / property functions (bodies defined in war_entities.h) vec2 wu_getUnitSize(WarContext* context, WarEntity* entity); vec2 wu_getUnitFrameSize(WarContext* context, WarEntity* entity); rect wu_getUnitFrameRect(WarContext* context, WarEntity* entity); vec2 wu_getUnitSpriteSize(WarContext* context, WarEntity* entity); rect wu_getUnitSpriteRect(WarContext* context, WarEntity* entity); vec2 wu_getUnitSpriteCenter(WarContext* context, WarEntity* entity); rect wu_getUnitRect(WarContext* context, WarEntity* entity); vec2 wu_getUnitPosition(WarContext* context, WarEntity* entity, bool inTiles); vec2 wu_getUnitCenterPosition(WarContext* context, WarEntity* entity, bool inTiles); void wu_setUnitPosition(WarContext* context, WarEntity* entity, vec2 position, bool inTiles); void wu_setUnitCenterPosition(WarContext* context, WarEntity* entity, vec2 position, bool inTiles); WarUnitDirection wu_getUnitDirection(WarContext* context, WarEntity* entity); WarUnitDirection wu_getDirectionFromDiff(f32 x, f32 y); void wu_setUnitDirection(WarContext* context, WarEntity* entity, WarUnitDirection direction); void wu_setUnitDirectionFromDiff(WarContext* context, WarEntity* entity, f32 dx, f32 dy); f32 wu_getUnitActionScale(WarContext* context, WarEntity* entity); vec2 wu_unitPointOnTarget(WarContext* context, WarEntity* entity, WarEntity* targetEntity); s32 wu_entityTileDistance(WarContext* context, WarEntity* entity, vec2 targetPosition); bool wu_tileInRange(WarContext* context, WarEntity* entity, vec2 targetTile, s32 range); s32 wu_unitDistanceInTiles(WarContext* context, WarEntity* entity, WarEntity* targetEntity); bool wu_unitInRange(WarContext* context, WarEntity* entity, WarEntity* targetEntity, s32 range); bool wu_isCarryingResources(WarContext* context, WarEntity* entity); s32 wu_getUnitSightRange(WarContext* context, WarEntity* entity); bool wu_displayUnitOnMinimap(WarContext* context, WarEntity* entity); WarColor wu_getUnitColorOnMinimap(WarContext* context, WarEntity* entity); s32 wu_getTotalNumberOfDudes(WarContext* context, u8 player); s32 wu_getTotalNumberOfBuildings(WarContext* context, u8 player, bool alreadyBuilt); s32 wu_getNumberOfBuildingsOfType(WarContext* context, u8 player, WarUnitType unitType, bool alreadyBuilt); s32 wu_getNumberOfUnitsOfType(WarContext* context, u8 player, WarUnitType unitType); s32 wu_getTotalNumberOfUnits(WarContext* context, u8 player); bool wu_playerHasUnit(WarContext* context, u8 player, WarUnitType unitType); bool wu_playerHasBuilding(WarContext* context, u8 player, WarUnitType unitType); bool wu_isValidUnitType(WarUnitType type); void wu_getUnitCommands(WarContext* context, WarEntity* entity, WarUnitCommandType commands[]); WarUnitCommandData wu_getUnitCommandData(WarContext* context, WarEntity* entity, WarUnitCommandType commandType); ================================================ FILE: src/war_walls.c ================================================ #include "war_entities.h" #include bool we_hasWallPieceAtPosition(WarContext* context, WarEntity* wall, s32 x, s32 y) { WarWallComponent* wallComp = we_getWallComponent(context, wall); assert(wallComp); WarWallPieceList* pieces = &wallComp->pieces; for (s32 i = 0; i < pieces->count; i++) { WarWallPiece* piece = &pieces->items[i]; if (piece->tilex == x && piece->tiley == y) return true; } return false; } WarWallPiece* we_getWallPieceAtPosition(WarContext* context, WarEntity* wall, s32 x, s32 y) { WarWallComponent* wallComp = we_getWallComponent(context, wall); assert(wallComp); WarWallPieceList* pieces = &wallComp->pieces; for (s32 i = 0; i < pieces->count; i++) { WarWallPiece* piece = &pieces->items[i]; if (piece->tilex == x && piece->tiley == y) return piece; } return NULL; } void we_determineWallTypes(WarContext* context, WarEntity* entity) { assert(entity->type == WAR_ENTITY_TYPE_WALL); WarMap* map = context->map; WarWallComponent* wallComp = we_getWallComponent(context, entity); assert(wallComp); WarWallPieceList* pieces = &wallComp->pieces; const s32 dirC = 4; const s32 dirX[] = { 0, 1, 0, -1 }; const s32 dirY[] = { -1, 0, 1, 0 }; s32 count = pieces->count; for(s32 i = 0; i < count; i++) { WarWallPiece* pi = &pieces->items[i]; s32 index = 0; for (s32 d = 0; d < dirC; d++) { s32 xx = pi->tilex + dirX[d]; s32 yy = pi->tiley + dirY[d]; if (!wpath_isInside(map->finder, xx, yy) || we_hasWallPieceAtPosition(context, entity, xx, yy)) { index = index | (1 << d); } } pi->type = wallTileTypeMap[index]; } } WarWallPiece* we_addWallPiece(WarContext* context, WarEntity* entity, s32 x, s32 y, s32 player) { WarWallComponent* wallComp = we_getWallComponent(context, entity); assert(wallComp); WarWallPieceList* pieces = &wallComp->pieces; WarWallPieceListAdd(pieces, createWallPiece(x, y, player)); return &pieces->items[pieces->count - 1]; } void we_addWallPiecesFromConstruct(WarContext* context, WarEntity* entity, WarLevelConstruct *construct) { assert(entity->type == WAR_ENTITY_TYPE_WALL); WarWallComponent* wallComp = we_getWallComponent(context, entity); assert(wallComp); WarWallPieceList *pieces = &wallComp->pieces; s32 x1 = construct->x1; s32 y1 = construct->y1; s32 x2 = construct->x2; s32 y2 = construct->y2; u8 player = construct->player; s32 dx = x2 - x1; dx = SIGN(dx); s32 dy = y2 - y1; dy = SIGN(dy); s32 x = x1; s32 y = y1; while (x != x2) { WarWallPieceListAdd(pieces, createWallPiece(x, y, player)); x += dx; } WarWallPieceListAdd(pieces, createWallPiece(x, y, player)); while (y != y2) { WarWallPieceListAdd(pieces, createWallPiece(x, y, player)); y += dy; } WarWallPieceListAdd(pieces, createWallPiece(x, y, player)); } void we_removeWallPiece(WarContext* context, WarEntity* entity, WarWallPiece* piece) { WarWallComponent* wallComp = we_getWallComponent(context, entity); assert(wallComp); WarWallPieceList* pieces = &wallComp->pieces; WarWallPieceListRemove(pieces, *piece); } WarEntity* we_createWall(WarContext* context) { WarMap* map = context->map; WarWallPieceList pieces; WarWallPieceListInit(&pieces, WarWallPieceListDefaultOptions); WarEntity *entity = we_createEntity(context, WAR_ENTITY_TYPE_WALL, true); we_addWallComponent(context, entity, pieces); we_addSpriteComponent(context, entity, WAR_SPRITE_COMPONENT_INIT( .sprite = map->sprite )); return entity; } ================================================ FILE: todo.md ================================================ # TODO List of thing to do in no particular order ## Bugs * [x] Corpses can be selected, it shouldn't be. * [x] Black pixels in little tree and gold icons. * [x] Black pixels in the "% COMPLETE" text. * [x] If a building is damaged then it can't start a train of a unit because it can't have the two states running at the same time. * [x] The Damaged state of buildings was removed, the damage animations are set in the takeDamage function now the building can build/train while is damaged. * [x] When a building is being built dont show command buttons or command texts. * [x] When different buildings are collapsed in near positions, the ruins doesn't merge well. * [x] Check why is failing when trying to determine if the midi is finish playing. Check that the entity removes correctly after the midi finish playing. * [x] Arrows for scrolling on the windows edges instead of viewport edges. * [x] Cursor have a some pixels without transparency. * [x] Right click when a command that needs a target should cancel the command. * [x] Sounds are freed 3 times!, what's up with that? This was the result of deleting the entity and the engine trying to free the sprites associated with the sprite and button components. * [x] When executing a command with a multiple selection all units play the corresponding sound, it saturate the channel and it sounds horrible. * [x] The lastActionStep for the harvest action is the same for multiples frames. Investigate what is happening there to correctly chop the tree and play the chop sound. Do the same for the repairing state. * [x] Sounds of the goldmine? There is no sound for the goldmine. * [x] Selection rect green for friendly units, red for enemies and white for neutral. * [x] Editing trees, walls, roads and ruins doesn't check that the click was inside the map panel. * [x] In the minimap corpses are shown. * [x] WATER ELEMENTAL name go outside of portrait area. Change to WATER ELEM or W. ELEMENTAL * [x] Death animation of scorpions loops. * [x] Spell animation isn't shown. * [x] Mana of magic units don't increase over time. * [x] Use `tileInRange` to calculate near units? used in splash damage. * [x] Fix colors of Rain of Fire portrait * [x] Fix colors of Poison Cloud * [x] Fix orc maps tile displacements * [x] Deliver command (when click on button) is not working when unit have wood. * [x] Summoned units have mana and when its mana runs out they die. * [x] Check harvest right click vs command button when clicking on a dark area that is partially covering a goldmine. * [x] Assertion in determining ruin pieces hit when goldmine ran out of gold. * [x] Holy Sight doesn't mark the buildings as hasBeenSeen. * [x] When a menu is showing in the map scene, the player can still select units and buildings. * [x] Orcs UI is still the Humans. * [x] In the first level there shouldn't be a Lumbermill to build. * [x] Revisit the FEATURES enum, it should be like this (maybe do a solution like the `getUpgradeLevel` macro): * [x] Check clipping of audios, `value = clamp(value, INT16_MIN, INT16_MAX);` this line doesn't make much sense because value is a `s16` already. * [x] Fix decaying music when changing scenes. * [x] Fix fucsia color in the border of the map of the orcs * [x] Damage animations are rendered below units. * [x] Corpses are rendered above units. * [x] Select footman -> right click on a tree, and assertion is hit. * [x] Fix walking animation with follow behavior. Make it continuous intead of reseting piece of the path. * [x] Make highlights in text be a span of text instead of just one character. * [x] When changing scenes, it seems that part of the music of the previous scene keeps playing. This was due to a feature on TinySoundFont that makes a fade of the music. The solution I gave was to make the time of that fade short enough so there is not an issue. * [x] If a worker is selected and enter a mine, you can still give orders to him. * [x] Enemy units are shown in fog. * [x] Buildings like mines aren't show in the minimap in fog, but they are in unkwon when have one tile on fog. * [x] Attack on ground on fog, the units doesn't move. * [x] Attack on units on fog, the minimap and the unit goes out of fog for a frame. * [x] When selected and enemy that goes into fog, the unit keeps selected. * [x] Fix clicking buttons will flick the tooltip text on and off. * [x] Make a call to `sleep` instead of waiting in a cycle until the frame end. This will probably increase effiency and decrease CPU usage. I need a portable sleep function, maybe something like: ```c void msleep(s32 milliseconds) // cross-platform sleep function { #ifdef WIN32 // windows.h need to be include for this Sleep(milliseconds); #elif _POSIX_C_SOURCE >= 199309L // this is the posix call, _POSIX_C_SOURCE need to be defined struct timespec ts; ts.tv_sec = milliseconds / 1000; ts.tv_nsec = (milliseconds % 1000) * 1000000; nanosleep(&ts, NULL); #else // unistd.h need to be include for this usleep(milliseconds * 1000); #endif } ``` * [x] Search for files: HMAP01-12.war, LOSE1.WAR, OMAP01-12.WAR, WIN1.WAR. Recovered from * [x] When a unit is selected before dispear in the fog, the unit remains selected. The unit should be removed from the selection. * [x] When rendering multiline texts, if the last character of a line doesn't fit and it's a space, then the space will be rendered in the next line which causes missalignment in the left border of the text. * [x] When building roads the player needs to go back and click on the build road button again to build the next one. * [x] When attacking a wall, if the units isn't within range, it will walk to the piece's position without considering its range of attack. That's because move state is being used in this case, instead of follow when attacking an unit. * [x] Sounds should be dependent if the source is inside the viewport bounds. For example, the swords sounds shouldn't interrupt other sounds if the battle is far away from the viewport bounds. * [x] Check why this appear when trying to spell the Dark Vision: "This upgrade type 15 doesn't increase any value of the units (Not reproducible)". * [x] Summon spells summon as many units as mana allows. * [x] Check death animations of scorpions and spiders. * [x] When a unit is selected, say a warrior, and the cursor is over an enemy unit, it shows the magnifying glass because there is no active command and is expecting to select the foe unit when maybe it would be better to show a possible command like attack. The same occurs when a worker is selected and the mouse is over a goldmine. Maybe make a check about possible commands, and show the corresponding cursor, for these cases. * [x] When Sally Shears cheat is enabled and the disabled the goldmines are shown in the minimap, even though no units was near them. * [x] When selected an enemy unit, the cursor change to red or yello crosshair when hover another unit. * [x] Solve problem of corrupt text in stdout due to the audio thread and main thread printing stuff at the same time. Added code for mutex that intent to be cross-platform. * [x] Solve problem of removing entities from different threads. Audio thread and main thread remove entities that can result in corrupted lists since SHL libraries aren't thread-safe. * [x] Check the uses of `context->deltaTime` when the speed of the game is not `1`. * [x] Changing global speed doesn't change ongoing trainings. * [x] When changing music with the Music cheat, a long fade out of the song is played while the new one starts. * [x] When catapults are close enough to buildings and attack them, may destroy themselves because of the splash damage. * [x] When editing walls, if trap an enemy unit and order a friendly unit to attack it removing in the process a piece of the wall, the friendly unit can't get to the enemy unit. Probably because I'm not updating the pathfinder information when deleting pieces of walls. * [x] When "Ides of march" cheat is used behind the panel the actions and sounds continues. That shouldn't be. * [x] Selection rectangle are missing * [x] Progress rectangle is missing * [x] Cursor is too sensitive, and usually out of window area * [x] Cursor should stay at the edges of the window. Should I capture the mouse from the OS!? That would allow scrolling when the cursor is at the edge and the player keep moving the mouse in the direction of that edge. Right now the OS cursor shows up when the user move the game cursor outside the window. That's no good. * [x] Click in a button, drag to the map panel, it start the selection rect. This shouldn't be. * [x] In breafing scenes, the text looks behind animations, mainly because of the refactor in `wsc_renderScene`, where it draws all UI entities first, and then animations. * [x] Scrolling by moving the mouse to the border is not working anymore. * [x] Frame rate gets unacceptable in debug mode (~5 fps after a while and a few units created) * [x] MENU F10 tooltip overlaps if there a building training a soldier or worker saying "TRAINING ..." * [x] Cancel button tooltip is not showing * [x] FPS and dt information in the window title render every frame, hard to see actual framerate. Title should be updated every frame, but fps, dt and wait time only each second. Actual time and frame count should be updated every frame, tho. * [x] Magnifying glass to select units is not showing / cursor is not chaging * [x] Clicking Cancel button crash the game * [ ] When the last position of a segment is occupied and there is more segments, what should be the behavior? continue to next segment from the current position? stop? * [ ] Check for memory leaks in the removing animations functionality. * [ ] Check why the changing of the global scale renders with the previous global scale after a change (only on Linux, on Windows it doesn't happen). * [ ] When a unit attacks a unit that is attacking a building, the second unit should stop the attack on the building and attack the first unit. * [ ] If an unit is attacked when idle, the unit respond the attack. * [ ] Instead of Holy Sight/Dark Vision create an object, make the fog of war cells have more states like `MAP_STATE_ALWAYS_VISIBLE` and `MAP_STATE_TIMED_VISIBLE`. * [ ] Check if the `changeSampleRate` introduces the tiny pop bug at the end of short sounds. * [ ] Sometimes you order a worker to mine, and it will enter the mine (dissapear) but it doesn't perform the mining. You can also give other orders like move, and the invisible worker will go there and do other stuff.... on the bright side, I have invisible units! :D... But wait.. I already have invisible units with Invisibility spells..., damn! :( * [ ] Some lines in text appear on Windows and between sprites, antialiasing maybe on the OpenGL ES driver in Windows? * [ ] If a unit is selected and the player give several orders in a row quickly, the audio gets saturated. Maybe I can restrict how much audios are generated by units, maybe keep track of the last time the unit spoke or a sound is emitted from a unit, to not do it again in short periods of time. * [ ] Check this: , * [ ] I can hear the sounds of the enemy spawning and doing stuff * [ ] Cursor doesn't change when scrolling on screen edges * [ ] When building something, as soon as I place the item to build, the click will deselect the current unit (worker or building), it should remain selected. ## General * [x] Test the new implementation for lists. * [x] Make some or macros or inline functions to create options for lists initializations. * [x] Map scroll with the mouse cursor at the edge. * [x] Factorize state_machine.c in files (maybe `state_machine_update.c`, `state_machine_enter.c`, etc.). * [x] Walls (same system like roads). * [x] Make a better input system * [x] Map scrolling and positioning by clicking in the minimap is now all under `updateViewport` function. * [x] Selection drag is now all under `updateDragRect` function. * [x] Refactor right click code into a more robust order system. * [x] Make trees behavior * [x] Test different configurations and update the excel and the array of tree index to tile mappings. * [x] Make roads behavior like the trees. * [x] Make walls behavior like the trees. * [x] Make ruins behavior like the trees. * [x] Update minimap with chopped trees. * [x] Make a `setUITextFormat` method that takes a format with arguments `printf` style. * [x] Rename `WarUnitCommandBaseData` to something like `WarUnitCommandBaseData`. * [x] Show corresponding WIN or LOSE messages in game over menu. * [x] Skip briefing with click. * [x] Create EntityManager to manage entities. * [x] Draw text system (to debug and other texts). * [x] Sort the units by `y` position to render and the units with greater `y` render on top of the ones with less `y`. * [x] Make screen to download demo DATA.WAR file if it doesn't exists (the app should download it and install it itself). Download it from here: . To get there go to , then SHOW ALL in DOWNLOAD OPTIONS -> WCRFT.ZIP (View Contents). * [x] Make commands/cheats system. * [x] Original cheats * [x] Pot of Gold: Gives 10000 gold and 5000 lumber to the player * [x] Eye of newt: All spells are now be able to be casted * [x] Iron forge: Research all upgrades * [x] Ides of March: Brings player to final campaign sequence * [x] Corwin of Amber: Enables cheats * [x] There can be only one: Your units stop taking damage and deal 255 Damage * [x] Crushing defeat: Instant loss * [x] Sally Shears: Disables fog of war * [x] Human#: Skip to human level (enter 1-12 for #) * [x] Orc#: Skip to orc level (enter 1-12 for #) * [x] Hurry up guys: Speeds up building/unit production * [x] Yours truly: Win current mission * [x] Custom cheats * [x] Make global cheat command even in non-map scenes * [x] Music #: Set volume music (enter 1-45 for #) * [x] Music {on|off}: Enable or disable music * [x] Sound {on|off}: Enable or disable sounds * [x] Music volume #: Set volume of music (enter 0-100 for #) * [x] Sound volume #: Set volume of sounds (enter 0-100 for #) * [x] Scale #: Set global scale (enter 1-5 for #) * [x] Speed #: Set global speed (enter 1-5 for #) * [x] Change edition of trees to cheat * [x] Change edition of ruins to cheat * [x] Change edition of walls to cheat * [x] Change edition of roads to cheat * [x] Change edition of rain of fire to cheat * [x] Add unit cheat * [x] Make feedback for the cheats (the wascally wabbit notification?) * [x] Make sounds and music volume settings globally. That will allow to set volumes through cheats in any scene or map and mantain the setting through changing scenes. * [x] Make a profiler system. * [x] Remove global __log__ and move it to WarContext. How could I access the `__log__` inside `WarContext` in the `glfwErrorCallback` callback? C/ GLFW was changed by SLD3 and now log system uses SDL_log functions. * [ ] Write a detailed description of the actions system, maybe as comments in the `war_actions.c` file? * [ ] Manage components with a dictionary and not each entity having all the components. * [ ] Make so that entities can have multiple sprites. * [ ] Add a `renderAnimations` function to render the animations above everything else and move the corresponding code in `renderUnit` to the new function. * [ ] Add animation for the gold and lumber numbers when they change. * [ ] Make the blue water/green water animated. * [ ] Make the move state to consider range distance to stop. * [ ] Units like raised skeletons have a decay, that's that after a certain time, the unit dies. Check if summoned units have the same behavior. * [ ] Check behavior of invisible units when are under attack (it maybe work with workers, to stop the attack on it) * [ ] Zoom feature * [ ] Rewrite `appendCheatTextInput` and `downloadFileFromUrl` to use more String/StringView friendly implementation. * [ ] Add tests * [ ] Pathfinding (A\* correctness with known maps) * [ ] Damage calculation * [ ] Resource cost enforcement * [ ] State machine transitions * [ ] DATA.WAR file parsing * [ ] Use SLD_rand instead of rand ## Gameplay * [x] Add functionalities about players and player infos, gold and wood amount, upgrades, unit count, race, etc. * [x] Fix black areas in human unit portraits images. * [x] Add selected units back images. * [x] Add portraits to selected units. * [x] Remove pink pixels from unit portraits images. * [x] Add name to the unit portraits. * [x] Add life bar to the unit portraits. * [x] Add magic to the unit portraits. * [x] Add complete % bar only when there is something building. * [x] Add command images based on selected(s) unit types. * [x] Add upgrades info to player info. * [x] Manage the gold in the mines and explode it when the gold is over. * [x] Add ruins to collapsed buildings. * [x] Create and entity for each tile that represent wood in order to keep track of the amount of wood in each area and been able to replace with the appropiated sprite when the wood in that tile is over. * [x] Fix the selection of units to select only dude units or one building. * [x] Making health system for units. * [x] Change the behavior of chopping trees when multiple units are chopping the same tree. With each hack of the axe the tree should loose wood, until it ran out of it. Each unit go back to the townhall when has max amount of wood or there is no more trees to chop. * [x] If each tree island is considered a forest, then the workers naturally will chop the entire forest/island and stop there, but the editing trees functionality doesn't work for multiple forests/island. If there is a single forest in the map, then the unit will chop all the wood in the map, which is not desired. Figure out which way is better, and make the necessary changes. * [x] The solution implemented was that tree islands are forests, and in editing, just determine the tree tiles for each forest, because the edition a less used and slower funcionality and it doesn't matter too much if every tree is checked in each operation. * [x] Add functionality of training units. * [x] Fix upgrade build times. * [x] Make so that train units withdraw gold and lumber. * [x] Handle the case when there is no sufficient gold or lumber (put a message in the status bar). * [x] Add keyboard shortcuts to train units. * [x] Handle the case when there is no sufficient farm food for the new training (put a message in the status bar). * [x] Add functionality of building upgrades. * [x] Fix upgrade build times. * [x] Make so that build upgrades withdraw gold and lumber. * [x] Handle the case when there is no sufficient gold or lumber (put a message in the status bar). * [x] Make so that the upgrades increase the corresponding values for the damage, armor and so. * [x] Add keyboard shortcuts to build upgrades. * [x] Add functionality of building buildings. * [x] Make so that build buildings withdraw gold and lumber. * [x] Handle the case when there is no sufficient gold or lumber (put a message in the status bar). * [x] Add keyboard shortcuts to build buildings. * [x] Add functionality of basic commands. * [x] Move command * [x] Stop command * [x] Attack command * [x] Check that the selected units can attack the target unit. * [x] Attack on the ground. * [x] Harvest command * [x] Repair command * [x] Add functionality of spell commands. * [x] Summoning * [x] Rain of fire * [x] Cloud of poison * [x] Far seeing / Dark vision * [x] Invisibility * [x] UnHoly armor * [x] Healing * [x] Raise dead * [x] Fog of war * [x] Update fog of war once each second? Yes. * [x] Block selection clicks in fog region * [x] Block build in fog region * [x] Cursor changing when hover a foe unit that is in the fog * [x] Moving unit clears fog * [x] Attack at distance clears fog? Yes. * [x] Spells at distance clears fog? Yes. * [x] Holy Vision/Dark Vision spells clears fog * [x] Buildings can't be built on unknown areas * [x] Attacks on unknown areas always produce the unit to move to the attacking point, even ranges ones. * [x] Attackers reveals themselves when attacking a player's unit. * [x] Reveal attacked units? Yes. * [x] After a number of seconds (3 maybe?) an area without friendly units remain with fog. * [x] That is, buildings, roads, ruins, walls, trees are shown in the map, with a fade of fog. * [x] Moving units are not shown in areas with fog. * [x] Make custom games (this is for be able to develop the AI in a custom game and not in a campaign map) * [x] Make custom game menu scene * [x] Make functionality to start a custom game * [ ] Change the palette of the unit portraits depending on the tileset of the current map (building portraits looks different). * [ ] Add explosion animation to living npc units when clicking to many times. * [ ] Make Ctrl+click select all units of the same type on the screen. * [ ] Make feature to select a point where automatically the trained unit will go. ## Animations/actions * [x] Add animations data for each unit type. * [x] Add actions for the peasant and peon when carrying gold or wood. * [x] Add actions for the buildings. * [x] Add little damage, huge damage and collapse animations to buildings. * [x] Add animation system, again. * [x] Switch animations without reseting the new animation to the start. This will allow have one animation for each orientation of then switch to the correct one depending of the orientation but conserving the state. * [x] Change the concept of animations by a sequence of frames, to a more complex but powerful system of actions. Each unit can have several actions, which can have steps and the steps of the actions describe what the unit does. For example, this is the `Attack` action of the footman: ```c Attack={ "unbreakable begin", "frame 5", "wait 5", "frame 20", "wait 5", "frame 35", "attack", "sound sword attack", "wait 5", "frame 50", "wait 5", "frame 60", "wait 5", "wait 0", "frame 0", "wait 1", "unbreakable end", "frame 0", "wait 1" } ``` * [x] Projectiles * [x] Arrows * [x] Fireballs * [x] Rain of fire * [x] Move actions system to animations, again? :| The problem is, for example in the move action, that the state machine does the moving, the wait between action steps are almost the same within the actions, and what is needed in reality is the changing frame, maybe the unbreakable markers and the sounds. I don't know maybe keep it, but removing the moving steps only. C/ For now the actions system was simplified to remove the unbrakable and move steps, as they didn't represents anything meaninful in the code. ## State machine * [x] Idle state * [x] Move state * [x] When the last position of a path is occupied and the unit waits is period but then continue to the last position when isn't clear. * [x] Mark the pathfinding data with id of the units, so they can clear it appropiately when leaving states. * [x] Moving with multiple waypoints. * [x] When the last few positions in a path are occupied and the final position is no longer reachable, the unit should get to the closest position posible. * [x] Patrol state * [x] Patrol is a combination of move behaviors. * [x] Patrol with multiple waypoints. * [x] Follow state * [x] Follow other units. * [x] Attack state * [x] Attack the unit next to * [x] Move to attack the unit that is far * [x] Consider ranged and melee attacks * [x] Do damage * [x] Do damage to units. * [x] Do damage to buildings. * [x] Do damage with splash * [x] Catapults * [x] Rain of fire * [x] Cloud of poison * [x] Do damage with magic. * [x] Ground-attack state * [x] Ground-attack is a combination of move and look around behaviors to attack anyone in range while the unit is moving to the target. * [x] Damaged state (for buildings) * [x] Collapse state (for buildings) * [x] Spawn ruins after the collapse of a building. * [x] Check if the new spawning ruins could merge with a previous one. This occurs when a building is built above a ruins. * [x] Build state * [x] Gathering resources state * [x] Gathering gold. * [x] Gathering wood * [x] Make a Leave function when the states are leaving, and not just free them. Let that responsibility to the state itself. * [ ] Make the state switching system can return values when going back to the previous state. This will allow follow and move to return to previous state (such attack) that there is no path to the target, so the unit can go idle. * [ ] When an unit is going to attack another one, but can't reach it because of is blocked but other units, there is a loop between attack and follow states, because there is not mechanism to allow the follow state to tell the attack state that the target unit can't be reached, so the unit must go idle. * [ ] Remove the interval for state, each state machine updates every frame. I'm going to worry about performance issues that this may cause later. ## Pathfinding * [x] Add path finding algorithm to move the entities. * [x] Make BFS is implementation. * [x] Implement A* algorithm for pathfinding. * [x] Test the implementation of the A* algorithm for pathfinding. * [x] Update the map in each interation of the state machines to support updating the paths when moving units. * [x] Include the current position of the unit in the path to support the patrol behaviour. * [x] Manage the case when there is no path to a position. It should stay or should go the closest position? * [x] Optimize the path finding when the destination is unreachable (e.g. when the unit is moving to another unit's position) * [x] When right click in the minimap, the selected unit should go there. * [ ] Give greater cost to diagonal movements than to straight movements. Check these links for a heuristic function that considers diagonal cost: * [ ] Remove BFS implementation. * [ ] Check again the path finding stuff, because now the units will go for side edges of buildings when a corner is closest. * [ ] Workers don't collide well while harvesting wood or gold when near the townhall. ## AI * [ ] Make scripted AI ## UI system * [x] Buttons * [x] Text * [x] Images * [x] Make font of original warcraft. * [x] Make a bunch of screenshots and draw the font in pixel art. * [x] Make the system to draw text from a sprite of characters. * [x] Make font of menus. * [ ] Dialogues * [ ] Cut scenes * [ ] Minimap * [ ] The minimap has to consider: base layer, chopped wood layer, entities layer. The base layer doesn't change once the map is created, so each frame only add the tiles about chopped wood and entities (position and types).