[GRASS-SVN] r32533 -
grass/branches/develbranch_6/visualization/nviz/src
svn_grass at osgeo.org
svn_grass at osgeo.org
Tue Aug 5 01:17:18 EDT 2008
Author: neteler
Date: 2008-08-05 01:17:18 -0400 (Tue, 05 Aug 2008)
New Revision: 32533
Modified:
grass/branches/develbranch_6/visualization/nviz/src/togl.c
grass/branches/develbranch_6/visualization/nviz/src/togl.h
Log:
restored original files from last source snapshot as not our files
Modified: grass/branches/develbranch_6/visualization/nviz/src/togl.c
===================================================================
--- grass/branches/develbranch_6/visualization/nviz/src/togl.c 2008-08-05 05:14:48 UTC (rev 32532)
+++ grass/branches/develbranch_6/visualization/nviz/src/togl.c 2008-08-05 05:17:18 UTC (rev 32533)
@@ -31,11 +31,11 @@
#elif defined(TOGL_X11)
# include <X11/Xlib.h>
# include <X11/Xutil.h>
-# include <X11/Xatom.h> /* for XA_RGB_DEFAULT_MAP atom */
+# include <X11/Xatom.h> /* for XA_RGB_DEFAULT_MAP atom */
# if defined(__vms)
-# include <X11/StdCmap.h> /* for XmuLookupStandardColormap */
+# include <X11/StdCmap.h> /* for XmuLookupStandardColormap */
# else
-# include <X11/Xmu/StdCmap.h> /* for XmuLookupStandardColormap */
+# include <X11/Xmu/StdCmap.h> /* for XmuLookupStandardColormap */
# endif
# include <GL/glx.h>
@@ -51,7 +51,7 @@
# include <AGL/agl.h>
# undef Cursor
# include "tkMacOSX.h"
-# include <tkMacOSXInt.h> /* usa MacDrawable */
+# include <tkMacOSXInt.h> /* usa MacDrawable */
# include <ApplicationServices/ApplicationServices.h>
#else /* make sure only one platform defined */
@@ -93,7 +93,7 @@
/* pointer to Tk_SetClassProcs function in the stub table */
static void (*SetClassProcsPtr)
-_ANSI_ARGS_((Tk_Window, Tk_ClassProcs *, ClientData));
+ _ANSI_ARGS_((Tk_Window, Tk_ClassProcs *, ClientData));
#endif
/*
@@ -101,19 +101,17 @@
* (this is needed for Tcl ver =< 8.4a3)
*/
-typedef Window(TkClassCreateProc) _ANSI_ARGS_((Tk_Window tkwin,
- Window parent,
- ClientData instanceData));
- typedef void (TkClassGeometryProc)
- _ANSI_ARGS_((ClientData instanceData));
- typedef void (TkClassModalProc)
- _ANSI_ARGS_((Tk_Window tkwin, XEvent * eventPtr));
- typedef struct TkClassProcs
- {
- TkClassCreateProc *createProc;
- TkClassGeometryProc *geometryProc;
- TkClassModalProc *modalProc;
- } TkClassProcs;
+typedef Window (TkClassCreateProc) _ANSI_ARGS_((Tk_Window tkwin,
+ Window parent, ClientData instanceData));
+typedef void (TkClassGeometryProc) _ANSI_ARGS_((ClientData instanceData));
+typedef void (TkClassModalProc) _ANSI_ARGS_((Tk_Window tkwin,
+ XEvent *eventPtr));
+typedef struct TkClassProcs
+{
+ TkClassCreateProc *createProc;
+ TkClassGeometryProc *geometryProc;
+ TkClassModalProc *modalProc;
+} TkClassProcs;
/* Defaults */
@@ -133,20 +131,19 @@
* copy of TkWinColormap from tkWinInt.h
*/
- typedef struct
- {
- HPALETTE palette; /* Palette handle used when drawing. */
- UINT size; /* Number of entries in the palette. */
- int stale; /* 1 if palette needs to be realized, otherwise
- * 0. If the palette is stale, then an idle
- * handler is scheduled to realize the palette. */
- Tcl_HashTable refCounts; /* Hash table of palette entry reference counts
- * indexed by pixel value. */
- } TkWinColormap;
+typedef struct
+{
+ HPALETTE palette; /* Palette handle used when drawing. */
+ UINT size; /* Number of entries in the palette. */
+ int stale; /* 1 if palette needs to be realized, otherwise
+ * 0. If the palette is stale, then an idle
+ * handler is scheduled to realize the palette. */
+ Tcl_HashTable refCounts; /* Hash table of palette entry reference counts
+ * indexed by pixel value. */
+} TkWinColormap;
- static LRESULT(CALLBACK * tkWinChildProc) (HWND hwnd, UINT message,
- WPARAM wParam,
- LPARAM lParam) = NULL;
+static LRESULT(CALLBACK *tkWinChildProc) (HWND hwnd, UINT message,
+ WPARAM wParam, LPARAM lParam) = NULL;
# define TK_WIN_CHILD_CLASS_NAME "TkChild"
@@ -180,129 +177,127 @@
PropertyChangeMask | \
ColormapChangeMask)
- struct Togl
- {
- Togl *Next; /* next in linked list */
+struct Togl
+{
+ Togl *Next; /* next in linked list */
#if defined(TOGL_WGL)
- HDC tglGLHdc; /* Device context of device that OpenGL calls
- * will be drawn on */
- HGLRC tglGLHglrc; /* OpenGL rendering context to be made current */
- int CiColormapSize; /* (Maximum) size of colormap in color index
- * mode */
+ HDC tglGLHdc; /* Device context of device that OpenGL calls
+ * will be drawn on */
+ HGLRC tglGLHglrc; /* OpenGL rendering context to be made current */
+ int CiColormapSize; /* (Maximum) size of colormap in color index
+ * mode */
#elif defined(TOGL_X11)
- GLXContext GlCtx; /* Normal planes GLX context */
+ GLXContext GlCtx; /* Normal planes GLX context */
#elif defined(TOGL_AGL_CLASSIC) || defined(TOGL_AGL)
- AGLContext aglCtx;
-#endif /* TOGL_WGL */
+ AGLContext aglCtx;
+#endif /* TOGL_WGL */
- Display *display; /* X's token for the window's display. */
- Tk_Window TkWin; /* Tk window structure */
- Tcl_Interp *Interp; /* Tcl interpreter */
- Tcl_Command widgetCmd; /* Token for togl's widget command */
+ Display *display; /* X's token for the window's display. */
+ Tk_Window TkWin; /* Tk window structure */
+ Tcl_Interp *Interp; /* Tcl interpreter */
+ Tcl_Command widgetCmd; /* Token for togl's widget command */
#ifndef NO_TK_CURSOR
- Tk_Cursor Cursor; /* The widget's cursor */
+ Tk_Cursor Cursor; /* The widget's cursor */
#endif
- int Width, Height; /* Dimensions of window */
- int SetGrid; /* positive is grid size for window manager */
- int TimerInterval; /* Time interval for timer in milliseconds */
+ int Width, Height; /* Dimensions of window */
+ int SetGrid; /* positive is grid size for window manager */
+ int TimerInterval; /* Time interval for timer in milliseconds */
#if (TCL_MAJOR_VERSION * 100 + TCL_MINOR_VERSION) >= 705
- Tcl_TimerToken timerHandler; /* Token for togl's timer handler */
+ Tcl_TimerToken timerHandler; /* Token for togl's timer handler */
#else
- Tk_TimerToken timerHandler; /* Token for togl's timer handler */
+ Tk_TimerToken timerHandler; /* Token for togl's timer handler */
#endif
- Bool RgbaFlag; /* configuration flags (ala GLX parameters) */
- int RgbaRed;
- int RgbaGreen;
- int RgbaBlue;
- Bool DoubleFlag;
- Bool DepthFlag;
- int DepthSize;
- Bool AccumFlag;
- int AccumRed;
- int AccumGreen;
- int AccumBlue;
- int AccumAlpha;
- Bool AlphaFlag;
- int AlphaSize;
- Bool StencilFlag;
- int StencilSize;
- Bool PrivateCmapFlag;
- Bool OverlayFlag;
- Bool StereoFlag;
+ Bool RgbaFlag; /* configuration flags (ala GLX parameters) */
+ int RgbaRed;
+ int RgbaGreen;
+ int RgbaBlue;
+ Bool DoubleFlag;
+ Bool DepthFlag;
+ int DepthSize;
+ Bool AccumFlag;
+ int AccumRed;
+ int AccumGreen;
+ int AccumBlue;
+ int AccumAlpha;
+ Bool AlphaFlag;
+ int AlphaSize;
+ Bool StencilFlag;
+ int StencilSize;
+ Bool PrivateCmapFlag;
+ Bool OverlayFlag;
+ Bool StereoFlag;
#ifdef __sgi
- Bool OldStereoFlag;
+ Bool OldStereoFlag;
#endif
- int AuxNumber;
- Bool Indirect;
- int PixelFormat;
- const char *ShareList; /* name (ident) of Togl to share dlists with */
- const char *ShareContext; /* name (ident) to share OpenGL context with */
+ int AuxNumber;
+ Bool Indirect;
+ int PixelFormat;
+ const char *ShareList; /* name (ident) of Togl to share dlists with */
+ const char *ShareContext; /* name (ident) to share OpenGL context with */
- const char *Ident; /* User's identification string */
- ClientData Client_Data; /* Pointer to user data */
+ const char *Ident; /* User's identification string */
+ ClientData Client_Data; /* Pointer to user data */
- Bool UpdatePending; /* Should normal planes be redrawn? */
+ Bool UpdatePending; /* Should normal planes be redrawn? */
- Togl_Callback *CreateProc; /* Callback when widget is created */
- Togl_Callback *DisplayProc; /* Callback when widget is rendered */
- Togl_Callback *ReshapeProc; /* Callback when window size changes */
- Togl_Callback *DestroyProc; /* Callback when widget is destroyed */
- Togl_Callback *TimerProc; /* Callback when widget is idle */
+ Togl_Callback *CreateProc; /* Callback when widget is created */
+ Togl_Callback *DisplayProc; /* Callback when widget is rendered */
+ Togl_Callback *ReshapeProc; /* Callback when window size changes */
+ Togl_Callback *DestroyProc; /* Callback when widget is destroyed */
+ Togl_Callback *TimerProc; /* Callback when widget is idle */
- /* Overlay stuff */
+ /* Overlay stuff */
#if defined(TOGL_X11)
- GLXContext OverlayCtx; /* Overlay planes OpenGL context */
+ GLXContext OverlayCtx; /* Overlay planes OpenGL context */
#elif defined(TOGL_WGL)
- HGLRC tglGLOverlayHglrc;
-#endif /* TOGL_X11 */
+ HGLRC tglGLOverlayHglrc;
+#endif /* TOGL_X11 */
- Window OverlayWindow; /* The overlay window, or 0 */
- Togl_Callback *OverlayDisplayProc; /* Overlay redraw proc */
- Bool OverlayUpdatePending; /* Should overlay be redrawn? */
- Colormap OverlayCmap; /* colormap for overlay is created */
- int OverlayTransparentPixel; /* transparent pixel */
- Bool OverlayIsMapped;
+ Window OverlayWindow; /* The overlay window, or 0 */
+ Togl_Callback *OverlayDisplayProc; /* Overlay redraw proc */
+ Bool OverlayUpdatePending; /* Should overlay be redrawn? */
+ Colormap OverlayCmap; /* colormap for overlay is created */
+ int OverlayTransparentPixel; /* transparent pixel */
+ Bool OverlayIsMapped;
- /* for DumpToEpsFile: Added by Miguel A. de Riera Pasenau 10.01.1997 */
- XVisualInfo *VisInfo; /* Visual info of the current */
- /* context needed for DumpToEpsFile */
- GLfloat *EpsRedMap; /* Index2RGB Maps for Color index modes */
- GLfloat *EpsGreenMap;
- GLfloat *EpsBlueMap;
- GLint EpsMapSize; /* = Number of indices in our Togl */
- };
+ /* for DumpToEpsFile: Added by Miguel A. de Riera Pasenau 10.01.1997 */
+ XVisualInfo *VisInfo; /* Visual info of the current */
+ /* context needed for DumpToEpsFile */
+ GLfloat *EpsRedMap; /* Index2RGB Maps for Color index modes */
+ GLfloat *EpsGreenMap;
+ GLfloat *EpsBlueMap;
+ GLint EpsMapSize; /* = Number of indices in our Togl */
+};
/* NTNTNT need to change to handle Windows Data Types */
/*
* Prototypes for functions local to this file
*/
- static int Togl_Cmd(ClientData clientData, Tcl_Interp * interp,
- int argc, CONST84 char **argv);
- static void Togl_EventProc(ClientData clientData, XEvent * eventPtr);
- static Window Togl_CreateWindow(Tk_Window, Window, ClientData);
- static void Togl_WorldChanged(ClientData);
+static int Togl_Cmd(ClientData clientData, Tcl_Interp *interp,
+ int argc, CONST84 char **argv);
+static void Togl_EventProc(ClientData clientData, XEvent *eventPtr);
+static Window Togl_CreateWindow(Tk_Window, Window, ClientData);
+static void Togl_WorldChanged(ClientData);
#ifdef MESA_COLOR_HACK
- static int get_free_color_cells(Display * display, int screen,
- Colormap colormap);
- static void free_default_color_cells(Display * display,
- Colormap colormap);
+static int get_free_color_cells(Display *display, int screen,
+ Colormap colormap);
+static void free_default_color_cells(Display *display, Colormap colormap);
#endif
- static void ToglCmdDeletedProc(ClientData);
+static void ToglCmdDeletedProc(ClientData);
#if defined(__sgi)
/* SGI-only stereo */
- static void oldStereoMakeCurrent(Display * dpy, Window win,
- GLXContext ctx);
- static void oldStereoInit(Togl * togl, int stereoEnabled);
+static void oldStereoMakeCurrent(Display *dpy, Window win, GLXContext ctx);
+static void oldStereoInit(Togl *togl, int stereoEnabled);
#endif
#if defined(TOGL_AGL_CLASSIC) || defined(TOGL_AGL)
- static void SetMacBufRect(Togl * togl);
+static void SetMacBufRect(Togl *togl);
#endif
@@ -310,114 +305,109 @@
* Setup Togl widget configuration options:
*/
- static Tk_ConfigSpec configSpecs[] = {
- {TK_CONFIG_PIXELS, TCL_STUPID "-height", "height", "Height",
- DEFAULT_HEIGHT, Tk_Offset(Togl, Height), 0, NULL},
+static Tk_ConfigSpec configSpecs[] = {
+ {TK_CONFIG_PIXELS, TCL_STUPID "-height", "height", "Height",
+ DEFAULT_HEIGHT, Tk_Offset(Togl, Height), 0, NULL},
- {TK_CONFIG_PIXELS, TCL_STUPID "-width", "width", "Width",
- DEFAULT_WIDTH, Tk_Offset(Togl, Width), 0, NULL},
+ {TK_CONFIG_PIXELS, TCL_STUPID "-width", "width", "Width",
+ DEFAULT_WIDTH, Tk_Offset(Togl, Width), 0, NULL},
- {TK_CONFIG_INT, TCL_STUPID "-setgrid", "setGrid", "SetGrid",
- "0", Tk_Offset(Togl, SetGrid), 0},
+ {TK_CONFIG_INT, TCL_STUPID "-setgrid", "setGrid", "SetGrid",
+ "0", Tk_Offset(Togl, SetGrid), 0},
- {TK_CONFIG_BOOLEAN, TCL_STUPID "-rgba", "rgba", "Rgba",
- "true", Tk_Offset(Togl, RgbaFlag), 0, NULL},
+ {TK_CONFIG_BOOLEAN, TCL_STUPID "-rgba", "rgba", "Rgba",
+ "true", Tk_Offset(Togl, RgbaFlag), 0, NULL},
- {TK_CONFIG_INT, TCL_STUPID "-redsize", "redsize", "RedSize",
- "1", Tk_Offset(Togl, RgbaRed), 0, NULL},
+ {TK_CONFIG_INT, TCL_STUPID "-redsize", "redsize", "RedSize",
+ "1", Tk_Offset(Togl, RgbaRed), 0, NULL},
- {TK_CONFIG_INT, TCL_STUPID "-greensize", "greensize", "GreenSize",
- "1", Tk_Offset(Togl, RgbaGreen), 0, NULL},
+ {TK_CONFIG_INT, TCL_STUPID "-greensize", "greensize", "GreenSize",
+ "1", Tk_Offset(Togl, RgbaGreen), 0, NULL},
- {TK_CONFIG_INT, TCL_STUPID "-bluesize", "bluesize", "BlueSize",
- "1", Tk_Offset(Togl, RgbaBlue), 0, NULL},
+ {TK_CONFIG_INT, TCL_STUPID "-bluesize", "bluesize", "BlueSize",
+ "1", Tk_Offset(Togl, RgbaBlue), 0, NULL},
- {TK_CONFIG_BOOLEAN, TCL_STUPID "-double", "double", "Double",
- "false", Tk_Offset(Togl, DoubleFlag), 0, NULL},
+ {TK_CONFIG_BOOLEAN, TCL_STUPID "-double", "double", "Double",
+ "false", Tk_Offset(Togl, DoubleFlag), 0, NULL},
- {TK_CONFIG_BOOLEAN, TCL_STUPID "-depth", "depth", "Depth",
- "false", Tk_Offset(Togl, DepthFlag), 0, NULL},
+ {TK_CONFIG_BOOLEAN, TCL_STUPID "-depth", "depth", "Depth",
+ "false", Tk_Offset(Togl, DepthFlag), 0, NULL},
- {TK_CONFIG_INT, TCL_STUPID "-depthsize", "depthsize", "DepthSize",
- "1", Tk_Offset(Togl, DepthSize), 0, NULL},
+ {TK_CONFIG_INT, TCL_STUPID "-depthsize", "depthsize", "DepthSize",
+ "1", Tk_Offset(Togl, DepthSize), 0, NULL},
- {TK_CONFIG_BOOLEAN, TCL_STUPID "-accum", "accum", "Accum",
- "false", Tk_Offset(Togl, AccumFlag), 0, NULL},
+ {TK_CONFIG_BOOLEAN, TCL_STUPID "-accum", "accum", "Accum",
+ "false", Tk_Offset(Togl, AccumFlag), 0, NULL},
- {TK_CONFIG_INT, TCL_STUPID "-accumredsize", "accumredsize",
- "AccumRedSize",
- "1", Tk_Offset(Togl, AccumRed), 0, NULL},
+ {TK_CONFIG_INT, TCL_STUPID "-accumredsize", "accumredsize", "AccumRedSize",
+ "1", Tk_Offset(Togl, AccumRed), 0, NULL},
- {TK_CONFIG_INT, TCL_STUPID "-accumgreensize", "accumgreensize",
- "AccumGreenSize",
- "1", Tk_Offset(Togl, AccumGreen), 0, NULL},
+ {TK_CONFIG_INT, TCL_STUPID "-accumgreensize", "accumgreensize",
+ "AccumGreenSize",
+ "1", Tk_Offset(Togl, AccumGreen), 0, NULL},
- {TK_CONFIG_INT, TCL_STUPID "-accumbluesize", "accumbluesize",
- "AccumBlueSize",
- "1", Tk_Offset(Togl, AccumBlue), 0, NULL},
+ {TK_CONFIG_INT, TCL_STUPID "-accumbluesize", "accumbluesize",
+ "AccumBlueSize",
+ "1", Tk_Offset(Togl, AccumBlue), 0, NULL},
- {TK_CONFIG_INT, TCL_STUPID "-accumalphasize", "accumalphasize",
- "AccumAlphaSize",
- "1", Tk_Offset(Togl, AccumAlpha), 0, NULL},
+ {TK_CONFIG_INT, TCL_STUPID "-accumalphasize", "accumalphasize",
+ "AccumAlphaSize",
+ "1", Tk_Offset(Togl, AccumAlpha), 0, NULL},
- {TK_CONFIG_BOOLEAN, TCL_STUPID "-alpha", "alpha", "Alpha",
- "false", Tk_Offset(Togl, AlphaFlag), 0, NULL},
+ {TK_CONFIG_BOOLEAN, TCL_STUPID "-alpha", "alpha", "Alpha",
+ "false", Tk_Offset(Togl, AlphaFlag), 0, NULL},
- {TK_CONFIG_INT, TCL_STUPID "-alphasize", "alphasize", "AlphaSize",
- "1", Tk_Offset(Togl, AlphaSize), 0, NULL},
+ {TK_CONFIG_INT, TCL_STUPID "-alphasize", "alphasize", "AlphaSize",
+ "1", Tk_Offset(Togl, AlphaSize), 0, NULL},
- {TK_CONFIG_BOOLEAN, TCL_STUPID "-stencil", "stencil", "Stencil",
- "false", Tk_Offset(Togl, StencilFlag), 0, NULL},
+ {TK_CONFIG_BOOLEAN, TCL_STUPID "-stencil", "stencil", "Stencil",
+ "false", Tk_Offset(Togl, StencilFlag), 0, NULL},
- {TK_CONFIG_INT, TCL_STUPID "-stencilsize", "stencilsize",
- "StencilSize",
- "1", Tk_Offset(Togl, StencilSize), 0, NULL},
+ {TK_CONFIG_INT, TCL_STUPID "-stencilsize", "stencilsize", "StencilSize",
+ "1", Tk_Offset(Togl, StencilSize), 0, NULL},
- {TK_CONFIG_INT, TCL_STUPID "-auxbuffers", "auxbuffers", "AuxBuffers",
- "0", Tk_Offset(Togl, AuxNumber), 0, NULL},
+ {TK_CONFIG_INT, TCL_STUPID "-auxbuffers", "auxbuffers", "AuxBuffers",
+ "0", Tk_Offset(Togl, AuxNumber), 0, NULL},
- {TK_CONFIG_BOOLEAN, TCL_STUPID "-privatecmap", "privateCmap",
- "PrivateCmap",
- "false", Tk_Offset(Togl, PrivateCmapFlag), 0, NULL},
+ {TK_CONFIG_BOOLEAN, TCL_STUPID "-privatecmap", "privateCmap", "PrivateCmap",
+ "false", Tk_Offset(Togl, PrivateCmapFlag), 0, NULL},
- {TK_CONFIG_BOOLEAN, TCL_STUPID "-overlay", "overlay", "Overlay",
- "false", Tk_Offset(Togl, OverlayFlag), 0, NULL},
+ {TK_CONFIG_BOOLEAN, TCL_STUPID "-overlay", "overlay", "Overlay",
+ "false", Tk_Offset(Togl, OverlayFlag), 0, NULL},
- {TK_CONFIG_BOOLEAN, TCL_STUPID "-stereo", "stereo", "Stereo",
- "false", Tk_Offset(Togl, StereoFlag), 0, NULL},
+ {TK_CONFIG_BOOLEAN, TCL_STUPID "-stereo", "stereo", "Stereo",
+ "false", Tk_Offset(Togl, StereoFlag), 0, NULL},
#ifdef __sgi
- {TK_CONFIG_BOOLEAN, TCL_STUPID "-oldstereo", "oldstereo",
- "OldStereo",
- "false", Tk_Offset(Togl, OldStereoFlag), 0, NULL},
+ {TK_CONFIG_BOOLEAN, TCL_STUPID "-oldstereo", "oldstereo", "OldStereo",
+ "false", Tk_Offset(Togl, OldStereoFlag), 0, NULL},
#endif
#ifndef NO_TK_CURSOR
- {TK_CONFIG_ACTIVE_CURSOR, TCL_STUPID "-cursor", "cursor", "Cursor",
- "", Tk_Offset(Togl, Cursor), TK_CONFIG_NULL_OK},
+ {TK_CONFIG_ACTIVE_CURSOR, TCL_STUPID "-cursor", "cursor", "Cursor",
+ "", Tk_Offset(Togl, Cursor), TK_CONFIG_NULL_OK},
#endif
- {TK_CONFIG_INT, TCL_STUPID "-time", "time", "Time",
- DEFAULT_TIME, Tk_Offset(Togl, TimerInterval), 0, NULL},
+ {TK_CONFIG_INT, TCL_STUPID "-time", "time", "Time",
+ DEFAULT_TIME, Tk_Offset(Togl, TimerInterval), 0, NULL},
- {TK_CONFIG_STRING, TCL_STUPID "-sharelist", "sharelist", "ShareList",
- NULL, Tk_Offset(Togl, ShareList), 0, NULL},
+ {TK_CONFIG_STRING, TCL_STUPID "-sharelist", "sharelist", "ShareList",
+ NULL, Tk_Offset(Togl, ShareList), 0, NULL},
- {TK_CONFIG_STRING, TCL_STUPID "-sharecontext", "sharecontext",
- "ShareContext", NULL, Tk_Offset(Togl, ShareContext), 0, NULL},
+ {TK_CONFIG_STRING, TCL_STUPID "-sharecontext", "sharecontext",
+ "ShareContext", NULL, Tk_Offset(Togl, ShareContext), 0, NULL},
- {TK_CONFIG_STRING, TCL_STUPID "-ident", "ident", "Ident",
- DEFAULT_IDENT, Tk_Offset(Togl, Ident), 0, NULL},
+ {TK_CONFIG_STRING, TCL_STUPID "-ident", "ident", "Ident",
+ DEFAULT_IDENT, Tk_Offset(Togl, Ident), 0, NULL},
- {TK_CONFIG_BOOLEAN, TCL_STUPID "-indirect", "indirect", "Indirect",
- "false", Tk_Offset(Togl, Indirect), 0, NULL},
+ {TK_CONFIG_BOOLEAN, TCL_STUPID "-indirect", "indirect", "Indirect",
+ "false", Tk_Offset(Togl, Indirect), 0, NULL},
- {TK_CONFIG_INT, TCL_STUPID "-pixelformat", "pixelFormat",
- "PixelFormat",
- "0", Tk_Offset(Togl, PixelFormat), 0, NULL},
+ {TK_CONFIG_INT, TCL_STUPID "-pixelformat", "pixelFormat", "PixelFormat",
+ "0", Tk_Offset(Togl, PixelFormat), 0, NULL},
- {TK_CONFIG_END, NULL, NULL, NULL, NULL, 0, 0, NULL}
- };
+ {TK_CONFIG_END, NULL, NULL, NULL, NULL, 0, 0, NULL}
+};
/*
@@ -441,7 +431,8 @@
/*
* Add given togl widget to linked list.
*/
-static void AddToList(Togl * t)
+static void
+AddToList(Togl *t)
{
t->Next = ToglHead;
ToglHead = t;
@@ -450,37 +441,38 @@
/*
* Remove given togl widget from linked list.
*/
-static void RemoveFromList(Togl * t)
+static void
+RemoveFromList(Togl *t)
{
- Togl *prev = NULL;
- Togl *pos = ToglHead;
+ Togl *prev = NULL;
+ Togl *pos = ToglHead;
while (pos) {
- if (pos == t) {
- if (prev) {
- prev->Next = pos->Next;
- }
- else {
- ToglHead = pos->Next;
- }
- return;
- }
- prev = pos;
- pos = pos->Next;
+ if (pos == t) {
+ if (prev) {
+ prev->Next = pos->Next;
+ } else {
+ ToglHead = pos->Next;
+ }
+ return;
+ }
+ prev = pos;
+ pos = pos->Next;
}
}
/*
* Return pointer to togl widget given a user identifier string.
*/
-static Togl *FindTogl(const char *ident)
+static Togl *
+FindTogl(const char *ident)
{
- Togl *t = ToglHead;
+ Togl *t = ToglHead;
while (t) {
- if (strcmp(t->Ident, ident) == 0)
- return t;
- t = t->Next;
+ if (strcmp(t->Ident, ident) == 0)
+ return t;
+ t = t->Next;
}
return NULL;
}
@@ -490,21 +482,22 @@
/*
* Return pointer to another togl widget with same OpenGL context.
*/
-static Togl *FindToglWithSameContext(Togl * togl)
+static Togl *
+FindToglWithSameContext(Togl *togl)
{
- Togl *t;
+ Togl *t;
for (t = ToglHead; t != NULL; t = t->Next) {
- if (t == togl)
- continue;
+ if (t == togl)
+ continue;
# if defined(TOGL_WGL)
- if (t->tglGLHglrc == togl->tglGLHglrc)
+ if (t->tglGLHglrc == togl->tglGLHglrc)
# elif defined(TOGL_X11)
- if (t->GlCtx == togl->GlCtx)
+ if (t->GlCtx == togl->GlCtx)
# elif defined(TOGL_AGL_CLASSIC) || defined(TOGL_AGL)
- if (t->aglCtx == togl->aglCtx)
+ if (t->aglCtx == togl->aglCtx)
# endif
- return t;
+ return t;
}
return NULL;
}
@@ -514,19 +507,20 @@
/*
* Return pointer to another togl widget with same OpenGL overlay context.
*/
-static Togl *FindToglWithSameOverlayContext(Togl * togl)
+static Togl *
+FindToglWithSameOverlayContext(Togl *togl)
{
- Togl *t;
+ Togl *t;
for (t = ToglHead; t != NULL; t = t->Next) {
- if (t == togl)
- continue;
+ if (t == togl)
+ continue;
# if defined(TOGL_X11)
- if (t->OverlayCtx == togl->OverlayCtx)
+ if (t->OverlayCtx == togl->OverlayCtx)
# elif defined(TOGL_WGL)
- if (t->tglGLOverlayHglrc == togl->tglGLOverlayHglrc)
+ if (t->tglGLOverlayHglrc == togl->tglGLOverlayHglrc)
# endif
- return t;
+ return t;
}
return NULL;
}
@@ -541,40 +535,39 @@
* Return: an X Colormap or 0 if there's a _serious_ error.
*/
static Colormap
-get_rgb_colormap(Display * dpy,
- int scrnum, const XVisualInfo * visinfo, Tk_Window tkwin)
+get_rgb_colormap(Display *dpy,
+ int scrnum, const XVisualInfo *visinfo, Tk_Window tkwin)
{
- Atom hp_cr_maps;
- Status status;
- int numCmaps;
- int i;
+ Atom hp_cr_maps;
+ Status status;
+ int numCmaps;
+ int i;
XStandardColormap *standardCmaps;
- Window root = XRootWindow(dpy, scrnum);
- Bool using_mesa;
+ Window root = XRootWindow(dpy, scrnum);
+ Bool using_mesa;
/*
* First check if visinfo's visual matches the default/root visual.
*/
if (visinfo->visual == Tk_Visual(tkwin)) {
- /* use the default/root colormap */
- Colormap cmap;
+ /* use the default/root colormap */
+ Colormap cmap;
- cmap = Tk_Colormap(tkwin);
+ cmap = Tk_Colormap(tkwin);
# ifdef MESA_COLOR_HACK
- (void)get_free_color_cells(dpy, scrnum, cmap);
+ (void) get_free_color_cells(dpy, scrnum, cmap);
# endif
- return cmap;
+ return cmap;
}
/*
* Check if we're using Mesa.
*/
if (strstr(glXQueryServerString(dpy, scrnum, GLX_VERSION), "Mesa")) {
- using_mesa = True;
+ using_mesa = True;
+ } else {
+ using_mesa = False;
}
- else {
- using_mesa = False;
- }
/*
* Next, if we're using Mesa and displaying on an HP with the "Color
@@ -583,29 +576,28 @@
* dither using this colormap.
*/
if (using_mesa) {
- hp_cr_maps = XInternAtom(dpy, "_HP_RGB_SMOOTH_MAP_LIST", True);
- if (hp_cr_maps
+ hp_cr_maps = XInternAtom(dpy, "_HP_RGB_SMOOTH_MAP_LIST", True);
+ if (hp_cr_maps
# ifdef __cplusplus
- && visinfo->visual->c_class == TrueColor
+ && visinfo->visual->c_class == TrueColor
# else
- && visinfo->visual->class == TrueColor
+ && visinfo->visual->class == TrueColor
# endif
- && visinfo->depth == 8) {
- status = XGetRGBColormaps(dpy, root, &standardCmaps,
- &numCmaps, hp_cr_maps);
- if (status) {
- for (i = 0; i < numCmaps; i++) {
- if (standardCmaps[i].visualid ==
- visinfo->visual->visualid) {
- Colormap cmap = standardCmaps[i].colormap;
+ && visinfo->depth == 8) {
+ status = XGetRGBColormaps(dpy, root, &standardCmaps,
+ &numCmaps, hp_cr_maps);
+ if (status) {
+ for (i = 0; i < numCmaps; i++) {
+ if (standardCmaps[i].visualid == visinfo->visual->visualid) {
+ Colormap cmap = standardCmaps[i].colormap;
- (void)XFree(standardCmaps);
- return cmap;
- }
- }
- (void)XFree(standardCmaps);
- }
- }
+ (void) XFree(standardCmaps);
+ return cmap;
+ }
+ }
+ (void) XFree(standardCmaps);
+ }
+ }
}
/*
@@ -614,25 +606,22 @@
# if !HP && !SUN
# ifndef SOLARIS_BUG
status = XmuLookupStandardColormap(dpy, visinfo->screen,
- visinfo->visualid, visinfo->depth,
- XA_RGB_DEFAULT_MAP,
- /* replace */ False,
- /* retain */
- True);
+ visinfo->visualid, visinfo->depth, XA_RGB_DEFAULT_MAP,
+ /* replace */ False, /* retain */ True);
if (status == 1) {
- status = XGetRGBColormaps(dpy, root, &standardCmaps,
- &numCmaps, XA_RGB_DEFAULT_MAP);
- if (status == 1) {
- for (i = 0; i < numCmaps; i++) {
- if (standardCmaps[i].visualid == visinfo->visualid) {
- Colormap cmap = standardCmaps[i].colormap;
+ status = XGetRGBColormaps(dpy, root, &standardCmaps,
+ &numCmaps, XA_RGB_DEFAULT_MAP);
+ if (status == 1) {
+ for (i = 0; i < numCmaps; i++) {
+ if (standardCmaps[i].visualid == visinfo->visualid) {
+ Colormap cmap = standardCmaps[i].colormap;
- (void)XFree(standardCmaps);
- return cmap;
- }
- }
- (void)XFree(standardCmaps);
- }
+ (void) XFree(standardCmaps);
+ return cmap;
+ }
+ }
+ (void) XFree(standardCmaps);
+ }
}
# endif
# endif
@@ -688,58 +677,60 @@
{0xFF, 0xFF, 0xFF, 0}
};
-static unsigned char ComponentFromIndex(int i, UINT nbits, UINT shift)
+static unsigned char
+ComponentFromIndex(int i, UINT nbits, UINT shift)
{
unsigned char val;
- val = (unsigned char)(i >> shift);
+ val = (unsigned char) (i >> shift);
switch (nbits) {
- case 1:
- val &= 0x1;
- return oneto8[val];
+ case 1:
+ val &= 0x1;
+ return oneto8[val];
- case 2:
- val &= 0x3;
- return twoto8[val];
+ case 2:
+ val &= 0x3;
+ return twoto8[val];
- case 3:
- val &= 0x7;
- return threeto8[val];
+ case 3:
+ val &= 0x7;
+ return threeto8[val];
- default:
- return 0;
+ default:
+ return 0;
}
}
-static Colormap Win32CreateRgbColormap(PIXELFORMATDESCRIPTOR pfd)
+static Colormap
+Win32CreateRgbColormap(PIXELFORMATDESCRIPTOR pfd)
{
- TkWinColormap *cmap = (TkWinColormap *) ckalloc(sizeof(TkWinColormap));
+ TkWinColormap *cmap = (TkWinColormap *) ckalloc(sizeof (TkWinColormap));
LOGPALETTE *pPal;
- int n, i;
+ int n, i;
n = 1 << pfd.cColorBits;
- pPal = (PLOGPALETTE) LocalAlloc(LMEM_FIXED, sizeof(LOGPALETTE)
- + n * sizeof(PALETTEENTRY));
+ pPal = (PLOGPALETTE) LocalAlloc(LMEM_FIXED, sizeof (LOGPALETTE)
+ + n * sizeof (PALETTEENTRY));
pPal->palVersion = 0x300;
pPal->palNumEntries = n;
for (i = 0; i < n; i++) {
- pPal->palPalEntry[i].peRed =
- ComponentFromIndex(i, pfd.cRedBits, pfd.cRedShift);
- pPal->palPalEntry[i].peGreen =
- ComponentFromIndex(i, pfd.cGreenBits, pfd.cGreenShift);
- pPal->palPalEntry[i].peBlue =
- ComponentFromIndex(i, pfd.cBlueBits, pfd.cBlueShift);
- pPal->palPalEntry[i].peFlags = 0;
+ pPal->palPalEntry[i].peRed =
+ ComponentFromIndex(i, pfd.cRedBits, pfd.cRedShift);
+ pPal->palPalEntry[i].peGreen =
+ ComponentFromIndex(i, pfd.cGreenBits, pfd.cGreenShift);
+ pPal->palPalEntry[i].peBlue =
+ ComponentFromIndex(i, pfd.cBlueBits, pfd.cBlueShift);
+ pPal->palPalEntry[i].peFlags = 0;
}
/* fix up the palette to include the default GDI palette */
if ((pfd.cColorBits == 8)
- && (pfd.cRedBits == 3) && (pfd.cRedShift == 0)
- && (pfd.cGreenBits == 3) && (pfd.cGreenShift == 3)
- && (pfd.cBlueBits == 2) && (pfd.cBlueShift == 6)) {
- for (i = 1; i <= 12; i++)
- pPal->palPalEntry[defaultOverride[i]] = defaultPalEntry[i];
+ && (pfd.cRedBits == 3) && (pfd.cRedShift == 0)
+ && (pfd.cGreenBits == 3) && (pfd.cGreenShift == 3)
+ && (pfd.cBlueBits == 2) && (pfd.cBlueShift == 6)) {
+ for (i = 1; i <= 12; i++)
+ pPal->palPalEntry[defaultOverride[i]] = defaultPalEntry[i];
}
cmap->palette = CreatePalette(pPal);
@@ -754,13 +745,14 @@
return (Colormap) cmap;
}
-static Colormap Win32CreateCiColormap(Togl * togl)
+static Colormap
+Win32CreateCiColormap(Togl *togl)
{
/* Create a colormap with size of togl->CiColormapSize and set all entries
* to black */
LOGPALETTE logPalette;
- TkWinColormap *cmap = (TkWinColormap *) ckalloc(sizeof(TkWinColormap));
+ TkWinColormap *cmap = (TkWinColormap *) ckalloc(sizeof (TkWinColormap));
logPalette.palVersion = 0x300;
logPalette.palNumEntries = 1;
@@ -771,7 +763,7 @@
cmap->palette = CreatePalette(&logPalette);
cmap->size = togl->CiColormapSize;
- ResizePalette(cmap->palette, cmap->size); /* sets new entries to black */
+ ResizePalette(cmap->palette, cmap->size); /* sets new entries to black */
cmap->stale = 0;
/* Since this is a private colormap of a fix size, we do not need a valid
@@ -789,18 +781,19 @@
*
* Called upon system startup to create Togl command.
*/
-int Togl_Init(Tcl_Interp * interp)
+int
+Togl_Init(Tcl_Interp *interp)
{
- int major, minor, patchLevel, releaseType;
+ int major, minor, patchLevel, releaseType;
#ifdef USE_TCL_STUBS
if (Tcl_InitStubs(interp, "8.1", 0) == NULL) {
- return TCL_ERROR;
+ return TCL_ERROR;
}
#endif
#ifdef USE_TK_STUBS
if (Tk_InitStubs(interp, TCL_STUPID "8.1", 0) == NULL) {
- return TCL_ERROR;
+ return TCL_ERROR;
}
#endif
@@ -810,37 +803,38 @@
# ifdef HAVE_TK_SETCLASSPROCS
if (major > 8
- || (major == 8
- && (minor > 4
- || (minor == 4 && (releaseType > 0 || patchLevel >= 2))))) {
+ || (major == 8
+ && (minor > 4
+ || (minor == 4 && (releaseType > 0
+ || patchLevel >= 2))))) {
# ifdef USE_TK_STUBS
- SetClassProcsPtr = tkStubsPtr->tk_SetClassProcs;
+ SetClassProcsPtr = tkStubsPtr->tk_SetClassProcs;
# else
- SetClassProcsPtr = Tk_SetClassProcs;
+ SetClassProcsPtr = Tk_SetClassProcs;
# endif
+ } else {
+ SetClassProcsPtr = NULL;
}
- else {
- SetClassProcsPtr = NULL;
- }
# else
if (major > 8
- || (major == 8
- && (minor > 4
- || (minor == 4 && (releaseType > 0 || patchLevel >= 2))))) {
- TCL_ERR(interp,
- "Sorry, this instance of Togl was not compiled to work with Tcl/Tk 8.4a2 or higher.");
+ || (major == 8
+ && (minor > 4
+ || (minor == 4 && (releaseType > 0
+ || patchLevel >= 2))))) {
+ TCL_ERR(interp,
+ "Sorry, this instance of Togl was not compiled to work with Tcl/Tk 8.4a2 or higher.");
}
# endif
#endif
if (Tcl_PkgProvide(interp, "Togl", TOGL_VERSION) != TCL_OK) {
- return TCL_ERROR;
+ return TCL_ERROR;
}
if (Tcl_CreateCommand(interp, "togl", Togl_Cmd,
- (ClientData) Tk_MainWindow(interp), NULL) == NULL)
- return TCL_ERROR;
+ (ClientData) Tk_MainWindow(interp), NULL) == NULL)
+ return TCL_ERROR;
Tcl_InitHashTable(&CommandTable, TCL_STRING_KEYS);
@@ -851,7 +845,8 @@
/*
* Register a C function to be called when an Togl widget is realized.
*/
-void Togl_CreateFunc(Togl_Callback * proc)
+void
+Togl_CreateFunc(Togl_Callback *proc)
{
DefaultCreateProc = proc;
}
@@ -860,7 +855,8 @@
/*
* Register a C function to be called when an Togl widget must be redrawn.
*/
-void Togl_DisplayFunc(Togl_Callback * proc)
+void
+Togl_DisplayFunc(Togl_Callback *proc)
{
DefaultDisplayProc = proc;
}
@@ -869,7 +865,8 @@
/*
* Register a C function to be called when an Togl widget is resized.
*/
-void Togl_ReshapeFunc(Togl_Callback * proc)
+void
+Togl_ReshapeFunc(Togl_Callback *proc)
{
DefaultReshapeProc = proc;
}
@@ -878,7 +875,8 @@
/*
* Register a C function to be called when an Togl widget is destroyed.
*/
-void Togl_DestroyFunc(Togl_Callback * proc)
+void
+Togl_DestroyFunc(Togl_Callback *proc)
{
DefaultDestroyProc = proc;
}
@@ -887,7 +885,8 @@
/*
* Register a C function to be called from TimerEventHandler.
*/
-void Togl_TimerFunc(Togl_Callback * proc)
+void
+Togl_TimerFunc(Togl_Callback *proc)
{
DefaultTimerProc = proc;
}
@@ -896,7 +895,8 @@
/*
* Reset default callback pointers to NULL.
*/
-void Togl_ResetDefaultCallbacks(void)
+void
+Togl_ResetDefaultCallbacks(void)
{
DefaultCreateProc = NULL;
DefaultDisplayProc = NULL;
@@ -911,7 +911,8 @@
/*
* Chnage the create callback for a specific Togl widget.
*/
-void Togl_SetCreateFunc(Togl * togl, Togl_Callback * proc)
+void
+Togl_SetCreateFunc(Togl *togl, Togl_Callback *proc)
{
togl->CreateProc = proc;
}
@@ -920,7 +921,8 @@
/*
* Change the display/redraw callback for a specific Togl widget.
*/
-void Togl_SetDisplayFunc(Togl * togl, Togl_Callback * proc)
+void
+Togl_SetDisplayFunc(Togl *togl, Togl_Callback *proc)
{
togl->DisplayProc = proc;
}
@@ -929,7 +931,8 @@
/*
* Change the reshape callback for a specific Togl widget.
*/
-void Togl_SetReshapeFunc(Togl * togl, Togl_Callback * proc)
+void
+Togl_SetReshapeFunc(Togl *togl, Togl_Callback *proc)
{
togl->ReshapeProc = proc;
}
@@ -938,7 +941,8 @@
/*
* Change the destroy callback for a specific Togl widget.
*/
-void Togl_SetDestroyFunc(Togl * togl, Togl_Callback * proc)
+void
+Togl_SetDestroyFunc(Togl *togl, Togl_Callback *proc)
{
togl->DestroyProc = proc;
}
@@ -949,24 +953,25 @@
*
* Gets called from Tk_CreateTimerHandler.
*/
-static void Togl_Timer(ClientData clientData)
+static void
+Togl_Timer(ClientData clientData)
{
- Togl *togl = (Togl *) clientData;
+ Togl *togl = (Togl *) clientData;
if (togl->TimerProc) {
- togl->TimerProc(togl);
+ togl->TimerProc(togl);
- /* Re-register this callback since Tcl/Tk timers are "one-shot". That
- * is, after the timer callback is called it not normally called again.
- * * * * * * * * * That's not the behavior we want for Togl. */
+ /* Re-register this callback since Tcl/Tk timers are "one-shot". That
+ * is, after the timer callback is called it not normally called again.
+ * * * * * * * * * That's not the behavior we want for Togl. */
#if (TK_MAJOR_VERSION * 100 + TK_MINOR_VERSION) >= 401
- togl->timerHandler =
- Tcl_CreateTimerHandler(togl->TimerInterval, Togl_Timer,
- (ClientData) togl);
+ togl->timerHandler =
+ Tcl_CreateTimerHandler(togl->TimerInterval, Togl_Timer,
+ (ClientData) togl);
#else
- togl->timerHandler =
- Tk_CreateTimerHandler(togl->TimeInterval, Togl_Timer,
- (ClientData) togl);
+ togl->timerHandler =
+ Tk_CreateTimerHandler(togl->TimeInterval, Togl_Timer,
+ (ClientData) togl);
#endif
}
}
@@ -976,18 +981,19 @@
* Change the timer callback for a specific Togl widget.
* Pass NULL to disable the callback.
*/
-void Togl_SetTimerFunc(Togl * togl, Togl_Callback * proc)
+void
+Togl_SetTimerFunc(Togl *togl, Togl_Callback *proc)
{
togl->TimerProc = proc;
if (proc) {
#if (TK_MAJOR_VERSION * 100 + TK_MINOR_VERSION) >= 401
- togl->timerHandler =
- Tcl_CreateTimerHandler(togl->TimerInterval, Togl_Timer,
- (ClientData) togl);
+ togl->timerHandler =
+ Tcl_CreateTimerHandler(togl->TimerInterval, Togl_Timer,
+ (ClientData) togl);
#else
- togl->timerHandler =
- Tk_CreateTimerHandler(togl->TimeInterval, Togl_Timer,
- (ClientData) togl);
+ togl->timerHandler =
+ Tk_CreateTimerHandler(togl->TimeInterval, Togl_Timer,
+ (ClientData) togl);
#endif
}
}
@@ -1001,9 +1007,10 @@
* Every time the sub-command is called from Tcl, the
* C routine will be called with all the arguments from Tcl.
*/
-void Togl_CreateCommand(char *cmd_name, Togl_CmdProc * cmd_proc)
+void
+Togl_CreateCommand(char *cmd_name, Togl_CmdProc *cmd_proc)
{
- int new_item;
+ int new_item;
Tcl_HashEntry *entry;
entry = Tcl_CreateHashEntry(&CommandTable, cmd_name, &new_item);
@@ -1017,30 +1024,29 @@
* Bind the OpenGL rendering context to the specified
* Togl widget.
*/
-void Togl_MakeCurrent(const Togl * togl)
+void
+Togl_MakeCurrent(const Togl *togl)
{
#if defined(TOGL_WGL)
- int res = wglMakeCurrent(togl->tglGLHdc, togl->tglGLHglrc);
+ int res = wglMakeCurrent(togl->tglGLHdc, togl->tglGLHglrc);
assert(res == TRUE);
#elif defined(TOGL_X11)
if (!togl->GlCtx)
- return;
- (void)glXMakeCurrent(togl->display,
- togl->TkWin ? Tk_WindowId(togl->TkWin) : None,
- togl->GlCtx);
+ return;
+ (void) glXMakeCurrent(togl->display,
+ togl->TkWin ? Tk_WindowId(togl->TkWin) : None, togl->GlCtx);
# if defined(__sgi)
if (togl->OldStereoFlag)
- oldStereoMakeCurrent(togl->display,
- togl->TkWin ? Tk_WindowId(togl->TkWin) : None,
- togl->GlCtx);
+ oldStereoMakeCurrent(togl->display,
+ togl->TkWin ? Tk_WindowId(togl->TkWin) : None, togl->GlCtx);
# endif /*__sgi STEREO */
#elif defined(TOGL_AGL_CLASSIC) || defined(TOGL_AGL)
if (!togl->aglCtx)
- return;
+ return;
aglSetCurrentContext(togl->aglCtx);
#endif
}
@@ -1048,40 +1054,42 @@
#ifdef TOGL_AGL_CLASSIC
/* tell OpenGL which part of the Mac window to render to */
-static void SetMacBufRect(Togl * togl)
+static void
+SetMacBufRect(Togl *togl)
{
- GLint wrect[4];
+ GLint wrect[4];
/* set wrect[0,1] to lower left corner of widget */
wrect[2] = ((TkWindow *) (togl->TkWin))->changes.width;
wrect[3] = ((TkWindow *) (togl->TkWin))->changes.height;
wrect[0] = ((TkWindow *) (togl->TkWin))->privatePtr->xOff;
wrect[1] =
- ((TkWindow *) (togl->TkWin))->privatePtr->toplevel->portPtr->
- portRect.bottom - wrect[3] -
- ((TkWindow *) (togl->TkWin))->privatePtr->yOff;
+ ((TkWindow *) (togl->TkWin))->privatePtr->toplevel->portPtr->
+ portRect.bottom - wrect[3] -
+ ((TkWindow *) (togl->TkWin))->privatePtr->yOff;
aglSetInteger(togl->aglCtx, AGL_BUFFER_RECT, wrect);
aglEnable(togl->aglCtx, AGL_BUFFER_RECT);
aglUpdateContext(togl->aglCtx);
}
#elif defined(TOGL_AGL)
/* tell OpenGL which part of the Mac window to render to */
-static void SetMacBufRect(Togl * togl)
+static void
+SetMacBufRect(Togl *togl)
{
- GLint wrect[4];
+ GLint wrect[4];
/* set wrect[0,1] to lower left corner of widget */
wrect[2] = Tk_Width(togl->TkWin);
wrect[3] = Tk_Height(togl->TkWin);
wrect[0] = ((TkWindow *) (togl->TkWin))->privatePtr->xOff;
- Rect r;
+ Rect r;
GetPortBounds(((TkWindow *) (togl->TkWin))->privatePtr->toplevel->grafPtr,
- &r);
+ &r);
wrect[1] = r.bottom -
- wrect[3] - ((TkWindow *) (togl->TkWin))->privatePtr->yOff;
+ wrect[3] - ((TkWindow *) (togl->TkWin))->privatePtr->yOff;
aglSetInteger(togl->aglCtx, AGL_BUFFER_RECT, wrect);
aglEnable(togl->aglCtx, AGL_BUFFER_RECT);
@@ -1096,97 +1104,102 @@
* Note that the parameter type is ClientData so this function can be
* passed to Tk_DoWhenIdle().
*/
-static void Togl_Render(ClientData clientData)
+static void
+Togl_Render(ClientData clientData)
{
- Togl *togl = (Togl *) clientData;
+ Togl *togl = (Togl *) clientData;
if (togl->DisplayProc) {
#ifdef TOGL_AGL_CLASSIC
- /* Mac is complicated here because OpenGL needs to know what part of
- * the parent window to render into, and it seems that region need to
- * be invalidated before drawing, so that QuickDraw will allow OpenGL
- * to transfer pixels into that part of the window. I'm not even
- * totally sure how or why this works as it does, since this aspect of
- * Mac OpenGL seems to be totally undocumented. This was put together
- * by trial and error! (thiessen) */
- MacRegion r;
- RgnPtr rp = &r;
- GrafPtr curPort, parentWin;
+ /* Mac is complicated here because OpenGL needs to know what part of
+ * the parent window to render into, and it seems that region need to
+ * be invalidated before drawing, so that QuickDraw will allow OpenGL
+ * to transfer pixels into that part of the window. I'm not even
+ * totally sure how or why this works as it does, since this aspect of
+ * Mac OpenGL seems to be totally undocumented. This was put together
+ * by trial and error! (thiessen) */
+ MacRegion r;
+ RgnPtr rp = &r;
+ GrafPtr curPort, parentWin;
- parentWin = (GrafPtr)
- (((MacDrawable *) (Tk_WindowId(togl->TkWin)))->toplevel->portPtr);
- if (!parentWin)
- return;
+ parentWin = (GrafPtr)
+ (((MacDrawable *) (Tk_WindowId(togl->TkWin)))->toplevel->
+ portPtr);
+ if (!parentWin)
+ return;
#endif
- Togl_MakeCurrent(togl);
+ Togl_MakeCurrent(togl);
#ifdef TOGL_AGL_CLASSIC
- /* Set QuickDraw port and clipping region */
- GetPort(&curPort);
- SetPort(parentWin);
- r.rgnBBox.left = ((TkWindow *) (togl->TkWin))->privatePtr->xOff;
- r.rgnBBox.right =
- r.rgnBBox.left + ((TkWindow *) (togl->TkWin))->changes.width - 1;
- r.rgnBBox.top = ((TkWindow *) (togl->TkWin))->privatePtr->yOff;
- r.rgnBBox.bottom =
- r.rgnBBox.top + ((TkWindow *) (togl->TkWin))->changes.height - 1;
- r.rgnSize = sizeof(Region);
- InvalRgn(&rp);
- SetClip(&rp);
- /* this may seem an odd place to put this, with possibly redundant
- * calls to aglSetInteger(AGL_BUFFER_RECT...), but for some reason
- * performance is actually a lot better if this is called before every
- * render... */
- SetMacBufRect(togl);
+ /* Set QuickDraw port and clipping region */
+ GetPort(&curPort);
+ SetPort(parentWin);
+ r.rgnBBox.left = ((TkWindow *) (togl->TkWin))->privatePtr->xOff;
+ r.rgnBBox.right =
+ r.rgnBBox.left + ((TkWindow *) (togl->TkWin))->changes.width -
+ 1;
+ r.rgnBBox.top = ((TkWindow *) (togl->TkWin))->privatePtr->yOff;
+ r.rgnBBox.bottom =
+ r.rgnBBox.top + ((TkWindow *) (togl->TkWin))->changes.height -
+ 1;
+ r.rgnSize = sizeof (Region);
+ InvalRgn(&rp);
+ SetClip(&rp);
+ /* this may seem an odd place to put this, with possibly redundant
+ * calls to aglSetInteger(AGL_BUFFER_RECT...), but for some reason
+ * performance is actually a lot better if this is called before every
+ * render... */
+ SetMacBufRect(togl);
#endif
#ifdef TOGL_AGL
- SetMacBufRect(togl);
+ SetMacBufRect(togl);
#endif
- togl->DisplayProc(togl);
+ togl->DisplayProc(togl);
#ifdef TOGL_AGL_CLASSIC
- SetPort(curPort); /* restore previous port */
+ SetPort(curPort); /* restore previous port */
#endif
}
#if defined(TOGL_AGL_CLASSIC) || defined(TOGL_AGL)
else {
- /* Always need to update on resize */
- SetMacBufRect(togl);
+ /* Always need to update on resize */
+ SetMacBufRect(togl);
}
#endif
togl->UpdatePending = False;
}
-static void RenderOverlay(ClientData clientData)
+static void
+RenderOverlay(ClientData clientData)
{
- Togl *togl = (Togl *) clientData;
+ Togl *togl = (Togl *) clientData;
if (togl->OverlayFlag && togl->OverlayDisplayProc) {
#if defined(TOGL_WGL)
- int res = wglMakeCurrent(togl->tglGLHdc, togl->tglGLHglrc);
+ int res = wglMakeCurrent(togl->tglGLHdc, togl->tglGLHglrc);
- assert(res == TRUE);
+ assert(res == TRUE);
#elif defined(TOGL_X11)
- (void)glXMakeCurrent(Tk_Display(togl->TkWin),
- togl->OverlayWindow, togl->OverlayCtx);
+ (void) glXMakeCurrent(Tk_Display(togl->TkWin),
+ togl->OverlayWindow, togl->OverlayCtx);
# if defined(__sgi)
- if (togl->OldStereoFlag)
- oldStereoMakeCurrent(Tk_Display(togl->TkWin),
- togl->OverlayWindow, togl->OverlayCtx);
+ if (togl->OldStereoFlag)
+ oldStereoMakeCurrent(Tk_Display(togl->TkWin),
+ togl->OverlayWindow, togl->OverlayCtx);
# endif /*__sgi STEREO */
#endif /* TOGL_WGL */
- togl->OverlayDisplayProc(togl);
+ togl->OverlayDisplayProc(togl);
}
togl->OverlayUpdatePending = False;
}
@@ -1197,81 +1210,81 @@
* options like RGBA - ColorIndex ; Z-buffer and so on
*/
int
-Togl_Configure(Tcl_Interp * interp, Togl * togl,
- int argc, const char *argv[], int flags)
+Togl_Configure(Tcl_Interp *interp, Togl *togl,
+ int argc, const char *argv[], int flags)
{
- Bool oldRgbaFlag = togl->RgbaFlag;
- int oldRgbaRed = togl->RgbaRed;
- int oldRgbaGreen = togl->RgbaGreen;
- int oldRgbaBlue = togl->RgbaBlue;
- Bool oldDoubleFlag = togl->DoubleFlag;
- Bool oldDepthFlag = togl->DepthFlag;
- int oldDepthSize = togl->DepthSize;
- Bool oldAccumFlag = togl->AccumFlag;
- int oldAccumRed = togl->AccumRed;
- int oldAccumGreen = togl->AccumGreen;
- int oldAccumBlue = togl->AccumBlue;
- int oldAccumAlpha = togl->AccumAlpha;
- Bool oldAlphaFlag = togl->AlphaFlag;
- int oldAlphaSize = togl->AlphaSize;
- Bool oldStencilFlag = togl->StencilFlag;
- int oldStencilSize = togl->StencilSize;
- int oldAuxNumber = togl->AuxNumber;
- int oldWidth = togl->Width;
- int oldHeight = togl->Height;
- int oldSetGrid = togl->SetGrid;
+ Bool oldRgbaFlag = togl->RgbaFlag;
+ int oldRgbaRed = togl->RgbaRed;
+ int oldRgbaGreen = togl->RgbaGreen;
+ int oldRgbaBlue = togl->RgbaBlue;
+ Bool oldDoubleFlag = togl->DoubleFlag;
+ Bool oldDepthFlag = togl->DepthFlag;
+ int oldDepthSize = togl->DepthSize;
+ Bool oldAccumFlag = togl->AccumFlag;
+ int oldAccumRed = togl->AccumRed;
+ int oldAccumGreen = togl->AccumGreen;
+ int oldAccumBlue = togl->AccumBlue;
+ int oldAccumAlpha = togl->AccumAlpha;
+ Bool oldAlphaFlag = togl->AlphaFlag;
+ int oldAlphaSize = togl->AlphaSize;
+ Bool oldStencilFlag = togl->StencilFlag;
+ int oldStencilSize = togl->StencilSize;
+ int oldAuxNumber = togl->AuxNumber;
+ int oldWidth = togl->Width;
+ int oldHeight = togl->Height;
+ int oldSetGrid = togl->SetGrid;
if (Tk_ConfigureWidget(interp, togl->TkWin, configSpecs,
- argc, argv, WIDGREC togl, flags) == TCL_ERROR) {
- return (TCL_ERROR);
+ argc, argv, WIDGREC togl, flags) == TCL_ERROR) {
+ return (TCL_ERROR);
}
#ifndef USE_OVERLAY
if (togl->OverlayFlag) {
- TCL_ERR(interp, "Sorry, overlay was disabled");
+ TCL_ERR(interp, "Sorry, overlay was disabled");
}
#endif
if (togl->Width != oldWidth || togl->Height != oldHeight
- || togl->SetGrid != oldSetGrid) {
- Togl_WorldChanged((ClientData) togl);
- /* this added per Lou Arata <arata at enya.picker.com> */
- Tk_ResizeWindow(togl->TkWin, togl->Width, togl->Height);
+ || togl->SetGrid != oldSetGrid) {
+ Togl_WorldChanged((ClientData) togl);
+ /* this added per Lou Arata <arata at enya.picker.com> */
+ Tk_ResizeWindow(togl->TkWin, togl->Width, togl->Height);
- if (togl->ReshapeProc &&
+ if (togl->ReshapeProc &&
#if defined(TOGL_WGL)
- togl->tglGLHglrc
+ togl->tglGLHglrc
#elif defined(TOGL_X11)
- togl->GlCtx
+ togl->GlCtx
#elif defined(TOGL_AGL_CLASSIC) || defined(TOGL_AGL)
- togl->aglCtx
+ togl->aglCtx
#endif
- ) {
- Togl_MakeCurrent(togl);
- togl->ReshapeProc(togl);
- }
+ ) {
+ Togl_MakeCurrent(togl);
+ togl->ReshapeProc(togl);
+ }
}
if (togl->RgbaFlag != oldRgbaFlag
- || togl->RgbaRed != oldRgbaRed
- || togl->RgbaGreen != oldRgbaGreen
- || togl->RgbaBlue != oldRgbaBlue
- || togl->DoubleFlag != oldDoubleFlag
- || togl->DepthFlag != oldDepthFlag
- || togl->DepthSize != oldDepthSize
- || togl->AccumFlag != oldAccumFlag
- || togl->AccumRed != oldAccumRed
- || togl->AccumGreen != oldAccumGreen
- || togl->AccumBlue != oldAccumBlue
- || togl->AccumAlpha != oldAccumAlpha
- || togl->AlphaFlag != oldAlphaFlag
- || togl->AlphaSize != oldAlphaSize
- || togl->StencilFlag != oldStencilFlag
- || togl->StencilSize != oldStencilSize
- || togl->AuxNumber != oldAuxNumber) {
+ || togl->RgbaRed != oldRgbaRed
+ || togl->RgbaGreen != oldRgbaGreen
+ || togl->RgbaBlue != oldRgbaBlue
+ || togl->DoubleFlag != oldDoubleFlag
+ || togl->DepthFlag != oldDepthFlag
+ || togl->DepthSize != oldDepthSize
+ || togl->AccumFlag != oldAccumFlag
+ || togl->AccumRed != oldAccumRed
+ || togl->AccumGreen != oldAccumGreen
+ || togl->AccumBlue != oldAccumBlue
+ || togl->AccumAlpha != oldAccumAlpha
+ || togl->AlphaFlag != oldAlphaFlag
+ || togl->AlphaSize != oldAlphaSize
+ || togl->StencilFlag != oldStencilFlag
+ || togl->StencilSize != oldStencilSize
+ || togl->AuxNumber != oldAuxNumber) {
#ifdef MESA_COLOR_HACK
- free_default_color_cells(Tk_Display(togl->TkWin),
- Tk_Colormap(togl->TkWin));
+ free_default_color_cells(Tk_Display(togl->TkWin),
+ Tk_Colormap(togl->TkWin));
#endif
}
#if defined(__sgi)
@@ -1283,115 +1296,103 @@
static int
-Togl_Widget(ClientData clientData, Tcl_Interp * interp, int argc,
- CONST84 char *argv[])
+Togl_Widget(ClientData clientData, Tcl_Interp *interp, int argc,
+ CONST84 char *argv[])
{
- Togl *togl = (Togl *) clientData;
- int result = TCL_OK;
+ Togl *togl = (Togl *) clientData;
+ int result = TCL_OK;
Tcl_HashEntry *entry;
Tcl_HashSearch search;
Togl_CmdProc *cmd_proc;
if (argc < 2) {
- Tcl_AppendResult(interp, "wrong # args: should be \"",
- argv[0], " ?options?\"", NULL);
- return TCL_ERROR;
+ Tcl_AppendResult(interp, "wrong # args: should be \"",
+ argv[0], " ?options?\"", NULL);
+ return TCL_ERROR;
}
Tk_Preserve((ClientData) togl);
if (!strncmp(argv[1], "configure", MAX(1, strlen(argv[1])))) {
- if (argc == 2) {
- /* Return list of all configuration parameters */
- result = Tk_ConfigureInfo(interp, togl->TkWin, configSpecs,
- WIDGREC togl, (char *)NULL, 0);
- }
- else if (argc == 3) {
- if (strcmp(argv[2], "-extensions") == 0) {
- /* Return a list of OpenGL extensions available */
- const char *extensions;
+ if (argc == 2) {
+ /* Return list of all configuration parameters */
+ result = Tk_ConfigureInfo(interp, togl->TkWin, configSpecs,
+ WIDGREC togl, (char *) NULL, 0);
+ } else if (argc == 3) {
+ if (strcmp(argv[2], "-extensions") == 0) {
+ /* Return a list of OpenGL extensions available */
+ const char *extensions;
- extensions = (const char *)glGetString(GL_EXTENSIONS);
- Tcl_SetResult(interp, TCL_STUPID extensions, TCL_STATIC);
- result = TCL_OK;
- }
- else {
- /* Return a specific configuration parameter */
- result = Tk_ConfigureInfo(interp, togl->TkWin, configSpecs,
- WIDGREC togl, argv[2], 0);
- }
- }
- else {
- /* Execute a configuration change */
- result = Togl_Configure(interp, togl, argc - 2, argv + 2,
- TK_CONFIG_ARGV_ONLY);
- }
+ extensions = (const char *) glGetString(GL_EXTENSIONS);
+ Tcl_SetResult(interp, TCL_STUPID extensions, TCL_STATIC);
+ result = TCL_OK;
+ } else {
+ /* Return a specific configuration parameter */
+ result = Tk_ConfigureInfo(interp, togl->TkWin, configSpecs,
+ WIDGREC togl, argv[2], 0);
+ }
+ } else {
+ /* Execute a configuration change */
+ result = Togl_Configure(interp, togl, argc - 2, argv + 2,
+ TK_CONFIG_ARGV_ONLY);
+ }
+ } else if (!strncmp(argv[1], "render", MAX(1, strlen(argv[1])))) {
+ /* force the widget to be redrawn */
+ Togl_Render((ClientData) togl);
+ } else if (!strncmp(argv[1], "swapbuffers", MAX(1, strlen(argv[1])))) {
+ /* force the widget to be redrawn */
+ Togl_SwapBuffers(togl);
+ } else if (!strncmp(argv[1], "makecurrent", MAX(1, strlen(argv[1])))) {
+ /* force the widget to be redrawn */
+ Togl_MakeCurrent(togl);
}
- else if (!strncmp(argv[1], "render", MAX(1, strlen(argv[1])))) {
- /* force the widget to be redrawn */
- Togl_Render((ClientData) togl);
- }
- else if (!strncmp(argv[1], "swapbuffers", MAX(1, strlen(argv[1])))) {
- /* force the widget to be redrawn */
- Togl_SwapBuffers(togl);
- }
- else if (!strncmp(argv[1], "makecurrent", MAX(1, strlen(argv[1])))) {
- /* force the widget to be redrawn */
- Togl_MakeCurrent(togl);
- }
#if TOGL_USE_FONTS == 1
else if (!strncmp(argv[1], "loadbitmapfont", MAX(1, strlen(argv[1])))) {
- if (argc == 3) {
- GLuint fontbase;
- Tcl_Obj *fontbaseAsTclObject;
+ if (argc == 3) {
+ GLuint fontbase;
+ Tcl_Obj *fontbaseAsTclObject;
- fontbase = Togl_LoadBitmapFont(togl, argv[2]);
- if (fontbase) {
- fontbaseAsTclObject = Tcl_NewIntObj(fontbase);
- Tcl_SetObjResult(interp, fontbaseAsTclObject);
- result = TCL_OK;
- }
- else {
- Tcl_AppendResult(interp, "Could not allocate font", NULL);
- result = TCL_ERROR;
- }
- }
- else {
- Tcl_AppendResult(interp, "wrong # args", NULL);
- result = TCL_ERROR;
- }
+ fontbase = Togl_LoadBitmapFont(togl, argv[2]);
+ if (fontbase) {
+ fontbaseAsTclObject = Tcl_NewIntObj(fontbase);
+ Tcl_SetObjResult(interp, fontbaseAsTclObject);
+ result = TCL_OK;
+ } else {
+ Tcl_AppendResult(interp, "Could not allocate font", NULL);
+ result = TCL_ERROR;
+ }
+ } else {
+ Tcl_AppendResult(interp, "wrong # args", NULL);
+ result = TCL_ERROR;
+ }
+ } else if (!strncmp(argv[1], "unloadbitmapfont", MAX(1, strlen(argv[1])))) {
+ if (argc == 3) {
+ Togl_UnloadBitmapFont(togl, atoi(argv[2]));
+ result = TCL_OK;
+ } else {
+ Tcl_AppendResult(interp, "wrong # args", NULL);
+ result = TCL_ERROR;
+ }
}
- else if (!strncmp(argv[1], "unloadbitmapfont", MAX(1, strlen(argv[1])))) {
- if (argc == 3) {
- Togl_UnloadBitmapFont(togl, atoi(argv[2]));
- result = TCL_OK;
- }
- else {
- Tcl_AppendResult(interp, "wrong # args", NULL);
- result = TCL_ERROR;
- }
- }
#endif /* TOGL_USE_FONTS */
else {
- /* Probably a user-defined function */
- entry = Tcl_FindHashEntry(&CommandTable, argv[1]);
- if (entry != NULL) {
- cmd_proc = (Togl_CmdProc *) Tcl_GetHashValue(entry);
- result = cmd_proc(togl, argc, argv);
- }
- else {
- Tcl_AppendResult(interp, "Togl: Unknown option: ", argv[1], "\n",
- "Try: configure or render\n",
- "or one of the user-defined commands:\n", NULL);
- entry = Tcl_FirstHashEntry(&CommandTable, &search);
- while (entry) {
- Tcl_AppendResult(interp, " ",
- Tcl_GetHashKey(&CommandTable, entry), "\n",
- NULL);
- entry = Tcl_NextHashEntry(&search);
- }
- result = TCL_ERROR;
- }
+ /* Probably a user-defined function */
+ entry = Tcl_FindHashEntry(&CommandTable, argv[1]);
+ if (entry != NULL) {
+ cmd_proc = (Togl_CmdProc *) Tcl_GetHashValue(entry);
+ result = cmd_proc(togl, argc, argv);
+ } else {
+ Tcl_AppendResult(interp, "Togl: Unknown option: ", argv[1], "\n",
+ "Try: configure or render\n",
+ "or one of the user-defined commands:\n", NULL);
+ entry = Tcl_FirstHashEntry(&CommandTable, &search);
+ while (entry) {
+ Tcl_AppendResult(interp, " ",
+ Tcl_GetHashKey(&CommandTable, entry), "\n", NULL);
+ entry = Tcl_NextHashEntry(&search);
+ }
+ result = TCL_ERROR;
+ }
}
Tk_Release((ClientData) togl);
@@ -1411,31 +1412,31 @@
* * Configures this Togl for the given arguments
*/
static int
-Togl_Cmd(ClientData clientData, Tcl_Interp * interp, int argc,
- CONST84 char **argv)
+Togl_Cmd(ClientData clientData, Tcl_Interp *interp, int argc,
+ CONST84 char **argv)
{
const char *name;
Tk_Window mainwin = (Tk_Window) clientData;
Tk_Window tkwin;
- Togl *togl;
+ Togl *togl;
if (argc <= 1) {
- TCL_ERR(interp, "wrong # args: should be \"pathName read filename\"");
+ TCL_ERR(interp, "wrong # args: should be \"pathName read filename\"");
}
/* Create the window. */
name = argv[1];
- tkwin = Tk_CreateWindowFromPath(interp, mainwin, name, (char *)NULL);
+ tkwin = Tk_CreateWindowFromPath(interp, mainwin, name, (char *) NULL);
if (tkwin == NULL) {
- return TCL_ERROR;
+ return TCL_ERROR;
}
Tk_SetClass(tkwin, "Togl");
/* Create Togl data structure */
- togl = (Togl *) malloc(sizeof(Togl));
+ togl = (Togl *) malloc(sizeof (Togl));
if (!togl) {
- return TCL_ERROR;
+ return TCL_ERROR;
}
togl->Next = NULL;
@@ -1501,9 +1502,8 @@
/* Create command event handler */
togl->widgetCmd = Tcl_CreateCommand(interp, Tk_PathName(tkwin),
- Togl_Widget, (ClientData) togl,
- (Tcl_CmdDeleteProc *)
- ToglCmdDeletedProc);
+ Togl_Widget, (ClientData) togl,
+ (Tcl_CmdDeleteProc *) ToglCmdDeletedProc);
/*
* Setup the Tk_ClassProcs callbacks to point at our own window creation
* function
@@ -1514,43 +1514,42 @@
#ifdef HAVE_TK_SETCLASSPROCS
- if (SetClassProcsPtr != NULL) { /* use public API (Tk 8.4+) */
- Tk_ClassProcs *procsPtr;
+ if (SetClassProcsPtr != NULL) { /* use public API (Tk 8.4+) */
+ Tk_ClassProcs *procsPtr;
- procsPtr = (Tk_ClassProcs *) Tcl_Alloc(sizeof(Tk_ClassProcs));
- procsPtr->size = sizeof(Tk_ClassProcs);
- procsPtr->createProc = Togl_CreateWindow;
- procsPtr->worldChangedProc = Togl_WorldChanged;
- procsPtr->modalProc = NULL;
- /* Tk_SetClassProcs(togl->TkWin,procsPtr,(ClientData)togl); */
- (SetClassProcsPtr) (togl->TkWin, procsPtr, (ClientData) togl);
- }
- else
+ procsPtr = (Tk_ClassProcs *) Tcl_Alloc(sizeof (Tk_ClassProcs));
+ procsPtr->size = sizeof (Tk_ClassProcs);
+ procsPtr->createProc = Togl_CreateWindow;
+ procsPtr->worldChangedProc = Togl_WorldChanged;
+ procsPtr->modalProc = NULL;
+ /* Tk_SetClassProcs(togl->TkWin,procsPtr,(ClientData)togl); */
+ (SetClassProcsPtr) (togl->TkWin, procsPtr, (ClientData) togl);
+ } else
#endif
- { /* use private API */
- /*
- * We need to set these fields in the Tk_FakeWin structure: dummy17 =
- * classProcsPtr dummy18 = instanceData */
- TkClassProcs *procsPtr;
- Tk_FakeWin *winPtr = (Tk_FakeWin *) (togl->TkWin);
+ { /* use private API */
+ /*
+ * We need to set these fields in the Tk_FakeWin structure: dummy17 =
+ * classProcsPtr dummy18 = instanceData */
+ TkClassProcs *procsPtr;
+ Tk_FakeWin *winPtr = (Tk_FakeWin *) (togl->TkWin);
- procsPtr = (TkClassProcs *) Tcl_Alloc(sizeof(TkClassProcs));
- procsPtr->createProc = Togl_CreateWindow;
- procsPtr->geometryProc = Togl_WorldChanged;
- procsPtr->modalProc = NULL;
- winPtr->dummy17 = (char *)procsPtr;
- winPtr->dummy18 = (ClientData) togl;
+ procsPtr = (TkClassProcs *) Tcl_Alloc(sizeof (TkClassProcs));
+ procsPtr->createProc = Togl_CreateWindow;
+ procsPtr->geometryProc = Togl_WorldChanged;
+ procsPtr->modalProc = NULL;
+ winPtr->dummy17 = (char *) procsPtr;
+ winPtr->dummy18 = (ClientData) togl;
}
Tk_CreateEventHandler(tkwin,
- ExposureMask | StructureNotifyMask, Togl_EventProc,
- (ClientData) togl);
+ ExposureMask | StructureNotifyMask, Togl_EventProc,
+ (ClientData) togl);
/* Configure Togl widget */
if (Togl_Configure(interp, togl, argc - 2, argv + 2, 0) == TCL_ERROR) {
- Tk_DestroyWindow(tkwin);
- Tcl_AppendResult(interp, "Couldn't configure togl widget\n", NULL);
- goto error;
+ Tk_DestroyWindow(tkwin);
+ Tcl_AppendResult(interp, "Couldn't configure togl widget\n", NULL);
+ goto error;
}
/*
@@ -1560,34 +1559,34 @@
*/
if (!
#if defined(TOGL_WGL)
- togl->tglGLHdc
+ togl->tglGLHdc
#elif defined(TOGL_X11)
- togl->GlCtx
+ togl->GlCtx
#elif defined(TOGL_AGL_CLASSIC) || defined(TOGL_AGL)
- togl->aglCtx
+ togl->aglCtx
#endif
- ) {
- Tk_MakeWindowExist(togl->TkWin);
- if (Tk_WindowId(togl->TkWin) == DUMMY_WINDOW) {
- return TCL_ERROR;
- }
- Togl_MakeCurrent(togl);
+ ) {
+ Tk_MakeWindowExist(togl->TkWin);
+ if (Tk_WindowId(togl->TkWin) == DUMMY_WINDOW) {
+ return TCL_ERROR;
+ }
+ Togl_MakeCurrent(togl);
}
/* If defined, call create callback */
if (togl->CreateProc) {
- togl->CreateProc(togl);
+ togl->CreateProc(togl);
}
/* If defined, call reshape proc */
if (togl->ReshapeProc) {
- togl->ReshapeProc(togl);
+ togl->ReshapeProc(togl);
}
/* If defined, setup timer */
if (togl->TimerProc) {
- (void)Tk_CreateTimerHandler(togl->TimerInterval, Togl_Timer,
- (ClientData) togl);
+ (void) Tk_CreateTimerHandler(togl->TimerInterval, Togl_Timer,
+ (ClientData) togl);
}
Tcl_AppendResult(interp, Tk_PathName(tkwin), NULL);
@@ -1598,7 +1597,7 @@
return TCL_OK;
error:
- (void)Tcl_DeleteCommand(interp, "togl");
+ (void) Tcl_DeleteCommand(interp, "togl");
/* free(togl); Don't free it, if we do a crash occurs later... */
return TCL_ERROR;
}
@@ -1610,22 +1609,23 @@
* Do all the setup for overlay planes
* Return: TCL_OK or TCL_ERROR
*/
-static int SetupOverlay(Togl * togl)
+static int
+SetupOverlay(Togl *togl)
{
# if defined(TOGL_X11)
# ifdef GLX_TRANSPARENT_TYPE_EXT
static int ovAttributeList[] = {
- GLX_BUFFER_SIZE, 2,
- GLX_LEVEL, 1,
- GLX_TRANSPARENT_TYPE_EXT, GLX_TRANSPARENT_INDEX_EXT,
- None
+ GLX_BUFFER_SIZE, 2,
+ GLX_LEVEL, 1,
+ GLX_TRANSPARENT_TYPE_EXT, GLX_TRANSPARENT_INDEX_EXT,
+ None
};
# else
static int ovAttributeList[] = {
- GLX_BUFFER_SIZE, 2,
- GLX_LEVEL, 1,
- None
+ GLX_BUFFER_SIZE, 2,
+ GLX_LEVEL, 1,
+ None
};
# endif
@@ -1635,51 +1635,49 @@
XSetWindowAttributes swa;
Tcl_HashEntry *hPtr;
- int new_flag;
+ int new_flag;
dpy = Tk_Display(togl->TkWin);
visinfo = glXChooseVisual(dpy, Tk_ScreenNumber(winPtr), ovAttributeList);
if (!visinfo) {
- Tcl_AppendResult(togl->Interp, Tk_PathName(winPtr),
- ": No suitable overlay index visual available",
- (char *)NULL);
- togl->OverlayCtx = 0;
- togl->OverlayWindow = 0;
- togl->OverlayCmap = 0;
- return TCL_ERROR;
+ Tcl_AppendResult(togl->Interp, Tk_PathName(winPtr),
+ ": No suitable overlay index visual available", (char *) NULL);
+ togl->OverlayCtx = 0;
+ togl->OverlayWindow = 0;
+ togl->OverlayCmap = 0;
+ return TCL_ERROR;
}
# ifdef GLX_TRANSPARENT_INDEX_EXT
{
- int fail = glXGetConfig(dpy, visinfo, GLX_TRANSPARENT_INDEX_VALUE_EXT,
- &togl->OverlayTransparentPixel);
+ int fail =
+ glXGetConfig(dpy, visinfo, GLX_TRANSPARENT_INDEX_VALUE_EXT,
+ &togl->OverlayTransparentPixel);
- if (fail)
- togl->OverlayTransparentPixel = 0; /* maybe, maybe ... */
+ if (fail)
+ togl->OverlayTransparentPixel = 0; /* maybe, maybe ... */
}
# else
- togl->OverlayTransparentPixel = 0; /* maybe, maybe ... */
+ togl->OverlayTransparentPixel = 0; /* maybe, maybe ... */
# endif
/* share display lists with normal layer context */
togl->OverlayCtx =
- glXCreateContext(dpy, visinfo, togl->GlCtx, !togl->Indirect);
+ glXCreateContext(dpy, visinfo, togl->GlCtx, !togl->Indirect);
swa.colormap = XCreateColormap(dpy, XRootWindow(dpy, visinfo->screen),
- visinfo->visual, AllocNone);
+ visinfo->visual, AllocNone);
togl->OverlayCmap = swa.colormap;
swa.border_pixel = 0;
swa.event_mask = ALL_EVENTS_MASK;
togl->OverlayWindow = XCreateWindow(dpy, Tk_WindowId(togl->TkWin), 0, 0,
- togl->Width, togl->Height, 0,
- visinfo->depth, InputOutput,
- visinfo->visual,
- CWBorderPixel | CWColormap |
- CWEventMask, &swa);
+ togl->Width, togl->Height, 0,
+ visinfo->depth, InputOutput,
+ visinfo->visual, CWBorderPixel | CWColormap | CWEventMask, &swa);
hPtr = Tcl_CreateHashEntry(&winPtr->dispPtr->winTable,
- (char *)togl->OverlayWindow, &new_flag);
+ (char *) togl->OverlayWindow, &new_flag);
Tcl_SetHashValue(hPtr, winPtr);
/* XMapWindow( dpy, togl->OverlayWindow ); */
@@ -1707,41 +1705,41 @@
static LRESULT CALLBACK
Win32WinProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
- LONG result;
- Togl *togl = (Togl *) GetWindowLong(hwnd, 0);
+ LONG result;
+ Togl *togl = (Togl *) GetWindowLong(hwnd, 0);
WNDCLASS childClass;
switch (message) {
- case WM_WINDOWPOSCHANGED:
- /* Should be processed by DefWindowProc, otherwise a double buffered
- * context is not properly resized when the corresponding window is
- * resized. */
- break;
- case WM_DESTROY:
- if (togl->tglGLHglrc) {
- wglDeleteContext(togl->tglGLHglrc);
- }
- if (togl->tglGLHdc) {
- ReleaseDC(hwnd, togl->tglGLHdc);
- }
- free(togl);
- break;
- default:
+ case WM_WINDOWPOSCHANGED:
+ /* Should be processed by DefWindowProc, otherwise a double buffered
+ * context is not properly resized when the corresponding window is
+ * resized. */
+ break;
+ case WM_DESTROY:
+ if (togl->tglGLHglrc) {
+ wglDeleteContext(togl->tglGLHglrc);
+ }
+ if (togl->tglGLHdc) {
+ ReleaseDC(hwnd, togl->tglGLHdc);
+ }
+ free(togl);
+ break;
+ default:
# if USE_STATIC_LIB
- return TkWinChildProc(hwnd, message, wParam, lParam);
+ return TkWinChildProc(hwnd, message, wParam, lParam);
# else
- /*
- * OK, since TkWinChildProc is not explicitly exported in the
- * dynamic libraries, we have to retrieve it from the class info
- * registered with windows.
- *
- */
- if (tkWinChildProc == NULL) {
- GetClassInfo(Tk_GetHINSTANCE(), TK_WIN_CHILD_CLASS_NAME,
- &childClass);
- tkWinChildProc = childClass.lpfnWndProc;
- }
- return tkWinChildProc(hwnd, message, wParam, lParam);
+ /*
+ * OK, since TkWinChildProc is not explicitly exported in the
+ * dynamic libraries, we have to retrieve it from the class info
+ * registered with windows.
+ *
+ */
+ if (tkWinChildProc == NULL) {
+ GetClassInfo(Tk_GetHINSTANCE(), TK_WIN_CHILD_CLASS_NAME,
+ &childClass);
+ tkWinChildProc = childClass.lpfnWndProc;
+ }
+ return tkWinChildProc(hwnd, message, wParam, lParam);
# endif
}
result = DefWindowProc(hwnd, message, wParam, lParam);
@@ -1762,37 +1760,37 @@
Togl_CreateWindow(Tk_Window tkwin, Window parent, ClientData instanceData)
{
- Togl *togl = (Togl *) instanceData;
+ Togl *togl = (Togl *) instanceData;
XVisualInfo *visinfo = NULL;
Display *dpy;
Colormap cmap;
- int scrnum;
- Window window;
+ int scrnum;
+ Window window;
#if defined(TOGL_X11)
- Bool directCtx = True;
- int attrib_list[1000];
- int attrib_count;
- int dummy;
+ Bool directCtx = True;
+ int attrib_list[1000];
+ int attrib_count;
+ int dummy;
XSetWindowAttributes swa;
# define MAX_ATTEMPTS 12
static int ci_depths[MAX_ATTEMPTS] = {
- 8, 4, 2, 1, 12, 16, 8, 4, 2, 1, 12, 16
+ 8, 4, 2, 1, 12, 16, 8, 4, 2, 1, 12, 16
};
static int dbl_flags[MAX_ATTEMPTS] = {
- 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1
+ 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1
};
#elif defined(TOGL_WGL)
- HWND hwnd, parentWin;
- int pixelformat;
- HANDLE hInstance;
+ HWND hwnd, parentWin;
+ int pixelformat;
+ HANDLE hInstance;
WNDCLASS ToglClass;
PIXELFORMATDESCRIPTOR pfd;
XVisualInfo VisInf;
#elif defined(TOGL_AGL_CLASSIC) || defined(TOGL_AGL)
- GLint attribs[20];
- int na;
+ GLint attribs[20];
+ int na;
AGLPixelFormat fmt;
XVisualInfo VisInf;
#endif /* TOGL_X11 */
@@ -1803,163 +1801,158 @@
#if defined(TOGL_X11)
/* Make sure OpenGL's GLX extension supported */
if (!glXQueryExtension(dpy, &dummy, &dummy)) {
- Tcl_SetResult(togl->Interp,
- TCL_STUPID "Togl: X server has no OpenGL GLX extension",
- TCL_STATIC);
- return DUMMY_WINDOW;
+ Tcl_SetResult(togl->Interp,
+ TCL_STUPID "Togl: X server has no OpenGL GLX extension",
+ TCL_STATIC);
+ return DUMMY_WINDOW;
}
if (togl->ShareContext && FindTogl(togl->ShareContext)) {
- /* share OpenGL context with existing Togl widget */
- Togl *shareWith = FindTogl(togl->ShareContext);
+ /* share OpenGL context with existing Togl widget */
+ Togl *shareWith = FindTogl(togl->ShareContext);
- assert(shareWith != NULL);
- assert(shareWith->GlCtx != NULL);
- togl->GlCtx = shareWith->GlCtx;
- togl->VisInfo = shareWith->VisInfo;
- visinfo = togl->VisInfo;
- }
- else {
- if (togl->PixelFormat) {
- XVisualInfo template;
- int count = 1;
+ assert(shareWith != NULL);
+ assert(shareWith->GlCtx != NULL);
+ togl->GlCtx = shareWith->GlCtx;
+ togl->VisInfo = shareWith->VisInfo;
+ visinfo = togl->VisInfo;
+ } else {
+ if (togl->PixelFormat) {
+ XVisualInfo template;
+ int count = 1;
- template.visualid = togl->PixelFormat;
- visinfo = XGetVisualInfo(dpy, VisualIDMask, &template, &count);
- if (visinfo == NULL) {
- Tcl_SetResult(togl->Interp,
- TCL_STUPID "Togl: couldn't choose pixel format",
- TCL_STATIC);
+ template.visualid = togl->PixelFormat;
+ visinfo = XGetVisualInfo(dpy, VisualIDMask, &template, &count);
+ if (visinfo == NULL) {
+ Tcl_SetResult(togl->Interp,
+ TCL_STUPID "Togl: couldn't choose pixel format",
+ TCL_STATIC);
- return DUMMY_WINDOW;
- }
- /* fill in flags normally passed in that affect behavior */
- (void)glXGetConfig(dpy, visinfo, GLX_RGBA, &togl->RgbaFlag);
- (void)glXGetConfig(dpy, visinfo, GLX_DOUBLEBUFFER,
- &togl->DoubleFlag);
- (void)glXGetConfig(dpy, visinfo, GLX_STEREO, &togl->StereoFlag);
- }
- else {
- int attempt;
+ return DUMMY_WINDOW;
+ }
+ /* fill in flags normally passed in that affect behavior */
+ (void) glXGetConfig(dpy, visinfo, GLX_RGBA, &togl->RgbaFlag);
+ (void) glXGetConfig(dpy, visinfo, GLX_DOUBLEBUFFER,
+ &togl->DoubleFlag);
+ (void) glXGetConfig(dpy, visinfo, GLX_STEREO, &togl->StereoFlag);
+ } else {
+ int attempt;
- /* It may take a few tries to get a visual */
- for (attempt = 0; attempt < MAX_ATTEMPTS; attempt++) {
- attrib_count = 0;
- attrib_list[attrib_count++] = GLX_USE_GL;
- if (togl->RgbaFlag) {
- /* RGB[A] mode */
- attrib_list[attrib_count++] = GLX_RGBA;
- attrib_list[attrib_count++] = GLX_RED_SIZE;
- attrib_list[attrib_count++] = togl->RgbaRed;
- attrib_list[attrib_count++] = GLX_GREEN_SIZE;
- attrib_list[attrib_count++] = togl->RgbaGreen;
- attrib_list[attrib_count++] = GLX_BLUE_SIZE;
- attrib_list[attrib_count++] = togl->RgbaBlue;
- if (togl->AlphaFlag) {
- attrib_list[attrib_count++] = GLX_ALPHA_SIZE;
- attrib_list[attrib_count++] = togl->AlphaSize;
- }
+ /* It may take a few tries to get a visual */
+ for (attempt = 0; attempt < MAX_ATTEMPTS; attempt++) {
+ attrib_count = 0;
+ attrib_list[attrib_count++] = GLX_USE_GL;
+ if (togl->RgbaFlag) {
+ /* RGB[A] mode */
+ attrib_list[attrib_count++] = GLX_RGBA;
+ attrib_list[attrib_count++] = GLX_RED_SIZE;
+ attrib_list[attrib_count++] = togl->RgbaRed;
+ attrib_list[attrib_count++] = GLX_GREEN_SIZE;
+ attrib_list[attrib_count++] = togl->RgbaGreen;
+ attrib_list[attrib_count++] = GLX_BLUE_SIZE;
+ attrib_list[attrib_count++] = togl->RgbaBlue;
+ if (togl->AlphaFlag) {
+ attrib_list[attrib_count++] = GLX_ALPHA_SIZE;
+ attrib_list[attrib_count++] = togl->AlphaSize;
+ }
- /* for EPS Output */
- if (togl->EpsRedMap)
- free(togl->EpsRedMap);
- if (togl->EpsGreenMap)
- free(togl->EpsGreenMap);
- if (togl->EpsBlueMap)
- free(togl->EpsBlueMap);
- togl->EpsRedMap = togl->EpsGreenMap = togl->EpsBlueMap =
- NULL;
- togl->EpsMapSize = 0;
- }
- else {
- /* Color index mode */
- int depth;
+ /* for EPS Output */
+ if (togl->EpsRedMap)
+ free(togl->EpsRedMap);
+ if (togl->EpsGreenMap)
+ free(togl->EpsGreenMap);
+ if (togl->EpsBlueMap)
+ free(togl->EpsBlueMap);
+ togl->EpsRedMap = togl->EpsGreenMap = togl->EpsBlueMap =
+ NULL;
+ togl->EpsMapSize = 0;
+ } else {
+ /* Color index mode */
+ int depth;
- attrib_list[attrib_count++] = GLX_BUFFER_SIZE;
- depth = ci_depths[attempt];
- attrib_list[attrib_count++] = depth;
- }
- if (togl->DepthFlag) {
- attrib_list[attrib_count++] = GLX_DEPTH_SIZE;
- attrib_list[attrib_count++] = togl->DepthSize;
- }
- if (togl->DoubleFlag || dbl_flags[attempt]) {
- attrib_list[attrib_count++] = GLX_DOUBLEBUFFER;
- }
- if (togl->StencilFlag) {
- attrib_list[attrib_count++] = GLX_STENCIL_SIZE;
- attrib_list[attrib_count++] = togl->StencilSize;
- }
- if (togl->AccumFlag) {
- attrib_list[attrib_count++] = GLX_ACCUM_RED_SIZE;
- attrib_list[attrib_count++] = togl->AccumRed;
- attrib_list[attrib_count++] = GLX_ACCUM_GREEN_SIZE;
- attrib_list[attrib_count++] = togl->AccumGreen;
- attrib_list[attrib_count++] = GLX_ACCUM_BLUE_SIZE;
- attrib_list[attrib_count++] = togl->AccumBlue;
- if (togl->AlphaFlag) {
- attrib_list[attrib_count++] = GLX_ACCUM_ALPHA_SIZE;
- attrib_list[attrib_count++] = togl->AccumAlpha;
- }
- }
- if (togl->AuxNumber != 0) {
- attrib_list[attrib_count++] = GLX_AUX_BUFFERS;
- attrib_list[attrib_count++] = togl->AuxNumber;
- }
- if (togl->Indirect) {
- directCtx = False;
- }
+ attrib_list[attrib_count++] = GLX_BUFFER_SIZE;
+ depth = ci_depths[attempt];
+ attrib_list[attrib_count++] = depth;
+ }
+ if (togl->DepthFlag) {
+ attrib_list[attrib_count++] = GLX_DEPTH_SIZE;
+ attrib_list[attrib_count++] = togl->DepthSize;
+ }
+ if (togl->DoubleFlag || dbl_flags[attempt]) {
+ attrib_list[attrib_count++] = GLX_DOUBLEBUFFER;
+ }
+ if (togl->StencilFlag) {
+ attrib_list[attrib_count++] = GLX_STENCIL_SIZE;
+ attrib_list[attrib_count++] = togl->StencilSize;
+ }
+ if (togl->AccumFlag) {
+ attrib_list[attrib_count++] = GLX_ACCUM_RED_SIZE;
+ attrib_list[attrib_count++] = togl->AccumRed;
+ attrib_list[attrib_count++] = GLX_ACCUM_GREEN_SIZE;
+ attrib_list[attrib_count++] = togl->AccumGreen;
+ attrib_list[attrib_count++] = GLX_ACCUM_BLUE_SIZE;
+ attrib_list[attrib_count++] = togl->AccumBlue;
+ if (togl->AlphaFlag) {
+ attrib_list[attrib_count++] = GLX_ACCUM_ALPHA_SIZE;
+ attrib_list[attrib_count++] = togl->AccumAlpha;
+ }
+ }
+ if (togl->AuxNumber != 0) {
+ attrib_list[attrib_count++] = GLX_AUX_BUFFERS;
+ attrib_list[attrib_count++] = togl->AuxNumber;
+ }
+ if (togl->Indirect) {
+ directCtx = False;
+ }
- if (togl->StereoFlag) {
- attrib_list[attrib_count++] = GLX_STEREO;
- }
- attrib_list[attrib_count++] = None;
+ if (togl->StereoFlag) {
+ attrib_list[attrib_count++] = GLX_STEREO;
+ }
+ attrib_list[attrib_count++] = None;
- visinfo = glXChooseVisual(dpy, Tk_ScreenNumber(togl->TkWin),
- attrib_list);
- if (visinfo) {
- /* found a GLX visual! */
- break;
- }
- }
+ visinfo = glXChooseVisual(dpy, Tk_ScreenNumber(togl->TkWin),
+ attrib_list);
+ if (visinfo) {
+ /* found a GLX visual! */
+ break;
+ }
+ }
- togl->VisInfo = visinfo;
+ togl->VisInfo = visinfo;
- if (visinfo == NULL) {
- Tcl_SetResult(togl->Interp,
- TCL_STUPID "Togl: couldn't get visual",
- TCL_STATIC);
- return DUMMY_WINDOW;
- }
+ if (visinfo == NULL) {
+ Tcl_SetResult(togl->Interp,
+ TCL_STUPID "Togl: couldn't get visual", TCL_STATIC);
+ return DUMMY_WINDOW;
+ }
- /*
- * Create a new OpenGL rendering context.
- */
- if (togl->ShareList) {
- /* share display lists with existing togl widget */
- Togl *shareWith = FindTogl(togl->ShareList);
- GLXContext shareCtx;
+ /*
+ * Create a new OpenGL rendering context.
+ */
+ if (togl->ShareList) {
+ /* share display lists with existing togl widget */
+ Togl *shareWith = FindTogl(togl->ShareList);
+ GLXContext shareCtx;
- if (shareWith)
- shareCtx = shareWith->GlCtx;
- else
- shareCtx = None;
- togl->GlCtx =
- glXCreateContext(dpy, visinfo, shareCtx, directCtx);
- }
- else {
- /* don't share display lists */
- togl->GlCtx = glXCreateContext(dpy, visinfo, None, directCtx);
- }
+ if (shareWith)
+ shareCtx = shareWith->GlCtx;
+ else
+ shareCtx = None;
+ togl->GlCtx =
+ glXCreateContext(dpy, visinfo, shareCtx, directCtx);
+ } else {
+ /* don't share display lists */
+ togl->GlCtx = glXCreateContext(dpy, visinfo, None, directCtx);
+ }
- if (togl->GlCtx == NULL) {
- Tcl_SetResult(togl->Interp,
- TCL_STUPID "could not create rendering context",
- TCL_STATIC);
- return DUMMY_WINDOW;
- }
+ if (togl->GlCtx == NULL) {
+ Tcl_SetResult(togl->Interp,
+ TCL_STUPID "could not create rendering context",
+ TCL_STATIC);
+ return DUMMY_WINDOW;
+ }
- }
+ }
}
@@ -1969,132 +1962,125 @@
parentWin = Tk_GetHWND(parent);
hInstance = Tk_GetHINSTANCE();
if (!ToglClassInitialized) {
- ToglClassInitialized = True;
- ToglClass.style = CS_HREDRAW | CS_VREDRAW;
- ToglClass.cbClsExtra = 0;
- ToglClass.cbWndExtra = 4; /* to save struct Togl* */
- ToglClass.hInstance = hInstance;
- ToglClass.hbrBackground = NULL;
- ToglClass.lpszMenuName = NULL;
- ToglClass.lpszClassName = TOGL_CLASS_NAME;
- ToglClass.lpfnWndProc = Win32WinProc;
- ToglClass.hIcon = NULL;
- ToglClass.hCursor = NULL;
- if (!RegisterClass(&ToglClass)) {
- Tcl_SetResult(togl->Interp,
- TCL_STUPID "unable register Togl window class",
- TCL_STATIC);
- return DUMMY_WINDOW;
- }
+ ToglClassInitialized = True;
+ ToglClass.style = CS_HREDRAW | CS_VREDRAW;
+ ToglClass.cbClsExtra = 0;
+ ToglClass.cbWndExtra = 4; /* to save struct Togl* */
+ ToglClass.hInstance = hInstance;
+ ToglClass.hbrBackground = NULL;
+ ToglClass.lpszMenuName = NULL;
+ ToglClass.lpszClassName = TOGL_CLASS_NAME;
+ ToglClass.lpfnWndProc = Win32WinProc;
+ ToglClass.hIcon = NULL;
+ ToglClass.hCursor = NULL;
+ if (!RegisterClass(&ToglClass)) {
+ Tcl_SetResult(togl->Interp,
+ TCL_STUPID "unable register Togl window class", TCL_STATIC);
+ return DUMMY_WINDOW;
+ }
}
hwnd = CreateWindow(TOGL_CLASS_NAME, NULL,
- WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS, 0, 0,
- togl->Width, togl->Height, parentWin, NULL, hInstance,
- NULL);
+ WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS, 0, 0,
+ togl->Width, togl->Height, parentWin, NULL, hInstance, NULL);
SetWindowLong(hwnd, 0, (LONG) togl);
SetWindowPos(hwnd, HWND_TOP, 0, 0, 0, 0,
- SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE);
+ SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE);
togl->tglGLHdc = GetDC(hwnd);
- pfd.nSize = sizeof(PIXELFORMATDESCRIPTOR);
+ pfd.nSize = sizeof (PIXELFORMATDESCRIPTOR);
pfd.nVersion = 1;
pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL;
if (togl->DoubleFlag) {
- pfd.dwFlags |= PFD_DOUBLEBUFFER;
+ pfd.dwFlags |= PFD_DOUBLEBUFFER;
}
/* The stereo flag is not supported in the current generic OpenGL
* implementation, but may be supported by specific hardware devices. */
if (togl->StereoFlag) {
- pfd.dwFlags |= PFD_STEREO;
+ pfd.dwFlags |= PFD_STEREO;
}
if (togl->PixelFormat) {
- pixelformat = togl->PixelFormat;
- }
- else {
- pfd.cColorBits = togl->RgbaRed + togl->RgbaGreen + togl->RgbaBlue;
- pfd.iPixelType = togl->RgbaFlag ? PFD_TYPE_RGBA : PFD_TYPE_COLORINDEX;
- /* Alpha bitplanes are not supported in the current generic OpenGL
- * implementation, but may be supported by specific hardware devices. */
- pfd.cAlphaBits = togl->AlphaFlag ? togl->AlphaSize : 0;
- pfd.cAccumBits =
- togl->AccumFlag ? (togl->AccumRed + togl->AccumGreen +
- togl->AccumBlue + togl->AccumAlpha) : 0;
- pfd.cDepthBits = togl->DepthFlag ? togl->DepthSize : 0;
- pfd.cStencilBits = togl->StencilFlag ? togl->StencilSize : 0;
- /* Auxiliary buffers are not supported in the current generic OpenGL
- * implementation, but may be supported by specific hardware devices. */
- pfd.cAuxBuffers = togl->AuxNumber;
- pfd.iLayerType = PFD_MAIN_PLANE;
+ pixelformat = togl->PixelFormat;
+ } else {
+ pfd.cColorBits = togl->RgbaRed + togl->RgbaGreen + togl->RgbaBlue;
+ pfd.iPixelType = togl->RgbaFlag ? PFD_TYPE_RGBA : PFD_TYPE_COLORINDEX;
+ /* Alpha bitplanes are not supported in the current generic OpenGL
+ * implementation, but may be supported by specific hardware devices. */
+ pfd.cAlphaBits = togl->AlphaFlag ? togl->AlphaSize : 0;
+ pfd.cAccumBits = togl->AccumFlag ? (togl->AccumRed + togl->AccumGreen +
+ togl->AccumBlue + togl->AccumAlpha) : 0;
+ pfd.cDepthBits = togl->DepthFlag ? togl->DepthSize : 0;
+ pfd.cStencilBits = togl->StencilFlag ? togl->StencilSize : 0;
+ /* Auxiliary buffers are not supported in the current generic OpenGL
+ * implementation, but may be supported by specific hardware devices. */
+ pfd.cAuxBuffers = togl->AuxNumber;
+ pfd.iLayerType = PFD_MAIN_PLANE;
- if ((pixelformat = ChoosePixelFormat(togl->tglGLHdc, &pfd)) == 0) {
- Tcl_SetResult(togl->Interp,
- TCL_STUPID "Togl: couldn't choose pixel format",
- TCL_STATIC);
- return DUMMY_WINDOW;
- }
+ if ((pixelformat = ChoosePixelFormat(togl->tglGLHdc, &pfd)) == 0) {
+ Tcl_SetResult(togl->Interp,
+ TCL_STUPID "Togl: couldn't choose pixel format",
+ TCL_STATIC);
+ return DUMMY_WINDOW;
+ }
}
if (SetPixelFormat(togl->tglGLHdc, pixelformat, &pfd) == FALSE) {
- Tcl_SetResult(togl->Interp,
- TCL_STUPID "Togl: couldn't choose pixel format",
- TCL_STATIC);
- return DUMMY_WINDOW;
+ Tcl_SetResult(togl->Interp,
+ TCL_STUPID "Togl: couldn't choose pixel format", TCL_STATIC);
+ return DUMMY_WINDOW;
}
/* Get the actual pixel format */
- DescribePixelFormat(togl->tglGLHdc, pixelformat, sizeof(pfd), &pfd);
+ DescribePixelFormat(togl->tglGLHdc, pixelformat, sizeof (pfd), &pfd);
if (togl->PixelFormat) {
- /* fill in flags normally passed in that affect behavior */
- togl->RgbaFlag = pfd.iPixelType == PFD_TYPE_RGBA;
- togl->DoubleFlag = pfd.cDepthBits > 0;
- togl->StereoFlag = (pfd.dwFlags & PFD_STEREO) != 0;
- // TODO: set depth flag, and more
+ /* fill in flags normally passed in that affect behavior */
+ togl->RgbaFlag = pfd.iPixelType == PFD_TYPE_RGBA;
+ togl->DoubleFlag = pfd.cDepthBits > 0;
+ togl->StereoFlag = (pfd.dwFlags & PFD_STEREO) != 0;
+ // TODO: set depth flag, and more
+ } else if (togl->StereoFlag && (pfd.dwFlags & PFD_STEREO) == 0) {
+ Tcl_SetResult(togl->Interp,
+ TCL_STUPID "Togl: couldn't choose stereo pixel format",
+ TCL_STATIC);
+ return DUMMY_WINDOW;
}
- else if (togl->StereoFlag && (pfd.dwFlags & PFD_STEREO) == 0) {
- Tcl_SetResult(togl->Interp,
- TCL_STUPID "Togl: couldn't choose stereo pixel format",
- TCL_STATIC);
- return DUMMY_WINDOW;
- }
if (togl->ShareContext && FindTogl(togl->ShareContext)) {
- /* share OpenGL context with existing Togl widget */
- Togl *shareWith = FindTogl(togl->ShareContext);
+ /* share OpenGL context with existing Togl widget */
+ Togl *shareWith = FindTogl(togl->ShareContext);
- assert(shareWith);
- assert(shareWith->tglGLHglrc);
- togl->tglGLHglrc = shareWith->tglGLHglrc;
- togl->VisInfo = shareWith->VisInfo;
- visinfo = togl->VisInfo;
- }
- else {
- /*
- * Create a new OpenGL rendering context. And check to share lists.
- */
- togl->tglGLHglrc = wglCreateContext(togl->tglGLHdc);
+ assert(shareWith);
+ assert(shareWith->tglGLHglrc);
+ togl->tglGLHglrc = shareWith->tglGLHglrc;
+ togl->VisInfo = shareWith->VisInfo;
+ visinfo = togl->VisInfo;
+ } else {
+ /*
+ * Create a new OpenGL rendering context. And check to share lists.
+ */
+ togl->tglGLHglrc = wglCreateContext(togl->tglGLHdc);
- if (togl->ShareList) {
- /* share display lists with existing togl widget */
- Togl *shareWith = FindTogl(togl->ShareList);
+ if (togl->ShareList) {
+ /* share display lists with existing togl widget */
+ Togl *shareWith = FindTogl(togl->ShareList);
- if (shareWith)
- wglShareLists(shareWith->tglGLHglrc, togl->tglGLHglrc);
- }
+ if (shareWith)
+ wglShareLists(shareWith->tglGLHglrc, togl->tglGLHglrc);
+ }
- if (!togl->tglGLHglrc) {
- Tcl_SetResult(togl->Interp,
- TCL_STUPID "could not create rendering context",
- TCL_STATIC);
- return DUMMY_WINDOW;
- }
+ if (!togl->tglGLHglrc) {
+ Tcl_SetResult(togl->Interp,
+ TCL_STUPID "could not create rendering context",
+ TCL_STATIC);
+ return DUMMY_WINDOW;
+ }
- /* Just for portability, define the simplest visinfo */
- visinfo = &VisInf;
- visinfo->visual = DefaultVisual(dpy, DefaultScreen(dpy));
- visinfo->depth = visinfo->visual->bits_per_rgb;
- togl->VisInfo = visinfo;
+ /* Just for portability, define the simplest visinfo */
+ visinfo = &VisInf;
+ visinfo->visual = DefaultVisual(dpy, DefaultScreen(dpy));
+ visinfo->depth = visinfo->visual->bits_per_rgb;
+ togl->VisInfo = visinfo;
}
#endif /* TOGL_WGL */
@@ -2105,78 +2091,74 @@
*/
scrnum = Tk_ScreenNumber(togl->TkWin);
if (togl->RgbaFlag) {
- /* Colormap for RGB mode */
+ /* Colormap for RGB mode */
#if defined(TOGL_X11)
- cmap = get_rgb_colormap(dpy, scrnum, visinfo, togl->TkWin);
+ cmap = get_rgb_colormap(dpy, scrnum, visinfo, togl->TkWin);
#elif defined(TOGL_WGL)
- if (pfd.dwFlags & PFD_NEED_PALETTE) {
- cmap = Win32CreateRgbColormap(pfd);
- }
- else {
- cmap = DefaultColormap(dpy, scrnum);
- }
- /* for EPS Output */
- if (togl->EpsRedMap)
- free(togl->EpsRedMap);
- if (togl->EpsGreenMap)
- free(togl->EpsGreenMap);
- if (togl->EpsBlueMap)
- free(togl->EpsBlueMap);
- togl->EpsRedMap = togl->EpsGreenMap = togl->EpsBlueMap = NULL;
- togl->EpsMapSize = 0;
+ if (pfd.dwFlags & PFD_NEED_PALETTE) {
+ cmap = Win32CreateRgbColormap(pfd);
+ } else {
+ cmap = DefaultColormap(dpy, scrnum);
+ }
+ /* for EPS Output */
+ if (togl->EpsRedMap)
+ free(togl->EpsRedMap);
+ if (togl->EpsGreenMap)
+ free(togl->EpsGreenMap);
+ if (togl->EpsBlueMap)
+ free(togl->EpsBlueMap);
+ togl->EpsRedMap = togl->EpsGreenMap = togl->EpsBlueMap = NULL;
+ togl->EpsMapSize = 0;
#elif defined(TOGL_AGL_CLASSIC) || defined(TOGL_AGL)
- cmap = DefaultColormap(dpy, scrnum);
- /* for EPS Output */
- if (togl->EpsRedMap)
- free(togl->EpsRedMap);
- if (togl->EpsGreenMap)
- free(togl->EpsGreenMap);
- if (togl->EpsBlueMap)
- free(togl->EpsBlueMap);
- togl->EpsRedMap = togl->EpsGreenMap = togl->EpsBlueMap = NULL;
- togl->EpsMapSize = 0;
+ cmap = DefaultColormap(dpy, scrnum);
+ /* for EPS Output */
+ if (togl->EpsRedMap)
+ free(togl->EpsRedMap);
+ if (togl->EpsGreenMap)
+ free(togl->EpsGreenMap);
+ if (togl->EpsBlueMap)
+ free(togl->EpsBlueMap);
+ togl->EpsRedMap = togl->EpsGreenMap = togl->EpsBlueMap = NULL;
+ togl->EpsMapSize = 0;
#endif /* TOGL_X11 */
- }
- else {
- /* Colormap for CI mode */
+ } else {
+ /* Colormap for CI mode */
#ifdef TOGL_WGL
- togl->CiColormapSize = 1 << pfd.cColorBits;
- togl->CiColormapSize = togl->CiColormapSize < MAX_CI_COLORMAP_SIZE ?
- togl->CiColormapSize : MAX_CI_COLORMAP_SIZE;
+ togl->CiColormapSize = 1 << pfd.cColorBits;
+ togl->CiColormapSize = togl->CiColormapSize < MAX_CI_COLORMAP_SIZE ?
+ togl->CiColormapSize : MAX_CI_COLORMAP_SIZE;
#endif /* TOGL_WGL */
- if (togl->PrivateCmapFlag) {
- /* need read/write colormap so user can store own color entries */
+ if (togl->PrivateCmapFlag) {
+ /* need read/write colormap so user can store own color entries */
#if defined(TOGL_X11)
- cmap = XCreateColormap(dpy, XRootWindow(dpy, visinfo->screen),
- visinfo->visual, AllocAll);
+ cmap = XCreateColormap(dpy, XRootWindow(dpy, visinfo->screen),
+ visinfo->visual, AllocAll);
#elif defined(TOGL_WGL)
- cmap = Win32CreateCiColormap(togl);
+ cmap = Win32CreateCiColormap(togl);
#elif defined(TOGL_AGL_CLASSIC) || defined(TOGL_AGL)
- /* need to figure out how to do this correctly on Mac... */
- cmap = DefaultColormap(dpy, scrnum);
+ /* need to figure out how to do this correctly on Mac... */
+ cmap = DefaultColormap(dpy, scrnum);
#endif /* TOGL_X11 */
- }
- else {
- if (visinfo->visual == DefaultVisual(dpy, scrnum)) {
- /* share default/root colormap */
- cmap = Tk_Colormap(togl->TkWin);
- }
- else {
- /* make a new read-only colormap */
- cmap = XCreateColormap(dpy, XRootWindow(dpy, visinfo->screen),
- visinfo->visual, AllocNone);
- }
- }
+ } else {
+ if (visinfo->visual == DefaultVisual(dpy, scrnum)) {
+ /* share default/root colormap */
+ cmap = Tk_Colormap(togl->TkWin);
+ } else {
+ /* make a new read-only colormap */
+ cmap = XCreateColormap(dpy, XRootWindow(dpy, visinfo->screen),
+ visinfo->visual, AllocNone);
+ }
+ }
}
#if !defined(TOGL_AGL)
/* Make sure Tk knows to switch to the new colormap when the cursor is over
* this window when running in color index mode. */
- (void)Tk_SetWindowVisual(togl->TkWin, visinfo->visual, visinfo->depth,
- cmap);
+ (void) Tk_SetWindowVisual(togl->TkWin, visinfo->visual, visinfo->depth,
+ cmap);
#endif
#ifdef TOGL_WGL
@@ -2190,238 +2172,232 @@
swa.border_pixel = 0;
swa.event_mask = ALL_EVENTS_MASK;
window = XCreateWindow(dpy, parent,
- 0, 0, togl->Width, togl->Height,
- 0, visinfo->depth,
- InputOutput, visinfo->visual,
- CWBorderPixel | CWColormap | CWEventMask, &swa);
+ 0, 0, togl->Width, togl->Height,
+ 0, visinfo->depth,
+ InputOutput, visinfo->visual,
+ CWBorderPixel | CWColormap | CWEventMask, &swa);
/* Make sure window manager installs our colormap */
- (void)XSetWMColormapWindows(dpy, window, &window, 1);
+ (void) XSetWMColormapWindows(dpy, window, &window, 1);
#elif defined(TOGL_WGL)
window = Tk_AttachHWND(togl->TkWin, hwnd);
#elif defined(TOGL_AGL_CLASSIC) || defined(TOGL_AGL)
{
- TkWindow *winPtr = (TkWindow *) togl->TkWin;
+ TkWindow *winPtr = (TkWindow *) togl->TkWin;
- window = TkpMakeWindow(winPtr, parent);
+ window = TkpMakeWindow(winPtr, parent);
}
#endif /* TOGL_X11 */
#ifdef USE_OVERLAY
if (togl->OverlayFlag) {
- if (SetupOverlay(togl) == TCL_ERROR) {
- fprintf(stderr, "Warning: couldn't setup overlay.\n");
- togl->OverlayFlag = False;
- }
+ if (SetupOverlay(togl) == TCL_ERROR) {
+ fprintf(stderr, "Warning: couldn't setup overlay.\n");
+ togl->OverlayFlag = False;
+ }
}
#endif /* USE_OVERLAY */
/* Request the X window to be displayed */
- (void)XMapWindow(dpy, window);
+ (void) XMapWindow(dpy, window);
#if defined(TOGL_AGL_CLASSIC) || defined(TOGL_AGL)
if (togl->ShareContext && FindTogl(togl->ShareContext)) {
- /* share OpenGL context with existing Togl widget */
- Togl *shareWith = FindTogl(togl->ShareContext);
+ /* share OpenGL context with existing Togl widget */
+ Togl *shareWith = FindTogl(togl->ShareContext);
- assert(shareWith);
- assert(shareWith->aglCtx);
- togl->aglCtx = shareWith->aglCtx;
- togl->VisInfo = shareWith->VisInfo;
- visinfo = togl->VisInfo;
+ assert(shareWith);
+ assert(shareWith->aglCtx);
+ togl->aglCtx = shareWith->aglCtx;
+ togl->VisInfo = shareWith->VisInfo;
+ visinfo = togl->VisInfo;
- }
- else {
- AGLContext shareCtx = NULL;
+ } else {
+ AGLContext shareCtx = NULL;
- if (togl->PixelFormat) {
- /* fill in RgbaFlag, DoubleFlag, and StereoFlag */
- fmt = (AGLPixelFormat) togl->PixelFormat;
- GLint has_rgba, has_doublebuf, has_stereo;
+ if (togl->PixelFormat) {
+ /* fill in RgbaFlag, DoubleFlag, and StereoFlag */
+ fmt = (AGLPixelFormat) togl->PixelFormat;
+ GLint has_rgba, has_doublebuf, has_stereo;
- if (aglDescribePixelFormat(fmt, AGL_RGBA, &has_rgba) &&
- aglDescribePixelFormat(fmt, AGL_DOUBLEBUFFER, &has_doublebuf)
- && aglDescribePixelFormat(fmt, AGL_STEREO, &has_stereo)) {
- togl->RgbaFlag = (has_rgba ? True : False);
- togl->DoubleFlag = (has_doublebuf ? True : False);
- togl->StereoFlag = (has_stereo ? True : False);
- }
- else {
- Tcl_SetResult(togl->Interp,
- TCL_STUPID
- "Togl: failed querying pixel format attributes",
- TCL_STATIC);
- return DUMMY_WINDOW;
- }
- }
- else {
+ if (aglDescribePixelFormat(fmt, AGL_RGBA, &has_rgba) &&
+ aglDescribePixelFormat(fmt, AGL_DOUBLEBUFFER,
+ &has_doublebuf)
+ && aglDescribePixelFormat(fmt, AGL_STEREO, &has_stereo)) {
+ togl->RgbaFlag = (has_rgba ? True : False);
+ togl->DoubleFlag = (has_doublebuf ? True : False);
+ togl->StereoFlag = (has_stereo ? True : False);
+ } else {
+ Tcl_SetResult(togl->Interp,
+ TCL_STUPID
+ "Togl: failed querying pixel format attributes",
+ TCL_STATIC);
+ return DUMMY_WINDOW;
+ }
+ } else {
- /* Need to do this after mapping window, so MacDrawable structure
- * is more completely filled in */
- na = 0;
- attribs[na++] = AGL_MINIMUM_POLICY;
- attribs[na++] = AGL_ROBUST;
- if (togl->RgbaFlag) {
- /* RGB[A] mode */
- attribs[na++] = AGL_RGBA;
- attribs[na++] = AGL_RED_SIZE;
- attribs[na++] = togl->RgbaRed;
- attribs[na++] = AGL_GREEN_SIZE;
- attribs[na++] = togl->RgbaGreen;
- attribs[na++] = AGL_BLUE_SIZE;
- attribs[na++] = togl->RgbaBlue;
- if (togl->AlphaFlag) {
- attribs[na++] = AGL_ALPHA_SIZE;
- attribs[na++] = togl->AlphaSize;
- }
- }
- else {
- /* Color index mode */
- attribs[na++] = AGL_BUFFER_SIZE;
- attribs[na++] = 8;
- }
- if (togl->DepthFlag) {
- attribs[na++] = AGL_DEPTH_SIZE;
- attribs[na++] = togl->DepthSize;
- }
- if (togl->DoubleFlag) {
- attribs[na++] = AGL_DOUBLEBUFFER;
- }
- if (togl->StencilFlag) {
- attribs[na++] = AGL_STENCIL_SIZE;
- attribs[na++] = togl->StencilSize;
- }
- if (togl->AccumFlag) {
- attribs[na++] = AGL_ACCUM_RED_SIZE;
- attribs[na++] = togl->AccumRed;
- attribs[na++] = AGL_ACCUM_GREEN_SIZE;
- attribs[na++] = togl->AccumGreen;
- attribs[na++] = AGL_ACCUM_BLUE_SIZE;
- attribs[na++] = togl->AccumBlue;
- if (togl->AlphaFlag) {
- attribs[na++] = AGL_ACCUM_ALPHA_SIZE;
- attribs[na++] = togl->AccumAlpha;
- }
- }
- if (togl->AuxNumber != 0) {
- attribs[na++] = AGL_AUX_BUFFERS;
- attribs[na++] = togl->AuxNumber;
- }
- attribs[na++] = AGL_NONE;
+ /* Need to do this after mapping window, so MacDrawable structure
+ * is more completely filled in */
+ na = 0;
+ attribs[na++] = AGL_MINIMUM_POLICY;
+ attribs[na++] = AGL_ROBUST;
+ if (togl->RgbaFlag) {
+ /* RGB[A] mode */
+ attribs[na++] = AGL_RGBA;
+ attribs[na++] = AGL_RED_SIZE;
+ attribs[na++] = togl->RgbaRed;
+ attribs[na++] = AGL_GREEN_SIZE;
+ attribs[na++] = togl->RgbaGreen;
+ attribs[na++] = AGL_BLUE_SIZE;
+ attribs[na++] = togl->RgbaBlue;
+ if (togl->AlphaFlag) {
+ attribs[na++] = AGL_ALPHA_SIZE;
+ attribs[na++] = togl->AlphaSize;
+ }
+ } else {
+ /* Color index mode */
+ attribs[na++] = AGL_BUFFER_SIZE;
+ attribs[na++] = 8;
+ }
+ if (togl->DepthFlag) {
+ attribs[na++] = AGL_DEPTH_SIZE;
+ attribs[na++] = togl->DepthSize;
+ }
+ if (togl->DoubleFlag) {
+ attribs[na++] = AGL_DOUBLEBUFFER;
+ }
+ if (togl->StencilFlag) {
+ attribs[na++] = AGL_STENCIL_SIZE;
+ attribs[na++] = togl->StencilSize;
+ }
+ if (togl->AccumFlag) {
+ attribs[na++] = AGL_ACCUM_RED_SIZE;
+ attribs[na++] = togl->AccumRed;
+ attribs[na++] = AGL_ACCUM_GREEN_SIZE;
+ attribs[na++] = togl->AccumGreen;
+ attribs[na++] = AGL_ACCUM_BLUE_SIZE;
+ attribs[na++] = togl->AccumBlue;
+ if (togl->AlphaFlag) {
+ attribs[na++] = AGL_ACCUM_ALPHA_SIZE;
+ attribs[na++] = togl->AccumAlpha;
+ }
+ }
+ if (togl->AuxNumber != 0) {
+ attribs[na++] = AGL_AUX_BUFFERS;
+ attribs[na++] = togl->AuxNumber;
+ }
+ attribs[na++] = AGL_NONE;
- if ((fmt = aglChoosePixelFormat(NULL, 0, attribs)) == NULL) {
- Tcl_SetResult(togl->Interp,
- TCL_STUPID "Togl: couldn't choose pixel format",
- TCL_STATIC);
- return DUMMY_WINDOW;
- }
- }
+ if ((fmt = aglChoosePixelFormat(NULL, 0, attribs)) == NULL) {
+ Tcl_SetResult(togl->Interp,
+ TCL_STUPID "Togl: couldn't choose pixel format",
+ TCL_STATIC);
+ return DUMMY_WINDOW;
+ }
+ }
- /*
- * Check whether to share lists.
- */
- if (togl->ShareList) {
- /* share display lists with existing togl widget */
- Togl *shareWith = FindTogl(togl->ShareList);
+ /*
+ * Check whether to share lists.
+ */
+ if (togl->ShareList) {
+ /* share display lists with existing togl widget */
+ Togl *shareWith = FindTogl(togl->ShareList);
- if (shareWith)
- shareCtx = shareWith->aglCtx;
- }
- if ((togl->aglCtx = aglCreateContext(fmt, shareCtx)) == NULL) {
- GLenum err = aglGetError();
+ if (shareWith)
+ shareCtx = shareWith->aglCtx;
+ }
+ if ((togl->aglCtx = aglCreateContext(fmt, shareCtx)) == NULL) {
+ GLenum err = aglGetError();
- aglDestroyPixelFormat(fmt);
- if (err == AGL_BAD_MATCH)
- Tcl_SetResult(togl->Interp,
- TCL_STUPID
- "Togl: couldn't create context, shared context doesn't match",
- TCL_STATIC);
- else if (err == AGL_BAD_CONTEXT)
- Tcl_SetResult(togl->Interp,
- TCL_STUPID
- "Togl: couldn't create context, bad shared context",
- TCL_STATIC);
- else if (err == AGL_BAD_PIXELFMT)
- Tcl_SetResult(togl->Interp,
- TCL_STUPID
- "Togl: couldn't create context, bad pixel format",
- TCL_STATIC);
- else
- Tcl_SetResult(togl->Interp,
- TCL_STUPID
- "Togl: couldn't create context, unknown reason",
- TCL_STATIC);
- return DUMMY_WINDOW;
- }
+ aglDestroyPixelFormat(fmt);
+ if (err == AGL_BAD_MATCH)
+ Tcl_SetResult(togl->Interp,
+ TCL_STUPID
+ "Togl: couldn't create context, shared context doesn't match",
+ TCL_STATIC);
+ else if (err == AGL_BAD_CONTEXT)
+ Tcl_SetResult(togl->Interp,
+ TCL_STUPID
+ "Togl: couldn't create context, bad shared context",
+ TCL_STATIC);
+ else if (err == AGL_BAD_PIXELFMT)
+ Tcl_SetResult(togl->Interp,
+ TCL_STUPID
+ "Togl: couldn't create context, bad pixel format",
+ TCL_STATIC);
+ else
+ Tcl_SetResult(togl->Interp,
+ TCL_STUPID
+ "Togl: couldn't create context, unknown reason",
+ TCL_STATIC);
+ return DUMMY_WINDOW;
+ }
- aglDestroyPixelFormat(fmt);
- if (!aglSetDrawable(togl->aglCtx,
+ aglDestroyPixelFormat(fmt);
+ if (!aglSetDrawable(togl->aglCtx,
# if defined(TOGL_AGL)
- ((MacDrawable *) (window))->toplevel->grafPtr
+ ((MacDrawable *) (window))->toplevel->grafPtr
# else
- ((MacDrawable *) (window))->toplevel->portPtr
+ ((MacDrawable *) (window))->toplevel->portPtr
# endif
- )) {
- aglDestroyContext(togl->aglCtx);
- Tcl_SetResult(togl->Interp,
- TCL_STUPID "Togl: couldn't set drawable",
- TCL_STATIC);
- return DUMMY_WINDOW;
- }
+ )) {
+ aglDestroyContext(togl->aglCtx);
+ Tcl_SetResult(togl->Interp,
+ TCL_STUPID "Togl: couldn't set drawable", TCL_STATIC);
+ return DUMMY_WINDOW;
+ }
- /* Just for portability, define the simplest visinfo */
- visinfo = &VisInf;
- visinfo->visual = DefaultVisual(dpy, DefaultScreen(dpy));
- visinfo->depth = visinfo->visual->bits_per_rgb;
+ /* Just for portability, define the simplest visinfo */
+ visinfo = &VisInf;
+ visinfo->visual = DefaultVisual(dpy, DefaultScreen(dpy));
+ visinfo->depth = visinfo->visual->bits_per_rgb;
- Tk_SetWindowVisual(togl->TkWin, visinfo->visual, visinfo->depth,
- cmap);
+ Tk_SetWindowVisual(togl->TkWin, visinfo->visual, visinfo->depth, cmap);
}
#endif /* TOGL_AGL_CLASSIC || TOGL_AGL */
#if defined(TOGL_X11)
/* Check for a single/double buffering snafu */
{
- int dbl_flag;
+ int dbl_flag;
- if (glXGetConfig(dpy, visinfo, GLX_DOUBLEBUFFER, &dbl_flag)) {
- if (!togl->DoubleFlag && dbl_flag) {
- /* We requested single buffering but had to accept a */
- /* double buffered visual. Set the GL draw buffer to */
- /* be the front buffer to simulate single buffering. */
- glDrawBuffer(GL_FRONT);
- }
- }
+ if (glXGetConfig(dpy, visinfo, GLX_DOUBLEBUFFER, &dbl_flag)) {
+ if (!togl->DoubleFlag && dbl_flag) {
+ /* We requested single buffering but had to accept a */
+ /* double buffered visual. Set the GL draw buffer to */
+ /* be the front buffer to simulate single buffering. */
+ glDrawBuffer(GL_FRONT);
+ }
+ }
}
#endif /* TOGL_X11 */
/* for EPS Output */
if (!togl->RgbaFlag) {
- int index_size;
+ int index_size;
#if defined(TOGL_X11) || defined(TOGL_AGL_CLASSIC) || defined(TOGL_AGL)
- GLint index_bits;
+ GLint index_bits;
- glGetIntegerv(GL_INDEX_BITS, &index_bits);
- index_size = 1 << index_bits;
+ glGetIntegerv(GL_INDEX_BITS, &index_bits);
+ index_size = 1 << index_bits;
#elif defined(TOGL_WGL)
- index_size = togl->CiColormapSize;
+ index_size = togl->CiColormapSize;
#endif /* TOGL_X11 */
- if (togl->EpsMapSize != index_size) {
- if (togl->EpsRedMap)
- free(togl->EpsRedMap);
- if (togl->EpsGreenMap)
- free(togl->EpsGreenMap);
- if (togl->EpsBlueMap)
- free(togl->EpsBlueMap);
- togl->EpsMapSize = index_size;
- togl->EpsRedMap = (GLfloat *) calloc(index_size, sizeof(GLfloat));
- togl->EpsGreenMap =
- (GLfloat *) calloc(index_size, sizeof(GLfloat));
- togl->EpsBlueMap =
- (GLfloat *) calloc(index_size, sizeof(GLfloat));
- }
+ if (togl->EpsMapSize != index_size) {
+ if (togl->EpsRedMap)
+ free(togl->EpsRedMap);
+ if (togl->EpsGreenMap)
+ free(togl->EpsGreenMap);
+ if (togl->EpsBlueMap)
+ free(togl->EpsBlueMap);
+ togl->EpsMapSize = index_size;
+ togl->EpsRedMap = (GLfloat *) calloc(index_size, sizeof (GLfloat));
+ togl->EpsGreenMap =
+ (GLfloat *) calloc(index_size, sizeof (GLfloat));
+ togl->EpsBlueMap = (GLfloat *) calloc(index_size, sizeof (GLfloat));
+ }
}
return window;
@@ -2432,20 +2408,19 @@
*
* Add support for setgrid option.
*/
-static void Togl_WorldChanged(ClientData instanceData)
+static void
+Togl_WorldChanged(ClientData instanceData)
{
- Togl *togl = (Togl *) instanceData;
+ Togl *togl = (Togl *) instanceData;
Tk_GeometryRequest(togl->TkWin, togl->Width, togl->Height);
Tk_SetInternalBorder(togl->TkWin, 0);
if (togl->SetGrid > 0) {
- Tk_SetGrid(togl->TkWin, togl->Width / togl->SetGrid,
- togl->Height / togl->SetGrid, togl->SetGrid,
- togl->SetGrid);
+ Tk_SetGrid(togl->TkWin, togl->Width / togl->SetGrid,
+ togl->Height / togl->SetGrid, togl->SetGrid, togl->SetGrid);
+ } else {
+ Tk_UnsetGrid(togl->TkWin);
}
- else {
- Tk_UnsetGrid(togl->TkWin);
- }
}
/*
@@ -2463,9 +2438,10 @@
*
*----------------------------------------------------------------------
*/
-static void ToglCmdDeletedProc(ClientData clientData)
+static void
+ToglCmdDeletedProc(ClientData clientData)
{
- Togl *togl = (Togl *) clientData;
+ Togl *togl = (Togl *) clientData;
Tk_Window tkwin = togl->TkWin;
/*
@@ -2476,40 +2452,40 @@
*/
if (togl && tkwin) {
- Tk_DeleteEventHandler(tkwin,
- ExposureMask | StructureNotifyMask,
- Togl_EventProc, (ClientData) togl);
+ Tk_DeleteEventHandler(tkwin,
+ ExposureMask | StructureNotifyMask,
+ Togl_EventProc, (ClientData) togl);
}
#if defined(TOGL_X11)
if (togl->GlCtx) {
- if (FindToglWithSameContext(togl) == NULL)
- glXDestroyContext(togl->display, togl->GlCtx);
- togl->GlCtx = NULL;
+ if (FindToglWithSameContext(togl) == NULL)
+ glXDestroyContext(togl->display, togl->GlCtx);
+ togl->GlCtx = NULL;
}
# ifdef USE_OVERLAY
if (togl->OverlayCtx) {
- Tcl_HashEntry *entryPtr;
- TkWindow *winPtr = (TkWindow *) togl->TkWin;
+ Tcl_HashEntry *entryPtr;
+ TkWindow *winPtr = (TkWindow *) togl->TkWin;
- if (winPtr) {
- entryPtr = Tcl_FindHashEntry(&winPtr->dispPtr->winTable,
- (char *)togl->OverlayWindow);
- Tcl_DeleteHashEntry(entryPtr);
- }
- if (FindToglWithSameOverlayContext(togl) == NULL)
- glXDestroyContext(togl->display, togl->OverlayCtx);
- togl->OverlayCtx = NULL;
+ if (winPtr) {
+ entryPtr = Tcl_FindHashEntry(&winPtr->dispPtr->winTable,
+ (char *) togl->OverlayWindow);
+ Tcl_DeleteHashEntry(entryPtr);
+ }
+ if (FindToglWithSameOverlayContext(togl) == NULL)
+ glXDestroyContext(togl->display, togl->OverlayCtx);
+ togl->OverlayCtx = NULL;
}
# endif /* USE_OVERLAY */
#endif
/* TODO: delete contexts on other platforms */
if (tkwin != NULL) {
- if (togl->SetGrid > 0) {
- Tk_UnsetGrid(tkwin);
- }
- togl->TkWin = NULL;
- Tk_DestroyWindow(tkwin);
+ if (togl->SetGrid > 0) {
+ Tk_UnsetGrid(tkwin);
+ }
+ togl->TkWin = NULL;
+ Tk_DestroyWindow(tkwin);
}
}
@@ -2519,25 +2495,26 @@
*
* Gets called when an Togl widget is destroyed.
*/
-static void Togl_Destroy(
+static void
+Togl_Destroy(
#if (TK_MAJOR_VERSION * 100 + TK_MINOR_VERSION) >= 401
- char *
+ char *
#else
- ClientData
+ ClientData
#endif
- clientData)
+ clientData)
{
- Togl *togl = (Togl *) clientData;
+ Togl *togl = (Togl *) clientData;
Tk_FreeOptions(configSpecs, WIDGREC togl, togl->display, 0);
#ifndef NO_TK_CURSOR
if (togl->Cursor != None) {
- Tk_FreeCursor(togl->display, togl->Cursor);
+ Tk_FreeCursor(togl->display, togl->Cursor);
}
#endif
if (togl->DestroyProc) {
- togl->DestroyProc(togl);
+ togl->DestroyProc(togl);
}
/* remove from linked list */
@@ -2554,184 +2531,188 @@
/*
* This gets called to handle Togl window configuration events
*/
-static void Togl_EventProc(ClientData clientData, XEvent * eventPtr)
+static void
+Togl_EventProc(ClientData clientData, XEvent *eventPtr)
{
- Togl *togl = (Togl *) clientData;
+ Togl *togl = (Togl *) clientData;
switch (eventPtr->type) {
- case Expose:
- if (eventPtr->xexpose.count == 0) {
- if (!togl->UpdatePending
- && eventPtr->xexpose.window == Tk_WindowId(togl->TkWin)) {
- Togl_PostRedisplay(togl);
- }
+ case Expose:
+ if (eventPtr->xexpose.count == 0) {
+ if (!togl->UpdatePending
+ && eventPtr->xexpose.window == Tk_WindowId(togl->TkWin)) {
+ Togl_PostRedisplay(togl);
+ }
#if defined(TOGL_X11)
- if (!togl->OverlayUpdatePending && togl->OverlayFlag
- && togl->OverlayIsMapped
- && eventPtr->xexpose.window == togl->OverlayWindow) {
- Togl_PostOverlayRedisplay(togl);
- }
+ if (!togl->OverlayUpdatePending && togl->OverlayFlag
+ && togl->OverlayIsMapped
+ && eventPtr->xexpose.window == togl->OverlayWindow) {
+ Togl_PostOverlayRedisplay(togl);
+ }
#endif /* TOGL_X11 */
- }
- break;
- case ConfigureNotify:
- if (togl->Width != Tk_Width(togl->TkWin)
- || togl->Height != Tk_Height(togl->TkWin)) {
- togl->Width = Tk_Width(togl->TkWin);
- togl->Height = Tk_Height(togl->TkWin);
- (void)XResizeWindow(Tk_Display(togl->TkWin),
- Tk_WindowId(togl->TkWin), togl->Width,
- togl->Height);
+ }
+ break;
+ case ConfigureNotify:
+ if (togl->Width != Tk_Width(togl->TkWin)
+ || togl->Height != Tk_Height(togl->TkWin)) {
+ togl->Width = Tk_Width(togl->TkWin);
+ togl->Height = Tk_Height(togl->TkWin);
+ (void) XResizeWindow(Tk_Display(togl->TkWin),
+ Tk_WindowId(togl->TkWin), togl->Width, togl->Height);
#if defined(TOGL_X11)
- if (togl->OverlayFlag) {
- (void)XResizeWindow(Tk_Display(togl->TkWin),
- togl->OverlayWindow, togl->Width,
- togl->Height);
- (void)XRaiseWindow(Tk_Display(togl->TkWin),
- togl->OverlayWindow);
- }
+ if (togl->OverlayFlag) {
+ (void) XResizeWindow(Tk_Display(togl->TkWin),
+ togl->OverlayWindow, togl->Width, togl->Height);
+ (void) XRaiseWindow(Tk_Display(togl->TkWin),
+ togl->OverlayWindow);
+ }
#endif /* TOGL_X11 */
- Togl_MakeCurrent(togl);
- if (togl->ReshapeProc) {
- togl->ReshapeProc(togl);
- }
- else {
- glViewport(0, 0, togl->Width, togl->Height);
+ Togl_MakeCurrent(togl);
+ if (togl->ReshapeProc) {
+ togl->ReshapeProc(togl);
+ } else {
+ glViewport(0, 0, togl->Width, togl->Height);
#if defined(TOGL_X11)
- if (togl->OverlayFlag) {
- Togl_UseLayer(togl, TOGL_OVERLAY);
- glViewport(0, 0, togl->Width, togl->Height);
- Togl_UseLayer(togl, TOGL_NORMAL);
- }
+ if (togl->OverlayFlag) {
+ Togl_UseLayer(togl, TOGL_OVERLAY);
+ glViewport(0, 0, togl->Width, togl->Height);
+ Togl_UseLayer(togl, TOGL_NORMAL);
+ }
#endif /* TOGL_X11 */
- }
-#ifndef TOGL_WGL /* causes double redisplay on Win32 platform */
- Togl_PostRedisplay(togl);
+ }
+#ifndef TOGL_WGL /* causes double redisplay on Win32 platform */
+ Togl_PostRedisplay(togl);
#endif /* TOGL_WGL */
- }
- break;
- case MapNotify:
+ }
+ break;
+ case MapNotify:
#if defined(TOGL_AGL)
- {
- /*
- * See comment for the UnmapNotify case below.
- */
- AGLDrawable d = TkMacOSXGetDrawablePort(Tk_WindowId(togl->TkWin));
+ {
+ /*
+ * See comment for the UnmapNotify case below.
+ */
+ AGLDrawable d = TkMacOSXGetDrawablePort(Tk_WindowId(togl->TkWin));
- aglSetDrawable(togl->aglCtx, d);
- }
+ aglSetDrawable(togl->aglCtx, d);
+ }
#endif /* TOGL_AGL */
- break;
- case UnmapNotify:
+ break;
+ case UnmapNotify:
#if defined(TOGL_AGL)
- {
- /*
- * For Mac OS X Aqua, Tk subwindows are not implemented as
- * separate Aqua windows. They are just different regions of
- * a single Aqua window. To unmap them they are just not drawn.
- * Have to disconnect the AGL context otherwise they will continue
- * to be displayed directly by Aqua.
- */
- aglSetDrawable(togl->aglCtx, NULL);
- }
+ {
+ /*
+ * For Mac OS X Aqua, Tk subwindows are not implemented as
+ * separate Aqua windows. They are just different regions of
+ * a single Aqua window. To unmap them they are just not drawn.
+ * Have to disconnect the AGL context otherwise they will continue
+ * to be displayed directly by Aqua.
+ */
+ aglSetDrawable(togl->aglCtx, NULL);
+ }
#endif /* TOGL_AGL */
- break;
- case DestroyNotify:
- if (togl->TkWin != NULL) {
- if (togl->SetGrid > 0) {
- Tk_UnsetGrid(togl->TkWin);
- }
- togl->TkWin = NULL;
+ break;
+ case DestroyNotify:
+ if (togl->TkWin != NULL) {
+ if (togl->SetGrid > 0) {
+ Tk_UnsetGrid(togl->TkWin);
+ }
+ togl->TkWin = NULL;
#if (TCL_MAJOR_VERSION * 100 + TCL_MINOR_VERSION) >= 800
- /* This function new in Tcl/Tk 8.0 */
- (void)Tcl_DeleteCommandFromToken(togl->Interp, togl->widgetCmd);
+ /* This function new in Tcl/Tk 8.0 */
+ (void) Tcl_DeleteCommandFromToken(togl->Interp, togl->widgetCmd);
#endif
- }
- if (togl->TimerProc != NULL) {
+ }
+ if (togl->TimerProc != NULL) {
#if (TK_MAJOR_VERSION * 100 + TK_MINOR_VERSION) >= 401
- Tcl_DeleteTimerHandler(togl->timerHandler);
+ Tcl_DeleteTimerHandler(togl->timerHandler);
#else
- Tk_DeleteTimerHandler(togl->timerHandler);
+ Tk_DeleteTimerHandler(togl->timerHandler);
#endif
- }
- if (togl->UpdatePending) {
+ }
+ if (togl->UpdatePending) {
#if (TCL_MAJOR_VERSION * 100 + TCL_MINOR_VERSION) >= 705
- Tcl_CancelIdleCall(Togl_Render