Addons updated to new doc format
[io.git] / addons / OpenGL / source / IoGLUQuadric.c
blob535f32cc6538f3bd38c36f90168b78ec3a24e621
2 //metadoc GLUQuadric copyright Steve Dekorte 2002
3 //metadoc GLUQuadric license BSD revised
4 //metadoc GLUQuadric category Graphics
6 #include "IoGLUQuadric.h"
7 #include "List.h"
8 #include "IoState.h"
9 #include "IoNumber.h"
10 #include "IoList.h"
11 #include "IoFile.h"
13 #define DATA(self) ((IoGLUQuadricData *)IoObject_dataPointer(self))
15 IoObject *IoMessage_locals_gluQuadricArgAt_(IoMessage *self, IoObject *locals, int n)
17 IoObject *v = IoMessage_locals_valueArgAt_(self, locals, n);
18 if (!ISGLUQUADRIC(v)) IoMessage_locals_numberArgAt_errorForType_(self, locals, n, "GLUQuadric");
19 return v;
22 IoTag *IoGLUQuadric_newTag(void *state)
24 IoTag *tag = IoTag_newWithName_("GLUQuadric");
25 IoTag_state_(tag, state);
26 IoTag_cloneFunc_(tag, (IoTagCloneFunc *)IoGLUQuadric_rawClone);
27 IoTag_freeFunc_(tag, (IoTagFreeFunc *)IoGLUQuadric_free);
28 IoTag_markFunc_(tag, (IoTagMarkFunc *)IoGLUQuadric_mark);
29 return tag;
32 IoGLUQuadric *IoGLUQuadric_proto(void *state)
34 IoObject *self = IoObject_new(state);
35 IoObject_tag_(self, IoGLUQuadric_newTag(state));
37 IoObject_setDataPointer_(self, calloc(1, sizeof(IoGLUQuadricData)));
39 IoState_registerProtoWithFunc_(state, self, IoGLUQuadric_proto);
41 return self;
44 /* ----------------------------------------------------------- */
46 IoGLUQuadric *IoGLUQuadric_rawClone(IoGLUQuadric *proto)
48 IoObject *self = IoObject_rawClonePrimitive(proto);
49 IoObject_setDataPointer_(self, cpalloc(IoObject_dataPointer(proto), sizeof(IoGLUQuadricData)));
50 return self;
53 IoGLUQuadric *IoGLUQuadric_new(void *state)
55 IoGLUQuadric *proto = IoState_protoWithInitFunction_(state, IoGLUQuadric_proto);
56 return IOCLONE(proto);
59 void IoGLUQuadric_free(IoGLUQuadric *self)
61 if (DATA(self)->q) gluDeleteQuadric(DATA(self)->q);
62 free(IoObject_dataPointer(self));
65 void IoGLUQuadric_mark(IoGLUQuadric *self)
66 { if (DATA(self)->texture) IoObject_shouldMark((IoObject *)(DATA(self)->texture)); }
68 GLUquadricObj *IoGLUQuadric_quadric(IoGLUQuadric *self)
70 if (!DATA(self)->q)
71 { DATA(self)->q = gluNewQuadric(); }
72 return DATA(self)->q;