2024-01-26 05:37:51 +00:00
|
|
|
using SDL2;
|
|
|
|
|
|
|
|
namespace KumiScript.Renderer
|
|
|
|
{
|
2024-07-12 00:17:00 +00:00
|
|
|
public class SDLRenderer : IDisposable
|
2024-01-26 05:37:51 +00:00
|
|
|
{
|
|
|
|
internal readonly nint id;
|
|
|
|
internal SDLRenderer(SDLWindow window)
|
|
|
|
{
|
2024-07-12 00:17:00 +00:00
|
|
|
id = SDL.SDL_CreateRenderer(window.Id, -1, SDL.SDL_RendererFlags.SDL_RENDERER_ACCELERATED | SDL.SDL_RendererFlags.SDL_RENDERER_PRESENTVSYNC);
|
2024-01-26 05:37:51 +00:00
|
|
|
if (id == 0)
|
|
|
|
throw new Exception("Failed to create renderer!");
|
|
|
|
}
|
|
|
|
|
|
|
|
public void Clear()
|
|
|
|
{
|
|
|
|
SDL.SDL_RenderClear(id);
|
|
|
|
}
|
|
|
|
|
2024-07-12 00:17:00 +00:00
|
|
|
public void Dispose()
|
|
|
|
{
|
|
|
|
SDL.SDL_DestroyRenderer(id);
|
|
|
|
}
|
|
|
|
|
2024-01-26 05:37:51 +00:00
|
|
|
public void SwapBuffers()
|
|
|
|
{
|
|
|
|
SDL.SDL_RenderPresent(id);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|