#+TITLE: sdl2 org src
#+AUTHOR: screwtape
* Rich media sdl2 C applications
(skip past window settings in your reading; they are just better at the top)
** Various updates
Now has odd inline
| SDL_HasIntersection(SDL_Rect *, SDL_Rect *) |
| SDL_IntersectRectAndLine(SDL_Rect *, int *x0, int *y0, int *x1, int *y1 |
| Array of SDL_Rect rocks being used somehow |
Note that SDL_IntersectRectAndLine clobbers intersected endpoint int *s.
both intersections should be compared with SDL_TRUE / SDL_FALSE.
** Window settings
#+NAME: w-sizing
#+HEADER: :includes "/usr/local/include/SDL2/SDL.h"
#+begin_src C
SDL_WINDOW_RESIZABLE
#+end_src
#+NAME: w-height
#+begin_src C
768
#+end_src
#+NAME: w-width
#+begin_src C
1280
#+end_src
** template
#+BEGIN_EXAMPLE
This template does seem a little bit goto cleanup rather than some clunky
long, but that is because it handles quit flag; but then, it was easier
keyboard and mouse events and mouse to goto quit which gotos cleanup. At
position in the general case. I do least the loop isn't goto based!
#+END_EXAMPLE
includes and libs might need to be customized. I found that my sdl2-config
flags on arm64 openbsd didn't actually work!
#+name: template
#+HEADER: :includes "/usr/local/include/SDL2/SDL.h" <stdlib.h>
#+HEADER: :libs "-L/usr/local/lib -lSDL2"
#+HEADER: :exports code
#+HEADER: :results none
#+HEADER: :noweb yes
#+begin_src C
<<hero-init>>
/* random */
int ra, rb;
time_t rt;
srand((unsigned)time(&rt));
/* /rand */