TwInit (function)

int TwInit(TwGraphAPI graphAPI, void *device)


This function initializes the AntTweakBar library. It must be called once at the beginning of the program, just after graphic mode is initialized.


  • When program finishes, TwTerminate must be called, just before graphic mode is terminated.
  • See how to integrate AntTweakBar into your application.



This parameter specifies which graphic API is used: OpenGL, OpenGL core profile (3.2 and higher), Direct3D 9, Direct3D 10 or Direct3D 11.

It is one of the TwGraphAPI enum element. If graphAPI is Direct3D, the D3D device pointer must be supplied.


Pointer to the Direct3D device, or NULL for OpenGL.

If graphAPI is OpenGL, this parameter must be NULL, otherwise it is the IDirect3DDevice9, ID3D10Device or ID3D11Device pointer returned by the appropriate D3D CreateDevice function when D3D has been initialized.

Return values

  • 0 if an error has occurred (call TwGetLastError to retrieve the error).
  • 1 if succeeded.

See also