Skip to content

Commit 3769c5c

Browse files
committed
SDL skeleton
1 parent c930dc8 commit 3769c5c

File tree

1 file changed

+43
-1
lines changed

1 file changed

+43
-1
lines changed

src/main.cpp

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,49 @@
33
#include <iostream>
44
using namespace std;
55

6+
SDL_Window* win = NULL;
7+
SDL_Surface* surface = NULL;
8+
SDL_Renderer* render = NULL;
9+
10+
const int WIDTH = 800;
11+
const int HEIGHT = 600;
12+
13+
void init() {
14+
SDL_Init(SDL_INIT_VIDEO);
15+
win = SDL_CreateWindow("SYCL Crowd Simulation", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, WIDTH, HEIGHT, SDL_WINDOW_SHOWN);
16+
render = SDL_CreateRenderer(win, -1, SDL_RENDERER_ACCELERATED);
17+
}
18+
19+
void draw() {
20+
SDL_SetRenderDrawColor(render, 255, 255, 255, 255);
21+
SDL_RenderClear(render);
22+
23+
SDL_RenderPresent(render);
24+
}
25+
26+
void close() {
27+
SDL_DestroyWindow(win);
28+
SDL_Quit();
29+
}
30+
631
int main() {
7-
cout << "Hello World!!";
32+
init();
33+
34+
draw();
35+
36+
bool isQuit = false;
37+
SDL_Event event;
38+
39+
while(!isQuit) {
40+
if (SDL_PollEvent(&event)) {
41+
if (event.type == SDL_QUIT) {
42+
isQuit = true;
43+
}
44+
}
45+
46+
draw();
47+
}
48+
49+
close();
850
return 0;
951
}

0 commit comments

Comments
 (0)