00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #if !defined TW_INCLUDED
00022 #define TW_INCLUDED
00023
00024 #include <stddef.h>
00025
00026 #define TW_VERSION 112 // Version Mmm : M=Major mm=minor (e.g., 102 is version 1.02)
00027
00028
00029 #ifdef __cplusplus
00030 # if defined(_MSC_VER)
00031 # pragma warning(push)
00032 # pragma warning(disable: 4995 4530)
00033 # include <string>
00034 # pragma warning(pop)
00035 # else
00036 # include <string>
00037 # endif
00038 extern "C" {
00039 #endif // __cplusplus
00040
00041
00042
00043
00044
00045
00046 #if defined(_WIN32) || defined(_WIN64)
00047 # define TW_CALL __stdcall
00048 # define TW_EXPORT_API __declspec(dllexport)
00049 # define TW_IMPORT_API __declspec(dllimport)
00050 #else
00051 # define TW_CALL
00052 # define TW_EXPORT_API
00053 # define TW_IMPORT_API
00054 #endif
00055
00056 #if defined TW_EXPORTS
00057 # define TW_API TW_EXPORT_API
00058 #elif defined TW_STATIC
00059 # define TW_API
00060 # if defined(_MSC_VER) && !defined(TW_NO_LIB_PRAGMA)
00061 # pragma comment(lib, "AntTweakBarStatic")
00062 # endif
00063 #else
00064 # define TW_API TW_IMPORT_API
00065 # if defined(_MSC_VER) && !defined(TW_NO_LIB_PRAGMA)
00066 # pragma comment(lib, "AntTweakBar")
00067 # endif
00068 #endif
00069
00070
00071
00072
00073
00074
00075 typedef struct CTwBar TwBar;
00076
00077 TW_API TwBar * TW_CALL TwNewBar(const char *name);
00078 TW_API int TW_CALL TwDeleteBar(TwBar *bar);
00079 TW_API int TW_CALL TwDeleteAllBars();
00080 TW_API int TW_CALL TwSetTopBar(const TwBar *bar);
00081 TW_API TwBar * TW_CALL TwGetTopBar();
00082 TW_API int TW_CALL TwSetBottomBar(const TwBar *bar);
00083 TW_API TwBar * TW_CALL TwGetBottomBar();
00084 TW_API const char * TW_CALL TwGetBarName(TwBar *bar);
00085
00086
00087
00088
00089
00090
00091 typedef enum ETwType
00092 {
00093 TW_TYPE_UNDEF = 0,
00094 #ifdef __cplusplus
00095 TW_TYPE_BOOLCPP = 1,
00096 #endif // __cplusplus
00097 TW_TYPE_BOOL8 = 2,
00098 TW_TYPE_BOOL16,
00099 TW_TYPE_BOOL32,
00100 TW_TYPE_CHAR,
00101 TW_TYPE_INT8,
00102 TW_TYPE_UINT8,
00103 TW_TYPE_INT16,
00104 TW_TYPE_UINT16,
00105 TW_TYPE_INT32,
00106 TW_TYPE_UINT32,
00107 TW_TYPE_FLOAT,
00108 TW_TYPE_DOUBLE,
00109 TW_TYPE_COLOR32,
00110 TW_TYPE_COLOR3F,
00111 TW_TYPE_COLOR4F,
00112 TW_TYPE_CDSTRING,
00113 #ifdef __cplusplus
00114 TW_TYPE_STDSTRING,
00115 #endif // __cplusplus
00116 TW_TYPE_QUAT4F = TW_TYPE_CDSTRING+2,
00117 TW_TYPE_QUAT4D,
00118 TW_TYPE_DIR3F,
00119 TW_TYPE_DIR3D
00120 } TwType;
00121 #define TW_TYPE_CSSTRING(n) ((TwType)(0x30000000+((n)&0xfffffff))) // Null-terminated C Static String of size n (defined as char[n], with n<2^28)
00122
00123 typedef void (TW_CALL * TwSetVarCallback)(const void *value, void *clientData);
00124 typedef void (TW_CALL * TwGetVarCallback)(void *value, void *clientData);
00125 typedef void (TW_CALL * TwButtonCallback)(void *clientData);
00126
00127 TW_API int TW_CALL TwAddVarRW(TwBar *bar, const char *name, TwType type, void *var, const char *def);
00128 TW_API int TW_CALL TwAddVarRO(TwBar *bar, const char *name, TwType type, const void *var, const char *def);
00129 TW_API int TW_CALL TwAddVarCB(TwBar *bar, const char *name, TwType type, TwSetVarCallback setCallback, TwGetVarCallback getCallback, void *clientData, const char *def);
00130 TW_API int TW_CALL TwAddButton(TwBar *bar, const char *name, TwButtonCallback callback, void *clientData, const char *def);
00131 TW_API int TW_CALL TwAddSeparator(TwBar *bar, const char *name, const char *def);
00132 TW_API int TW_CALL TwRemoveVar(TwBar *bar, const char *name);
00133 TW_API int TW_CALL TwRemoveAllVars(TwBar *bar);
00134
00135 typedef struct CTwEnumVal
00136 {
00137 int Value;
00138 const char * Label;
00139 } TwEnumVal;
00140 typedef struct CTwStructMember
00141 {
00142 const char * Name;
00143 TwType Type;
00144 size_t Offset;
00145 const char * DefString;
00146 } TwStructMember;
00147 typedef void (TW_CALL * TwSummaryCallback)(char *summaryString, size_t summaryMaxLength, const void *value, void *clientData);
00148
00149 TW_API int TW_CALL TwDefine(const char *def);
00150 TW_API TwType TW_CALL TwDefineEnum(const char *name, const TwEnumVal *enumValues, unsigned int nbValues);
00151 TW_API TwType TW_CALL TwDefineStruct(const char *name, const TwStructMember *structMembers, unsigned int nbMembers, size_t structSize, TwSummaryCallback summaryCallback, void *summaryClientData);
00152
00153 typedef void (TW_CALL * TwCopyCDStringToClient)(char **destinationClientStringPtr, const char *sourceString);
00154 TW_API void TW_CALL TwCopyCDStringToClientFunc(TwCopyCDStringToClient copyCDStringFunc);
00155 TW_API void TW_CALL TwCopyCDStringToLibrary(char **destinationLibraryStringPtr, const char *sourceClientString);
00156 #ifdef __cplusplus
00157 typedef void (TW_CALL * TwCopyStdStringToClient)(std::string& destinationClientString, const std::string& sourceString);
00158 TW_API void TW_CALL TwCopyStdStringToClientFunc(TwCopyStdStringToClient copyStdStringToClientFunc);
00159 TW_API void TW_CALL TwCopyStdStringToLibrary(std::string& destinationLibraryString, const std::string& sourceClientString);
00160 #endif // __cplusplus
00161
00162
00163
00164
00165
00166
00167 typedef enum ETwGraphAPI
00168 {
00169 TW_OPENGL = 1,
00170 TW_DIRECT3D9 = 2,
00171 TW_DIRECT3D10 = 3
00172 } TwGraphAPI;
00173
00174 TW_API int TW_CALL TwInit(TwGraphAPI graphAPI, void *device);
00175 TW_API int TW_CALL TwTerminate();
00176
00177 TW_API int TW_CALL TwDraw();
00178 TW_API int TW_CALL TwWindowSize(int width, int height);
00179
00180 typedef enum ETwKeyModifier
00181 {
00182 TW_KMOD_NONE = 0x0000,
00183 TW_KMOD_SHIFT = 0x0003,
00184 TW_KMOD_CTRL = 0x00c0,
00185 TW_KMOD_ALT = 0x0100,
00186 TW_KMOD_META = 0x0c00
00187 } TwKeyModifier;
00188 typedef enum EKeySpecial
00189 {
00190 TW_KEY_BACKSPACE = '\b',
00191 TW_KEY_TAB = '\t',
00192 TW_KEY_CLEAR = 0x0c,
00193 TW_KEY_RETURN = '\r',
00194 TW_KEY_PAUSE = 0x13,
00195 TW_KEY_ESCAPE = 0x1b,
00196 TW_KEY_SPACE = ' ',
00197 TW_KEY_DELETE = 0x7f,
00198 TW_KEY_UP = 273,
00199 TW_KEY_DOWN,
00200 TW_KEY_RIGHT,
00201 TW_KEY_LEFT,
00202 TW_KEY_INSERT,
00203 TW_KEY_HOME,
00204 TW_KEY_END,
00205 TW_KEY_PAGE_UP,
00206 TW_KEY_PAGE_DOWN,
00207 TW_KEY_F1,
00208 TW_KEY_F2,
00209 TW_KEY_F3,
00210 TW_KEY_F4,
00211 TW_KEY_F5,
00212 TW_KEY_F6,
00213 TW_KEY_F7,
00214 TW_KEY_F8,
00215 TW_KEY_F9,
00216 TW_KEY_F10,
00217 TW_KEY_F11,
00218 TW_KEY_F12,
00219 TW_KEY_F13,
00220 TW_KEY_F14,
00221 TW_KEY_F15,
00222 TW_KEY_LAST
00223 } TwKeySpecial;
00224
00225 TW_API int TW_CALL TwKeyPressed(int key, int modifiers);
00226
00227 typedef enum ETwMouseAction
00228 {
00229 TW_MOUSE_RELEASED,
00230 TW_MOUSE_PRESSED
00231 } TwMouseAction;
00232 typedef enum ETwMouseButtonID
00233 {
00234 TW_MOUSE_LEFT = 1,
00235 TW_MOUSE_MIDDLE = 2,
00236 TW_MOUSE_RIGHT = 3
00237 } TwMouseButtonID;
00238
00239 TW_API int TW_CALL TwMouseButton(TwMouseAction action, TwMouseButtonID button);
00240 TW_API int TW_CALL TwMouseMotion(int mouseX, int mouseY);
00241 TW_API int TW_CALL TwMouseWheel(int pos);
00242
00243 TW_API const char * TW_CALL TwGetLastError();
00244 typedef void (TW_CALL * TwErrorHandler)(const char *errorMessage);
00245 TW_API void TW_CALL TwHandleErrors(TwErrorHandler errorHandler);
00246
00247
00248
00249
00250
00251
00252
00253
00254
00255
00256 #ifndef _W64 // Microsoft specific (detection of 64 bits portability problems)
00257 # define _W64
00258 #endif // _W64
00259 TW_API int TW_CALL TwEventWin(void *wnd, unsigned int msg, unsigned int _W64 wParam, int _W64 lParam);
00260 #define TwEventWin32 TwEventWin // For compatibility with AntTweakBar versions prior to 1.11
00261
00262
00263 TW_API int TW_CALL TwEventSDL(const void *sdlEvent);
00264
00265
00266 TW_API int TW_CALL TwEventMouseButtonGLFW(int glfwButton, int glfwAction);
00267 TW_API int TW_CALL TwEventKeyGLFW(int glfwKey, int glfwAction);
00268 TW_API int TW_CALL TwEventCharGLFW(int glfwChar, int glfwAction);
00269 #define TwEventMousePosGLFW TwMouseMotion
00270 #define TwEventMouseWheelGLFW TwMouseWheel
00271
00272
00273 #if defined(_WIN32) || defined(_WIN64)
00274 # define TW_GLUT_CALL __cdecl
00275 #else
00276 # define TW_GLUT_CALL
00277 #endif
00278 TW_API int TW_GLUT_CALL TwEventMouseButtonGLUT(int glutButton, int glutState, int mouseX, int mouseY);
00279 TW_API int TW_GLUT_CALL TwEventMouseMotionGLUT(int mouseX, int mouseY);
00280 TW_API int TW_GLUT_CALL TwEventKeyboardGLUT(unsigned char glutKey, int mouseX, int mouseY);
00281 TW_API int TW_GLUT_CALL TwEventSpecialGLUT(int glutKey, int mouseX, int mouseY);
00282 TW_API int TW_CALL TwGLUTModifiersFunc(int (TW_CALL *glutGetModifiersFunc)(void));
00283 typedef void (TW_GLUT_CALL *GLUTmousebuttonfun)(int glutButton, int glutState, int mouseX, int mouseY);
00284 typedef void (TW_GLUT_CALL *GLUTmousemotionfun)(int mouseX, int mouseY);
00285 typedef void (TW_GLUT_CALL *GLUTkeyboardfun)(unsigned char glutKey, int mouseX, int mouseY);
00286 typedef void (TW_GLUT_CALL *GLUTspecialfun)(int glutKey, int mouseX, int mouseY);
00287
00288
00289
00290
00291
00292
00293 #define TW_COMPILE_TIME_ASSERT(name, x) typedef int TW_DUMMY_ ## name[(x) * 2 - 1]
00294
00295 TW_COMPILE_TIME_ASSERT(CHAR, sizeof(char) == 1);
00296 TW_COMPILE_TIME_ASSERT(SHORT, sizeof(short) == 2);
00297 TW_COMPILE_TIME_ASSERT(INT, sizeof(int) == 4);
00298 TW_COMPILE_TIME_ASSERT(FLOAT, sizeof(float) == 4);
00299 TW_COMPILE_TIME_ASSERT(DOUBLE, sizeof(double) == 8);
00300
00301
00302
00303
00304
00305 #ifdef __cplusplus
00306 }
00307 #endif // __cplusplus
00308
00309
00310 #endif // !defined TW_INCLUDED