-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathwslsdlexample.cpp
More file actions
39 lines (33 loc) · 773 Bytes
/
wslsdlexample.cpp
File metadata and controls
39 lines (33 loc) · 773 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
#include <iostream>
#include <SDL.h>
int main(int argc, char *argv[]) {
if(SDL_Init(SDL_INIT_EVERYTHING) != 0) {
std::cout << "error:" << SDL_GetError() << std::endl;
}
SDL_Window* w;
SDL_Renderer* r;
w = SDL_CreateWindow("WSL SDL Example",
SDL_WINDOWPOS_CENTERED,
SDL_WINDOWPOS_CENTERED,
600, 600, 0);
r = SDL_CreateRenderer(w, -1, 0);
// Draw
SDL_SetRenderDrawColor(r, 0, 0, 0, 0);
SDL_RenderClear(r);
SDL_SetRenderDrawColor(r, 0, 255, 0, 255);
for(int i = 0; i < 600; i++) {
SDL_RenderDrawPoint(r, i, i);
}
SDL_RenderPresent(r);
// Wait
SDL_Event e;
while(1) {
if(SDL_PollEvent(&e) && (e.type == SDL_QUIT || e.type == SDL_KEYDOWN))
break;
};
// Clean up
SDL_DestroyRenderer(r);
SDL_DestroyWindow(w);
SDL_Quit();
return 0;
}