# Upgrading to Version 2

## Contents

- Widget callback changes
- Widget subcommand changes
- Stereo changes
- Font API changes

Internally, Togl version 2 isn't very different from version 1, and much of the C interface is the same. The main difference is that the focus of the Togl API has changed from being a C API to being a Tcl API. Which means that the full power of Togl is accessible from Tcl (the few exceptions are considered bugs).

## Widget callback changes

The biggest change is how the various callback are initialized. In version 1, the C API Togl_Set*Func functions had to be used to setup the callback functions before creating the Togl widget. And once the callbacks were set for a particular Togl widget, they could not be changed. If more than once Togl widget was needed, the callback functions would need to be reset before each widget creation. In version 2, the callbacks are configuration arguments to the widget and can be updated like any other standard widget configuration option. See the Tcl API for details.

## Widget subcommand changes

Version 1 also allowed new subcommands to be added to the togl widget command via the C API. This was dropped for a variety of reasons: there is no exact Tcl equivalent, there is no standard object-oriented technique currently in the Tcl core (8.4.13), it is unclear how to make the API thread safe, and the internal Tcl C API doesn't support dynamically changing sets of subcommands. That said, this functionality might come back, especially when TIP #257 is implemented. Instead, in version 2, create a Tcl function that takes the Togl widget as an argument. Functions written in C can get the underlying Togl structure handle with either the `Togl_GetToglFromObj` or the `Togl_GetToglFromName` function, as appropriate. This means that there are no special Togl commands, only Tcl commands. See the C API for details.

## Stereo changes

The stereo support has been totally revamped. Some form of stereo is available all of the time.

## Font changes

Tcl support for writing strings has been added.

The font C API has been revised so that Togl_LoadBitmapFont returns a font object instead an integer (likewise for Togl_UnloadBitmapFont). So instead of calling glListBase and glCallLists directly, use Togl_WriteObj or Togl_WriteChars.

The TOGL_BITMAP_* constants remain for limited backwards source compatibility and are deprecated. The acceptable font names are now the same as Tk_GetFont and the Tk font command on all platforms.