KumiScript/renderer/sdl/SDLWindow.cs
2024-01-25 23:37:51 -06:00

39 lines
No EOL
1.1 KiB
C#

using SDL2;
namespace KumiScript.Renderer
{
public class SDLWindow
{
internal readonly nint Id;
ushort _width;
ushort _height;
string _title;
SDLRenderer? _renderer;
public SDLWindow(ushort horizontalResolution, ushort verticalResolution, string windowTitle)
{
_width = horizontalResolution;
_height = verticalResolution;
_title = windowTitle;
nint window = SDL.SDL_CreateWindow(windowTitle, SDL.SDL_WINDOWPOS_CENTERED, SDL.SDL_WINDOWPOS_CENTERED,
horizontalResolution, verticalResolution, 0);
if (window == 0)
throw new Exception("Failed to create window!");
Id = window;
}
public int UpdateSurface()
{
return SDL.SDL_UpdateWindowSurface(Id);
}
public SDLRenderer GetRenderer()
{
if (_renderer is null)
_renderer = new SDLRenderer(this);
return _renderer;
}
}
}