Togl_Init
,
Togl_InitStubs
Togl_PostRedisplay
,
Togl_SwapBuffers
,
Togl_MakeCurrent
,
Togl_SwapInterval
Togl_Ident
,
Togl_Width
,
Togl_Height
,
Togl_Interp
,
Togl_TkWin
,
Togl_GetProcAddr
,
Togl_ContextTag
Togl_UpdatePending
Togl_AllocColor
,
Togl_FreeColor
,
Togl_SetColor
Togl_LoadBitmapFont
,
Togl_UnloadBitmapFont
,
Togl_WriteObj
,
Togl_WriteChars
Togl_SetClientData
,
Togl_GetClientData
Togl_UseLayer
,
Togl_ShowOverlay
,
Togl_HideOverlay
,
Togl_PostOveralyRedisplay
,
Togl_ExistsOverlay
,
Togl_GetOverlayTransparentValue
,
Togl_IsMappedOverlay
,
Togl_AllocColorOverlay
,
Togl_FreeColorOverlay
Togl_Drawbuffer
,
Togl_Clear
Togl_Frustum
Togl_Ortho
Togl_NumEyes
Togl_TakePhoto
Togl_GetToglFromObj
,
Togl_GetToglFromName
All Togl functions are found in the Togl header file.
#include "togl.h"
For portability, you should include the togl.h
header
before any other OpenGL headers
so it will compile on Microsoft Windows.
Before calling any Togl functions, you need to initialize it.
Regardless if you're using stubs (by defining USE_TOGL_STUBS
)
or not, the following code will properly initialize togl:
if (Tcl_InitStubs(interp, "8.1", 0) == NULL || Togl_InitStubs(interp, "2.0", 0) == NULL) { /* fail */ }
If you are using a prebuilt binary distribution,
you should be sure to define USE_TOGL_STUBS
beforehand.
See the source for the demo programs in the Togl source distribution for working examples.
If you are using a prebuilt binary,
be sure to link against the stub library.
On Microsoft Windows,
link against Toglstub20.lib opengl32.lib user32.lib gdi32.lib
,
on Apple Mac OS X,
link against -lToglstub2.0 -framework OpenGL
,
on other platforms,
link against -lToglstub2.0 -lGLU -lGL -lm
.
If building your own Togl package,
you can use the stubs interface or link in the Tcl and Tk libraries as well.
If using the stubs interface, link as shown above.
Otherwise:
on Microsoft Windows,
link against Togl20.lib tk84.lib tcl84.lib opengl32.lib user32.lib gdi32.lib
,
on Apple Mac OS X,
link against -lTogl2.0 -framework Tk -framework Tcl -framework OpenGL
,
on other platforms,
link against -lTogl2.0 -ltk8.4 -ltcl8.4 -lGLU -lGL -lm
.
int Togl_Init(Tcl_Interp *interp)
package require Togl
command.
const char *Togl_InitStubs(Tcl_Interp *interp, const char *version, int exact)
interp
reter
and initializes it.
version
should be "2.0"
or higher.
This is typically called from C/C++ code that accesses Togl's C API
and has installed Togl into the standard TCL hierarchy.
See the Tcl InitStubs(3) or the Tk TkInitStubs(3) manual pages for
more information.
void Togl_PostRedisplay(Togl *togl)
displaycommand
callback will be invoked.
void Togl_SwapBuffers(const Togl *togl)
displaycommand
callback function.
void Togl_MakeCurrent(const Togl *togl)
Bool Togl_SwapInterval(const Togl *togl, int interval)
char *Togl_Ident(const Togl *togl)
int Togl_Width(const Togl *togl)
reshapecommand
callback function.
int Togl_Height(const Togl *togl)
reshapecommand
callback function.
Tcl_Interp *Togl_Interp(const Togl *togl)
Tk_Window Togl_TkWin(const Togl *togl)
Togl_FuncPtr Togl_GetProcAddr(const char *funcname)
int Togl_ContextTag(const Togl *t)
Bool Togl_UpdatePending(const Togl *t)
These functions are only used for color index mode.
unsigned long Togl_AllocColor(Togl *togl, float red, float green, float blue)
-privatecmap
option is false.
void Togl_FreeColor(Togl *togl, unsigned long index)
-privatecmap
option
is false.
void Togl_SetColor(Togl *togl,
int index, float red, float green, float blue)
-privatecmap
option is true.
These functions provide an interface to the simple bitmap font capabilities that every OpenGL implementation provides. Better font support is found in other C APIs, e.g., QuesoGLC or FTGL.
GLuint Togl_LoadBitmapFont(Togl *togl,
const char *fontname)
glListBase(fontbase);
glCallLists(strlen(s), GL_BYTE, s);
Zero is returned if this function fails.
int Togl_UnloadBitmapFont(Togl *togl, Tcl_Obj *toglfont)
int Togl_WriteChars(const Togl *togl, const Tcl_Obj *toglfont, const char *str, int len)
int Togl_WriteObj(const Togl *togl, const Tcl_Obj *toglfont, Tcl_Obj *obj)
Tcl_WriteChars
.
void Togl_SetClientData(Togl *togl, ClientData clientData)
ClientData Togl_GetClientData(const Togl *togl)
These functions are modelled after GLUT's overlay sub-API.
void Togl_UseLayer(Togl *togl, int layer)
void Togl_ShowOverlay(Togl *togl)
void Togl_HideOverlay(Togl *togl)
void Togl_PostOverlayRedisplay(Togl *togl)
overlaydisplaycommand
callback will be invoked.
int Togl_ExistsOverlay(Togl *togl)
int Togl_GetOverlayTransparentValue(const Togl *togl)
int Togl_IsMappedOverlay(const Togl *togl)
unsigned long Togl_AllocColorOverlay(const Togl *togl,
float red, float green, float blue)
void Togl_FreeColorOverlay(const Togl *togl, unsigned long index)
Togl abstracts part of the stereo drawing process to seamlessly support quad-buffered stereo as well as various alternative stereo formats.
void Togl_DrawBuffer(Togl *togl, GLenum mode)
void Togl_Clear(const Togl *togl, GLbitfield mask)
void Togl_Frustum(const Togl *togl, GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat near, GLfloat far)
void Togl_Ortho(const Togl *togl, GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat near, GLfloat far)
int Togl_NumEyes(const Togl *togl)
This code works for quad-buffered stereo, as well as the other stereo modes.
if (Togl_NumEyes(togl) == 1) { Togl_DrawBuffer(togl, GL_BACK); Togl_Clear(togl); glMatrixMode(GL_PROJECTION); glLoadIdentity(); Togl_Frustum(togl, left, right, bottom, top, near, far); glMatrixMode(GL_MODELVIEW); draw image } else { Togl_DrawBuffer(togl, GL_BACK_LEFT); Togl_Clear(togl); glMatrixMode(GL_PROJECTION); glLoadIdentity(); Togl_Frustum(togl, left, right, bottom, top, near, far); glMatrixMode(GL_MODELVIEW); draw left-eye image Togl_DrawBuffer(togl, GL_BACK_RIGHT); Togl_Clear(togl); glMatrixMode(GL_PROJECTION); glLoadIdentity(); Togl_Frustum(togl, left, right, bottom, top, near, far); glMatrixMode(GL_MODELVIEW); draw right-eye image } Togl_SwapBuffers(togl);
int Togl_TakePhoto(Togl *togl, Tk_PhotoHandle photo)
photo
object.
If the window is partially obscured,
either by other windows or by the edges of the display,
the results are undefined in the obscured region.
These functions aid the programmer when writing Togl callback functions.
int Togl_GetToglFromObj(Tcl_Interp *interp, Tcl_Obj *obj, Togl **toglPtr)
int Togl_GetToglFromName(Tcl_Interp *interp, const char *cmdName, Togl **toglPtr)