GLib2d

From homebrew.pixelbath
Revision as of 22:24, 27 April 2017 by Mhoskins (talk | contribs) (initial page from https://github.com/libcg/gLib2D)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

gLib2D is a C library by Geecko that aims to be a simple, fast, lightweight 2D graphics library. It has been specifically designed to replace the old graphics.c (graphics.h) file found in many PSP homebrew tutorials.

Installation

As a single include file, the glib2d.c and its header file can be dropped directly into your main project. At the top of your main file, add:

#include "glib2d.h"

Examples

Load a PNG File

Note that while most examples show loading the bare filename, in practice I found this to be problematic. An easy way to load an absolute path is by adding some macros to the top:

#define TITLE "APPTITLE"
#define ROOT "ms0:/PSP/GAME/" TITLE "/"

We can now stuff the ROOT macro into the path. In order to successfully locate the PNG file, it must be located in the ROOT path. The "swizzle" parameter tells the PSP to load the image via a faster-use method:

g2dTexture* tex = _g2dTexLoadPNG(ROOT "filename.png", G2D_SWIZZLE);