com
It is about:
www.thefarm51.com
Cross-platform work
&' de facto ( Linu )
githu*.com+ine,uation -oy $ro.ects/ $ersonal utilities/ uni#ersity stuff 0ames as well1 2341%! 3rystal 5$ace id-ech %4*ased games Painkiller Hell !amnation Linu as $referred 65 for 78 years Former o$en4source e#angelist
www.thefarm51.com
www.thefarm51.com
Linux 101
: www.thefarm51.com
OMG LINUX!!11
www.thefarm51.com
OMG LINUX!!11
<ichard =. 5tallman
5ource> htt$>++commons.wikimedia.org+wiki+File><=5?i0@Acius?techfest?iit*.BP0
www.thefarm51.com
OMG LINUX!!11
www.thefarm51.com
1!
1!
www.thefarm51.com
11
0.o:
0.":
Long/ intrinsic traditions of free software @o esta*lished channels of $ro$rietary software distri*ution But 1team can *ecome a 2ame-.an2er/
11 www.thefarm51.com
12
!tandards
Linu adheres to I56+IN3 standards/ such as PO1I3 and 1in2le %ni# 1pe-ifi-ation...
5ystem 2PI ( file system access/ threading/ access control/ IP3 etc. 3ommand4line shell utilities
...which also ha$$en to *e su$$orted *y 4a-O1 3/ 5ndroid/ iO1 &yes/ really1) and a handful of other 65es
12
www.thefarm51.com
1%
!tandards
Linu has OpenGL $61) for %" gra$hics rendering Linu has Open5L for %" audio with "5P Linu has 71! so-kets for networking Linu has lots of other $orta*le li*raries 2nd all of these things are also a#aila*le on other $latforms ( 5ndroid/ 4a-O1 3/ iO1/ 0indows1
1%
www.thefarm51.com
19
Linu
=o*ile
=ac65 O
E not to scaleP actual o#erla$ is greater
19 www.thefarm51.com
15
6#treme heterogeneity
Package managers &software distri*ution mechanisms) Patches a$$lied to u$stream code ' $otential differences in functionality Qighly customized system configurations
15 www.thefarm51.com
1:
Pro$rietary #s free 0PA dri#ers <ule of thum*> free dri#ers $erform more $oorly than $ro$rietary ones
Intel only has free/ *ut the hardware is *ad anyway Legacy 2="+2-I 0PAs only ha#e free/ and itMs ,uite good actually
@FI"I2 dri#ers are e,ually good as the Kindows ones 2="+2-I dri#ers are a *it worse than the Kindows ones
1:
www.thefarm51.com
17
!olution?
5ssume %buntu(
For de#elo$ment and testing alike Pro*a*ly the most $o$ular deskto$ distroE -his is what Fal#e does - Bonus $oints> 5team com$ati*lity1 Power users will get your game running on others anyway
E there are claims itMs Linu =int now/ *ut itMs still *ased on A*untu
17 www.thefarm51.com
1;
Development
1; www.thefarm51.com
1C
Getting started
8irtual ma-.ine Fair enough for *uilding @o such luck with testing
Nati9e installation Painless dual *oot 0.i-. dis- ima2e to download: 0et whate#er Fal#e recommends for 5team
2!
#ools
F= toolchains
- 4ono/ Open;!<+Ora-le ;!<
Build tools
21
%ebugging
3PA 3lassic command4 line 2db/ 2dbser9er -ons of front4ends 0ra$hics 2!67u22er+Code3L N8I!I5 Nsi2.t for Ncli$se apitra-e
21
www.thefarm51.com
22
Pro#ides>
- 2PI in 3 with ma$$ings to other languages - -imers and threads - In$ut ( mouse/ key*oard/ .oysticks+$ads &incl. Anicode characters) - Kindow management &incl. 0L conte t) - 2udio &#ery *are*one) - 2" gra$hics &hardware *litting)
22
www.thefarm51.com
2%
5"L hides away most $latform4s$ecific code - -hatMs right/ no need to e#en use P65IO1
// main game l--. +hile (() { // ,i*.atch event* +hile (SDL_:-ll vent(;ev)){ *+itch (event<t2.e) { // <<< = = = SDL_Sh-+0'r*-r(()) SDL_/#_3ra4In.'t(SDL_3$56_!>>)) ret'rn &)
int main (int argc, char *argv[]) { // initialize SDL if (SDL_Init(SDL_INIT_VID ! " SDL_INIT_TI# $) % &) ret'rn () // *et +in,-+ ca.ti-n SDL_/#_Set0a.ti-n(1#2 SDL 3ame1, 1#2SDL3ame1)) // hi,e m-'*e, gra4 in.'t SDL_Sh-+0'r*-r(&)) SDL_/#_3ra4In.'t(SDL_3$56_!N)) // ma7e SDL clean '. -n e8it ate8it(SDL_9'it)) 2%
www.thefarm51.com
29
"es$ite its awesomeness/ 5"L has its shortcomings @o e $licit 0LO+K0L conte t data sharing and no direct conte t access ' no threaded rendering
@o %" $ositioning or "5P su$$ort in the stock 5"L audio su*system - Partially remedied *y 5"L?mi er 7ut we need t.ose/ Now w.at:/
29
www.thefarm51.com
25
25
www.thefarm51.com
2:
0O!IX 10I
-here is an e tensi#e/ centralised reference manual in the man.age*B,ev $ackage -y$e in a shell to access>
man %*ecti-n n'm4erC %*'4JectC
5ection num*er cheat sheet 1. 0eneral console commands 2. 5ystem calls %. 3 standard li*rary calls 9. 5$ecial files &/,ev/*) and dri#ers 5. File formats and con#entions
www.thefarm51.com
2:
27
27
www.thefarm51.com
2;
.oysti'k2ga"e)ad 10I
@ot $art of O11 in$ut e#ent framework Rernel *lock de#ices - 3reated as /,ev/in.'t/J** - Qot$lug e#ents #ia li*ude# &also in 5team Linu <untime) - Qandled #ia -.en() and i-ctl() - "etailed documentation in the kernel
htt$>++kernel.org+doc+"ocumentation+in$ut+.oystick4a$i.t t
2;
www.thefarm51.com
2C
2C
www.thefarm51.com
%!
%!
www.thefarm51.com
%1
%1
www.thefarm51.com
%2
How:
1tati- linkin2
8 will work fore#er 4 *inary *loat
%2
%%
<eady4to4use 0334*ased toolchains for i%;: and amd:9 5hi$s with 5team/ so e9er" &non4orthodo ) Linu# 2amer .as it
%%
www.thefarm51.com
%9
5tart4u$ shell scri$ts are common $ractice - 5earch for an installed 5team <untime instance - If not found/ install your $ri#ate co$y - 6nly when the 5L< is a#aila*le/ run the actual *inary
%9
www.thefarm51.com
%5
%5
www.thefarm51.com
%:
Lo'ales
-he 3 standard defines lo-ales for language and regional settings &see manR*etl-cale) -hey affect *.rintf()+**canf() and more Oli* can modify locale categories for 0AI a$$s &see man FSetL-cale#-,ifier*) N am$le P65IO locales> .l_:L<ET>M/
en_36<IS!BMMSTB(/ r'_$E<U!IMB$
-he Linu manual might make it seem like retrie#ing current locale is as easy as calling
charR*l-caleRDR*etl-cale(L0_5LL, NELL))
www.thefarm51.com
%:
%7
Lo'ales
No su-. lu-k/
// 4ac7'. the -riginal a..licati-n l-cale char *L-cale D *etl-cale(L0_5LL, NELL)) char *!riginalL-cale D NELL) if (L-cale ;; *L-cale) !riginalL-cale D *tr,'.(L-cale)) // re*et l-cale t- *2*tem ('*er) ,efa'lt *etl-cale(L0_5LL, 11)) // retrieve the ,efa'lt l-cale L-cale D *etl-cale(L0_5LL, NELL)) // .r-ce** l-cale here // re*t-re -riginal l-cale if (!riginalL-cale) { *etl-cale(L0_5LL, !rigL-cale)) free(!riginalL-cale)) =
%7 www.thefarm51.com
%;
Ke often want to kee$ sym*ols for shi$$ing *inaries 6n Kindows ( kee$ the .$d* files 6n Linu
-4Jc-.2 BB-nl2B7ee.B,e4'g 1K{t-*tri.file=1 1K{,e4'g,ir=/K{,e4'gfile=1 *tri. BB*tri.B,e4'g BB*tri.B'nnee,e, 1K{t-*tri.file=1 -4Jc-.2 BBa,,Bgn'B,e4'glin7D 1K{,e4'g,ir=/K{,e4'gfile=1 1K{t-*tri.file="
%;
P P P P P
www.thefarm51.com
%C
7rash handler
6n P65IO this is called a si2nal .andler 5ignals are a $rimiti#e IP3 mechanism used not only for crashes
- "e*ugger tra$s/ floating $oint e ce$tions/ terminal hangu$/ e it re,uests... 5ee the out$ut of 7ill Bl
9!
1 word on li'ensing
Khene#er you use a li*rary/ -.e-k its li-ensin2 terms/ GPL is restri-ti9e - <e,uires deri#ati#e works to use 0PL ' sharing the source code LGPL is restricti#e with linkin2 e#-eption - 2llows linking to an L0PL li*rary without sharing the source code 4IT/ 71! and >lib licenses are generally permissi9e/ some might re,uire ad#ertising
9! www.thefarm51.com
91
Deployment
91 www.thefarm51.com
92
Kindows - 0ame data and *inaries> 3>UProgram Files - Aser data> V2PP"2-2V/ "ocuments... - 2o54like organization Linu &con#entional) - 0ame *inaries> +usr+*in+/ +usr+games+ - 0ame data> +usr+share+games+ - Aser data> WQ6=N+.config+
www.thefarm51.com
9%
FQ5 mainly concerns distro $ackages Pro$rietary software often installs into +o$t+X$ackage nameY+
Pro$rietary software also often installs Dwhere#erG 5team games li#e in Z+.steam+steam+5team2$$s+ Bust $ut game data and *inaries in one $lace/ and sa#e user data to Z+.config+
9%
www.thefarm51.com
99
"istro $ackages &.r$m/ .de*...) 5elf4e tracting command4line installers as shell scri$ts
htt$s>++coderwall.com+$+y%u$,w
=o.o5etu$
htt$>++icculus.org+mo.osetu$+
99
www.thefarm51.com
95
Summary
95 www.thefarm51.com
9:
!u""ary
Nngineering costs of a Linu $ort for an already multi$latfrom game engine are low - DItMs .ust an 2PIG[ 5"L co#ers a lot of *oiler$late for you 6#ercoming heterogeneity is essential - 5team Linu <untime is hel$ing to fi it Katch out for those licenses1 Khen in dou*t> - Ase A*untu - "o whate#er Fal#e does
9:
www.thefarm51.com
97
Questions?
97
leszek.godlewski@thefarm51.com
www.thefarm51.com
9;
!)e'ial thanks
4i-.aA 0iel2us
3ritical re#iew S free software comrade
=ein.ard Polli-e
9C
www.thefarm51.com
Thank you!
Like us on Facebook! http://www.facebook.com/farm51 http://www.facebook.com/deadfalladventures http://www.facebook.com/PainkillerGame
leszek.godlewski@thefarm51.com