-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhello.cpp
More file actions
59 lines (49 loc) · 1.36 KB
/
Copy pathhello.cpp
File metadata and controls
59 lines (49 loc) · 1.36 KB
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
#include <SDL2/SDL.h>
#include <SDL_error.h>
#include <SDL_events.h>
#include <SDL_pixels.h>
#include <SDL_surface.h>
#include <SDL_video.h>
#include <cstdlib>
#include <iostream>
using namespace std;
const int SCREEN_WIDTH = 640;
const int SCREEN_HEIGHT = 480;
int main(int argc, char *args[]) {
cout << "Starting.." << endl;
// The rendering window
SDL_Window *window = NULL;
// The surfaced contained by the window
SDL_Surface *screenSurface = NULL;
// Init SDL
if (SDL_Init(SDL_INIT_VIDEO) < 0) {
cout << "SDL count not be initialized" << SDL_GetError() << endl;
return EXIT_FAILURE;
}
// Create window
window =
SDL_CreateWindow("SDL", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED,
SCREEN_WIDTH, SCREEN_HEIGHT, SDL_WINDOW_SHOWN);
if (window == NULL) {
cout << "Window could not be create: SDL ERROR " << SDL_GetError() << endl;
SDL_Quit();
return EXIT_FAILURE;
}
// Get window surface
screenSurface = SDL_GetWindowSurface(window);
SDL_FillRect(screenSurface, NULL,
SDL_MapRGB(screenSurface->format, 0xFF, 0xFF, 0xFF));
SDL_UpdateWindowSurface(window);
SDL_Event e;
bool quit = false;
while (quit == false) {
while (SDL_PollEvent(&e) != 0) {
if (e.type == SDL_QUIT) {
quit = true;
}
}
}
SDL_DestroyWindow(window);
SDL_Quit();
return 0;
}