Agar Logo

Agar 1.7 Manual

(Printable Version)


#include <agar/core.h>
#include <agar/gui.h>
#include <agar/map/rg.h>


The RG_Feature element performs some operation on the surface of a RG_Tile(3). For example, a Blur filter may be implemented as a RG_Feature. The interface is defined by the RG_FeatureOps structure:
typedef struct rg_feature_ops {
	const char *type;       /* Feature name */
	AG_Size len;            /* Size of structure */
	const char *desc;       /* Feature description */
	int flags;
#define RG_FEATURE_AUTOREDRAW 0x01 /* Automatic redraw on edit */

	void (*init)(void *self, RG_Tileset *set, int flags);
	int  (*load)(void *self, AG_DataSource *ds);
	void (*save)(void *self, AG_DataSource *ds);
	void (*destroy)(void *self);
	void (*apply)(void *self, RG_Tile *tile, int x, int y);
	void (*menu)(void *self, AG_MenuItem *menu);
	AG_Toolbar *(*toolbar)(void *self, RG_Tileview *view);
	AG_Window  *(*edit)(void *self, RG_Tileview *view);

The init(), load(), save(), destroy() and edit() operations are analogous to the AG_Object(3) operations of the same name. init() must invoke RG_FeatureInit().

The menu() and toolbar() operations, where not NULL, generate and return AG_Menu(3) items and an AG_Toolbar(3), respectively, for the GUI.

The apply() operation performs the actual modification on the tile. The x and y arguments are specific to the instance of this feature and may be ignored.


void RG_FeatureInit (void *feature, RG_Tileset *ts, int flags, const RG_FeatureOps *featureOps)

void RG_FeatureAddPixmap (RG_Feature *feature, RG_Pixmap *pixmap)

void RG_FeatureAddSketch (RG_Feature *feature, RG_Sketch *sketch)

void RG_FeatureDelPixmap (RG_Feature *feature, RG_Pixmap *pixmap)

void RG_FeatureDelSketch (RG_Feature *feature, RG_Sketch *sketch)

The RG_FeatureInit() function initializes a derivate of the RG_Feature structure, described by the ops structure (see DESCRIPTION section). The following flags are defined:
RG_FEATURE_AUTOREDRAWPeriodically redraw target tile when feature is undergoing edition.

Features occasionally need to reference other resources in the current RG_Tileset. The RG_FeatureAddPixmap() and RG_FeatureAddSketch() functions add a reference to a pixmap or sketch, respectively. RG_FeatureDelPixmap() and RG_FeatureDelSketch() remove the given reference.

SEE ALSO ElectronTubeStore