Ryan C. Gordon icculus Getting Started with Linux Game Development
Ryan C. Gordon icculus Getting Started with Linux Game Development
description
Transcript of Ryan C. Gordon icculus Getting Started with Linux Game Development
![Page 1: Ryan C. Gordon icculus Getting Started with Linux Game Development](https://reader034.fdocuments.in/reader034/viewer/2022051002/56815a05550346895dc75134/html5/thumbnails/1.jpg)
Ryan C. Gordonicculus.org
Getting Started with Linux Game Development
![Page 2: Ryan C. Gordon icculus Getting Started with Linux Game Development](https://reader034.fdocuments.in/reader034/viewer/2022051002/56815a05550346895dc75134/html5/thumbnails/2.jpg)
A few notes…
• Feel free to interrupt!
• Slides are at https://icculus.org/SteamDevDays/
• Today is a high-level overview.
![Page 3: Ryan C. Gordon icculus Getting Started with Linux Game Development](https://reader034.fdocuments.in/reader034/viewer/2022051002/56815a05550346895dc75134/html5/thumbnails/3.jpg)
Who am I?
• Hacker, game developer, porter
• Port games, build tools
• Freelance
• 15 years experience
![Page 4: Ryan C. Gordon icculus Getting Started with Linux Game Development](https://reader034.fdocuments.in/reader034/viewer/2022051002/56815a05550346895dc75134/html5/thumbnails/4.jpg)
![Page 5: Ryan C. Gordon icculus Getting Started with Linux Game Development](https://reader034.fdocuments.in/reader034/viewer/2022051002/56815a05550346895dc75134/html5/thumbnails/5.jpg)
![Page 6: Ryan C. Gordon icculus Getting Started with Linux Game Development](https://reader034.fdocuments.in/reader034/viewer/2022051002/56815a05550346895dc75134/html5/thumbnails/6.jpg)
Why Linux?
• New, unsaturated market
• Low barrier to entry
• No walled garden
• SteamOS and Steam Machines
![Page 7: Ryan C. Gordon icculus Getting Started with Linux Game Development](https://reader034.fdocuments.in/reader034/viewer/2022051002/56815a05550346895dc75134/html5/thumbnails/7.jpg)
MythBusting
• Distro fragmentation isn’t real
• Most hardware is supported
• GPU drivers are good
• Linux users spend money on software
• Tech you need is available for Linux
![Page 8: Ryan C. Gordon icculus Getting Started with Linux Game Development](https://reader034.fdocuments.in/reader034/viewer/2022051002/56815a05550346895dc75134/html5/thumbnails/8.jpg)
The Good News
• Middleware is largely available
• Engines you use (Unity3D, etc) work
• Tools you use (Perforce, etc) work
• Cool new tech (Oculus, etc) work
![Page 9: Ryan C. Gordon icculus Getting Started with Linux Game Development](https://reader034.fdocuments.in/reader034/viewer/2022051002/56815a05550346895dc75134/html5/thumbnails/9.jpg)
The Bad News
• If you need Visual Studio, this is harder.
![Page 10: Ryan C. Gordon icculus Getting Started with Linux Game Development](https://reader034.fdocuments.in/reader034/viewer/2022051002/56815a05550346895dc75134/html5/thumbnails/10.jpg)
So wait…no Visual Studio?!• Emacs and vi
• Sublime Text
• QtCreator
• Code::Blocks
• Eclipse
• Many other options
![Page 11: Ryan C. Gordon icculus Getting Started with Linux Game Development](https://reader034.fdocuments.in/reader034/viewer/2022051002/56815a05550346895dc75134/html5/thumbnails/11.jpg)
The Porting Process
![Page 12: Ryan C. Gordon icculus Getting Started with Linux Game Development](https://reader034.fdocuments.in/reader034/viewer/2022051002/56815a05550346895dc75134/html5/thumbnails/12.jpg)
Start with Windows
• Move to SDL2 on Windows
• Move to OpenGL on Windows
• Then start port to Linux
![Page 13: Ryan C. Gordon icculus Getting Started with Linux Game Development](https://reader034.fdocuments.in/reader034/viewer/2022051002/56815a05550346895dc75134/html5/thumbnails/13.jpg)
Get it compiling
• GCC, Clang, Intel C++
• Makefiles, CMake, Premake, scons
![Page 14: Ryan C. Gordon icculus Getting Started with Linux Game Development](https://reader034.fdocuments.in/reader034/viewer/2022051002/56815a05550346895dc75134/html5/thumbnails/14.jpg)
Mining from VS2008 .vcproj
<File RelativePath=“src\audio\player.cpp” >
![Page 15: Ryan C. Gordon icculus Getting Started with Linux Game Development](https://reader034.fdocuments.in/reader034/viewer/2022051002/56815a05550346895dc75134/html5/thumbnails/15.jpg)
Mining from VS2010 .vcxproj
<ClCompile Include="src\audio\player.cpp" />
![Page 16: Ryan C. Gordon icculus Getting Started with Linux Game Development](https://reader034.fdocuments.in/reader034/viewer/2022051002/56815a05550346895dc75134/html5/thumbnails/16.jpg)
When in doubt, stub it out
#define STUBBED(x) printf("STUBBED: %s\n", x)
![Page 17: Ryan C. Gordon icculus Getting Started with Linux Game Development](https://reader034.fdocuments.in/reader034/viewer/2022051002/56815a05550346895dc75134/html5/thumbnails/17.jpg)
When in doubt, stub it out
#define STUBBED(x) do { \ static bool seen_this = false; \ if (!seen_this) { \ seen_this = true; \ fprintf(stderr, "STUBBED: %s at %s (%s:%d)\n”, \ x, __FUNCTION__, __FILE__, __LINE__); \ } \} while (0)
![Page 18: Ryan C. Gordon icculus Getting Started with Linux Game Development](https://reader034.fdocuments.in/reader034/viewer/2022051002/56815a05550346895dc75134/html5/thumbnails/18.jpg)
When in doubt, stub it out
MessageBox(hwnd, “Out of memory”, “Error”, 0);
![Page 19: Ryan C. Gordon icculus Getting Started with Linux Game Development](https://reader034.fdocuments.in/reader034/viewer/2022051002/56815a05550346895dc75134/html5/thumbnails/19.jpg)
When in doubt, stub it out
#if WINDOWSMessageBox(hwnd, “Out of memory”, “Error”, 0);#elseSTUBBED(“Need a Linux msgbox”);#endif
![Page 20: Ryan C. Gordon icculus Getting Started with Linux Game Development](https://reader034.fdocuments.in/reader034/viewer/2022051002/56815a05550346895dc75134/html5/thumbnails/20.jpg)
Don’t do this.
#if LINUX some_non_windows_thing();#endif
![Page 21: Ryan C. Gordon icculus Getting Started with Linux Game Development](https://reader034.fdocuments.in/reader034/viewer/2022051002/56815a05550346895dc75134/html5/thumbnails/21.jpg)
Do this!
#if !WINDOWS some_non_windows_thing();#endif
![Page 22: Ryan C. Gordon icculus Getting Started with Linux Game Development](https://reader034.fdocuments.in/reader034/viewer/2022051002/56815a05550346895dc75134/html5/thumbnails/22.jpg)
Definitely don’t do this.
#if WINDOWS some_windows_thing();#elif PLAYSTATION some_ps_thing();#endif
![Page 23: Ryan C. Gordon icculus Getting Started with Linux Game Development](https://reader034.fdocuments.in/reader034/viewer/2022051002/56815a05550346895dc75134/html5/thumbnails/23.jpg)
Do this!
#if WINDOWS some_windows_thing();#elif PLAYSTATION some_ps_thing();#else #error Oh no.#endif
![Page 24: Ryan C. Gordon icculus Getting Started with Linux Game Development](https://reader034.fdocuments.in/reader034/viewer/2022051002/56815a05550346895dc75134/html5/thumbnails/24.jpg)
Inline assembly
_asm { mov ecx, 1 mov eax, ecx}
![Page 25: Ryan C. Gordon icculus Getting Started with Linux Game Development](https://reader034.fdocuments.in/reader034/viewer/2022051002/56815a05550346895dc75134/html5/thumbnails/25.jpg)
Inline assembly__asm__ __volatile__ ( “movl $1, %%ecx \n” “movl %%ecx, %%eax \n” : “a”
: /* no inputs */ : “ecx”);
![Page 26: Ryan C. Gordon icculus Getting Started with Linux Game Development](https://reader034.fdocuments.in/reader034/viewer/2022051002/56815a05550346895dc75134/html5/thumbnails/26.jpg)
Inline assembly
• Don’t use inline asm. Ever.
• Seriously, don’t do it.
• Compiler intrinsics
• SDL2 atomics, SDL_GetTicks(), SDL_GetPerformanceCounter(), etc.
• nasm
![Page 27: Ryan C. Gordon icculus Getting Started with Linux Game Development](https://reader034.fdocuments.in/reader034/viewer/2022051002/56815a05550346895dc75134/html5/thumbnails/27.jpg)
Get it compiling
• Stub out problem code
• Fix simple things now
• Don’t touch anything else (for now)
![Page 28: Ryan C. Gordon icculus Getting Started with Linux Game Development](https://reader034.fdocuments.in/reader034/viewer/2022051002/56815a05550346895dc75134/html5/thumbnails/28.jpg)
Get it linking
• Middleware
• System dependencies
![Page 29: Ryan C. Gordon icculus Getting Started with Linux Game Development](https://reader034.fdocuments.in/reader034/viewer/2022051002/56815a05550346895dc75134/html5/thumbnails/29.jpg)
Get it running
• Use SDL2!
• Use OpenGL!
• (maybe) Use OpenAL!
• Use the Steam Runtime!
![Page 30: Ryan C. Gordon icculus Getting Started with Linux Game Development](https://reader034.fdocuments.in/reader034/viewer/2022051002/56815a05550346895dc75134/html5/thumbnails/30.jpg)
Filesystem gotchas• Its paths are ‘/‘ instead of ‘\\’
• It’s single root, no drive letters
• It’s more locked down
• It’s multiuser
• It’s always Unicode (sort of)
• It’s case-sensitive!
![Page 31: Ryan C. Gordon icculus Getting Started with Linux Game Development](https://reader034.fdocuments.in/reader034/viewer/2022051002/56815a05550346895dc75134/html5/thumbnails/31.jpg)
Unicode
• All system calls and filenames are UTF-8
• “wchar_t” is UCS-4 (32 bits per codepoint)
• Memory bloat isn’t usually an issue, serialization is
• iconv, or roll your own
![Page 32: Ryan C. Gordon icculus Getting Started with Linux Game Development](https://reader034.fdocuments.in/reader034/viewer/2022051002/56815a05550346895dc75134/html5/thumbnails/32.jpg)
Get it debugged
• GDB 7
• UndoDB
• WinGDB
• VisualGDB
• QtCreator
• Valgrind
• LLVM’s AddressSanitizer
• See next two talks in this room!
![Page 33: Ryan C. Gordon icculus Getting Started with Linux Game Development](https://reader034.fdocuments.in/reader034/viewer/2022051002/56815a05550346895dc75134/html5/thumbnails/33.jpg)
Debugging OpenGL
• ApiTrace
• gDebugger
• See Jason/Rich/Dan’s talk, immediately following this one.
![Page 34: Ryan C. Gordon icculus Getting Started with Linux Game Development](https://reader034.fdocuments.in/reader034/viewer/2022051002/56815a05550346895dc75134/html5/thumbnails/34.jpg)
Get it optimized
• perf
• Zoom
• ApiTrace
• Telemetry
![Page 35: Ryan C. Gordon icculus Getting Started with Linux Game Development](https://reader034.fdocuments.in/reader034/viewer/2022051002/56815a05550346895dc75134/html5/thumbnails/35.jpg)
Get it shipping
• Simple tarballs
• MojoSetup
• Ship it on Steam!
• Avoid distro packages
![Page 36: Ryan C. Gordon icculus Getting Started with Linux Game Development](https://reader034.fdocuments.in/reader034/viewer/2022051002/56815a05550346895dc75134/html5/thumbnails/36.jpg)
Contact me
• https://icculus.org/SteamDevDays
• @icculus on Twitter
• http://gplus.to/icculus
• (If you hire me, you can forget this whole talk!)
![Page 37: Ryan C. Gordon icculus Getting Started with Linux Game Development](https://reader034.fdocuments.in/reader034/viewer/2022051002/56815a05550346895dc75134/html5/thumbnails/37.jpg)
Other talks to see
• Moving your game to OpenGL: 3pm today, this room
• Getting started Debugging on Linux: 4pm today, this room
• Breakout: Programming on Linux, OpenGL: 5pm today, this room
• Beyond Porting: 3pm tomorrow, this room
• Game Development with SDL 2.0: 5pm tomorrow, Room 611/613