-
Notifications
You must be signed in to change notification settings - Fork 0
cResource
Holds a programmer-implemented object. It doesn't offer any functionality on its own; the programmer must provide a drawing and cleanup routine.
void*
Holds a pointer to whatever struct or datatype you want, casted into void*. This is what you're passing into drawingRoutine to draw, and cleanupRoutine to de-allocate (if necessary).
void (*drawingRoutine)(void*, cCamera)
The function pointer to your custom draw routine. The subclass what is passed into the function through the void* argument (i.e. when called, it is called as such: yourCResource->drawingRoutine(yourCResource->subclass, camera);)
Note that of course you must cast the void* argument back to whatever struct or datatype your subclass initially was.
void (*cleanupRoutine)(void*)
The function pointer to your custom cleanup routine. Again, the subclass is what will be passed into this method at runtime. If no cleanup is required, initialize this as NULL.
void initCResource(cResource* res, void* subclass, void (*drawingRoutine)(void*, cCamera), void (*cleanupRoutine)(void*), int renderLayer)
This will initialize the cResource you pass in with the data passed in. Pass NULL for cleanupRoutine if no cleanup routine is required.
void drawCResource(cResource* res, cCamera camera)
All this does is call your custom draw routine with your subclass data and the given camera as arguments.
void destroyCResource(cResource* res)
All this does is call your custom cleanup routine with your subclass data as the argument. If the custom cleanup routine is NULL, this will be skipped.