-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
48 lines (40 loc) · 1.41 KB
/
main.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
#include <iostream>
#include <SDL.h>
#include <SDL2_LOVES_CMAKEConfig.hpp>
const int SCREEN_WIDTH = 1280;
const int SCREEN_HEIGHT = 720;
int main(int argc, char* args[]) {
std::cout << "Version: " << SDL2_LOVES_CMAKE_VERSION_MAJOR << "." << SDL2_LOVES_CMAKE_VERSION_MINOR << std::endl;
SDL_Window* window = nullptr;
SDL_Surface* screenSurface = nullptr;
if (SDL_Init(SDL_INIT_VIDEO) < 0) {
std::cout << "SDL couldn't init video: " << SDL_GetError() << std::endl;
} else {
window = SDL_CreateWindow("SDL2 Window", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, SCREEN_WIDTH, SCREEN_HEIGHT, SDL_WINDOW_SHOWN);
if (window == nullptr) {
std::cout << "Window couldn't be created: " << SDL_GetError() << std::endl;
} else {
screenSurface = SDL_GetWindowSurface(window);
SDL_FillRect(screenSurface, nullptr, SDL_MapRGB(screenSurface->format, 0x00, 0xFF, 0xFF));
SDL_UpdateWindowSurface(window);
}
}
SDL_Event e;
bool quit = false;
while (!quit){
while (SDL_PollEvent(&e)){
if (e.type == SDL_QUIT){
quit = true;
}
if (e.type == SDL_KEYDOWN){
quit = true;
}
if (e.type == SDL_MOUSEBUTTONDOWN){
quit = true;
}
}
}
SDL_DestroyWindow(window);
SDL_Quit();
return 0;
}