nsi.h

  1#ifndef __nsi_h
  2#define __nsi_h
  3
  4#include <stddef.h>
  5
  6#ifdef _WIN32
  7    #define DL_INTERFACE __declspec(dllimport)
  8#else
  9    #define DL_INTERFACE
 10#endif
 11
 12#ifdef  __cplusplus
 13extern "C" {
 14#endif
 15
 16typedef int NSIContext_t;
 17typedef const char* NSIHandle_t;
 18
 19#define NSI_BAD_CONTEXT ((NSIContext_t)0)
 20#define NSI_SCENE_ROOT ".root"
 21#define NSI_SCENE_GLOBAL ".global"
 22#define NSI_ALL_NODES ".all"
 23#define NSI_ALL_ATTRIBUTES ".all"
 24#define NSI_VERSION 2
 25
 26/* Type values for NSIParam_t.type */
 27enum NSIType_t
 28{
 29	NSITypeInvalid = 0,
 30	NSITypeFloat = 1,
 31	NSITypeDouble = NSITypeFloat | 0x10,
 32	NSITypeInteger = 2,
 33	NSITypeString = 3,
 34	NSITypeColor = 4,
 35	NSITypePoint = 5,
 36	NSITypeVector = 6,
 37	NSITypeNormal = 7,
 38	NSITypeMatrix = 8,
 39	NSITypeDoubleMatrix = NSITypeMatrix | 0x10,
 40	NSITypePointer = 9
 41};
 42
 43static inline
 44size_t NSITypeSizeOf(unsigned t)
 45{
 46	static const unsigned char sizes[] =
 47	{
 48		0, sizeof(float), sizeof(int), sizeof(char*),
 49		3*sizeof(float), 3*sizeof(float), 3*sizeof(float), 3*sizeof(float),
 50		16*sizeof(float), sizeof(void*), 0, 0,
 51		0, 0, 0, 0,
 52		0, sizeof(double), 0, 0,
 53		0, 0, 0, 0,
 54		16*sizeof(double)
 55	};
 56	return t <= 24 ? sizes[t] : 0;
 57}
 58
 59/* Flag values for NSIParam_t.flags */
 60enum
 61{
 62	NSIParamIsArray = 1,
 63	NSIParamPerFace = 2,
 64	NSIParamPerVertex = 4,
 65	NSIParamInterpolateLinear = 8
 66};
 67
 68/* Structure for optional parameters. */
 69struct NSIParam_t
 70{
 71	const char *name;
 72	const void *data;
 73	int type;
 74	int arraylength;
 75	size_t count;
 76	int flags;
 77};
 78
 79/* Values for second parameter of NSIRenderStopped_t */
 80enum NSIStoppingStatus
 81{
 82	NSIRenderCompleted = 0,
 83	NSIRenderAborted = 1,
 84	NSIRenderSynchronized = 2,
 85	NSIRenderRestarted = 3
 86};
 87
 88/* Error levels for the error callback. */
 89enum NSIErrorLevel
 90{
 91	NSIErrMessage = 0,
 92	NSIErrInfo = 1,
 93	NSIErrWarning = 2,
 94	NSIErrError = 3
 95};
 96
 97/* Error handler callback type. */
 98typedef void (*NSIErrorHandler_t)(
 99	void *userdata, int level, int code, const char *message );
100
101/* Stopped callback type. */
102typedef void (*NSIRenderStopped_t)(
103	void *userdata, NSIContext_t ctx, int status );
104
105DL_INTERFACE NSIContext_t NSIBegin(
106	int nparams,
107	const struct NSIParam_t *params );
108
109DL_INTERFACE void NSIEnd( NSIContext_t ctx );
110
111DL_INTERFACE void NSICreate(
112	NSIContext_t ctx,
113	NSIHandle_t handle,
114	const char *type,
115	int nparams,
116	const struct NSIParam_t *params );
117
118DL_INTERFACE void NSIDelete(
119	NSIContext_t ctx,
120	NSIHandle_t handle,
121	int nparams,
122	const struct NSIParam_t *params );
123
124DL_INTERFACE void NSISetAttribute(
125	NSIContext_t ctx,
126	NSIHandle_t object,
127	int nparams,
128	const struct NSIParam_t *params );
129
130DL_INTERFACE void NSISetAttributeAtTime(
131	NSIContext_t ctx,
132	NSIHandle_t object,
133	double time,
134	int nparams,
135	const struct NSIParam_t *params );
136
137DL_INTERFACE void NSIDeleteAttribute(
138	NSIContext_t ctx,
139	NSIHandle_t object,
140	const char *name );
141
142DL_INTERFACE void NSIConnect(
143	NSIContext_t ctx,
144	NSIHandle_t from,
145	const char *from_attr,
146	NSIHandle_t to,
147	const char *to_attr,
148	int nparams,
149	const struct NSIParam_t *params );
150
151DL_INTERFACE void NSIDisconnect(
152	NSIContext_t ctx,
153	NSIHandle_t from,
154	const char *from_attr,
155	NSIHandle_t to,
156	const char *to_attr );
157
158DL_INTERFACE void NSIEvaluate(
159	NSIContext_t ctx,
160	int nparams,
161	const struct NSIParam_t *params );
162
163DL_INTERFACE void NSIRenderControl(
164	NSIContext_t ctx,
165	int nparams,
166	const struct NSIParam_t *params );
167
168#ifdef __cplusplus
169}
170#endif
171
172#endif