Skip to content

Commit bb1a161

Browse files
committed
Initial
0 parents  commit bb1a161

File tree

7 files changed

+834
-0
lines changed

7 files changed

+834
-0
lines changed

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "extlibs/libSDL2pp"]
2+
path = extlibs/libSDL2pp
3+
url = git://github.com/AMDmi3/libSDL2pp.git

.travis.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
language: cpp
2+
compiler:
3+
- gcc
4+
- clang
5+
before_install:
6+
- sudo add-apt-repository --yes ppa:zoogie/sdl2-snapshots
7+
- sudo add-apt-repository --yes ppa:ubuntu-toolchain-r/test
8+
- sudo apt-get update -qq
9+
- sudo apt-get install -qq cmake libsdl2-dev libsdl2-image-dev g++-4.8
10+
- sudo sed -i -e 's|friend class hash|friend struct hash|' /usr/include/c++/4.8/bits/stl_bvector.h
11+
- if [ "$CXX" = "g++" ]; then export CXX="g++-4.8" CC="gcc-4.8"; fi
12+
script:
13+
- cmake -DCMAKE_CXX_FLAGS=-Werror .
14+
- make

CMakeLists.txt

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
PROJECT(FIXME_PROJECT)
2+
3+
# meta
4+
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
5+
6+
# flags
7+
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -Wextra -pedantic")
8+
9+
# depends
10+
IF(NOT EXISTS ${PROJECT_SOURCE_DIR}/extlibs/libSDL2pp/CMakeLists.txt)
11+
MESSAGE(FATAL_ERROR "The source directory\n ${PROJECT_SOURCE_DIR}/extlibs/libSDL2pp\ndoes not contain a CMakeLists.txt file.\nIt is likely that you forgot to run\n git submodule init && git submodule update")
12+
ENDIF(NOT EXISTS ${PROJECT_SOURCE_DIR}/extlibs/libSDL2pp/CMakeLists.txt)
13+
14+
SET(SDL2PP_WITH_IMAGE TRUE)
15+
SET(SDL2PP_WITH_TTF TRUE)
16+
ADD_SUBDIRECTORY(extlibs/libSDL2pp)
17+
18+
# datadir
19+
ADD_DEFINITIONS(-DDATADIR="${PROJECT_SOURCE_DIR}/data")
20+
21+
# sources
22+
SET(FIXME_PROJECT_SOURCES
23+
main.cc
24+
)
25+
26+
SET(FIXME_PROJECT_HEADERS
27+
)
28+
29+
# binary
30+
INCLUDE_DIRECTORIES(SYSTEM ${SDL2PP_INCLUDE_DIRS})
31+
ADD_EXECUTABLE(FIXME_PROGNAME ${FIXME_PROJECT_SOURCES} ${FIXME_PROJECT_HEADERS})
32+
TARGET_LINK_LIBRARIES(FIXME_PROGNAME ${SDL2PP_LIBRARIES})

COPYING

Lines changed: 674 additions & 0 deletions
Large diffs are not rendered by default.

README.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# FIXME_NAME
2+
3+
[![Build Status](https://travis-ci.org/FIXME_USER/FIXME_PROJECT.svg?branch=master)](https://travis-ci.org/FIXME_USER/FIXME_PROJECT)
4+
5+
FIXME_DESCRIPTION
6+
7+
## Building
8+
9+
Dependencies:
10+
11+
* cmake
12+
* SDL2
13+
* SDL2_image
14+
15+
The project also uses libSDL2pp, C++11 bindings library for SDL2.
16+
It's included into git repository as a submodule, so if you've
17+
obtained source through git, don't forget to run ```git submodule
18+
init && git submodule update```.
19+
20+
To build the project, run:
21+
22+
```
23+
cmake . && make
24+
```
25+
26+
## Author
27+
28+
* [FIXME_NAME](https://github.com/FIXME_USER) <FIXME_EMAIL>
29+
30+
## License
31+
32+
GPLv3 or later, see COPYING
33+
34+
The project also bundles third party software under its own licenses:
35+
36+
* extlibs/libSDL2pp (C++11 SDL2 wrapper library) - zlib license

extlibs/libSDL2pp

Submodule libSDL2pp added at 0834e48

main.cc

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
/*
2+
* Copyright (C) YEAR NAME
3+
*
4+
* This file is part of FIXME_NAME.
5+
*
6+
* FIXME_NAME is free software: you can redistribute it and/or modify
7+
* it under the terms of the GNU General Public License as published by
8+
* the Free Software Foundation, either version 3 of the License, or
9+
* (at your option) any later version.
10+
*
11+
* FIXME_NAME is distributed in the hope that it will be useful,
12+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
* GNU General Public License for more details.
15+
*
16+
* You should have received a copy of the GNU General Public License
17+
* along with FIXME_NAME. If not, see <http://www.gnu.org/licenses/>.
18+
*/
19+
20+
#include <iostream>
21+
#include <string>
22+
23+
#include <SDL2/SDL.h>
24+
25+
#include <SDL2pp/SDL.hh>
26+
#include <SDL2pp/Window.hh>
27+
#include <SDL2pp/Renderer.hh>
28+
29+
int main(int /*argc*/, char** /*argv*/) try {
30+
// SDL stuff
31+
SDL2pp::SDL sdl(SDL_INIT_VIDEO);
32+
SDL2pp::Window window("FIXME_TITLE", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 640, 480, SDL_WINDOW_RESIZABLE);
33+
SDL2pp::Renderer renderer(window, -1, SDL_RENDERER_ACCELERATED);
34+
35+
unsigned int prev_ticks = SDL_GetTicks();
36+
37+
// Main loop
38+
while (1) {
39+
unsigned int frame_ticks = SDL_GetTicks();
40+
unsigned int frame_delta = frame_ticks - prev_ticks;
41+
prev_ticks = frame_ticks;
42+
43+
// Process events
44+
SDL_Event event;
45+
while (SDL_PollEvent(&event)) {
46+
if (event.type == SDL_QUIT) {
47+
return 0;
48+
} else if (event.type == SDL_KEYDOWN) {
49+
switch (event.key.keysym.sym) {
50+
case SDLK_ESCAPE: case SDLK_q:
51+
return 0;
52+
}
53+
}
54+
}
55+
56+
// Render
57+
renderer.SetDrawColor(0, 0, 0);
58+
renderer.Clear();
59+
60+
renderer.Present();
61+
62+
// Frame limiter
63+
SDL_Delay(1);
64+
}
65+
66+
return 0;
67+
} catch (std::exception& e) {
68+
std::cerr << "Error: " << e.what() << std::endl;
69+
return 1;
70+
} catch (...) {
71+
std::cerr << "Unknown error" << std::endl;
72+
return 1;
73+
}
74+

0 commit comments

Comments
 (0)