there is more to c · there is more to c 26.11. 2012 fi muni juraj michálek
TRANSCRIPT
![Page 1: There is more to C · There is more to C 26.11. 2012 FI MUNI Juraj Michálek](https://reader034.vdocuments.site/reader034/viewer/2022042104/5e8164ddac69643bb444de74/html5/thumbnails/1.jpg)
There is more to C
26.11. 2012FI MUNI
Juraj Michálekhttp://georgik.sinusgear.comhttp://twitter.com/sinusgear
![Page 2: There is more to C · There is more to C 26.11. 2012 FI MUNI Juraj Michálek](https://reader034.vdocuments.site/reader034/viewer/2022042104/5e8164ddac69643bb444de74/html5/thumbnails/2.jpg)
Something about me ;-)
![Page 3: There is more to C · There is more to C 26.11. 2012 FI MUNI Juraj Michálek](https://reader034.vdocuments.site/reader034/viewer/2022042104/5e8164ddac69643bb444de74/html5/thumbnails/3.jpg)
Content
Why C rocks?
libuv
![Page 5: There is more to C · There is more to C 26.11. 2012 FI MUNI Juraj Michálek](https://reader034.vdocuments.site/reader034/viewer/2022042104/5e8164ddac69643bb444de74/html5/thumbnails/5.jpg)
Trends
![Page 6: There is more to C · There is more to C 26.11. 2012 FI MUNI Juraj Michálek](https://reader034.vdocuments.site/reader034/viewer/2022042104/5e8164ddac69643bb444de74/html5/thumbnails/6.jpg)
Interactive C - Robot
● Handyboard● Motorola 68AX11● derrived from C● http://www.kipr.org● http://www.boatball.org
![Page 8: There is more to C · There is more to C 26.11. 2012 FI MUNI Juraj Michálek](https://reader034.vdocuments.site/reader034/viewer/2022042104/5e8164ddac69643bb444de74/html5/thumbnails/8.jpg)
Clone examples
Available at GitHub:https://github.com/georgik/fimuni-c-cpp-examples
git clone git://github.com/georgik/fimuni-c-cpp-examples.git
![Page 9: There is more to C · There is more to C 26.11. 2012 FI MUNI Juraj Michálek](https://reader034.vdocuments.site/reader034/viewer/2022042104/5e8164ddac69643bb444de74/html5/thumbnails/9.jpg)
Allegro
Allegro Low Level Game Routines
![Page 10: There is more to C · There is more to C 26.11. 2012 FI MUNI Juraj Michálek](https://reader034.vdocuments.site/reader034/viewer/2022042104/5e8164ddac69643bb444de74/html5/thumbnails/10.jpg)
Allegro - features
keyboard, mouse, touch screenaudio, video, graphics
timers, eventsdata files
![Page 11: There is more to C · There is more to C 26.11. 2012 FI MUNI Juraj Michálek](https://reader034.vdocuments.site/reader034/viewer/2022042104/5e8164ddac69643bb444de74/html5/thumbnails/11.jpg)
Allegro 5.1
Win, Lin, Mac
iOS, Android
http://alleg.sourceforge.net/a5docs/refman/
![Page 12: There is more to C · There is more to C 26.11. 2012 FI MUNI Juraj Michálek](https://reader034.vdocuments.site/reader034/viewer/2022042104/5e8164ddac69643bb444de74/html5/thumbnails/12.jpg)
Initialization
al_init();
![Page 13: There is more to C · There is more to C 26.11. 2012 FI MUNI Juraj Michálek](https://reader034.vdocuments.site/reader034/viewer/2022042104/5e8164ddac69643bb444de74/html5/thumbnails/13.jpg)
Graphic environment
al_create_display(int w, int h)
![Page 14: There is more to C · There is more to C 26.11. 2012 FI MUNI Juraj Michálek](https://reader034.vdocuments.site/reader034/viewer/2022042104/5e8164ddac69643bb444de74/html5/thumbnails/14.jpg)
ALLEGRO_BITMAP
Structure for bitmaps
ALLEGRO_BITMAP *bmp = create_bitmap(x,y);
![Page 15: There is more to C · There is more to C 26.11. 2012 FI MUNI Juraj Michálek](https://reader034.vdocuments.site/reader034/viewer/2022042104/5e8164ddac69643bb444de74/html5/thumbnails/15.jpg)
Graphics
al_putpixel(x, y, color)
al_load_bitmap(filename);
al_draw_bitmap(bmp, 10, 10, 0);
![Page 16: There is more to C · There is more to C 26.11. 2012 FI MUNI Juraj Michálek](https://reader034.vdocuments.site/reader034/viewer/2022042104/5e8164ddac69643bb444de74/html5/thumbnails/16.jpg)
Release memory
al_destroy_bitmap(bmp);
![Page 17: There is more to C · There is more to C 26.11. 2012 FI MUNI Juraj Michálek](https://reader034.vdocuments.site/reader034/viewer/2022042104/5e8164ddac69643bb444de74/html5/thumbnails/17.jpg)
Keyboard
al_install_keyboard()al_uninstall_keyboard()
event.keyboard.keycode
![Page 18: There is more to C · There is more to C 26.11. 2012 FI MUNI Juraj Michálek](https://reader034.vdocuments.site/reader034/viewer/2022042104/5e8164ddac69643bb444de74/html5/thumbnails/18.jpg)
Mouse
al_install_mouse()al_uninstall_mouse()
al_get_mouse_state(&msestate);
![Page 19: There is more to C · There is more to C 26.11. 2012 FI MUNI Juraj Michálek](https://reader034.vdocuments.site/reader034/viewer/2022042104/5e8164ddac69643bb444de74/html5/thumbnails/19.jpg)
Additional Allegro libraries
Allegttf - True Type fonts support
AllegGL – HW accelerated graphics
DUMB - audio (Vorbis/Ogg)
![Page 20: There is more to C · There is more to C 26.11. 2012 FI MUNI Juraj Michálek](https://reader034.vdocuments.site/reader034/viewer/2022042104/5e8164ddac69643bb444de74/html5/thumbnails/20.jpg)
CompilationConfiguration 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
![Page 22: There is more to C · There is more to C 26.11. 2012 FI MUNI Juraj Michálek](https://reader034.vdocuments.site/reader034/viewer/2022042104/5e8164ddac69643bb444de74/html5/thumbnails/22.jpg)
Allegro – CMake – MSVC 2012
Requires: 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/
![Page 23: There is more to C · There is more to C 26.11. 2012 FI MUNI Juraj Michálek](https://reader034.vdocuments.site/reader034/viewer/2022042104/5e8164ddac69643bb444de74/html5/thumbnails/23.jpg)
Allegro – CMake - KDevelop4
![Page 24: There is more to C · There is more to C 26.11. 2012 FI MUNI Juraj Michálek](https://reader034.vdocuments.site/reader034/viewer/2022042104/5e8164ddac69643bb444de74/html5/thumbnails/24.jpg)
Sources
Library: http://alleg.sourceforge.net
Wiki: http://wiki.allegro.cc/
![Page 26: There is more to C · There is more to C 26.11. 2012 FI MUNI Juraj Michálek](https://reader034.vdocuments.site/reader034/viewer/2022042104/5e8164ddac69643bb444de74/html5/thumbnails/26.jpg)
Simple Direct Media Layer
![Page 27: There is more to C · There is more to C 26.11. 2012 FI MUNI Juraj Michálek](https://reader034.vdocuments.site/reader034/viewer/2022042104/5e8164ddac69643bb444de74/html5/thumbnails/27.jpg)
Init/quit
SDL_init(flags)
SDL_quit()
![Page 28: There is more to C · There is more to C 26.11. 2012 FI MUNI Juraj Michálek](https://reader034.vdocuments.site/reader034/viewer/2022042104/5e8164ddac69643bb444de74/html5/thumbnails/28.jpg)
Graphics
SDL_SetVideoMode(width, height, video_bpp, videoflags)
Store in memory: SDL_SWSURFACEStore on graphics card: SDL_HWSURFACE
![Page 29: There is more to C · There is more to C 26.11. 2012 FI MUNI Juraj Michálek](https://reader034.vdocuments.site/reader034/viewer/2022042104/5e8164ddac69643bb444de74/html5/thumbnails/29.jpg)
Visual data
SDL_Surface
SDL_CreateRGBSurface(SDL_SWSURFACE, width, height, 32, rmask, gmask, bmask,
amask);
![Page 30: There is more to C · There is more to C 26.11. 2012 FI MUNI Juraj Michálek](https://reader034.vdocuments.site/reader034/viewer/2022042104/5e8164ddac69643bb444de74/html5/thumbnails/30.jpg)
Visual data
SDL_Surface *SDL_LoadBMP(const char *file)
Copy from one memory to another:SDL_BlitSurface(src, srcrect, dst,
dstrect);
![Page 31: There is more to C · There is more to C 26.11. 2012 FI MUNI Juraj Michálek](https://reader034.vdocuments.site/reader034/viewer/2022042104/5e8164ddac69643bb444de74/html5/thumbnails/31.jpg)
Keyboard
SDL_PollEvent(SDL_Event *event)
event.key.keysym.sym
![Page 32: There is more to C · There is more to C 26.11. 2012 FI MUNI Juraj Michálek](https://reader034.vdocuments.site/reader034/viewer/2022042104/5e8164ddac69643bb444de74/html5/thumbnails/32.jpg)
Timer
static int counter;
SDL_SetTimer(interval, tick_callback);
![Page 33: There is more to C · There is more to C 26.11. 2012 FI MUNI Juraj Michálek](https://reader034.vdocuments.site/reader034/viewer/2022042104/5e8164ddac69643bb444de74/html5/thumbnails/33.jpg)
Mouse
SDL_GetMouseState(*x, *y);
![Page 34: There is more to C · There is more to C 26.11. 2012 FI MUNI Juraj Michálek](https://reader034.vdocuments.site/reader034/viewer/2022042104/5e8164ddac69643bb444de74/html5/thumbnails/34.jpg)
Text
Not implemented
![Page 35: There is more to C · There is more to C 26.11. 2012 FI MUNI Juraj Michálek](https://reader034.vdocuments.site/reader034/viewer/2022042104/5e8164ddac69643bb444de74/html5/thumbnails/35.jpg)
Extensions
support for GL
extension for many languagesAda, Eiffel, Java, Lua, Perl, PHP, Pike, Python,
Ruby
176 additional libraries
![Page 36: There is more to C · There is more to C 26.11. 2012 FI MUNI Juraj Michálek](https://reader034.vdocuments.site/reader034/viewer/2022042104/5e8164ddac69643bb444de74/html5/thumbnails/36.jpg)
SDL based Libraries
SDL_mixer – audio mixer
SDL_image – image formats
SDL_net – network support
![Page 38: There is more to C · There is more to C 26.11. 2012 FI MUNI Juraj Michálek](https://reader034.vdocuments.site/reader034/viewer/2022042104/5e8164ddac69643bb444de74/html5/thumbnails/38.jpg)
Compilation
sdl-config
Linux, Windows, BeOS, Mac OSgcc foo.cc -o foo `sdl-config --libs`
![Page 41: There is more to C · There is more to C 26.11. 2012 FI MUNI Juraj Michálek](https://reader034.vdocuments.site/reader034/viewer/2022042104/5e8164ddac69643bb444de74/html5/thumbnails/41.jpg)
Architecture of Node.js
![Page 42: There is more to C · There is more to C 26.11. 2012 FI MUNI Juraj Michálek](https://reader034.vdocuments.site/reader034/viewer/2022042104/5e8164ddac69643bb444de74/html5/thumbnails/42.jpg)
libuv
High performance evented I/O library
which offers the same API
on Windows and Unix
![Page 43: There is more to C · There is more to C 26.11. 2012 FI MUNI Juraj Michálek](https://reader034.vdocuments.site/reader034/viewer/2022042104/5e8164ddac69643bb444de74/html5/thumbnails/43.jpg)
libuv
https://github.com/joyent/libuv
http://nikhilm.github.com/uvbook/index.html
![Page 44: There is more to C · There is more to C 26.11. 2012 FI MUNI Juraj Michálek](https://reader034.vdocuments.site/reader034/viewer/2022042104/5e8164ddac69643bb444de74/html5/thumbnails/44.jpg)
libuv – event loop
Call callbacks Sleep
![Page 45: There is more to C · There is more to C 26.11. 2012 FI MUNI Juraj Michálek](https://reader034.vdocuments.site/reader034/viewer/2022042104/5e8164ddac69643bb444de74/html5/thumbnails/45.jpg)
libuv - example
![Page 46: There is more to C · There is more to C 26.11. 2012 FI MUNI Juraj Michálek](https://reader034.vdocuments.site/reader034/viewer/2022042104/5e8164ddac69643bb444de74/html5/thumbnails/46.jpg)
Features
Filesystem
Networking
Threads
Processes
Utilities
![Page 47: There is more to C · There is more to C 26.11. 2012 FI MUNI Juraj Michálek](https://reader034.vdocuments.site/reader034/viewer/2022042104/5e8164ddac69643bb444de74/html5/thumbnails/47.jpg)
TCP server example
![Page 49: There is more to C · There is more to C 26.11. 2012 FI MUNI Juraj Michálek](https://reader034.vdocuments.site/reader034/viewer/2022042104/5e8164ddac69643bb444de74/html5/thumbnails/49.jpg)
GTK
GIMP ToolKit
C++, Guile, Perl, Python, TOM, Ada95, Objective C, Free Pascal, Eiffel...
![Page 51: There is more to C · There is more to C 26.11. 2012 FI MUNI Juraj Michálek](https://reader034.vdocuments.site/reader034/viewer/2022042104/5e8164ddac69643bb444de74/html5/thumbnails/51.jpg)
Valgrind
debugging a profiling
memcheck
helgrind - race condition, thread profiling
![Page 52: There is more to C · There is more to C 26.11. 2012 FI MUNI Juraj Michálek](https://reader034.vdocuments.site/reader034/viewer/2022042104/5e8164ddac69643bb444de74/html5/thumbnails/52.jpg)
Modes debugger
Local application
Attach to local process
Attach to remote process
Post-mortem
![Page 53: There is more to C · There is more to C 26.11. 2012 FI MUNI Juraj Michálek](https://reader034.vdocuments.site/reader034/viewer/2022042104/5e8164ddac69643bb444de74/html5/thumbnails/53.jpg)
Application crashed
Post-mortem analysis
Image from memory: coredump
![Page 54: There is more to C · There is more to C 26.11. 2012 FI MUNI Juraj Michálek](https://reader034.vdocuments.site/reader034/viewer/2022042104/5e8164ddac69643bb444de74/html5/thumbnails/54.jpg)
Quick analysis of coredump
![Page 55: There is more to C · There is more to C 26.11. 2012 FI MUNI Juraj Michálek](https://reader034.vdocuments.site/reader034/viewer/2022042104/5e8164ddac69643bb444de74/html5/thumbnails/55.jpg)
Strace
![Page 56: There is more to C · There is more to C 26.11. 2012 FI MUNI Juraj Michálek](https://reader034.vdocuments.site/reader034/viewer/2022042104/5e8164ddac69643bb444de74/html5/thumbnails/56.jpg)
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
![Page 58: There is more to C · There is more to C 26.11. 2012 FI MUNI Juraj Michálek](https://reader034.vdocuments.site/reader034/viewer/2022042104/5e8164ddac69643bb444de74/html5/thumbnails/58.jpg)
EOF
26.11. 2012FI MUNI
Juraj Michálekhttp://georgik.sinusgear.comhttp://twitter.com/sinusgear