-/* $Id: tess.c,v 1.9 1999/09/17 06:34:46 gareth Exp $ */
+/* $Id: tess.c,v 1.10 1999/10/03 00:56:07 gareth Exp $ */
/*
* Mesa 3-D graphics library
* Version: 3.1
- *
+ *
* Copyright (C) 1999 Brian Paul All Rights Reserved.
- *
+ *
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
- *
+ *
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
- *
+ *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
/*
* $Log: tess.c,v $
+ * Revision 1.10 1999/10/03 00:56:07 gareth
+ * Added tessellation winding rule support. Misc bug fixes.
+ *
* Revision 1.9 1999/09/17 06:34:46 gareth
* Winding rule updates.
*
tobj->grid = NULL;
#endif
tobj->cvc_lists = NULL;
+ tobj->user_data = NULL;
+ tobj->label = 0;
tobj->error = GLU_NO_ERROR;
{
/* gluEndPolygon was not called. */
DEBUGP( 0, ( "*** error 3 ***\n" ) );
- tess_error_callback( tobj, GLU_TESS_ERROR3, NULL );
+ tess_error_callback( tobj, GLU_TESS_ERROR3 );
}
/* Delete all internal structures. */
{
/* gluEndPolygon was not called. */
DEBUGP( 0, ( "*** error 3 ***\n" ) );
- tess_error_callback( tobj, GLU_TESS_ERROR3, NULL );
+ tess_error_callback( tobj, GLU_TESS_ERROR3 );
tess_cleanup( tobj );
}
+ tobj->user_data = polygon_data;
+
DEBUGP( 3, ( "<- gluTessBeginPolygon( tobj:%p data:%p )\n", tobj, polygon_data ) );
}
{
/* gluTessEndContour was not called. */
DEBUGP( 0, ( "*** error 4 ***\n" ) );
- tess_error_callback( tobj, GLU_TESS_ERROR4, NULL );
+ tess_error_callback( tobj, GLU_TESS_ERROR4 );
return;
}
(tess_contour_t *) malloc( sizeof(tess_contour_t) ) ) == NULL )
{
DEBUGP( 0, ( "*** memory error ***\n" ) );
- tess_error_callback( tobj, GLU_OUT_OF_MEMORY, NULL );
+ tess_error_callback( tobj, GLU_OUT_OF_MEMORY );
return;
}
{
/* gluTessBeginContour was not called. */
DEBUGP( 0, ( "*** error 2 ***\n" ) );
- tess_error_callback( tobj, GLU_TESS_ERROR2, NULL );
+ tess_error_callback( tobj, GLU_TESS_ERROR2 );
return;
}
malloc( sizeof(tess_vertex_t) ) ) == NULL )
{
DEBUGP( 0, ( "*** memory error ***\n" ) );
- tess_error_callback( tobj, GLU_OUT_OF_MEMORY, NULL );
+ tess_error_callback( tobj, GLU_OUT_OF_MEMORY );
return;
}
last_vertex->angle = 0.0;
last_vertex->label = 0;
+ last_vertex->mark = 0;
last_vertex->next = NULL;
last_vertex->previous = NULL;
malloc( sizeof(tess_vertex_t) ) ) == NULL )
{
DEBUGP( 0, ( "*** memory error ***\n" ) );
- tess_error_callback( tobj, GLU_OUT_OF_MEMORY, NULL );
+ tess_error_callback( tobj, GLU_OUT_OF_MEMORY );
return;
}
vertex->angle = 0.0;
vertex->label = 0;
+ vertex->mark = 0;
vertex->next = NULL;
vertex->previous = last_vertex;
{
/* gluTessBeginContour was not called. */
DEBUGP( 0, ( "*** error 2 ***\n" ) );
- tess_error_callback( tobj, GLU_TESS_ERROR2, NULL );
+ tess_error_callback( tobj, GLU_TESS_ERROR2 );
return;
}
{
/* gluTessBeginPolygon was not called. */
DEBUGP( 0, ( "*** error 1 ***\n" ) );
- tess_error_callback( tobj, GLU_TESS_ERROR1, NULL );
+ tess_error_callback( tobj, GLU_TESS_ERROR1 );
return;
}
TESS_CHECK_ERRORS( tobj );
* tess_error_callback
*
* Internal error handler. Call the user-registered error callback.
+ *
+ * 2nd arg changed from 'errno' to 'errnum' since MSVC defines errnum as
+ * a macro (of all things) and thus breaks the build -tjump
*****************************************************************************/
-/* 2nd arg changed from 'errno' to 'errnum' since MSVC defines errnum as */
-/* a macro (of all things) and thus breaks the build -tjump */
-
-void tess_error_callback( GLUtesselator *tobj, GLenum errnum, void *data )
+void tess_error_callback( GLUtesselator *tobj, GLenum errnum )
{
if ( tobj->error == GLU_NO_ERROR )
{
if ( tobj->callbacks.errorData != NULL )
{
- ( tobj->callbacks.errorData )( errnum, data );
+ ( tobj->callbacks.errorData )( errnum, tobj->user_data );
}
else if ( tobj->callbacks.error != NULL )
{
if ( vb == va ) {
DEBUGP( 0, ( "*** error 7 ***\n" ) );
- tess_error_callback( tobj, GLU_TESS_ERROR7, NULL );
+ tess_error_callback( tobj, GLU_TESS_ERROR7 );
}
SUB_3V( a, vb->coords, va->coords );
}
}
DEBUGP( 0, ( "*** error 7 ***\n" ) );
- tess_error_callback( tobj, GLU_TESS_ERROR7, NULL );
+ tess_error_callback( tobj, GLU_TESS_ERROR7 );
return GLU_ERROR;
}
free( vertex );
vertex = next_vertex;
}
- free( vertex );
+ if ( vertex ) {
+ free( vertex );
+ }
next_contour = current->next;
free( current );
+#ifdef DEBUG
+
/*****************************************************************************
* Debugging output
*****************************************************************************/
-#ifdef DEBUG
-int tess_debug_level = 0;
+int tess_debug_level = -1;
int vdebugstr( char *format_str, ... )
{
va_end( ap );
return 0;
}
+
#endif
-/* $Id: tess.h,v 1.8 1999/09/17 06:31:02 gareth Exp $ */
+/* $Id: tess.h,v 1.9 1999/10/03 00:56:07 gareth Exp $ */
/*
* Mesa 3-D graphics library
* Version: 3.1
- *
+ *
* Copyright (C) 1999 Brian Paul All Rights Reserved.
- *
+ *
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
- *
+ *
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
- *
+ *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
/*
* $Log: tess.h,v $
+ * Revision 1.9 1999/10/03 00:56:07 gareth
+ * Added tessellation winding rule support. Misc bug fixes.
+ *
* Revision 1.8 1999/09/17 06:31:02 gareth
* Winding rule updates.
*
#endif
heap_t *ears;
hashtable_t *cvc_lists;
+ void *user_data;
+ GLuint label;
GLenum error;
};
/*****************************************************************************
* Tessellation error handler:
*****************************************************************************/
-extern void tess_error_callback( GLUtesselator *, GLenum, void * );
+extern void tess_error_callback( GLUtesselator *, GLenum );
/*****************************************************************************
int vdebugstr( char *format_str, ... );
#pragma message( "tess: using DEBUGP for debugging output" )
-#define DEBUGP(level, body) \
+#define DEBUGP( level, body ) \
do { \
if ( tess_debug_level >= level ) { \
vdebugstr( "%11.11s:%-5d ", __FILE__, __LINE__, level ); \
fflush( stderr ); \
} \
} while ( 0 )
-#define DEBUGIF(level) do { if ( tess_debug_level >= level ) {
-#define DEBUGENDIF } } while ( 0 )
+#define DEBUGIF( level ) do { if ( tess_debug_level >= level ) {
+#define DEBUGENDIF } } while ( 0 )
+
#else
-#define DEBUGP(level, body)
-#define DEBUGIF(level) while(0) {
+
+#define DEBUGP( level, body )
+#define DEBUGIF( level ) while(0) {
#define DEBUGENDIF }
+
#endif
#ifdef __cplusplus