aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlecoanet2003-03-17 16:31:05 +0000
committerlecoanet2003-03-17 16:31:05 +0000
commit63c89efed6af65f9faf1b7aa310aa9e3285c9449 (patch)
tree846ad8fa6fad74d996385ce55b6e44238b656027
parent5f7fd52b5abcdf55fad660ba4ae945c8724f318d (diff)
downloadtkzinc-63c89efed6af65f9faf1b7aa310aa9e3285c9449.zip
tkzinc-63c89efed6af65f9faf1b7aa310aa9e3285c9449.tar.gz
tkzinc-63c89efed6af65f9faf1b7aa310aa9e3285c9449.tar.bz2
tkzinc-63c89efed6af65f9faf1b7aa310aa9e3285c9449.tar.xz
* Utilisation de l'ent�te glu.h de libtess au lieu de GLU.
* (WidgetObjCmd): Emp�che de placer un groupe ancetre dans un de ses fils par la commande chggroup. * (Contour): Correction d'une erreur de type sur winding_flag. * Incorporation du test de la variable d'environnement ZINC_GLX_INFO permettant de desactiver les msgs d'info GL. * (Repair): Suppression de la d�pendance � GLU (gluOrtho2D). * (Tkzinc_Init): Compilation pour utiliser tcl et tk avec les stubs, l'init est plus conforme � la norme Tcl actuelle. * (Destroy): Correction d'un core dump du � la tentative de lib�ration d'un context GL en X.
-rw-r--r--generic/tkZinc.c135
1 files changed, 90 insertions, 45 deletions
diff --git a/generic/tkZinc.c b/generic/tkZinc.c
index bdf14d2..433535c 100644
--- a/generic/tkZinc.c
+++ b/generic/tkZinc.c
@@ -54,6 +54,7 @@ static const char compile_id[]="$Compile: " __FILE__ " " __DATE__ " " __TIME__ "
#include "Draw.h"
#include "Color.h"
#include "perfos.h"
+#include "libtess/glu.h"
#include <ctype.h>
#include <stdlib.h>
@@ -63,7 +64,6 @@ static const char compile_id[]="$Compile: " __FILE__ " " __DATE__ " " __TIME__ "
#include <X11/Xatom.h>
#ifdef GLX
#include <GL/glx.h>
-#include <GL/glu.h>
#endif
@@ -313,12 +313,6 @@ SetStringObj(Tcl_Obj *o,
return Tcl_SetStringObj(o, str, strlen(str));
}
-char *
-Tcl_GetString(Tcl_Obj *obj)
-{
- return Tcl_GetStringFromObj(obj, NULL);
-}
-
/*
*----------------------------------------------------------------------
@@ -810,7 +804,9 @@ ZincObjCmd(ClientData client_data, /* Main window associated with
#endif
#if GLX_PRINT_CONFIG
- fprintf(stderr, "GLX version %d.%d\n", major_glx, minor_glx);
+ if (getenv("ZINC_GLX_INFO")) {
+ fprintf(stderr, "GLX version %d.%d\n", major_glx, minor_glx);
+ }
#endif
wi->gl_visual = glXChooseVisual(wi->dpy,
XScreenNumberOfScreen(wi->screen),
@@ -828,24 +824,28 @@ ZincObjCmd(ClientData client_data, /* Main window associated with
}
else {
#ifdef GLX_PRINT_CONFIG
- fprintf(stderr, " Visual : 0x%x, ", (int) wi->gl_visual->visualid);
- glXGetConfig(wi->dpy, wi->gl_visual, GLX_RGBA, &val);
- fprintf(stderr, "RGBA : %d, ", val);
- glXGetConfig(wi->dpy, wi->gl_visual, GLX_DOUBLEBUFFER, &val);
- fprintf(stderr, "Double Buffer : %d, ", val);
- glXGetConfig(wi->dpy, wi->gl_visual, GLX_STENCIL_SIZE, &val);
- fprintf(stderr, "Stencil : %d, ", val);
- glXGetConfig(wi->dpy, wi->gl_visual, GLX_BUFFER_SIZE, &val);
- fprintf(stderr, "depth : %d, ", val);
- glXGetConfig(wi->dpy, wi->gl_visual, GLX_RED_SIZE, &val);
- fprintf(stderr, "red : %d, ", val);
- glXGetConfig(wi->dpy, wi->gl_visual, GLX_GREEN_SIZE, &val);
- fprintf(stderr, "green : %d, ", val);
- glXGetConfig(wi->dpy, wi->gl_visual, GLX_BLUE_SIZE, &val);
- fprintf(stderr, "blue : %d, ", val);
- glXGetConfig(wi->dpy, wi->gl_visual, GLX_ALPHA_SIZE, &val);
- fprintf(stderr, "alpha : %d\n", val);
- fprintf(stderr, " Direct Rendering: %d\n", glXIsDirect(wi->dpy, wi->gl_context));
+ if (getenv("ZINC_GLX_INFO")) {
+ fprintf(stderr, " Visual : 0x%x, ",
+ (int) wi->gl_visual->visualid);
+ glXGetConfig(wi->dpy, wi->gl_visual, GLX_RGBA, &val);
+ fprintf(stderr, "RGBA : %d, ", val);
+ glXGetConfig(wi->dpy, wi->gl_visual, GLX_DOUBLEBUFFER, &val);
+ fprintf(stderr, "Double Buffer : %d, ", val);
+ glXGetConfig(wi->dpy, wi->gl_visual, GLX_STENCIL_SIZE, &val);
+ fprintf(stderr, "Stencil : %d, ", val);
+ glXGetConfig(wi->dpy, wi->gl_visual, GLX_BUFFER_SIZE, &val);
+ fprintf(stderr, "depth : %d, ", val);
+ glXGetConfig(wi->dpy, wi->gl_visual, GLX_RED_SIZE, &val);
+ fprintf(stderr, "red : %d, ", val);
+ glXGetConfig(wi->dpy, wi->gl_visual, GLX_GREEN_SIZE, &val);
+ fprintf(stderr, "green : %d, ", val);
+ glXGetConfig(wi->dpy, wi->gl_visual, GLX_BLUE_SIZE, &val);
+ fprintf(stderr, "blue : %d, ", val);
+ glXGetConfig(wi->dpy, wi->gl_visual, GLX_ALPHA_SIZE, &val);
+ fprintf(stderr, "alpha : %d\n", val);
+ fprintf(stderr, " Direct Rendering: %d\n",
+ glXIsDirect(wi->dpy, wi->gl_context));
+ }
#endif
Tk_SetWindowVisual(wi->win, wi->gl_visual->visual,
24,
@@ -2595,13 +2595,13 @@ Contour(WidgetInfo *wi,
ZnPoint *points;
Item item, shape;
int cmd, num_points, cw, result, i, j, k;
+ int winding_flag, revert = False;
long index;
- char *controls, winding_flag;
+ char *controls;
ZnBool simple=False;
ZnPoly poly;
ZnTransfo t, inv;
ZnContour *contours;
- int revert = False;
/* Keep this array in sync with ZnContourCmd in Types.h */
static CONST char *op_strings[] = {
@@ -3457,7 +3457,7 @@ WidgetObjCmd(ClientData client_data, /* Information about the widget. */
*/
case ZN_W_CHGGROUP:
{
- Item grp;
+ Item grp, scan;
int adjust=0;
ZnTransfo inv, t, t2, *this_one=NULL;
@@ -3473,6 +3473,25 @@ WidgetObjCmd(ClientData client_data, /* Information about the widget. */
if ((result == ZN_ERROR) || (grp == ZN_NO_ITEM)|| (grp->class != ZnGroup)) {
goto error;
}
+ if (item->parent == grp) {
+ /*
+ * Nothing to be done, the item is already in the
+ * target group.
+ */
+ goto done;
+ }
+ /*
+ * Check the ancestors to find if item is an
+ * ancestor of grp, which would lead to a
+ * forbidden move.
+ */
+ for (scan = grp; scan && (scan != item); scan = scan->parent);
+ if (scan == item) {
+ Tcl_AppendResult(interp, "\"", Tcl_GetString(args[3]),
+ "\" is a descendant of \"", Tcl_GetString(args[2]),
+ "\" and can't be used as its parent", NULL);
+ goto error;
+ }
if (argc == 5) {
if (Tcl_GetBooleanFromObj(interp, args[4], &adjust) != ZN_OK) {
goto error;
@@ -5032,6 +5051,7 @@ Configure(Tcl_Interp *interp,/* Used for error reporting. */
if (CONFIG_PROBE(FONT_SPEC) || !wi->font_tfi) {
if (wi->font_tfi) {
ZnFreeTexFont(wi->font_tfi);
+ wi->font_tfi = NULL;
}
if (wi->render) {
wi->font_tfi = ZnGetTexFont(wi, wi->font);
@@ -5040,6 +5060,7 @@ Configure(Tcl_Interp *interp,/* Used for error reporting. */
if (CONFIG_PROBE(MAP_TEXT_FONT_SPEC) || !wi->map_font_tfi) {
if (wi->map_font_tfi) {
ZnFreeTexFont(wi->map_font_tfi);
+ wi->map_font_tfi = NULL;
}
if (wi->render) {
wi->map_font_tfi = ZnGetTexFont(wi, wi->map_text_font);
@@ -5273,12 +5294,20 @@ Event(ClientData client_data, /* Information about widget. */
glGetFloatv(GL_SMOOTH_POINT_SIZE_RANGE, r);
wi->max_point_width = r[1];
#ifdef GLX_PRINT_CONFIG
- fprintf(stderr, "OpenGL version %s\n", (char *) glGetString(GL_VERSION));
- fprintf(stderr, " Moteur de rendu : %s, ", (char *) glGetString(GL_RENDERER));
- fprintf(stderr, " Fabriquant : %s\n", (char *) glGetString(GL_VENDOR));
- fprintf(stderr, " Extensions présentes : %s\n", (char *) glGetString(GL_EXTENSIONS));
- fprintf(stderr, "Max antialiased line width: %g\n", wi->max_line_width);
- fprintf(stderr, "Max antialiased point size: %g\n", wi->max_point_width);
+ if (getenv("ZINC_GLX_INFO")) {
+ fprintf(stderr, "OpenGL version %s\n",
+ (char *) glGetString(GL_VERSION));
+ fprintf(stderr, " Rendering engine: %s, ",
+ (char *) glGetString(GL_RENDERER));
+ fprintf(stderr, " Vendor: %s\n",
+ (char *) glGetString(GL_VENDOR));
+ fprintf(stderr, " Available extensions: %s\n",
+ (char *) glGetString(GL_EXTENSIONS));
+ fprintf(stderr, "Max antialiased line width: %g\n",
+ wi->max_line_width);
+ fprintf(stderr, "Max antialiased point size: %g\n",
+ wi->max_point_width);
+ }
#endif
#endif
}
@@ -6243,11 +6272,13 @@ Destroy(char *mem_ptr) /* Info about the widget. */
FreeChrono(wi->this_draw_chrono);
#ifdef GLX
- if (wi->gl_context) {
- glXDestroyContext(wi->dpy, wi->gl_context);
- }
- if (wi->gl_visual) {
- XFree(wi->gl_visual);
+ if (wi->render) {
+ if (wi->gl_context) {
+ glXDestroyContext(wi->dpy, wi->gl_context);
+ }
+ if (wi->gl_visual) {
+ XFree(wi->gl_visual);
+ }
}
if (wi->tess) {
gluDeleteTess(wi->tess);
@@ -6419,7 +6450,7 @@ Repair(WidgetInfo *wi)
glViewport(0, 0, (GLsizei) int_width, int_height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
- gluOrtho2D(0.0, int_width, int_height, 0.0);
+ glOrtho(0.0, int_width, int_height, 0.0, -1.0, 1.0);
glMatrixMode(GL_MODELVIEW);
#ifdef GLX_DAMAGE
@@ -6797,15 +6828,29 @@ InitZinc(Tcl_Interp *interp) {
int
Tkzinc_Init(Tcl_Interp *interp) /* Used for error reporting. */
{
- if (!Tk_MainWindow(interp)) {
- fprintf(stderr, "Tk main window not created");
- return ZN_ERROR;
+ if (
+#ifdef USE_TCL_STUBS
+ Tcl_InitStubs(interp, "8.2", 0)
+#else
+ Tcl_PkgRequire(interp, "Tcl", "8.2", 0)
+#endif
+ == NULL) {
+ return TCL_ERROR;
+ }
+ if (
+#ifdef USE_TK_STUBS
+ Tk_InitStubs(interp, "8.2", 0)
+#else
+ Tcl_PkgRequire(interp, "Tk", "8.2", 0)
+#endif
+ == NULL) {
+ return TCL_ERROR;
}
/*
* Create additional commands
*/
- if (Tcl_PkgProvide(interp, "zinc", "3.0") == ZN_ERROR) {
+ if (Tcl_PkgProvide(interp, "Tkzinc", "3.2") == ZN_ERROR) {
return ZN_ERROR;
}