Drawing rectangles SDL
Drawing rectangles can become such a pain in the ass after drawing them a couple of times. I made a helper function that makes this easier.
void FillRect(int x, int y, int w, int h, int color) {
SDL_Rect rect = {x,y,w,h};
SDL_FillRect(screen, &rect, color);
}
I want to add a 100×150 rectangle at the position (25,25) with the color white.
FillRect(25,25,100,150,0xFFFFFF);
Great, no more headache and code memorizing.
Using the OpenBSD package system
The package system in OpenBSD consists of pre-compiled programs that can be managed with the pkg tool. The packages may not necessarily contain the same kind of security and realibility as the base system, but pkg is useful for installing “third party” software.
1. Create the environment variabel PKG_PATH with the value of the right directory to fetch the packages.
export PKG_PATH=ftp://ftp.openbsd.org/pub/OpenBSD/4.5/packages/i386/
2. Add this line into the startup file, ~/.profiles so we don’t have to export it every time we use pkg.
Installing a package
pkg_add -i firefox
Removing a package
pkg_delete firefox
Information about installed packages
pkg_info