-
Notifications
You must be signed in to change notification settings - Fork 0
/
example.cpp
78 lines (63 loc) · 1.56 KB
/
example.cpp
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
import sdl.SDL;
int main(int, char **)
{
if (sdl::Init(sdl::InitFlags::VIDEO) != 0)
{
sdl::ShowSimpleMessageBox(
sdl::MessageBoxFlags::ERROR,
"Error",
"Failed to initialize SDL",
nullptr
);
return 1;
}
auto window = sdl::CreateWindow(
"Hello world!",
640, 480,
sdl::WindowFlags::OPENGL
);
if (window == nullptr)
{
sdl::ShowSimpleMessageBox(
sdl::MessageBoxFlags::ERROR,
"Error",
"Failed to create window",
nullptr
);
return 1;
}
auto renderer = sdl::CreateRenderer(window, nullptr);
if (renderer == nullptr)
{
sdl::ShowSimpleMessageBox(
sdl::MessageBoxFlags::ERROR,
"Error",
"Failed to create renderer",
nullptr
);
return 1;
}
sdl::Event event;
bool running = true;
while (running)
{
while (sdl::PollEvent(&event))
{
if (event.type == sdl::EventType::QUIT)
{
running = false;
}
}
sdl::SetRenderDrawColor(renderer, 0, 0, 0, 255);
sdl::RenderClear(renderer);
sdl::SetRenderDrawColor(renderer, 255, 255, 255, 255);
sdl::RenderLine(renderer, 320, 240, 400, 300);
sdl::RenderPresent(renderer);
sdl::Delay(16);
}
// this is still manual for now :(
sdl::DestroyRenderer(renderer);
sdl::DestroyWindow(window);
sdl::Quit();
return 0;
}