2 //metadoc GLUQuadric copyright Steve Dekorte 2002
3 //metadoc GLUQuadric license BSD revised
4 //metadoc GLUQuadric category Graphics
6 #include "IoGLUQuadric.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");
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
);
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
);
44 /* ----------------------------------------------------------- */
46 IoGLUQuadric
*IoGLUQuadric_rawClone(IoGLUQuadric
*proto
)
48 IoObject
*self
= IoObject_rawClonePrimitive(proto
);
49 IoObject_setDataPointer_(self
, cpalloc(IoObject_dataPointer(proto
), sizeof(IoGLUQuadricData
)));
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
)
71 { DATA(self
)->q
= gluNewQuadric(); }