There is more to C

2,217 views
2,076 views

Published on

Slides form talk at FI MUNI about development in C (2012). Covers topic about C libraries including libuv library from Node.js and its relation to Google V8 JavaScript Engine.

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
2,217
On SlideShare
0
From Embeds
0
Number of Embeds
1,127
Actions
Shares
0
Downloads
6
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

There is more to C

  1. 1. There is more to C 26.11. 2012 FI MUNI Juraj Michálekhttp://georgik.sinusgear.com http://twitter.com/sinusgear
  2. 2. Something about me ;-)
  3. 3. ContentWhy C rocks? libuv
  4. 4. #1 language 2012http://www.tiobe.com
  5. 5. Trends
  6. 6. Interactive C - Robot● Handyboard● Motorola 68AX11● derrived from C● http://www.kipr.org● http://www.boatball.org
  7. 7. PortabilityLinux – Windows – Mac – BSD http://suacommunity.com/
  8. 8. Clone examples Available at GitHub: https://github.com/georgik/fimuni-c-cpp-examplesgit clone git://github.com/georgik/fimuni-c-cpp-examples.git
  9. 9. AllegroAllegro Low Level Game Routines
  10. 10. Allegro - featureskeyboard, mouse, touch screen audio, video, graphics timers, events data files
  11. 11. Allegro 5.1 Win, Lin, Mac iOS, Androidhttp://alleg.sourceforge.net/a5docs/refman/
  12. 12. Initialization al_init();
  13. 13. Graphic environmental_create_display(int w, int h)
  14. 14. ALLEGRO_BITMAP Structure for bitmapsALLEGRO_BITMAP *bmp = create_bitmap(x,y);
  15. 15. Graphics al_putpixel(x, y, color) al_load_bitmap(filename);al_draw_bitmap(bmp, 10, 10, 0);
  16. 16. Release memoryal_destroy_bitmap(bmp);
  17. 17. Keyboard al_install_keyboard()al_uninstall_keyboard()event.keyboard.keycode
  18. 18. Mouse al_install_mouse() al_uninstall_mouse()al_get_mouse_state(&msestate);
  19. 19. Additional Allegro libraries Allegttf - True Type fonts supportAllegGL – HW accelerated graphics DUMB - audio (Vorbis/Ogg)
  20. 20. Compilation Configuration script: allegro-config Linux, Unix, MacOS: gcc foo.cc -o foo `allegro-config --libs`gcc foo.cc -o foo `pkg-config --libs --cflags allegro-5.0` iPhone – requires Xcode Android – requires Android SDK
  21. 21. CMake – Cross Platform Make http://www.cmake.org
  22. 22. Allegro – CMake – MSVC 2012Requires: DirectX SDK (e.g. Windows SDK for Windows 8)Small tweak to run examples: http://georgik.sinusgear.com/2012/11/18/allegro5-1-and-visual-studio-2012-unable-to-start-examples-missing-dll-files/
  23. 23. Allegro – CMake - KDevelop4
  24. 24. SourcesLibrary: http://alleg.sourceforge.net Wiki: http://wiki.allegro.cc/
  25. 25. Game development community network http://www.allegro.cc
  26. 26. Simple Direct Media Layer
  27. 27. Init/quitSDL_init(flags) SDL_quit()
  28. 28. GraphicsSDL_SetVideoMode(width, height, video_bpp, videoflags) Store in memory: SDL_SWSURFACEStore on graphics card: SDL_HWSURFACE
  29. 29. Visual data SDL_Surface SDL_CreateRGBSurface(SDL_SWSURFACE,width, height, 32, rmask, gmask, bmask, amask);
  30. 30. Visual dataSDL_Surface *SDL_LoadBMP(const char *file) Copy from one memory to another: SDL_BlitSurface(src, srcrect, dst, dstrect);
  31. 31. KeyboardSDL_PollEvent(SDL_Event *event) event.key.keysym.sym
  32. 32. Timer static int counter;SDL_SetTimer(interval, tick_callback);
  33. 33. MouseSDL_GetMouseState(*x, *y);
  34. 34. TextNot implemented
  35. 35. Extensions support for GL extension for many languagesAda, Eiffel, Java, Lua, Perl, PHP, Pike, Python, Ruby 176 additional libraries
  36. 36. SDL based Libraries SDL_mixer – audio mixerSDL_image – image formatsSDL_net – network support
  37. 37. Sourcehttp://www.libsdl.org
  38. 38. Compilation sdl-config Linux, Windows, BeOS, Mac OSgcc foo.cc -o foo `sdl-config --libs`
  39. 39. PyGamePower of C and Power of Python http://www.pygame.org
  40. 40. http://nodejs.org/
  41. 41. Architecture of Node.js
  42. 42. libuvHigh performance evented I/O library which offers the same API on Windows and Unix
  43. 43. libuv https://github.com/joyent/libuvhttp://nikhilm.github.com/uvbook/index.html
  44. 44. libuv – event loopCall callbacks Sleep
  45. 45. libuv - example
  46. 46. FeaturesFilesystemNetworking ThreadsProcesses Utilities
  47. 47. TCP server example
  48. 48. http://www.gtk.org
  49. 49. GTK GIMP ToolKitC++, Guile, Perl, Python, TOM, Ada95, Objective C, Free Pascal, Eiffel...
  50. 50. Glade 3http://glade.gnome.org
  51. 51. Valgrind debugging a profiling memcheckhelgrind - race condition, thread profiling
  52. 52. Modes debugger Local application Attach to local processAttach to remote process Post-mortem
  53. 53. Application crashed Post-mortem analysisImage from memory: coredump
  54. 54. Quick analysis of coredump
  55. 55. Strace
  56. 56. Mutextrace● mutextrace ./mutex-tester-app param1 param2 – lock #1, free -> thread 1 – init #2 – lock #2, free -> thread 1 – unlock #1 – lock #1, free -> thread 1 – init #3 – lock #3, free -> thread 1 – unlock #1
  57. 57. http://www.se-radio.net
  58. 58. EOF 26.11. 2012 FI MUNI Juraj Michálekhttp://georgik.sinusgear.com http://twitter.com/sinusgear

×