-
-
Notifications
You must be signed in to change notification settings - Fork 457
Expand file tree
/
Copy pathProgram.cs
More file actions
42 lines (36 loc) · 994 Bytes
/
Program.cs
File metadata and controls
42 lines (36 loc) · 994 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using Silk.NET.SDL;
if (!Sdl.Init(Sdl.InitVideo))
{
throw new Exception($"SDL failed to initialize: {Sdl.GetError().ReadToString()}");
}
var window = Sdl.CreateWindow("Silk.NET.SDL - Hello Window", 800, 600, Sdl.WindowResizable);
if (window == nullptr)
{
throw new Exception("Failed to create window");
}
try
{
var renderer = Sdl.CreateRenderer(window, nullptr);
{
var shouldRun = true;
while (shouldRun)
{
var e = default(Event);
Sdl.PollEvent(e.AsRef());
if (e.Type == (uint)EventType.Quit)
{
shouldRun = false;
}
Sdl.SetRenderDrawColor(renderer, 0, 255, 0, 255);
Sdl.RenderClear(renderer);
Sdl.RenderPresent(renderer);
}
}
Sdl.DestroyWindow(window);
}
finally
{
Sdl.Quit();
}