[GRASS-SVN] r32528 - grass/trunk/visualization/nviz/src
svn_grass at osgeo.org
svn_grass at osgeo.org
Mon Aug 4 18:32:57 EDT 2008
Author: glynn
Date: 2008-08-04 18:32:56 -0400 (Mon, 04 Aug 2008)
New Revision: 32528
Modified:
grass/trunk/visualization/nviz/src/togl.c
grass/trunk/visualization/nviz/src/togl.h
Log:
Don't "indent" Togl; it contains constructs which confuse indent (and
isn't our code, either).
Modified: grass/trunk/visualization/nviz/src/togl.c
===================================================================
--- grass/trunk/visualization/nviz/src/togl.c 2008-08-04 21:59:51 UTC (rev 32527)
+++ grass/trunk/visualization/nviz/src/togl.c 2008-08-04 22:32:56 UTC (rev 32528)
@@ -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,24 +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
@@ -687,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);
@@ -753,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;
@@ -770,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
@@ -788,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
@@ -809,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);
@@ -850,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;
}
@@ -859,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;
}
@@ -868,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;
}
@@ -877,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;
}
@@ -886,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;
}
@@ -895,7 +895,8 @@
/*
* Reset default callback pointers to NULL.
*/
-void Togl_ResetDefaultCallbacks(void)
+void
+Togl_ResetDefaultCallbacks(void)
{
DefaultCreateProc = NULL;
DefaultDisplayProc = NULL;
@@ -910,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;
}
@@ -919,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;
}
@@ -928,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;
}
@@ -937,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;
}
@@ -948,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
}
}
@@ -975,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
}
}
@@ -1000,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);
@@ -1016,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
}
@@ -1047,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);
@@ -1095,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;
}
@@ -1196,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)
@@ -1282,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);
@@ -1410,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;
@@ -1500,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
@@ -1513,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;
}
/*
@@ -1559,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);
@@ -1597,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;
}
@@ -1609,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
@@ -1634,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 ); */
@@ -1706,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);
@@ -1761,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 */
@@ -1802,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;
+ }
- }
+ }
}
@@ -1968,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 */
@@ -2104,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
@@ -2189,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;
@@ -2431,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);
- }
}
/*
@@ -2462,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;
/*
@@ -2475,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);
}
}
@@ -2518,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 */
@@ -2553,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, (ClientData) togl);
+ Tcl_CancelIdleCall(Togl_Render, (ClientData) togl);
#else
- Tk_CancelIdleCall(Togl_Render, (ClientData) togl);
+ Tk_CancelIdleCall(Togl_Render, (ClientData) togl);
#endif
- }
+ }
#if (TK_MAJOR_VERSION * 100 + TK_MINOR_VERSION) >= 401
- Tcl_EventuallyFree((ClientData) togl, Togl_Destroy);
+ Tcl_EventuallyFree((ClientData) togl, Togl_Destroy);
#else
- Tk_EventuallyFree((ClientData) togl, Togl_Destroy);
+ Tk_EventuallyFree((ClientData) togl, Togl_Destroy);
#endif
- break;
- default:
- /* nothing */
- ;
+ break;
+ default:
+ /* nothing */
+ ;
}
}
-void Togl_PostRedisplay(Togl * togl)
+void
+Togl_PostRedisplay(Togl *togl)
{
if (!togl->UpdatePending) {
- togl->UpdatePending = True;
- Tk_DoWhenIdle(Togl_Render, (ClientData) togl);
+ togl->UpdatePending = True;
+ Tk_DoWhenIdle(Togl_Render, (ClientData) togl);
}
}
-void Togl_SwapBuffers(const Togl * togl)
+void
+Togl_SwapBuffers(const Togl *togl)
{
if (togl->DoubleFlag) {
#if defined(TOGL_WGL)
- int res = SwapBuffers(togl->tglGLHdc);
+ int res = SwapBuffers(togl->tglGLHdc);
- assert(res == TRUE);
+ assert(res == TRUE);
#elif defined(TOGL_X11)
- glXSwapBuffers(Tk_Display(togl->TkWin), Tk_WindowId(togl->TkWin));
+ glXSwapBuffers(Tk_Display(togl->TkWin), Tk_WindowId(togl->TkWin));
#elif defined(TOGL_AGL_CLASSIC) || defined(TOGL_AGL)
- aglSwapBuffers(togl->aglCtx);
+ aglSwapBuffers(togl->aglCtx);
#endif /* TOGL_WGL */
+ } else {
+ glFlush();
}
- else {
- glFlush();
- }
}
-const char *Togl_Ident(const Togl * togl)
+const char *
+Togl_Ident(const Togl *togl)
{
return togl->Ident;
}
-int Togl_Width(const Togl * togl)
+int
+Togl_Width(const Togl *togl)
{
return togl->Width;
}
-int Togl_Height(const Togl * togl)
+int
+Togl_Height(const Togl *togl)
{
return togl->Height;
}
-Tcl_Interp *Togl_Interp(const Togl * togl)
+Tcl_Interp *
+Togl_Interp(const Togl *togl)
{
return togl->Interp;
}
-Tk_Window Togl_TkWin(const Togl * togl)
+Tk_Window
+Togl_TkWin(const Togl *togl)
{
return togl->TkWin;
}
@@ -2751,40 +2733,40 @@
* Output: exact - 1=exact color match, 0=closest match
*/
static void
-noFaultXAllocColor(Display * dpy, Colormap cmap, int cmapSize,
- XColor * color, int *exact)
+noFaultXAllocColor(Display *dpy, Colormap cmap, int cmapSize,
+ XColor *color, int *exact)
{
XColor *ctable, subColor;
- int i, bestmatch;
- double mindist; /* 3*2^16^2 exceeds long int precision. */
+ int i, bestmatch;
+ double mindist; /* 3*2^16^2 exceeds long int precision. */
/* First try just using XAllocColor. */
if (XAllocColor(dpy, cmap, color)) {
- *exact = 1;
- return;
+ *exact = 1;
+ return;
}
/* Retrieve color table entries. */
/* XXX alloca candidate. */
- ctable = (XColor *) malloc(cmapSize * sizeof(XColor));
+ ctable = (XColor *) malloc(cmapSize * sizeof (XColor));
for (i = 0; i < cmapSize; i++) {
- ctable[i].pixel = i;
+ ctable[i].pixel = i;
}
- (void)XQueryColors(dpy, cmap, ctable, cmapSize);
+ (void) XQueryColors(dpy, cmap, ctable, cmapSize);
/* Find best match. */
bestmatch = -1;
mindist = 0;
for (i = 0; i < cmapSize; i++) {
- double dr = (double)color->red - (double)ctable[i].red;
- double dg = (double)color->green - (double)ctable[i].green;
- double db = (double)color->blue - (double)ctable[i].blue;
- double dist = dr * dr + dg * dg + db * db;
+ double dr = (double) color->red - (double) ctable[i].red;
+ double dg = (double) color->green - (double) ctable[i].green;
+ double db = (double) color->blue - (double) ctable[i].blue;
+ double dist = dr * dr + dg * dg + db * db;
- if (bestmatch < 0 || dist < mindist) {
- bestmatch = i;
- mindist = dist;
- }
+ if (bestmatch < 0 || dist < mindist) {
+ bestmatch = i;
+ mindist = dist;
+ }
}
/* Return result. */
@@ -2796,12 +2778,12 @@
* cell is read/write. Otherwise, we're incrementing the cell's reference
* count. */
if (!XAllocColor(dpy, cmap, &subColor)) {
- /* do this to work around a problem reported by Frank Ortega */
- subColor.pixel = (unsigned long)bestmatch;
- subColor.red = ctable[bestmatch].red;
- subColor.green = ctable[bestmatch].green;
- subColor.blue = ctable[bestmatch].blue;
- subColor.flags = DoRed | DoGreen | DoBlue;
+ /* do this to work around a problem reported by Frank Ortega */
+ subColor.pixel = (unsigned long) bestmatch;
+ subColor.red = ctable[bestmatch].red;
+ subColor.green = ctable[bestmatch].green;
+ subColor.blue = ctable[bestmatch].blue;
+ subColor.flags = DoRed | DoGreen | DoBlue;
}
*color = subColor;
}
@@ -2809,22 +2791,22 @@
#elif defined(TOGL_WGL)
static UINT
-Win32AllocColor(const Togl * togl, float red, float green, float blue)
+Win32AllocColor(const Togl *togl, float red, float green, float blue)
{
/* Modified version of XAllocColor emulation of Tk. - returns index,
* instead of color itself - allocates logical palette entry even for
* non-palette devices */
TkWinColormap *cmap = (TkWinColormap *) Tk_Colormap(togl->TkWin);
- UINT index;
+ UINT index;
COLORREF newColor, closeColor;
PALETTEENTRY entry, closeEntry;
- int new, refCount;
+ int new, refCount;
Tcl_HashEntry *entryPtr;
- entry.peRed = (unsigned char)(red * 255 + .5);
- entry.peGreen = (unsigned char)(green * 255 + .5);
- entry.peBlue = (unsigned char)(blue * 255 + .5);
+ entry.peRed = (unsigned char) (red * 255 + .5);
+ entry.peGreen = (unsigned char) (green * 255 + .5);
+ entry.peBlue = (unsigned char) (blue * 255 + .5);
entry.peFlags = 0;
/*
@@ -2841,26 +2823,24 @@
*/
if (newColor != closeColor) {
- if (cmap->size == (unsigned int)togl->CiColormapSize) {
- entry = closeEntry;
- }
- else {
- cmap->size++;
- ResizePalette(cmap->palette, cmap->size);
- index = cmap->size - 1;
- SetPaletteEntries(cmap->palette, index, 1, &entry);
- SelectPalette(togl->tglGLHdc, cmap->palette, TRUE);
- RealizePalette(togl->tglGLHdc);
- }
+ if (cmap->size == (unsigned int) togl->CiColormapSize) {
+ entry = closeEntry;
+ } else {
+ cmap->size++;
+ ResizePalette(cmap->palette, cmap->size);
+ index = cmap->size - 1;
+ SetPaletteEntries(cmap->palette, index, 1, &entry);
+ SelectPalette(togl->tglGLHdc, cmap->palette, TRUE);
+ RealizePalette(togl->tglGLHdc);
+ }
}
newColor = PALETTERGB(entry.peRed, entry.peGreen, entry.peBlue);
- entryPtr = Tcl_CreateHashEntry(&cmap->refCounts, (char *)newColor, &new);
+ entryPtr = Tcl_CreateHashEntry(&cmap->refCounts, (char *) newColor, &new);
if (new) {
- refCount = 1;
+ refCount = 1;
+ } else {
+ refCount = ((int) Tcl_GetHashValue(entryPtr)) + 1;
}
- else {
- refCount = ((int)Tcl_GetHashValue(entryPtr)) + 1;
- }
Tcl_SetHashValue(entryPtr, (ClientData) refCount);
/* for EPS output */
@@ -2870,50 +2850,50 @@
return index;
}
-static void Win32FreeColor(const Togl * togl, unsigned long index)
+static void
+Win32FreeColor(const Togl *togl, unsigned long index)
{
TkWinColormap *cmap = (TkWinColormap *) Tk_Colormap(togl->TkWin);
COLORREF cref;
- UINT count, refCount;
+ UINT count, refCount;
PALETTEENTRY entry, *entries;
Tcl_HashEntry *entryPtr;
if (index >= cmap->size) {
- panic("Tried to free a color that isn't allocated.");
+ panic("Tried to free a color that isn't allocated.");
}
GetPaletteEntries(cmap->palette, index, 1, &entry);
cref = PALETTERGB(entry.peRed, entry.peGreen, entry.peBlue);
- entryPtr = Tcl_FindHashEntry(&cmap->refCounts, (char *)cref);
+ entryPtr = Tcl_FindHashEntry(&cmap->refCounts, (char *) cref);
if (!entryPtr) {
- panic("Tried to free a color that isn't allocated.");
+ panic("Tried to free a color that isn't allocated.");
}
- refCount = (int)Tcl_GetHashValue(entryPtr) - 1;
+ refCount = (int) Tcl_GetHashValue(entryPtr) - 1;
if (refCount == 0) {
- count = cmap->size - index;
- entries = (PALETTEENTRY *) ckalloc(sizeof(PALETTEENTRY) * count);
- GetPaletteEntries(cmap->palette, index + 1, count, entries);
- SetPaletteEntries(cmap->palette, index, count, entries);
- SelectPalette(togl->tglGLHdc, cmap->palette, TRUE);
- RealizePalette(togl->tglGLHdc);
- ckfree((char *)entries);
- cmap->size--;
- Tcl_DeleteHashEntry(entryPtr);
+ count = cmap->size - index;
+ entries = (PALETTEENTRY *) ckalloc(sizeof (PALETTEENTRY) * count);
+ GetPaletteEntries(cmap->palette, index + 1, count, entries);
+ SetPaletteEntries(cmap->palette, index, count, entries);
+ SelectPalette(togl->tglGLHdc, cmap->palette, TRUE);
+ RealizePalette(togl->tglGLHdc);
+ ckfree((char *) entries);
+ cmap->size--;
+ Tcl_DeleteHashEntry(entryPtr);
+ } else {
+ Tcl_SetHashValue(entryPtr, (ClientData) refCount);
}
- else {
- Tcl_SetHashValue(entryPtr, (ClientData) refCount);
- }
}
static void
-Win32SetColor(const Togl * togl,
- unsigned long index, float red, float green, float blue)
+Win32SetColor(const Togl *togl,
+ unsigned long index, float red, float green, float blue)
{
TkWinColormap *cmap = (TkWinColormap *) Tk_Colormap(togl->TkWin);
PALETTEENTRY entry;
- entry.peRed = (unsigned char)(red * 255 + .5);
- entry.peGreen = (unsigned char)(green * 255 + .5);
- entry.peBlue = (unsigned char)(blue * 255 + .5);
+ entry.peRed = (unsigned char) (red * 255 + .5);
+ entry.peGreen = (unsigned char) (green * 255 + .5);
+ entry.peBlue = (unsigned char) (blue * 255 + .5);
entry.peFlags = 0;
SetPaletteEntries(cmap->palette, index, 1, &entry);
SelectPalette(togl->tglGLHdc, cmap->palette, TRUE);
@@ -2928,37 +2908,36 @@
unsigned long
-Togl_AllocColor(const Togl * togl, float red, float green, float blue)
+Togl_AllocColor(const Togl *togl, float red, float green, float blue)
{
if (togl->RgbaFlag) {
- (void)fprintf(stderr,
- "Error: Togl_AllocColor illegal in RGBA mode.\n");
- return 0;
+ (void) fprintf(stderr,
+ "Error: Togl_AllocColor illegal in RGBA mode.\n");
+ return 0;
}
/* TODO: maybe not... */
if (togl->PrivateCmapFlag) {
- (void)fprintf(stderr,
- "Error: Togl_FreeColor illegal with private colormap\n");
- return 0;
+ (void) fprintf(stderr,
+ "Error: Togl_FreeColor illegal with private colormap\n");
+ return 0;
}
#if defined(TOGL_X11)
{
- XColor xcol;
- int exact;
+ XColor xcol;
+ int exact;
- xcol.red = (short)(red * 65535.0);
- xcol.green = (short)(green * 65535.0);
- xcol.blue = (short)(blue * 65535.0);
+ xcol.red = (short) (red * 65535.0);
+ xcol.green = (short) (green * 65535.0);
+ xcol.blue = (short) (blue * 65535.0);
- noFaultXAllocColor(Tk_Display(togl->TkWin), Tk_Colormap(togl->TkWin),
- Tk_Visual(togl->TkWin)->map_entries, &xcol,
- &exact);
- /* for EPS output */
- togl->EpsRedMap[xcol.pixel] = (float)xcol.red / 65535.0;
- togl->EpsGreenMap[xcol.pixel] = (float)xcol.green / 65535.0;
- togl->EpsBlueMap[xcol.pixel] = (float)xcol.blue / 65535.0;
+ noFaultXAllocColor(Tk_Display(togl->TkWin), Tk_Colormap(togl->TkWin),
+ Tk_Visual(togl->TkWin)->map_entries, &xcol, &exact);
+ /* for EPS output */
+ togl->EpsRedMap[xcol.pixel] = (float) xcol.red / 65535.0;
+ togl->EpsGreenMap[xcol.pixel] = (float) xcol.green / 65535.0;
+ togl->EpsBlueMap[xcol.pixel] = (float) xcol.blue / 65535.0;
- return xcol.pixel;
+ return xcol.pixel;
}
#elif defined(TOGL_WGL)
@@ -2973,22 +2952,23 @@
-void Togl_FreeColor(const Togl * togl, unsigned long pixel)
+void
+Togl_FreeColor(const Togl *togl, unsigned long pixel)
{
if (togl->RgbaFlag) {
- (void)fprintf(stderr,
- "Error: Togl_AllocColor illegal in RGBA mode.\n");
- return;
+ (void) fprintf(stderr,
+ "Error: Togl_AllocColor illegal in RGBA mode.\n");
+ return;
}
/* TODO: maybe not... */
if (togl->PrivateCmapFlag) {
- (void)fprintf(stderr,
- "Error: Togl_FreeColor illegal with private colormap\n");
- return;
+ (void) fprintf(stderr,
+ "Error: Togl_FreeColor illegal with private colormap\n");
+ return;
}
#if defined(TOGL_X11)
- (void)XFreeColors(Tk_Display(togl->TkWin), Tk_Colormap(togl->TkWin),
- &pixel, 1, 0);
+ (void) XFreeColors(Tk_Display(togl->TkWin), Tk_Colormap(togl->TkWin),
+ &pixel, 1, 0);
#elif defined(TOGL_WGL)
Win32FreeColor(togl, pixel);
#endif /* TOGL_X11 */
@@ -2997,37 +2977,37 @@
void
-Togl_SetColor(const Togl * togl,
- unsigned long index, float red, float green, float blue)
+Togl_SetColor(const Togl *togl,
+ unsigned long index, float red, float green, float blue)
{
if (togl->RgbaFlag) {
- (void)fprintf(stderr,
- "Error: Togl_AllocColor illegal in RGBA mode.\n");
- return;
+ (void) fprintf(stderr,
+ "Error: Togl_AllocColor illegal in RGBA mode.\n");
+ return;
}
if (!togl->PrivateCmapFlag) {
- (void)fprintf(stderr,
- "Error: Togl_SetColor requires a private colormap\n");
- return;
+ (void) fprintf(stderr,
+ "Error: Togl_SetColor requires a private colormap\n");
+ return;
}
#if defined(TOGL_X11)
{
- XColor xcol;
+ XColor xcol;
- xcol.pixel = index;
- xcol.red = (short)(red * 65535.0);
- xcol.green = (short)(green * 65535.0);
- xcol.blue = (short)(blue * 65535.0);
- xcol.flags = DoRed | DoGreen | DoBlue;
+ xcol.pixel = index;
+ xcol.red = (short) (red * 65535.0);
+ xcol.green = (short) (green * 65535.0);
+ xcol.blue = (short) (blue * 65535.0);
+ xcol.flags = DoRed | DoGreen | DoBlue;
- (void)XStoreColor(Tk_Display(togl->TkWin), Tk_Colormap(togl->TkWin),
- &xcol);
+ (void) XStoreColor(Tk_Display(togl->TkWin), Tk_Colormap(togl->TkWin),
+ &xcol);
- /* for EPS output */
- togl->EpsRedMap[xcol.pixel] = (float)xcol.red / 65535.0;
- togl->EpsGreenMap[xcol.pixel] = (float)xcol.green / 65535.0;
- togl->EpsBlueMap[xcol.pixel] = (float)xcol.blue / 65535.0;
+ /* for EPS output */
+ togl->EpsRedMap[xcol.pixel] = (float) xcol.red / 65535.0;
+ togl->EpsGreenMap[xcol.pixel] = (float) xcol.green / 65535.0;
+ togl->EpsBlueMap[xcol.pixel] = (float) xcol.blue / 65535.0;
}
#elif defined(TOGL_WGL)
Win32SetColor(togl, index, red, green, blue);
@@ -3046,12 +3026,12 @@
typedef struct WinFont
{
- TkFont font; /* Stuff used by generic font package. Must be
- * first in structure. */
- HFONT hFont; /* Windows information about font. */
- HWND hwnd; /* Toplevel window of application that owns
- * this font, used for getting HDC. */
- int widths[256]; /* Widths of first 256 chars in this font. */
+ TkFont font; /* Stuff used by generic font package. Must be
+ * first in structure. */
+ HFONT hFont; /* Windows information about font. */
+ HWND hwnd; /* Toplevel window of application that owns
+ * this font, used for getting HDC. */
+ int widths[256]; /* Widths of first 256 chars in this font. */
} WinFont;
# endif /* TOGL_WGL */
@@ -3067,7 +3047,8 @@
* fontname may be one of the predefined fonts like TOGL_BITMAP_8_BY_13
* or an X font name, or a Windows font name, etc.
*/
-GLuint Togl_LoadBitmapFont(const Togl * togl, const char *fontname)
+GLuint
+Togl_LoadBitmapFont(const Togl *togl, const char *fontname)
{
static Bool FirstTime = True;
@@ -3075,22 +3056,22 @@
XFontStruct *fontinfo;
# elif defined(TOGL_WGL)
WinFont *winfont;
- HFONT oldFont;
+ HFONT oldFont;
TEXTMETRIC tm;
# endif
/* TOGL_X11 */
- int first, last, count;
- GLuint fontbase;
+ int first, last, count;
+ GLuint fontbase;
const char *name;
/* Initialize the ListBase and ListCount arrays */
if (FirstTime) {
- int i;
+ int i;
- for (i = 0; i < MAX_FONTS; i++) {
- ListBase[i] = ListCount[i] = 0;
- }
- FirstTime = False;
+ for (i = 0; i < MAX_FONTS; i++) {
+ ListBase[i] = ListCount[i] = 0;
+ }
+ FirstTime = False;
}
/*
@@ -3098,57 +3079,46 @@
* is a kludge. To be fixed when I find time...
*/
if (fontname == TOGL_BITMAP_8_BY_13) {
- name = "8x13";
+ name = "8x13";
+ } else if (fontname == TOGL_BITMAP_9_BY_15) {
+ name = "9x15";
+ } else if (fontname == TOGL_BITMAP_TIMES_ROMAN_10) {
+ name = "-adobe-times-medium-r-normal--10-100-75-75-p-54-iso8859-1";
+ } else if (fontname == TOGL_BITMAP_TIMES_ROMAN_24) {
+ name = "-adobe-times-medium-r-normal--24-240-75-75-p-124-iso8859-1";
+ } else if (fontname == TOGL_BITMAP_HELVETICA_10) {
+ name = "-adobe-helvetica-medium-r-normal--10-100-75-75-p-57-iso8859-1";
+ } else if (fontname == TOGL_BITMAP_HELVETICA_12) {
+ name = "-adobe-helvetica-medium-r-normal--12-120-75-75-p-67-iso8859-1";
+ } else if (fontname == TOGL_BITMAP_HELVETICA_18) {
+ name = "-adobe-helvetica-medium-r-normal--18-180-75-75-p-98-iso8859-1";
+ } else if (!fontname) {
+ name = DEFAULT_FONTNAME;
+ } else {
+ name = (const char *) fontname;
}
- else if (fontname == TOGL_BITMAP_9_BY_15) {
- name = "9x15";
- }
- else if (fontname == TOGL_BITMAP_TIMES_ROMAN_10) {
- name = "-adobe-times-medium-r-normal--10-100-75-75-p-54-iso8859-1";
- }
- else if (fontname == TOGL_BITMAP_TIMES_ROMAN_24) {
- name = "-adobe-times-medium-r-normal--24-240-75-75-p-124-iso8859-1";
- }
- else if (fontname == TOGL_BITMAP_HELVETICA_10) {
- name =
- "-adobe-helvetica-medium-r-normal--10-100-75-75-p-57-iso8859-1";
- }
- else if (fontname == TOGL_BITMAP_HELVETICA_12) {
- name =
- "-adobe-helvetica-medium-r-normal--12-120-75-75-p-67-iso8859-1";
- }
- else if (fontname == TOGL_BITMAP_HELVETICA_18) {
- name =
- "-adobe-helvetica-medium-r-normal--18-180-75-75-p-98-iso8859-1";
- }
- else if (!fontname) {
- name = DEFAULT_FONTNAME;
- }
- else {
- name = (const char *)fontname;
- }
assert(name);
# if defined(TOGL_X11)
fontinfo = (XFontStruct *) XLoadQueryFont(Tk_Display(togl->TkWin), name);
if (!fontinfo) {
- return 0;
+ return 0;
}
first = fontinfo->min_char_or_byte2;
last = fontinfo->max_char_or_byte2;
# elif defined(TOGL_WGL)
winfont = (WinFont *) Tk_GetFont(togl->Interp, togl->TkWin, name);
if (!winfont) {
- return 0;
+ return 0;
}
oldFont = SelectObject(togl->tglGLHdc, winfont->hFont);
GetTextMetrics(togl->tglGLHdc, &tm);
first = tm.tmFirstChar;
last = tm.tmLastChar;
# elif defined(TOGL_AGL_CLASSIC) || defined(TOGL_AGL)
- first = 10; /* don't know how to determine font range on
- * Mac... */
+ first = 10; /* don't know how to determine font range on
+ * Mac... */
last = 127;
# endif
/* TOGL_X11 */
@@ -3157,36 +3127,36 @@
fontbase = glGenLists((GLuint) (last + 1));
if (fontbase == 0) {
# ifdef TOGL_WGL
- SelectObject(togl->tglGLHdc, oldFont);
- Tk_FreeFont((Tk_Font) winfont);
+ SelectObject(togl->tglGLHdc, oldFont);
+ Tk_FreeFont((Tk_Font) winfont);
# endif
- /* TOGL_WGL */
- return 0;
+ /* TOGL_WGL */
+ return 0;
}
# if defined(TOGL_WGL)
- wglUseFontBitmaps(togl->tglGLHdc, first, count, (int)fontbase + first);
+ wglUseFontBitmaps(togl->tglGLHdc, first, count, (int) fontbase + first);
SelectObject(togl->tglGLHdc, oldFont);
Tk_FreeFont((Tk_Font) winfont);
# elif defined(TOGL_X11)
- glXUseXFont(fontinfo->fid, first, count, (int)fontbase + first);
+ glXUseXFont(fontinfo->fid, first, count, (int) fontbase + first);
# elif defined(TOGL_AGL_CLASSIC) || defined(TOGL_AGL)
- aglUseFont(togl->aglCtx, 1, 0, 14, /* for now, only app font, regular
- * 14-point */
- 10, 118, fontbase + first);
+ aglUseFont(togl->aglCtx, 1, 0, 14, /* for now, only app font, regular
+ * 14-point */
+ 10, 118, fontbase + first);
# endif
/* Record the list base and number of display lists for
* Togl_UnloadBitmapFont(). */
{
- int i;
+ int i;
- for (i = 0; i < MAX_FONTS; i++) {
- if (ListBase[i] == 0) {
- ListBase[i] = fontbase;
- ListCount[i] = last + 1;
- break;
- }
- }
+ for (i = 0; i < MAX_FONTS; i++) {
+ if (ListBase[i] == 0) {
+ ListBase[i] = fontbase;
+ ListCount[i] = last + 1;
+ break;
+ }
+ }
}
return fontbase;
@@ -3197,17 +3167,18 @@
/*
* Release the display lists which were generated by Togl_LoadBitmapFont().
*/
-void Togl_UnloadBitmapFont(const Togl * togl, GLuint fontbase)
+void
+Togl_UnloadBitmapFont(const Togl *togl, GLuint fontbase)
{
- int i;
+ int i;
- (void)togl;
+ (void) togl;
for (i = 0; i < MAX_FONTS; i++) {
- if (ListBase[i] == fontbase) {
- glDeleteLists(ListBase[i], ListCount[i]);
- ListBase[i] = ListCount[i] = 0;
- return;
- }
+ if (ListBase[i] == fontbase) {
+ glDeleteLists(ListBase[i], ListCount[i]);
+ ListBase[i] = ListCount[i] = 0;
+ return;
+ }
}
}
@@ -3219,128 +3190,135 @@
*/
-void Togl_UseLayer(Togl * togl, int layer)
+void
+Togl_UseLayer(Togl *togl, int layer)
{
if (!togl->OverlayWindow)
- return;
+ return;
if (layer == TOGL_OVERLAY) {
#if defined(TOGL_WGL)
- int res = wglMakeCurrent(togl->tglGLHdc, togl->tglGLOverlayHglrc);
+ int res = wglMakeCurrent(togl->tglGLHdc, togl->tglGLOverlayHglrc);
- 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 */
+ /* __sgi STEREO */
#endif /* TOGL_WGL */
- }
- else if (layer == TOGL_NORMAL) {
+ } else if (layer == TOGL_NORMAL) {
#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),
- Tk_WindowId(togl->TkWin), togl->GlCtx);
+ (void) glXMakeCurrent(Tk_Display(togl->TkWin),
+ Tk_WindowId(togl->TkWin), togl->GlCtx);
# if defined(__sgi)
- if (togl->OldStereoFlag)
- oldStereoMakeCurrent(Tk_Display(togl->TkWin),
- Tk_WindowId(togl->TkWin), togl->GlCtx);
+ if (togl->OldStereoFlag)
+ oldStereoMakeCurrent(Tk_Display(togl->TkWin),
+ Tk_WindowId(togl->TkWin), togl->GlCtx);
# endif
- /* __sgi STEREO */
+ /* __sgi STEREO */
#endif /* TOGL_WGL */
+ } else {
+ /* error */
}
- else {
- /* error */
- }
}
-void Togl_ShowOverlay(Togl * togl)
+void
+Togl_ShowOverlay(Togl *togl)
{
-#if defined(TOGL_X11) /* not yet implemented on Windows */
+#if defined(TOGL_X11) /* not yet implemented on Windows */
if (togl->OverlayWindow) {
- (void)XMapWindow(Tk_Display(togl->TkWin), togl->OverlayWindow);
- (void)XInstallColormap(Tk_Display(togl->TkWin), togl->OverlayCmap);
- togl->OverlayIsMapped = True;
+ (void) XMapWindow(Tk_Display(togl->TkWin), togl->OverlayWindow);
+ (void) XInstallColormap(Tk_Display(togl->TkWin), togl->OverlayCmap);
+ togl->OverlayIsMapped = True;
}
#endif /* TOGL_X11 */
}
-void Togl_HideOverlay(Togl * togl)
+void
+Togl_HideOverlay(Togl *togl)
{
if (togl->OverlayWindow && togl->OverlayIsMapped) {
- (void)XUnmapWindow(Tk_Display(togl->TkWin), togl->OverlayWindow);
- togl->OverlayIsMapped = False;
+ (void) XUnmapWindow(Tk_Display(togl->TkWin), togl->OverlayWindow);
+ togl->OverlayIsMapped = False;
}
}
-void Togl_PostOverlayRedisplay(Togl * togl)
+void
+Togl_PostOverlayRedisplay(Togl *togl)
{
if (!togl->OverlayUpdatePending
- && togl->OverlayWindow && togl->OverlayDisplayProc) {
- Tk_DoWhenIdle(RenderOverlay, (ClientData) togl);
- togl->OverlayUpdatePending = True;
+ && togl->OverlayWindow && togl->OverlayDisplayProc) {
+ Tk_DoWhenIdle(RenderOverlay, (ClientData) togl);
+ togl->OverlayUpdatePending = True;
}
}
-void Togl_OverlayDisplayFunc(Togl_Callback * proc)
+void
+Togl_OverlayDisplayFunc(Togl_Callback *proc)
{
DefaultOverlayDisplayProc = proc;
}
-int Togl_ExistsOverlay(const Togl * togl)
+int
+Togl_ExistsOverlay(const Togl *togl)
{
return togl->OverlayFlag;
}
-int Togl_GetOverlayTransparentValue(const Togl * togl)
+int
+Togl_GetOverlayTransparentValue(const Togl *togl)
{
return togl->OverlayTransparentPixel;
}
-int Togl_IsMappedOverlay(const Togl * togl)
+int
+Togl_IsMappedOverlay(const Togl *togl)
{
return togl->OverlayFlag && togl->OverlayIsMapped;
}
unsigned long
-Togl_AllocColorOverlay(const Togl * togl, float red, float green, float blue)
+Togl_AllocColorOverlay(const Togl *togl, float red, float green, float blue)
{
-#if defined(TOGL_X11) /* not yet implemented on Windows */
+#if defined(TOGL_X11) /* not yet implemented on Windows */
if (togl->OverlayFlag && togl->OverlayCmap) {
- XColor xcol;
+ XColor xcol;
- xcol.red = (short)(red * 65535.0);
- xcol.green = (short)(green * 65535.0);
- xcol.blue = (short)(blue * 65535.0);
- if (!XAllocColor(Tk_Display(togl->TkWin), togl->OverlayCmap, &xcol))
- return (unsigned long)-1;
- return xcol.pixel;
+ xcol.red = (short) (red * 65535.0);
+ xcol.green = (short) (green * 65535.0);
+ xcol.blue = (short) (blue * 65535.0);
+ if (!XAllocColor(Tk_Display(togl->TkWin), togl->OverlayCmap, &xcol))
+ return (unsigned long) -1;
+ return xcol.pixel;
}
#endif /* TOGL_X11 */
- return (unsigned long)-1;
+ return (unsigned long) -1;
}
-void Togl_FreeColorOverlay(const Togl * togl, unsigned long pixel)
+void
+Togl_FreeColorOverlay(const Togl *togl, unsigned long pixel)
{
-#if defined(TOGL_X11) /* not yet implemented on Windows */
+#if defined(TOGL_X11) /* not yet implemented on Windows */
if (togl->OverlayFlag && togl->OverlayCmap) {
- (void)XFreeColors(Tk_Display(togl->TkWin), togl->OverlayCmap, &pixel,
- 1, 0);
+ (void) XFreeColors(Tk_Display(togl->TkWin), togl->OverlayCmap, &pixel,
+ 1, 0);
}
#endif /* TOGL_X11 */
}
@@ -3350,19 +3328,22 @@
* User client data
*/
-void Togl_ClientData(ClientData clientData)
+void
+Togl_ClientData(ClientData clientData)
{
DefaultClientData = clientData;
}
-ClientData Togl_GetClientData(const Togl * togl)
+ClientData
+Togl_GetClientData(const Togl *togl)
{
return togl->Client_Data;
}
-void Togl_SetClientData(Togl * togl, ClientData clientData)
+void
+Togl_SetClientData(Togl *togl, ClientData clientData)
{
togl->Client_Data = clientData;
}
@@ -3373,22 +3354,26 @@
* Contributed by Miguel A. De Riera Pasenau (miguel at DALILA.UPC.ES)
*/
-Display *Togl_Display(const Togl * togl)
+Display *
+Togl_Display(const Togl *togl)
{
return Tk_Display(togl->TkWin);
}
-Screen *Togl_Screen(const Togl * togl)
+Screen *
+Togl_Screen(const Togl *togl)
{
return Tk_Screen(togl->TkWin);
}
-int Togl_ScreenNumber(const Togl * togl)
+int
+Togl_ScreenNumber(const Togl *togl)
{
return Tk_ScreenNumber(togl->TkWin);
}
-Colormap Togl_Colormap(const Togl * togl)
+Colormap
+Togl_Colormap(const Togl *togl)
{
return Tk_Colormap(togl->TkWin);
}
@@ -3400,8 +3385,7 @@
* Let's know how many free colors do we have
*/
# if 0
-static unsigned char rojo[] =
- { 4, 39, 74, 110, 145, 181, 216, 251 }, verde[] = {
+static unsigned char rojo[] = { 4, 39, 74, 110, 145, 181, 216, 251 }, verde[] = {
4, 39, 74, 110, 145, 181, 216, 251}, azul[] = {
4, 39, 74, 110, 145, 181, 216, 251};
@@ -3422,53 +3406,54 @@
static int ToglMesaUsedFreeCells = 0;
static int
-get_free_color_cells(Display * display, int screen, Colormap colormap)
+get_free_color_cells(Display *display, int screen, Colormap colormap)
{
if (!ToglMesaUsedPixelCells) {
- XColor xcol;
- int i;
- int colorsfailed, ncolors = XDisplayCells(display, screen);
+ XColor xcol;
+ int i;
+ int colorsfailed, ncolors = XDisplayCells(display, screen);
- long r, g, b;
+ long r, g, b;
- ToglMesaUsedPixelCells =
- (unsigned long *)calloc(ncolors, sizeof(unsigned long));
+ ToglMesaUsedPixelCells =
+ (unsigned long *) calloc(ncolors, sizeof (unsigned long));
- /* Allocate X colors and initialize color_table[], red_table[], etc */
- /* de Mesa 2.1: xmesa1.c setup_dithered_(...) */
- i = colorsfailed = 0;
- for (r = 0; r < RLEVELS; r++)
- for (g = 0; g < GLEVELS; g++)
- for (b = 0; b < BLEVELS; b++) {
- int exact;
+ /* Allocate X colors and initialize color_table[], red_table[], etc */
+ /* de Mesa 2.1: xmesa1.c setup_dithered_(...) */
+ i = colorsfailed = 0;
+ for (r = 0; r < RLEVELS; r++)
+ for (g = 0; g < GLEVELS; g++)
+ for (b = 0; b < BLEVELS; b++) {
+ int exact;
- xcol.red = (r * 65535) / (RLEVELS - 1);
- xcol.green = (g * 65535) / (GLEVELS - 1);
- xcol.blue = (b * 65535) / (BLEVELS - 1);
- noFaultXAllocColor(display, colormap, ncolors,
- &xcol, &exact);
- ToglMesaUsedPixelCells[i++] = xcol.pixel;
- if (!exact) {
- colorsfailed++;
- }
- }
- ToglMesaUsedFreeCells = i;
+ xcol.red = (r * 65535) / (RLEVELS - 1);
+ xcol.green = (g * 65535) / (GLEVELS - 1);
+ xcol.blue = (b * 65535) / (BLEVELS - 1);
+ noFaultXAllocColor(display, colormap, ncolors,
+ &xcol, &exact);
+ ToglMesaUsedPixelCells[i++] = xcol.pixel;
+ if (!exact) {
+ colorsfailed++;
+ }
+ }
+ ToglMesaUsedFreeCells = i;
- XFreeColors(display, colormap, ToglMesaUsedPixelCells,
- ToglMesaUsedFreeCells, 0x00000000);
+ XFreeColors(display, colormap, ToglMesaUsedPixelCells,
+ ToglMesaUsedFreeCells, 0x00000000);
}
return ToglMesaUsedFreeCells;
}
-static void free_default_color_cells(Display * display, Colormap colormap)
+static void
+free_default_color_cells(Display *display, Colormap colormap)
{
if (ToglMesaUsedPixelCells) {
- XFreeColors(display, colormap, ToglMesaUsedPixelCells,
- ToglMesaUsedFreeCells, 0x00000000);
- free(ToglMesaUsedPixelCells);
- ToglMesaUsedPixelCells = NULL;
- ToglMesaUsedFreeCells = 0;
+ XFreeColors(display, colormap, ToglMesaUsedPixelCells,
+ ToglMesaUsedFreeCells, 0x00000000);
+ free(ToglMesaUsedPixelCells);
+ ToglMesaUsedPixelCells = NULL;
+ ToglMesaUsedFreeCells = 0;
}
}
#endif
@@ -3486,27 +3471,26 @@
/* Copyright (c) Mark J. Kilgard, 1996. */
-static GLvoid *grabPixels(int inColor, unsigned int width,
- unsigned int height)
+static GLvoid *
+grabPixels(int inColor, unsigned int width, unsigned int height)
{
GLvoid *buffer;
- GLint swapbytes, lsbfirst, rowlength;
- GLint skiprows, skippixels, alignment;
- GLenum format;
+ GLint swapbytes, lsbfirst, rowlength;
+ GLint skiprows, skippixels, alignment;
+ GLenum format;
unsigned int size;
if (inColor) {
- format = GL_RGB;
- size = width * height * 3;
+ format = GL_RGB;
+ size = width * height * 3;
+ } else {
+ format = GL_LUMINANCE;
+ size = width * height * 1;
}
- else {
- format = GL_LUMINANCE;
- size = width * height * 1;
- }
buffer = (GLvoid *) malloc(size);
if (buffer == NULL)
- return NULL;
+ return NULL;
/* Save current modes. */
glGetIntegerv(GL_PACK_SWAP_BYTES, &swapbytes);
@@ -3527,7 +3511,7 @@
/* Actually read the pixels. */
glReadPixels(0, 0, width, height, format,
- GL_UNSIGNED_BYTE, (GLvoid *) buffer);
+ GL_UNSIGNED_BYTE, (GLvoid *) buffer);
/* Restore saved modes. */
glPixelStorei(GL_PACK_SWAP_BYTES, swapbytes);
@@ -3542,157 +3526,156 @@
static int
generateEPS(const char *filename, int inColor,
- unsigned int width, unsigned int height)
+ unsigned int width, unsigned int height)
{
- FILE *fp;
+ FILE *fp;
GLvoid *pixels;
unsigned char *curpix;
unsigned int components, i;
- int pos;
+ int pos;
unsigned int bitpixel;
pixels = grabPixels(inColor, width, height);
if (pixels == NULL)
- return 1;
+ return 1;
if (inColor)
- components = 3; /* Red, green, blue. */
+ components = 3; /* Red, green, blue. */
else
- components = 1; /* Luminance. */
+ components = 1; /* Luminance. */
fp = fopen(filename, "w");
if (fp == NULL) {
- return 2;
+ return 2;
}
- (void)fprintf(fp, "%%!PS-Adobe-2.0 EPSF-1.2\n");
- (void)fprintf(fp, "%%%%Creator: OpenGL pixmap render output\n");
- (void)fprintf(fp, "%%%%BoundingBox: 0 0 %d %d\n", width, height);
- (void)fprintf(fp, "%%%%EndComments\n");
+ (void) fprintf(fp, "%%!PS-Adobe-2.0 EPSF-1.2\n");
+ (void) fprintf(fp, "%%%%Creator: OpenGL pixmap render output\n");
+ (void) fprintf(fp, "%%%%BoundingBox: 0 0 %d %d\n", width, height);
+ (void) fprintf(fp, "%%%%EndComments\n");
- i = (((width * height) + 7) / 8) / 40; /* # of lines, 40 bytes per
- * line */
- (void)fprintf(fp, "%%%%BeginPreview: %d %d %d %d\n%%", width, height, 1,
- i);
+ i = (((width * height) + 7) / 8) / 40; /* # of lines, 40 bytes per
+ * line */
+ (void) fprintf(fp, "%%%%BeginPreview: %d %d %d %d\n%%", width, height, 1,
+ i);
pos = 0;
- curpix = (unsigned char *)pixels;
+ curpix = (unsigned char *) pixels;
for (i = 0; i < width * height * components;) {
- bitpixel = 0;
- if (inColor) {
- double pix = 0;
+ bitpixel = 0;
+ if (inColor) {
+ double pix = 0;
- pix = 0.30 * (double)curpix[i] + 0.59 * (double)curpix[i + 1] +
- 0.11 * (double)curpix[i + 2];
- i += 3;
- if (pix > 127.0)
- bitpixel |= 0x80;
- pix = 0.30 * (double)curpix[i] + 0.59 * (double)curpix[i + 1] +
- 0.11 * (double)curpix[i + 2];
- i += 3;
- if (pix > 127.0)
- bitpixel |= 0x40;
- pix = 0.30 * (double)curpix[i] + 0.59 * (double)curpix[i + 1] +
- 0.11 * (double)curpix[i + 2];
- i += 3;
- if (pix > 127.0)
- bitpixel |= 0x20;
- pix = 0.30 * (double)curpix[i] + 0.59 * (double)curpix[i + 1] +
- 0.11 * (double)curpix[i + 2];
- i += 3;
- if (pix > 127.0)
- bitpixel |= 0x10;
- pix = 0.30 * (double)curpix[i] + 0.59 * (double)curpix[i + 1] +
- 0.11 * (double)curpix[i + 2];
- i += 3;
- if (pix > 127.0)
- bitpixel |= 0x08;
- pix = 0.30 * (double)curpix[i] + 0.59 * (double)curpix[i + 1] +
- 0.11 * (double)curpix[i + 2];
- i += 3;
- if (pix > 127.0)
- bitpixel |= 0x04;
- pix = 0.30 * (double)curpix[i] + 0.59 * (double)curpix[i + 1] +
- 0.11 * (double)curpix[i + 2];
- i += 3;
- if (pix > 127.0)
- bitpixel |= 0x02;
- pix = 0.30 * (double)curpix[i] + 0.59 * (double)curpix[i + 1] +
- 0.11 * (double)curpix[i + 2];
- i += 3;
- if (pix > 127.0)
- bitpixel |= 0x01;
- }
- else {
- if (curpix[i++] > 0x7f)
- bitpixel |= 0x80;
- if (curpix[i++] > 0x7f)
- bitpixel |= 0x40;
- if (curpix[i++] > 0x7f)
- bitpixel |= 0x20;
- if (curpix[i++] > 0x7f)
- bitpixel |= 0x10;
- if (curpix[i++] > 0x7f)
- bitpixel |= 0x08;
- if (curpix[i++] > 0x7f)
- bitpixel |= 0x04;
- if (curpix[i++] > 0x7f)
- bitpixel |= 0x02;
- if (curpix[i++] > 0x7f)
- bitpixel |= 0x01;
- }
- (void)fprintf(fp, "%02x", bitpixel);
- if (++pos >= 40) {
- (void)fprintf(fp, "\n%%");
- pos = 0;
- }
+ pix = 0.30 * (double) curpix[i] + 0.59 * (double) curpix[i + 1] +
+ 0.11 * (double) curpix[i + 2];
+ i += 3;
+ if (pix > 127.0)
+ bitpixel |= 0x80;
+ pix = 0.30 * (double) curpix[i] + 0.59 * (double) curpix[i + 1] +
+ 0.11 * (double) curpix[i + 2];
+ i += 3;
+ if (pix > 127.0)
+ bitpixel |= 0x40;
+ pix = 0.30 * (double) curpix[i] + 0.59 * (double) curpix[i + 1] +
+ 0.11 * (double) curpix[i + 2];
+ i += 3;
+ if (pix > 127.0)
+ bitpixel |= 0x20;
+ pix = 0.30 * (double) curpix[i] + 0.59 * (double) curpix[i + 1] +
+ 0.11 * (double) curpix[i + 2];
+ i += 3;
+ if (pix > 127.0)
+ bitpixel |= 0x10;
+ pix = 0.30 * (double) curpix[i] + 0.59 * (double) curpix[i + 1] +
+ 0.11 * (double) curpix[i + 2];
+ i += 3;
+ if (pix > 127.0)
+ bitpixel |= 0x08;
+ pix = 0.30 * (double) curpix[i] + 0.59 * (double) curpix[i + 1] +
+ 0.11 * (double) curpix[i + 2];
+ i += 3;
+ if (pix > 127.0)
+ bitpixel |= 0x04;
+ pix = 0.30 * (double) curpix[i] + 0.59 * (double) curpix[i + 1] +
+ 0.11 * (double) curpix[i + 2];
+ i += 3;
+ if (pix > 127.0)
+ bitpixel |= 0x02;
+ pix = 0.30 * (double) curpix[i] + 0.59 * (double) curpix[i + 1] +
+ 0.11 * (double) curpix[i + 2];
+ i += 3;
+ if (pix > 127.0)
+ bitpixel |= 0x01;
+ } else {
+ if (curpix[i++] > 0x7f)
+ bitpixel |= 0x80;
+ if (curpix[i++] > 0x7f)
+ bitpixel |= 0x40;
+ if (curpix[i++] > 0x7f)
+ bitpixel |= 0x20;
+ if (curpix[i++] > 0x7f)
+ bitpixel |= 0x10;
+ if (curpix[i++] > 0x7f)
+ bitpixel |= 0x08;
+ if (curpix[i++] > 0x7f)
+ bitpixel |= 0x04;
+ if (curpix[i++] > 0x7f)
+ bitpixel |= 0x02;
+ if (curpix[i++] > 0x7f)
+ bitpixel |= 0x01;
+ }
+ (void) fprintf(fp, "%02x", bitpixel);
+ if (++pos >= 40) {
+ (void) fprintf(fp, "\n%%");
+ pos = 0;
+ }
}
if (pos)
- (void)fprintf(fp, "\n%%%%EndPreview\n");
+ (void) fprintf(fp, "\n%%%%EndPreview\n");
else
- (void)fprintf(fp, "%%EndPreview\n");
+ (void) fprintf(fp, "%%EndPreview\n");
- (void)fprintf(fp, "gsave\n");
- (void)fprintf(fp, "/bwproc {\n");
- (void)fprintf(fp, " rgbproc\n");
- (void)fprintf(fp, " dup length 3 idiv string 0 3 0\n");
- (void)fprintf(fp, " 5 -1 roll {\n");
- (void)fprintf(fp, " add 2 1 roll 1 sub dup 0 eq\n");
- (void)fprintf(fp, " { pop 3 idiv 3 -1 roll dup 4 -1 roll dup\n");
- (void)fprintf(fp, " 3 1 roll 5 -1 roll put 1 add 3 0 }\n");
- (void)fprintf(fp, " { 2 1 roll } ifelse\n");
- (void)fprintf(fp, " } forall\n");
- (void)fprintf(fp, " pop pop pop\n");
- (void)fprintf(fp, "} def\n");
- (void)fprintf(fp, "systemdict /colorimage known not {\n");
- (void)fprintf(fp, " /colorimage {\n");
- (void)fprintf(fp, " pop\n");
- (void)fprintf(fp, " pop\n");
- (void)fprintf(fp, " /rgbproc exch def\n");
- (void)fprintf(fp, " { bwproc } image\n");
- (void)fprintf(fp, " } def\n");
- (void)fprintf(fp, "} if\n");
- (void)fprintf(fp, "/picstr %d string def\n", width * components);
- (void)fprintf(fp, "%d %d scale\n", width, height);
- (void)fprintf(fp, "%d %d %d\n", width, height, 8);
- (void)fprintf(fp, "[%d 0 0 %d 0 0]\n", width, height);
- (void)fprintf(fp, "{currentfile picstr readhexstring pop}\n");
- (void)fprintf(fp, "false %d\n", components);
- (void)fprintf(fp, "colorimage\n");
+ (void) fprintf(fp, "gsave\n");
+ (void) fprintf(fp, "/bwproc {\n");
+ (void) fprintf(fp, " rgbproc\n");
+ (void) fprintf(fp, " dup length 3 idiv string 0 3 0\n");
+ (void) fprintf(fp, " 5 -1 roll {\n");
+ (void) fprintf(fp, " add 2 1 roll 1 sub dup 0 eq\n");
+ (void) fprintf(fp, " { pop 3 idiv 3 -1 roll dup 4 -1 roll dup\n");
+ (void) fprintf(fp, " 3 1 roll 5 -1 roll put 1 add 3 0 }\n");
+ (void) fprintf(fp, " { 2 1 roll } ifelse\n");
+ (void) fprintf(fp, " } forall\n");
+ (void) fprintf(fp, " pop pop pop\n");
+ (void) fprintf(fp, "} def\n");
+ (void) fprintf(fp, "systemdict /colorimage known not {\n");
+ (void) fprintf(fp, " /colorimage {\n");
+ (void) fprintf(fp, " pop\n");
+ (void) fprintf(fp, " pop\n");
+ (void) fprintf(fp, " /rgbproc exch def\n");
+ (void) fprintf(fp, " { bwproc } image\n");
+ (void) fprintf(fp, " } def\n");
+ (void) fprintf(fp, "} if\n");
+ (void) fprintf(fp, "/picstr %d string def\n", width * components);
+ (void) fprintf(fp, "%d %d scale\n", width, height);
+ (void) fprintf(fp, "%d %d %d\n", width, height, 8);
+ (void) fprintf(fp, "[%d 0 0 %d 0 0]\n", width, height);
+ (void) fprintf(fp, "{currentfile picstr readhexstring pop}\n");
+ (void) fprintf(fp, "false %d\n", components);
+ (void) fprintf(fp, "colorimage\n");
- curpix = (unsigned char *)pixels;
+ curpix = (unsigned char *) pixels;
pos = 0;
for (i = width * height * components; i != 0; i--) {
- (void)fprintf(fp, "%02hx", *curpix++);
- if (++pos >= 40) {
- (void)fprintf(fp, "\n");
- pos = 0;
- }
+ (void) fprintf(fp, "%02hx", *curpix++);
+ if (++pos >= 40) {
+ (void) fprintf(fp, "\n");
+ pos = 0;
+ }
}
if (pos)
- (void)fprintf(fp, "\n");
+ (void) fprintf(fp, "\n");
- (void)fprintf(fp, "grestore\n");
+ (void) fprintf(fp, "grestore\n");
free(pixels);
if (fclose(fp) != 0)
- return 1;
+ return 1;
return 0;
}
@@ -3701,29 +3684,29 @@
* void (*user_redraw)(void)) */
/* changed by GG */
int
-Togl_DumpToEpsFile(const Togl * togl, const char *filename,
- int inColor, void (*user_redraw) (const Togl *))
+Togl_DumpToEpsFile(const Togl *togl, const char *filename,
+ int inColor, void (*user_redraw) (const Togl *))
{
- Bool using_mesa = False;
+ Bool using_mesa = False;
#if 0
- Pixmap eps_pixmap;
+ Pixmap eps_pixmap;
GLXPixmap eps_glxpixmap;
XVisualInfo *vi = togl->VisInfo;
- Window win = Tk_WindowId(togl->TkWin);
+ Window win = Tk_WindowId(togl->TkWin);
#endif
- int retval;
+ int retval;
unsigned int width = togl->Width, height = togl->Height;
#if defined(TOGL_X11)
Display *dpy = Tk_Display(togl->TkWin);
- int scrnum = Tk_ScreenNumber(togl->TkWin);
+ int scrnum = Tk_ScreenNumber(togl->TkWin);
if (strstr(glXQueryServerString(dpy, scrnum, GLX_VERSION), "Mesa"))
- using_mesa = True;
+ using_mesa = True;
else
#endif /* TOGL_X11 */
- using_mesa = False;
+ using_mesa = False;
/* I don't use Pixmap do drawn into, because the code should link with Mesa
* libraries and OpenGL libraries, and the which library we use at run time
* should not matter, but the name of the calls differs one from another:
@@ -3734,11 +3717,11 @@
#if 0
eps_pixmap = XCreatePixmap(dpy, win, width, height, vi->depth);
if (using_mesa)
- eps_glxpixmap =
- glXCreateGLXPixmapMESA(dpy, vi, eps_pixmap,
- Tk_Colormap(togl->TkWin));
+ eps_glxpixmap =
+ glXCreateGLXPixmapMESA(dpy, vi, eps_pixmap,
+ Tk_Colormap(togl->TkWin));
else
- eps_glxpixmap = glXCreateGLXPixmap(dpy, vi, eps_pixmap);
+ eps_glxpixmap = glXCreateGLXPixmap(dpy, vi, eps_pixmap);
glXMakeCurrent(dpy, eps_glxpixmap, togl->GlCtx);
user_redraw();
@@ -3746,31 +3729,30 @@
if (!togl->RgbaFlag) {
#if defined(TOGL_WGL)
- /* Due to the lack of a unique inverse mapping from the frame buffer to
- * the logical palette we need a translation map from the complete
- * logical palette. */
- {
- int n, i;
- TkWinColormap *cmap = (TkWinColormap *) Tk_Colormap(togl->TkWin);
- LPPALETTEENTRY entry =
- malloc(togl->EpsMapSize * sizeof(PALETTEENTRY));
- n = GetPaletteEntries(cmap->palette, 0, togl->EpsMapSize, entry);
- for (i = 0; i < n; i++) {
- togl->EpsRedMap[i] = (GLfloat) (entry[i].peRed / 255.0);
- togl->EpsGreenMap[i] = (GLfloat) (entry[i].peGreen / 255.0);
- togl->EpsBlueMap[i] = (GLfloat) (entry[i].peBlue / 255.0);
- }
- free(entry);
- }
+ /* Due to the lack of a unique inverse mapping from the frame buffer to
+ * the logical palette we need a translation map from the complete
+ * logical palette. */
+ {
+ int n, i;
+ TkWinColormap *cmap = (TkWinColormap *) Tk_Colormap(togl->TkWin);
+ LPPALETTEENTRY entry =
+ malloc(togl->EpsMapSize * sizeof (PALETTEENTRY));
+ n = GetPaletteEntries(cmap->palette, 0, togl->EpsMapSize, entry);
+ for (i = 0; i < n; i++) {
+ togl->EpsRedMap[i] = (GLfloat) (entry[i].peRed / 255.0);
+ togl->EpsGreenMap[i] = (GLfloat) (entry[i].peGreen / 255.0);
+ togl->EpsBlueMap[i] = (GLfloat) (entry[i].peBlue / 255.0);
+ }
+ free(entry);
+ }
#endif /* TOGL_WGL */
- glPixelMapfv(GL_PIXEL_MAP_I_TO_R, togl->EpsMapSize, togl->EpsRedMap);
- glPixelMapfv(GL_PIXEL_MAP_I_TO_G, togl->EpsMapSize,
- togl->EpsGreenMap);
- glPixelMapfv(GL_PIXEL_MAP_I_TO_B, togl->EpsMapSize, togl->EpsBlueMap);
+ glPixelMapfv(GL_PIXEL_MAP_I_TO_R, togl->EpsMapSize, togl->EpsRedMap);
+ glPixelMapfv(GL_PIXEL_MAP_I_TO_G, togl->EpsMapSize, togl->EpsGreenMap);
+ glPixelMapfv(GL_PIXEL_MAP_I_TO_B, togl->EpsMapSize, togl->EpsBlueMap);
}
/* user_redraw(); */
- user_redraw(togl); /* changed by GG */
+ user_redraw(togl); /* changed by GG */
/* glReadBuffer( GL_FRONT); */
/* by default it read GL_BACK in double buffer mode */
glFlush();
@@ -3793,119 +3775,121 @@
static struct stereoStateRec
{
- Bool useSGIStereo;
+ Bool useSGIStereo;
Display *currentDisplay;
- Window currentWindow;
+ Window currentWindow;
GLXContext currentContext;
- GLenum currentDrawBuffer;
- int currentStereoBuffer;
- Bool enabled;
- char *stereoCommand;
- char *restoreCommand;
+ GLenum currentDrawBuffer;
+ int currentStereoBuffer;
+ Bool enabled;
+ char *stereoCommand;
+ char *restoreCommand;
} stereo;
/* call instead of glDrawBuffer */
-void Togl_OldStereoDrawBuffer(GLenum mode)
+void
+Togl_OldStereoDrawBuffer(GLenum mode)
{
if (stereo.useSGIStereo) {
- stereo.currentDrawBuffer = mode;
- switch (mode) {
- case GL_FRONT:
- case GL_BACK:
- case GL_FRONT_AND_BACK:
- /*
- ** Simultaneous drawing to both left and right buffers isn't
- ** really possible if we don't have a stereo capable visual.
- ** For now just fall through and use the left buffer.
- */
- case GL_LEFT:
- case GL_FRONT_LEFT:
- case GL_BACK_LEFT:
- stereo.currentStereoBuffer = STEREO_BUFFER_LEFT;
- break;
- case GL_RIGHT:
- case GL_FRONT_RIGHT:
- stereo.currentStereoBuffer = STEREO_BUFFER_RIGHT;
- mode = GL_FRONT;
- break;
- case GL_BACK_RIGHT:
- stereo.currentStereoBuffer = STEREO_BUFFER_RIGHT;
- mode = GL_BACK;
- break;
- default:
- break;
- }
- if (stereo.currentDisplay && stereo.currentWindow) {
- glXWaitGL(); /* sync with GL command stream before calling X
- */
- XSGISetStereoBuffer(stereo.currentDisplay,
- stereo.currentWindow,
- stereo.currentStereoBuffer);
- glXWaitX(); /* sync with X command stream before calling GL
- */
- }
+ stereo.currentDrawBuffer = mode;
+ switch (mode) {
+ case GL_FRONT:
+ case GL_BACK:
+ case GL_FRONT_AND_BACK:
+ /*
+ ** Simultaneous drawing to both left and right buffers isn't
+ ** really possible if we don't have a stereo capable visual.
+ ** For now just fall through and use the left buffer.
+ */
+ case GL_LEFT:
+ case GL_FRONT_LEFT:
+ case GL_BACK_LEFT:
+ stereo.currentStereoBuffer = STEREO_BUFFER_LEFT;
+ break;
+ case GL_RIGHT:
+ case GL_FRONT_RIGHT:
+ stereo.currentStereoBuffer = STEREO_BUFFER_RIGHT;
+ mode = GL_FRONT;
+ break;
+ case GL_BACK_RIGHT:
+ stereo.currentStereoBuffer = STEREO_BUFFER_RIGHT;
+ mode = GL_BACK;
+ break;
+ default:
+ break;
+ }
+ if (stereo.currentDisplay && stereo.currentWindow) {
+ glXWaitGL(); /* sync with GL command stream before calling X
+ */
+ XSGISetStereoBuffer(stereo.currentDisplay,
+ stereo.currentWindow, stereo.currentStereoBuffer);
+ glXWaitX(); /* sync with X command stream before calling GL
+ */
+ }
}
glDrawBuffer(mode);
}
/* call instead of glClear */
-void Togl_OldStereoClear(GLbitfield mask)
+void
+Togl_OldStereoClear(GLbitfield mask)
{
- GLenum drawBuffer;
+ GLenum drawBuffer;
if (stereo.useSGIStereo) {
- drawBuffer = stereo.currentDrawBuffer;
- switch (drawBuffer) {
- case GL_FRONT:
- Togl_OldStereoDrawBuffer(GL_FRONT_RIGHT);
- glClear(mask);
- Togl_OldStereoDrawBuffer(drawBuffer);
- break;
- case GL_BACK:
- Togl_OldStereoDrawBuffer(GL_BACK_RIGHT);
- glClear(mask);
- Togl_OldStereoDrawBuffer(drawBuffer);
- break;
- case GL_FRONT_AND_BACK:
- Togl_OldStereoDrawBuffer(GL_RIGHT);
- glClear(mask);
- Togl_OldStereoDrawBuffer(drawBuffer);
- break;
- case GL_LEFT:
- case GL_FRONT_LEFT:
- case GL_BACK_LEFT:
- case GL_RIGHT:
- case GL_FRONT_RIGHT:
- case GL_BACK_RIGHT:
- default:
- break;
- }
+ drawBuffer = stereo.currentDrawBuffer;
+ switch (drawBuffer) {
+ case GL_FRONT:
+ Togl_OldStereoDrawBuffer(GL_FRONT_RIGHT);
+ glClear(mask);
+ Togl_OldStereoDrawBuffer(drawBuffer);
+ break;
+ case GL_BACK:
+ Togl_OldStereoDrawBuffer(GL_BACK_RIGHT);
+ glClear(mask);
+ Togl_OldStereoDrawBuffer(drawBuffer);
+ break;
+ case GL_FRONT_AND_BACK:
+ Togl_OldStereoDrawBuffer(GL_RIGHT);
+ glClear(mask);
+ Togl_OldStereoDrawBuffer(drawBuffer);
+ break;
+ case GL_LEFT:
+ case GL_FRONT_LEFT:
+ case GL_BACK_LEFT:
+ case GL_RIGHT:
+ case GL_FRONT_RIGHT:
+ case GL_BACK_RIGHT:
+ default:
+ break;
+ }
}
glClear(mask);
}
-static void oldStereoMakeCurrent(Display * dpy, Window win, GLXContext ctx)
+static void
+oldStereoMakeCurrent(Display *dpy, Window win, GLXContext ctx)
{
if (dpy && (dpy != stereo.currentDisplay)) {
- int event, error;
+ int event, error;
- /* Make sure new Display supports SGIStereo */
- if (XSGIStereoQueryExtension(dpy, &event, &error) == False) {
- dpy = NULL;
- }
+ /* Make sure new Display supports SGIStereo */
+ if (XSGIStereoQueryExtension(dpy, &event, &error) == False) {
+ dpy = NULL;
+ }
}
if (dpy && win && (win != stereo.currentWindow)) {
- /* Make sure new Window supports SGIStereo */
- if (XSGIQueryStereoMode(dpy, win) == X_STEREO_UNSUPPORTED) {
- win = None;
- }
+ /* Make sure new Window supports SGIStereo */
+ if (XSGIQueryStereoMode(dpy, win) == X_STEREO_UNSUPPORTED) {
+ win = None;
+ }
}
if (ctx && (ctx != stereo.currentContext)) {
- GLint drawBuffer;
+ GLint drawBuffer;
- glGetIntegerv(GL_DRAW_BUFFER, &drawBuffer);
- Togl_OldStereoDrawBuffer((GLenum) drawBuffer);
+ glGetIntegerv(GL_DRAW_BUFFER, &drawBuffer);
+ Togl_OldStereoDrawBuffer((GLenum) drawBuffer);
}
stereo.currentDisplay = dpy;
stereo.currentWindow = win;
@@ -3914,7 +3898,8 @@
/* call before using stereo */
-static void oldStereoInit(Togl * togl, int stereoEnabled)
+static void
+oldStereoInit(Togl *togl, int stereoEnabled)
{
stereo.useSGIStereo = stereoEnabled;
stereo.currentDisplay = NULL;
@@ -3930,8 +3915,7 @@
void
Togl_StereoFrustum(GLfloat left, GLfloat right, GLfloat bottom, GLfloat top,
- GLfloat zNear, GLfloat zFar, GLfloat eyeDist,
- GLfloat eyeOffset)
+ GLfloat zNear, GLfloat zFar, GLfloat eyeDist, GLfloat eyeOffset)
{
GLfloat eyeShift = (eyeDist - zNear) * (eyeOffset / eyeDist);
@@ -3967,17 +3951,18 @@
*----------------------------------------------------------------------
*/
-int Togl_MacInit(void)
+int
+Togl_MacInit(void)
{
- int i;
- long result, mask = 0x0700; /* mask = system 7.x */
+ int i;
+ long result, mask = 0x0700; /* mask = system 7.x */
# if GENERATING68K && !GENERATINGCFM
SetApplLimit(GetApplLimit() - (TK_MAC_68K_STACK_GROWTH));
# endif
MaxApplZone();
for (i = 0; i < 4; i++) {
- (void)MoreMasters();
+ (void) MoreMasters();
}
/*
@@ -3994,24 +3979,24 @@
* control panel.
*/
if (TkMacHaveAppearance()) {
- RegisterAppearanceClient();
+ RegisterAppearanceClient();
}
InitGraf(&tcl_macQdPtr->thePort);
InitFonts();
InitWindows();
InitMenus();
- InitDialogs((long)NULL);
+ InitDialogs((long) NULL);
InitCursor();
/*
* Make sure we are running on system 7 or higher
*/
if ((NGetTrapAddress(_Gestalt, ToolTrap) ==
- NGetTrapAddress(_Unimplemented, ToolTrap))
- || (((Gestalt(gestaltSystemVersion, &result) != noErr)
- || (result < mask)))) {
- panic("Tcl/Tk requires System 7 or higher.");
+ NGetTrapAddress(_Unimplemented, ToolTrap))
+ || (((Gestalt(gestaltSystemVersion, &result) != noErr)
+ || (result < mask)))) {
+ panic("Tcl/Tk requires System 7 or higher.");
}
/*
@@ -4019,8 +4004,8 @@
* (this means we can't run on 68000 macs)
*/
if (((Gestalt(gestaltQuickdrawVersion, &result) != noErr)
- || (result < gestalt32BitQD13))) {
- panic("Tk requires Color QuickDraw.");
+ || (result < gestalt32BitQD13))) {
+ panic("Tk requires Color QuickDraw.");
}
FlushEvents(everyEvent, 0);
@@ -4030,7 +4015,8 @@
return TCL_OK;
}
-int Togl_MacSetupMainInterp(Tcl_Interp * interp)
+int
+Togl_MacSetupMainInterp(Tcl_Interp *interp)
{
TkMacInitAppleEvents(interp);
TkMacInitMenus(interp);
Modified: grass/trunk/visualization/nviz/src/togl.h
===================================================================
--- grass/trunk/visualization/nviz/src/togl.h 2008-08-04 21:59:51 UTC (rev 32527)
+++ grass/trunk/visualization/nviz/src/togl.h 2008-08-04 22:32:56 UTC (rev 32528)
@@ -65,7 +65,7 @@
# endif
# ifndef TOGL_USE_FONTS
-# define TOGL_USE_FONTS 1 /* needed for demos */
+# define TOGL_USE_FONTS 1 /* needed for demos */
# endif
# ifdef __cplusplus
@@ -98,98 +98,95 @@
struct Togl;
typedef struct Togl Togl;
-typedef void (Togl_Callback) (Togl * togl);
-typedef int (Togl_CmdProc) (Togl * togl, int argc, CONST84 char *argv[]);
+typedef void (Togl_Callback) (Togl *togl);
+typedef int (Togl_CmdProc) (Togl *togl, int argc, CONST84 char *argv[]);
-TOGL_EXTERN int Togl_Init(Tcl_Interp * interp);
+TOGL_EXTERN int Togl_Init(Tcl_Interp *interp);
/*
* Default/initial callback setup functions
*/
-TOGL_EXTERN void Togl_CreateFunc(Togl_Callback * proc);
-TOGL_EXTERN void Togl_DisplayFunc(Togl_Callback * proc);
-TOGL_EXTERN void Togl_ReshapeFunc(Togl_Callback * proc);
-TOGL_EXTERN void Togl_DestroyFunc(Togl_Callback * proc);
-TOGL_EXTERN void Togl_TimerFunc(Togl_Callback * proc);
+TOGL_EXTERN void Togl_CreateFunc(Togl_Callback *proc);
+TOGL_EXTERN void Togl_DisplayFunc(Togl_Callback *proc);
+TOGL_EXTERN void Togl_ReshapeFunc(Togl_Callback *proc);
+TOGL_EXTERN void Togl_DestroyFunc(Togl_Callback *proc);
+TOGL_EXTERN void Togl_TimerFunc(Togl_Callback *proc);
TOGL_EXTERN void Togl_ResetDefaultCallbacks(void);
/*
* Change callbacks for existing widget
*/
-TOGL_EXTERN void Togl_SetCreateFunc(Togl * togl, Togl_Callback * proc);
-TOGL_EXTERN void Togl_SetDisplayFunc(Togl * togl, Togl_Callback * proc);
-TOGL_EXTERN void Togl_SetReshapeFunc(Togl * togl, Togl_Callback * proc);
-TOGL_EXTERN void Togl_SetDestroyFunc(Togl * togl, Togl_Callback * proc);
-TOGL_EXTERN void Togl_SetTimerFunc(Togl * togl, Togl_Callback * proc);
+TOGL_EXTERN void Togl_SetCreateFunc(Togl *togl, Togl_Callback *proc);
+TOGL_EXTERN void Togl_SetDisplayFunc(Togl *togl, Togl_Callback *proc);
+TOGL_EXTERN void Togl_SetReshapeFunc(Togl *togl, Togl_Callback *proc);
+TOGL_EXTERN void Togl_SetDestroyFunc(Togl *togl, Togl_Callback *proc);
+TOGL_EXTERN void Togl_SetTimerFunc(Togl *togl, Togl_Callback *proc);
/*
* Miscellaneous
*/
-TOGL_EXTERN int Togl_Configure(Tcl_Interp * interp, Togl * togl,
- int argc, const char *argv[], int flags);
-TOGL_EXTERN void Togl_MakeCurrent(const Togl * togl);
-TOGL_EXTERN void Togl_CreateCommand(char *cmd_name, Togl_CmdProc * cmd_proc);
-TOGL_EXTERN void Togl_PostRedisplay(Togl * togl);
-TOGL_EXTERN void Togl_SwapBuffers(const Togl * togl);
+TOGL_EXTERN int Togl_Configure(Tcl_Interp *interp, Togl *togl,
+ int argc, const char *argv[], int flags);
+TOGL_EXTERN void Togl_MakeCurrent(const Togl *togl);
+TOGL_EXTERN void Togl_CreateCommand(char *cmd_name, Togl_CmdProc *cmd_proc);
+TOGL_EXTERN void Togl_PostRedisplay(Togl *togl);
+TOGL_EXTERN void Togl_SwapBuffers(const Togl *togl);
/*
* Query functions
*/
-TOGL_EXTERN const char *Togl_Ident(const Togl * togl);
-TOGL_EXTERN int Togl_Width(const Togl * togl);
-TOGL_EXTERN int Togl_Height(const Togl * togl);
-TOGL_EXTERN Tcl_Interp *Togl_Interp(const Togl * togl);
-TOGL_EXTERN Tk_Window Togl_TkWin(const Togl * togl);
+TOGL_EXTERN const char *Togl_Ident(const Togl *togl);
+TOGL_EXTERN int Togl_Width(const Togl *togl);
+TOGL_EXTERN int Togl_Height(const Togl *togl);
+TOGL_EXTERN Tcl_Interp *Togl_Interp(const Togl *togl);
+TOGL_EXTERN Tk_Window Togl_TkWin(const Togl *togl);
/*
* Color Index mode
*/
-TOGL_EXTERN unsigned long Togl_AllocColor(const Togl * togl, float red,
- float green, float blue);
-TOGL_EXTERN void Togl_FreeColor(const Togl * togl, unsigned long index);
-TOGL_EXTERN void Togl_SetColor(const Togl * togl, unsigned long index,
- float red, float green, float blue);
+TOGL_EXTERN unsigned long Togl_AllocColor(const Togl *togl, float red,
+ float green, float blue);
+TOGL_EXTERN void Togl_FreeColor(const Togl *togl, unsigned long index);
+TOGL_EXTERN void Togl_SetColor(const Togl *togl, unsigned long index,
+ float red, float green, float blue);
# if TOGL_USE_FONTS == 1
/*
* Bitmap fonts
*/
-TOGL_EXTERN GLuint Togl_LoadBitmapFont(const Togl * togl,
- const char *fontname);
-TOGL_EXTERN void Togl_UnloadBitmapFont(const Togl * togl, GLuint fontbase);
+TOGL_EXTERN GLuint Togl_LoadBitmapFont(const Togl *togl, const char *fontname);
+TOGL_EXTERN void Togl_UnloadBitmapFont(const Togl *togl, GLuint fontbase);
# endif
/*
* Overlay functions
*/
-TOGL_EXTERN void Togl_UseLayer(Togl * togl, int layer);
-TOGL_EXTERN void Togl_ShowOverlay(Togl * togl);
-TOGL_EXTERN void Togl_HideOverlay(Togl * togl);
-TOGL_EXTERN void Togl_PostOverlayRedisplay(Togl * togl);
-TOGL_EXTERN void Togl_OverlayDisplayFunc(Togl_Callback * proc);
-TOGL_EXTERN int Togl_ExistsOverlay(const Togl * togl);
-TOGL_EXTERN int Togl_GetOverlayTransparentValue(const Togl * togl);
-TOGL_EXTERN int Togl_IsMappedOverlay(const Togl * togl);
-TOGL_EXTERN unsigned long Togl_AllocColorOverlay(const Togl * togl,
- float red, float green,
- float blue);
-TOGL_EXTERN void Togl_FreeColorOverlay(const Togl * togl,
- unsigned long index);
+TOGL_EXTERN void Togl_UseLayer(Togl *togl, int layer);
+TOGL_EXTERN void Togl_ShowOverlay(Togl *togl);
+TOGL_EXTERN void Togl_HideOverlay(Togl *togl);
+TOGL_EXTERN void Togl_PostOverlayRedisplay(Togl *togl);
+TOGL_EXTERN void Togl_OverlayDisplayFunc(Togl_Callback *proc);
+TOGL_EXTERN int Togl_ExistsOverlay(const Togl *togl);
+TOGL_EXTERN int Togl_GetOverlayTransparentValue(const Togl *togl);
+TOGL_EXTERN int Togl_IsMappedOverlay(const Togl *togl);
+TOGL_EXTERN unsigned long Togl_AllocColorOverlay(const Togl *togl,
+ float red, float green, float blue);
+TOGL_EXTERN void Togl_FreeColorOverlay(const Togl *togl, unsigned long index);
/*
* User client data
*/
TOGL_EXTERN void Togl_ClientData(ClientData clientData);
-TOGL_EXTERN ClientData Togl_GetClientData(const Togl * togl);
-TOGL_EXTERN void Togl_SetClientData(Togl * togl, ClientData clientData);
+TOGL_EXTERN ClientData Togl_GetClientData(const Togl *togl);
+TOGL_EXTERN void Togl_SetClientData(Togl *togl, ClientData clientData);
# ifdef TOGL_X11
/*
@@ -197,10 +194,10 @@
* Contributed by Miguel A. De Riera Pasenau (miguel at DALILA.UPC.ES)
*/
-TOGL_EXTERN Display *Togl_Display(const Togl * togl);
-TOGL_EXTERN Screen *Togl_Screen(const Togl * togl);
-TOGL_EXTERN int Togl_ScreenNumber(const Togl * togl);
-TOGL_EXTERN Colormap Togl_Colormap(const Togl * togl);
+TOGL_EXTERN Display *Togl_Display(const Togl *togl);
+TOGL_EXTERN Screen *Togl_Screen(const Togl *togl);
+TOGL_EXTERN int Togl_ScreenNumber(const Togl *togl);
+TOGL_EXTERN Colormap Togl_Colormap(const Togl *togl);
# endif
# ifdef __sgi
@@ -213,26 +210,24 @@
TOGL_EXTERN void Togl_OldStereoClear(GLbitfield mask);
# endif
-TOGL_EXTERN void Togl_StereoFrustum(GLfloat left, GLfloat right,
- GLfloat bottom, GLfloat top, GLfloat near,
- GLfloat far, GLfloat eyeDist,
- GLfloat eyeOffset);
+TOGL_EXTERN void Togl_StereoFrustum(GLfloat left, GLfloat right, GLfloat bottom,
+ GLfloat top, GLfloat near, GLfloat far, GLfloat eyeDist,
+ GLfloat eyeOffset);
/*
* Generate EPS file.
* Contributed by Miguel A. De Riera Pasenau (miguel at DALILA.UPC.ES)
*/
-TOGL_EXTERN int Togl_DumpToEpsFile(const Togl * togl, const char *filename,
- int inColor,
- void (*user_redraw) (const Togl *));
+TOGL_EXTERN int Togl_DumpToEpsFile(const Togl *togl, const char *filename,
+ int inColor, void (*user_redraw) (const Togl *));
# ifdef TOGL_AGL_CLASSIC
/*
* Mac-specific setup functions
*/
extern int Togl_MacInit(void);
-extern int Togl_MacSetupMainInterp(Tcl_Interp * interp);
+extern int Togl_MacSetupMainInterp(Tcl_Interp *interp);
# endif
# ifdef __cplusplus
More information about the grass-commit
mailing list