SlideShare a Scribd company logo
inequation.orginequation.org
WGK 2013 · September 7th, 2013WGK 2013 · September 7th, 2013
Cross-platform game engine
development with SDL 2.0
Leszek Godlewski
Freelance Programmer
lg@inequation.org
AgendaAgenda
2 inequation.org2 inequation.org
● Who is this guy?
● Introduction to SDL
● Event pump
● New features of SDL 2.0
● Questions
Who is this guy?Who is this guy?
3 inequation.org3 inequation.org
Freelance Programmer
(Sep 2013 – onwards)
● inequation.org
● Unannounced project
Generalist Programmer,
The Farm 51
(Mar 2010 – Aug 2013)
● thefarm51.com
● Painkiller Hell & Damnation
(2012-2013; Win/Linux/X360/PS3)
● Deadfall Adventures (2011-2013;
Win/X360)
● A few unannounced projects
Who is this guy?Who is this guy?
4 inequation.org4 inequation.org
Cross-platform work
( de facto – Linux)→
● github.com/inequation
● Toy projects, personal utilities,
university stuff
● Games as well!
● AC-130
● Crystal Space
● idTech 3-based games
● Painkiller Hell & Damnation
● Linux as preferred OS for 7+ years
● Former open-source evangelist
● Not anymore – lost interest
AgendaAgenda
5 inequation.org5 inequation.org
● Who is this guy?
● Introduction to SDL
● Event pump
● New features of SDL 2.0
● Questions
What is SDL?What is SDL?
6 inequation.org6 inequation.org
Simple DirectMedia Layer
The cross-platform, open-source „DirectX”
● Written by Sam Lantinga (ex-Loki, ex-Blizzard,
currently Valve), Ryan Gordon (legendary porter) et al.
● Provides:
● API in C with mappings to other languages
● Timers and threads
● Thread-safe input and events (incl. Unicode and IME)
● Polled and event-based APIs (incl. filtering)
● Window management (incl. OpenGL [ES] contexts)
● Audio (very barebone)
● Accelerated 2D graphics (simple drawing, blitting)
● More!
Benefits of SDLBenefits of SDL
7 inequation.org7 inequation.org
Many supported platforms
● Windows XP+
● Linux 2.6+
● Mac OS X 10.5+
● Android 2.3.3+
● iOS 4.0.1+
● Many more: Free/Open/NetBSD, Solaris, Playstation Portable,
Haiku, Pandora...
Yup,
mobiles!
Benefits of SDLBenefits of SDL
8 inequation.org8 inequation.org
All platform details hidden away under a
unified interface!
(truly one codebase shared by all of them
→ write once, compile anywhere)
Benefits of SDLBenefits of SDL
9 inequation.org9 inequation.org
Extremely simple – goodbye, boilerplate!
int main(int argc, char** argv) {
if (SDL_Init(SDL_INIT_EVERYTHING) != 0)
return 1;
SDL_Window *win = SDL_CreateWindow("Hello World!",
100, 100, 640, 480, SDL_WINDOW_SHOWN);
SDL_Renderer *ren = SDL_CreateRenderer(win, -1,
SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC);
SDL_Surface *bmp = SDL_LoadBMP("hello.bmp");
SDL_Texture *tex = SDL_CreateTextureFromSurface(ren, bmp);
SDL_FreeSurface(bmp);
SDL_RenderClear(ren);
SDL_RenderCopy(ren, tex, NULL, NULL);
SDL_RenderPresent(ren);
SDL_Delay(2000);
SDL_DestroyTexture(tex);
SDL_DestroyRenderer(ren);
SDL_DestroyWindow(win);
SDL_Quit();
return 0;
}
MonoGame-SDL2MonoGame-SDL2
10 inequation.org10 inequation.org
Hey indies!
● MonoGame: an XNA implementation on top of Mono
● MG-SDL2: backend for MonoGame by Ethan Lee
(Twitter: @flibitijibibo)
● Shipped and WIP games:
● Capsized
● FEZ
● Gateways
http://github.com/flibitijibibo/MonoGame
Sample SDL game: AC-130Sample SDL game: AC-130
11 inequation.org11 inequation.org
AgendaAgenda
12 inequation.org12 inequation.org
● Who is this guy?
● Introduction to SDL
● Event pump
● New features of SDL 2.0
● Questions
Event pumpEvent pump
13 inequation.org13 inequation.org
SDL encapsulates hardware, system, window
management and input events
● SDL_QUIT, SDL_APP_TERMINATING, SDL_APP_LOWMEMORY, SDL_APP_WILLENTERBACKGROUND,
SDL_APP_DIDENTERBACKGROUND, SDL_APP_WILLENTERFOREGROUND,
SDL_APP_DIDENTERFOREGROUND, SDL_WINDOWEVENT, SDL_SYSWMEVENT, SDL_KEYDOWN,
SDL_KEYUP, SDL_TEXTEDITING, SDL_TEXTINPUT, SDL_MOUSEMOTION, SDL_MOUSEBUTTONDOWN,
SDL_MOUSEBUTTONUP, SDL_MOUSEWHEEL, SDL_JOYAXISMOTION, SDL_JOYBALLMOTION,
SDL_JOYHATMOTION, SDL_JOYBUTTONDOWN, SDL_JOYBUTTONUP, SDL_JOYDEVICEADDED,
SDL_JOYDEVICEREMOVED, SDL_CONTROLLERAXISMOTION, SDL_CONTROLLERBUTTONDOWN,
SDL_CONTROLLERBUTTONUP, SDL_CONTROLLERDEVICEADDED, SDL_CONTROLLERDEVICEREMOVED,
SDL_CONTROLLERDEVICEREMAPPED, SDL_FINGERDOWN, SDL_FINGERUP, SDL_FINGERMOTION,
SDL_DOLLARGESTURE, SDL_DOLLARRECORD, SDL_MULTIGESTURE, SDL_CLIPBOARDUPDATE,
SDL_DROPFILE, SDL_USEREVENT
● SDL_PeepEvents(), SDL_PollEvents(),
SDL_WaitEvent()...
● Filtering: simple, by type (SDL_EventState()) or
complex with callbacks (SDL_EventFilter)
● Custom user events - SDL_RegisterEvents()
Event pumpEvent pump
14 inequation.org14 inequation.org
● Probably the single coolest feature!
● One switch in a loop takes care of almost everything
● Typical SDL application structure:
● Subsystem initialization
● Event pump
● Cleanup
● That's it!
Sample SDL game: AC-130Sample SDL game: AC-130
15 inequation.org15 inequation.org
<AC-130 main loop breakdown>
github.com/inequation/ac130
AgendaAgenda
16 inequation.org16 inequation.org
● Who is this guy?
● Introduction to SDL
● Event pump
● New features of SDL 2.0
● Questions
Current state of SDL 2Current state of SDL 2
17 inequation.org17 inequation.org
● First stable release, 2.0.0, announced August 11th
● Present in the Steam Linux Runtime since early RCs
● Valve games and others rely on it
● Documentation is slightly outdated
● Ongoing effort, gaps being quickly filled
● You might be misled to believe a feature is missing...
● When in doubt, read header file comments or
generate your own docs
What's new in SDL 2What's new in SDL 2
18 inequation.org18 inequation.org
● OpenGL 3+ support
● Incl. context sharing (finally!)
● OpenGL ES support
● Haptic (force) feedback
● Game controller API
● Android and iOS support
● Touch input with gestures
● Support for multiple displays, windows, audio devices
● IME and proper Unicode support
● Pluggable 2D renderer backends
● Portable atomic operations
● Power management
● Rudimentary UI (message boxes etc.)
● Clipboard & drag-and-drop support
OpenGL context sharingOpenGL context sharing
19 inequation.org19 inequation.org
Finally – yay for multithreaded/multi-window
rendering! ☺
●
Undocumented... ☹ FIXED as of August 11th
● Only mention in Google is the May 2012 commit that
introduces the feature
● Needs an SDL-OpenGL attribute set before window
creation:
SDL_GL_SetAttribute(
SDL_GL_SHARE_WITH_CURRENT_CONTEXT, 1);
● Voila - all contexts created from now on with
SDL_GL_CreateContext() will share data with the
currently bound context (buffers, shaders etc.)!
OpenGL context sharingOpenGL context sharing
20 inequation.org20 inequation.org
Gotcha: pre-RC4 SDL2 keeps a global
reference to the current window/GL context
pair
● Care must be taken when unbinding contexts (e.g.
when killing worker threads)!
// …
SDL_GL_MakeCurrent(NULL, NULL);
// most SDL_GL_* calls made on any thread
// will crash now :(
● Solution: simply bind back to the main window and
context instead of unbinding
SDL_GL_MakeCurrent(MainWindow, MainGLCtx);
OpenGL context sharingOpenGL context sharing
21 inequation.org21 inequation.org
Gotcha: pre-RC4 SDL2 keeps a global
reference to the current window/GL context
pair
RC4 and newer (incl. 2.0.0 stable) – nothing to worry
about ☺
● Some distros still ship <= RC4
● Ship your own or use Steam Linux Runtime
(fixed on 11 Jul 2013, rev. 50211a1fd557)
Full-screen quirksFull-screen quirks
22 inequation.org22 inequation.org
Gotcha: full-screen in Linux is hacky ☹
● X11 doesn't really support „true” full-screen windows
● Actually just a decoration-less window
● SDL_WINDOW_FULLSCREEN uses an XRandR hack
● Change display mode while maintaining desktop size
● Crop the „viewport”
● Side effect: „viewport” follows mouse and may scroll
away from app window... Bad! ☹
● SDL_WINDOW_FULLSCREEN_DESKTOP simply creates a
desktop-sized window, no XRandR magic
● Render to offscreen buffer (FBO), then blit with scaling
● This is what Valve does!
Game controller API: SDL_GameController*Game controller API: SDL_GameController*
23 inequation.org23 inequation.org
Unified gamepad/joystick handling
● Layout modelled after the Xbox 360 controller
● Built by Valve with Steam Big Picture in mind
● Button/axis mapping support for other controllers
● Kind of a built-in equivalent to Xpadder
● Bindings may be imported/exported via strings
● Popular controllers have built-in mappings
● Hotplug support – yay!
● May be polled for state or handled with events
● API very similar to the regular joystick API, but buttons
and axes are identified by enumerations instead
● SDL_GameControllerAxis
● SDL_GameControllerButton
Game controller API: SDL_GameController*Game controller API: SDL_GameController*
24 inequation.org24 inequation.org
Gotcha: joystick/game controller API interop
● GC API is implemented on top of the SDL joystick API
● SDL GC subsystem initialization implies joystick
subsystem initialization
● Regular joystick events are issued for GCs as well!
● This means double events for the axes, buttons, even
hotplugs!
● Don't need joystick hats, arbitrary axes etc.? Just filter
out joystick events altogether
● Otherwise you can identify the device type with
SDL_IsGameController()
Haptic feedback: SDL_Haptic*Haptic feedback: SDL_Haptic*
25 inequation.org25 inequation.org
● Powerful API with more than just rumbles
● Remember arcade racing machines that blocked the
steering wheel and pedals?
● Haptic devices may be stand-alone (e.g. rumble motors
in mobile devices) or derived from joysticks with
SDL_HapticOpenFromJoystick()
● Simplified API for rumbles
TakeawayTakeaway
26 inequation.org26 inequation.org
● Battle-proven low-level abstraction layer
● Ships with the Steam Linux Runtime
● Support for many platforms, including Windows, Linux,
Mac, mobiles and some handheld consoles
● Provides a universal event pump
● Integrates well with OpenGL
● Exposes game controllers and force feedback
● Open-source!
libsdl.org
bugzilla.libsdl.org
inequation.orginequation.org
Questions?
lg@inequation.org
WGK 2013 · September 7th, 2013WGK 2013 · September 7th, 2013
inequation.orginequation.org
Thank you!
inequation.org
lg@inequation.org
@TheIneQuation
WGK 2013 · September 7th, 2013WGK 2013 · September 7th, 2013

More Related Content

What's hot

Software Architecture
Software ArchitectureSoftware Architecture
Software Architecture
Prabhat gangwar
 
OOAD - UML - Class and Object Diagrams - Lab
OOAD - UML - Class and Object Diagrams - LabOOAD - UML - Class and Object Diagrams - Lab
OOAD - UML - Class and Object Diagrams - Lab
Victer Paul
 
Responsibility Driven Design
Responsibility Driven DesignResponsibility Driven Design
Responsibility Driven Design
Harsh Jegadeesan
 
Daa unit 1
Daa unit 1Daa unit 1
Daa unit 1
Abhimanyu Mishra
 
Design concept -Software Engineering
Design concept -Software EngineeringDesign concept -Software Engineering
Design concept -Software Engineering
Varsha Ajith
 
Statistical Machine Learning for Text Classification with scikit-learn and NLTK
Statistical Machine Learning for Text Classification with scikit-learn and NLTKStatistical Machine Learning for Text Classification with scikit-learn and NLTK
Statistical Machine Learning for Text Classification with scikit-learn and NLTK
Olivier Grisel
 
Story Cards
Story CardsStory Cards
Story Cards
Ayoub Babiker
 
Software Engineering - Ch11
Software Engineering - Ch11Software Engineering - Ch11
Software Engineering - Ch11
Siddharth Ayer
 
Complexity metrics and models
Complexity metrics and modelsComplexity metrics and models
Complexity metrics and models
Roy Antony Arnold G
 
Fundamentals of Neural Networks
Fundamentals of Neural NetworksFundamentals of Neural Networks
Fundamentals of Neural Networks
Gagan Deep
 
Unit 3 system models
Unit 3 system modelsUnit 3 system models
Unit 3 system models
Azhar Shaik
 
Computer Vision for Beginners
Computer Vision for BeginnersComputer Vision for Beginners
Computer Vision for Beginners
Sanghamitra Deb
 
unit 5 Architectural design
 unit 5 Architectural design unit 5 Architectural design
unit 5 Architectural design
devika g
 
Debugging by induction
Debugging by inductionDebugging by induction
Debugging by induction
Waqar Ali
 
Cs8092 computer graphics and multimedia unit 2
Cs8092 computer graphics and multimedia unit 2Cs8092 computer graphics and multimedia unit 2
Cs8092 computer graphics and multimedia unit 2
SIMONTHOMAS S
 
Architecture evaluation
Architecture evaluationArchitecture evaluation
Architecture evaluation
Alexandru Chica
 
Software Engineering Practice
Software Engineering PracticeSoftware Engineering Practice
Software Engineering Practice
Research & Development LAB QUEST Nawabshah
 
Tic Tac Toe using Mini Max Algorithm
Tic Tac Toe using Mini Max AlgorithmTic Tac Toe using Mini Max Algorithm
Tic Tac Toe using Mini Max Algorithm
Ujjawal Poudel
 
Tic tac toe simple ai game
Tic tac toe simple ai gameTic tac toe simple ai game
Tic tac toe simple ai game
Seevaratnam Kajandan
 
Question bank soft computing
Question bank   soft computingQuestion bank   soft computing
Question bank soft computing
Mohit Singh
 

What's hot (20)

Software Architecture
Software ArchitectureSoftware Architecture
Software Architecture
 
OOAD - UML - Class and Object Diagrams - Lab
OOAD - UML - Class and Object Diagrams - LabOOAD - UML - Class and Object Diagrams - Lab
OOAD - UML - Class and Object Diagrams - Lab
 
Responsibility Driven Design
Responsibility Driven DesignResponsibility Driven Design
Responsibility Driven Design
 
Daa unit 1
Daa unit 1Daa unit 1
Daa unit 1
 
Design concept -Software Engineering
Design concept -Software EngineeringDesign concept -Software Engineering
Design concept -Software Engineering
 
Statistical Machine Learning for Text Classification with scikit-learn and NLTK
Statistical Machine Learning for Text Classification with scikit-learn and NLTKStatistical Machine Learning for Text Classification with scikit-learn and NLTK
Statistical Machine Learning for Text Classification with scikit-learn and NLTK
 
Story Cards
Story CardsStory Cards
Story Cards
 
Software Engineering - Ch11
Software Engineering - Ch11Software Engineering - Ch11
Software Engineering - Ch11
 
Complexity metrics and models
Complexity metrics and modelsComplexity metrics and models
Complexity metrics and models
 
Fundamentals of Neural Networks
Fundamentals of Neural NetworksFundamentals of Neural Networks
Fundamentals of Neural Networks
 
Unit 3 system models
Unit 3 system modelsUnit 3 system models
Unit 3 system models
 
Computer Vision for Beginners
Computer Vision for BeginnersComputer Vision for Beginners
Computer Vision for Beginners
 
unit 5 Architectural design
 unit 5 Architectural design unit 5 Architectural design
unit 5 Architectural design
 
Debugging by induction
Debugging by inductionDebugging by induction
Debugging by induction
 
Cs8092 computer graphics and multimedia unit 2
Cs8092 computer graphics and multimedia unit 2Cs8092 computer graphics and multimedia unit 2
Cs8092 computer graphics and multimedia unit 2
 
Architecture evaluation
Architecture evaluationArchitecture evaluation
Architecture evaluation
 
Software Engineering Practice
Software Engineering PracticeSoftware Engineering Practice
Software Engineering Practice
 
Tic Tac Toe using Mini Max Algorithm
Tic Tac Toe using Mini Max AlgorithmTic Tac Toe using Mini Max Algorithm
Tic Tac Toe using Mini Max Algorithm
 
Tic tac toe simple ai game
Tic tac toe simple ai gameTic tac toe simple ai game
Tic tac toe simple ai game
 
Question bank soft computing
Question bank   soft computingQuestion bank   soft computing
Question bank soft computing
 

Viewers also liked

Jogos em Perl
Jogos em PerlJogos em Perl
Jogos em Perl
garux
 
Gamedev-grade debugging
Gamedev-grade debuggingGamedev-grade debugging
Gamedev-grade debugging
Leszek Godlewski
 
El barrroco
El barrrocoEl barrroco
El barrroco
espejodeoesed
 
One Year of Porting - Post-mortem of two Linux/SteamOS launches
One Year of Porting - Post-mortem of two Linux/SteamOS launchesOne Year of Porting - Post-mortem of two Linux/SteamOS launches
One Year of Porting - Post-mortem of two Linux/SteamOS launches
Leszek Godlewski
 
El presidencialismo mexicano antes y después
El presidencialismo mexicano antes y después El presidencialismo mexicano antes y después
El presidencialismo mexicano antes y después
espejodeoesed
 
Linux as a gaming platform - Errata
Linux as a gaming platform - ErrataLinux as a gaming platform - Errata
Linux as a gaming platform - Errata
Leszek Godlewski
 
CriminalEFS-PowerPoint
CriminalEFS-PowerPointCriminalEFS-PowerPoint
CriminalEFS-PowerPoint
Jenn Amabile
 
Ecosistemas
EcosistemasEcosistemas
Ecosistemas
espejodeoesed
 
Social Media For Busy Entrepreneurs and Small Businesses
Social Media For Busy Entrepreneurs and Small Businesses Social Media For Busy Entrepreneurs and Small Businesses
Social Media For Busy Entrepreneurs and Small Businesses
Fikriyyah George
 
Crisis Subprime en España
Crisis Subprime en EspañaCrisis Subprime en España
Crisis Subprime en España
espejodeoesed
 
Linux as a gaming platform, ideology aside
Linux as a gaming platform, ideology asideLinux as a gaming platform, ideology aside
Linux as a gaming platform, ideology aside
Leszek Godlewski
 
Green Peace y WWF
Green Peace y WWFGreen Peace y WWF
Green Peace y WWF
espejodeoesed
 
Хипстеры в энтерпрайзе
Хипстеры в энтерпрайзеХипстеры в энтерпрайзе
Хипстеры в энтерпрайзе
Aleksandr Tarasov
 
каталог керасис
каталог керасискаталог керасис
каталог керасисNastasik
 
Advanced Linux Game Programming
Advanced Linux Game ProgrammingAdvanced Linux Game Programming
Advanced Linux Game Programming
Leszek Godlewski
 
OpenGL (ES) debugging
OpenGL (ES) debuggingOpenGL (ES) debugging
OpenGL (ES) debugging
Leszek Godlewski
 
Docker In Bank Unrated
Docker In Bank UnratedDocker In Bank Unrated
Docker In Bank Unrated
Aleksandr Tarasov
 
Service Discovery. Spring Cloud Internals
Service Discovery. Spring Cloud InternalsService Discovery. Spring Cloud Internals
Service Discovery. Spring Cloud Internals
Aleksandr Tarasov
 

Viewers also liked (20)

Jogos em Perl
Jogos em PerlJogos em Perl
Jogos em Perl
 
Gamedev-grade debugging
Gamedev-grade debuggingGamedev-grade debugging
Gamedev-grade debugging
 
El barrroco
El barrrocoEl barrroco
El barrroco
 
Suir img
Suir imgSuir img
Suir img
 
One Year of Porting - Post-mortem of two Linux/SteamOS launches
One Year of Porting - Post-mortem of two Linux/SteamOS launchesOne Year of Porting - Post-mortem of two Linux/SteamOS launches
One Year of Porting - Post-mortem of two Linux/SteamOS launches
 
El presidencialismo mexicano antes y después
El presidencialismo mexicano antes y después El presidencialismo mexicano antes y después
El presidencialismo mexicano antes y después
 
Imágenes inmersivas
Imágenes inmersivasImágenes inmersivas
Imágenes inmersivas
 
Linux as a gaming platform - Errata
Linux as a gaming platform - ErrataLinux as a gaming platform - Errata
Linux as a gaming platform - Errata
 
CriminalEFS-PowerPoint
CriminalEFS-PowerPointCriminalEFS-PowerPoint
CriminalEFS-PowerPoint
 
Ecosistemas
EcosistemasEcosistemas
Ecosistemas
 
Social Media For Busy Entrepreneurs and Small Businesses
Social Media For Busy Entrepreneurs and Small Businesses Social Media For Busy Entrepreneurs and Small Businesses
Social Media For Busy Entrepreneurs and Small Businesses
 
Crisis Subprime en España
Crisis Subprime en EspañaCrisis Subprime en España
Crisis Subprime en España
 
Linux as a gaming platform, ideology aside
Linux as a gaming platform, ideology asideLinux as a gaming platform, ideology aside
Linux as a gaming platform, ideology aside
 
Green Peace y WWF
Green Peace y WWFGreen Peace y WWF
Green Peace y WWF
 
Хипстеры в энтерпрайзе
Хипстеры в энтерпрайзеХипстеры в энтерпрайзе
Хипстеры в энтерпрайзе
 
каталог керасис
каталог керасискаталог керасис
каталог керасис
 
Advanced Linux Game Programming
Advanced Linux Game ProgrammingAdvanced Linux Game Programming
Advanced Linux Game Programming
 
OpenGL (ES) debugging
OpenGL (ES) debuggingOpenGL (ES) debugging
OpenGL (ES) debugging
 
Docker In Bank Unrated
Docker In Bank UnratedDocker In Bank Unrated
Docker In Bank Unrated
 
Service Discovery. Spring Cloud Internals
Service Discovery. Spring Cloud InternalsService Discovery. Spring Cloud Internals
Service Discovery. Spring Cloud Internals
 

Similar to Cross-platform game engine development with SDL 2.0

Don't Give Credit: Hacking Arcade Machines
Don't Give Credit: Hacking Arcade MachinesDon't Give Credit: Hacking Arcade Machines
Don't Give Credit: Hacking Arcade Machines
Michael Scovetta
 
Porting the Source Engine to Linux: Valve's Lessons Learned
Porting the Source Engine to Linux: Valve's Lessons LearnedPorting the Source Engine to Linux: Valve's Lessons Learned
Porting the Source Engine to Linux: Valve's Lessons Learned
basisspace
 
OpenGL Introduction.
OpenGL Introduction.OpenGL Introduction.
OpenGL Introduction.
Girish Ghate
 
Programming with OpenGL
Programming with OpenGLProgramming with OpenGL
Programming with OpenGL
Syed Zaid Irshad
 
Embedded Graphics Drivers in Mesa (ELCE 2019)
Embedded Graphics Drivers in Mesa (ELCE 2019)Embedded Graphics Drivers in Mesa (ELCE 2019)
Embedded Graphics Drivers in Mesa (ELCE 2019)
Igalia
 
Developing games and graphic visualizations in Pascal
Developing games and graphic visualizations in PascalDeveloping games and graphic visualizations in Pascal
Developing games and graphic visualizations in Pascal
Michalis Kamburelis
 
SDL2 Game Development VT Code Camp 2013
SDL2 Game Development VT Code Camp 2013SDL2 Game Development VT Code Camp 2013
SDL2 Game Development VT Code Camp 2013
Eric Basile
 
LMG Lightning Talks - SFO17-205
LMG Lightning Talks - SFO17-205LMG Lightning Talks - SFO17-205
LMG Lightning Talks - SFO17-205
Linaro
 
Introduction to Internet of Things Hardware
Introduction to Internet of Things HardwareIntroduction to Internet of Things Hardware
Introduction to Internet of Things Hardware
Daniel Eichhorn
 
Woden 2: Developing a modern 3D graphics engine in Smalltalk
Woden 2: Developing a modern 3D graphics engine in SmalltalkWoden 2: Developing a modern 3D graphics engine in Smalltalk
Woden 2: Developing a modern 3D graphics engine in Smalltalk
ESUG
 
Smartphone++
Smartphone++Smartphone++
Smartphone++
mharkus
 
13th kandroid OpenGL and EGL
13th kandroid OpenGL and EGL13th kandroid OpenGL and EGL
13th kandroid OpenGL and EGL
Jungsoo Nam
 
Raspberry Pi - HW/SW Application Development
Raspberry Pi - HW/SW Application DevelopmentRaspberry Pi - HW/SW Application Development
Raspberry Pi - HW/SW Application Development
Corley S.r.l.
 
Castle Game Engine and the joy of making and using a custom game engine
Castle Game Engine and the joy  of making and using a custom game engineCastle Game Engine and the joy  of making and using a custom game engine
Castle Game Engine and the joy of making and using a custom game engine
Michalis Kamburelis
 
Yocto and IoT - a retrospective
Yocto and IoT - a retrospectiveYocto and IoT - a retrospective
Yocto and IoT - a retrospective
Open-RnD
 
Is Android the New Embedded Linux? at AnDevCon VI
Is Android the New Embedded Linux? at AnDevCon VIIs Android the New Embedded Linux? at AnDevCon VI
Is Android the New Embedded Linux? at AnDevCon VI
Opersys inc.
 
mloc.js 2014 - JavaScript and the browser as a platform for game development
mloc.js 2014 - JavaScript and the browser as a platform for game developmentmloc.js 2014 - JavaScript and the browser as a platform for game development
mloc.js 2014 - JavaScript and the browser as a platform for game development
David Galeano
 
Ake hedman why we need to unite and why vscp is a solution to a problem
Ake hedman  why we need to unite and why vscp is a solution to a problemAke hedman  why we need to unite and why vscp is a solution to a problem
Ake hedman why we need to unite and why vscp is a solution to a problem
WithTheBest
 
Iot with-the-best & VSCP
Iot with-the-best & VSCPIot with-the-best & VSCP
Iot with-the-best & VSCP
Ake Hedman
 
pcDuino Presentation at SparkFun
pcDuino Presentation at SparkFunpcDuino Presentation at SparkFun
pcDuino Presentation at SparkFun
Jingfeng Liu
 

Similar to Cross-platform game engine development with SDL 2.0 (20)

Don't Give Credit: Hacking Arcade Machines
Don't Give Credit: Hacking Arcade MachinesDon't Give Credit: Hacking Arcade Machines
Don't Give Credit: Hacking Arcade Machines
 
Porting the Source Engine to Linux: Valve's Lessons Learned
Porting the Source Engine to Linux: Valve's Lessons LearnedPorting the Source Engine to Linux: Valve's Lessons Learned
Porting the Source Engine to Linux: Valve's Lessons Learned
 
OpenGL Introduction.
OpenGL Introduction.OpenGL Introduction.
OpenGL Introduction.
 
Programming with OpenGL
Programming with OpenGLProgramming with OpenGL
Programming with OpenGL
 
Embedded Graphics Drivers in Mesa (ELCE 2019)
Embedded Graphics Drivers in Mesa (ELCE 2019)Embedded Graphics Drivers in Mesa (ELCE 2019)
Embedded Graphics Drivers in Mesa (ELCE 2019)
 
Developing games and graphic visualizations in Pascal
Developing games and graphic visualizations in PascalDeveloping games and graphic visualizations in Pascal
Developing games and graphic visualizations in Pascal
 
SDL2 Game Development VT Code Camp 2013
SDL2 Game Development VT Code Camp 2013SDL2 Game Development VT Code Camp 2013
SDL2 Game Development VT Code Camp 2013
 
LMG Lightning Talks - SFO17-205
LMG Lightning Talks - SFO17-205LMG Lightning Talks - SFO17-205
LMG Lightning Talks - SFO17-205
 
Introduction to Internet of Things Hardware
Introduction to Internet of Things HardwareIntroduction to Internet of Things Hardware
Introduction to Internet of Things Hardware
 
Woden 2: Developing a modern 3D graphics engine in Smalltalk
Woden 2: Developing a modern 3D graphics engine in SmalltalkWoden 2: Developing a modern 3D graphics engine in Smalltalk
Woden 2: Developing a modern 3D graphics engine in Smalltalk
 
Smartphone++
Smartphone++Smartphone++
Smartphone++
 
13th kandroid OpenGL and EGL
13th kandroid OpenGL and EGL13th kandroid OpenGL and EGL
13th kandroid OpenGL and EGL
 
Raspberry Pi - HW/SW Application Development
Raspberry Pi - HW/SW Application DevelopmentRaspberry Pi - HW/SW Application Development
Raspberry Pi - HW/SW Application Development
 
Castle Game Engine and the joy of making and using a custom game engine
Castle Game Engine and the joy  of making and using a custom game engineCastle Game Engine and the joy  of making and using a custom game engine
Castle Game Engine and the joy of making and using a custom game engine
 
Yocto and IoT - a retrospective
Yocto and IoT - a retrospectiveYocto and IoT - a retrospective
Yocto and IoT - a retrospective
 
Is Android the New Embedded Linux? at AnDevCon VI
Is Android the New Embedded Linux? at AnDevCon VIIs Android the New Embedded Linux? at AnDevCon VI
Is Android the New Embedded Linux? at AnDevCon VI
 
mloc.js 2014 - JavaScript and the browser as a platform for game development
mloc.js 2014 - JavaScript and the browser as a platform for game developmentmloc.js 2014 - JavaScript and the browser as a platform for game development
mloc.js 2014 - JavaScript and the browser as a platform for game development
 
Ake hedman why we need to unite and why vscp is a solution to a problem
Ake hedman  why we need to unite and why vscp is a solution to a problemAke hedman  why we need to unite and why vscp is a solution to a problem
Ake hedman why we need to unite and why vscp is a solution to a problem
 
Iot with-the-best & VSCP
Iot with-the-best & VSCPIot with-the-best & VSCP
Iot with-the-best & VSCP
 
pcDuino Presentation at SparkFun
pcDuino Presentation at SparkFunpcDuino Presentation at SparkFun
pcDuino Presentation at SparkFun
 

Recently uploaded

Introduction of Cybersecurity with OSS at Code Europe 2024
Introduction of Cybersecurity with OSS  at Code Europe 2024Introduction of Cybersecurity with OSS  at Code Europe 2024
Introduction of Cybersecurity with OSS at Code Europe 2024
Hiroshi SHIBATA
 
[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...
[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...
[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...
Jason Yip
 
ScyllaDB Tablets: Rethinking Replication
ScyllaDB Tablets: Rethinking ReplicationScyllaDB Tablets: Rethinking Replication
ScyllaDB Tablets: Rethinking Replication
ScyllaDB
 
Must Know Postgres Extension for DBA and Developer during Migration
Must Know Postgres Extension for DBA and Developer during MigrationMust Know Postgres Extension for DBA and Developer during Migration
Must Know Postgres Extension for DBA and Developer during Migration
Mydbops
 
JavaLand 2024: Application Development Green Masterplan
JavaLand 2024: Application Development Green MasterplanJavaLand 2024: Application Development Green Masterplan
JavaLand 2024: Application Development Green Masterplan
Miro Wengner
 
Demystifying Knowledge Management through Storytelling
Demystifying Knowledge Management through StorytellingDemystifying Knowledge Management through Storytelling
Demystifying Knowledge Management through Storytelling
Enterprise Knowledge
 
What is an RPA CoE? Session 1 – CoE Vision
What is an RPA CoE?  Session 1 – CoE VisionWhat is an RPA CoE?  Session 1 – CoE Vision
What is an RPA CoE? Session 1 – CoE Vision
DianaGray10
 
Leveraging the Graph for Clinical Trials and Standards
Leveraging the Graph for Clinical Trials and StandardsLeveraging the Graph for Clinical Trials and Standards
Leveraging the Graph for Clinical Trials and Standards
Neo4j
 
Nordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptxNordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptx
MichaelKnudsen27
 
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdfHow to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
Chart Kalyan
 
LF Energy Webinar: Carbon Data Specifications: Mechanisms to Improve Data Acc...
LF Energy Webinar: Carbon Data Specifications: Mechanisms to Improve Data Acc...LF Energy Webinar: Carbon Data Specifications: Mechanisms to Improve Data Acc...
LF Energy Webinar: Carbon Data Specifications: Mechanisms to Improve Data Acc...
DanBrown980551
 
inQuba Webinar Mastering Customer Journey Management with Dr Graham Hill
inQuba Webinar Mastering Customer Journey Management with Dr Graham HillinQuba Webinar Mastering Customer Journey Management with Dr Graham Hill
inQuba Webinar Mastering Customer Journey Management with Dr Graham Hill
LizaNolte
 
AppSec PNW: Android and iOS Application Security with MobSF
AppSec PNW: Android and iOS Application Security with MobSFAppSec PNW: Android and iOS Application Security with MobSF
AppSec PNW: Android and iOS Application Security with MobSF
Ajin Abraham
 
"Frontline Battles with DDoS: Best practices and Lessons Learned", Igor Ivaniuk
"Frontline Battles with DDoS: Best practices and Lessons Learned",  Igor Ivaniuk"Frontline Battles with DDoS: Best practices and Lessons Learned",  Igor Ivaniuk
"Frontline Battles with DDoS: Best practices and Lessons Learned", Igor Ivaniuk
Fwdays
 
Freshworks Rethinks NoSQL for Rapid Scaling & Cost-Efficiency
Freshworks Rethinks NoSQL for Rapid Scaling & Cost-EfficiencyFreshworks Rethinks NoSQL for Rapid Scaling & Cost-Efficiency
Freshworks Rethinks NoSQL for Rapid Scaling & Cost-Efficiency
ScyllaDB
 
"What does it really mean for your system to be available, or how to define w...
"What does it really mean for your system to be available, or how to define w..."What does it really mean for your system to be available, or how to define w...
"What does it really mean for your system to be available, or how to define w...
Fwdays
 
QA or the Highway - Component Testing: Bridging the gap between frontend appl...
QA or the Highway - Component Testing: Bridging the gap between frontend appl...QA or the Highway - Component Testing: Bridging the gap between frontend appl...
QA or the Highway - Component Testing: Bridging the gap between frontend appl...
zjhamm304
 
Crafting Excellence: A Comprehensive Guide to iOS Mobile App Development Serv...
Crafting Excellence: A Comprehensive Guide to iOS Mobile App Development Serv...Crafting Excellence: A Comprehensive Guide to iOS Mobile App Development Serv...
Crafting Excellence: A Comprehensive Guide to iOS Mobile App Development Serv...
Pitangent Analytics & Technology Solutions Pvt. Ltd
 
Harnessing the Power of NLP and Knowledge Graphs for Opioid Research
Harnessing the Power of NLP and Knowledge Graphs for Opioid ResearchHarnessing the Power of NLP and Knowledge Graphs for Opioid Research
Harnessing the Power of NLP and Knowledge Graphs for Opioid Research
Neo4j
 
Y-Combinator seed pitch deck template PP
Y-Combinator seed pitch deck template PPY-Combinator seed pitch deck template PP
Y-Combinator seed pitch deck template PP
c5vrf27qcz
 

Recently uploaded (20)

Introduction of Cybersecurity with OSS at Code Europe 2024
Introduction of Cybersecurity with OSS  at Code Europe 2024Introduction of Cybersecurity with OSS  at Code Europe 2024
Introduction of Cybersecurity with OSS at Code Europe 2024
 
[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...
[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...
[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...
 
ScyllaDB Tablets: Rethinking Replication
ScyllaDB Tablets: Rethinking ReplicationScyllaDB Tablets: Rethinking Replication
ScyllaDB Tablets: Rethinking Replication
 
Must Know Postgres Extension for DBA and Developer during Migration
Must Know Postgres Extension for DBA and Developer during MigrationMust Know Postgres Extension for DBA and Developer during Migration
Must Know Postgres Extension for DBA and Developer during Migration
 
JavaLand 2024: Application Development Green Masterplan
JavaLand 2024: Application Development Green MasterplanJavaLand 2024: Application Development Green Masterplan
JavaLand 2024: Application Development Green Masterplan
 
Demystifying Knowledge Management through Storytelling
Demystifying Knowledge Management through StorytellingDemystifying Knowledge Management through Storytelling
Demystifying Knowledge Management through Storytelling
 
What is an RPA CoE? Session 1 – CoE Vision
What is an RPA CoE?  Session 1 – CoE VisionWhat is an RPA CoE?  Session 1 – CoE Vision
What is an RPA CoE? Session 1 – CoE Vision
 
Leveraging the Graph for Clinical Trials and Standards
Leveraging the Graph for Clinical Trials and StandardsLeveraging the Graph for Clinical Trials and Standards
Leveraging the Graph for Clinical Trials and Standards
 
Nordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptxNordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptx
 
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdfHow to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
 
LF Energy Webinar: Carbon Data Specifications: Mechanisms to Improve Data Acc...
LF Energy Webinar: Carbon Data Specifications: Mechanisms to Improve Data Acc...LF Energy Webinar: Carbon Data Specifications: Mechanisms to Improve Data Acc...
LF Energy Webinar: Carbon Data Specifications: Mechanisms to Improve Data Acc...
 
inQuba Webinar Mastering Customer Journey Management with Dr Graham Hill
inQuba Webinar Mastering Customer Journey Management with Dr Graham HillinQuba Webinar Mastering Customer Journey Management with Dr Graham Hill
inQuba Webinar Mastering Customer Journey Management with Dr Graham Hill
 
AppSec PNW: Android and iOS Application Security with MobSF
AppSec PNW: Android and iOS Application Security with MobSFAppSec PNW: Android and iOS Application Security with MobSF
AppSec PNW: Android and iOS Application Security with MobSF
 
"Frontline Battles with DDoS: Best practices and Lessons Learned", Igor Ivaniuk
"Frontline Battles with DDoS: Best practices and Lessons Learned",  Igor Ivaniuk"Frontline Battles with DDoS: Best practices and Lessons Learned",  Igor Ivaniuk
"Frontline Battles with DDoS: Best practices and Lessons Learned", Igor Ivaniuk
 
Freshworks Rethinks NoSQL for Rapid Scaling & Cost-Efficiency
Freshworks Rethinks NoSQL for Rapid Scaling & Cost-EfficiencyFreshworks Rethinks NoSQL for Rapid Scaling & Cost-Efficiency
Freshworks Rethinks NoSQL for Rapid Scaling & Cost-Efficiency
 
"What does it really mean for your system to be available, or how to define w...
"What does it really mean for your system to be available, or how to define w..."What does it really mean for your system to be available, or how to define w...
"What does it really mean for your system to be available, or how to define w...
 
QA or the Highway - Component Testing: Bridging the gap between frontend appl...
QA or the Highway - Component Testing: Bridging the gap between frontend appl...QA or the Highway - Component Testing: Bridging the gap between frontend appl...
QA or the Highway - Component Testing: Bridging the gap between frontend appl...
 
Crafting Excellence: A Comprehensive Guide to iOS Mobile App Development Serv...
Crafting Excellence: A Comprehensive Guide to iOS Mobile App Development Serv...Crafting Excellence: A Comprehensive Guide to iOS Mobile App Development Serv...
Crafting Excellence: A Comprehensive Guide to iOS Mobile App Development Serv...
 
Harnessing the Power of NLP and Knowledge Graphs for Opioid Research
Harnessing the Power of NLP and Knowledge Graphs for Opioid ResearchHarnessing the Power of NLP and Knowledge Graphs for Opioid Research
Harnessing the Power of NLP and Knowledge Graphs for Opioid Research
 
Y-Combinator seed pitch deck template PP
Y-Combinator seed pitch deck template PPY-Combinator seed pitch deck template PP
Y-Combinator seed pitch deck template PP
 

Cross-platform game engine development with SDL 2.0

  • 1. inequation.orginequation.org WGK 2013 · September 7th, 2013WGK 2013 · September 7th, 2013 Cross-platform game engine development with SDL 2.0 Leszek Godlewski Freelance Programmer lg@inequation.org
  • 2. AgendaAgenda 2 inequation.org2 inequation.org ● Who is this guy? ● Introduction to SDL ● Event pump ● New features of SDL 2.0 ● Questions
  • 3. Who is this guy?Who is this guy? 3 inequation.org3 inequation.org Freelance Programmer (Sep 2013 – onwards) ● inequation.org ● Unannounced project Generalist Programmer, The Farm 51 (Mar 2010 – Aug 2013) ● thefarm51.com ● Painkiller Hell & Damnation (2012-2013; Win/Linux/X360/PS3) ● Deadfall Adventures (2011-2013; Win/X360) ● A few unannounced projects
  • 4. Who is this guy?Who is this guy? 4 inequation.org4 inequation.org Cross-platform work ( de facto – Linux)→ ● github.com/inequation ● Toy projects, personal utilities, university stuff ● Games as well! ● AC-130 ● Crystal Space ● idTech 3-based games ● Painkiller Hell & Damnation ● Linux as preferred OS for 7+ years ● Former open-source evangelist ● Not anymore – lost interest
  • 5. AgendaAgenda 5 inequation.org5 inequation.org ● Who is this guy? ● Introduction to SDL ● Event pump ● New features of SDL 2.0 ● Questions
  • 6. What is SDL?What is SDL? 6 inequation.org6 inequation.org Simple DirectMedia Layer The cross-platform, open-source „DirectX” ● Written by Sam Lantinga (ex-Loki, ex-Blizzard, currently Valve), Ryan Gordon (legendary porter) et al. ● Provides: ● API in C with mappings to other languages ● Timers and threads ● Thread-safe input and events (incl. Unicode and IME) ● Polled and event-based APIs (incl. filtering) ● Window management (incl. OpenGL [ES] contexts) ● Audio (very barebone) ● Accelerated 2D graphics (simple drawing, blitting) ● More!
  • 7. Benefits of SDLBenefits of SDL 7 inequation.org7 inequation.org Many supported platforms ● Windows XP+ ● Linux 2.6+ ● Mac OS X 10.5+ ● Android 2.3.3+ ● iOS 4.0.1+ ● Many more: Free/Open/NetBSD, Solaris, Playstation Portable, Haiku, Pandora... Yup, mobiles!
  • 8. Benefits of SDLBenefits of SDL 8 inequation.org8 inequation.org All platform details hidden away under a unified interface! (truly one codebase shared by all of them → write once, compile anywhere)
  • 9. Benefits of SDLBenefits of SDL 9 inequation.org9 inequation.org Extremely simple – goodbye, boilerplate! int main(int argc, char** argv) { if (SDL_Init(SDL_INIT_EVERYTHING) != 0) return 1; SDL_Window *win = SDL_CreateWindow("Hello World!", 100, 100, 640, 480, SDL_WINDOW_SHOWN); SDL_Renderer *ren = SDL_CreateRenderer(win, -1, SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC); SDL_Surface *bmp = SDL_LoadBMP("hello.bmp"); SDL_Texture *tex = SDL_CreateTextureFromSurface(ren, bmp); SDL_FreeSurface(bmp); SDL_RenderClear(ren); SDL_RenderCopy(ren, tex, NULL, NULL); SDL_RenderPresent(ren); SDL_Delay(2000); SDL_DestroyTexture(tex); SDL_DestroyRenderer(ren); SDL_DestroyWindow(win); SDL_Quit(); return 0; }
  • 10. MonoGame-SDL2MonoGame-SDL2 10 inequation.org10 inequation.org Hey indies! ● MonoGame: an XNA implementation on top of Mono ● MG-SDL2: backend for MonoGame by Ethan Lee (Twitter: @flibitijibibo) ● Shipped and WIP games: ● Capsized ● FEZ ● Gateways http://github.com/flibitijibibo/MonoGame
  • 11. Sample SDL game: AC-130Sample SDL game: AC-130 11 inequation.org11 inequation.org
  • 12. AgendaAgenda 12 inequation.org12 inequation.org ● Who is this guy? ● Introduction to SDL ● Event pump ● New features of SDL 2.0 ● Questions
  • 13. Event pumpEvent pump 13 inequation.org13 inequation.org SDL encapsulates hardware, system, window management and input events ● SDL_QUIT, SDL_APP_TERMINATING, SDL_APP_LOWMEMORY, SDL_APP_WILLENTERBACKGROUND, SDL_APP_DIDENTERBACKGROUND, SDL_APP_WILLENTERFOREGROUND, SDL_APP_DIDENTERFOREGROUND, SDL_WINDOWEVENT, SDL_SYSWMEVENT, SDL_KEYDOWN, SDL_KEYUP, SDL_TEXTEDITING, SDL_TEXTINPUT, SDL_MOUSEMOTION, SDL_MOUSEBUTTONDOWN, SDL_MOUSEBUTTONUP, SDL_MOUSEWHEEL, SDL_JOYAXISMOTION, SDL_JOYBALLMOTION, SDL_JOYHATMOTION, SDL_JOYBUTTONDOWN, SDL_JOYBUTTONUP, SDL_JOYDEVICEADDED, SDL_JOYDEVICEREMOVED, SDL_CONTROLLERAXISMOTION, SDL_CONTROLLERBUTTONDOWN, SDL_CONTROLLERBUTTONUP, SDL_CONTROLLERDEVICEADDED, SDL_CONTROLLERDEVICEREMOVED, SDL_CONTROLLERDEVICEREMAPPED, SDL_FINGERDOWN, SDL_FINGERUP, SDL_FINGERMOTION, SDL_DOLLARGESTURE, SDL_DOLLARRECORD, SDL_MULTIGESTURE, SDL_CLIPBOARDUPDATE, SDL_DROPFILE, SDL_USEREVENT ● SDL_PeepEvents(), SDL_PollEvents(), SDL_WaitEvent()... ● Filtering: simple, by type (SDL_EventState()) or complex with callbacks (SDL_EventFilter) ● Custom user events - SDL_RegisterEvents()
  • 14. Event pumpEvent pump 14 inequation.org14 inequation.org ● Probably the single coolest feature! ● One switch in a loop takes care of almost everything ● Typical SDL application structure: ● Subsystem initialization ● Event pump ● Cleanup ● That's it!
  • 15. Sample SDL game: AC-130Sample SDL game: AC-130 15 inequation.org15 inequation.org <AC-130 main loop breakdown> github.com/inequation/ac130
  • 16. AgendaAgenda 16 inequation.org16 inequation.org ● Who is this guy? ● Introduction to SDL ● Event pump ● New features of SDL 2.0 ● Questions
  • 17. Current state of SDL 2Current state of SDL 2 17 inequation.org17 inequation.org ● First stable release, 2.0.0, announced August 11th ● Present in the Steam Linux Runtime since early RCs ● Valve games and others rely on it ● Documentation is slightly outdated ● Ongoing effort, gaps being quickly filled ● You might be misled to believe a feature is missing... ● When in doubt, read header file comments or generate your own docs
  • 18. What's new in SDL 2What's new in SDL 2 18 inequation.org18 inequation.org ● OpenGL 3+ support ● Incl. context sharing (finally!) ● OpenGL ES support ● Haptic (force) feedback ● Game controller API ● Android and iOS support ● Touch input with gestures ● Support for multiple displays, windows, audio devices ● IME and proper Unicode support ● Pluggable 2D renderer backends ● Portable atomic operations ● Power management ● Rudimentary UI (message boxes etc.) ● Clipboard & drag-and-drop support
  • 19. OpenGL context sharingOpenGL context sharing 19 inequation.org19 inequation.org Finally – yay for multithreaded/multi-window rendering! ☺ ● Undocumented... ☹ FIXED as of August 11th ● Only mention in Google is the May 2012 commit that introduces the feature ● Needs an SDL-OpenGL attribute set before window creation: SDL_GL_SetAttribute( SDL_GL_SHARE_WITH_CURRENT_CONTEXT, 1); ● Voila - all contexts created from now on with SDL_GL_CreateContext() will share data with the currently bound context (buffers, shaders etc.)!
  • 20. OpenGL context sharingOpenGL context sharing 20 inequation.org20 inequation.org Gotcha: pre-RC4 SDL2 keeps a global reference to the current window/GL context pair ● Care must be taken when unbinding contexts (e.g. when killing worker threads)! // … SDL_GL_MakeCurrent(NULL, NULL); // most SDL_GL_* calls made on any thread // will crash now :( ● Solution: simply bind back to the main window and context instead of unbinding SDL_GL_MakeCurrent(MainWindow, MainGLCtx);
  • 21. OpenGL context sharingOpenGL context sharing 21 inequation.org21 inequation.org Gotcha: pre-RC4 SDL2 keeps a global reference to the current window/GL context pair RC4 and newer (incl. 2.0.0 stable) – nothing to worry about ☺ ● Some distros still ship <= RC4 ● Ship your own or use Steam Linux Runtime (fixed on 11 Jul 2013, rev. 50211a1fd557)
  • 22. Full-screen quirksFull-screen quirks 22 inequation.org22 inequation.org Gotcha: full-screen in Linux is hacky ☹ ● X11 doesn't really support „true” full-screen windows ● Actually just a decoration-less window ● SDL_WINDOW_FULLSCREEN uses an XRandR hack ● Change display mode while maintaining desktop size ● Crop the „viewport” ● Side effect: „viewport” follows mouse and may scroll away from app window... Bad! ☹ ● SDL_WINDOW_FULLSCREEN_DESKTOP simply creates a desktop-sized window, no XRandR magic ● Render to offscreen buffer (FBO), then blit with scaling ● This is what Valve does!
  • 23. Game controller API: SDL_GameController*Game controller API: SDL_GameController* 23 inequation.org23 inequation.org Unified gamepad/joystick handling ● Layout modelled after the Xbox 360 controller ● Built by Valve with Steam Big Picture in mind ● Button/axis mapping support for other controllers ● Kind of a built-in equivalent to Xpadder ● Bindings may be imported/exported via strings ● Popular controllers have built-in mappings ● Hotplug support – yay! ● May be polled for state or handled with events ● API very similar to the regular joystick API, but buttons and axes are identified by enumerations instead ● SDL_GameControllerAxis ● SDL_GameControllerButton
  • 24. Game controller API: SDL_GameController*Game controller API: SDL_GameController* 24 inequation.org24 inequation.org Gotcha: joystick/game controller API interop ● GC API is implemented on top of the SDL joystick API ● SDL GC subsystem initialization implies joystick subsystem initialization ● Regular joystick events are issued for GCs as well! ● This means double events for the axes, buttons, even hotplugs! ● Don't need joystick hats, arbitrary axes etc.? Just filter out joystick events altogether ● Otherwise you can identify the device type with SDL_IsGameController()
  • 25. Haptic feedback: SDL_Haptic*Haptic feedback: SDL_Haptic* 25 inequation.org25 inequation.org ● Powerful API with more than just rumbles ● Remember arcade racing machines that blocked the steering wheel and pedals? ● Haptic devices may be stand-alone (e.g. rumble motors in mobile devices) or derived from joysticks with SDL_HapticOpenFromJoystick() ● Simplified API for rumbles
  • 26. TakeawayTakeaway 26 inequation.org26 inequation.org ● Battle-proven low-level abstraction layer ● Ships with the Steam Linux Runtime ● Support for many platforms, including Windows, Linux, Mac, mobiles and some handheld consoles ● Provides a universal event pump ● Integrates well with OpenGL ● Exposes game controllers and force feedback ● Open-source! libsdl.org bugzilla.libsdl.org
  • 27. inequation.orginequation.org Questions? lg@inequation.org WGK 2013 · September 7th, 2013WGK 2013 · September 7th, 2013