Mercurial > hg > dmlib
view dmtimeline.h @ 332:d4802335cbbc
Clean up video (re)initialization.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Mon, 15 Oct 2012 13:17:12 +0300 |
parents | af04394e9620 |
children | 40e8a01e0478 |
line wrap: on
line source
#ifndef DMTIMELINE_H #define DMTIMELINE_H #include "dmlib.h" #include "dmres.h" #ifdef __cplusplus extern "C" { #endif #define DT_MAGIC_ID "SDMETLNE" #define DT_MAX_EFFECT_PARAMS 16 #define DT_MAX_NAME_LENGTH 32 #define DT_FLOAT_STORE_SIZE 16 enum { EFIT_SET, // No interpolation, just "set" the value EFIT_LINEAR, // Linear interpolation EFIT_SMOOTH, // Smoothstep interpolation }; enum { EFPT_POINTS, EFPT_INT, EFPT_FLOAT, EFPT_STRING, }; typedef struct { int type; // Interpolation type (EFIT_*) between this and next point int time; // Offsets to event start, -1 == attach to event start, -2 = event end (if event) DMFloat value; } DMTimelinePoint; typedef struct { int npoints, nallocated; DMTimelinePoint *points; } DMTimelinePoints; typedef struct { char *name; // Name / description of the parameter int type; // Type (EFPT_*) char *vstr; int vint; DMFloat vfloat; DMTimelinePoints vpts; } DMTimelineEventParam; typedef struct { char name[DT_MAX_NAME_LENGTH]; Uint32 type; } DMFTimelineEventParam; typedef struct { char * name; int type; int (*init)(void **data); void (*shutdown)(void *data); int (*render)(SDL_Surface *screen, void *data, const DMTimelineEventParam *params); int nparams; DMTimelineEventParam params[DT_MAX_EFFECT_PARAMS]; } DMEffect; typedef struct { Uint32 start, duration; char effectName[DT_MAX_NAME_LENGTH]; Uint32 nparams; } DMFTimelineEvent; typedef struct { int start, duration; DMEffect *effect; int nparams; DMTimelineEventParam *params; } DMTimelineEvent; typedef struct { BOOL enabled; DMTimelinePoints points; } DMTimelineCurve; typedef struct { char name[DT_MAX_NAME_LENGTH]; Uint8 enabled; Uint32 nevents; } DMFTimelineTrack; typedef struct { char *name; // Name of the timeline track BOOL enabled; // Enabled? int nevents, nallocated; // Number of events DMTimelineEvent **events; // Events DMTimelineCurve composite; // Composite curve (transparency of the "layer") } DMTimelineTrack; typedef struct { char magic[8]; char name[DT_MAX_NAME_LENGTH]; Uint32 ntracks; Uint32 duration; } DMFTimeline; typedef struct { char *name; int ntracks, nallocated, duration; DMTimelineTrack **tracks; } DMTimeline; typedef struct { DMTimelineTrack *track; DMTimelineEvent *event; } DMPreparedEvent; typedef struct _DMPreparedEventGroup { int start, end, nevents, nallocated; DMPreparedEvent *events; struct _DMPreparedEventGroup *next, *prev; } DMPreparedEventGroup; typedef struct { int duration, ngroups, pos; DMPreparedEventGroup **groups; } DMPreparedTimeline; extern DMEffect *dmEffects; extern int ndmEffects, ndmEffectsAlloc; extern void **dmEffectData; int dmRegisterEffect(const DMEffect *ef); int dmInitializeEffects(); void dmShutdownEffects(); DMEffect *dmFindEffect(const char *name, const int nparams); DMEffect *dmFindEffectByName(const char *name); int dmLoadTimeline(DMResource *res, DMTimeline **tl); void dmFreeTimeline(DMTimeline *tl); // Execution related int dmPrepareTimeline(DMTimeline *tl, DMPreparedTimeline *ptl); int dmSeekTimeline(DMPreparedTimeline *tl, int time); int dmExecuteTimeline(DMPreparedTimeline *tl, SDL_Surface *screen, int time); // Editing/saving related functions int dmSaveTimeline(DMResource *res, DMTimeline *tl); int dmTimelineNew(DMTimeline **tl, const char *name); int dmTimelineAddTrack(DMTimeline *tl, DMTimelineTrack **track, const char *name); int dmTimelineTrackAddEvent(DMTimelineTrack *track, int start, int duration, DMTimelineEvent **pev); int dmTimelineEventSetEffect(DMTimelineEvent *event, const char *name); DMTimelineEvent *dmTimelineGetEventAt(DMTimelineTrack *track, int time); #ifdef __cplusplus } #endif #endif // DMTIMELINE_H