vpSetCallback(3)
β¨ vpSetCallback(3) β¨
ok so bestie, you know that one page from the Library Functions Manual β the one about vpSetCallback? yeah. that one. sit down, get comfy, we're doing this π
π NAME π
vpSetCallback β define a callback function. that's it. that's the whole vibe. slay β¨
π¦ SYNOPSIS π¦
#include <volpack.h>
vpResult
vpSetCallback(vpc, option, func)
vpContext *vpc;
int option;
void (*func)();
πΈ ARGUMENTS πΈ
vpcβ your VolPack context, the one you got fromvpCreateContext. your main character, if you will πoptionβ a code that tells VolPack which callback function you're setting. it's giving "choose your fighter" energy.funcβ a pointer to the callback function itself. the actual function. the moment. π
π DESCRIPTION π
ok so vpSetCallback is literally the "hey, you handle this" function. you use it to set a callback function. here are all the possible values for option, no skips, no summaries, we're doing all of them fr fr:
VP_GRAY_SHADE_FUNCβfunchere is a shading callback that produces a floating point grayscale pixel intensity. it should be declared like this:
void func(void *voxel_ptr, float *i_ptr,
void *client_data);
voxel_ptrβ pointer to the beginning of a voxel that must be shaded.i_ptrβ the location where your function should store the grayscale intensity result. it should be a single-precision floating point in the range0.0(black) to1.0(white). black to white, the full range, no in-between shenanigans π€π€client_dataβ pointer to the application-defined client data (seevpSetClientData(3)).
the callback can be used to implement custom shading routines that cannot be implemented with a lookup table. see vpSetLookupShader(3) for more info. lowkey iconic.
VP_RGB_SHADE_FUNCβfunchere is a shading callback that produces a floating point RGB pixel intensity. it should be declared:
void func(void *voxel_ptr, float *r_ptr,
float *r_ptr, float *r_ptr,
void *client_data);
voxel_ptrβ pointer to the beginning of a voxel that must be shaded.r_ptr, g_ptr, b_ptrβ the location where your function should store the RGB intensities of the result. each intensity should be a single-precision floating point in the range0.0(no intensity) to1.0(full intensity).client_dataβ pointer to the application-defined client data (seevpSetClientData(3)).
the callback can be used to implement custom shading routines that cannot be implemented with a lookup table. see vpSetLookupShader(3) for more information.
VP_READ_FUNCβfunchere is a callback that takes the same arguments and returns the same result as theread(2)system call. it's used to read data from files (seevpLoadRawVolume(3)). by default, thereadsystem call is used. the callback can be used to implement a custom I/O interface β for example a compression/decompression system. custom I/O era πVP_WRITE_FUNCβfunchere is a callback that takes the same arguments and returns the same result as thewrite(2)system call. it's used to write data to files (seevpStoreRawVolume(3)). by default, thewritesystem call is used. the callback can be used to implement a custom I/O interface, for example a compression/decompression system.VP_MMAP_FUNCβfunchere is a callback that gets called to memory map data from a file instead of copying the data into memory (seevpLoadRawVolume(3)). it should be declared:
void *func(int fd, unsigned offset,
void *client_data);
fdβ file descriptor fromopen(2)open for reading.offsetβ byte offset in the file to the beginning of the memory to be mapped.client_dataβ pointer to the application-defined client data (seevpSetClientData(3)).
the function should map the entire file into memory and return a pointer to the memory location that corresponds to the file offset. by default, memory mapping is disabled. it's giving "opt-in only" π«Ά
VP_STATUS_FUNCβfunchere is a callback that gets called periodically during long-running operations, like during preprocessing of a volume. it should be declared:
void func(double frac, void *client_data);
fracβ an estimate of the fraction of the current operation that is complete.client_dataβ pointer to the client data associated with the context.
the callback can be used to print a status report or to process time-critical events such as user input.
β οΈ okay but for real: the callback should not make any calls to VolPack functions, because the internal VolPack state may be inconsistent. do not do it. hands off. no cap. π
VP_LOG_ALLOC_FUNCβfunchere is a callback that gets called whenever VolPack allocates memory. it should be declared:
void func(void *ptr, int size, char *use,
int line, char *file, void *client_data);
ptrβ address of the allocated memory.sizeβ size (in bytes) of the allocated memory.useβ short description of the use of the allocated memory.lineβ source code line number for the call to the memory allocator.fileβ source code file name for the call to the memory allocator.client_dataβ pointer to the client data associated with the context.
the callback can be used to track memory allocations (primarily for debugging memory leaks). detective mode π
VP_LOG_FREE_FUNCβfunchere is a callback that gets called whenever VolPack deallocates memory. it should be declared:
void func(void *ptr, void *client_data)
ptrβ address of the deallocated memory.client_dataβ pointer to the client data associated with the context.
the callback can be used to track memory deallocations (primarily for debugging memory leaks).
and here's the lil plot twist: if the func argument is NULL, then the corresponding callback function gets reset to the default behavior β or disabled if there's no default behavior. so NULL = "never mind, we're so back to normal" β¨
π ERRORS π
the normal return value is VP_OK. the following error return value is possible:
VPERROR_BAD_OPTIONβ theoptionargument is invalid. like, girl, that's not a real option π
π SEE ALSO π
VolPack(3), vpCreateContext(3), vpSetClientData(3), vpSetLookupShader(3), vpLoadRawVolume(3), vpStoreRawVolume(3)
ok that's the whole page bestie, you ate it, no crumbs ππ this was the vpSetCallback(3) page from the VolPack library, living in the Library Functions Manual β and yes, VolPack is the name at the bottom too, iykyk. go set some callbacks. mwah π
β¨
π¦ where this page comes from
- fedora 43: volpack 1.0c7-35.fc43 Β· BSD-3-Clause
- fedora 43: volpack 1.0c7-35.fc43 Β· BSD-3-Clause
- fedora 44: volpack 1.0c7-36.fc44 Β· BSD-3-Clause
- fedora 44: volpack 1.0c7-36.fc44 Β· BSD-3-Clause
- Copyright (c) 1995-2008, Stanford University
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms