{"id":23254878,"url":"https://github.com/tinybiggames/dsdl","last_synced_at":"2025-09-03T00:49:31.976Z","repository":{"id":268461985,"uuid":"904434628","full_name":"tinyBigGAMES/DSDL","owner":"tinyBigGAMES","description":"SDL for Delphi","archived":false,"fork":false,"pushed_at":"2024-12-18T19:50:44.000Z","size":45741,"stargazers_count":15,"open_issues_count":0,"forks_count":2,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-08-27T14:47:52.751Z","etag":null,"topics":["2d-game-development","2d-game-framework","delphi","game-library","mpeg-1","pascal","sdl","sdl3","spine-animation","spine2d","win64","windows-10","windows-11","zip-archive"],"latest_commit_sha":null,"homepage":"","language":"Pascal","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tinyBigGAMES.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"github":"tinyBigGAMES","patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"lfx_crowdfunding":null,"polar":null,"buy_me_a_coffee":null,"thanks_dev":null,"custom":null}},"created_at":"2024-12-16T22:07:45.000Z","updated_at":"2025-08-24T13:57:10.000Z","dependencies_parsed_at":"2024-12-16T23:28:42.663Z","dependency_job_id":"cebbcd2d-f553-44a5-b1c7-e34234ce81c0","html_url":"https://github.com/tinyBigGAMES/DSDL","commit_stats":null,"previous_names":["tinybiggames/dsdl"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/tinyBigGAMES/DSDL","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tinyBigGAMES%2FDSDL","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tinyBigGAMES%2FDSDL/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tinyBigGAMES%2FDSDL/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tinyBigGAMES%2FDSDL/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tinyBigGAMES","download_url":"https://codeload.github.com/tinyBigGAMES/DSDL/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tinyBigGAMES%2FDSDL/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273372600,"owners_count":25093713,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-02T02:00:09.530Z","response_time":77,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["2d-game-development","2d-game-framework","delphi","game-library","mpeg-1","pascal","sdl","sdl3","spine-animation","spine2d","win64","windows-10","windows-11","zip-archive"],"created_at":"2024-12-19T11:17:36.228Z","updated_at":"2025-09-03T00:49:31.916Z","avatar_url":"https://github.com/tinyBigGAMES.png","language":"Pascal","readme":"![PLUS](media/dsdl.png)  \n[![Chat on Discord](https://img.shields.io/discord/754884471324672040?style=for-the-badge)](https://discord.gg/tPWjMwK)\n[![Follow on Bluesky](https://img.shields.io/badge/Bluesky-tinyBigGAMES-blue?style=for-the-badge\u0026logo=bluesky)](https://bsky.app/profile/tinybiggames.com)\n\n**DSDL** - SDL for Delphi 🎮 is a powerful **Delphi-native** framework that integrates the robust features of **SDL3** and its related libraries with enhanced capabilities like **Spine Runtime Animation**, **MPEG-1 Video Playback**, and **Secure ZIP-based I/O Support**. This library is designed to help developers build modern, high-performance **2D games** and **multimedia applications** efficiently.\n\n## Table of Contents 📖\n\n1. [🚀 Features](#features)\n2. [🏁 Getting Started](#getting-started)\n3. [🛠️ Installation](#installation)\n4. [📖 Usage Guide](#usage-guide)\n5. [🧩 Code Examples](#code-examples)\n6. [📚 Dependencies](#dependencies)\n7. [📄 License](#license)\n8. [🙌 Acknowledgements](#acknowledgements)\n9. [🤝 Contributing](#contributing)\n\n## Features\n\n### 1. **Password-Protected ZIP Support 📦**\n   - Read files (textures, audio, configurations, etc.) directly from password-protected ZIP archives.\n   - No need for pre-extraction, saving storage and time.\n   - Seamless integration using SDL's `SDL_IOStream` interface.\n\n**Use Case:**\n   - Load compressed assets in real-time while maintaining security.\n\n\n### 2. **MPEG-1 Video Playback 🎬**\n   - Play MPEG-1 videos with **real-time streaming** support directly from ZIP archives.\n   - Designed to be lightweight and optimized for minimal resource usage.\n   - Smooth integration with SDL's rendering pipeline.\n\n**Use Case:**\n   - In-game cutscenes, intro videos, or dynamic multimedia overlays.\n\n### 3. **Spine Animation Support 🦴**\n   - Full integration with Spine runtime for smooth, real-time **2D character animations**.\n   - Supports `.json` and `.atlas` files.\n   - Key Features:\n      - Dynamic animation states\n      - Smooth blending\n      - Clipping masks\n      - Premultiplied alpha transparency for crystal-clear visuals.\n\n**Use Case:**\n   - Create lively, animated characters and scenes with Spine-based animations.\n\n### 4. **Frame Rate Limiting and Timing Support ⏱️**\n   - Precise control over frame rate to ensure smooth and consistent performance.\n   - Synchronizes game logic updates with rendering cycles.\n   - Reduces CPU/GPU usage and enhances energy efficiency.\n\n**Use Case:**\n   - Develop applications that require stable frame rates and optimized performance.\n\n### 5. **Simplified SDL Utilities 🛠️**\n   - Enhanced helper routines for:\n      - Window creation\n      - Input handling\n      - Texture loading\n      - Error management\n   - Reduces boilerplate code and accelerates development.\n\n**Use Case:**\n   - Simplify the process of managing common tasks in SDL projects.\n\n## Getting Started\n\n### Prerequisites 📋\n\n- **Delphi 12 CE or higher** 🖥️\n- **Windows 10 or higher** 🪟\n- **Tested on Windows 11 64-bit (24H2), Delphi 12.2** ✅\n\n### Installation\n\n1. Clone or [download](https://github.com/tinyBigGAMES/DSDL/archive/refs/heads/main.zip) the repository:\n   ```bash\n   git clone https://github.com/your-repo/dsdl.git\n   cd dsdl\n   ```\n\n2. Add the library files to your Delphi project:\n   - Include the `DSDL.pas` (or relevant units) into your project source.\n   - SDL3 and other dependencies will be linked inside your executable.\n\n3. Compile and run your project.\n\n## Usage Guide\n\n### Basic Setup\n\nHere is how you initialize a window, load assets, and use the framework:\n\n1. **Initializing SDL and Creating a Window**\n   ```delphi\n   uses\n     DSDL;\n\n   var\n     Window: PSDL_Window;\n     Renderer: PSDL_Renderer;\n   begin\n     if SDL_Init(SDL_INIT_VIDEO) \u003c\u003e 0 then\n       Exit;\n\n     Window := SDL_CreateWindow('DSDL Window', 100, 100, 800, 600, SDL_WINDOW_SHOWN);\n     Renderer := SDL_CreateRenderer(Window, -1, SDL_RENDERER_ACCELERATED or SDL_RENDERER_PRESENTVSYNC);\n\n     // Your code goes here...\n\n     SDL_DestroyWindow(Window);\n     SDL_Quit;\n   end;\n   ```\n\n2. **Loading Spine Animations**\n   ```delphi\n   var\n     Atlas: PspAtlas;\n     SkeletonData: PspSkeletonData;\n     Drawable: PspSkeletonDrawable;\n   begin\n     Atlas := spAtlas_createFromFile('data/spineboy-pma.atlas', Renderer);\n     SkeletonData := spSkeletonJson_readSkeletonDataFile(Atlas, 'data/spineboy-pro.json');\n     Drawable := spSkeletonDrawable_create(SkeletonData);\n\n     Drawable^.Skeleton^.X := 400;\n     Drawable^.Skeleton^.Y := 500;\n\n     // Update and draw skeleton\n     spSkeletonDrawable_update(Drawable, DeltaTime, SP_PHYSICS_UPDATE);\n     spSkeletonDrawable_draw(Drawable, Renderer);\n   end;\n   ```\n\n3. **Playing MPEG-1 Videos**\n   ```delphi\n   begin\n    // Load and play a video file from the ZIP archive.\n    SDL_LoadPlayVideoFromZipFile(LRenderer, 'Data.zip', 'res/videos/sample01.mpg', 0.1, -1);\n    \n     ...  \n     // Update video playback timing.\n     SDL_UpdateVideo(SDL_GetFramerateDuration());\n\n     ...\n     // Render the video content.\n     SDL_RenderVideo(LRenderer, 0, 0, 0.5);\n     \n   end;\n   ```\n\n4. **Reading from Password-Protected ZIP Files**\n   ```delphi\n   var\n     LRenderer: PSDL_Renderer;\n     LTexture: PSDL_Texture;\n   begin\n     ...  \n     // Load an image texture from the ZIP archive.\n     LTexture := IMG_LoadTexture_IO(LRenderer, SDL_IOFromZipFile('Data.zip',\n       'res/images/cute_kitten.jpg'), True);\n\n     ...\n     SDL_DestroyTexture(LTexture);\n   end;\n   ```\n\n## Code Examples\n\n### Full Spine Animation Example\n```delphi  \nuses\n  DSDL;\n  \nvar\n  LWindow: PSDL_Window;                  // Pointer to the SDL window.\n  LRenderer: PSDL_Renderer;              // Pointer to the SDL renderer.\n  LAtlas: PspAtlas;                      // Atlas for Spine animation textures.\n  LSkeletonJson: PspSkeletonJson;        // JSON parser for Spine skeleton data.\n  LSkeletonData: PspSkeletonData;        // Spine skeleton data.\n  LAnimationStateData: PspAnimationStateData; // State data for animation transitions.\n  LDrawable: PspSkeletonDrawable;        // Drawable object for the Spine skeleton.\n  LEvent: SDL_Event;                     // Event structure for SDL event handling.\n  LQuit: Boolean;                        // Flag to control the main loop.\n  LLastFrameTime, LNow: UInt64;          // Variables for frame timing.\n  LDeltaTime: Double;                    // Time elapsed between frames.\nbegin\n  // Initialize SDL video subsystem.\n  if not SDL_Init(SDL_INIT_VIDEO) then\n  begin\n    Writeln('Error: ', SDL_GetError); // Print SDL initialization error.\n    Exit; // Exit if initialization fails.\n  end;\n\n  // Create an SDL window with the specified title and size.\n  LWindow := SDL_CreateWindow('DSDL: Load spine animation from file', 800, 600, 0);\n  if LWindow = nil then\n  begin\n    Writeln('Error: ', SDL_GetError); // Print window creation error.\n    SDL_Quit; // Clean up SDL resources.\n    Exit;\n  end;\n\n  // Create an SDL renderer for the window with OpenGL backend.\n  LRenderer := SDL_CreateRenderer(LWindow, 'opengl');\n  if LRenderer = nil then\n  begin\n    Writeln('Error: ', SDL_GetError); // Print renderer creation error.\n    SDL_DestroyWindow(LWindow);       // Destroy the created window.\n    SDL_Quit;                         // Clean up SDL resources.\n    Exit;\n  end;\n\n  // Load the Spine animation atlas.\n  LAtlas := spAtlas_createFromFile('res/spine/spineboy/spineboy-pma.atlas', LRenderer);\n\n  // Create a skeleton JSON parser and scale the skeleton.\n  LSkeletonJson := spSkeletonJson_create(LAtlas);\n  LSkeletonJson.scale := 0.5;\n\n  // Read skeleton data from the JSON file.\n  LSkeletonData := spSkeletonJson_readSkeletonDataFile(LSkeletonJson,\n    'res/spine/spineboy/spineboy-pro.json');\n\n  // Create animation state data and set default transition mix.\n  LAnimationStateData := spAnimationStateData_create(LSkeletonData);\n  LAnimationStateData.defaultMix := 0.2;\n\n  // Create a drawable skeleton object and set its initial position.\n  LDrawable := spSkeletonDrawable_create(LSkeletonData, LAnimationStateData);\n  LDrawable.usePremultipliedAlpha := -1; // Enable premultiplied alpha.\n  LDrawable.skeleton^.x := 400;         // Set X position.\n  LDrawable.skeleton^.y := 500;         // Set Y position.\n\n  // Set the skeleton to its setup pose.\n  spSkeleton_setToSetupPose(LDrawable.skeleton);\n\n  // Perform an initial skeleton update.\n  spSkeletonDrawable_update(LDrawable, 0, SP_PHYSICS_UPDATE);\n\n  // Set initial animation state: 'portal' followed by 'run' (looped).\n  spAnimationState_setAnimationByName(LDrawable.animationState, 0, 'portal', 0);\n  spAnimationState_addAnimationByName(LDrawable.animationState, 0, 'run', -1, 0);\n\n  // Initialize the quit flag and timing variables.\n  LQuit := False;\n  LLastFrameTime := SDL_GetPerformanceCounter;\n\n  // Main event loop.\n  while not LQuit do\n  begin\n    // Poll SDL events.\n    while SDL_PollEvent(@LEvent) do\n    begin\n      // Exit the loop if a quit event is detected.\n      if LEvent.\u0026type = SDL_EVENT_QUIT then\n      begin\n        LQuit := True;\n        Break;\n      end;\n    end;\n\n    // Clear the screen with a specified color.\n    SDL_SetRenderDrawColor(LRenderer, 94, 93, 96, 255);\n    SDL_RenderClear(LRenderer);\n\n    // Calculate delta time (time between frames) for smooth animation.\n    LNow := SDL_GetPerformanceCounter;\n    LDeltaTime := (LNow - LLastFrameTime) / SDL_GetPerformanceFrequency;\n    LLastFrameTime := LNow;\n\n    // Update the skeleton animation based on delta time.\n    spSkeletonDrawable_update(LDrawable, LDeltaTime, SP_PHYSICS_UPDATE);\n\n    // Draw the updated skeleton on the renderer.\n    spSkeletonDrawable_draw(LDrawable, LRenderer);\n\n    // Present the rendered frame to the window.\n    SDL_RenderPresent(LRenderer);\n  end;\n```\n\n## Dependencies\n\nThis project uses the following open-source libraries:\n- [pl_mpeg](https://github.com/phoboslab/pl_mpeg)\n- [SDL](https://github.com/libsdl-org/SDL)\n- [SDL_image](https://github.com/libsdl-org/SDL_image)\n- [SDL_mixer](https://github.com/libsdl-org/SDL_mixer)\n- [SDL_net](https://github.com/libsdl-org/SDL_net)\n- [SDL_ttf](https://github.com/libsdl-org/SDL_ttf)\n- [Spine Runtimes](https://github.com/EsotericSoftware/spine-runtimes)\n- [zlib](https://github.com/madler/zlib)\n\n## License\n\n**DSDL** is distributed under the 🆓 **BSD-3-Clause License**, allowing for redistribution and use in both source and binary forms, with or without modification, under specific conditions. See the [LICENSE](https://github.com/tinyBigGAMES/DSDL?tab=BSD-3-Clause-1-ov-file#BSD-3-Clause-1-ov-file) file for more details.\n\n## Acknowledgements\n\nSpecial thanks to the maintainers of:\n- **Esoteric Software** for Spine Runtime\n- **SDL** team for providing an amazing multimedia library\n- **Open-source contributors** for pl_mpeg, zlib, and SDL extensions.\n\n## Media\n\n### Podcast Deep Dive\nExplore the in-depth discussion about DSDL, its features, and its use cases.\n\nhttps://github.com/user-attachments/assets/8d735ed7-a765-4da2-8a81-be8cc1b5a3fc\n\n### Extensions\nLoad spine animation from zipfile\n\nhttps://github.com/user-attachments/assets/3f3d4aae-7db4-46b5-9f1b-56247077d94b\n\nVideo Playback from zipfile\n\nhttps://github.com/user-attachments/assets/90805b12-2cc7-47be-9a26-f70e26da0b0b\n\n\n## Contributing\n\nContributions to **DSDL** are highly encouraged. Please feel free to submit issues, suggest new features, or create pull requests to expand the capabilities and robustness of the scripting engine.\n\n\n## Support\n\n- \u003ca href=\"https://github.com/tinyBigGAMES/DSDL/issues\" target=\"_blank\"\u003eIssues\u003c/a\u003e\n- \u003ca href=\"https://github.com/tinyBigGAMES/DSDL/discussions\" target=\"_blank\"\u003eDiscussions\u003c/a\u003e\n- \u003ca href=\"https://wiki.libsdl.org/SDL3/FrontPage/\" target=\"_blank\"\u003eSDL Wiki\u003c/a\u003e\n- \u003ca href=\"https://learndelphi.org/\" target=\"_blank\"\u003eLearn Delphi\u003c/a\u003e\n---\nWith **DSDL**, you can build robust, modern 2D games and applications effortlessly. Whether you're animating characters, streaming videos, or managing secure resources, **DSDL** has you covered! 🎮🚀\n\n\u003cp align=\"center\"\u003e\n\u003cimg src=\"media/delphi.png\" alt=\"Delphi\"\u003e\n\u003c/p\u003e\n\u003ch5 align=\"center\"\u003e\n\nMade with :heart: in Delphi\n\u003c/h5\u003e\n\n\n","funding_links":["https://github.com/sponsors/tinyBigGAMES"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftinybiggames%2Fdsdl","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftinybiggames%2Fdsdl","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftinybiggames%2Fdsdl/lists"}