mirror of
https://github.com/MaddyThorson/StrawberryBF.git
synced 2025-12-15 13:27:06 +08:00
Simple font loading and rendering
This commit is contained in:
@ -99,5 +99,18 @@ namespace Strawberry
|
||||
SDL.SetTextureBlendMode(sprite[frame].Texture, .Blend);
|
||||
SDL.RenderCopyEx(Game.Renderer, sprite[frame].Texture, &src, &dst, rotation, &cnt, .None);
|
||||
}
|
||||
|
||||
static public void Text(Strawberry.Font font, String text, Point position, Color color)
|
||||
{
|
||||
SDL.SetRenderDrawColor(Game.Renderer, color.R, color.G, color.B, color.A);
|
||||
let surface = SDLTTF.RenderUTF8_Blended(font.Font, text, color);
|
||||
let texture = SDL.CreateTextureFromSurface(Game.Renderer, surface);
|
||||
|
||||
SDL.Rect srcRect = .(0, 0, surface.w, surface.h);
|
||||
SDL.Rect destRect = .((int32)position.X, (int32)position.Y, surface.w, surface.h);
|
||||
SDL.RenderCopy(Game.Renderer, texture, &srcRect, &destRect);
|
||||
SDL.FreeSurface(surface);
|
||||
SDL.DestroyTexture(texture);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user