Skip to content
slaeshjag edited this page Mar 24, 2013 · 16 revisions

DARNIT_PLATFORMS

These bit flags are used to indicate what platform libdarnit detected/was built for.

#define         DARNIT_PLATFORM_DESKTOP         0x100000
#define         DARNIT_PLATFORM_HANDHELD        0x200000

#define         DARNIT_PLATFORM_LINUX           0x1
#define         DARNIT_PLATFORM_WIN32           0x2
#define         DARNIT_PLATFORM_PANDORA         0x4
#define         DARNIT_PLATFORM_GCWZERO         0x8
#define         DARNIT_PLATFORM_GPHCAANOO       0x10
#define         DARNIT_PLATFORM_MACOSX          0x20
#define         DARNIT_PLATFORM_FREEBSD         0x40
#define         DARNIT_PLATFORM_MAEMO           0x80
#define         DARNIT_PLATFORM_BIGENDIAN       0x80000000

There's only one of the bit-flags < 0x10000 in a DARNIT_PLATFORMS field. There can be multiple ones of those with a larger value.

DARNIT_PLATFORM

typedef struct {
        DARNIT_PLATFORMS        platform;
        unsigned int            screen_w;
        unsigned int            screen_h;
        unsigned int            fullscreen;
} DARNIT_PLATFORM;
  • platform - Is a series of flags indicating the platform the program is running on.
  • screen_w - If fully initialized, this is the current screen/window width. If not fully initialized, it's the recommended screen width.
  • screen_h - Same as above, but screen/window height
  • fullscreen - Same as above, but wuth fullscreen. 1 if fullscreen, 0 if not.

DARNIT_VIDEOMODE

typedef struct {
        signed short            x       : 16;
        signed  short           y       : 16;
        unsigned short          w       : 16;
        unsigned short          h       : 16;
} DARNIT_VIDEOMODE;

This is a direct wrapper of SDL_ListModes, with the exception that -1 is not returned if all modes are available. That's just silly. We use NULL instead.

  • x - You can't do anything with it in libdarnit, ignore
  • y - Same as above
  • w - Screen width for the supported mode
  • h - Screen height for the supported mode

DARNIT_MAIN

  • void *d_init(const char *wtitle, const char *data_dir, const char *icon);
  • void *d_init_custom(const char *wtitle, int win_w, int win_h, int fullscreen, const char *data_dir, const * char *icon);
  • void d_loop();
  • unsigned int d_time_get();
  • int d_fps();
  • int d_last_frame_time();
  • DARNIT_PLATFORM d_platform_get();
  • void d_quit();
  • void *d_init_partial(const char *data_dir);
  • int d_init_rest(const char *wtitle, int win_w, int win_h, int fullscreen, const char *icon);
  • DARNIT_VIDEOMODE **d_videomode_get();

d_init

void *d_init(const char *wtitle, const char *data_dir, const char *icon);

Initializes libdarnit and creates a window with values from platform defaults.

Arguments

  • wtitle - A string that will be displayed as the windows title
  • data_dir - The name of the directories that store data in data and write dir path. See platform defaults for more information.
  • icon - Path for the window icon. Can be in any supported image format. Can be inside an LDI file, provided it's mounted. NULL means no icon.

Return value

Returns NULL on failure, anything else is success. You do not need to save this pointer, and you can't really do anything but trouble with it.

d_init_custom

void *d_init_custom(const char *wtitle, int win_w, int win_h, int fullscreen, const char *data_dir, const char *icon);

Creates a window with all parameters specified by the program instead of with platform defaults.

Arguments

  • wtitle - A string that will be displayed as the windows title
  • win_w - The width of the window to create
  • win_h - The height of the window to create
  • fullscreen - 1 if you want it to be full screen, 0 if not
  • data_dir - The name of the directories that store data in data and write dir path. See platform defaults for more information.
  • icon - Path for the window icon. Can be in any supported image format. Can be inside an LDI file, provided it's mounted. NULL means no icon.

Return value

Returns NULL on failure, anything else is success. You do not need to save this pointer, and you can't really do anything but trouble with it.

d_loop

void d_loop();

Flips the rendering buffer and does some various housekeeping. It also locks the framerate to 60 FPS. Must be called after you've rendered a frame.

Arguments None.

Return value None.

d_time_get

unsigned int d_time_get();

Just a wrapper for SDL_GetTicks. Returns the number of milliseconds since libdarnit was initialized.

Arguments None.

Return value

Returns the number of milliseconds since libdarnit was initialized.

d_fps

int d_fps();

Returns the number of frames that was rendered last second (actual counted frames, updated once per second.)

Arguments None.

Return value

Returns the number of frames that was rendered last second.

d_last_frame_time

int d_last_frame_time();

Returns the number of milliseconds it took to render last frame (the time between the last two calls to d_loop.)

Arguments None.

Return value

Number of milliseconds that elapsed while the last frame was rendered.

d_platform_get

DARNIT_PLATFORM d_platform_get();

Clone this wiki locally