Contents
TwType (enum)
DescriptionConstants used to declare the type of variables added to a tweak bar. Used by functions TwAddVarRW, TwAddVarRO and TwAddVarCB.
ConstantsTW_TYPE_BOOLCPPA C++ boolean. C++ only . Example: bool b = true; // ... TwAddVarRW(bar, "b", TW_TYPE_BOOLCPP, &b, ""); TW_TYPE_BOOL8A byte (8 bits) which represents a boolean value. Example: char mipmap = 0; // ... TwAddVarRW(bar, "MIP-map", TW_TYPE_BOOL8, &mipmap, " true=Enabled false=Disabled "); TW_TYPE_BOOL16A 16 bits variable which represents a boolean value. Example: short modeIsLinear = 1; // ... TwAddVarRW(bar, "InterpMode", TW_TYPE_BOOL16, &modeIsLinear, " label='Interpolation mode' true=Linear false=Point "); TW_TYPE_BOOL32A 32 bits variable which represents a boolean value. Example: int antialias = 0; // ... TwAddVarRW(bar, "Antialiasing", TW_TYPE_BOOL32, &antialias, " key=ALT+a "); TW_TYPE_CHARA character (8 bits). Example: char letter = 'A'; // ... TwAddVarRW(bar, "Letter", TW_TYPE_CHAR, &letter, " min=65 max=90 "); // 65 and 90 correspond to 'A' and 'Z' ASCII codes TW_TYPE_INT8A 8 bits signed integer. Example: signed char i8 = 0; // ... TwAddVarRW(bar, "int8", TW_TYPE_INT8, &i8, " keyIncr=i keyDecr=I "); TW_TYPE_UINT8A 8 bits unsigned integer. Example: unsigned char ui8 = 0; // ... TwAddVarRW(bar, "uint8", TW_TYPE_UINT8, &ui8, ""); TW_TYPE_INT16A 16 bits signed integer. Example: short i16 = 0; // ... TwAddVarRW(bar, "int16", TW_TYPE_INT16, &i16, ""); TW_TYPE_UINT16A 16 bits unsigned integer. Example: unsigned short ui16 = 0; // ... TwAddVarRW(bar, "uint16", TW_TYPE_UINT16, &ui16, ""); TW_TYPE_INT32A 32 bits signed integer. Example: int z = 20; // ... TwAddVarRW(bar, "Z", TW_TYPE_INT32, &z, " min=-1000 max=1000 keyIncr=z keyDecr=Z "); TW_TYPE_UINT32A 32 bits unsigned integer. Example: unsigned int cost = 2000; // ... TwAddVarRW(bar, "Cost", TW_TYPE_UINT32, &cost, " max=100000 step=100 "); TW_TYPE_FLOATA 32 bits floating point value (float). Example: float seconds = 5.0f; // ... TwAddVarRW(bar, "DeltaTime", TW_TYPE_FLOAT, &seconds, " min=0 max=60 step=0.1 "); TW_TYPE_DOUBLEA 64 bits floating point value (double). Example: double tmpt = 30.0; // ... TwAddVarRW(bar, "Temperature", TW_TYPE_DOUBLE, &tmpt, " precision=3 "); TW_TYPE_COLOR32
A color represented by a 32 bits integer. Order is RGBA if the graphic API is OpenGL or Direct3D10, and inversed if the graphic API is Direct3D9. R, G, B and A are respectively the Red, Green, Blue and Alpha channels. The alpha channel can be made editable by specifying Example: unsigned int color; // ... TwAddVarRW(bar, "Color", TW_TYPE_COLOR32, &color, " coloralpha=true "); TW_TYPE_COLOR3FA color represented by 3 floats in the range [0,1] and corresponding to the Red, Green and Blue color channels (in that order). Example: float submarineColor[3] = {1, 1, 0}; // yellow // ... TwAddVarRW(bar, "Submarine", TW_TYPE_COLOR3F, &submarineColor, " colormode=hls "); TW_TYPE_COLOR4FA color with transparency represented by 4 floats in the range [0,1] and corresponding to the Red, Green, Blue and Alpha channels (in that order). Example: float glassColor[4] = {0, 1, 1, 0.2f}; // transparent cyan // ... TwAddVarRW(bar, "Glass", TW_TYPE_COLOR4F, &glassColor, ""); TW_TYPE_CSSTRING(maxsize)A C-Static sized null-terminated String. Here ‘static’ means that the maximum size of the string is fixed and the string pointer is also fixed (the string memory block will not be moved).
Example: char s1[64] = "a static string"; // ... TwAddVarRW(bar, "s1", TW_TYPE_CSSTRING(sizeof(s1)), s1, ""); // here, sizeof(s1) is 64 // also works with TwAddVarRO and TwAddVarCB Note that you don’t need to pass a pointer to An example using TwAddVarCB: char s1[64] = "a static string"; // ... void TW_CALL SetMyCSStringCB(const void *value, void * /*clientData*/) { const char *src = (const char *)value; strncpy(s1, src, sizeof(s1)); s1[sizeof(s1)-1] = '\0'; // ensure that it is always null-terminated } void TW_CALL GetMyCSStringCB(void *value, void * /*clientData*/) { char *dest = (char *)value; strncpy(dest, s1, sizeof(s1)); dest[sizeof(s1)-1] = '\0'; // ensure that it is always null-terminated } // ... TwAddVarCB(bar, "s1", TW_TYPE_CSSTRING(sizeof(s1)), SetMyCSStringCB, GetMyCSStringCB, NULL, ""); TW_TYPE_CDSTRING
A C-Dynamic null-terminated String. This null-terminated string can be allocated and reallocated dynamically (eg. by calling Example: // TwCopyCDStringToClientFunc must have been called before (see explanation below) char *s2 = strdup("a string allocated dynamically"); // ... TwAddVarRW(bar, "s2", TW_TYPE_CDSTRING, &s2, ""); // also works with TwAddVarRO and TwAddVarCB // ... free(s2); Note that you should pass a pointer to the pointer In order to correctly handle memory allocations between your client application and the AntTweakBar library, you must also provide a function that will be called by AntTweakBar to copy the content of a C-Dynamic String. If this function is not provided, the variable will remain read-only. See TwCopyCDStringToClientFunc for more details.
In the other way, if your application needs to copy a C-Dynamic String to AntTweakBar (for instance if you use callbacks to handle the variable via TwAddVarCB), use the function TwCopyCDStringToLibrary. See TwCopyCDStringToLibrary for an example of how to use See also this recap of how to handle the different string variable types. TW_TYPE_STDSTRING
A C++ String. It corresponds to an object of type Example: // TwCopyStdStringToClientFunc must have been called before (see explanation below) std::string s3 = "a STL string"; // ... TwAddVarRW(bar, "s3", TW_TYPE_STDSTRING, &s3, ""); // also works with TwAddVarRO and TwAddVarCB
In order to correctly handle memory allocations between your client application and the AntTweakBar library, you must also provide a function that will be called by AntTweakBar to copy the content of a
In the other way, if your application needs to copy a See also this recap of how to handle the different string variable types. TW_TYPE_QUAT4FTW_TYPE_QUAT4DA rotation represented by a unit quaternion coded with 4 floats or 4 doubles.
See the following page for a description of quaternions:
Quaternion values are stored in the following order: Example: float quat[4] = {0, 0, 0, 1}; // null rotation // ... TwAddVarRW(bar, "Rotation", TW_TYPE_QUAT4F, &quat, ""); See example TwSimpleGLUT for a more complete use of quaternions and directions. TW_TYPE_DIR3FTW_TYPE_DIR3DA direction represented by a 3D vector coded with 3 floats or 3 doubles. Example: double dir[3] = {1, 1, 0}; // direction pointing to +x and +y // ... TwAddVarRW(bar, "LightDir", TW_TYPE_DIR3D, &dir, ""); See example TwSimpleGLUT for a more complete use of quaternions and directions. See alsoTwAddVarRW, TwAddVarRO, TwAddVarCB, TwDefineEnum, TwDefineStruct, string var examples, TwCopyCDStringToClientFunc, TwCopyStdStringToClientFunc, TwCopyStdStringToLibrary, Defintion string |