Skip to content

Commit 0e18f68

Browse files
Linux/Mac template
0 parents  commit 0e18f68

8 files changed

+542
-0
lines changed

.gitignore

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
CMakeLists.txt.user
2+
CMakeCache.txt
3+
CMakeFiles/
4+
CMakeScripts/
5+
Testing
6+
Makefile
7+
cmake_install.cmake
8+
install_manifest.txt
9+
compile_commands.json
10+
CTestTestfile.cmake
11+
*.exe
12+
*.lib
13+
*.a
14+
*.so

CMakeLists.txt

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
cmake_minimum_required(VERSION 3.12)
2+
3+
project(SDL2TemplateCMake)
4+
5+
set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake")
6+
7+
find_package(SDL2 REQUIRED)
8+
find_package(SDL2_ttf REQUIRED)
9+
10+
add_executable(main main.cpp)
11+
12+
target_include_directories(main
13+
PRIVATE
14+
${CMAKE_CURRENT_SOURCE_DIR}
15+
PUBLIC
16+
${SDL2_INCLUDE_DIRS}
17+
${SDL2_TTF_INCLUDE_DIR}
18+
)
19+
20+
target_compile_options(main
21+
PRIVATE
22+
-Wall
23+
-Werror
24+
)
25+
26+
target_compile_features(main PRIVATE cxx_std_17)
27+
28+
target_link_libraries(main
29+
PUBLIC
30+
${SDL2_LIBRARIES}
31+
${SDL2_TTF_LIBRARY}
32+
)

LICENCE.iosevka.txt

Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
Iosevka is a free font which is available here:
2+
https://github.com/be5invis/Iosevka
3+
4+
It's licence is reproduced below:
5+
---
6+
7+
The font is licensed under SIL OFL Version 1.1.
8+
9+
The support code is licensed under Berkeley Software Distribution license.
10+
11+
---
12+
---
13+
14+
Copyright (c) 2015-2017 Belleve Invis (belleve@typeof.net).
15+
16+
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
17+
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
18+
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
19+
* Neither the name of Belleve Invis nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
20+
21+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BELLEVE INVIS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
22+
23+
-----------------------
24+
25+
---
26+
27+
Copyright 2015-2017, Belleve Invis (belleve@typeof.net).
28+
29+
This Font Software is licensed under the SIL Open Font License, Version 1.1.
30+
31+
This license is copied below, and is also available with a FAQ at:
32+
http://scripts.sil.org/OFL
33+
34+
--------------------------
35+
36+
37+
SIL Open Font License v1.1
38+
====================================================
39+
40+
41+
Preamble
42+
----------
43+
44+
The goals of the Open Font License (OFL) are to stimulate worldwide
45+
development of collaborative font projects, to support the font creation
46+
efforts of academic and linguistic communities, and to provide a free and
47+
open framework in which fonts may be shared and improved in partnership
48+
with others.
49+
50+
The OFL allows the licensed fonts to be used, studied, modified and
51+
redistributed freely as long as they are not sold by themselves. The
52+
fonts, including any derivative works, can be bundled, embedded,
53+
redistributed and/or sold with any software provided that any reserved
54+
names are not used by derivative works. The fonts and derivatives,
55+
however, cannot be released under any other type of license. The
56+
requirement for fonts to remain under this license does not apply
57+
to any document created using the fonts or their derivatives.
58+
59+
60+
Definitions
61+
-------------
62+
63+
`"Font Software"` refers to the set of files released by the Copyright
64+
Holder(s) under this license and clearly marked as such. This may
65+
include source files, build scripts and documentation.
66+
67+
`"Reserved Font Name"` refers to any names specified as such after the
68+
copyright statement(s).
69+
70+
`"Original Version"` refers to the collection of Font Software components as
71+
distributed by the Copyright Holder(s).
72+
73+
`"Modified Version"` refers to any derivative made by adding to, deleting,
74+
or substituting -- in part or in whole -- any of the components of the
75+
Original Version, by changing formats or by porting the Font Software to a
76+
new environment.
77+
78+
`"Author"` refers to any designer, engineer, programmer, technical
79+
writer or other person who contributed to the Font Software.
80+
81+
82+
Permission & Conditions
83+
------------------------
84+
85+
Permission is hereby granted, free of charge, to any person obtaining
86+
a copy of the Font Software, to use, study, copy, merge, embed, modify,
87+
redistribute, and sell modified and unmodified copies of the Font
88+
Software, subject to the following conditions:
89+
90+
1. Neither the Font Software nor any of its individual components,
91+
in Original or Modified Versions, may be sold by itself.
92+
93+
2. Original or Modified Versions of the Font Software may be bundled,
94+
redistributed and/or sold with any software, provided that each copy
95+
contains the above copyright notice and this license. These can be
96+
included either as stand-alone text files, human-readable headers or
97+
in the appropriate machine-readable metadata fields within text or
98+
binary files as long as those fields can be easily viewed by the user.
99+
100+
3. No Modified Version of the Font Software may use the Reserved Font
101+
Name(s) unless explicit written permission is granted by the corresponding
102+
Copyright Holder. This restriction only applies to the primary font name as
103+
presented to the users.
104+
105+
4. The name(s) of the Copyright Holder(s) or the Author(s) of the Font
106+
Software shall not be used to promote, endorse or advertise any
107+
Modified Version, except to acknowledge the contribution(s) of the
108+
Copyright Holder(s) and the Author(s) or with their explicit written
109+
permission.
110+
111+
5. The Font Software, modified or unmodified, in part or in whole,
112+
must be distributed entirely under this license, and must not be
113+
distributed under any other license. The requirement for fonts to
114+
remain under this license does not apply to any document created
115+
using the Font Software.
116+
117+
118+
119+
Termination
120+
-----------
121+
122+
This license becomes null and void if any of the above conditions are
123+
not met.
124+
125+
126+
DISCLAIMER
127+
128+
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
129+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
130+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
131+
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
132+
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
133+
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
134+
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
135+
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
136+
OTHER DEALINGS IN THE FONT SOFTWARE.

LICENSE.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
Copyright 2019 Shane Peelar <lookatyouhacker@gmail.com>
2+
3+
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
4+
5+
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
6+
7+
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
8+
9+
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
10+
11+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

README.md

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
UWindsor COMP-3520 SDL2 Project Template (CMake version)
2+
===
3+
4+
This template is intended for students in the COMP-3520 Introduction to Computer Graphics course
5+
at the University of Windsor, however it should serve as a useful template for anyone interested in
6+
getting started with the [SDL2](http://libsdl.org/) library quickly on non-Windows platforms.
7+
8+
The following dependencies are required:
9+
* [CMake](https://cmake.org/)
10+
* [SDL2](http://libsdl.org/)
11+
* [SDL2_ttf](https://www.libsdl.org/projects/SDL_ttf/) library for easy text rendering
12+
* [freetype2](https://www.freetype.org/) which `SDL2_ttf` uses for the actual work
13+
14+
It's very easy to get started with SDL2 on most linux distributions. Just ensure you have the above packages installed along with their header files (usually requires a `-dev` package)
15+
16+
On Debian based systems, the packages will probably be called `libsdl2-dev` and `libsdl2-ttf-dev`.
17+
On Arch Linux, look for the packages `sdl2` and `sdl2_ttf`.
18+
19+
Mac users should be able to use Homebrew or a similar package manager to install the needed dependencies.
20+
If you need help, just send me an email.
21+
22+
Setup
23+
---
24+
25+
Once you've installed these packages, you'll be all set to start your first assignment.
26+
Clone this repository somewhere using Git (in a shell):
27+
28+
~~~
29+
git clone https://github.com/InBetweenNames/SDL2TemplateCMake.git
30+
cd SDL2TemplateCMake
31+
~~~
32+
33+
Next, enter the build directory:
34+
35+
~~~
36+
cd build
37+
~~~
38+
39+
Run CMake:
40+
41+
~~~
42+
cmake ..
43+
~~~
44+
45+
If this runs without errors, you're ready to build:
46+
47+
~~~
48+
cmake --build .
49+
~~~
50+
51+
Now, run the demo:
52+
53+
~~~
54+
./main
55+
~~~
56+
57+
Note that `iosevka-regular.ttf` must be in the working directory of `main` for it to work.
58+
In practice, this means you need to be in the `build` directory when running `main`.
59+
I would welcome a pull request that removes this restriction.
60+
61+
The demo
62+
---
63+
64+
The sample code provided should display "Hello World!" in a window on your screen when run.
65+
You can clone this project as many times as you need for different assignments.
66+
67+
Recommended practices
68+
---
69+
70+
Students who know C++ are encouraged to use it, however, C++ is not a requirement for the course.
71+
The sample code provided is mostly C compatible for the benefit of students who haven't had much C++ exposure yet.
72+
73+
When we get to the more mathy parts of the course, if you have a good handle on C++, consider using
74+
[Eigen](http://eigen.tuxfamily.org/index.php?title=Main_Page) for your Linear Algebra needs.
75+
76+
Extra goodies:
77+
---
78+
79+
Although this template has everything you need to succeed in the course, in your own personal projects
80+
it's likely you'll want to go even further. Consider adding the following libraries for your arsenal:
81+
82+
* [SDL2_image](https://www.libsdl.org/projects/SDL_image/) for easy image loading from a variety of formats
83+
* [SDL2_net](https://www.libsdl.org/projects/SDL_net/) for a basic cross-platform networking library
84+
* [SDL2_mixer](https://www.libsdl.org/projects/SDL_mixer/) for sound rendering
85+
* [SDL2_rtf](https://www.libsdl.org/projects/SDL_rtf/) for basic document handling (RTF)
86+
87+
Bugs:
88+
---
89+
90+
If you find any problems with the template, please let me know by either creating an Issue on the project page or sending
91+
me an email.

build/iosevka-regular.ttf

380 KB
Binary file not shown.

0 commit comments

Comments
 (0)