
DSDL -DelphiのSDL? SDL3とその関連ライブラリの堅牢な機能を、スパインランタイムアニメーション、 MPEG-1ビデオ再生、 ZIPベースのI/Oサポートを安全な機能と拡張する機能と統合する強力なDelphi-Nativeフレームワークです。このライブラリは、開発者が最新の高性能2Dゲームとマルチメディアアプリケーションを効率的に構築できるように設計されています。
SDL_IOStreamインターフェイスを使用したシームレスな統合。使用事例:
使用事例:
.jsonおよび.atlasファイルをサポートします。使用事例:
使用事例:
使用事例:
リポジトリをクローンまたはダウンロードします。
git clone https://github.com/your-repo/dsdl.git
cd dsdlDelphiプロジェクトにライブラリファイルを追加します。
DSDL.pas (または関連するユニット)を含めます。プロジェクトをコンパイルして実行します。
ウィンドウの初期化、資産をロードし、フレームワークを使用する方法は次のとおりです。
SDLの初期化とウィンドウの作成
uses
DSDL;
var
Window: PSDL_Window;
Renderer: PSDL_Renderer;
begin
if SDL_Init(SDL_INIT_VIDEO) <> 0 then
Exit;
Window := SDL_CreateWindow( ' DSDL Window ' , 100 , 100 , 800 , 600 , SDL_WINDOW_SHOWN);
Renderer := SDL_CreateRenderer(Window, - 1 , SDL_RENDERER_ACCELERATED or SDL_RENDERER_PRESENTVSYNC);
// Your code goes here...
SDL_DestroyWindow(Window);
SDL_Quit;
end ;スパインアニメーションの読み込み
var
Atlas: PspAtlas;
SkeletonData: PspSkeletonData;
Drawable: PspSkeletonDrawable;
begin
Atlas := spAtlas_createFromFile( ' data/spineboy-pma.atlas ' , Renderer);
SkeletonData := spSkeletonJson_readSkeletonDataFile(Atlas, ' data/spineboy-pro.json ' );
Drawable := spSkeletonDrawable_create(SkeletonData);
Drawable^.Skeleton^.X := 400 ;
Drawable^.Skeleton^.Y := 500 ;
// Update and draw skeleton
spSkeletonDrawable_update(Drawable, DeltaTime, SP_PHYSICS_UPDATE);
spSkeletonDrawable_draw(Drawable, Renderer);
end ;MPEG-1ビデオを再生します
begin
// Load and play a video file from the ZIP archive.
SDL_LoadPlayVideoFromZipFile(LRenderer, ' Data.zip ' , ' res/videos/sample01.mpg ' , 0.1 , - 1 );
...
// Update video playback timing.
SDL_UpdateVideo(SDL_GetFramerateDuration());
...
// Render the video content.
SDL_RenderVideo(LRenderer, 0 , 0 , 0.5 );
end ;パスワードで保護されたzipファイルから読み取ります
var
LRenderer: PSDL_Renderer;
LTexture: PSDL_Texture;
begin
...
// Load an image texture from the ZIP archive.
LTexture := IMG_LoadTexture_IO(LRenderer, SDL_IOFromZipFile( ' Data.zip ' ,
' res/images/cute_kitten.jpg ' ), True);
...
SDL_DestroyTexture(LTexture);
end ; uses
DSDL;
var
LWindow: PSDL_Window; // Pointer to the SDL window.
LRenderer: PSDL_Renderer; // Pointer to the SDL renderer.
LAtlas: PspAtlas; // Atlas for Spine animation textures.
LSkeletonJson: PspSkeletonJson; // JSON parser for Spine skeleton data.
LSkeletonData: PspSkeletonData; // Spine skeleton data.
LAnimationStateData: PspAnimationStateData; // State data for animation transitions.
LDrawable: PspSkeletonDrawable; // Drawable object for the Spine skeleton.
LEvent: SDL_Event; // Event structure for SDL event handling.
LQuit: Boolean; // Flag to control the main loop.
LLastFrameTime, LNow: UInt64; // Variables for frame timing.
LDeltaTime: Double; // Time elapsed between frames.
begin
// Initialize SDL video subsystem.
if not SDL_Init(SDL_INIT_VIDEO) then
begin
Writeln( ' Error: ' , SDL_GetError); // Print SDL initialization error.
Exit; // Exit if initialization fails.
end ;
// Create an SDL window with the specified title and size.
LWindow := SDL_CreateWindow( ' DSDL: Load spine animation from file ' , 800 , 600 , 0 );
if LWindow = nil then
begin
Writeln( ' Error: ' , SDL_GetError); // Print window creation error.
SDL_Quit; // Clean up SDL resources.
Exit;
end ;
// Create an SDL renderer for the window with OpenGL backend.
LRenderer := SDL_CreateRenderer(LWindow, ' opengl ' );
if LRenderer = nil then
begin
Writeln( ' Error: ' , SDL_GetError); // Print renderer creation error.
SDL_DestroyWindow(LWindow); // Destroy the created window.
SDL_Quit; // Clean up SDL resources.
Exit;
end ;
// Load the Spine animation atlas.
LAtlas := spAtlas_createFromFile( ' res/spine/spineboy/spineboy-pma.atlas ' , LRenderer);
// Create a skeleton JSON parser and scale the skeleton.
LSkeletonJson := spSkeletonJson_create(LAtlas);
LSkeletonJson.scale := 0.5 ;
// Read skeleton data from the JSON file.
LSkeletonData := spSkeletonJson_readSkeletonDataFile(LSkeletonJson,
' res/spine/spineboy/spineboy-pro.json ' );
// Create animation state data and set default transition mix.
LAnimationStateData := spAnimationStateData_create(LSkeletonData);
LAnimationStateData.defaultMix := 0.2 ;
// Create a drawable skeleton object and set its initial position.
LDrawable := spSkeletonDrawable_create(LSkeletonData, LAnimationStateData);
LDrawable.usePremultipliedAlpha := - 1 ; // Enable premultiplied alpha.
LDrawable.skeleton^.x := 400 ; // Set X position.
LDrawable.skeleton^.y := 500 ; // Set Y position.
// Set the skeleton to its setup pose.
spSkeleton_setToSetupPose(LDrawable.skeleton);
// Perform an initial skeleton update.
spSkeletonDrawable_update(LDrawable, 0 , SP_PHYSICS_UPDATE);
// Set initial animation state: 'portal' followed by 'run' (looped).
spAnimationState_setAnimationByName(LDrawable.animationState, 0 , ' portal ' , 0 );
spAnimationState_addAnimationByName(LDrawable.animationState, 0 , ' run ' , - 1 , 0 );
// Initialize the quit flag and timing variables.
LQuit := False;
LLastFrameTime := SDL_GetPerformanceCounter;
// Main event loop.
while not LQuit do
begin
// Poll SDL events.
while SDL_PollEvent(@LEvent) do
begin
// Exit the loop if a quit event is detected.
if LEvent.& type = SDL_EVENT_QUIT then
begin
LQuit := True;
Break;
end ;
end ;
// Clear the screen with a specified color.
SDL_SetRenderDrawColor(LRenderer, 94 , 93 , 96 , 255 );
SDL_RenderClear(LRenderer);
// Calculate delta time (time between frames) for smooth animation.
LNow := SDL_GetPerformanceCounter;
LDeltaTime := (LNow - LLastFrameTime) / SDL_GetPerformanceFrequency;
LLastFrameTime := LNow;
// Update the skeleton animation based on delta time.
spSkeletonDrawable_update(LDrawable, LDeltaTime, SP_PHYSICS_UPDATE);
// Draw the updated skeleton on the renderer.
spSkeletonDrawable_draw(LDrawable, LRenderer);
// Present the rendered frame to the window.
SDL_RenderPresent(LRenderer);
end ;このプロジェクトでは、次のオープンソースライブラリを使用しています。
DSDLは? BSD-3-Clauseライセンス。特定の条件下で、変更の有無にかかわらず、ソースフォームとバイナリ形式の両方での再分配と使用を可能にします。詳細については、ライセンスファイルを参照してください。
メンテナーに感謝します:
DSDL、その機能、およびそのユースケースに関する詳細な議論を調べてください。
Zipfileからスパインアニメーションをロードします
Zipfileからのビデオ再生
DSDLへの貢献は強く奨励されています。お気軽に問題を提出したり、新機能を提案したり、スクリプトエンジンの機能と堅牢性を拡張するためのプルリクエストを作成してください。
DSDLを使用すると、堅牢で最新の2Dゲームとアプリケーションを簡単に構築できます。キャラクターのアニメーション化、ビデオのストリーミング、安全なリソースの管理など、 DSDLがカバーしています。 ?

Delphiで❤️で作られています