SlideShare a Scribd company logo
1 of 70
Download to read offline
Mono	
  for	
  Game	
  Developers	
  

            Miguel	
  de	
  Icaza	
  
        miguel@xamarin.com,	
  @migueldeicaza	
  
                        	
  

                Xamarin	
  Inc	
  
Agenda	
  
•    Mono	
  in	
  Games	
  
•    Using	
  Mono	
  for	
  Games	
  
•    Performance	
  
•    Garbage	
  CollecKon	
  
•    Co-­‐rouKnes,	
  Asynchronous	
  Programming	
  




                     Mono	
  for	
  Game	
  Developers	
  –	
  AltDevConf	
  2012	
     h=p://www.xamarin.com	
  
MONO  IN  GAMES  
C#	
  

     Java	
  

 JavaScript	
  

     Ruby	
  


   Python	
  


Visual	
  Basic	
  


       F#	
  
                      Mono	
  for	
  Game	
  Developers	
  –	
  AltDevConf	
  2012	
     h=p://www.xamarin.com	
  
C#	
  

     Java	
  

 JavaScript	
  

     Ruby	
  


   Python	
  


Visual	
  Basic	
  


       F#	
  
                      Mono	
  for	
  Game	
  Developers	
  –	
  AltDevConf	
  2012	
     h=p://www.xamarin.com	
  
Sims	
  3	
  
•  Mixed	
  Code:	
  
    –  C/C++	
  engine	
  
    –  C#	
  scripKng/AI	
  
    –  C#	
  high-­‐level	
  


•  Visual	
  Studio	
  +	
  Mono	
  

•  X86,	
  PS3,	
  Xbox360	
  
	
  
                                                 Credit:	
  	
  www.thesims3facts.webs.com	
  
BasKon	
  –	
  on	
  Google	
  Chrome	
  NaCl	
  
•  C#	
  XNA	
  codebase	
  

•  Originally	
  on	
  Xbox	
  

•  Ported	
  to	
  NaKveClient	
  
    –  Mono	
  
    –  MonoGame	
  (XNA)	
  


•  Mac,	
  Windows,	
  Linux	
  
Pure	
  C#	
  -­‐	
  SoulCra_	
  
•  DeltaEngine	
  
   –  Pure	
  C#	
  engine	
  
   –  Open	
  source	
  
   –  Android,	
  iOS,	
  Mac,	
  Win	
  
Unity	
  3D	
  
•  Unity	
  Engine	
  
    –  C/C++	
  game	
  engine	
  
    –  Embedded	
  Mono	
  
•  User	
  code	
  
    –  C#	
  or	
  UnityScript	
  
    –  Extends	
  Unity	
  itself	
  
    	
  
    	
  



                                                Shadow	
  Gun,	
  built	
  with	
  Unity	
  
SecondLife	
  
•    Mono	
  on	
  the	
  server	
  
•    Powers	
  LSL	
  scripts	
  
•    Nice	
  200x	
  perf	
  boost	
  
•    Code	
  InjecKon	
  
Infinite	
  Flight	
  
•  Subject	
  of	
  the	
  second	
  
   part	
  of	
  this	
  session	
  
WHY  MONO?  
Because	
  Life	
  is	
  too	
  Short	
  

•  To	
  debug	
  another	
  memory	
  leak	
  

•  To	
  track	
  another	
  memory	
  corrupKon	
  bug	
  

•  Because	
  you	
  deserve	
  be=er	
  


                      Mono	
  for	
  Game	
  Developers	
  –	
  AltDevConf	
  2012	
     h=p://www.xamarin.com	
  
The	
  Quest	
  for	
  ProducKvity	
  
System  Languages                          Scrip<ng  Languages  
Pros:	
                                    Pros:	
  
•  Low-­‐level	
                           •  High-­‐level,	
  good	
  producKvity	
  
•  Good	
  control	
  of	
  hardware	
  
•  Typed	
                                 •  Easy	
  to	
  write	
  
•  Fast	
  code	
                          •  Safe,	
  prevent	
  crashes	
  
                                           •  Loosely	
  typed	
  
Cons:	
                                    	
  
•  Easy	
  to	
  corrupt	
  state	
        Cons:	
  
•  Low	
  producKvity	
  
                                           •  Poor	
  control	
  of	
  hardware	
  
•  Crash	
  o_en	
  
•  Complex	
  for	
  newcomers	
           •  Slow	
  (interpreted)	
  
John	
  Ousterhout	
  ScripKng	
  Quest	
  
                IEEE	
  1998	
  Summary	
  Paper	
  	
  




                                          Mono	
  for	
  Game	
  Developers	
  –	
  AltDevConf	
  2012	
  
h=p://www.stanford.edu/~ouster/cgi-­‐bin/papers/scripKng.pdf	
                                               h=p://www.xamarin.com	
  
John	
  was	
  always	
  ahead	
  of	
  his	
  Kme	
  

•  Professional	
  workstaKons	
  in	
  1998	
  
    –  SPARC,	
  HP-­‐PA	
  


•  Not	
  achievable	
  on	
  PCs	
  of	
  the	
  Kme	
  




                          Mono	
  for	
  Game	
  Developers	
  –	
  AltDevConf	
  2012	
     h=p://www.xamarin.com	
  
2000	
  –	
  Desktop	
  Development	
  
•  Building	
  desktop	
  apps	
  with	
  C	
  and	
  C++	
  
     –  Slow	
  progress,	
  error	
  prone,	
  frequent	
  crashes	
  

•  Windows	
  2000	
  Requirements:	
  
     –  133	
  Mhz	
  or	
  more	
  
     –  64	
  megs	
  for	
  desktop,	
  256	
  for	
  server	
  

•  Windows	
  XP	
  Requirements	
  (one	
  year	
  later)	
  
     –  233Mhz	
  or	
  more	
  
     –  128	
  megs	
  for	
  desktop	
  

•  Development	
  desktops	
  at	
  the	
  Kme:	
  
     –  ~1Ghz	
  speed	
  
     –  ~1	
  GB	
  of	
  memory	
  

                                       Mono	
  for	
  Game	
  Developers	
  –	
  AltDevConf	
  2012	
     h=p://www.xamarin.com	
  
C#	
  Introduced	
  in	
  2000	
  
•  C#	
  1.0	
  was	
  a	
  Java-­‐like	
  system	
  

•  With	
  many	
  design	
  fixes	
  
    –  10	
  years	
  of	
  experience	
  
    –  Change	
  defaults	
  (all	
  virtual,	
  vs	
  opt-­‐in	
  virtual)	
  
    –  Introduce	
  structs	
  (help	
  GC,	
  no	
  boxing)	
  
    –  Direct	
  access	
  to	
  naKve	
  libraries	
  (P/Invoke)	
  
    –  Delegates	
  (foundaKon	
  for	
  lambdas)	
  

                            Mono	
  for	
  Game	
  Developers	
  –	
  AltDevConf	
  2012	
     h=p://www.xamarin.com	
  
Language	
  Choices	
  
                                         	
  
                          Fully	
  Dynamic	
  
    Easy	
  
                                                       C#/Java	
  
     ProducKvity	
  




                                                                     C/C++	
  



                                                                          Assembly	
  Language	
  
Difficult	
  

                       Slow	
                                              Fast	
  
                                            Performance	
  
Game	
  So_ware	
  Components	
  
                        .	
  


Display	
          SimulaKon	
          Game	
  Logic	
            Support	
  

•  Rendering	
       •  Physics	
          •  World	
  rules	
     •  Audio	
  
•  Shading	
         •  Collision	
        •  Enemy	
  AI	
        •  Input	
  
•  Scene	
           •  ParKcles	
         •  User	
               •  Networking	
  
•  AnimaKon	
        •  Terrain	
             control	
  
•  Geometry	
                              •  Camera	
  
•  GUI	
                                   •  Behavior	
  
The	
  Problem	
  
                     Games	
  are	
  real-­‐Kme	
  programs	
  
•  30	
  to	
  60	
  frames	
  per	
  second	
  (0.016	
  seconds)	
  


   Input	
                             AI	
                   Updates	
  
  	
                               	
                         	
  
  •  User	
  control	
             •  Scripted,	
  slow	
     •  Render	
  Graphics	
  
  •  Network	
                     •  React	
  to	
           •  Play	
  audio	
  
       events	
                         change	
  
                                   •  Update	
  scene	
  
Problem:	
  	
  ScripKng	
  Is	
  A	
  Bo=leneck	
  
                        Gaming's	
  Achilles'	
  Heel	
  

Display	
              SimulaKon	
                Game	
  Logic	
                 Support	
  

•  Rendering	
           •  Physics	
                •  World	
  rules	
          •  Audio	
  
•  Shading	
             •  Collision	
              •  Enemy	
  AI	
             •  Input	
  
•  Scene	
               •  ParKcles	
               •  User	
                    •  Networking	
  
•  AnimaKon	
            •  Terrain	
                   control	
  
•  Geometry	
                                        •  Camera	
  
•  GUI	
                                             •  Behavior	
  




           C/C++	
                    C/C++	
                        Script	
                   C/C++	
  
Problem:	
  	
  ScripKng	
  Is	
  A	
  Bo=leneck	
  
                        Gaming's	
  Achilles'	
  Heel	
  

Display	
              SimulaKon	
                Game	
  Logic	
                 Support	
  

•  Rendering	
           •  Physics	
                •  World	
  rules	
          •  Audio	
  
•  Shading	
             •  Collision	
              •  Enemy	
  AI	
             •  Input	
  
•  Scene	
               •  ParKcles	
               •  User	
                    •  Networking	
  
•  AnimaKon	
            •  Terrain	
                   control	
  
•  Geometry	
                                        •  Camera	
  
•  GUI	
                                             •  Behavior	
  




           C/C++	
                    C/C++	
                        Script	
                   C/C++	
  

                                                                       C#	
  
What	
  C#	
  Offers	
  
•  Close	
  to	
  naKve	
  performance	
  
   –  50%-­‐90%	
  of	
  naKve	
  performance	
  


•  Safe	
  ExecuKon	
  Environment	
  
   –  With	
  opKonal	
  support	
  to	
  shoot	
  yourself	
  in	
  the	
  
      foot.	
  




                          Mono	
  for	
  Game	
  Developers	
  –	
  AltDevConf	
  2012	
     h=p://www.xamarin.com	
  
C#	
  -­‐	
  An	
  Evolving	
  Language	
  
                                                           2012	
      5.0	
       Asynchronous	
  Programming	
  



                                             2010	
      4.0	
        Dynamic	
  extensions	
  



                             2007	
      3.0	
          Language	
  Integrated	
  Query,	
  FuncKonal	
  



              2005	
      2.0	
         Generics,	
  Iterators,	
  Lambdas	
  



2002	
     1.0	
         Managed	
  Code,	
  strongly	
  typed	
  
USING  MONO  
Designing	
  Mono	
  ApplicaKons	
  
•  Provided:	
  
   –  C#	
  Language	
  
   –  Base	
  Class	
  Libraries	
  


•  Not	
  Provided:	
  
   –  User	
  Interface,	
  Graphics,	
  Audio	
  
   –  These	
  are	
  all	
  plaqorm	
  specific	
  


                          Mono	
  for	
  Game	
  Developers	
  –	
  AltDevConf	
  2012	
     h=p://www.xamarin.com	
  
Code	
  Sharing	
  and	
  NaKve	
  Experience	
  



                            C#	
                               Core	
  Engine,	
  Shared	
  Logic,	
  Business	
  Logic	
  
                                         	
  
                 Plus	
  ECMA	
  languages




                     RunKme	
                     .NET	
                                            Mono	
  



                                                Windows	
  
                            OS	
                  Xbox	
                     Mac	
                    iOS	
                   Android	
  
                                                WinPhone	
  

Not	
  a	
  comprehensive	
  list	
  
Code	
  Sharing	
  and	
  NaKve	
  Experience	
  

                    NaKve	
  UI	
                 XAML	
  
                                                                         MonoMac	
               MonoTouch	
             MonoDroid	
  
                      APIs	
                       XNA	
  




                            C#	
                               Core	
  Engine,	
  Shared	
  Logic,	
  Business	
  Logic	
  
                                         	
  
                 Plus	
  ECMA	
  languages




                     RunKme	
                     .NET	
                                            Mono	
  



                                                Windows	
  
                            OS	
                  Xbox	
                     Mac	
                    iOS	
                   Android	
  
                                                WinPhone	
  

Not	
  a	
  comprehensive	
  list	
  
Modes	
  of	
  Use	
  
•  Drive	
  the	
  applicaKon	
  
•  ScripKng	
  engine	
  
   –  Sandboxed	
  
   –  Full	
  access	
  




                            Mono	
  for	
  Game	
  Developers	
  –	
  AltDevConf	
  2012	
     h=p://www.xamarin.com	
  
Run	
  on	
  Mono	
  




 Mono	
  for	
  Game	
  Developers	
  –	
  AltDevConf	
  2012	
     h=p://www.xamarin.com	
  
Run	
  on	
  Mono	
  

          Game	
  –	
  Your	
  C#	
  Code	
  

 Mono	
                              C#/.NET	
  Libraries	
  
RunKme	
  
               MonoGame	
                                     OpenTK	
                 Physics	
  

OperaKng	
  
 System	
       OpenAL	
                                      OpenGL	
               Networking	
  

                  Mono	
  for	
  Game	
  Developers	
  –	
  AltDevConf	
  2012	
       h=p://www.xamarin.com	
  
Using	
  Mono	
  as	
  a	
  Library	
  




         Mono	
  for	
  Game	
  Developers	
  –	
  AltDevConf	
  2012	
     h=p://www.xamarin.com	
  
Use	
  Mono	
  as	
  a	
  Library	
  

               Game	
  Engine	
  
Game	
  Engine	
  Libraries	
                                                            Mono	
  

                                                                                     Game	
  –	
  Your	
  
   Audio	
                    Graphics	
  
                                                                                       C#	
  Code	
  
                  Mono	
  for	
  Game	
  Developers	
  –	
  AltDevConf	
  2012	
             h=p://www.xamarin.com	
  
TIPS  ON  USING  MONO  
Two	
  Code	
  GeneraKon	
  Backends	
  
Mono’s  Na<ve  Backend                   LLVM  Backend  

•  Very	
  fast	
  codegen	
             •  Very	
  slow	
  codegen	
  
     –  .3	
  seconds	
  bootstrap	
          –  7	
  second	
  bootstrap	
  


•  Not	
  great	
  code	
  output	
      •  Great	
  output	
  quality	
  

•  JIT’s	
  default	
  engine	
          •  Opt-­‐in:	
  
                                              –  mono  -­‐-­‐llvm
Just	
  in	
  Time	
  vs	
  Ahead	
  of	
  Time	
  
•  Just	
  in	
  Time	
  CompilaKon	
  
   –  Default	
  Mode	
  of	
  OperaKon	
  
   –  Very	
  fast	
  at	
  compiling	
  code	
  
   –  Not	
  great	
  quality	
  of	
  code	
  generaKon	
  

•  Ahead	
  of	
  Time	
  CompilaKon	
  
   –  Mandatory	
  on	
  some	
  plaqorms	
  
       •  PS3,	
  XBox360,	
  iOS	
  	
  
   –  Can	
  afford	
  expensive	
  compiler	
  opKmizaKons	
  

                              Mono	
  for	
  Game	
  Developers	
  –	
  AltDevConf	
  2012	
     h=p://www.xamarin.com	
  
Arrays	
  Bounds	
  Checking	
  



Mono	
  RunKme	
  translates	
  this	
  to:	
  




                      Mono	
  for	
  Game	
  Developers	
  –	
  AltDevConf	
  2012	
     h=p://www.xamarin.com	
  
Disabling	
  Arrays	
  Bounds	
  Checking	
  
•  Very	
  unsafe	
  
    –  GC	
  depends	
  on	
  system	
  integrity	
  
    –  But	
  admissible	
  if	
  no	
  error	
  ever	
  found	
  on	
  tesKng	
  


•  We	
  give	
  you	
  the	
  tools	
  to	
  shoot	
  your	
  feet	
  
    –  mono  –O=unsafe


•  Ask	
  your	
  QA	
  team	
  
                            Mono	
  for	
  Game	
  Developers	
  –	
  AltDevConf	
  2012	
     h=p://www.xamarin.com	
  
GARBAGE  COLLECTION  
Mono’s	
  Garbage	
  Collectors	
  
•  Boehm	
  GC:	
  
   –  TradiKonal	
  Mono	
  GC	
  
   –  Mostly-­‐precise,	
  stack	
  conservaKve	
  
   –  Scans	
  everything	
  on	
  each	
  GC	
  

•  GeneraKonal	
  Collector	
  (SGen)	
  
   –  New	
  (default	
  on	
  Android)	
  
   –  GeneraKonal	
  (Old	
  generaKon,	
  nurseries)	
  
   –  Copying	
  (plus	
  mark+sweep	
  for	
  large	
  objects)	
  

                        Mono	
  for	
  Game	
  Developers	
  –	
  AltDevConf	
  2012	
     h=p://www.xamarin.com	
  
SGen	
  

                                                                                     Old	
  
             Nursery	
  
                                                                                  GeneraKon	
  

• New	
  objects	
                                   • Aged	
  objects	
  
• Small	
  size	
  (4MB)	
                           • Slower	
  collecKon	
  
• Per	
  thread	
  regions	
                         • Fixed	
  or	
  variable	
  
• Very	
  fast	
                                       heaps	
  
  collecKon	
                                        • Parallel	
  collecKon	
  
                        Mono	
  for	
  Game	
  Developers	
  –	
  AltDevConf	
  2012	
      h=p://www.xamarin.com	
  
Garbage	
  CollecKon	
  
Memory  Allocated                             Released  later  




 Garbage	
  Collector	
  determines	
  when	
  to	
  run	
  and	
  release	
  memory	
  

 •  HeurisKcs	
  are	
  plaqorm-­‐specific	
  
 •  GC.Collect()	
  is	
  the	
  only	
  determinisKc	
  opKon	
  
 	
  
Best	
  PracKces	
  
•  Pre-­‐allocate	
  major	
  objects	
  before	
  Game	
  Loop	
  
    –  Managed	
  objects	
  
    –  Or	
  unmanaged	
  buffers	
  
    –  Try	
  to	
  only	
  use	
  the	
  nursery	
  (stay	
  under	
  4M)	
  
    –  If	
  you	
  must	
  collect,	
  only	
  collect	
  the	
  nursery:	
  
         •  GC.Collect	
  (0)	
  –	
  Performs	
  only	
  a	
  nursery	
  collecKon	
  
         •  GC.Collect	
  ()	
  –	
  Performs	
  a	
  complete	
  GC	
  on	
  the	
  heap	
  


•  On	
  Main	
  loop:	
  
    –  Use	
  structs	
  instead	
  of	
  classes	
  

                                 Mono	
  for	
  Game	
  Developers	
  –	
  AltDevConf	
  2012	
     h=p://www.xamarin.com	
  
Schedule	
  GC	
  CollecKon	
  

                    Game	
                    Game	
                         Game	
                      Network	
          Audio	
  
 Physics	
  
                    Logic	
  1	
              Logic	
  2	
                   Logic	
  3	
                 Checks	
         Updates	
  




               Game	
                Game	
                   Game	
                       GC	
              Network	
         Audio	
  
Physics	
  
               Logic	
  1	
          Logic	
  2	
             Logic	
  3	
               Collect	
            Checks	
        Updates	
  

                                                                                  GC.Collect	
  (0)	
  	
  
                                                                                  Limit	
  CollecKon	
  to	
  Nursery	
  

                                      Mono	
  for	
  Game	
  Developers	
  –	
  AltDevConf	
  2012	
                   h=p://www.xamarin.com	
  
Mono’s	
  GC	
  Thread	
  Control	
  
•  Garbage	
  CollecKon	
  Stops	
  all	
  Mono	
  Threads	
  
•  Non-­‐Mono	
  threads	
  are	
  not	
  affected	
  

•  AlternaKve:	
  
    •  Use	
  a	
  Render	
  Scene	
  +	
  Render	
  Thread	
  	
  
    •  Like	
  Apple’s	
  CoreAnimaKon	
  or	
  Microso_	
  WPF	
  

                                 Game	
                               Network	
  
        Mono	
                                                                                        IO	
  Thread	
  
                                 Thread	
                              Thread	
  


                    Render	
  
                    Scene	
  

                                                                                                                  Mono	
  Thread	
  
       Render	
              Real	
  Time	
  
       Thread	
              Thread	
  1	
                                                                        NaKve	
  Thread	
  

                                   Mono	
  for	
  Game	
  Developers	
  –	
  AltDevConf	
  2012	
                 h=p://www.xamarin.com	
  
COROUTINES  
State-­‐based	
  programming	
  




        Mono	
  for	
  Game	
  Developers	
  –	
  AltDevConf	
  2012	
     h=p://www.xamarin.com	
  
Problems	
  with	
  Callbacks	
  and	
  State-­‐Machines	
  Systems	
  

•  RepeKKve	
  

•  Cumbersome	
  

•  Error	
  Prone	
  

•  Poor	
  Error	
  PropagaKon	
  protocols/pracKces	
  

•  Life	
  is	
  too	
  short	
  

                               Mono	
  for	
  Game	
  Developers	
  –	
  AltDevConf	
  2012	
     h=p://www.xamarin.com	
  
Co-­‐rouKnes	
  
•  Popular	
  soluKon	
  to	
  simplify	
  AI	
  code	
  
•  Each	
  Game	
  Object	
  has	
  a	
  script	
  a=ached	
  
    –  Runs	
  Game	
  Logic	
  
    –  AI	
  bits	
  

•  Many	
  soluKons	
  
    –  longjmp/setjmp	
  for	
  unmanaged	
  code	
  
    –  Stack	
  fiddling	
  (Mono.Tasklets)	
  
    –  Interpreted	
  languages	
  with	
  VM	
  support	
  
                          Mono	
  for	
  Game	
  Developers	
  –	
  AltDevConf	
  2012	
     h=p://www.xamarin.com	
  
C#	
  5.0	
  and	
  Async	
  Programming	
  
•  Mono	
  master	
  has	
  a	
  complete	
  C#	
  5	
  Compiler	
  

•  Turns	
  repeKKve	
  callback-­‐based	
  async	
  
   programming	
  into	
  linear	
  programming	
  
   –  Compiler	
  rewrites	
  the	
  code	
  into	
  a	
  state	
  machine	
  
   –  Tasks	
  are	
  scheduled	
  on	
  the	
  main	
  thread	
  
   –  Scheduling	
  is	
  customizable	
  

•  Originally	
  designed	
  for	
  interacKve	
  UIs	
  
                         Mono	
  for	
  Game	
  Developers	
  –	
  AltDevConf	
  2012	
     h=p://www.xamarin.com	
  
Using	
  Await	
  




Mono	
  for	
  Game	
  Developers	
  –	
  AltDevConf	
  2012	
     h=p://www.xamarin.com	
  
The	
  Magic	
  
•  Await	
  lets	
  you	
  write	
  linear	
  code	
  

•  Lets	
  you	
  focus	
  on	
  the	
  problem	
  
    –  The	
  compiler	
  is	
  at	
  your	
  service	
  


•  Microso_	
  convenKons	
  for	
  responsive	
  UIs:	
  
    –  If	
  it	
  takes	
  more	
  than	
  50ms,	
  make	
  it	
  async	
  


                             Mono	
  for	
  Game	
  Developers	
  –	
  AltDevConf	
  2012	
     h=p://www.xamarin.com	
  
More	
  on	
  await
•  await	
  introduces	
  a	
  suspension	
  point	
  
   –  Code	
  returns	
  to	
  caller	
  
   –  ExecuKon	
  resumes	
  a_er	
  “await”	
  instrucKon	
  
   –  Very	
  cheap	
  memory-­‐wise	
  

•  Works	
  with	
  IO,	
  Networking	
  stacks,	
  slow	
  code	
  
   –  System.IO,	
  System.Net,	
  Database	
  access	
  
   –  Slow	
  processing:	
  XML,	
  Json	
  data	
  
   –  Blends	
  transparently	
  with	
  Threads	
  on	
  mulK-­‐cores	
  
                        Mono	
  for	
  Game	
  Developers	
  –	
  AltDevConf	
  2012	
     h=p://www.xamarin.com	
  
Li=le	
  more	
  interesKng	
  




       Mono	
  for	
  Game	
  Developers	
  –	
  AltDevConf	
  2012	
     h=p://www.xamarin.com	
  
Current	
  Trends	
  in	
  Async	
  Programming	
  
  Callback	
  based	
  
  	
  
  Where:	
  
  •  GUI	
  programming	
  
  •  Scalable	
  web	
  servers	
  
  •  Responsive	
  mobile	
  and	
  desktop	
  applicaKons	
  




                         Mono	
  for	
  Game	
  Developers	
  –	
  AltDevConf	
  2012	
     h=p://www.xamarin.com	
  
With	
  some	
  error	
  handling.	
  




          Mono	
  for	
  Game	
  Developers	
  –	
  AltDevConf	
  2012	
     h=p://www.xamarin.com	
  
C#	
  5.0	
  Async	
  Support	
  




       Mono	
  for	
  Game	
  Developers	
  –	
  AltDevConf	
  2012	
     h=p://www.xamarin.com	
  
Q&A	
  
•  Mono,	
  ISO	
  Standard,	
  C#	
  Async	
  
      –  h=p://www.mono-­‐project.com	
  
      –  ISO	
  Standard:	
  h=p://bit.ly/cli-­‐iso-­‐standard	
  
      –  C#	
  Async:	
  h=p://msdn.microso_.com/en-­‐us/vstudio/gg316360	
  

•  Xamarin,	
  Mono	
  on	
  iOS,	
  Android:	
  
      –  Discount	
  for	
  AltDevConf	
  a=endees:	
  	
  
      –  h=p://www.xamarin.com/altdevconf	
  

•  Contact:	
  
      –  miguel@xamarin.com,	
  @migueldeicaza	
  

•  Resources:	
  
      –  @MonoGameTeam,	
  @Unity3D	
  

•  Live	
  Chat	
  on	
  IRC:	
  irc.gnome.org	
  	
  
      –  #mono,	
  #monotouch,	
  #monodroid,	
  #monogame	
  

                                       Mono	
  for	
  Game	
  Developers	
  –	
  AltDevConf	
  2012	
     h=p://www.xamarin.com	
  
BACKUP  SLIDES  
Iterators	
  
•  C#	
  compiler	
  provided	
  assistance	
  
    –  Built	
  on	
  top	
  of	
  C#	
  IEnumerable	
  
    –  C#	
  compiler	
  rewrites	
  iterators	
  into	
  state	
  machines	
  

•  Developers	
  build	
  on	
  top	
  of	
  convenKons	
  

•  Unity3D	
  uses	
  this	
  approach	
  

•  Open	
  Source	
  Iterator	
  game	
  framework:	
  
    –    http://mjhutchinson.com/journal/2010/02/01/iteratorbased_microthreading




                              Mono	
  for	
  Game	
  Developers	
  –	
  AltDevConf	
  2012	
     h=p://www.xamarin.com	
  
Iterator	
  based	
  code	
  




     Mono	
  for	
  Game	
  Developers	
  –	
  AltDevConf	
  2012	
     h=p://www.xamarin.com	
  
Mono.Tasklets	
  
•  Pros:	
  
    –  No	
  need	
  to	
  rewrite	
  code	
  
    –  You	
  can	
  suspend	
  execuKon/resume	
  without	
  new	
  
       convenKons.	
  

•  Cons:	
  
    –  Not	
  available	
  on	
  every	
  plaqorm	
  –	
  Stack	
  Fiddling	
  
    –  Does	
  not	
  work	
  with	
  Mono’s	
  new	
  Precise	
  GC	
  
    –  In	
  parKcular,	
  wont	
  work	
  with	
  Microso_	
  .NET	
  

                           Mono	
  for	
  Game	
  Developers	
  –	
  AltDevConf	
  2012	
     h=p://www.xamarin.com	
  
Not	
  a	
  comprehensive	
  list	
  

GAME  ENGINES  USING  C#  
Unity	
  3D	
  
•  Commercial	
  Engine	
  
•  Very	
  extensive	
  support:	
  
   –  Consoles:	
  XBox360,	
  PS3,	
  Wii	
  
   –  iOS,	
  Android	
  
   –  Mac,	
  Windows	
  
   –  Google	
  NaKve	
  Client	
  
   –  Flash	
  target	
  


                        Mono	
  for	
  Game	
  Developers	
  –	
  AltDevConf	
  2012	
     h=p://www.xamarin.com	
  
MonoGame	
  –	
  Open	
  Source	
  XNA	
  
•  Open	
  Source	
  XNA	
  implementaKon	
  
    –  Currently	
  2D-­‐based	
  
    –  3D	
  support	
  coming	
  

•  Runs	
  on	
  many	
  plaqorms:	
  
    –  iOS	
  (iPhone,	
  iPad)	
  
    –  Android	
  (phones	
  and	
  tablets)	
  
    –  Linux	
  
    –  Mac	
  
    –  Windows	
  

                           Mono	
  for	
  Game	
  Developers	
  –	
  AltDevConf	
  2012	
     h=p://www.xamarin.com	
  
Delta	
  Engine	
  
•  Open	
  Source	
  Game	
  Engine	
  
•  Wri=en	
  100%	
  in	
  C#	
  
•  Runs	
  on:	
  
   –  Android	
  
   –  Windows	
  Phone	
  
   –  iOS	
  
   –  Mac	
  
   –  Windows	
  

                     Mono	
  for	
  Game	
  Developers	
  –	
  AltDevConf	
  2012	
     h=p://www.xamarin.com	
  
Axiom	
  
•    Open	
  source	
  
•    Based	
  on	
  the	
  OGRE	
  C++	
  Engine	
  
•    Windows,	
  Linux	
  
•    XNA,	
  DirectX	
  and	
  OpenGL	
  support	
  	
  




                         Mono	
  for	
  Game	
  Developers	
  –	
  AltDevConf	
  2012	
     h=p://www.xamarin.com	
  
F#	
  -­‐	
  FascinaKng	
  Language	
  
•  h=p://sharp-­‐gamedev.blogspot.com/	
  
   –  Blog	
  tracking	
  the	
  experiences	
  of	
  game	
  
      development	
  using	
  F#	
  


•  F#	
  introduced	
  Async	
  
   –  Later	
  adopted	
  by	
  C#	
  




                          Mono	
  for	
  Game	
  Developers	
  –	
  AltDevConf	
  2012	
     h=p://www.xamarin.com	
  
Architecture	
  
•  Computer	
  Architecture	
  –	
  A	
  QuanKtaKve	
  
   Approach	
  

•  Unix	
  Systems	
  for	
  Modern	
  Architectures	
  
   –  It	
  says	
  “Unix”	
  
   –  But	
  applies	
  to	
  low-­‐level	
  systems	
  engineering	
  
   –  Caches,	
  MMUs,	
  performance	
  
   –  Hardware	
  Architectures	
  design	
  

                         Mono	
  for	
  Game	
  Developers	
  –	
  AltDevConf	
  2012	
     h=p://www.xamarin.com	
  

More Related Content

What's hot

StateScriptingInUncharted2
StateScriptingInUncharted2StateScriptingInUncharted2
StateScriptingInUncharted2gcarlton
 
Qualcomm Hexagon SDK: Optimize Your Multimedia Solutions
Qualcomm Hexagon SDK: Optimize Your Multimedia SolutionsQualcomm Hexagon SDK: Optimize Your Multimedia Solutions
Qualcomm Hexagon SDK: Optimize Your Multimedia SolutionsQualcomm Developer Network
 
Tactical Air Attack IR and Mapping
Tactical Air Attack IR and MappingTactical Air Attack IR and Mapping
Tactical Air Attack IR and Mappingmszaller
 
EFL (Tizen Native Display Layer – Architecture & Usage) - Carsten Haitzler
EFL (Tizen Native Display Layer – Architecture & Usage)  - Carsten HaitzlerEFL (Tizen Native Display Layer – Architecture & Usage)  - Carsten Haitzler
EFL (Tizen Native Display Layer – Architecture & Usage) - Carsten HaitzlerRyo Jin
 
03/2012 - Popping the gherkin stack
03/2012 - Popping the gherkin stack03/2012 - Popping the gherkin stack
03/2012 - Popping the gherkin stackdaveayan
 
State-Based Scripting in Uncharted 2: Among Thieves
State-Based Scripting in Uncharted 2: Among ThievesState-Based Scripting in Uncharted 2: Among Thieves
State-Based Scripting in Uncharted 2: Among ThievesNaughty Dog
 
Porting E-poetry: The Case of First Screening
Porting E-poetry: The Case of First ScreeningPorting E-poetry: The Case of First Screening
Porting E-poetry: The Case of First ScreeningLeonardo Flores
 
Glitch-Free A/V Encoding (CocoaConf Boston, October 2013)
Glitch-Free A/V Encoding (CocoaConf Boston, October 2013)Glitch-Free A/V Encoding (CocoaConf Boston, October 2013)
Glitch-Free A/V Encoding (CocoaConf Boston, October 2013)Chris Adamson
 
Capturing Stills, Sounds, and Scenes with AV Foundation
Capturing Stills, Sounds, and Scenes with AV FoundationCapturing Stills, Sounds, and Scenes with AV Foundation
Capturing Stills, Sounds, and Scenes with AV FoundationChris Adamson
 
Supersize your production pipe enjmin 2013 v1.1 hd
Supersize your production pipe    enjmin 2013 v1.1 hdSupersize your production pipe    enjmin 2013 v1.1 hd
Supersize your production pipe enjmin 2013 v1.1 hdslantsixgames
 
Compartmentalized Continuous Integration: Enabling Rapid, Flexible Collaborat...
Compartmentalized Continuous Integration: Enabling Rapid, Flexible Collaborat...Compartmentalized Continuous Integration: Enabling Rapid, Flexible Collaborat...
Compartmentalized Continuous Integration: Enabling Rapid, Flexible Collaborat...Perforce
 

What's hot (12)

StateScriptingInUncharted2
StateScriptingInUncharted2StateScriptingInUncharted2
StateScriptingInUncharted2
 
Qualcomm Hexagon SDK: Optimize Your Multimedia Solutions
Qualcomm Hexagon SDK: Optimize Your Multimedia SolutionsQualcomm Hexagon SDK: Optimize Your Multimedia Solutions
Qualcomm Hexagon SDK: Optimize Your Multimedia Solutions
 
Tactical Air Attack IR and Mapping
Tactical Air Attack IR and MappingTactical Air Attack IR and Mapping
Tactical Air Attack IR and Mapping
 
EFL (Tizen Native Display Layer – Architecture & Usage) - Carsten Haitzler
EFL (Tizen Native Display Layer – Architecture & Usage)  - Carsten HaitzlerEFL (Tizen Native Display Layer – Architecture & Usage)  - Carsten Haitzler
EFL (Tizen Native Display Layer – Architecture & Usage) - Carsten Haitzler
 
03/2012 - Popping the gherkin stack
03/2012 - Popping the gherkin stack03/2012 - Popping the gherkin stack
03/2012 - Popping the gherkin stack
 
State-Based Scripting in Uncharted 2: Among Thieves
State-Based Scripting in Uncharted 2: Among ThievesState-Based Scripting in Uncharted 2: Among Thieves
State-Based Scripting in Uncharted 2: Among Thieves
 
Porting E-poetry: The Case of First Screening
Porting E-poetry: The Case of First ScreeningPorting E-poetry: The Case of First Screening
Porting E-poetry: The Case of First Screening
 
Glitch-Free A/V Encoding (CocoaConf Boston, October 2013)
Glitch-Free A/V Encoding (CocoaConf Boston, October 2013)Glitch-Free A/V Encoding (CocoaConf Boston, October 2013)
Glitch-Free A/V Encoding (CocoaConf Boston, October 2013)
 
Capturing Stills, Sounds, and Scenes with AV Foundation
Capturing Stills, Sounds, and Scenes with AV FoundationCapturing Stills, Sounds, and Scenes with AV Foundation
Capturing Stills, Sounds, and Scenes with AV Foundation
 
Hardware Accelerated 2D Rendering for Android
Hardware Accelerated 2D Rendering for AndroidHardware Accelerated 2D Rendering for Android
Hardware Accelerated 2D Rendering for Android
 
Supersize your production pipe enjmin 2013 v1.1 hd
Supersize your production pipe    enjmin 2013 v1.1 hdSupersize your production pipe    enjmin 2013 v1.1 hd
Supersize your production pipe enjmin 2013 v1.1 hd
 
Compartmentalized Continuous Integration: Enabling Rapid, Flexible Collaborat...
Compartmentalized Continuous Integration: Enabling Rapid, Flexible Collaborat...Compartmentalized Continuous Integration: Enabling Rapid, Flexible Collaborat...
Compartmentalized Continuous Integration: Enabling Rapid, Flexible Collaborat...
 

Similar to Mono for Game Developers - AltDevConf 2012

Brewing Your Own Game Engie eng
Brewing Your Own Game Engie engBrewing Your Own Game Engie eng
Brewing Your Own Game Engie engCoconut Island
 
Ghajini - The Game Development
Ghajini - The Game DevelopmentGhajini - The Game Development
Ghajini - The Game DevelopmentImran K
 
Augmenting Maintenance
Augmenting MaintenanceAugmenting Maintenance
Augmenting MaintenanceNetcetera
 
Building Applications with the Microsoft Kinect SDK
Building Applications with the Microsoft Kinect SDKBuilding Applications with the Microsoft Kinect SDK
Building Applications with the Microsoft Kinect SDKDataLeader.io
 
ميهين
ميهينميهين
ميهينAhmed
 
Distributed high-quality image manipulation and review in a virtual collabora...
Distributed high-quality image manipulation and review in a virtual collabora...Distributed high-quality image manipulation and review in a virtual collabora...
Distributed high-quality image manipulation and review in a virtual collabora...ETCenter
 
Design your 3d game engine
Design your 3d game engineDesign your 3d game engine
Design your 3d game engineDaosheng Mu
 
Video game development for everybody
Video game development for everybodyVideo game development for everybody
Video game development for everybodySarah Sexton
 
Road to Success (July 1st) - Mobile Game Development Alternatives - Andrew Bu...
Road to Success (July 1st) - Mobile Game Development Alternatives - Andrew Bu...Road to Success (July 1st) - Mobile Game Development Alternatives - Andrew Bu...
Road to Success (July 1st) - Mobile Game Development Alternatives - Andrew Bu...SanaChoudary
 
Abc of DirectX
Abc of DirectXAbc of DirectX
Abc of DirectXPrabodh20
 
HTML5 Games Status and issues
HTML5 Games Status and issuesHTML5 Games Status and issues
HTML5 Games Status and issuesJ.h. Liu
 
Hacking for Salone: Drone Races - Di Saverio; Lippolis - Codemotion Milan 2016
Hacking for Salone: Drone Races - Di Saverio; Lippolis - Codemotion Milan 2016Hacking for Salone: Drone Races - Di Saverio; Lippolis - Codemotion Milan 2016
Hacking for Salone: Drone Races - Di Saverio; Lippolis - Codemotion Milan 2016Codemotion
 
Low Level Graphics & OpenGL
Low Level Graphics & OpenGLLow Level Graphics & OpenGL
Low Level Graphics & OpenGLDominic Farolino
 
Fast Track - Windows 8 Apps
Fast Track - Windows 8 AppsFast Track - Windows 8 Apps
Fast Track - Windows 8 AppsAnkit Kashyap
 
The next generation of GPU APIs for Game Engines
The next generation of GPU APIs for Game EnginesThe next generation of GPU APIs for Game Engines
The next generation of GPU APIs for Game EnginesPooya Eimandar
 
ngGoBuilder and collaborative development between San Francisco and Tokyo
ngGoBuilder and collaborative development between San Francisco and TokyongGoBuilder and collaborative development between San Francisco and Tokyo
ngGoBuilder and collaborative development between San Francisco and Tokyonotolab
 
2004: Söldner - a Post Mortem
2004: Söldner - a Post Mortem2004: Söldner - a Post Mortem
2004: Söldner - a Post MortemTeut Weidemann
 

Similar to Mono for Game Developers - AltDevConf 2012 (20)

Pc54
Pc54Pc54
Pc54
 
Brewing Your Own Game Engie eng
Brewing Your Own Game Engie engBrewing Your Own Game Engie eng
Brewing Your Own Game Engie eng
 
Ghajini - The Game Development
Ghajini - The Game DevelopmentGhajini - The Game Development
Ghajini - The Game Development
 
Augmenting Maintenance
Augmenting MaintenanceAugmenting Maintenance
Augmenting Maintenance
 
From Web to Mobile with Stage 3D
From Web to Mobile with Stage 3DFrom Web to Mobile with Stage 3D
From Web to Mobile with Stage 3D
 
Building Applications with the Microsoft Kinect SDK
Building Applications with the Microsoft Kinect SDKBuilding Applications with the Microsoft Kinect SDK
Building Applications with the Microsoft Kinect SDK
 
ميهين
ميهينميهين
ميهين
 
Hacking for salone: drone races
Hacking for salone: drone racesHacking for salone: drone races
Hacking for salone: drone races
 
Distributed high-quality image manipulation and review in a virtual collabora...
Distributed high-quality image manipulation and review in a virtual collabora...Distributed high-quality image manipulation and review in a virtual collabora...
Distributed high-quality image manipulation and review in a virtual collabora...
 
Design your 3d game engine
Design your 3d game engineDesign your 3d game engine
Design your 3d game engine
 
Video game development for everybody
Video game development for everybodyVideo game development for everybody
Video game development for everybody
 
Road to Success (July 1st) - Mobile Game Development Alternatives - Andrew Bu...
Road to Success (July 1st) - Mobile Game Development Alternatives - Andrew Bu...Road to Success (July 1st) - Mobile Game Development Alternatives - Andrew Bu...
Road to Success (July 1st) - Mobile Game Development Alternatives - Andrew Bu...
 
Abc of DirectX
Abc of DirectXAbc of DirectX
Abc of DirectX
 
HTML5 Games Status and issues
HTML5 Games Status and issuesHTML5 Games Status and issues
HTML5 Games Status and issues
 
Hacking for Salone: Drone Races - Di Saverio; Lippolis - Codemotion Milan 2016
Hacking for Salone: Drone Races - Di Saverio; Lippolis - Codemotion Milan 2016Hacking for Salone: Drone Races - Di Saverio; Lippolis - Codemotion Milan 2016
Hacking for Salone: Drone Races - Di Saverio; Lippolis - Codemotion Milan 2016
 
Low Level Graphics & OpenGL
Low Level Graphics & OpenGLLow Level Graphics & OpenGL
Low Level Graphics & OpenGL
 
Fast Track - Windows 8 Apps
Fast Track - Windows 8 AppsFast Track - Windows 8 Apps
Fast Track - Windows 8 Apps
 
The next generation of GPU APIs for Game Engines
The next generation of GPU APIs for Game EnginesThe next generation of GPU APIs for Game Engines
The next generation of GPU APIs for Game Engines
 
ngGoBuilder and collaborative development between San Francisco and Tokyo
ngGoBuilder and collaborative development between San Francisco and TokyongGoBuilder and collaborative development between San Francisco and Tokyo
ngGoBuilder and collaborative development between San Francisco and Tokyo
 
2004: Söldner - a Post Mortem
2004: Söldner - a Post Mortem2004: Söldner - a Post Mortem
2004: Söldner - a Post Mortem
 

More from Xamarin

Xamarin University Presents: Building Your First Intelligent App with Xamarin...
Xamarin University Presents: Building Your First Intelligent App with Xamarin...Xamarin University Presents: Building Your First Intelligent App with Xamarin...
Xamarin University Presents: Building Your First Intelligent App with Xamarin...Xamarin
 
Xamarin University Presents: Ship Better Apps with Visual Studio App Center
Xamarin University Presents: Ship Better Apps with Visual Studio App CenterXamarin University Presents: Ship Better Apps with Visual Studio App Center
Xamarin University Presents: Ship Better Apps with Visual Studio App CenterXamarin
 
Get the Most Out of iOS 11 with Visual Studio Tools for Xamarin
Get the Most Out of iOS 11 with Visual Studio Tools for XamarinGet the Most Out of iOS 11 with Visual Studio Tools for Xamarin
Get the Most Out of iOS 11 with Visual Studio Tools for XamarinXamarin
 
Get the Most out of Android 8 Oreo with Visual Studio Tools for Xamarin
Get the Most out of Android 8 Oreo with Visual Studio Tools for XamarinGet the Most out of Android 8 Oreo with Visual Studio Tools for Xamarin
Get the Most out of Android 8 Oreo with Visual Studio Tools for XamarinXamarin
 
Creative Hacking: Delivering React Native App A/B Testing Using CodePush
Creative Hacking: Delivering React Native App A/B Testing Using CodePushCreative Hacking: Delivering React Native App A/B Testing Using CodePush
Creative Hacking: Delivering React Native App A/B Testing Using CodePushXamarin
 
Build Better Games with Unity and Microsoft Azure
Build Better Games with Unity and Microsoft AzureBuild Better Games with Unity and Microsoft Azure
Build Better Games with Unity and Microsoft AzureXamarin
 
Exploring UrhoSharp 3D with Xamarin Workbooks
Exploring UrhoSharp 3D with Xamarin WorkbooksExploring UrhoSharp 3D with Xamarin Workbooks
Exploring UrhoSharp 3D with Xamarin WorkbooksXamarin
 
Desktop Developer’s Guide to Mobile with Visual Studio Tools for Xamarin
Desktop Developer’s Guide to Mobile with Visual Studio Tools for XamarinDesktop Developer’s Guide to Mobile with Visual Studio Tools for Xamarin
Desktop Developer’s Guide to Mobile with Visual Studio Tools for XamarinXamarin
 
Developer’s Intro to Azure Machine Learning
Developer’s Intro to Azure Machine LearningDeveloper’s Intro to Azure Machine Learning
Developer’s Intro to Azure Machine LearningXamarin
 
Customizing Xamarin.Forms UI
Customizing Xamarin.Forms UICustomizing Xamarin.Forms UI
Customizing Xamarin.Forms UIXamarin
 
Session 4 - Xamarin Partner Program, Events and Resources
Session 4 - Xamarin Partner Program, Events and ResourcesSession 4 - Xamarin Partner Program, Events and Resources
Session 4 - Xamarin Partner Program, Events and ResourcesXamarin
 
Session 3 - Driving Mobile Growth and Profitability
Session 3 - Driving Mobile Growth and ProfitabilitySession 3 - Driving Mobile Growth and Profitability
Session 3 - Driving Mobile Growth and ProfitabilityXamarin
 
Session 2 - Emerging Technologies in your Mobile Practice
Session 2 - Emerging Technologies in your Mobile PracticeSession 2 - Emerging Technologies in your Mobile Practice
Session 2 - Emerging Technologies in your Mobile PracticeXamarin
 
Session 1 - Transformative Opportunities in Mobile and Cloud
Session 1 - Transformative Opportunities in Mobile and Cloud Session 1 - Transformative Opportunities in Mobile and Cloud
Session 1 - Transformative Opportunities in Mobile and Cloud Xamarin
 
SkiaSharp Graphics for Xamarin.Forms
SkiaSharp Graphics for Xamarin.FormsSkiaSharp Graphics for Xamarin.Forms
SkiaSharp Graphics for Xamarin.FormsXamarin
 
Building Games for iOS, macOS, and tvOS with Visual Studio and Azure
Building Games for iOS, macOS, and tvOS with Visual Studio and AzureBuilding Games for iOS, macOS, and tvOS with Visual Studio and Azure
Building Games for iOS, macOS, and tvOS with Visual Studio and AzureXamarin
 
Intro to Xamarin.Forms for Visual Studio 2017
Intro to Xamarin.Forms for Visual Studio 2017Intro to Xamarin.Forms for Visual Studio 2017
Intro to Xamarin.Forms for Visual Studio 2017Xamarin
 
Connected Mobile Apps with Microsoft Azure
Connected Mobile Apps with Microsoft AzureConnected Mobile Apps with Microsoft Azure
Connected Mobile Apps with Microsoft AzureXamarin
 
Introduction to Xamarin for Visual Studio 2017
Introduction to Xamarin for Visual Studio 2017Introduction to Xamarin for Visual Studio 2017
Introduction to Xamarin for Visual Studio 2017Xamarin
 
Building Your First iOS App with Xamarin for Visual Studio
Building Your First iOS App with Xamarin for Visual StudioBuilding Your First iOS App with Xamarin for Visual Studio
Building Your First iOS App with Xamarin for Visual StudioXamarin
 

More from Xamarin (20)

Xamarin University Presents: Building Your First Intelligent App with Xamarin...
Xamarin University Presents: Building Your First Intelligent App with Xamarin...Xamarin University Presents: Building Your First Intelligent App with Xamarin...
Xamarin University Presents: Building Your First Intelligent App with Xamarin...
 
Xamarin University Presents: Ship Better Apps with Visual Studio App Center
Xamarin University Presents: Ship Better Apps with Visual Studio App CenterXamarin University Presents: Ship Better Apps with Visual Studio App Center
Xamarin University Presents: Ship Better Apps with Visual Studio App Center
 
Get the Most Out of iOS 11 with Visual Studio Tools for Xamarin
Get the Most Out of iOS 11 with Visual Studio Tools for XamarinGet the Most Out of iOS 11 with Visual Studio Tools for Xamarin
Get the Most Out of iOS 11 with Visual Studio Tools for Xamarin
 
Get the Most out of Android 8 Oreo with Visual Studio Tools for Xamarin
Get the Most out of Android 8 Oreo with Visual Studio Tools for XamarinGet the Most out of Android 8 Oreo with Visual Studio Tools for Xamarin
Get the Most out of Android 8 Oreo with Visual Studio Tools for Xamarin
 
Creative Hacking: Delivering React Native App A/B Testing Using CodePush
Creative Hacking: Delivering React Native App A/B Testing Using CodePushCreative Hacking: Delivering React Native App A/B Testing Using CodePush
Creative Hacking: Delivering React Native App A/B Testing Using CodePush
 
Build Better Games with Unity and Microsoft Azure
Build Better Games with Unity and Microsoft AzureBuild Better Games with Unity and Microsoft Azure
Build Better Games with Unity and Microsoft Azure
 
Exploring UrhoSharp 3D with Xamarin Workbooks
Exploring UrhoSharp 3D with Xamarin WorkbooksExploring UrhoSharp 3D with Xamarin Workbooks
Exploring UrhoSharp 3D with Xamarin Workbooks
 
Desktop Developer’s Guide to Mobile with Visual Studio Tools for Xamarin
Desktop Developer’s Guide to Mobile with Visual Studio Tools for XamarinDesktop Developer’s Guide to Mobile with Visual Studio Tools for Xamarin
Desktop Developer’s Guide to Mobile with Visual Studio Tools for Xamarin
 
Developer’s Intro to Azure Machine Learning
Developer’s Intro to Azure Machine LearningDeveloper’s Intro to Azure Machine Learning
Developer’s Intro to Azure Machine Learning
 
Customizing Xamarin.Forms UI
Customizing Xamarin.Forms UICustomizing Xamarin.Forms UI
Customizing Xamarin.Forms UI
 
Session 4 - Xamarin Partner Program, Events and Resources
Session 4 - Xamarin Partner Program, Events and ResourcesSession 4 - Xamarin Partner Program, Events and Resources
Session 4 - Xamarin Partner Program, Events and Resources
 
Session 3 - Driving Mobile Growth and Profitability
Session 3 - Driving Mobile Growth and ProfitabilitySession 3 - Driving Mobile Growth and Profitability
Session 3 - Driving Mobile Growth and Profitability
 
Session 2 - Emerging Technologies in your Mobile Practice
Session 2 - Emerging Technologies in your Mobile PracticeSession 2 - Emerging Technologies in your Mobile Practice
Session 2 - Emerging Technologies in your Mobile Practice
 
Session 1 - Transformative Opportunities in Mobile and Cloud
Session 1 - Transformative Opportunities in Mobile and Cloud Session 1 - Transformative Opportunities in Mobile and Cloud
Session 1 - Transformative Opportunities in Mobile and Cloud
 
SkiaSharp Graphics for Xamarin.Forms
SkiaSharp Graphics for Xamarin.FormsSkiaSharp Graphics for Xamarin.Forms
SkiaSharp Graphics for Xamarin.Forms
 
Building Games for iOS, macOS, and tvOS with Visual Studio and Azure
Building Games for iOS, macOS, and tvOS with Visual Studio and AzureBuilding Games for iOS, macOS, and tvOS with Visual Studio and Azure
Building Games for iOS, macOS, and tvOS with Visual Studio and Azure
 
Intro to Xamarin.Forms for Visual Studio 2017
Intro to Xamarin.Forms for Visual Studio 2017Intro to Xamarin.Forms for Visual Studio 2017
Intro to Xamarin.Forms for Visual Studio 2017
 
Connected Mobile Apps with Microsoft Azure
Connected Mobile Apps with Microsoft AzureConnected Mobile Apps with Microsoft Azure
Connected Mobile Apps with Microsoft Azure
 
Introduction to Xamarin for Visual Studio 2017
Introduction to Xamarin for Visual Studio 2017Introduction to Xamarin for Visual Studio 2017
Introduction to Xamarin for Visual Studio 2017
 
Building Your First iOS App with Xamarin for Visual Studio
Building Your First iOS App with Xamarin for Visual StudioBuilding Your First iOS App with Xamarin for Visual Studio
Building Your First iOS App with Xamarin for Visual Studio
 

Recently uploaded

Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 

Recently uploaded (20)

Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 

Mono for Game Developers - AltDevConf 2012

  • 1. Mono  for  Game  Developers   Miguel  de  Icaza   miguel@xamarin.com,  @migueldeicaza     Xamarin  Inc  
  • 2. Agenda   •  Mono  in  Games   •  Using  Mono  for  Games   •  Performance   •  Garbage  CollecKon   •  Co-­‐rouKnes,  Asynchronous  Programming   Mono  for  Game  Developers  –  AltDevConf  2012   h=p://www.xamarin.com  
  • 4. C#   Java   JavaScript   Ruby   Python   Visual  Basic   F#   Mono  for  Game  Developers  –  AltDevConf  2012   h=p://www.xamarin.com  
  • 5. C#   Java   JavaScript   Ruby   Python   Visual  Basic   F#   Mono  for  Game  Developers  –  AltDevConf  2012   h=p://www.xamarin.com  
  • 6. Sims  3   •  Mixed  Code:   –  C/C++  engine   –  C#  scripKng/AI   –  C#  high-­‐level   •  Visual  Studio  +  Mono   •  X86,  PS3,  Xbox360     Credit:    www.thesims3facts.webs.com  
  • 7. BasKon  –  on  Google  Chrome  NaCl   •  C#  XNA  codebase   •  Originally  on  Xbox   •  Ported  to  NaKveClient   –  Mono   –  MonoGame  (XNA)   •  Mac,  Windows,  Linux  
  • 8. Pure  C#  -­‐  SoulCra_   •  DeltaEngine   –  Pure  C#  engine   –  Open  source   –  Android,  iOS,  Mac,  Win  
  • 9. Unity  3D   •  Unity  Engine   –  C/C++  game  engine   –  Embedded  Mono   •  User  code   –  C#  or  UnityScript   –  Extends  Unity  itself       Shadow  Gun,  built  with  Unity  
  • 10. SecondLife   •  Mono  on  the  server   •  Powers  LSL  scripts   •  Nice  200x  perf  boost   •  Code  InjecKon  
  • 11. Infinite  Flight   •  Subject  of  the  second   part  of  this  session  
  • 13. Because  Life  is  too  Short   •  To  debug  another  memory  leak   •  To  track  another  memory  corrupKon  bug   •  Because  you  deserve  be=er   Mono  for  Game  Developers  –  AltDevConf  2012   h=p://www.xamarin.com  
  • 14. The  Quest  for  ProducKvity   System  Languages   Scrip<ng  Languages   Pros:   Pros:   •  Low-­‐level   •  High-­‐level,  good  producKvity   •  Good  control  of  hardware   •  Typed   •  Easy  to  write   •  Fast  code   •  Safe,  prevent  crashes   •  Loosely  typed   Cons:     •  Easy  to  corrupt  state   Cons:   •  Low  producKvity   •  Poor  control  of  hardware   •  Crash  o_en   •  Complex  for  newcomers   •  Slow  (interpreted)  
  • 15. John  Ousterhout  ScripKng  Quest   IEEE  1998  Summary  Paper     Mono  for  Game  Developers  –  AltDevConf  2012   h=p://www.stanford.edu/~ouster/cgi-­‐bin/papers/scripKng.pdf   h=p://www.xamarin.com  
  • 16. John  was  always  ahead  of  his  Kme   •  Professional  workstaKons  in  1998   –  SPARC,  HP-­‐PA   •  Not  achievable  on  PCs  of  the  Kme   Mono  for  Game  Developers  –  AltDevConf  2012   h=p://www.xamarin.com  
  • 17. 2000  –  Desktop  Development   •  Building  desktop  apps  with  C  and  C++   –  Slow  progress,  error  prone,  frequent  crashes   •  Windows  2000  Requirements:   –  133  Mhz  or  more   –  64  megs  for  desktop,  256  for  server   •  Windows  XP  Requirements  (one  year  later)   –  233Mhz  or  more   –  128  megs  for  desktop   •  Development  desktops  at  the  Kme:   –  ~1Ghz  speed   –  ~1  GB  of  memory   Mono  for  Game  Developers  –  AltDevConf  2012   h=p://www.xamarin.com  
  • 18. C#  Introduced  in  2000   •  C#  1.0  was  a  Java-­‐like  system   •  With  many  design  fixes   –  10  years  of  experience   –  Change  defaults  (all  virtual,  vs  opt-­‐in  virtual)   –  Introduce  structs  (help  GC,  no  boxing)   –  Direct  access  to  naKve  libraries  (P/Invoke)   –  Delegates  (foundaKon  for  lambdas)   Mono  for  Game  Developers  –  AltDevConf  2012   h=p://www.xamarin.com  
  • 19. Language  Choices     Fully  Dynamic   Easy   C#/Java   ProducKvity   C/C++   Assembly  Language   Difficult   Slow   Fast   Performance  
  • 20. Game  So_ware  Components   .   Display   SimulaKon   Game  Logic   Support   •  Rendering   •  Physics   •  World  rules   •  Audio   •  Shading   •  Collision   •  Enemy  AI   •  Input   •  Scene   •  ParKcles   •  User   •  Networking   •  AnimaKon   •  Terrain   control   •  Geometry   •  Camera   •  GUI   •  Behavior  
  • 21. The  Problem   Games  are  real-­‐Kme  programs   •  30  to  60  frames  per  second  (0.016  seconds)   Input   AI   Updates         •  User  control   •  Scripted,  slow   •  Render  Graphics   •  Network   •  React  to   •  Play  audio   events   change   •  Update  scene  
  • 22. Problem:    ScripKng  Is  A  Bo=leneck   Gaming's  Achilles'  Heel   Display   SimulaKon   Game  Logic   Support   •  Rendering   •  Physics   •  World  rules   •  Audio   •  Shading   •  Collision   •  Enemy  AI   •  Input   •  Scene   •  ParKcles   •  User   •  Networking   •  AnimaKon   •  Terrain   control   •  Geometry   •  Camera   •  GUI   •  Behavior   C/C++   C/C++   Script   C/C++  
  • 23. Problem:    ScripKng  Is  A  Bo=leneck   Gaming's  Achilles'  Heel   Display   SimulaKon   Game  Logic   Support   •  Rendering   •  Physics   •  World  rules   •  Audio   •  Shading   •  Collision   •  Enemy  AI   •  Input   •  Scene   •  ParKcles   •  User   •  Networking   •  AnimaKon   •  Terrain   control   •  Geometry   •  Camera   •  GUI   •  Behavior   C/C++   C/C++   Script   C/C++   C#  
  • 24. What  C#  Offers   •  Close  to  naKve  performance   –  50%-­‐90%  of  naKve  performance   •  Safe  ExecuKon  Environment   –  With  opKonal  support  to  shoot  yourself  in  the   foot.   Mono  for  Game  Developers  –  AltDevConf  2012   h=p://www.xamarin.com  
  • 25. C#  -­‐  An  Evolving  Language   2012   5.0   Asynchronous  Programming   2010   4.0   Dynamic  extensions   2007   3.0   Language  Integrated  Query,  FuncKonal   2005   2.0   Generics,  Iterators,  Lambdas   2002   1.0   Managed  Code,  strongly  typed  
  • 27. Designing  Mono  ApplicaKons   •  Provided:   –  C#  Language   –  Base  Class  Libraries   •  Not  Provided:   –  User  Interface,  Graphics,  Audio   –  These  are  all  plaqorm  specific   Mono  for  Game  Developers  –  AltDevConf  2012   h=p://www.xamarin.com  
  • 28. Code  Sharing  and  NaKve  Experience   C#   Core  Engine,  Shared  Logic,  Business  Logic     Plus  ECMA  languages RunKme   .NET   Mono   Windows   OS   Xbox   Mac   iOS   Android   WinPhone   Not  a  comprehensive  list  
  • 29. Code  Sharing  and  NaKve  Experience   NaKve  UI   XAML   MonoMac   MonoTouch   MonoDroid   APIs   XNA   C#   Core  Engine,  Shared  Logic,  Business  Logic     Plus  ECMA  languages RunKme   .NET   Mono   Windows   OS   Xbox   Mac   iOS   Android   WinPhone   Not  a  comprehensive  list  
  • 30. Modes  of  Use   •  Drive  the  applicaKon   •  ScripKng  engine   –  Sandboxed   –  Full  access   Mono  for  Game  Developers  –  AltDevConf  2012   h=p://www.xamarin.com  
  • 31. Run  on  Mono   Mono  for  Game  Developers  –  AltDevConf  2012   h=p://www.xamarin.com  
  • 32. Run  on  Mono   Game  –  Your  C#  Code   Mono   C#/.NET  Libraries   RunKme   MonoGame   OpenTK   Physics   OperaKng   System   OpenAL   OpenGL   Networking   Mono  for  Game  Developers  –  AltDevConf  2012   h=p://www.xamarin.com  
  • 33. Using  Mono  as  a  Library   Mono  for  Game  Developers  –  AltDevConf  2012   h=p://www.xamarin.com  
  • 34. Use  Mono  as  a  Library   Game  Engine   Game  Engine  Libraries   Mono   Game  –  Your   Audio   Graphics   C#  Code   Mono  for  Game  Developers  –  AltDevConf  2012   h=p://www.xamarin.com  
  • 35. TIPS  ON  USING  MONO  
  • 36. Two  Code  GeneraKon  Backends   Mono’s  Na<ve  Backend   LLVM  Backend   •  Very  fast  codegen   •  Very  slow  codegen   –  .3  seconds  bootstrap   –  7  second  bootstrap   •  Not  great  code  output   •  Great  output  quality   •  JIT’s  default  engine   •  Opt-­‐in:   –  mono  -­‐-­‐llvm
  • 37. Just  in  Time  vs  Ahead  of  Time   •  Just  in  Time  CompilaKon   –  Default  Mode  of  OperaKon   –  Very  fast  at  compiling  code   –  Not  great  quality  of  code  generaKon   •  Ahead  of  Time  CompilaKon   –  Mandatory  on  some  plaqorms   •  PS3,  XBox360,  iOS     –  Can  afford  expensive  compiler  opKmizaKons   Mono  for  Game  Developers  –  AltDevConf  2012   h=p://www.xamarin.com  
  • 38. Arrays  Bounds  Checking   Mono  RunKme  translates  this  to:   Mono  for  Game  Developers  –  AltDevConf  2012   h=p://www.xamarin.com  
  • 39. Disabling  Arrays  Bounds  Checking   •  Very  unsafe   –  GC  depends  on  system  integrity   –  But  admissible  if  no  error  ever  found  on  tesKng   •  We  give  you  the  tools  to  shoot  your  feet   –  mono  –O=unsafe •  Ask  your  QA  team   Mono  for  Game  Developers  –  AltDevConf  2012   h=p://www.xamarin.com  
  • 41. Mono’s  Garbage  Collectors   •  Boehm  GC:   –  TradiKonal  Mono  GC   –  Mostly-­‐precise,  stack  conservaKve   –  Scans  everything  on  each  GC   •  GeneraKonal  Collector  (SGen)   –  New  (default  on  Android)   –  GeneraKonal  (Old  generaKon,  nurseries)   –  Copying  (plus  mark+sweep  for  large  objects)   Mono  for  Game  Developers  –  AltDevConf  2012   h=p://www.xamarin.com  
  • 42. SGen   Old   Nursery   GeneraKon   • New  objects   • Aged  objects   • Small  size  (4MB)   • Slower  collecKon   • Per  thread  regions   • Fixed  or  variable   • Very  fast   heaps   collecKon   • Parallel  collecKon   Mono  for  Game  Developers  –  AltDevConf  2012   h=p://www.xamarin.com  
  • 43. Garbage  CollecKon   Memory  Allocated   Released  later   Garbage  Collector  determines  when  to  run  and  release  memory   •  HeurisKcs  are  plaqorm-­‐specific   •  GC.Collect()  is  the  only  determinisKc  opKon    
  • 44. Best  PracKces   •  Pre-­‐allocate  major  objects  before  Game  Loop   –  Managed  objects   –  Or  unmanaged  buffers   –  Try  to  only  use  the  nursery  (stay  under  4M)   –  If  you  must  collect,  only  collect  the  nursery:   •  GC.Collect  (0)  –  Performs  only  a  nursery  collecKon   •  GC.Collect  ()  –  Performs  a  complete  GC  on  the  heap   •  On  Main  loop:   –  Use  structs  instead  of  classes   Mono  for  Game  Developers  –  AltDevConf  2012   h=p://www.xamarin.com  
  • 45. Schedule  GC  CollecKon   Game   Game   Game   Network   Audio   Physics   Logic  1   Logic  2   Logic  3   Checks   Updates   Game   Game   Game   GC   Network   Audio   Physics   Logic  1   Logic  2   Logic  3   Collect   Checks   Updates   GC.Collect  (0)     Limit  CollecKon  to  Nursery   Mono  for  Game  Developers  –  AltDevConf  2012   h=p://www.xamarin.com  
  • 46. Mono’s  GC  Thread  Control   •  Garbage  CollecKon  Stops  all  Mono  Threads   •  Non-­‐Mono  threads  are  not  affected   •  AlternaKve:   •  Use  a  Render  Scene  +  Render  Thread     •  Like  Apple’s  CoreAnimaKon  or  Microso_  WPF   Game   Network   Mono   IO  Thread   Thread   Thread   Render   Scene   Mono  Thread   Render   Real  Time   Thread   Thread  1   NaKve  Thread   Mono  for  Game  Developers  –  AltDevConf  2012   h=p://www.xamarin.com  
  • 48. State-­‐based  programming   Mono  for  Game  Developers  –  AltDevConf  2012   h=p://www.xamarin.com  
  • 49. Problems  with  Callbacks  and  State-­‐Machines  Systems   •  RepeKKve   •  Cumbersome   •  Error  Prone   •  Poor  Error  PropagaKon  protocols/pracKces   •  Life  is  too  short   Mono  for  Game  Developers  –  AltDevConf  2012   h=p://www.xamarin.com  
  • 50. Co-­‐rouKnes   •  Popular  soluKon  to  simplify  AI  code   •  Each  Game  Object  has  a  script  a=ached   –  Runs  Game  Logic   –  AI  bits   •  Many  soluKons   –  longjmp/setjmp  for  unmanaged  code   –  Stack  fiddling  (Mono.Tasklets)   –  Interpreted  languages  with  VM  support   Mono  for  Game  Developers  –  AltDevConf  2012   h=p://www.xamarin.com  
  • 51. C#  5.0  and  Async  Programming   •  Mono  master  has  a  complete  C#  5  Compiler   •  Turns  repeKKve  callback-­‐based  async   programming  into  linear  programming   –  Compiler  rewrites  the  code  into  a  state  machine   –  Tasks  are  scheduled  on  the  main  thread   –  Scheduling  is  customizable   •  Originally  designed  for  interacKve  UIs   Mono  for  Game  Developers  –  AltDevConf  2012   h=p://www.xamarin.com  
  • 52. Using  Await   Mono  for  Game  Developers  –  AltDevConf  2012   h=p://www.xamarin.com  
  • 53. The  Magic   •  Await  lets  you  write  linear  code   •  Lets  you  focus  on  the  problem   –  The  compiler  is  at  your  service   •  Microso_  convenKons  for  responsive  UIs:   –  If  it  takes  more  than  50ms,  make  it  async   Mono  for  Game  Developers  –  AltDevConf  2012   h=p://www.xamarin.com  
  • 54. More  on  await •  await  introduces  a  suspension  point   –  Code  returns  to  caller   –  ExecuKon  resumes  a_er  “await”  instrucKon   –  Very  cheap  memory-­‐wise   •  Works  with  IO,  Networking  stacks,  slow  code   –  System.IO,  System.Net,  Database  access   –  Slow  processing:  XML,  Json  data   –  Blends  transparently  with  Threads  on  mulK-­‐cores   Mono  for  Game  Developers  –  AltDevConf  2012   h=p://www.xamarin.com  
  • 55. Li=le  more  interesKng   Mono  for  Game  Developers  –  AltDevConf  2012   h=p://www.xamarin.com  
  • 56. Current  Trends  in  Async  Programming   Callback  based     Where:   •  GUI  programming   •  Scalable  web  servers   •  Responsive  mobile  and  desktop  applicaKons   Mono  for  Game  Developers  –  AltDevConf  2012   h=p://www.xamarin.com  
  • 57. With  some  error  handling.   Mono  for  Game  Developers  –  AltDevConf  2012   h=p://www.xamarin.com  
  • 58. C#  5.0  Async  Support   Mono  for  Game  Developers  –  AltDevConf  2012   h=p://www.xamarin.com  
  • 59. Q&A   •  Mono,  ISO  Standard,  C#  Async   –  h=p://www.mono-­‐project.com   –  ISO  Standard:  h=p://bit.ly/cli-­‐iso-­‐standard   –  C#  Async:  h=p://msdn.microso_.com/en-­‐us/vstudio/gg316360   •  Xamarin,  Mono  on  iOS,  Android:   –  Discount  for  AltDevConf  a=endees:     –  h=p://www.xamarin.com/altdevconf   •  Contact:   –  miguel@xamarin.com,  @migueldeicaza   •  Resources:   –  @MonoGameTeam,  @Unity3D   •  Live  Chat  on  IRC:  irc.gnome.org     –  #mono,  #monotouch,  #monodroid,  #monogame   Mono  for  Game  Developers  –  AltDevConf  2012   h=p://www.xamarin.com  
  • 61. Iterators   •  C#  compiler  provided  assistance   –  Built  on  top  of  C#  IEnumerable   –  C#  compiler  rewrites  iterators  into  state  machines   •  Developers  build  on  top  of  convenKons   •  Unity3D  uses  this  approach   •  Open  Source  Iterator  game  framework:   –  http://mjhutchinson.com/journal/2010/02/01/iteratorbased_microthreading Mono  for  Game  Developers  –  AltDevConf  2012   h=p://www.xamarin.com  
  • 62. Iterator  based  code   Mono  for  Game  Developers  –  AltDevConf  2012   h=p://www.xamarin.com  
  • 63. Mono.Tasklets   •  Pros:   –  No  need  to  rewrite  code   –  You  can  suspend  execuKon/resume  without  new   convenKons.   •  Cons:   –  Not  available  on  every  plaqorm  –  Stack  Fiddling   –  Does  not  work  with  Mono’s  new  Precise  GC   –  In  parKcular,  wont  work  with  Microso_  .NET   Mono  for  Game  Developers  –  AltDevConf  2012   h=p://www.xamarin.com  
  • 64. Not  a  comprehensive  list   GAME  ENGINES  USING  C#  
  • 65. Unity  3D   •  Commercial  Engine   •  Very  extensive  support:   –  Consoles:  XBox360,  PS3,  Wii   –  iOS,  Android   –  Mac,  Windows   –  Google  NaKve  Client   –  Flash  target   Mono  for  Game  Developers  –  AltDevConf  2012   h=p://www.xamarin.com  
  • 66. MonoGame  –  Open  Source  XNA   •  Open  Source  XNA  implementaKon   –  Currently  2D-­‐based   –  3D  support  coming   •  Runs  on  many  plaqorms:   –  iOS  (iPhone,  iPad)   –  Android  (phones  and  tablets)   –  Linux   –  Mac   –  Windows   Mono  for  Game  Developers  –  AltDevConf  2012   h=p://www.xamarin.com  
  • 67. Delta  Engine   •  Open  Source  Game  Engine   •  Wri=en  100%  in  C#   •  Runs  on:   –  Android   –  Windows  Phone   –  iOS   –  Mac   –  Windows   Mono  for  Game  Developers  –  AltDevConf  2012   h=p://www.xamarin.com  
  • 68. Axiom   •  Open  source   •  Based  on  the  OGRE  C++  Engine   •  Windows,  Linux   •  XNA,  DirectX  and  OpenGL  support     Mono  for  Game  Developers  –  AltDevConf  2012   h=p://www.xamarin.com  
  • 69. F#  -­‐  FascinaKng  Language   •  h=p://sharp-­‐gamedev.blogspot.com/   –  Blog  tracking  the  experiences  of  game   development  using  F#   •  F#  introduced  Async   –  Later  adopted  by  C#   Mono  for  Game  Developers  –  AltDevConf  2012   h=p://www.xamarin.com  
  • 70. Architecture   •  Computer  Architecture  –  A  QuanKtaKve   Approach   •  Unix  Systems  for  Modern  Architectures   –  It  says  “Unix”   –  But  applies  to  low-­‐level  systems  engineering   –  Caches,  MMUs,  performance   –  Hardware  Architectures  design   Mono  for  Game  Developers  –  AltDevConf  2012   h=p://www.xamarin.com